Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
51 lines (36 loc) · 1.13 KB

testnativecocoa.m

File metadata and controls

51 lines (36 loc) · 1.13 KB
 
Jun 22, 2011
Jun 22, 2011
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
#include "testnative.h"
#ifdef TEST_NATIVE_COCOA
#include <Cocoa/Cocoa.h>
static void *CreateWindowCocoa(int w, int h);
static void DestroyWindowCocoa(void *window);
NativeWindowFactory CocoaWindowFactory = {
"cocoa",
CreateWindowCocoa,
DestroyWindowCocoa
};
static void *CreateWindowCocoa(int w, int h)
{
NSAutoreleasePool *pool;
NSWindow *nswindow;
NSRect rect;
unsigned int style;
pool = [[NSAutoreleasePool alloc] init];
rect.origin.x = 0;
rect.origin.y = 0;
rect.size.width = w;
rect.size.height = h;
rect.origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - rect.origin.y - rect.size.height;
style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
nswindow = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE];
[nswindow makeKeyAndOrderFront:nil];
[pool release];
return nswindow;
}
static void DestroyWindowCocoa(void *window)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *nswindow = (NSWindow *)window;
[nswindow close];
[pool release];
}
#endif