| 29 #import "window.h" |
29 #import "window.h" |
| 30 |
30 |
| 31 #import "MainWindow.h" |
31 #import "MainWindow.h" |
| 32 #import "WindowManager.h" |
32 #import "WindowManager.h" |
| 33 |
33 |
| |
34 #import <objc/runtime.h> |
| |
35 |
| 34 #include "../ui/window.h" |
36 #include "../ui/window.h" |
| 35 #include "../ui/properties.h" |
37 #include "../ui/properties.h" |
| 36 #include "../common/context.h" |
38 #include "../common/context.h" |
| 37 #include "../common/menu.h" |
39 #include "../common/menu.h" |
| 38 #include "../common/toolbar.h" |
40 #include "../common/toolbar.h" |
| 39 |
41 |
| 40 #include <cx/mempool.h> |
42 #include <cx/mempool.h> |
| |
43 |
| 41 |
44 |
| 42 static UiObject* create_window(const char *title, BOOL simple) { |
45 static UiObject* create_window(const char *title, BOOL simple) { |
| 43 CxMempool *mp = cxMempoolCreateSimple(256); |
46 CxMempool *mp = cxMempoolCreateSimple(256); |
| 44 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
47 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
| 45 obj->ref = 0; |
48 obj->ref = 0; |
| 49 MainWindow *window = [[MainWindow alloc] init:obj]; |
52 MainWindow *window = [[MainWindow alloc] init:obj]; |
| 50 [[WindowManager sharedWindowManager] addWindow:window]; |
53 [[WindowManager sharedWindowManager] addWindow:window]; |
| 51 window.releasedWhenClosed = false; |
54 window.releasedWhenClosed = false; |
| 52 |
55 |
| 53 obj->wobj = (__bridge void*)window; |
56 obj->wobj = (__bridge void*)window; |
| |
57 |
| |
58 MainWindowController *controller = [[MainWindowController alloc] initWithWindow:obj window:window]; |
| |
59 window.windowController = controller; |
| |
60 [window setNextResponder:(NSResponder*)controller]; |
| |
61 objc_setAssociatedObject(window, "windowcontroller", controller, OBJC_ASSOCIATION_RETAIN); |
| 54 |
62 |
| 55 return obj; |
63 return obj; |
| 56 } |
64 } |
| 57 |
65 |
| 58 UiObject* ui_window(const char *title, void *window_data) { |
66 UiObject* ui_window(const char *title, void *window_data) { |