home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Examples / AppKit / Draw / Rectangle.m < prev    next >
Text File  |  1995-09-04  |  1KB  |  48 lines

  1. #import "draw.h"
  2.  
  3. @implementation Rectangle : Graphic
  4. /*
  5.  * This is the canonical Graphic.
  6.  * It doesn't get much simpler than this.
  7.  *
  8.  * This line is just a stub to get genstrings to generate
  9.  * a .strings file entry for the name of this type of Graphic.
  10.  * The name is used in the Undo New <Whatever> menu item.
  11.  *
  12.  * NSLocalString("Rectangle", NULL, "Name of the tool that draws rectangles, i.e., the %@ of the New %@ operation.")
  13.  */
  14.  
  15. /* Methods overridden from superclass */
  16.  
  17. - (float)naturalAspectRatio
  18. /*
  19.  * The natural aspect ratio of a rectangle is 1.0 (a square).
  20.  */
  21. {
  22.     return 1.0;
  23. }
  24.  
  25. - (Graphic *)colorAcceptorAt:(NSPoint)point
  26. {
  27.     if ([self hit:point]) return self;
  28.     return nil;
  29. }
  30.  
  31. - draw
  32. {
  33.     if (bounds.size.width < 1.0 || bounds.size.height < 1.0) return self;
  34.  
  35.     if ([self fill]) {
  36.     [self setFillColor];
  37.     NSRectFill(bounds);
  38.     }
  39.     if (!gFlags.nooutline) {
  40.     [self setLineColor];
  41.     PSrectstroke(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
  42.     }
  43.  
  44.     return self;
  45. }
  46.  
  47. @end
  48.