home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / NSWindow.h < prev    next >
Text File  |  1996-09-09  |  13KB  |  385 lines

  1. /*
  2.     NSWindow.h
  3.     Application Kit
  4.     Copyright (c) 1994-1996, NeXT Software, Inc.
  5.     All rights reserved.
  6. */
  7.  
  8. #import <AppKit/NSResponder.h>
  9. #import <AppKit/NSScreen.h>
  10. #import <AppKit/NSGraphics.h>
  11. #import <AppKit/NSDragging.h>
  12. #import <AppKit/NSColor.h>
  13. #import <AppKit/AppKitDefines.h>
  14. #import <Foundation/NSHashTable.h>
  15. @class NSText;
  16. @class NSCursor;
  17. @class NSView;
  18. @class NSButtonCell;
  19.  
  20. enum {
  21.     NSBorderlessWindowMask        = 0,
  22.     NSTitledWindowMask            = 1 << 0,
  23.     NSClosableWindowMask        = 1 << 1,
  24.     NSMiniaturizableWindowMask        = 1 << 2,
  25.     NSResizableWindowMask        = 1 << 3
  26. };
  27.  
  28. #ifndef STRICT_OPENSTEP
  29. /* used with NSRunLoop's performSelector:target:argument:order:modes: */
  30. enum {
  31.     NSDisplayWindowRunLoopOrdering    = 600000,
  32.     NSResetCursorRectsRunLoopOrdering    = 700000
  33. };
  34. #endif
  35.  
  36. APPKIT_EXTERN NSSize NSIconSize;
  37. APPKIT_EXTERN NSSize NSTokenSize;
  38.  
  39. enum {
  40.     NSNormalWindowLevel            = 0,
  41.     NSFloatingWindowLevel        = 3,
  42.     NSDockWindowLevel            = 5,
  43.     NSSubmenuWindowLevel        = 10,
  44.     NSMainMenuWindowLevel        = 20
  45. };
  46.  
  47. typedef enum _NSSelectionDirection {
  48.     NSDirectSelection = 0,
  49.     NSSelectingNext,
  50.     NSSelectingPrevious
  51. } NSSelectionDirection;
  52.  
  53. @class NSEvent;
  54.  
  55. @interface NSWindow : NSResponder
  56. {
  57.     NSRect              _frame;
  58.     id                  _contentView;
  59.     id                  _delegate;
  60.     NSResponder        *_firstResponder;
  61.     NSView        *_lastLeftHit;
  62.     NSView        *_lastRightHit;
  63.     id                  _counterpart;
  64.     id                  _fieldEditor;
  65.     int                 _winEventMask;
  66.     int                 _windowNum;
  67.     int            _level;
  68.     NSColor        *_backgroundColor;
  69.     id                  _borderView;
  70.     unsigned char    _postingDisabled;
  71.     unsigned char    _styleMask;
  72.     unsigned char    _flushDisabled;
  73.     unsigned char    _reservedWindow1;
  74.     void        *_cursorRects;
  75.     NSHashTable        *_trectTable;
  76.     NSImage        *_miniIcon;
  77.     int            _lastResizeTime;
  78.     NSMutableSet    *_dragTypes;
  79.     NSString        *_representedFilename;
  80.     NSSize        *_sizeLimits;
  81.     NSString        *_frameSaveName;
  82.     NSSet        *_regDragTypes;
  83.     struct __wFlags {
  84.         unsigned int        backing:2;
  85.         unsigned int        visible:1;
  86.         unsigned int        isMainWindow:1;
  87.         unsigned int        isKeyWindow:1;
  88.         unsigned int        hidesOnDeactivate:1;
  89.         unsigned int        dontFreeWhenClosed:1;
  90.         unsigned int        oneShot:1;
  91.         unsigned int        deferred:1;
  92.         unsigned int        cursorRectsDisabled:1;
  93.         unsigned int        haveFreeCursorRects:1;
  94.         unsigned int        validCursorRects:1;
  95.         unsigned int        docEdited:1;
  96.         unsigned int        dynamicDepthLimit:1;
  97.         unsigned int        worksWhenModal:1;
  98.         unsigned int        limitedBecomeKey:1;
  99.         unsigned int        needsFlush:1;
  100.         unsigned int        viewsNeedDisplay:1;
  101.         unsigned int        ignoredFirstMouse:1;
  102.         unsigned int        repostedFirstMouse:1;
  103.         unsigned int        windowDying:1;
  104.         unsigned int        tempHidden:1;
  105.         unsigned int        floatingPanel:1;
  106.         unsigned int        wantsToBeOnMainScreen:1;
  107.         unsigned int        optimizedDrawingOk:1;
  108.         unsigned int        optimizeDrawing:1;
  109.         unsigned int        titleIsRepresentedFilename:1;
  110.         unsigned int        excludedFromWindowsMenu:1;
  111.         unsigned int        depthLimit:4;
  112.         unsigned int        delegateReturnsValidRequestor:1;
  113.         unsigned int        lmouseupPending:1;
  114.         unsigned int        rmouseupPending:1;
  115.         unsigned int        wantsToDestroyRealWindow:1;
  116.         unsigned int        wantsToRegDragTypes:1;
  117.         unsigned int        titleNeedsDisplay:1;
  118.         unsigned int        avoidsActivation:1;
  119.         unsigned int        frameSavedUsingTitle:1;
  120.         unsigned int        didRegDragTypes:1;
  121.         unsigned int        delayedOneShot:1;
  122.         unsigned int        postedNeedsDisplayNote:1;
  123.         unsigned int        postedInvalidCursorRectsNote:1;
  124.         unsigned int        initialFirstResponderTempSet:1;
  125.         unsigned int        autodisplay:1;
  126.         unsigned int        tossedFirstEvent:1;
  127.         unsigned int        isImageCache:1;
  128.         unsigned int        interfaceStyle:3;
  129.         unsigned int        keyViewSelectionDirection:2;
  130.         unsigned int        defaultButtonCellKETemporarilyDisabled:1;
  131.         unsigned int        defaultButtonCellKEDisabled:1;
  132.         unsigned int        menuHasBeenSet:1;
  133.         unsigned int        wantsToBeModal:1;
  134.         unsigned int        showingModalFrame:1;
  135.         unsigned int        _reserved:6;
  136.     }                   _wFlags;
  137.     id            _defaultButtonCell;
  138.     NSView         *_initialFirstResponder;
  139.     unsigned int    _reservedWindow2;
  140. }
  141.  
  142. + (NSRect)frameRectForContentRect:(NSRect)cRect styleMask:(unsigned int)aStyle;
  143. + (NSRect)contentRectForFrameRect:(NSRect)fRect styleMask:(unsigned int)aStyle;
  144. + (float)minFrameWidthWithTitle:(NSString *)aTitle styleMask:(unsigned int)aStyle;
  145. + (NSWindowDepth)defaultDepthLimit;
  146.  
  147.  
  148. - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
  149. - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen;
  150.  
  151. - (NSString *)title;
  152. - (void)setTitle:(NSString *)aString;
  153. - (NSString *)representedFilename;
  154. - (void)setRepresentedFilename:(NSString *)aString;
  155. - (void)setTitleWithRepresentedFilename:(NSString *)filename;
  156. - (void)setExcludedFromWindowsMenu:(BOOL)flag;
  157. - (BOOL)isExcludedFromWindowsMenu;
  158. - (void)setContentView:(NSView *)aView;
  159. - (id)contentView;
  160. - (void)setDelegate:(id)anObject;
  161. - (id)delegate;
  162. - (int)windowNumber;
  163. - (unsigned int)styleMask;
  164. - (NSText *)fieldEditor:(BOOL)createFlag forObject:(id)anObject;
  165. - (void)endEditingFor:(id)anObject;
  166.  
  167. - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
  168. - (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
  169. - (void)setContentSize:(NSSize)aSize;
  170. - (void)setFrameOrigin:(NSPoint)aPoint;
  171. - (void)setFrameTopLeftPoint:(NSPoint)aPoint;
  172. - (NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeftPoint;
  173. - (NSRect)frame;
  174.  
  175. - (void)setResizeIncrements:(NSSize)increments;
  176. - (NSSize)resizeIncrements;
  177. - (void)setAspectRatio:(NSSize)ratio;
  178. - (NSSize)aspectRatio;
  179.  
  180. - (void)useOptimizedDrawing:(BOOL)flag;
  181. - (void)disableFlushWindow;
  182. - (void)enableFlushWindow;
  183. - (BOOL)isFlushWindowDisabled;
  184. - (void)flushWindow;
  185. - (void)flushWindowIfNeeded;
  186. - (void)setViewsNeedDisplay:(BOOL)flag;
  187. - (BOOL)viewsNeedDisplay;
  188. - (void)displayIfNeeded;
  189. - (void)display;
  190. - (void)setAutodisplay:(BOOL)flag;
  191. - (BOOL)isAutodisplay;
  192.  
  193. - (void)update;
  194. - (BOOL)makeFirstResponder:(NSResponder *)aResponder;
  195. - (NSResponder *)firstResponder;
  196. - (int)resizeFlags;
  197. - (void)keyDown:(NSEvent *)theEvent;
  198. - (void)close;
  199. - (void)setReleasedWhenClosed:(BOOL)flag;
  200. - (BOOL)isReleasedWhenClosed;
  201. - (void)miniaturize:(id)sender;
  202. - (void)deminiaturize:(id)sender;
  203. - (BOOL)isMiniaturized;
  204. - (BOOL)tryToPerform:(SEL)anAction with:(id)anObject;
  205. - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType;
  206. - (void)setBackgroundColor:(NSColor *)color;
  207. - (NSColor *)backgroundColor;
  208.  
  209. - (void)setHidesOnDeactivate:(BOOL)flag;
  210. - (BOOL)hidesOnDeactivate;
  211. - (void)center;
  212. - (void)makeKeyAndOrderFront:(id)sender;
  213. - (void)orderFront:(id)sender;
  214. - (void)orderBack:(id)sender;
  215. - (void)orderOut:(id)sender;
  216. - (void)orderWindow:(NSWindowOrderingMode)place relativeTo:(int)otherWin;
  217. - (void)orderFrontRegardless;
  218.  
  219. - (void)setMiniwindowImage:(NSImage *)image;
  220. - (void)setMiniwindowTitle:(NSString *)title;
  221. - (NSImage *)miniwindowImage;
  222. - (NSString *)miniwindowTitle;
  223.  
  224. - (void)setDocumentEdited:(BOOL)flag;
  225. - (BOOL)isDocumentEdited;
  226. - (BOOL)isVisible;
  227. - (BOOL)isKeyWindow;
  228. - (BOOL)isMainWindow;
  229. - (BOOL)canBecomeKeyWindow;
  230. - (BOOL)canBecomeMainWindow;
  231. - (void)makeKeyWindow;
  232. - (void)makeMainWindow;
  233. - (void)becomeKeyWindow;
  234. - (void)resignKeyWindow;
  235. - (void)becomeMainWindow;
  236. - (void)resignMainWindow;
  237.  
  238. - (BOOL)worksWhenModal;
  239. - (NSPoint)convertBaseToScreen:(NSPoint)aPoint;
  240. - (NSPoint)convertScreenToBase:(NSPoint)aPoint;
  241. - (void)performClose:(id)sender;
  242. - (void)performMiniaturize:(id)sender;
  243. - (int)gState;
  244. - (void)setOneShot:(BOOL)flag;
  245. - (BOOL)isOneShot;
  246. - (NSData *)dataWithEPSInsideRect:(NSRect)rect;
  247. - (void)print:(id)sender;
  248.  
  249. #ifndef STRICT_OPENSTEP
  250. #ifndef WIN32
  251. - (void)fax:(id)sender;
  252. #endif /* WIN32 */
  253. #endif /* STRICT_OPENSTEP */
  254.  
  255. - (void)disableCursorRects;
  256. - (void)enableCursorRects;
  257. - (void)discardCursorRects;
  258. - (BOOL)areCursorRectsEnabled;
  259. - (void)invalidateCursorRectsForView:(NSView *)aView;
  260. - (void)resetCursorRects;
  261.  
  262. - (void)setBackingType:(NSBackingStoreType)bufferingType;
  263. - (NSBackingStoreType)backingType;
  264. - (void)setLevel:(int)newLevel;
  265. - (int)level;
  266. - (void)setDepthLimit:(NSWindowDepth)limit;
  267. - (NSWindowDepth)depthLimit;
  268. - (void)setDynamicDepthLimit:(BOOL)flag;
  269. - (BOOL)hasDynamicDepthLimit;
  270. - (NSScreen *)screen;
  271. - (NSScreen *)deepestScreen;
  272. - (BOOL)canStoreColor;
  273.  
  274. - (NSString *)stringWithSavedFrame;
  275. - (void)setFrameFromString:(NSString *)string;
  276. - (void)saveFrameUsingName:(NSString *)name;
  277. - (BOOL)setFrameUsingName:(NSString *)name;
  278. - (BOOL)setFrameAutosaveName:(NSString *)name;
  279. - (NSString *)frameAutosaveName;
  280. + (void)removeFrameUsingName:(NSString *)name;
  281.  
  282. - (void)cacheImageInRect:(NSRect)aRect;
  283. - (void)restoreCachedImage;
  284. - (void)discardCachedImage;
  285.  
  286. - (NSSize)minSize;
  287. - (NSSize)maxSize;
  288. - (void)setMinSize:(NSSize)size;
  289. - (void)setMaxSize:(NSSize)size;
  290. - (NSEvent *)nextEventMatchingMask:(unsigned int)mask;
  291. - (NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag;
  292. - (void)discardEventsMatchingMask:(unsigned int)mask beforeEvent:(NSEvent *)lastEvent;
  293. - (void)postEvent:(NSEvent *)event atStart:(BOOL)flag;
  294. - (NSEvent *)currentEvent;
  295. - (void)setAcceptsMouseMovedEvents:(BOOL)flag;
  296. - (BOOL)acceptsMouseMovedEvents;
  297. - (NSDictionary *)deviceDescription;
  298. - (void)sendEvent:(NSEvent *)theEvent;
  299. - (NSPoint)mouseLocationOutsideOfEventStream;
  300.  
  301. #ifndef STRICT_OPENSTEP
  302. + (void)menuChanged:(NSMenu *)menu;
  303. #endif
  304.  
  305. @end
  306.  
  307. #ifndef STRICT_OPENSTEP
  308. @interface NSWindow(NSKeyboardUI)
  309. - (void)setInitialFirstResponder:(NSView *)view;
  310. - (NSView *)initialFirstResponder;
  311. - (void)selectNextKeyView:(id)sender;
  312. - (void)selectPreviousKeyView:(id)sender;
  313. - (void)selectKeyViewFollowingView:(NSView *)aView;
  314. - (void)selectKeyViewPrecedingView:(NSView *)aView;
  315. - (NSSelectionDirection)keyViewSelectionDirection;
  316. - (void)setDefaultButtonCell:(NSButtonCell *)defButt;
  317. - (NSButtonCell *)defaultButtonCell;
  318. - (void)disableKeyEquivalentForDefaultButtonCell;
  319. - (void)enableKeyEquivalentForDefaultButtonCell;
  320. @end
  321. #endif
  322.  
  323. @interface NSWindow(NSDrag)
  324. - (void)dragImage:(NSImage *)anImage at:(NSPoint)baseLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag;
  325.  
  326. - (void)registerForDraggedTypes:(NSArray *)newTypes;
  327. - (void)unregisterDraggedTypes;
  328. @end
  329.  
  330. #ifndef STRICT_OPENSTEP
  331. #ifdef WIN32
  332. @interface NSWindow (NSWindowsExtensions)
  333. - (void * /*HWND*/)windowHandle;
  334. @end
  335. #endif
  336. #endif
  337.  
  338. @interface NSObject(NSWindowNotifications)
  339. - (void)windowDidResize:(NSNotification *)notification;
  340. - (void)windowDidExpose:(NSNotification *)notification;
  341. #ifndef STRICT_OPENSTEP
  342. - (void)windowWillMove:(NSNotification *)notification;
  343. #endif
  344. - (void)windowDidMove:(NSNotification *)notification;
  345. - (void)windowDidBecomeKey:(NSNotification *)notification;
  346. - (void)windowDidResignKey:(NSNotification *)notification;
  347. - (void)windowDidBecomeMain:(NSNotification *)notification;
  348. - (void)windowDidResignMain:(NSNotification *)notification;
  349. - (void)windowWillClose:(NSNotification *)notification;
  350. #ifndef STRICT_OPENSTEP
  351. - (void)windowWillMiniaturize:(NSNotification *)notification;
  352. #endif
  353. - (void)windowDidMiniaturize:(NSNotification *)notification;
  354. - (void)windowDidDeminiaturize:(NSNotification *)notification;
  355. - (void)windowDidUpdate:(NSNotification *)notification;
  356. - (void)windowDidChangeScreen:(NSNotification *)notification;
  357. @end
  358.  
  359. @interface NSObject(NSWindowDelegate)
  360. - (BOOL)windowShouldClose:(id)sender;
  361. - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client;
  362. #ifndef STRICT_OPENSTEP
  363. - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize;
  364. #endif
  365. @end
  366.  
  367.  
  368. /* Notifications */
  369. APPKIT_EXTERN NSString *NSWindowDidBecomeKeyNotification;
  370. APPKIT_EXTERN NSString *NSWindowDidBecomeMainNotification;
  371. APPKIT_EXTERN NSString *NSWindowDidChangeScreenNotification;
  372. APPKIT_EXTERN NSString *NSWindowDidDeminiaturizeNotification;
  373. APPKIT_EXTERN NSString *NSWindowDidExposeNotification;            // userInfo key:  @"NSExposedRect"
  374. APPKIT_EXTERN NSString *NSWindowDidMiniaturizeNotification;
  375. APPKIT_EXTERN NSString *NSWindowDidMoveNotification;
  376. APPKIT_EXTERN NSString *NSWindowDidResignKeyNotification;
  377. APPKIT_EXTERN NSString *NSWindowDidResignMainNotification;
  378. APPKIT_EXTERN NSString *NSWindowDidResizeNotification;
  379. APPKIT_EXTERN NSString *NSWindowDidUpdateNotification;
  380. APPKIT_EXTERN NSString *NSWindowWillCloseNotification;
  381. #ifndef STRICT_OPENSTEP
  382. APPKIT_EXTERN NSString *NSWindowWillMiniaturizeNotification;
  383. APPKIT_EXTERN NSString *NSWindowWillMoveNotification;
  384. #endif
  385.