Debian Codegraph @

phoenix/cocoa/action/radio-item.cpp

raw
1 @implementation CocoaRadioItem : NSMenuItem
2
3 -(id) initWith:(phoenix::RadioItem&)radioItemReference {
4 if(self = [super initWithTitle:@"" action:@selector(activate) keyEquivalent:@""]) {
5 radioItem = &radioItemReference;
6
7 [self setTarget:self];
8 [self setOnStateImage:[NSImage imageNamed:@"NSMenuRadio"]];
9 }
10 return self;
11 }
12
13 -(void) activate {
14 radioItem->setChecked();
15 if(radioItem->onActivate) radioItem->onActivate();
16 }
17
18 @end
19
20 namespace phoenix {
21
22 void pRadioItem::setChecked() {
23 @autoreleasepool {
24 for(auto& item : radioItem.state.group) {
25 auto state = (&item == &radioItem) ? NSOnState : NSOffState;
26 [item.p.cocoaAction setState:state];
27 }
28 }
29 }
30
31 void pRadioItem::setGroup(const group<RadioItem>& group) {
32 }
33
34 void pRadioItem::setText(string text) {
35 @autoreleasepool {
36 [cocoaAction setTitle:[NSString stringWithUTF8String:text]];
37 }
38 }
39
40 void pRadioItem::constructor() {
41 @autoreleasepool {
42 cocoaAction = cocoaRadioItem = [[CocoaRadioItem alloc] initWith:radioItem];
43 setText(radioItem.state.text);
44 }
45 }
46
47 void pRadioItem::destructor() {
48 @autoreleasepool {
49 [cocoaAction release];
50 }
51 }
52
53 }