-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathjackwrap.mm
48 lines (39 loc) · 1.16 KB
/
jackwrap.mm
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
#ifdef __APPLE__
#import <Cocoa/Cocoa.h>
static void makeAppMenu (void) {
id menubar = [[NSMenu new] autorelease];
id appMenuItem = [[NSMenuItem new] autorelease];
[menubar addItem:appMenuItem];
[NSApp setMainMenu:menubar];
id appMenu = [[NSMenu new] autorelease];
[appMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
[appMenuItem setSubmenu:appMenu];
}
void rtk_osx_api_init(void) {
[NSAutoreleasePool new];
[NSApplication sharedApplication];
makeAppMenu ();
//[NSApp setDelegate:[NSApplication sharedApplication]];
//[NSApp finishLaunching];
}
#ifndef OSX_SHUTDOWN_WAIT
#define OSX_SHUTDOWN_WAIT 100 // run loop callbacks, jack to allow graceful close
#endif
void rtk_osx_api_terminate(void) {
static int term_from_term = 0;
if (term_from_term) {
[[NSApplication sharedApplication] stop:nil];
}
if (++term_from_term > OSX_SHUTDOWN_WAIT) {
[[NSApplication sharedApplication] terminate:nil];
}
}
void rtk_osx_api_run(void) {
[NSApp run];
}
void rtk_osx_api_err(const char *msg) {
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert setMessageText:[NSString stringWithUTF8String:msg]];
[alert runModal];
}
#endif