libui/redo/darwin/label.m

44 lines
965 B
Mathematica
Raw Normal View History

2015-08-14 21:50:20 -05:00
// 14 august 2015
#import "uipriv_darwin.h"
struct uiLabel {
uiDarwinControl c;
2015-08-17 14:20:46 -05:00
NSTextField *textfield;
2015-08-14 21:50:20 -05:00
};
uiDarwinDefineControl(
uiLabel, // type name
uiLabelType, // type function
textfield // handle
)
char *uiLabelText(uiLabel *l)
2015-08-14 21:50:20 -05:00
{
return uiDarwinNSStringToText([l->textfield stringValue]);
}
void uiLabelSetText(uiLabel *l, const char *text)
{
[l->textfield setStringValue:toNSString(text)];
// changing the text might necessitate a change in the label's size
uiDarwinControlTriggerRelayout(uiDarwinControl(l));
2015-08-14 21:50:20 -05:00
}
uiLabel *uiNewLabel(const char *text)
{
uiLabel *l;
l = (uiLabel *) uiNewControl(uiLabelType());
l->textfield = [[NSTextField alloc] initWithFrame:NSZeroRect];
[l->textfield setStringValue:toNSString(text)];
[l->textfield setEditable:NO];
[l->textfield setSelectable:NO];
[l->textfield setDrawsBackground:NO];
finishNewTextField(l->textfield, NO);
uiDarwinFinishNewControl(l, uiLabel);
return l;
}