diff options
| author | Pietro Gagliardi <[email protected]> | 2014-05-12 15:15:26 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-05-12 15:15:26 -0400 |
| commit | f14614c0c7c98f160e27964dd8926cdc778712d0 (patch) | |
| tree | 3bf10e2de54c355ab318577aeafb205054d0cfcd /sysdata_darwin.m | |
| parent | 05c71e0d252cb9dda500706cbdb939f81b714f1b (diff) | |
Began the migration to native Objective-C by moving the NSWindow functions and some of the shared helper routines.
Diffstat (limited to 'sysdata_darwin.m')
| -rw-r--r-- | sysdata_darwin.m | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/sysdata_darwin.m b/sysdata_darwin.m new file mode 100644 index 0000000..1eee324 --- /dev/null +++ b/sysdata_darwin.m @@ -0,0 +1,56 @@ +// 12 may 2014 + +//#include "sysdata_darwin.h" +#include "objc_darwin.h" +#include <Foundation/NSGeometry.h> +#include <AppKit/NSWindow.h> +#include <AppKit/NSView.h> +#include <AppKit/NSCell.h> + +static NSRect dummyRect;// = NSMakeRect(0, 0, 100, 100); + +#define to(T, x) ((T *) x) +#define toNSWindow(x) to(NSWindow, x) +#define toNSView(x) to(NSView, x) + +void addControl(id parentWindow, id control) +{ + [[toNSWindow(parentWindow) contentView] addSubview:control]; +} + +void controlShow(id what) +{ + [toNSView(what) setHidden:NO]; +} + +void controlHide(id what) +{ + [toNSView(what) setHidden:YES]; +} + +void applyStandardControlFont(id what) +{ + // TODO inline this + objc_setFont(what, NSRegularControlSize); +} + +id makeWindow(void) +{ + // TODO separate to initilaizer + dummyRect = NSMakeRect(0, 0, 100, 100); + return [[NSWindow alloc] + initWithContentRect:dummyRect + styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask) + backing:NSBackingStoreBuffered + defer:YES]; // defer creation of device until we show the window +} + +void windowShow(id window) +{ + [toNSWindow(window) makeKeyAndOrderFront:window]; +} + +void windowHide(id window) +{ + [toNSWindow(window) orderOut:window]; +} |
