blob: 87c45250190377201839a9320aaf33bbc7b5bbb8 (
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
57
58
59
|
// 7 april 2015
#import "uipriv_darwin.h"
@interface button : NSObject
@property uiControl *c;
@property void (*onClicked)(uiControl *, void *);
@property void *onClickedData;
@end
@implementation button
uiLogObjCClassAllocations
- (IBAction)buttonClicked:(id)sender
{
(*(self.onClicked))(self.c, self.onClickedData);
}
@end
static void defaultOnClicked(uiControl *c, void *data)
{
// do nothing
}
// TODO destruction
uiControl *uiNewButton(const char *text)
{
button *b;
NSButton *bb;
b = [button new];
b.c = uiDarwinNewControl([NSButton class], NO, NO, b);
bb = (NSButton *) uiControlHandle(b.c);
[bb setTitle:toNSString(text)];
[bb setButtonType:NSMomentaryPushInButton];
[bb setBordered:YES];
[bb setBezelStyle:NSRoundedBezelStyle];
setStandardControlFont((NSControl *) bb);
[bb setTarget:b];
[bb setAction:@selector(buttonClicked:)];
b.onClicked = defaultOnClicked;
return b.c;
}
// TODO text
void uiButtonOnClicked(uiControl *c, void (*f)(uiControl *, void *), void *data)
{
button *b;
b = (button *) uiDarwinControlData(c);
b.onClicked = f;
b.onClickedData = data;
}
|