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