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

  1. /*
  2.     NSApplication.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/NSNibLoading.h>
  10. #import <AppKit/AppKitDefines.h>
  11.  
  12. @class NSApplication;
  13. @class NSWindow;
  14. @class NSPasteboard;
  15. @class NSEvent;
  16. @class NSImage;
  17. @class NSMenu;
  18.  
  19. /* Modes passed to NSRunLoop */
  20. APPKIT_EXTERN NSString *NSModalPanelRunLoopMode;
  21. APPKIT_EXTERN NSString *NSEventTrackingRunLoopMode;
  22.  
  23. /* Pre-defined return values for runModalFor: and runModalSession:. The system also reserves all values below these. */
  24. enum {
  25.     NSRunStoppedResponse            = (-1000),
  26.     NSRunAbortedResponse            = (-1001),
  27.     NSRunContinuesResponse            = (-1002)
  28. };
  29.  
  30. #ifndef STRICT_OPENSTEP
  31. /* used with NSRunLoop's performSelector:target:argument:order:modes: */
  32. enum {
  33.     NSUpdateWindowsRunLoopOrdering        = 500000
  34. };
  35. #endif STRICT_OPENSTEP
  36.  
  37. APPKIT_EXTERN id NSApp;
  38.  
  39. /* Information used by the system during modal sessions */
  40. typedef struct _NSModalSession *NSModalSession;
  41.  
  42. @interface NSApplication : NSResponder
  43. {
  44.     NSEvent            *_currentEvent;
  45.     NSMutableArray     *_windowList;
  46.     id                  _keyWindow;
  47.     id                  _mainWindow;
  48.     id                  _delegate;
  49.     int                *_hiddenList;
  50.     int                 _hiddenCount;
  51.     NSDPSContext       *_context;
  52.     id                  _appListener;
  53.     id            _appSpeaker;
  54.     short               _unusedApp;
  55.     short               _running;
  56.     struct __appFlags {
  57.     unsigned int        _hidden:1;
  58.     unsigned int        _RESERVED1:1;
  59.     unsigned int        _active:1;
  60.     unsigned int        _hasBeenRun:1;
  61.     unsigned int        _doingUnhide:1;
  62.     unsigned int        _delegateReturnsValidRequestor:1;
  63.     unsigned int        _deactPending:1;
  64.     unsigned int        _invalidState:1;
  65.     unsigned int        _invalidEvent:1;
  66.     unsigned int        _postedWindowsNeedUpdateNote:1;
  67.     unsigned int        _reserved:22;
  68.     }                   _appFlags;
  69.     id                  _mainMenu;
  70.     id                  _appIcon;
  71.     id                  _nameTable;
  72.     id                  _reservedApplication1;
  73.     id                  _reservedApplication2;
  74. }
  75.  
  76. + (NSApplication *)sharedApplication;
  77.  
  78. - (void)setDelegate:(id)anObject;
  79. - (id)delegate;
  80. - (NSDPSContext *)context;
  81. - (void)hide:(id)sender;
  82. - (void)unhide:(id)sender;
  83. - (void)unhideWithoutActivation;
  84. - (NSWindow *)windowWithWindowNumber:(int)windowNum;
  85. - (NSWindow *)mainWindow;
  86. - (NSWindow *)keyWindow;
  87. - (BOOL)isActive;
  88. - (BOOL)isHidden;
  89. - (BOOL)isRunning;
  90. - (void)deactivate;
  91. - (void)activateIgnoringOtherApps:(BOOL)flag;
  92.  
  93. - (void)finishLaunching;
  94. - (void)run;
  95. - (int)runModalForWindow:(NSWindow *)theWindow;
  96. - (void)stop:(id)sender;
  97. - (void)stopModal;
  98. - (void)stopModalWithCode:(int)returnCode;
  99. - (void)abortModal;
  100. - (NSModalSession)beginModalSessionForWindow:(NSWindow *)theWindow;
  101. - (int)runModalSession:(NSModalSession)session;
  102. - (void)endModalSession:(NSModalSession)session;
  103. - (void)terminate:(id)sender;
  104.  
  105. - (NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag;
  106. - (void)discardEventsMatchingMask:(unsigned int)mask beforeEvent:(NSEvent *)lastEvent;
  107. - (void)postEvent:(NSEvent *)event atStart:(BOOL)flag;
  108. - (NSEvent *)currentEvent;
  109.  
  110. - (void)sendEvent:(NSEvent *)theEvent;
  111. - (void)preventWindowOrdering;
  112. - (NSWindow *)makeWindowsPerform:(SEL)aSelector inOrder:(BOOL)flag;
  113. - (NSArray *)windows;
  114. - (void)setWindowsNeedUpdate:(BOOL)needUpdate;
  115. - (void)updateWindows;
  116.  
  117. - (void)setMainMenu:(NSMenu *)aMenu;
  118. - (NSMenu *)mainMenu;
  119.  
  120. - (void)setApplicationIconImage:(NSImage *)image;
  121. - (NSImage *)applicationIconImage;
  122.  
  123. - (BOOL)sendAction:(SEL)theAction to:(id)theTarget from:(id)sender;
  124. - (id)targetForAction:(SEL)theAction;
  125. - (BOOL)tryToPerform:(SEL)anAction with:(id)anObject;
  126. - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType;
  127.  
  128. - (void)reportException:(NSException *)theException;
  129.  
  130. @end
  131.  
  132. @interface NSApplication(NSWindowsMenu)
  133. - (void)setWindowsMenu:(NSMenu *)aMenu;
  134. - (NSMenu *)windowsMenu;
  135. - (void)arrangeInFront:(id)sender;
  136. - (void)removeWindowsItem:(NSWindow *)win;
  137. - (void)addWindowsItem:(NSWindow *)win title:(NSString *)aString filename:(BOOL)isFilename;
  138. - (void)changeWindowsItem:(NSWindow *)win title:(NSString *)aString filename:(BOOL)isFilename;
  139. - (void)updateWindowsItem:(NSWindow *)win;
  140. - (void)miniaturizeAll:(id)sender;
  141. @end
  142.  
  143.  
  144. @interface NSObject(NSApplicationNotifications)
  145. - (void)applicationWillFinishLaunching:(NSNotification *)notification;
  146. - (void)applicationDidFinishLaunching:(NSNotification *)notification;
  147. - (void)applicationWillHide:(NSNotification *)notification;
  148. - (void)applicationDidHide:(NSNotification *)notification;
  149. - (void)applicationWillUnhide:(NSNotification *)notification;
  150. - (void)applicationDidUnhide:(NSNotification *)notification;
  151. - (void)applicationWillBecomeActive:(NSNotification *)notification;
  152. - (void)applicationDidBecomeActive:(NSNotification *)notification;
  153. - (void)applicationWillResignActive:(NSNotification *)notification;
  154. - (void)applicationDidResignActive:(NSNotification *)notification;
  155. - (void)applicationWillUpdate:(NSNotification *)notification;
  156. - (void)applicationDidUpdate:(NSNotification *)notification;
  157. - (void)applicationWillTerminate:(NSNotification *)notification;
  158. @end
  159.  
  160. @interface NSObject(NSApplicationDelegate)
  161. - (BOOL)applicationShouldTerminate:(NSApplication *)sender;
  162. - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename;
  163. - (BOOL)application:(NSApplication *)sender openTempFile:(NSString *)filename;
  164. - (BOOL)applicationOpenUntitledFile:(NSApplication *)sender;
  165. - (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename;
  166.  
  167. #ifndef STRICT_OPENSTEP
  168. - (BOOL)application:(NSApplication *)sender printFile:(NSString *)filename;
  169. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender;
  170. #endif
  171. @end
  172.  
  173. @interface NSApplication(NSServicesMenu)
  174. - (void)setServicesMenu:(NSMenu *)aMenu;
  175. - (NSMenu *)servicesMenu;
  176. - (void)registerServicesMenuSendTypes:(NSArray *)sendTypes returnTypes:(NSArray *)returnTypes;
  177. @end
  178.  
  179. @interface NSObject(NSServicesRequests)
  180. - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types;
  181. - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard;
  182. @end
  183.  
  184. @interface NSApplication(NSServicesHandling)
  185. - (void)setServicesProvider:(id)provider;
  186. - (id)servicesProvider;
  187. @end
  188.  
  189. #ifndef STRICT_OPENSTEP
  190. #ifdef WIN32
  191. @interface NSApplication (NSWindowsExtensions)
  192. + (void)setApplicationHandle:(void * /*HINSTANCE*/)hInstance previousHandle:(void * /*HINSTANCE*/)PrevInstance commandLine:(NSString *)cmdLine show:(int)cmdShow;
  193. + (void)useRunningCopyOfApplication;
  194. - (void * /*HINSTANCE*/)applicationHandle;
  195. - (NSWindow *)windowWithWindowHandle:(void * /*HWND*/)hWnd; // does not create a new NSWindow
  196. @end
  197. #endif
  198.  
  199. #endif
  200.  
  201. /* An Application's startup function */
  202.  
  203. APPKIT_EXTERN int NSApplicationMain(int argc, const char *argv[]);
  204.  
  205. /*
  206.  * Functions to enable/disable Services Menu items.  These should usually
  207.  * only be called by service PROVIDERS (since they are the only ones who
  208.  * know the name of the services, requestors don't).  The itemName in the
  209.  * two functions below is the language-independent "Menu Item:" entry in
  210.  * the __services section (which all provided services must have).  The
  211.  * set function returns whether it was successful.
  212.  * NSUpdateDynamicServices() causes the services information for the
  213.  * system to be updated.  This will only be necessary if your program
  214.  * adds dynamic services to the system (i.e. services not found in macho
  215.  * segments of executables).
  216.  */
  217.  
  218. APPKIT_EXTERN BOOL NSShowsServicesMenuItem(NSString * itemName);
  219. APPKIT_EXTERN int NSSetShowsServicesMenuItem(NSString * itemName, BOOL enabled);
  220. APPKIT_EXTERN void NSUpdateDynamicServices(void);
  221. APPKIT_EXTERN BOOL NSPerformService(NSString *itemName, NSPasteboard *pboard);
  222.  
  223. APPKIT_EXTERN void NSRegisterServicesProvider(id provider, NSString *name); // apps should use -setServicesProvider
  224. APPKIT_EXTERN void NSUnregisterServicesProvider(NSString *name);
  225.  
  226. /* Notifications */
  227. APPKIT_EXTERN NSString *NSApplicationDidBecomeActiveNotification;
  228. APPKIT_EXTERN NSString *NSApplicationDidHideNotification;
  229. APPKIT_EXTERN NSString *NSApplicationDidFinishLaunchingNotification;
  230. APPKIT_EXTERN NSString *NSApplicationDidResignActiveNotification;
  231. APPKIT_EXTERN NSString *NSApplicationDidUnhideNotification;
  232. APPKIT_EXTERN NSString *NSApplicationDidUpdateNotification;
  233. APPKIT_EXTERN NSString *NSApplicationWillBecomeActiveNotification;
  234. APPKIT_EXTERN NSString *NSApplicationWillHideNotification;
  235. APPKIT_EXTERN NSString *NSApplicationWillFinishLaunchingNotification;
  236. APPKIT_EXTERN NSString *NSApplicationWillResignActiveNotification;
  237. APPKIT_EXTERN NSString *NSApplicationWillUnhideNotification;
  238. APPKIT_EXTERN NSString *NSApplicationWillUpdateNotification;
  239. APPKIT_EXTERN NSString *NSApplicationWillTerminateNotification;
  240.  
  241.