summaryrefslogtreecommitdiff
path: root/redo/control_darwin.m
blob: f34f3c2c441fbde70ac45c769615e74fe3b596ae (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
// 30 july 2014

#import "objc_darwin.h"
#import <Cocoa/Cocoa.h>

#define toNSControl(x) ((NSControl *) (x))
#define toNSView(x) ((NSView *) (x))

// also good for NSTableView (TODO might not do what we want) and NSProgressIndicator
struct xsize controlPreferredSize(id control)
{
	NSControl *c;
	NSRect r;
	struct xsize s;

	c = toNSControl(control);
	[c sizeToFit];
	r = [c frame];
	s.width = (intptr_t) r.size.width;
	s.height = (intptr_t) r.size.height;
	return s;
}

// TODO verify this when we add more scrolling controls
// TODO no borders on Area
id newScrollView(id content)
{
	NSScrollView *sv;

	sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
	[sv setDocumentView:toNSView(content)];
	[sv setHasHorizontalScroller:YES];
	[sv setHasVerticalScroller:YES];
	[sv setAutohidesScrollers:YES];
	[sv setBorderType:NSBezelBorder];
	return (id) sv;
}