2015-04-09 01:35:52 -05:00
|
|
|
// 9 april 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
struct entry {
|
|
|
|
uiEntry e;
|
|
|
|
NSTextField *textfield;
|
2015-04-17 17:54:17 -05:00
|
|
|
};
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
static void destroy(void *data)
|
2015-04-09 01:35:52 -05:00
|
|
|
{
|
2015-04-17 17:40:12 -05:00
|
|
|
struct entry *e = (struct entry *) data;
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
uiFree(e);
|
|
|
|
}
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
static char *entryText(uiEntry *ee)
|
2015-04-16 13:41:24 -05:00
|
|
|
{
|
2015-04-17 17:40:12 -05:00
|
|
|
struct entry *e = (struct entry *) ee;
|
2015-04-16 13:41:24 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
return uiDarwinNSStringToText([e->textfield stringValue]);
|
2015-04-16 13:41:24 -05:00
|
|
|
}
|
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
static void entrySetText(uiEntry *ee, const char *text)
|
2015-04-16 13:41:24 -05:00
|
|
|
{
|
2015-04-17 17:40:12 -05:00
|
|
|
struct entry *e = (struct entry *) ee;
|
2015-04-16 13:41:24 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
[e->textfield setStringValue:toNSString(text)];
|
2015-04-16 13:41:24 -05:00
|
|
|
}
|
|
|
|
|
2015-04-09 01:35:52 -05:00
|
|
|
// 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 :/
|
2015-04-09 10:54:02 -05:00
|
|
|
void finishNewTextField(NSTextField *t, BOOL isEntry)
|
2015-04-09 01:35:52 -05:00
|
|
|
{
|
2015-04-17 17:40:12 -05:00
|
|
|
setStandardControlFont(t);
|
2015-04-09 01:35:52 -05:00
|
|
|
|
|
|
|
// THE ORDER OF THESE CALLS IS IMPORTANT; CHANGE IT AND THE BORDERS WILL DISAPPEAR
|
|
|
|
[t setBordered:NO];
|
|
|
|
[t setBezelStyle:NSTextFieldSquareBezel];
|
2015-04-09 10:54:02 -05:00
|
|
|
[t setBezeled:isEntry];
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-10 16:06:59 -05:00
|
|
|
// we don't need to worry about substitutions/autocorrect here; see window_darwin.m for details
|
2015-04-09 01:35:52 -05:00
|
|
|
|
|
|
|
[[t cell] setLineBreakMode:NSLineBreakByClipping];
|
|
|
|
[[t cell] setScrollable:YES];
|
|
|
|
}
|
|
|
|
|
2015-04-16 13:41:24 -05:00
|
|
|
uiEntry *uiNewEntry(void)
|
2015-04-09 01:35:52 -05:00
|
|
|
{
|
2015-04-17 17:40:12 -05:00
|
|
|
struct entry *e;
|
|
|
|
|
|
|
|
e = uiNew(struct entry);
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-19 10:41:23 -05:00
|
|
|
uiDarwinNewControl(uiControl(e), [NSTextField class], NO, NO, destroy, e);
|
2015-04-16 13:41:24 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
e->textfield = (NSTextField *) VIEW(e);
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
[e->textfield setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
|
|
|
|
finishNewTextField(e->textfield, YES);
|
2015-04-09 01:35:52 -05:00
|
|
|
|
2015-04-16 13:41:24 -05:00
|
|
|
uiEntry(e)->Text = entryText;
|
|
|
|
uiEntry(e)->SetText = entrySetText;
|
2015-04-09 10:54:02 -05:00
|
|
|
|
2015-04-17 17:40:12 -05:00
|
|
|
return uiEntry(e);
|
2015-04-09 10:54:02 -05:00
|
|
|
}
|