summaryrefslogtreecommitdiff
path: root/sysdata_darwin.m
blob: 1eee324972b59c9a7e8664d4849593394016d828 (plain)
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
52
53
54
55
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];
}