1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
9 #import <AppKit/NSResponder.h>
10 #import <AppKit/AppKitExport.h>
11 #import <AppKit/NSGraphics.h>
13 @
class NSWindow
, NSImage
, NSMenu
, NSPasteboard
, NSDisplay
, NSDockTile
;
15 APPKIT_EXPORT NSString
*const NSModalPanelRunLoopMode
;
16 APPKIT_EXPORT NSString
*const NSEventTrackingRunLoopMode
;
18 APPKIT_EXPORT NSString
*const NSApplicationWillFinishLaunchingNotification
;
19 APPKIT_EXPORT NSString
*const NSApplicationDidFinishLaunchingNotification
;
21 APPKIT_EXPORT NSString
*const NSApplicationWillBecomeActiveNotification
;
22 APPKIT_EXPORT NSString
*const NSApplicationDidBecomeActiveNotification
;
23 APPKIT_EXPORT NSString
*const NSApplicationWillResignActiveNotification
;
24 APPKIT_EXPORT NSString
*const NSApplicationDidResignActiveNotification
;
26 APPKIT_EXPORT NSString
*const NSApplicationWillUpdateNotification
;
27 APPKIT_EXPORT NSString
*const NSApplicationDidUpdateNotification
;
29 APPKIT_EXPORT NSString
*const NSApplicationWillHideNotification
;
30 APPKIT_EXPORT NSString
*const NSApplicationDidHideNotification
;
31 APPKIT_EXPORT NSString
*const NSApplicationWillUnhideNotification
;
32 APPKIT_EXPORT NSString
*const NSApplicationDidUnhideNotification
;
34 APPKIT_EXPORT NSString
*const NSApplicationWillTerminateNotification
;
36 APPKIT_EXPORT NSString
*const NSApplicationDidChangeScreenParametersNotification
;
38 APPKIT_EXPORT id NSApp
;
40 typedef id NSModalSession
;
43 NSRunStoppedResponse
= -1000,
44 NSRunAbortedResponse
= -1001,
45 NSRunContinuesResponse
= -1002
52 } NSApplicationTerminateReply
;
56 NSInformationalRequest
,
57 } NSRequestUserAttentionType
;
60 NSApplicationDelegateReplySuccess
,
61 NSApplicationDelegateReplyCancel
,
62 NSApplicationDelegateReplyFailure
,
63 } NSApplicationDelegateReply
;
70 } NSApplicationPrintReply
;
72 @interface NSApplication
: NSResponder
{
75 NSMutableArray
*_windows
;
77 NSWindow
*_mainWindow
;
81 NSImage
*_applicationIconImage
;
86 BOOL _windowsNeedUpdate
;
87 NSEvent
*_currentEvent
;
88 NSDockTile
*_dockTile
;
90 NSMutableArray
*_modalStack
;
92 NSMutableArray
*_orderedWindows
; // get rid of
93 NSTimer
*_attentionTimer
;
96 + (NSApplication
*)sharedApplication
;
98 + (void)detachDrawingThread
:(SEL
)selector toTarget
:target withObject
:object
;
102 - (NSGraphicsContext
*)context
;
105 - (NSArray
*)windows
;
106 - (NSWindow
*)windowWithWindowNumber
:(NSInteger
)number
;
108 - (NSMenu
*)mainMenu
;
109 - (NSMenu
*)windowsMenu
;
110 - (NSWindow
*)mainWindow
;
111 - (NSWindow
*)keyWindow
;
112 - (NSImage
*)applicationIconImage
;
117 - (NSWindow
*)makeWindowsPerform
:(SEL
)selector inOrder
:(BOOL
)inOrder
;
118 - (void)miniaturizeAll
:sender
;
120 - (NSArray
*)orderedDocuments
;
121 - (NSArray
*)orderedWindows
;
122 - (void)preventWindowOrdering
;
124 - (void)setDelegate
:delegate
;
125 - (void)setMainMenu
:(NSMenu
*)menu
;
126 - (void)setApplicationIconImage
:(NSImage
*)image
;
128 - (void)setWindowsMenu
:(NSMenu
*)menu
;
129 - (void)addWindowsItem
:(NSWindow
*)window title
:(NSString
*)title filename
:(BOOL
)filename
;
130 - (void)changeWindowsItem
:(NSWindow
*)window title
:(NSString
*)title filename
:(BOOL
)filename
;
131 - (void)removeWindowsItem
:(NSWindow
*)window
;
132 - (void)updateWindowsItem
:(NSWindow
*)window
;
134 - (void)finishLaunching
;
137 - (void)sendEvent
:(NSEvent
*)event
;
139 - (NSEvent
*)nextEventMatchingMask
:(unsigned int)mask untilDate
:(NSDate
*)untilDate inMode
:(NSString
*)mode dequeue
:(BOOL
)dequeue
;
140 - (NSEvent
*)currentEvent
;
141 - (void)discardEventsMatchingMask
:(unsigned)mask beforeEvent
:(NSEvent
*)event
;
142 - (void)postEvent
:(NSEvent
*)event atStart
:(BOOL
)atStart
;
144 - targetForAction
:(SEL
)action
;
145 - targetForAction
:(SEL
)action to
:target from
:sender
;
146 - (BOOL
)sendAction
:(SEL
)action to
:target from
:sender
;
147 - (BOOL
)tryToPerform
:(SEL
)selector with
:object
;
149 - (void)setWindowsNeedUpdate
:(BOOL
)value
;
150 - (void)updateWindows
;
152 - (void)activateIgnoringOtherApps
:(BOOL
)flag
;
155 - (NSWindow
*)modalWindow
;
156 - (NSModalSession
)beginModalSessionForWindow
:(NSWindow
*)window
;
157 - (int)runModalSession
:(NSModalSession
)session
;
158 - (void)endModalSession
:(NSModalSession
)session
;
159 - (void)stopModalWithCode
:(int)code
;
161 - (int)runModalForWindow
:(NSWindow
*)window
;
165 - (void)beginSheet
:(NSWindow
*)sheet modalForWindow
:(NSWindow
*)window modalDelegate
:modalDelegate didEndSelector
:(SEL
)didEndSelector contextInfo
:(void *)contextInfo
;
166 - (void)endSheet
:(NSWindow
*)sheet returnCode
:(int)returnCode
;
167 - (void)endSheet
:(NSWindow
*)sheet
;
169 - (void)reportException
:(NSException
*)exception
;
171 - (int)requestUserAttention
:(NSRequestUserAttentionType
)attentionType
;
172 - (void)cancelUserAttentionRequest
:(int)requestNumber
;
174 - (void)runPageLayout
:sender
;
175 - (void)orderFrontColorPanel
:sender
;
176 - (void)orderFrontCharacterPalette
:sender
;
179 - (void)hideOtherApplications
:sender
;
180 - (void)unhide
:sender
;
181 - (void)unhideAllApplications
:sender
;
182 - (void)unhideWithoutActivation
;
184 - (void)terminate
:sender
;
186 - (void)replyToApplicationShouldTerminate
:(BOOL
)terminate
;
187 - (void)replyToOpenOrPrint
:(NSApplicationDelegateReply
)reply
;
189 - (void)arrangeInFront
:sender
;
191 - (NSMenu
*)servicesMenu
;
192 - (void)setServicesMenu
:(NSMenu
*)menu
;
194 - (void)setServicesProvider
:provider
;
195 - (void)registerServicesMenuSendTypes
:(NSArray
*)sendTypes returnTypes
:(NSArray
*)returnTypes
;
196 - validRequestorForSendType
:(NSString
*)sendType returnType
:(NSString
*)returnType
;
198 - (void)orderFrontStandardAboutPanel
:sender
;
199 - (void)orderFrontStandardAboutPanelWithOptions
:(NSDictionary
*)options
;
200 - (void)activateContextHelpMode
:sender
;
201 - (void)showHelp
:sender
;
203 - (NSDockTile
*)dockTile
;
206 - (void)_addWindow
:(NSWindow
*)window
;
208 - (void)_windowWillBecomeActive
:(NSWindow
*)window
;
209 - (void)_windowDidBecomeActive
:(NSWindow
*)window
;
210 - (void)_windowWillBecomeDeactive
:(NSWindow
*)window
;
211 - (void)_windowDidBecomeDeactive
:(NSWindow
*)window
;
215 @interface
NSObject (NSApplication_serviceRequest
)
216 - (BOOL
)writeSelectionToPasteboard
:(NSPasteboard
*)pasteboard types
:(NSArray
*)types
;
219 @interface
NSObject (NSApplication_notifications
)
220 - (void)applicationWillFinishLaunching
:(NSNotification
*)note
;
221 - (void)applicationDidFinishLaunching
:(NSNotification
*)note
;
223 - (void)applicationWillBecomeActive
:(NSNotification
*)note
;
224 - (void)applicationDidBecomeActive
:(NSNotification
*)note
;
225 - (void)applicationWillResignActive
:(NSNotification
*)note
;
226 - (void)applicationDidResignActive
:(NSNotification
*)note
;
228 - (void)applicationWillUpdate
:(NSNotification
*)note
;
229 - (void)applicationDidUpdate
:(NSNotification
*)note
;
231 - (void)applicationWillHide
:(NSNotification
*)note
;
232 - (void)applicationDidHide
:(NSNotification
*)note
;
233 - (void)applicationWillUnhide
:(NSNotification
*)note
;
234 - (void)applicationDidUnhide
:(NSNotification
*)note
;
236 - (void)applicationWillTerminate
:(NSNotification
*)note
;
238 - (void)applicationDidChangeScreenParameters
:(NSNotification
*)note
;
241 @interface
NSObject (NSApplication_delegate
)
242 - (BOOL
)applicationShouldOpenUntitledFile
:(NSApplication
*)application
;
243 - (BOOL
)applicationOpenUntitledFile
:(NSApplication
*)application
;
244 - (BOOL
)application
:(NSApplication
*)application openFile
:(NSString
*)path
;
245 - (void)application
:(NSApplication
*)application openFiles
:(NSArray
*)pathArray
;
246 - (BOOL
)application
:(NSApplication
*)application openFileWithoutUI
:(NSString
*)path
;
247 - (BOOL
)application
:(NSApplication
*)applicationsender openTempFile
:(NSString
*)path
;
248 - (BOOL
)applicationShouldHandleReopen
:(NSApplication
*)application hasVisibleWindows
:(BOOL
)visible
;
250 - (BOOL
)application
:(NSApplication
*)application printFile
:(NSString
*)path
;
251 - (NSApplicationPrintReply
)application
:(NSApplication
*)application printFiles
:(NSArray
*)pathArray withSettings
:(NSDictionary
*)settings showPrintPanels
:(BOOL
)showPanel
;
253 - (NSMenu
*)applicationDockMenu
:(NSApplication
*)application
;
254 - (BOOL
)application
:(NSApplication
*)application delegateHandlesKey
:(NSString
*)key
;
256 - (NSError
*)application
:(NSApplication
*)application willPresentError
:(NSError
*)error
;
258 - (BOOL
)applicationShouldTerminateAfterLastWindowClosed
:(NSApplication
*)application
;
259 - (NSApplicationTerminateReply
)applicationShouldTerminate
:(NSApplication
*)application
;
263 @protocol NSApplicationDelegate
265 // FIXME: @optional is broken in compiler
268 - (BOOL
)application
:(NSApplication
*)theApplication openFile
:(NSString
*)filename
;
269 - (void)application
:(NSApplication
*)sender openFiles
:(NSArray
*)filenames
;
270 - (BOOL
)application
:(id
)sender openFileWithoutUI
:(NSString
*)filename
;
271 - (BOOL
)application
:(NSApplication
*)theApplication openTempFile
:(NSString
*)filename
;
272 - (BOOL
)application
:(NSApplication
*)theApplication printFile
:(NSString
*)filename
;
273 - (NSApplicationPrintReply
)application
:(NSApplication
*)application printFiles
:(NSArray
*)fileNames withSettings
:(NSDictionary
*)printSettings showPrintPanels
:(BOOL
)showPrintPanels
;
274 - (NSError
*)application
:(NSApplication
*)application willPresentError
:(NSError
*)error
;
275 - (void)applicationDidBecomeActive
:(NSNotification
*)aNotification
;
276 - (void)applicationDidChangeScreenParameters
:(NSNotification
*)aNotification
;
277 - (void)applicationDidFinishLaunching
:(NSNotification
*)aNotification
;
278 - (void)applicationDidHide
:(NSNotification
*)aNotification
;
279 - (void)applicationDidResignActive
:(NSNotification
*)aNotification
;
280 - (void)applicationDidUnhide
:(NSNotification
*)aNotification
;
281 - (void)applicationDidUpdate
:(NSNotification
*)aNotification
;
282 - (NSMenu
*)applicationDockMenu
:(NSApplication
*)sender
;
283 - (BOOL
)applicationOpenUntitledFile
:(NSApplication
*)theApplication
;
284 - (BOOL
)applicationShouldHandleReopen
:(NSApplication
*)theApplication hasVisibleWindows
:(BOOL
)flag
;
285 - (BOOL
)applicationShouldOpenUntitledFile
:(NSApplication
*)sender
;
286 - (NSApplicationTerminateReply
)applicationShouldTerminate
:(NSApplication
*)sender
;
287 - (BOOL
)applicationShouldTerminateAfterLastWindowClosed
:(NSApplication
*)theApplication
;
288 - (void)applicationWillBecomeActive
:(NSNotification
*)aNotification
;
289 - (void)applicationWillFinishLaunching
:(NSNotification
*)aNotification
;
290 - (void)applicationWillHide
:(NSNotification
*)aNotification
;
291 - (void)applicationWillResignActive
:(NSNotification
*)aNotification
;
292 - (void)applicationWillTerminate
:(NSNotification
*)aNotification
;
293 - (void)applicationWillUnhide
:(NSNotification
*)aNotification
;
294 - (void)applicationWillUpdate
:(NSNotification
*)aNotification
;
298 APPKIT_EXPORT
int NSApplicationMain(int argc
, const char *argv
[]);
300 APPKIT_EXPORT
void NSUpdateDynamicServices(void);
301 APPKIT_EXPORT BOOL
NSPerformService(NSString
*itemName
, NSPasteboard
*pasteboard
);