From a9717bfb4fd6627d51dfc07c35f393f0a93368ff Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 16 May 2014 09:13:11 -0400 Subject: [PATCH] Organized the dummyRect declarations/definitions/etc. in the Objective-C files. I think that's it for the Objective-C conversion of the Mac OS X code! --- area_darwin.m | 4 +++- delegateuitask_darwin.m | 3 +++ listbox_darwin.m | 4 +++- objc_darwin.m | 5 ++++- sysdata_darwin.m | 5 +---- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/area_darwin.m b/area_darwin.m index 6c58910..a34dcdb 100644 --- a/area_darwin.m +++ b/area_darwin.m @@ -17,6 +17,8 @@ #define toNSUInteger(x) ((NSUInteger) (x)) #define fromNSUInteger(x) ((uintptr_t) (x)) +extern NSRect dummyRect; + @interface areaView : NSView { NSTrackingArea *trackingArea; } @@ -103,7 +105,7 @@ keyEvent(flagsChanged, areaView_flagsChanged) id makeArea(void) { return [[areaView alloc] - initWithFrame:NSMakeRect(0, 0, 100, 100)]; + initWithFrame:dummyRect]; } void drawImage(void *pixels, intptr_t width, intptr_t height, intptr_t stride, intptr_t xdest, intptr_t ydest) diff --git a/delegateuitask_darwin.m b/delegateuitask_darwin.m index 9aeabaf..52074d6 100644 --- a/delegateuitask_darwin.m +++ b/delegateuitask_darwin.m @@ -10,6 +10,8 @@ #include #include +extern NSRect dummyRect; + @interface appDelegate : NSObject @end @@ -56,6 +58,7 @@ id windowGetContentView(id window) BOOL initCocoa(id appDelegate) { + dummyRect = NSMakeRect(0, 0, 100, 100); [NSApplication sharedApplication]; if ([NSApp setActivationPolicy:NSApplicationActivationPolicyRegular] != YES) return NO; diff --git a/listbox_darwin.m b/listbox_darwin.m index 5f3fe88..ff427fd 100644 --- a/listbox_darwin.m +++ b/listbox_darwin.m @@ -19,6 +19,8 @@ #define toNSUInteger(x) ((NSUInteger) (x)) #define fromNSUInteger(x) ((uintptr_t) (x)) +extern NSRect dummyRect; + id toListboxItem(id key, id value) { return [NSMutableDictionary dictionaryWithObject:value forKey:key]; @@ -101,7 +103,7 @@ id makeListbox(id tableColumn, BOOL multisel) NSTableView *listbox; listbox = [[NSTableView alloc] - initWithFrame:NSMakeRect(0, 0, 100, 100)]; + initWithFrame:dummyRect]; [listbox addTableColumn:tableColumn]; [listbox setAllowsMultipleSelection:multisel]; [listbox setAllowsEmptySelection:YES]; diff --git a/objc_darwin.m b/objc_darwin.m index 08113b6..09c2ec2 100644 --- a/objc_darwin.m +++ b/objc_darwin.m @@ -10,6 +10,9 @@ #define toNSView(x) to(NSView, (x)) #define toNSScrollView(x) to(NSScrollView, (x)) +// because the only way to make a new NSControl/NSView is with a frame (it gets overridden later) +NSRect dummyRect; + id toNSString(char *str) { return [NSString stringWithUTF8String:str]; @@ -43,7 +46,7 @@ id makeScrollView(id content) NSScrollView *scrollview; scrollview = [[NSScrollView alloc] - initWithFrame:NSMakeRect(0, 0, 100, 100)]; + initWithFrame:dummyRect]; [scrollview setHasHorizontalScroller:YES]; [scrollview setHasVerticalScroller:YES]; [scrollview setAutohidesScrollers:YES]; diff --git a/sysdata_darwin.m b/sysdata_darwin.m index bb2b1a7..c0d5cab 100644 --- a/sysdata_darwin.m +++ b/sysdata_darwin.m @@ -14,8 +14,7 @@ #include #include -// because the only way to make a new NSControl/NSView is with a frame (it gets overridden later) -static NSRect dummyRect;// = NSMakeRect(0, 0, 100, 100); +extern NSRect dummyRect; #define to(T, x) ((T *) (x)) #define toNSWindow(x) to(NSWindow, (x)) @@ -60,8 +59,6 @@ id makeWindow(id delegate) { NSWindow *w; - // TODO separate to initilaizer - dummyRect = NSMakeRect(0, 0, 100, 100); w = [[NSWindow alloc] initWithContentRect:dummyRect styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)