2015-07-29 11:28:13 -05:00
|
|
|
// 28 april 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
|
|
|
// This is a uiControl wrapper a la GtkBin on GTK+.
|
|
|
|
// It serves the function of tabPage on Windows: it allows uiWindow and uiTab to give their children a real uiControl as a parent while not screwing with the internal NSView structure of those uiControls.
|
|
|
|
// It also provides margins.
|
|
|
|
|
|
|
|
struct bin {
|
|
|
|
uiControl c;
|
|
|
|
NSView *view;
|
|
|
|
uiControl *child;
|
|
|
|
int margined;
|
|
|
|
};
|
|
|
|
|
|
|
|
uiDefineControlType(bin, binType, struct bin)
|
|
|
|
|
|
|
|
static uintptr_t binHandle(uiControl *c)
|
|
|
|
{
|
|
|
|
struct bin *b = (struct bin *) c;
|
|
|
|
|
|
|
|
return (uintptr_t) (b->view);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiControl *newBin(void)
|
|
|
|
{
|
|
|
|
struct bin *b;
|
|
|
|
|
|
|
|
b = (struct bin *) uiNewControl(binType());
|
|
|
|
|
|
|
|
// a simple NSView will do fine
|
|
|
|
b->view = [[NSView alloc] initWithFrame:NSZeroRect];
|
2015-07-29 12:29:32 -05:00
|
|
|
uiDarwinMakeSingleViewControl(uiControl(b), b->view, NO);
|
2015-07-29 11:28:13 -05:00
|
|
|
|
|
|
|
uiControl(b)->Handle = binHandle;
|
|
|
|
|
|
|
|
return uiControl(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void binSetChild(uiControl *c, uiControl *child)
|
|
|
|
{
|
|
|
|
struct bin *b = (struct bin *) c;
|
|
|
|
NSView *childView;
|
|
|
|
|
|
|
|
if (b->child != NULL) {
|
|
|
|
childView = (NSView *) uiControlHandle(b->child);
|
|
|
|
[childView removeFromSuperview];
|
|
|
|
}
|
|
|
|
b->child = child;
|
|
|
|
if (b->child != NULL) {
|
|
|
|
uiControlSetParent(b->child, uiControl(b));
|
|
|
|
childView = (NSView *) uiControlHandle(b->child);
|
|
|
|
// TODO auto layout to autoresize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int binMargined(uiControl *c)
|
|
|
|
{
|
|
|
|
struct bin *b = (struct bin *) c;
|
|
|
|
|
|
|
|
return b->margined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void binSetMargined(uiControl *c, int margined)
|
|
|
|
{
|
|
|
|
struct bin *b = (struct bin *) c;
|
|
|
|
|
|
|
|
b->margined = margined;
|
|
|
|
// TODO use auto layout
|
|
|
|
}
|