More OS X control work.

This commit is contained in:
Pietro Gagliardi 2015-07-27 23:38:44 -04:00
parent 23e1fe0c98
commit 15a3d151cd
4 changed files with 54 additions and 14 deletions

View File

@ -3,7 +3,9 @@
struct combobox {
uiCombobox c;
OSTYPE *OSHANDLE;
BOOL editable;
NSPopUpButton *pb;
NSComboBox *cb;
};
uiDefineControlType(uiCombobox, uiTypeCombobox, struct combobox)
@ -12,7 +14,9 @@ static uintptr_t comboboxHandle(uiControl *cc)
{
struct combobox *c = (struct combobox *) cc;
return (uintptr_t) (c->OSHANDLE);
if (c->editable)
return (uintptr_t) (c->cb);
return (uintptr_t) (c->pb);
}
static void comboboxAppend(uiCombobox *cc, const char *text)
@ -22,13 +26,28 @@ static void comboboxAppend(uiCombobox *cc, const char *text)
PUT_CODE_HERE;
}
static uiCombobox *finishNewCombobox(OSTHING OSARG)
static uiCombobox *finishNewCombobox(BOOL editable)
{
struct combobox *c;
c = (struct combobox *) MAKE_CONTROL_INSTANCE(uiTypeCombobox());
c = (struct combobox *) uiNewControl(uiTypeCombobox());
PUT_CODE_HERE;
c->editable = editable;
if (c->editable) {
c->cb = [[NSComboBox alloc] initWithFrame:NSZeroRect];
[c->cb setUsesDataSource:NO];
[c->cb setButtonBordered:YES];
NSLog(@"TEST intercellSpacing %@", NSStringFromSize([c->cb intercellSpacing]);
[c->cb setCompletes:NO];
uiDarwinMakeSingleViewControl(uiControl(c), c->cb, YES);
NSLog(@"TEST intercellSpacing %@", NSStringFromSize([c->cb intercellSpacing]);
} else {
c->pb = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO];
// TODO preferred edge
// TODO arrow position
// TODO font
uiDarwinMakeSingleViewControl(uiControl(c), c->cb, YES);
}
uiControl(c)->Handle = comboboxHandle;
@ -39,10 +58,10 @@ static uiCombobox *finishNewCombobox(OSTHING OSARG)
uiCombobox *uiNewCombobox(void)
{
return finishNewCombobox(OSARGNONEDITABLE);
return finishNewCombobox(NO);
}
uiCombobox *uiNewEditableCombobox(void)
{
return finishNewCombobox(OSARGEDITABLE);
return finishNewCombobox(YES);
}

View File

@ -3,7 +3,7 @@
struct group {
uiGroup g;
OSTYPE *OSHANDLE;
NSBox *box;
uiControl *child;
int margined;
};
@ -14,7 +14,7 @@ static uintptr_t groupHandle(uiControl *c)
{
struct group *g = (struct group *) c;
return (uintptr_t) (g->OSHANDLE);
return (uintptr_t) (g->box);
}
static void groupContainerUpdateState(uiControl *c)
@ -75,7 +75,16 @@ uiGroup *uiNewGroup(const char *text)
g = (struct group *) MAKE_CONTROL_INSTANCE(uiTypeGroup());
PUT_CODE_HERE;
g->box = [[NSBox alloc] initWithFrame:NSZeroRect];
[g->box setBoxType:NSBoxPrimary];
[g->box setBorderType:TODO];
[g->box setTransparent:NO];
[g->box setTitlePosition:NSAtTop];
// can't set title font the way the function does; plus we need to use a different size
uiDarwinMakeSingleViewControl(uiControl(g), g->box, NO);
// TODO verify if Small in Xcode is this small
[g->box setTitleFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
uiControl(g)->Handle = groupHandle;
uiControl(g)->ContainerUpdateState = groupContainerUpdateState;

View File

@ -1,9 +1,11 @@
// 11 june 2015
#include "uipriv_darwin.h"
// TODO sizing
struct separator {
uiSeparator s;
OSTYPE *OSHANDLE;
NSBox *box;
};
uiDefineControlType(uiSeparator, uiTypeSeparator, struct separator)
@ -12,7 +14,7 @@ static uintptr_t separatorHandle(uiControl *c)
{
struct separator *s = (struct separator *) c;
return (uintptr_t) (s->OSHANDLE);
return (uintptr_t) (s->box);
}
uiSeparator *uiNewHorizontalSeparator(void)
@ -21,7 +23,13 @@ uiSeparator *uiNewHorizontalSeparator(void)
s = (struct separator *) MAKE_CONTROL_INSTANCE(uiTypeSeparator());
PUT_CODE_HERE;
s->box = [[NSBox alloc] initWithFrame:NSZeroRect];
[s->box setBoxType:NSBoxSeparator];
[s->box setBorderType:TODO];
[s->box setTransparent:NO];
[s->box setTitlePosition:NSNoTitle];
uiDarwinMakeSingleViewControl(uiControl(s), s->box, NO);
uiControl(s)->Handle = separatorHandle;

View File

@ -54,13 +54,17 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max)
s = (struct slider *) uiNewControl(uiTypeSlider());
s->slider = [[NSSlider alloc] initWithFrame:NSZeroRect];
NSLog(@"NOTE thickness %f\n", [s->slider knobThickness]);
// TODO vertical is defined by wider than tall
[s->slider setMinValue:min];
[s->slider setMaxValue:max];
// TODO NSTickMarkAbove?
[s->slider setAllowsTickMarkValuesOnly:NO];
[s->slider setNumberOfTicks:0];
[s->slider setTickMarkPosition:NSTickMarkAbove];
cell = (NSSliderCell *) [s->slider cell];
[cell setSliderType:NSLinearSlider];
NSLog(@"NOTE thickness %f\n", [s->slider knobThickness]);
uiDarwinMakeSingleViewControl(uiControl(s), s->slider, NO);