More OS X uiControl work.
This commit is contained in:
parent
d5744df476
commit
62b5365577
|
@ -1,50 +0,0 @@
|
||||||
// 9 april 2015
|
|
||||||
#import "uipriv_darwin.h"
|
|
||||||
|
|
||||||
struct label {
|
|
||||||
uiLabel l;
|
|
||||||
NSTextField *label;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void destroy(void *data)
|
|
||||||
{
|
|
||||||
struct label *l = (struct label *) data;
|
|
||||||
|
|
||||||
uiFree(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *labelText(uiLabel *ll)
|
|
||||||
{
|
|
||||||
struct label *l = (struct label *) ll;
|
|
||||||
|
|
||||||
return uiDarwinNSStringToText([l->label stringValue]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void labelSetText(uiLabel *ll, const char *text)
|
|
||||||
{
|
|
||||||
struct label *l = (struct label *) ll;
|
|
||||||
|
|
||||||
[l->label setStringValue:toNSString(text)];
|
|
||||||
}
|
|
||||||
|
|
||||||
uiLabel *uiNewLabel(const char *text)
|
|
||||||
{
|
|
||||||
struct label *l;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
struct label {
|
struct label {
|
||||||
uiLabel l;
|
uiLabel l;
|
||||||
OSTYPE *OSHANDLE;
|
NSTextField *label;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiDefineControlType(uiLabel, uiTypeLabel, struct label)
|
uiDefineControlType(uiLabel, uiTypeLabel, struct label)
|
||||||
|
@ -12,21 +12,21 @@ static uintptr_t labelHandle(uiControl *c)
|
||||||
{
|
{
|
||||||
struct label *l = (struct label *) c;
|
struct label *l = (struct label *) c;
|
||||||
|
|
||||||
return (uintptr_t) (l->OSHANDLE);
|
return (uintptr_t) (l->label);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *labelText(uiLabel *ll)
|
static char *labelText(uiLabel *ll)
|
||||||
{
|
{
|
||||||
struct label *l = (struct label *) ll;
|
struct label *l = (struct label *) ll;
|
||||||
|
|
||||||
return PUT_CODE_HERE;
|
return uiDarwinNSStringToText([l->label stringValue]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void labelSetText(uiLabel *ll, const char *text)
|
static void labelSetText(uiLabel *ll, const char *text)
|
||||||
{
|
{
|
||||||
struct label *l = (struct label *) ll;
|
struct label *l = (struct label *) ll;
|
||||||
|
|
||||||
PUT_CODE_HERE;
|
[l->label setStringValue:toNSString(text)];
|
||||||
// changing the text might necessitate a change in the label's size
|
// changing the text might necessitate a change in the label's size
|
||||||
uiControlQueueResize(uiControl(l));
|
uiControlQueueResize(uiControl(l));
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,15 @@ uiLabel *uiNewLabel(const char *text)
|
||||||
{
|
{
|
||||||
struct label *l;
|
struct label *l;
|
||||||
|
|
||||||
l = (struct label *) MAKE_CONTROL_INSTANCE(uiTypeLabel());
|
l = (struct label *) uiNewControl(uiTypeLabel());
|
||||||
|
|
||||||
PUT_CODE_HERE;
|
l->label = [[NSTextField alloc] initWithFrame:NSZeroRect];
|
||||||
|
|
||||||
|
[l->label setStringValue:toNSString(text)];
|
||||||
|
[l->label setEditable:NO];
|
||||||
|
[l->label setSelectable:NO];
|
||||||
|
[l->label setDrawsBackground:NO];
|
||||||
|
finishNewTextField(uiControl(l), l->label, NO);
|
||||||
|
|
||||||
uiControl(l)->Handle = labelHandle;
|
uiControl(l)->Handle = labelHandle;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ extern void setStandardControlFont(NSControl *);
|
||||||
extern void disableAutocorrect(NSTextView *);
|
extern void disableAutocorrect(NSTextView *);
|
||||||
|
|
||||||
// entry.m
|
// entry.m
|
||||||
extern void finishNewTextField(NSTextField *, BOOL);
|
extern void finishNewTextField(uiControl *, NSTextField *, BOOL);
|
||||||
|
|
||||||
// window.m
|
// window.m
|
||||||
extern uiWindow *windowFromNSWindow(NSWindow *);
|
extern uiWindow *windowFromNSWindow(NSWindow *);
|
||||||
|
|
Loading…
Reference in New Issue