libui/darwin/label.m

60 lines
1.2 KiB
Mathematica
Raw Normal View History

2015-04-11 22:49:34 -05:00
// 9 april 2015
#import "uipriv_darwin.h"
@interface uiLabelNSTextField : NSTextField
@property uiLabel *uiL;
2015-04-11 22:49:34 -05:00
@end
@implementation uiLabelNSTextField
- (void)viewDidMoveToSuperview
{
if (uiDarwinControlFreeWhenAppropriate(uiControl(self.uiL), [self superview])) {
2015-04-11 22:49:34 -05:00
[self setTarget:nil];
self.uiL = NULL;
2015-04-11 22:49:34 -05:00
}
[super viewDidMoveToSuperview];
}
@end
static char *labelText(uiLabel *l)
2015-04-11 22:49:34 -05:00
{
uiLabelNSTextField *t;
2015-04-11 22:49:34 -05:00
t = (uiLabelNSTextField *) uiControlHandle(uiControl(l));
return uiDarwinNSStringToText([t stringValue]);
2015-04-11 22:49:34 -05:00
}
static void labelSetText(uiLabel *l, const char *text)
2015-04-11 22:49:34 -05:00
{
uiLabelNSTextField *t;
t = (uiLabelNSTextField *) uiControlHandle(uiControl(l));
[t setStringValue:toNSString(text)];
2015-04-11 22:49:34 -05:00
}
uiControl *uiNewLabel(const char *text)
2015-04-11 22:49:34 -05:00
{
uiLabel *l;
2015-04-11 22:49:34 -05:00
uiLabelNSTextField *t;
l = uiNew(uiLabel);
uiDarwinNewControl(uiControl(l), [uiLabelNSTextField class], NO, NO);
2015-04-11 22:49:34 -05:00
t = (uiLabelNSTextField *) uiControlHandle(c);
2015-04-11 22:49:34 -05:00
[t setStringValue:toNSString(text)];
[t setEditable:NO];
[t setSelectable:NO];
[t setDrawsBackground:NO];
finishNewTextField((NSTextField *) t, NO);
uiLabel(l)->Text = labelText;
uiLabel(l)->SetText = labelSetText;
t.uiC = l;
return t.uiC;
2015-04-11 22:49:34 -05:00
}