home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / NSView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-09  |  9.4 KB  |  293 lines

  1. /*
  2.     NSView.h
  3.     Application Kit
  4.     Copyright (c) 1994-1996, NeXT Software, Inc.
  5.     All rights reserved.
  6. */
  7.  
  8. #import <Foundation/Foundation.h>
  9. #import <AppKit/NSWindow.h>
  10. #import <AppKit/NSScreen.h>
  11. #import <AppKit/AppKitDefines.h>
  12.  
  13. @class NSCursor;
  14. @class NSScrollView;
  15.  
  16. enum {
  17.     NSViewNotSizable            =  0,
  18.     NSViewMinXMargin            =  1,
  19.     NSViewWidthSizable            =  2,
  20.     NSViewMaxXMargin            =  4,
  21.     NSViewMinYMargin            =  8,
  22.     NSViewHeightSizable            = 16,
  23.     NSViewMaxYMargin            = 32
  24. };
  25.  
  26. typedef enum _NSBorderType {
  27.     NSNoBorder                = 0,
  28.     NSLineBorder            = 1,
  29.     NSBezelBorder            = 2,
  30.     NSGrooveBorder            = 3
  31. } NSBorderType;
  32.  
  33. typedef struct __VFlags {
  34. #ifdef __BIG_ENDIAN__
  35.     unsigned int        rotatedFromBase:1;
  36.     unsigned int        rotatedOrScaledFromBase:1;
  37.     unsigned int        autosizing:6;
  38.     unsigned int        autoresizeSubviews:1;
  39.     unsigned int        wantsGState:1;
  40.     unsigned int        needsDisplay:1;
  41.     unsigned int        validGState:1;
  42.     unsigned int        newGState:1;
  43.     unsigned int        noVerticalAutosizing:1;
  44.     unsigned int        frameChangeNotesSuspended:1;
  45.     unsigned int        needsFrameChangeNote:1;
  46.     unsigned int        focusChangeNotesSuspended:1;
  47.     unsigned int        boundsChangeNotesSuspended:1;
  48.     unsigned int        needsBoundsChangeNote:1;
  49.     unsigned int        removingWithoutInvalidation:1;
  50.         unsigned int        interfaceStyle0:1;
  51.     unsigned int        needsDisplayForBounds:1;
  52.     unsigned int        specialArchiving:1;
  53.     unsigned int        interfaceStyle1:1;
  54.     unsigned int        retainCount:6;
  55.     unsigned int        retainCountOverMax:1;
  56.     unsigned int        aboutToResize:1;
  57. #else
  58.     unsigned int        aboutToResize:1;
  59.     unsigned int        retainCountOverMax:1;
  60.     unsigned int        retainCount:6;
  61.     unsigned int        interfaceStyle1:1;
  62.     unsigned int        specialArchiving:1;
  63.     unsigned int        needsDisplayForBounds:1;
  64.     unsigned int        interfaceStyle0:1;
  65.         unsigned int        removingWithoutInvalidation:1;
  66.     unsigned int        needsBoundsChangeNote:1;
  67.     unsigned int        boundsChangeNotesSuspended:1;
  68.     unsigned int        focusChangeNotesSuspended:1;
  69.     unsigned int        needsFrameChangeNote:1;
  70.     unsigned int        frameChangeNotesSuspended:1;
  71.     unsigned int        noVerticalAutosizing:1;
  72.     unsigned int        newGState:1;
  73.     unsigned int        validGState:1;
  74.     unsigned int        needsDisplay:1;
  75.     unsigned int        wantsGState:1;
  76.     unsigned int        autoresizeSubviews:1;
  77.     unsigned int        autosizing:6;
  78.     unsigned int        rotatedOrScaledFromBase:1;
  79.     unsigned int        rotatedFromBase:1;
  80. #endif
  81. } _VFlags;
  82.  
  83. typedef int NSTrackingRectTag;
  84.  
  85. @class NSEvent;
  86.  
  87. @interface NSView : NSResponder
  88. {
  89.     NSRect              _frame;
  90.     NSRect              _bounds;
  91.     id                  _superview;
  92.     NSMutableArray      *_subviews;
  93.     NSWindow            *_window;
  94.     int                 _gState;
  95.     id                  _frameMatrix;
  96.     id            _drawMatrix;
  97.     NSMutableSet    *_dragTypes;
  98.     NSRect        *_errorOffsets;
  99.     _VFlags        _vFlags;
  100.     struct __VFlags2 {
  101.     unsigned int    nextKeyViewRefCount:14;
  102.     unsigned int    previousKeyViewRefCount:14;
  103.     unsigned int    clippedFocus:1;
  104.     unsigned int    reserved:3;
  105.     } _vFlags2;
  106. }
  107.  
  108.  
  109. - (id)initWithFrame:(NSRect)frameRect;
  110.  
  111. - (NSWindow *)window;
  112. - (NSView *)superview;
  113. - (NSArray *)subviews;
  114. - (BOOL)isDescendantOf:(NSView *)aView;
  115. - (NSView *)ancestorSharedWithView:(NSView *)aView;
  116. - (NSView *)opaqueAncestor;
  117. - (void)addSubview:(NSView *)aView;
  118. - (void)addSubview:(NSView *)aView positioned:(NSWindowOrderingMode)place relativeTo:(NSView *)otherView;
  119. - (void)sortSubviewsUsingFunction:(int (*)(id, id, void *))compare context:(void *)context;
  120. - (void)viewWillMoveToWindow:(NSWindow *)newWindow;
  121. - (void)viewWillMoveToSuperview:(NSView *)newSuperview;
  122. - (void)removeFromSuperview;
  123. - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
  124. #ifndef STRICT_OPENSTEP
  125. - (void)removeFromSuperviewWithoutNeedingDisplay;
  126. #endif
  127.  
  128. - (void)setPostsFrameChangedNotifications:(BOOL)flag;
  129. - (BOOL)postsFrameChangedNotifications;
  130. - (void)resizeSubviewsWithOldSize:(NSSize)oldSize;
  131. - (void)resizeWithOldSuperviewSize:(NSSize)oldSize;
  132. - (void)setAutoresizesSubviews:(BOOL)flag;
  133. - (BOOL)autoresizesSubviews;
  134. - (void)setAutoresizingMask:(unsigned int)mask;
  135. - (unsigned int)autoresizingMask;
  136.  
  137. - (void)setFrameOrigin:(NSPoint)newOrigin;
  138. - (void)setFrameSize:(NSSize)newSize;
  139. - (void)setFrame:(NSRect)frameRect;
  140. - (NSRect)frame;
  141. - (void)setFrameRotation:(float)angle;
  142. - (float)frameRotation;
  143.  
  144. - (void)setBoundsOrigin:(NSPoint)newOrigin;
  145. - (void)setBoundsSize:(NSSize)newSize;
  146. - (void)setBoundsRotation:(float)angle;
  147. - (float)boundsRotation;
  148. - (void)translateOriginToPoint:(NSPoint)translation;
  149. - (void)scaleUnitSquareToSize:(NSSize)newUnitSize;
  150. - (void)rotateByAngle:(float)angle;
  151. - (void)setBounds:(NSRect)aRect;
  152. - (NSRect)bounds;
  153.  
  154. - (BOOL)isFlipped;
  155. - (BOOL)isRotatedFromBase;
  156. - (BOOL)isRotatedOrScaledFromBase;
  157. - (BOOL)isOpaque;
  158.  
  159. - (NSPoint)convertPoint:(NSPoint)aPoint fromView:(NSView *)aView;
  160. - (NSPoint)convertPoint:(NSPoint)aPoint toView:(NSView *)aView;
  161. - (NSSize)convertSize:(NSSize)aSize fromView:(NSView *)aView;
  162. - (NSSize)convertSize:(NSSize)aSize toView:(NSView *)aView;
  163. - (NSRect)convertRect:(NSRect)aRect fromView:(NSView *)aView;
  164. - (NSRect)convertRect:(NSRect)aRect toView:(NSView *)aView;
  165. - (NSRect)centerScanRect:(NSRect)aRect;
  166.  
  167. - (BOOL)canDraw;
  168. - (void)setNeedsDisplay:(BOOL)flag;
  169. - (void)setNeedsDisplayInRect:(NSRect)invalidRect;
  170. - (BOOL)needsDisplay;
  171. - (void)lockFocus;
  172. - (void)unlockFocus;
  173. + (NSView *)focusView;
  174. - (NSRect)visibleRect;
  175.  
  176. - (void)display;
  177. - (void)displayIfNeeded;
  178. - (void)displayIfNeededIgnoringOpacity;
  179. - (void)displayRect:(NSRect)rect;
  180. - (void)displayIfNeededInRect:(NSRect)rect;
  181. - (void)displayRectIgnoringOpacity:(NSRect)rect;
  182. - (void)displayIfNeededInRectIgnoringOpacity:(NSRect)rect;
  183. - (void)drawRect:(NSRect)rect;
  184.  
  185. - (int)gState;
  186. - (void)allocateGState;
  187. - (void)releaseGState;
  188. - (void)setUpGState;
  189. - (void)renewGState;
  190.  
  191. - (void)scrollPoint:(NSPoint)aPoint;
  192. - (BOOL)scrollRectToVisible:(NSRect)aRect;
  193. - (BOOL)autoscroll:(NSEvent *)theEvent;
  194. - (NSRect)adjustScroll:(NSRect)newVisible;
  195. - (void)scrollRect:(NSRect)aRect by:(NSSize)delta;
  196.  
  197. - (NSView *)hitTest:(NSPoint)aPoint;
  198. - (BOOL)mouse:(NSPoint)aPoint inRect:(NSRect)aRect;
  199. - (id)viewWithTag:(int)aTag;
  200. - (int)tag;
  201. - (BOOL)performKeyEquivalent:(NSEvent *)theEvent;
  202. - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
  203. - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent;
  204. - (BOOL)needsPanelToBecomeKey;
  205.  
  206. - (void)addCursorRect:(NSRect)aRect cursor:(NSCursor *)anObj;
  207. - (void)removeCursorRect:(NSRect)aRect cursor:(NSCursor *)anObj;
  208. - (void)discardCursorRects;
  209. - (void)resetCursorRects;
  210.  
  211. - (NSTrackingRectTag)addTrackingRect:(NSRect)aRect owner:(id)anObject userData:(void *)data assumeInside:(BOOL)flag;
  212. - (void)removeTrackingRect:(NSTrackingRectTag)tag;
  213.  
  214. - (BOOL)shouldDrawColor;
  215.  
  216. - (void)setPostsBoundsChangedNotifications:(BOOL)flag;
  217. - (BOOL)postsBoundsChangedNotifications;
  218.  
  219. #ifndef STRICT_OPENSTEP
  220. - (NSMenu *)menuForEvent:(NSEvent *)event;
  221. + (NSMenu *)defaultMenu;
  222. #endif
  223.  
  224. - (NSScrollView *)enclosingScrollView;
  225.  
  226. @end
  227.  
  228. #ifndef STRICT_OPENSTEP
  229. @interface NSView(NSKeyboardUI)
  230. - (BOOL)performMnemonic:(NSString *)theString;
  231. - (void)setNextKeyView:(NSView *)next;
  232. - (NSView *)nextKeyView;
  233. - (NSView *)previousKeyView;
  234. - (NSView *)nextValidKeyView;
  235. - (NSView *)previousValidKeyView;
  236. @end
  237. #endif
  238.  
  239. @interface NSView(NSPrinting)
  240.  
  241. - (void)writeEPSInsideRect:(NSRect)rect toPasteboard:(NSPasteboard *)pasteboard;
  242. - (NSData *)dataWithEPSInsideRect:(NSRect)rect;
  243. - (void)print:(id)sender;
  244. - (BOOL)knowsPagesFirst:(int *)firstPageNum last:(int *)lastPageNum;
  245. - (void)beginPrologueBBox:(NSRect)boundingBox creationDate:(NSString *)dateCreated createdBy:(NSString *)anApplication fonts:(NSString *)fontNames forWhom:(NSString *)user pages:(int)numPages title:(NSString *)aTitle;
  246. - (void)endHeaderComments;
  247. - (void)endPrologue;
  248. - (void)beginSetup;
  249. - (void)endSetup;
  250. - (void)beginPage:(int)ordinalNum label:(NSString *)aString bBox:(NSRect)pageRect fonts:(NSString *)fontNames;
  251. - (void)beginPageSetupRect:(NSRect)aRect placement:(NSPoint)location;
  252. - (void)addToPageSetup;
  253. - (void)endPageSetup;
  254. - (void)endPage;
  255. - (void)beginTrailer;
  256. - (void)endTrailer;
  257. - (float)heightAdjustLimit;
  258. - (float)widthAdjustLimit;
  259. - (void)adjustPageWidthNew:(float *)newRight left:(float)oldLeft right:(float)oldRight limit:(float)rightLimit;
  260. - (void)adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit;
  261. - (NSRect)rectForPage:(int)page;
  262. - (NSPoint)locationOfPrintRect:(NSRect)aRect;
  263. - (void)drawSheetBorderWithSize:(NSSize)borderSize;
  264. - (void)drawPageBorderWithSize:(NSSize)borderSize;
  265.  
  266. #ifndef STRICT_OPENSTEP
  267. #ifndef WIN32
  268. // Mach-only non-openstep API.
  269. - (void)fax:(id)sender;
  270. #endif
  271. #endif
  272.  
  273. @end
  274.  
  275.  
  276. @interface NSView(NSDrag)
  277. - (void)dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag;
  278.  
  279. - (void)registerForDraggedTypes:(NSArray *)newTypes;
  280. - (void)unregisterDraggedTypes;
  281.  
  282. - (BOOL)dragFile:(NSString *)filename fromRect:(NSRect)rect slideBack:(BOOL)aFlag event:(NSEvent *)event;
  283.  
  284. @end
  285.  
  286. /* Notifications */
  287.  
  288. APPKIT_EXTERN NSString *NSViewFrameDidChangeNotification;
  289. APPKIT_EXTERN NSString *NSViewFocusDidChangeNotification;
  290. APPKIT_EXTERN NSString *NSViewBoundsDidChangeNotification;
  291.     // This notification is sent whenever the views bounds change and the frame does not.  That is, it is sent whenever the view's bounds are translated, scaled or rotated, but NOT when the bounds change as a result of, for example, setFrameSize:.
  292.  
  293.