2015-07-11 15:56:37 -05:00
|
|
|
// 11 june 2015
|
2015-07-11 16:02:01 -05:00
|
|
|
#include "uipriv_darwin.h"
|
2015-07-11 15:56:37 -05:00
|
|
|
|
|
|
|
struct combobox {
|
|
|
|
uiCombobox c;
|
2015-07-27 22:38:44 -05:00
|
|
|
BOOL editable;
|
|
|
|
NSPopUpButton *pb;
|
|
|
|
NSComboBox *cb;
|
2015-07-11 15:56:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
uiDefineControlType(uiCombobox, uiTypeCombobox, struct combobox)
|
|
|
|
|
|
|
|
static uintptr_t comboboxHandle(uiControl *cc)
|
|
|
|
{
|
|
|
|
struct combobox *c = (struct combobox *) cc;
|
|
|
|
|
2015-07-27 22:38:44 -05:00
|
|
|
if (c->editable)
|
|
|
|
return (uintptr_t) (c->cb);
|
|
|
|
return (uintptr_t) (c->pb);
|
2015-07-11 15:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void comboboxAppend(uiCombobox *cc, const char *text)
|
|
|
|
{
|
|
|
|
struct combobox *c = (struct combobox *) cc;
|
|
|
|
|
|
|
|
PUT_CODE_HERE;
|
|
|
|
}
|
|
|
|
|
2015-07-27 22:38:44 -05:00
|
|
|
static uiCombobox *finishNewCombobox(BOOL editable)
|
2015-07-11 15:56:37 -05:00
|
|
|
{
|
|
|
|
struct combobox *c;
|
|
|
|
|
2015-07-27 22:38:44 -05:00
|
|
|
c = (struct combobox *) uiNewControl(uiTypeCombobox());
|
2015-07-11 15:56:37 -05:00
|
|
|
|
2015-07-27 22:38:44 -05:00
|
|
|
c->editable = editable;
|
|
|
|
if (c->editable) {
|
|
|
|
c->cb = [[NSComboBox alloc] initWithFrame:NSZeroRect];
|
|
|
|
[c->cb setUsesDataSource:NO];
|
|
|
|
[c->cb setButtonBordered:YES];
|
2015-07-28 13:14:41 -05:00
|
|
|
NSLog(@"TEST intercellSpacing %@", NSStringFromSize([c->cb intercellSpacing]));
|
2015-07-27 22:38:44 -05:00
|
|
|
[c->cb setCompletes:NO];
|
|
|
|
uiDarwinMakeSingleViewControl(uiControl(c), c->cb, YES);
|
2015-07-28 13:14:41 -05:00
|
|
|
NSLog(@"TEST intercellSpacing %@", NSStringFromSize([c->cb intercellSpacing]));
|
2015-07-27 22:38:44 -05:00
|
|
|
} else {
|
|
|
|
c->pb = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO];
|
|
|
|
// TODO preferred edge
|
|
|
|
// TODO arrow position
|
|
|
|
// TODO font
|
|
|
|
uiDarwinMakeSingleViewControl(uiControl(c), c->cb, YES);
|
|
|
|
}
|
2015-07-11 15:56:37 -05:00
|
|
|
|
|
|
|
uiControl(c)->Handle = comboboxHandle;
|
|
|
|
|
|
|
|
uiCombobox(c)->Append = comboboxAppend;
|
|
|
|
|
|
|
|
return uiCombobox(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiCombobox *uiNewCombobox(void)
|
|
|
|
{
|
2015-07-27 22:38:44 -05:00
|
|
|
return finishNewCombobox(NO);
|
2015-07-11 15:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uiCombobox *uiNewEditableCombobox(void)
|
|
|
|
{
|
2015-07-27 22:38:44 -05:00
|
|
|
return finishNewCombobox(YES);
|
2015-07-11 15:56:37 -05:00
|
|
|
}
|