Implemented uiLabel on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2015-04-11 23:49:34 -04:00
parent ca6b5c9dfd
commit 7f984b29e2
2 changed files with 56 additions and 0 deletions

53
label_darwin.m Normal file
View File

@ -0,0 +1,53 @@
// 9 april 2015
#import "uipriv_darwin.h"
@interface uiLabelNSTextField : NSTextField
@property uiControl *uiC;
@end
@implementation uiLabelNSTextField
- (void)viewDidMoveToSuperview
{
if (uiDarwinControlFreeWhenAppropriate(self.uiC, [self superview])) {
[self setTarget:nil];
self.uiC = NULL;
}
[super viewDidMoveToSuperview];
}
@end
uiControl *uiNewLabel(const char *text)
{
uiControl *c;
uiLabelNSTextField *l;
c = uiDarwinNewControl([uiLabelNSTextField class], NO, NO);
l = (uiLabelNSTextField *) uiControlHandle(c);
l.uiC = c;
[l setStringValue:toNSString(text)];
[l setEditable:NO];
[l setSelectable:NO];
[l setDrawsBackground:NO];
finishNewTextField((NSTextField *) l, NO);
return l.uiC;
}
char *uiLabelText(uiControl *c)
{
uiLabelNSTextField *t;
t = (uiLabelNSTextField *) uiControlHandle(c);
return uiDarwinNSStringToText([t stringValue]);
}
void uiLabelSetText(uiControl *c, const char *text)
{
uiLabelNSTextField *t;
t = (uiLabelNSTextField *) uiControlHandle(c);
[t setStringValue:toNSString(text)];
}

View File

@ -38,3 +38,6 @@ extern void disableAutocorrect(NSTextView *);
- (BOOL)uiMargined;
- (void)uiSetMargined:(BOOL)margined;
@end
// entry_darwin.m
extern void finishNewTextField(NSTextField *, BOOL);