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 group {
|
|
|
|
uiGroup g;
|
2015-07-27 22:38:44 -05:00
|
|
|
NSBox *box;
|
2015-07-11 15:56:37 -05:00
|
|
|
uiControl *child;
|
|
|
|
int margined;
|
|
|
|
};
|
|
|
|
|
|
|
|
uiDefineControlType(uiGroup, uiTypeGroup, struct group)
|
|
|
|
|
|
|
|
static uintptr_t groupHandle(uiControl *c)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) c;
|
|
|
|
|
2015-07-27 22:38:44 -05:00
|
|
|
return (uintptr_t) (g->box);
|
2015-07-11 15:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void groupContainerUpdateState(uiControl *c)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) c;
|
|
|
|
|
|
|
|
if (g->child != NULL)
|
|
|
|
uiControlUpdateState(g->child);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *groupTitle(uiGroup *gg)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
return PUT_CODE_HERE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void groupSetTitle(uiGroup *gg, const char *text)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
PUT_CODE_HERE;
|
|
|
|
// changing the text might necessitate a change in the groupbox's size
|
|
|
|
uiControlQueueResize(uiControl(g));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void groupSetChild(uiGroup *gg, uiControl *child)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
if (g->child != NULL)
|
|
|
|
uiControlSetParent(g->child, NULL);
|
|
|
|
g->child = child;
|
|
|
|
if (g->child != NULL) {
|
|
|
|
uiControlSetParent(g->child, uiControl(g));
|
|
|
|
uiControlQueueResize(g->child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int groupMargined(uiGroup *gg)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
return g->margined;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void groupSetMargined(uiGroup *gg, int margined)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
g->margined = margined;
|
|
|
|
uiControlQueueResize(uiControl(g));
|
|
|
|
}
|
|
|
|
|
|
|
|
uiGroup *uiNewGroup(const char *text)
|
|
|
|
{
|
|
|
|
struct group *g;
|
|
|
|
|
2015-07-28 13:14:41 -05:00
|
|
|
g = (struct group *) uiNewControl(uiTypeGroup());
|
2015-07-11 15:56:37 -05:00
|
|
|
|
2015-07-27 22:38:44 -05:00
|
|
|
g->box = [[NSBox alloc] initWithFrame:NSZeroRect];
|
|
|
|
[g->box setBoxType:NSBoxPrimary];
|
2015-07-28 13:14:41 -05:00
|
|
|
//TODO [g->box setBorderType:TODO];
|
2015-07-27 22:38:44 -05:00
|
|
|
[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]]];
|
2015-07-11 15:56:37 -05:00
|
|
|
|
|
|
|
uiControl(g)->Handle = groupHandle;
|
|
|
|
uiControl(g)->ContainerUpdateState = groupContainerUpdateState;
|
|
|
|
|
|
|
|
uiGroup(g)->Title = groupTitle;
|
|
|
|
uiGroup(g)->SetTitle = groupSetTitle;
|
|
|
|
uiGroup(g)->SetChild = groupSetChild;
|
|
|
|
uiGroup(g)->Margined = groupMargined;
|
|
|
|
uiGroup(g)->SetMargined = groupSetMargined;
|
|
|
|
|
|
|
|
return uiGroup(g);
|
|
|
|
}
|