|
|
1.1 ! root 1: @class GraphicView; ! 2: ! 3: #define KNOB_DY_ONCE 0x1 ! 4: #define KNOB_DY_TWICE 0x2 ! 5: #define KNOB_DX_ONCE 0x4 ! 6: #define KNOB_DX_TWICE 0x8 ! 7: ! 8: /* corners */ ! 9: ! 10: #define LOWER_LEFT (0x10) ! 11: #define LEFT_SIDE (KNOB_DY_ONCE) ! 12: #define UPPER_LEFT (LEFT_SIDE|KNOB_DY_TWICE) ! 13: #define TOP_SIDE (UPPER_LEFT|KNOB_DX_ONCE) ! 14: #define UPPER_RIGHT (TOP_SIDE|KNOB_DX_TWICE) ! 15: #define BOTTOM_SIDE (KNOB_DX_ONCE) ! 16: #define LOWER_RIGHT (BOTTOM_SIDE|KNOB_DX_TWICE) ! 17: #define RIGHT_SIDE (LOWER_RIGHT|KNOB_DY_ONCE) ! 18: ! 19: /* special corner which means upper right, but also note that we're creating */ ! 20: ! 21: #define CREATE (0x20) ! 22: ! 23: /* corner mask values */ ! 24: ! 25: #define LOWER_LEFT_MASK (1 << LOWER_LEFT) ! 26: #define LEFT_SIDE_MASK (1 << LEFT_SIDE) ! 27: #define UPPER_LEFT_MASK (1 << UPPER_LEFT) ! 28: #define TOP_SIDE_MASK (1 << TOP_SIDE) ! 29: #define UPPER_RIGHT_MASK (1 << UPPER_RIGHT) ! 30: #define BOTTOM_SIDE_MASK (1 << BOTTOM_SIDE) ! 31: #define LOWER_RIGHT_MASK (1 << LOWER_RIGHT) ! 32: #define RIGHT_SIDE_MASK (1 << RIGHT_SIDE) ! 33: #define ALL_CORNERS 0xffffffff ! 34: ! 35: /* arrows */ ! 36: ! 37: #define ARROW_AT_START 1 ! 38: #define ARROW_AT_END 2 ! 39: #define ARROW_AT_BOTH 3 ! 40: ! 41: /* Fills - These must match up with the order in the PopUpList in the Inspector Panel */ ! 42: ! 43: #define FILL_NONE 0 ! 44: #define FILL_EO 1 ! 45: #define FILL_NZWR 2 ! 46: ! 47: extern id CrossCursor; ! 48: ! 49: @interface Graphic : Object ! 50: { ! 51: NXRect bounds; /* the bounds */ ! 52: float linewidth; /* linewidth */ ! 53: struct _gFlags { ! 54: #ifdef __BIG_ENDIAN__ ! 55: unsigned int selected:1; /* whether selected */ ! 56: unsigned int active:1; /* whether to really draw in draw: */ ! 57: unsigned int eofill:1; /* whether eofilled */ ! 58: unsigned int fillColorSet:1; /* whether to put frame around fill */ ! 59: unsigned int downhill:1; /* Line: direction line goes */ ! 60: unsigned int initialized:1; /* subclass specific */ ! 61: unsigned int linewidthSet:1; /* used when archiving only */ ! 62: unsigned int lineColorSet:1; /* used when archiving only */ ! 63: unsigned int linejoin:2; /* line join */ ! 64: unsigned int linecap:2; /* line cap */ ! 65: unsigned int fill:1; /* whether filled */ ! 66: unsigned int locked:1; /* locked down? */ ! 67: unsigned int arrow:2; /* arrow position */ ! 68: unsigned int nooutline:1; /* whether the graphic is outlined */ ! 69: unsigned int isFormEntry:1; /* whether the graphic is a form entry (TextGraphic only) */ ! 70: unsigned int localizeFormEntry:1; /* whether to localize a form entry (TextGraphic only) */ ! 71: unsigned int mightBeLinked:1; /* set if Graphic has ever had a link associated with it */ ! 72: unsigned int padding:12; ! 73: #else ! 74: unsigned int padding:12; ! 75: unsigned int mightBeLinked:1; /* set if Graphic has ever had a link associated with it */ ! 76: unsigned int localizeFormEntry:1; /* whether to localize a form entry (TextGraphic only) */ ! 77: unsigned int isFormEntry:1; /* whether the graphic is a form entry (TextGraphic only) */ ! 78: unsigned int nooutline:1; /* whether the graphic is outlined */ ! 79: unsigned int arrow:2; /* arrow position */ ! 80: unsigned int locked:1; /* locked down? */ ! 81: unsigned int fill:1; /* whether filled */ ! 82: unsigned int linecap:2; /* line cap */ ! 83: unsigned int linejoin:2; /* line join */ ! 84: unsigned int lineColorSet:1; /* used when archiving only */ ! 85: unsigned int linewidthSet:1; /* used when archiving only */ ! 86: unsigned int initialized:1; /* subclass specific */ ! 87: unsigned int downhill:1; /* Line: direction line goes */ ! 88: unsigned int fillColorSet:1; /* whether to put frame around fill */ ! 89: unsigned int eofill:1; /* whether eofilled */ ! 90: unsigned int active:1; /* whether to really draw in draw: */ ! 91: unsigned int selected:1; /* whether selected */ ! 92: #endif ! 93: } gFlags; ! 94: NXColor *lineColor; ! 95: NXColor *fillColor; ! 96: int identifier; /* unique identifier */ ! 97: } ! 98: ! 99: /* Factory methods */ ! 100: ! 101: + showFastKnobFills; ! 102: + initialize; ! 103: + (BOOL)isEditable; ! 104: + cursor; ! 105: ! 106: + (int)currentGraphicIdentifier; ! 107: + updateCurrentGraphicIdentifier:(int)newMaxIdentifier; ! 108: ! 109: /* Initialization method */ ! 110: ! 111: - init; ! 112: ! 113: /* Called when a GraphicView is unarchived */ ! 114: ! 115: - awake; ! 116: ! 117: /* Private methods (for subclassers only) */ ! 118: ! 119: - setGraphicsState; ! 120: - setLineColor; ! 121: - setFillColor; ! 122: - (int)cornerMask; ! 123: ! 124: /* Data link methods */ ! 125: ! 126: - setLink:(NXDataLink *)aLink; ! 127: - (NXDataLink *)link; ! 128: - (Graphic *)graphicLinkedBy:(NXDataLink *)aLink; ! 129: - reviveLink:(NXDataLinkManager *)linkManager; ! 130: - (NXSelection *)selection; ! 131: - (BOOL)mightBeLinked; ! 132: - readLinkFromPasteboard:(Pasteboard *)pboard usingManager:(NXDataLinkManager *)linkManager useNewIdentifier:(BOOL)useNewIdentifier; ! 133: ! 134: /* Notification from GraphicView */ ! 135: ! 136: - wasRemovedFrom:(GraphicView *)sender; ! 137: - wasAddedTo:(GraphicView *)sender; ! 138: ! 139: /* Methods for uniquely identifying a Graphic. */ ! 140: ! 141: - resetIdentifier; ! 142: - (int)identifier; ! 143: - writeIdentifierTo:(char *)buffer; ! 144: - (Graphic *)graphicIdentifiedBy:(int)anIdentifier; ! 145: ! 146: /* Event handling */ ! 147: ! 148: - (BOOL)handleEvent:(NXEvent *)event at:(const NXPoint *)p inView:(View *)view; ! 149: ! 150: /* Number of Graphics this Graphic represents (1 for non-Group). */ ! 151: ! 152: - (int)graphicCount; ! 153: ! 154: /* Public routines (called mostly by a GraphicView or subclassers). */ ! 155: ! 156: - (const char *)title; ! 157: - (BOOL)isSelected; ! 158: - (BOOL)isActive; ! 159: - (BOOL)isLocked; ! 160: - select; ! 161: - deselect; ! 162: - activate; ! 163: - deactivate; ! 164: - lock; ! 165: - unlock; ! 166: ! 167: - (BOOL)isFormEntry; ! 168: - setFormEntry:(int)flag; ! 169: - (BOOL)hasFormEntries; ! 170: - (BOOL)writeFormEntryToStream:(NXStream *)stream; ! 171: ! 172: - setCacheable:(BOOL)flag; ! 173: - (BOOL)isCacheable; ! 174: ! 175: - getBounds:(NXRect *)theRect; ! 176: - setBounds:(const NXRect *)aRect; ! 177: - (NXRect *)getExtendedBounds:(NXRect *)theRect; ! 178: ! 179: - (int)knobHit:(const NXPoint *)point; ! 180: ! 181: - draw:(const NXRect *)rect; ! 182: ! 183: - (BOOL)canEmitEPS; ! 184: - (BOOL)canEmitTIFF; ! 185: ! 186: - moveLeftEdgeTo:(const NXCoord *)x; ! 187: - moveRightEdgeTo:(const NXCoord *)x; ! 188: - moveTopEdgeTo:(const NXCoord *)y; ! 189: - moveBottomEdgeTo:(const NXCoord *)y; ! 190: - moveHorizontalCenterTo:(const NXCoord *)x; ! 191: - moveVerticalCenterTo:(const NXCoord *)y; ! 192: - moveBaselineTo:(const NXCoord *)y; ! 193: - (NXCoord)baseline; ! 194: ! 195: - moveBy:(const NXPoint *)offset; ! 196: - moveTo:(const NXPoint *)p; ! 197: - centerAt:(const NXPoint *)center; ! 198: - sizeTo:(const NXSize *)size; ! 199: - sizeToNaturalAspectRatio; ! 200: - alignToGrid:(GraphicView *)graphicView; ! 201: - sizeToGrid:(GraphicView *)graphicView; ! 202: ! 203: /* Compatibility methods */ ! 204: ! 205: - replaceWithImage; ! 206: ! 207: /* Public routines (called mostly by inspectors and the like). */ ! 208: ! 209: - setLineWidth:(const float *)value; ! 210: - (float)lineWidth; ! 211: - setLineColor:(const NXColor *)color; ! 212: - (Graphic *)colorAcceptorAt:(const NXPoint *)point; ! 213: - (NXColor)lineColor; ! 214: - setFillColor:(const NXColor *)color; ! 215: - (NXColor)fillColor; ! 216: - changeFont:sender; ! 217: - (Font *)font; ! 218: - setGray:(const float *)value; ! 219: - (float)gray; ! 220: - setFill:(int)mode; ! 221: - (int)fill; ! 222: - setOutlined:(BOOL)outlinedFlag; ! 223: - (BOOL)isOutlined; ! 224: - setLineCap:(int)capValue; ! 225: - (int)lineCap; ! 226: - setLineArrow:(int)arrowValue; ! 227: - (int)lineArrow; ! 228: - setLineJoin:(int)joinValue; ! 229: - (int)lineJoin; ! 230: ! 231: /* Archiving (must be overridden by subclasses with instance variables) */ ! 232: ! 233: - write:(NXTypedStream *)stream; ! 234: - read:(NXTypedStream *)stream; ! 235: ! 236: /* Routines intended to be subclassed for different types of Graphics. */ ! 237: ! 238: /* ! 239: * Can be overridden to provide more sophisticated size constraining ! 240: * than an aspect ratio (though that is almost always sufficient). ! 241: * For example, Line overrides this to constrain to closes 15 degree angle. ! 242: * constrainByDefault says whether constraining is the default or not for ! 243: * the receiving kind of Graphic. ! 244: */ ! 245: ! 246: - (BOOL)constrainByDefault; ! 247: - constrainCorner:(int)corner toAspectRatio:(float)aspect; ! 248: ! 249: /* ! 250: * Can be overridden to resize the Graphic differently than the ! 251: * default (which is to drag out the bounds), or to do something ! 252: * before and/or after the subclass is resized. This is called ! 253: * during the default creation method as well (create:in:). ! 254: */ ! 255: ! 256: - resize:(NXEvent *)event by:(int)corner in:(GraphicView *)view; ! 257: ! 258: /* ! 259: * Possible override candidate for different types of Graphics. ! 260: * Should return YES if the Graphic got created okay. ! 261: * The most common need to override this method is if the creation ! 262: * of the Graphic requires multiple mouseUps and mouseDowns (for ! 263: * an arbitrary arc, for example). ! 264: */ ! 265: ! 266: - (BOOL)create:(NXEvent *)event in:(GraphicView *)view; ! 267: ! 268: /* ! 269: * Override hit: if you want your subclass to only get selected when the ! 270: * mouse goes down in certain parts of the bounds (not the whole bounds). ! 271: * e.g. Lines only get selected if you click close to them. ! 272: */ ! 273: ! 274: - (BOOL)hit:(const NXPoint *)point; ! 275: ! 276: /* ! 277: * Returns YES if this Graphic can't be seen through. ! 278: * Default behaviour is to return YES if the Graphic isFilled. ! 279: */ ! 280: ! 281: - (BOOL)isOpaque; ! 282: ! 283: /* ! 284: * Returns YES if the Graphic is properly formed (usually this just ! 285: * refers to whether it is big enough to be a real graphic during creation). ! 286: * This is called by create:in:. By default it returns YES if the Graphic ! 287: * is at least 10.0 by 10.0 pixels in size. ! 288: */ ! 289: ! 290: - (BOOL)isValid; ! 291: ! 292: /* ! 293: * This is the Graphic's natural aspect ratio. If it doesn't have a natural ! 294: * aspect ratio, then this method should return zero (the default return). ! 295: */ ! 296: ! 297: - (float)naturalAspectRatio; ! 298: ! 299: /* ! 300: * Called repeatedly as the user drags the mouse to create or resize ! 301: * the Graphic. The default implementation does the right thing. ! 302: * The specified corner should be moved to the specified point. ! 303: */ ! 304: ! 305: - (int)moveCorner:(int)corner to:(const NXPoint *)point constrain:(BOOL)flag; ! 306: ! 307: /* ! 308: * This routine actually draws the graphic. It should be draw to fit the ! 309: * bounds instance variable. Be sure to use all the parameters listed in ! 310: * the instance variable list (e.g. linewidth, fillgray, etc.) that are ! 311: * appropriate to this object. It is probably a good idea to do a newpath ! 312: * and a closepath at the beginning and the end of draw. ! 313: * If a sublcass just wants to draw a unit-sized version of itself ! 314: * (i.e. it draws itself in a bounding box of {{0.0,0.0},{1.0,1.0}}) ! 315: * it can just override unitDraw (and not draw). ! 316: */ ! 317: ! 318: - unitDraw; ! 319: - draw; ! 320: ! 321: /* ! 322: * Should return YES iff the Graphic can be "edited." It is up to the ! 323: * subclass of Graphic to determine what this means for it. Usually ! 324: * it means that it has text and allows that text to be edited by the ! 325: * user (e.g. TextGraphic). Default is to do nothing and return NO. ! 326: */ ! 327: ! 328: - (BOOL)edit:(NXEvent *)event in:(View *)view; ! 329: ! 330: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.