home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSApplication.h < prev    next >
Text File  |  1996-12-20  |  9KB  |  245 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        _wantsToActivate:1;
  68.         unsigned int        _doingHide:1;
  69.     unsigned int        _dontSendShouldTerminate:1;
  70.         unsigned int        _skipWin32DelayedRestoreKeyWindowAfterHide:1;
  71.     unsigned int        _reserved:18;
  72.     }                   _appFlags;
  73.     id                  _mainMenu;
  74.     id                  _appIcon;
  75.     id                  _nameTable;
  76.     id                  _reservedApplication1;
  77.     id                  _reservedApplication2;
  78. }
  79.  
  80. + (NSApplication *)sharedApplication;
  81.  
  82. - (void)setDelegate:(id)anObject;
  83. - (id)delegate;
  84. - (NSDPSContext *)context;
  85. - (void)hide:(id)sender;
  86. - (void)unhide:(id)sender;
  87. - (void)unhideWithoutActivation;
  88. - (NSWindow *)windowWithWindowNumber:(int)windowNum;
  89. - (NSWindow *)mainWindow;
  90. - (NSWindow *)keyWindow;
  91. - (BOOL)isActive;
  92. - (BOOL)isHidden;
  93. - (BOOL)isRunning;
  94. - (void)deactivate;
  95. - (void)activateIgnoringOtherApps:(BOOL)flag;
  96.  
  97. - (void)finishLaunching;
  98. - (void)run;
  99. - (int)runModalForWindow:(NSWindow *)theWindow;
  100. - (void)stop:(id)sender;
  101. - (void)stopModal;
  102. - (void)stopModalWithCode:(int)returnCode;
  103. - (void)abortModal;
  104. - (NSModalSession)beginModalSessionForWindow:(NSWindow *)theWindow;
  105. - (int)runModalSession:(NSModalSession)session;
  106. - (void)endModalSession:(NSModalSession)session;
  107. - (void)terminate:(id)sender;
  108.  
  109. - (NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag;
  110. - (void)discardEventsMatchingMask:(unsigned int)mask beforeEvent:(NSEvent *)lastEvent;
  111. - (void)postEvent:(NSEvent *)event atStart:(BOOL)flag;
  112. - (NSEvent *)currentEvent;
  113.  
  114. - (void)sendEvent:(NSEvent *)theEvent;
  115. - (void)preventWindowOrdering;
  116. - (NSWindow *)makeWindowsPerform:(SEL)aSelector inOrder:(BOOL)flag;
  117. - (NSArray *)windows;
  118. - (void)setWindowsNeedUpdate:(BOOL)needUpdate;
  119. - (void)updateWindows;
  120.  
  121. - (void)setMainMenu:(NSMenu *)aMenu;
  122. - (NSMenu *)mainMenu;
  123.  
  124. - (void)setApplicationIconImage:(NSImage *)image;
  125. - (NSImage *)applicationIconImage;
  126.  
  127. - (BOOL)sendAction:(SEL)theAction to:(id)theTarget from:(id)sender;
  128. - (id)targetForAction:(SEL)theAction;
  129. - (BOOL)tryToPerform:(SEL)anAction with:(id)anObject;
  130. - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType;
  131.  
  132. - (void)reportException:(NSException *)theException;
  133.  
  134. @end
  135.  
  136. @interface NSApplication(NSWindowsMenu)
  137. - (void)setWindowsMenu:(NSMenu *)aMenu;
  138. - (NSMenu *)windowsMenu;
  139. - (void)arrangeInFront:(id)sender;
  140. - (void)removeWindowsItem:(NSWindow *)win;
  141. - (void)addWindowsItem:(NSWindow *)win title:(NSString *)aString filename:(BOOL)isFilename;
  142. - (void)changeWindowsItem:(NSWindow *)win title:(NSString *)aString filename:(BOOL)isFilename;
  143. - (void)updateWindowsItem:(NSWindow *)win;
  144. - (void)miniaturizeAll:(id)sender;
  145. @end
  146.  
  147.  
  148. @interface NSObject(NSApplicationNotifications)
  149. - (void)applicationWillFinishLaunching:(NSNotification *)notification;
  150. - (void)applicationDidFinishLaunching:(NSNotification *)notification;
  151. - (void)applicationWillHide:(NSNotification *)notification;
  152. - (void)applicationDidHide:(NSNotification *)notification;
  153. - (void)applicationWillUnhide:(NSNotification *)notification;
  154. - (void)applicationDidUnhide:(NSNotification *)notification;
  155. - (void)applicationWillBecomeActive:(NSNotification *)notification;
  156. - (void)applicationDidBecomeActive:(NSNotification *)notification;
  157. - (void)applicationWillResignActive:(NSNotification *)notification;
  158. - (void)applicationDidResignActive:(NSNotification *)notification;
  159. - (void)applicationWillUpdate:(NSNotification *)notification;
  160. - (void)applicationDidUpdate:(NSNotification *)notification;
  161. - (void)applicationWillTerminate:(NSNotification *)notification;
  162. @end
  163.  
  164. @interface NSObject(NSApplicationDelegate)
  165. - (BOOL)applicationShouldTerminate:(NSApplication *)sender;
  166. - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename;
  167. - (BOOL)application:(NSApplication *)sender openTempFile:(NSString *)filename;
  168. - (BOOL)applicationOpenUntitledFile:(NSApplication *)sender;
  169. - (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename;
  170.  
  171. #ifndef STRICT_OPENSTEP
  172. - (BOOL)application:(NSApplication *)sender printFile:(NSString *)filename;
  173. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender;
  174. #endif
  175. @end
  176.  
  177. @interface NSApplication(NSServicesMenu)
  178. - (void)setServicesMenu:(NSMenu *)aMenu;
  179. - (NSMenu *)servicesMenu;
  180. - (void)registerServicesMenuSendTypes:(NSArray *)sendTypes returnTypes:(NSArray *)returnTypes;
  181. @end
  182.  
  183. @interface NSObject(NSServicesRequests)
  184. - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types;
  185. - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard;
  186. @end
  187.  
  188. @interface NSApplication(NSServicesHandling)
  189. - (void)setServicesProvider:(id)provider;
  190. - (id)servicesProvider;
  191. @end
  192.  
  193. #ifndef STRICT_OPENSTEP
  194. #ifdef WIN32
  195. @interface NSApplication (NSWindowsExtensions)
  196. + (void)setApplicationHandle:(void * /*HINSTANCE*/)hInstance previousHandle:(void * /*HINSTANCE*/)PrevInstance commandLine:(NSString *)cmdLine show:(int)cmdShow;
  197. + (void)useRunningCopyOfApplication;
  198. - (void * /*HINSTANCE*/)applicationHandle;
  199. - (NSWindow *)windowWithWindowHandle:(void * /*HWND*/)hWnd; // does not create a new NSWindow
  200. @end
  201. #endif
  202.  
  203. #endif
  204.  
  205. /* An Application's startup function */
  206.  
  207. APPKIT_EXTERN int NSApplicationMain(int argc, const char *argv[]);
  208.  
  209. /*
  210.  * Functions to enable/disable Services Menu items.  These should usually
  211.  * only be called by service PROVIDERS (since they are the only ones who
  212.  * know the name of the services, requestors don't).  The itemName in the
  213.  * two functions below is the language-independent "Menu Item:" entry in
  214.  * the __services section (which all provided services must have).  The
  215.  * set function returns whether it was successful.
  216.  * NSUpdateDynamicServices() causes the services information for the
  217.  * system to be updated.  This will only be necessary if your program
  218.  * adds dynamic services to the system (i.e. services not found in macho
  219.  * segments of executables).
  220.  */
  221.  
  222. APPKIT_EXTERN BOOL NSShowsServicesMenuItem(NSString * itemName);
  223. APPKIT_EXTERN int NSSetShowsServicesMenuItem(NSString * itemName, BOOL enabled);
  224. APPKIT_EXTERN void NSUpdateDynamicServices(void);
  225. APPKIT_EXTERN BOOL NSPerformService(NSString *itemName, NSPasteboard *pboard);
  226.  
  227. APPKIT_EXTERN void NSRegisterServicesProvider(id provider, NSString *name); // apps should use -setServicesProvider
  228. APPKIT_EXTERN void NSUnregisterServicesProvider(NSString *name);
  229.  
  230. /* Notifications */
  231. APPKIT_EXTERN NSString *NSApplicationDidBecomeActiveNotification;
  232. APPKIT_EXTERN NSString *NSApplicationDidHideNotification;
  233. APPKIT_EXTERN NSString *NSApplicationDidFinishLaunchingNotification;
  234. APPKIT_EXTERN NSString *NSApplicationDidResignActiveNotification;
  235. APPKIT_EXTERN NSString *NSApplicationDidUnhideNotification;
  236. APPKIT_EXTERN NSString *NSApplicationDidUpdateNotification;
  237. APPKIT_EXTERN NSString *NSApplicationWillBecomeActiveNotification;
  238. APPKIT_EXTERN NSString *NSApplicationWillHideNotification;
  239. APPKIT_EXTERN NSString *NSApplicationWillFinishLaunchingNotification;
  240. APPKIT_EXTERN NSString *NSApplicationWillResignActiveNotification;
  241. APPKIT_EXTERN NSString *NSApplicationWillUnhideNotification;
  242. APPKIT_EXTERN NSString *NSApplicationWillUpdateNotification;
  243. APPKIT_EXTERN NSString *NSApplicationWillTerminateNotification;
  244.  
  245.