summaryrefslogtreecommitdiff
path: root/packages/cocoaint/src/appkit/NSApplication.inc
blob: 31f7fe3d34d8cc61c08b6d69babe2a5d41c802a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
{ Parsed from Appkit.framework NSApplication.h }
{ Version: 2.1.2 - Wed Dec 8 10:06:06 CET 2010 }


{$ifdef TYPES}
{$ifndef NSAPPLICATION_PAS_T}
{$define NSAPPLICATION_PAS_T}

{ Defines }
const
  NSAppKitVersionNumber10_0 = 577;
  NSAppKitVersionNumber10_1 = 620;
  NSAppKitVersionNumber10_2 = 663;
  NSAppKitVersionNumber10_2_3 = 663.6;
  NSAppKitVersionNumber10_3 = 743;
  NSAppKitVersionNumber10_3_2 = 743.14;
  NSAppKitVersionNumber10_3_3 = 743.2;
  NSAppKitVersionNumber10_3_5 = 743.24;
  NSAppKitVersionNumber10_3_7 = 743.33;
  NSAppKitVersionNumber10_3_9 = 743.36;
  NSAppKitVersionNumber10_4 = 824;
  NSAppKitVersionNumber10_4_1 = 824.1;
  NSAppKitVersionNumber10_4_3 = 824.23;
  NSAppKitVersionNumber10_4_4 = 824.33;
  NSAppKitVersionNumber10_4_7 = 824.41;
  NSAppKitVersionNumber10_5 = 949;
  NSAppKitVersionNumber10_5_2 = 949.27;
  NSAppKitVersionNumber10_5_3 = 949.33;

{ Constants }

const
  NSRunStoppedResponse = -1000;
  NSRunAbortedResponse = -1001;
  NSRunContinuesResponse = -1002;

const
  NSUpdateWindowsRunLoopOrdering = 500000;

const
  NSApplicationPresentationDefault = 0;
  NSApplicationPresentationAutoHideDock = 1 shl  0;
  NSApplicationPresentationHideDock = 1 shl  1;
  NSApplicationPresentationAutoHideMenuBar = 1 shl  2;
  NSApplicationPresentationHideMenuBar = 1 shl  3;
  NSApplicationPresentationDisableAppleMenu = 1 shl  4;
  NSApplicationPresentationDisableProcessSwitching = 1 shl  5;
  NSApplicationPresentationDisableForceQuit = 1 shl  6;
  NSApplicationPresentationDisableSessionTermination = 1 shl  7;
  NSApplicationPresentationDisableHideApplication = 1 shl  8;
  NSApplicationPresentationDisableMenuBarTransparency = 1 shl  9;

const
  NSCriticalRequest = 0;
  NSInformationalRequest = 10;

const
  NSApplicationDelegateReplySuccess = 0;
  NSApplicationDelegateReplyCancel = 1;
  NSApplicationDelegateReplyFailure = 2;

const
  NSTerminateCancel = 0;
  NSTerminateNow = 1;
  NSTerminateLater = 2;

const
  NSPrintingCancelled = 0;
  NSPrintingSuccess = 1;
  NSPrintingFailure = 3;
  NSPrintingReplyLater = 2;

const
  NSUserInterfaceLayoutDirectionLeftToRight = 0;
  NSUserInterfaceLayoutDirectionRightToLeft = 1;

{ Types }
type
  NSApplicationPresentationOptions = NSUInteger;
  NSApplicationPresentationOptionsPtr = ^NSApplicationPresentationOptions;
  NSModalSession = Pointer;
  NSModalSessionPtr = ^NSModalSession;
  NSThreadPrivate = record end;
  _NSThreadPrivate = NSThreadPrivate;
  _NSThreadPrivatePtr = ^_NSThreadPrivate;
  NSRequestUserAttentionType = NSUInteger;
  NSRequestUserAttentionTypePtr = ^NSRequestUserAttentionType;
  NSApplicationDelegateReply = NSUInteger;
  NSApplicationDelegateReplyPtr = ^NSApplicationDelegateReply;
  NSApplicationTerminateReply = NSUInteger;
  NSApplicationTerminateReplyPtr = ^NSApplicationTerminateReply;
  NSApplicationPrintReply = NSUInteger;
  NSApplicationPrintReplyPtr = ^NSApplicationPrintReply;
  NSUserInterfaceLayoutDirection = NSInteger;
  NSUserInterfaceLayoutDirectionPtr = ^NSUserInterfaceLayoutDirection;

{$endif}
{$endif}

{$ifdef RECORDS}
{$ifndef NSAPPLICATION_PAS_R}
{$define NSAPPLICATION_PAS_R}

{$endif}
{$endif}

{$ifdef FUNCTIONS}
{$ifndef NSAPPLICATION_PAS_F}
{$define NSAPPLICATION_PAS_F}

{ Functions }
function NSApplicationMain(argc: cint; argv: PPChar {array of PChar}): cint; cdecl; external;
function NSApplicationLoad: Boolean; cdecl; external;
function NSShowsServicesMenuItem(itemName: NSString): Boolean; cdecl; external;
function NSSetShowsServicesMenuItem(itemName: NSString; enabled: Boolean): NSInteger; cdecl; external;
procedure NSUpdateDynamicServices; cdecl; external;
function NSPerformService(itemName: NSString; pboard: NSPasteboard): Boolean; cdecl; external;
procedure NSRegisterServicesProvider(provider: id; name: NSString); cdecl; external;
procedure NSUnregisterServicesProvider(name: NSString); cdecl; external;

{$endif}
{$endif}

{$ifdef EXTERNAL_SYMBOLS}
{$ifndef NSAPPLICATION_PAS_S}
{$define NSAPPLICATION_PAS_S}

{ External symbols }
var
  NSAppKitVersionNumber: double; cvar; external;
  NSApp: id; cvar; external;

{ External string constants }
var
  NSModalPanelRunLoopMode: NSString; cvar; external;
  NSEventTrackingRunLoopMode: NSString; cvar; external;
  NSApplicationDidBecomeActiveNotification: NSString; cvar; external;
  NSApplicationDidHideNotification: NSString; cvar; external;
  NSApplicationDidFinishLaunchingNotification: NSString; cvar; external;
  NSApplicationDidResignActiveNotification: NSString; cvar; external;
  NSApplicationDidUnhideNotification: NSString; cvar; external;
  NSApplicationDidUpdateNotification: NSString; cvar; external;
  NSApplicationWillBecomeActiveNotification: NSString; cvar; external;
  NSApplicationWillHideNotification: NSString; cvar; external;
  NSApplicationWillFinishLaunchingNotification: NSString; cvar; external;
  NSApplicationWillResignActiveNotification: NSString; cvar; external;
  NSApplicationWillUnhideNotification: NSString; cvar; external;
  NSApplicationWillUpdateNotification: NSString; cvar; external;
  NSApplicationWillTerminateNotification: NSString; cvar; external;
  NSApplicationDidChangeScreenParametersNotification: NSString; cvar; external;

{$endif}
{$endif}

{$ifdef FORWARD}
  NSApplicationDelegateProtocol = objcprotocol;
  NSApplication = objcclass;
  NSApplicationPointer = ^NSApplication;
  NSApplicationPtr = NSApplicationPointer;

{$endif}

{$ifdef CLASSES}
{$ifndef NSAPPLICATION_PAS_C}
{$define NSAPPLICATION_PAS_C}

{ NSApplication }
  NSApplication = objcclass(NSResponder, NSUserInterfaceValidationsProtocol)
  private
    _currentEvent: NSEvent;
    _windowList: id;
    _keyWindow: id;
    _mainWindow: id;
    _delegate: id;
    _hiddenList: idPtr;
    _hiddenCount: cint;
    _context: NSInteger;
    _appleEventSuspensionID: Pointer;
    _previousKeyWindow: id; {garbage collector: __weak }
    _unusedApp: cshort;
    _running: cshort;
    __appFlags: bitpacked record
      case byte of
       0: (_anonbitfield_NSApplication0: cuint);
       1: (
        _hidden: 0..1;
        _RESERVED1: 0..1;
        _active: 0..1;
        _hasBeenRun: 0..1;
        _doingUnhide: 0..1;
        _delegateReturnsValidRequestor: 0..1;
        _deactPending: 0..1;
        _invalidState: 0..1;
        _invalidEvent: 0..1;
        _postedWindowsNeedUpdateNote: 0..1;
        _wantsToActivate: 0..1;
        _doingHide: 0..1;
        _dontSendShouldTerminate: 0..1;
        _skipWin32DelayedRestoreKeyWindowAfterHide: 0..1;
        _finishedLaunching: 0..1;
        _hasEventDelegate: 0..1;
        _appDying: 0..1;
        _didNSOpenOrPrint: 0..1;
        _inDealloc: 0..1;
        _pendingDidFinish: 0..1;
        _hasKeyFocus: 0..1;
        _panelsNonactivating: 0..1;
        _hiddenOnLaunch: 0..1;
        _openStatus: 0..((1 shl 2)-1);
        _batchOrdering: 0..1;
        _waitingForTerminationReply: 0..1;
        _windowMoveDisabled: 0..1;
        _reserved: 0..((1 shl 4)-1);
      );
      end;
    _mainMenu: id;
    _appIcon: id;
    _nameTable: id;
    _eventDelegate: id;
    _threadingSupport: _NSThreadPrivatePtr;
    
  public
    class function alloc: NSApplication; message 'alloc';

    class function sharedApplication: NSApplication; message 'sharedApplication';
    procedure setDelegate(anObject: id); message 'setDelegate:';
    function delegate: id; message 'delegate';
    function context: NSGraphicsContext; message 'context';
    procedure hide(sender: id); message 'hide:';
    procedure unhide(sender: id); message 'unhide:';
    procedure unhideWithoutActivation; message 'unhideWithoutActivation';
    function windowWithWindowNumber(windowNum: NSInteger): NSWindow; message 'windowWithWindowNumber:';
    function mainWindow: NSWindow; message 'mainWindow';
    function keyWindow: NSWindow; message 'keyWindow';
    function isActive: Boolean; message 'isActive';
    function isHidden: Boolean; message 'isHidden';
    function isRunning: Boolean; message 'isRunning';
    procedure deactivate; message 'deactivate';
    procedure activateIgnoringOtherApps(flag: Boolean); message 'activateIgnoringOtherApps:';
    procedure hideOtherApplications(sender: id); message 'hideOtherApplications:';
    procedure unhideAllApplications(sender: id); message 'unhideAllApplications:';
    procedure finishLaunching; message 'finishLaunching';
    procedure run; message 'run';
    function runModalForWindow(theWindow: NSWindow): NSInteger; message 'runModalForWindow:';
    procedure stop(sender: id); message 'stop:';
    procedure stopModal; message 'stopModal';
    procedure stopModalWithCode(returnCode: NSInteger); message 'stopModalWithCode:';
    procedure abortModal; message 'abortModal';
    function modalWindow: NSWindow; message 'modalWindow';
    function beginModalSessionForWindow(theWindow: NSWindow): NSModalSession; message 'beginModalSessionForWindow:';
    function runModalSession(session: NSModalSession): NSInteger; message 'runModalSession:';
    procedure endModalSession(session: NSModalSession); message 'endModalSession:';
    procedure terminate(sender: id); message 'terminate:';
    function requestUserAttention(requestType: NSRequestUserAttentionType): NSInteger; message 'requestUserAttention:';
    procedure cancelUserAttentionRequest(request: NSInteger); message 'cancelUserAttentionRequest:';
    procedure beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(sheet: NSWindow; docWindow: NSWindow; modalDelegate: id; didEndSelector: SEL; contextInfo: Pointer); message 'beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:';
    procedure endSheet(sheet: NSWindow); message 'endSheet:';
    procedure endSheet_returnCode(sheet: NSWindow; returnCode: NSInteger); message 'endSheet:returnCode:';
    function nextEventMatchingMask_untilDate_inMode_dequeue(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: Boolean): NSEvent; message 'nextEventMatchingMask:untilDate:inMode:dequeue:';
    procedure discardEventsMatchingMask_beforeEvent(mask: NSUInteger; lastEvent: NSEvent); message 'discardEventsMatchingMask:beforeEvent:';
    procedure postEvent_atStart(event: NSEvent; flag: Boolean); message 'postEvent:atStart:';
    function currentEvent: NSEvent; message 'currentEvent';
    procedure sendEvent(theEvent: NSEvent); message 'sendEvent:';
    procedure preventWindowOrdering; message 'preventWindowOrdering';
    function makeWindowsPerform_inOrder(aSelector: SEL; flag: Boolean): NSWindow; message 'makeWindowsPerform:inOrder:';
    function windows: NSArray; message 'windows';
    procedure setWindowsNeedUpdate(needUpdate: Boolean); message 'setWindowsNeedUpdate:';
    procedure updateWindows; message 'updateWindows';
    procedure setMainMenu(aMenu: NSMenu); message 'setMainMenu:';
    function mainMenu: NSMenu; message 'mainMenu';
    procedure setHelpMenu(helpMenu: NSMenu); message 'setHelpMenu:';
    function helpMenu: NSMenu; message 'helpMenu';
    procedure setApplicationIconImage(image: NSImage); message 'setApplicationIconImage:';
    function applicationIconImage: NSImage; message 'applicationIconImage';
    function activationPolicy: NSApplicationActivationPolicy; message 'activationPolicy';
    function setActivationPolicy(activationPolicy_: NSApplicationActivationPolicy): Boolean; message 'setActivationPolicy:';
    function dockTile: NSDockTile; message 'dockTile';
    function sendAction_to_from(theAction: SEL; theTarget: id; sender: id): Boolean; message 'sendAction:to:from:';
    function targetForAction(theAction: SEL): id; message 'targetForAction:';
    function targetForAction_to_from(theAction: SEL; theTarget: id; sender: id): id; message 'targetForAction:to:from:';
    function tryToPerform_with(anAction: SEL; anObject: id): Boolean; message 'tryToPerform:with:';
    function validRequestorForSendType_returnType(sendType: NSString; returnType: NSString): id; message 'validRequestorForSendType:returnType:';
    procedure reportException(theException: NSException); message 'reportException:';
    class procedure detachDrawingThread_toTarget_withObject(selector: SEL; target: id; argument: id); message 'detachDrawingThread:toTarget:withObject:';
    procedure replyToApplicationShouldTerminate(shouldTerminate: Boolean); message 'replyToApplicationShouldTerminate:';
    procedure replyToOpenOrPrint(reply: NSApplicationDelegateReply); message 'replyToOpenOrPrint:';
    procedure orderFrontCharacterPalette(sender: id); message 'orderFrontCharacterPalette:';
    function presentationOptions: NSApplicationPresentationOptions; message 'presentationOptions';
    procedure setPresentationOptions(newOptions: NSApplicationPresentationOptions); message 'setPresentationOptions:';
    function currentSystemPresentationOptions: NSApplicationPresentationOptions; message 'currentSystemPresentationOptions';

    { Adopted Protocols }
    function validateUserInterfaceItem(anItem: id): Boolean;
  end; external;

{ NSWindowsMenuCategory }
  NSWindowsMenuCategory = objccategory(NSApplication)
    procedure setWindowsMenu(aMenu: NSMenu); message 'setWindowsMenu:';
    function windowsMenu: NSMenu; message 'windowsMenu';
    procedure arrangeInFront(sender: id); message 'arrangeInFront:';
    procedure removeWindowsItem(win: NSWindow); message 'removeWindowsItem:';
    procedure addWindowsItem_title_filename(win: NSWindow; aString: NSString; isFilename: Boolean); message 'addWindowsItem:title:filename:';
    procedure changeWindowsItem_title_filename(win: NSWindow; aString: NSString; isFilename: Boolean); message 'changeWindowsItem:title:filename:';
    procedure updateWindowsItem(win: NSWindow); message 'updateWindowsItem:';
    procedure miniaturizeAll(sender: id); message 'miniaturizeAll:';
  end; external;

{ NSFullKeyboardAccessCategory }
  NSFullKeyboardAccessCategory = objccategory(NSApplication)
    function isFullKeyboardAccessEnabled: Boolean; message 'isFullKeyboardAccessEnabled';
  end; external;

{ NSServicesMenuCategory }
  NSServicesMenuCategory = objccategory(NSApplication)
    procedure setServicesMenu(aMenu: NSMenu); message 'setServicesMenu:';
    function servicesMenu: NSMenu; message 'servicesMenu';
    procedure registerServicesMenuSendTypes_returnTypes(sendTypes: NSArray; returnTypes: NSArray); message 'registerServicesMenuSendTypes:returnTypes:';
  end; external;

{ NSServicesRequestsCategory }
  NSServicesRequestsCategory = objccategory(NSObject)
    function writeSelectionToPasteboard_types(pboard: NSPasteboard; types: NSArray): Boolean; message 'writeSelectionToPasteboard:types:';
    function readSelectionFromPasteboard(pboard: NSPasteboard): Boolean; message 'readSelectionFromPasteboard:';
  end; external;

{ NSServicesHandlingCategory }
  NSServicesHandlingCategory = objccategory(NSApplication)
    procedure setServicesProvider(provider: id); message 'setServicesProvider:';
    function servicesProvider: id; message 'servicesProvider';
  end; external;

{ NSStandardAboutPanelCategory }
  NSStandardAboutPanelCategory = objccategory(NSApplication)
    procedure orderFrontStandardAboutPanel(sender: id); message 'orderFrontStandardAboutPanel:';
    procedure orderFrontStandardAboutPanelWithOptions(optionsDictionary: NSDictionary); message 'orderFrontStandardAboutPanelWithOptions:';
  end; external;

{ NSApplicationLayoutDirectionCategory }
  NSApplicationLayoutDirectionCategory = objccategory(NSApplication)
    function userInterfaceLayoutDirection: NSUserInterfaceLayoutDirection; message 'userInterfaceLayoutDirection';
  end; external;

{ NSDeprecated_NSApplicationCategory }
  NSDeprecated_NSApplicationCategory = objccategory(NSApplication)
    function runModalForWindow_relativeToWindow(theWindow: NSWindow; docWindow: NSWindow): NSInteger; message 'runModalForWindow:relativeToWindow:'; deprecated 'in Mac OS X 10 and later';
    function beginModalSessionForWindow_relativeToWindow(theWindow: NSWindow; docWindow: NSWindow): NSModalSession; message 'beginModalSessionForWindow:relativeToWindow:'; deprecated 'in Mac OS X 10 and later';
    procedure application_printFiles(sender: NSApplication; filenames: NSArray); message 'application:printFiles:';
  end; external name 'NSDeprecated';

{$endif}
{$endif}
{$ifdef PROTOCOLS}
{$ifndef NSAPPLICATION_PAS_P}
{$define NSAPPLICATION_PAS_P}
  
{ NSApplicationDelegate Protocol }
  NSApplicationDelegateProtocol = objcprotocol
    function applicationShouldTerminate(sender: NSApplication): NSApplicationTerminateReply; message 'applicationShouldTerminate:';
    function application_openFile(sender: NSApplication; filename: NSString): Boolean; message 'application:openFile:';
    procedure application_openFiles(sender: NSApplication; filenames: NSArray); message 'application:openFiles:';
    function application_openTempFile(sender: NSApplication; filename: NSString): Boolean; message 'application:openTempFile:';
    function applicationShouldOpenUntitledFile(sender: NSApplication): Boolean; message 'applicationShouldOpenUntitledFile:';
    function applicationOpenUntitledFile(sender: NSApplication): Boolean; message 'applicationOpenUntitledFile:';
    function application_openFileWithoutUI(sender: id; filename: NSString): Boolean; message 'application:openFileWithoutUI:';
    function application_printFile(sender: NSApplication; filename: NSString): Boolean; message 'application:printFile:';
    function application_printFiles_withSettings_showPrintPanels(application: NSApplication; fileNames: NSArray; printSettings: NSDictionary; showPrintPanels: Boolean): NSApplicationPrintReply; message 'application:printFiles:withSettings:showPrintPanels:';
    function applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication): Boolean; message 'applicationShouldTerminateAfterLastWindowClosed:';
    function applicationShouldHandleReopen_hasVisibleWindows(sender: NSApplication; flag: Boolean): Boolean; message 'applicationShouldHandleReopen:hasVisibleWindows:';
    function applicationDockMenu(sender: NSApplication): NSMenu; message 'applicationDockMenu:';
    function application_willPresentError(application: NSApplication; error: NSError): NSError; message 'application:willPresentError:';
    procedure applicationWillFinishLaunching(notification: NSNotification); message 'applicationWillFinishLaunching:';
    procedure applicationDidFinishLaunching(notification: NSNotification); message 'applicationDidFinishLaunching:';
    procedure applicationWillHide(notification: NSNotification); message 'applicationWillHide:';
    procedure applicationDidHide(notification: NSNotification); message 'applicationDidHide:';
    procedure applicationWillUnhide(notification: NSNotification); message 'applicationWillUnhide:';
    procedure applicationDidUnhide(notification: NSNotification); message 'applicationDidUnhide:';
    procedure applicationWillBecomeActive(notification: NSNotification); message 'applicationWillBecomeActive:';
    procedure applicationDidBecomeActive(notification: NSNotification); message 'applicationDidBecomeActive:';
    procedure applicationWillResignActive(notification: NSNotification); message 'applicationWillResignActive:';
    procedure applicationDidResignActive(notification: NSNotification); message 'applicationDidResignActive:';
    procedure applicationWillUpdate(notification: NSNotification); message 'applicationWillUpdate:';
    procedure applicationDidUpdate(notification: NSNotification); message 'applicationDidUpdate:';
    procedure applicationWillTerminate(notification: NSNotification); message 'applicationWillTerminate:';
    procedure applicationDidChangeScreenParameters(notification: NSNotification); message 'applicationDidChangeScreenParameters:';
  end; external name 'NSApplicationDelegate';
{$endif}
{$endif}