libui/darwin/label.m

51 lines
961 B
Mathematica
Raw Normal View History

2015-04-11 22:49:34 -05:00
// 9 april 2015
#import "uipriv_darwin.h"
struct label {
uiLabel l;
NSTextField *label;
};
2015-04-11 22:49:34 -05:00
static void destroy(void *data)
2015-04-11 22:49:34 -05:00
{
struct label *l = (struct label *) data;
2015-04-11 22:49:34 -05:00
uiFree(l);
}
2015-04-11 22:49:34 -05:00
static char *labelText(uiLabel *ll)
2015-04-11 22:49:34 -05:00
{
struct label *l = (struct label *) ll;
2015-04-11 22:49:34 -05:00
return uiDarwinNSStringToText([l->label stringValue]);
2015-04-11 22:49:34 -05:00
}
static void labelSetText(uiLabel *ll, const char *text)
2015-04-11 22:49:34 -05:00
{
struct label *l = (struct label *) ll;
2015-04-11 22:49:34 -05:00
[l->label setStringValue:toNSString(text)];
2015-04-11 22:49:34 -05:00
}
uiLabel *uiNewLabel(const char *text)
2015-04-11 22:49:34 -05:00
{
struct label *l;
2015-04-11 22:49:34 -05:00
l = uiNew(struct label);
uiDarwinMakeControl(uiControl(l), [NSTextField class], NO, NO, destroy, l);
l->label = (NSTextField *) uiControlHandle(uiControl(l));
[l->label setStringValue:toNSString(text)];
[l->label setEditable:NO];
[l->label setSelectable:NO];
[l->label setDrawsBackground:NO];
finishNewTextField(l->label, NO);
uiLabel(l)->Text = labelText;
uiLabel(l)->SetText = labelSetText;
return uiLabel(l);
2015-04-11 22:49:34 -05:00
}