Implemented the text functions on OS X.
This commit is contained in:
parent
b5eea413c4
commit
67bfe61c93
|
@ -53,7 +53,21 @@ uiControl *uiNewButton(const char *text)
|
||||||
return b.uiC;
|
return b.uiC;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO text
|
char *uiButtonText(uiControl *c)
|
||||||
|
{
|
||||||
|
uiNSButton *b;
|
||||||
|
|
||||||
|
b = (uiNSButton *) uiControlHandle(c);
|
||||||
|
return strdup(fromNSString([b title]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiButtonSetText(uiControl *c, const char *text)
|
||||||
|
{
|
||||||
|
uiNSButton *b;
|
||||||
|
|
||||||
|
b = (uiNSButton *) uiControlHandle(c);
|
||||||
|
[b setTitle:toNSString(text)];
|
||||||
|
}
|
||||||
|
|
||||||
void uiButtonOnClicked(uiControl *c, void (*f)(uiControl *, void *), void *data)
|
void uiButtonOnClicked(uiControl *c, void (*f)(uiControl *, void *), void *data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,14 +20,14 @@
|
||||||
|
|
||||||
// TOOD move elsewhere
|
// TOOD move elsewhere
|
||||||
// these are based on interface builder defaults; my comments in the old code weren't very good so I don't really know what talked about what, sorry :/
|
// these are based on interface builder defaults; my comments in the old code weren't very good so I don't really know what talked about what, sorry :/
|
||||||
void finishNewTextField(NSTextField *t, BOOL isLabel)
|
void finishNewTextField(NSTextField *t, BOOL isEntry)
|
||||||
{
|
{
|
||||||
setStandardControlFont((id) t);
|
setStandardControlFont((id) t);
|
||||||
|
|
||||||
// THE ORDER OF THESE CALLS IS IMPORTANT; CHANGE IT AND THE BORDERS WILL DISAPPEAR
|
// THE ORDER OF THESE CALLS IS IMPORTANT; CHANGE IT AND THE BORDERS WILL DISAPPEAR
|
||||||
[t setBordered:NO];
|
[t setBordered:NO];
|
||||||
[t setBezelStyle:NSTextFieldSquareBezel];
|
[t setBezelStyle:NSTextFieldSquareBezel];
|
||||||
[t setBezeled:isLabel];
|
[t setBezeled:isEntry];
|
||||||
|
|
||||||
// TODO autocorrect comment
|
// TODO autocorrect comment
|
||||||
|
|
||||||
|
@ -49,3 +49,20 @@ uiControl *uiNewEntry(void)
|
||||||
|
|
||||||
return t.uiC;
|
return t.uiC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *uiEntryText(uiControl *c)
|
||||||
|
{
|
||||||
|
uiNSTextField *t;
|
||||||
|
|
||||||
|
t = (uiNSTextField *) uiControlHandle(c);
|
||||||
|
// TODO wrap all strdup calls
|
||||||
|
return strdup(fromNSString([t stringValue]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiEntrySetText(uiControl *c, const char *text)
|
||||||
|
{
|
||||||
|
uiNSTextField *t;
|
||||||
|
|
||||||
|
t = (uiNSTextField *) uiControlHandle(c);
|
||||||
|
[t setStringValue:toNSString(text)];
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#import "ui_darwin.h"
|
#import "ui_darwin.h"
|
||||||
|
|
||||||
#define toNSString(str) [NSString stringWithUTF8String:(str)]
|
#define toNSString(str) [NSString stringWithUTF8String:(str)]
|
||||||
|
#define fromNSString(str) [(str) UTF8String]
|
||||||
|
|
||||||
// TODO move this to the right place
|
// TODO move this to the right place
|
||||||
struct uiSizing {
|
struct uiSizing {
|
||||||
|
|
|
@ -6,3 +6,8 @@ void setStandardControlFont(NSControl *control)
|
||||||
{
|
{
|
||||||
[control setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
|
[control setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiFreeText(char *s)
|
||||||
|
{
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
|
|
@ -79,7 +79,15 @@ uintptr_t uiWindowHandle(uiWindow *w)
|
||||||
return (uintptr_t) (D.w);
|
return (uintptr_t) (D.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO titles
|
char *uiWindowTitle(uiWindow *w)
|
||||||
|
{
|
||||||
|
return strdup(fromNSString([D.w title]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowSetTitle(uiWindow *w, const char *title)
|
||||||
|
{
|
||||||
|
[D.w setTitle:toNSString(title)];
|
||||||
|
}
|
||||||
|
|
||||||
void uiWindowShow(uiWindow *w)
|
void uiWindowShow(uiWindow *w)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue