Changed uiStack to uiBox.
This commit is contained in:
parent
409480e93a
commit
c3adfb7225
|
@ -18,7 +18,7 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFILES = \
|
CFILES = \
|
||||||
stack.c \
|
box.c \
|
||||||
test.c
|
test.c
|
||||||
HFILES = \
|
HFILES = \
|
||||||
ui.h \
|
ui.h \
|
||||||
|
|
151
stack.c → box.c
151
stack.c → box.c
|
@ -1,15 +1,12 @@
|
||||||
// 7 april 2015
|
// 7 april 2015
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
// TODO
|
typedef struct box box;
|
||||||
// - rename to uiBox
|
typedef struct boxControl boxControl;
|
||||||
|
|
||||||
typedef struct stack stack;
|
struct box {
|
||||||
typedef struct stackControl stackControl;
|
uiBox s;
|
||||||
|
boxControl *controls;
|
||||||
struct stack {
|
|
||||||
uiStack s;
|
|
||||||
stackControl *controls;
|
|
||||||
uintmax_t len;
|
uintmax_t len;
|
||||||
uintmax_t cap;
|
uintmax_t cap;
|
||||||
int vertical;
|
int vertical;
|
||||||
|
@ -21,16 +18,16 @@ struct stack {
|
||||||
int containerDisabled;
|
int containerDisabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stackControl {
|
struct boxControl {
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
int stretchy;
|
int stretchy;
|
||||||
intmax_t width; // both used by resize(); preallocated to save time and reduce risk of failure
|
intmax_t width; // both used by resize(); preallocated to save time and reduce risk of failure
|
||||||
intmax_t height;
|
intmax_t height;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void stackDestroy(uiControl *c)
|
static void boxDestroy(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
if (b->parent != NULL)
|
if (b->parent != NULL)
|
||||||
|
@ -41,14 +38,14 @@ static void stackDestroy(uiControl *c)
|
||||||
uiFree(b);
|
uiFree(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintptr_t stackHandle(uiControl *c)
|
static uintptr_t boxHandle(uiControl *c)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackSetParent(uiControl *c, uiParent *parent)
|
static void boxSetParent(uiControl *c, uiParent *parent)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
uiParent *oldparent;
|
uiParent *oldparent;
|
||||||
|
|
||||||
|
@ -62,12 +59,12 @@ static void stackSetParent(uiControl *c, uiParent *parent)
|
||||||
uiParentUpdate(b->parent);
|
uiParentUpdate(b->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
static void boxPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
int xpadding, ypadding;
|
int xpadding, ypadding;
|
||||||
uintmax_t nStretchy;
|
uintmax_t nStretchy;
|
||||||
// these two contain the largest preferred width and height of all stretchy controls in the stack
|
// these two contain the largest preferred width and height of all stretchy controls in the box
|
||||||
// all stretchy controls will use this value to determine the final preferred size
|
// all stretchy controls will use this value to determine the final preferred size
|
||||||
intmax_t maxStretchyWidth, maxStretchyHeight;
|
intmax_t maxStretchyWidth, maxStretchyHeight;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
@ -78,7 +75,7 @@ static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
|
||||||
if (b->len == 0)
|
if (b->len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 0) get this Stack's padding
|
// 0) get this Box's padding
|
||||||
xpadding = 0;
|
xpadding = 0;
|
||||||
ypadding = 0;
|
ypadding = 0;
|
||||||
if (b->padded) {
|
if (b->padded) {
|
||||||
|
@ -128,9 +125,9 @@ static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
|
||||||
*width += nStretchy * maxStretchyWidth;
|
*width += nStretchy * maxStretchyWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
static void boxResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
int xpadding, ypadding;
|
int xpadding, ypadding;
|
||||||
uintmax_t nStretchy;
|
uintmax_t nStretchy;
|
||||||
intmax_t stretchywid, stretchyht;
|
intmax_t stretchywid, stretchyht;
|
||||||
|
@ -140,7 +137,7 @@ static void stackResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, in
|
||||||
if (b->len == 0)
|
if (b->len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// -1) get this Stack's padding
|
// -1) get this Box's padding
|
||||||
xpadding = 0;
|
xpadding = 0;
|
||||||
ypadding = 0;
|
ypadding = 0;
|
||||||
if (b->padded) {
|
if (b->padded) {
|
||||||
|
@ -205,16 +202,16 @@ static void stackResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stackVisible(uiControl *c)
|
static int boxVisible(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
|
|
||||||
return !(b->userHid);
|
return !(b->userHid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackShow(uiControl *c)
|
static void boxShow(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->userHid = 0;
|
b->userHid = 0;
|
||||||
|
@ -226,9 +223,9 @@ static void stackShow(uiControl *c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackHide(uiControl *c)
|
static void boxHide(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->userHid = 1;
|
b->userHid = 1;
|
||||||
|
@ -238,9 +235,9 @@ static void stackHide(uiControl *c)
|
||||||
uiParentUpdate(b->parent);
|
uiParentUpdate(b->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackContainerShow(uiControl *c)
|
static void boxContainerShow(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->containerHid = 0;
|
b->containerHid = 0;
|
||||||
|
@ -252,9 +249,9 @@ static void stackContainerShow(uiControl *c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackContainerHide(uiControl *c)
|
static void boxContainerHide(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->containerHid = 1;
|
b->containerHid = 1;
|
||||||
|
@ -264,9 +261,9 @@ static void stackContainerHide(uiControl *c)
|
||||||
uiParentUpdate(b->parent);
|
uiParentUpdate(b->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackEnable(uiControl *c)
|
static void boxEnable(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->userDisabled = 0;
|
b->userDisabled = 0;
|
||||||
|
@ -275,9 +272,9 @@ static void stackEnable(uiControl *c)
|
||||||
uiControlContainerEnable(b->controls[i].c);
|
uiControlContainerEnable(b->controls[i].c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackDisable(uiControl *c)
|
static void boxDisable(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->userDisabled = 1;
|
b->userDisabled = 1;
|
||||||
|
@ -285,9 +282,9 @@ static void stackDisable(uiControl *c)
|
||||||
uiControlContainerDisable(b->controls[i].c);
|
uiControlContainerDisable(b->controls[i].c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackContainerEnable(uiControl *c)
|
static void boxContainerEnable(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->containerDisabled = 0;
|
b->containerDisabled = 0;
|
||||||
|
@ -296,9 +293,9 @@ static void stackContainerEnable(uiControl *c)
|
||||||
uiControlContainerEnable(b->controls[i].c);
|
uiControlContainerEnable(b->controls[i].c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackContainerDisable(uiControl *c)
|
static void boxContainerDisable(uiControl *c)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) c;
|
box *b = (box *) c;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
b->containerDisabled = 1;
|
b->containerDisabled = 1;
|
||||||
|
@ -306,15 +303,15 @@ static void stackContainerDisable(uiControl *c)
|
||||||
uiControlContainerDisable(b->controls[i].c);
|
uiControlContainerDisable(b->controls[i].c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define stackCapGrow 32
|
#define boxCapGrow 32
|
||||||
|
|
||||||
static void stackAppend(uiStack *ss, uiControl *c, int stretchy)
|
static void boxAppend(uiBox *ss, uiControl *c, int stretchy)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) ss;
|
box *b = (box *) ss;
|
||||||
|
|
||||||
if (b->len >= b->cap) {
|
if (b->len >= b->cap) {
|
||||||
b->cap += stackCapGrow;
|
b->cap += boxCapGrow;
|
||||||
b->controls = (stackControl *) uiRealloc(b->controls, b->cap * sizeof (stackControl), "stackControl[]");
|
b->controls = (boxControl *) uiRealloc(b->controls, b->cap * sizeof (boxControl), "boxControl[]");
|
||||||
}
|
}
|
||||||
b->controls[b->len].c = c;
|
b->controls[b->len].c = c;
|
||||||
b->controls[b->len].stretchy = stretchy;
|
b->controls[b->len].stretchy = stretchy;
|
||||||
|
@ -325,9 +322,9 @@ static void stackAppend(uiStack *ss, uiControl *c, int stretchy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackDelete(uiStack *ss, uintmax_t index)
|
static void boxDelete(uiBox *ss, uintmax_t index)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) ss;
|
box *b = (box *) ss;
|
||||||
uiControl *removed;
|
uiControl *removed;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
|
@ -343,58 +340,58 @@ static void stackDelete(uiStack *ss, uintmax_t index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stackPadded(uiStack *ss)
|
static int boxPadded(uiBox *ss)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) ss;
|
box *b = (box *) ss;
|
||||||
|
|
||||||
return b->padded;
|
return b->padded;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackSetPadded(uiStack *ss, int padded)
|
static void boxSetPadded(uiBox *ss, int padded)
|
||||||
{
|
{
|
||||||
stack *b = (stack *) ss;
|
box *b = (box *) ss;
|
||||||
|
|
||||||
b->padded = padded;
|
b->padded = padded;
|
||||||
if (b->parent != NULL)
|
if (b->parent != NULL)
|
||||||
uiParentUpdate(b->parent);
|
uiParentUpdate(b->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiStack *uiNewHorizontalStack(void)
|
uiBox *uiNewHorizontalBox(void)
|
||||||
{
|
{
|
||||||
stack *b;
|
box *b;
|
||||||
|
|
||||||
b = uiNew(stack);
|
b = uiNew(box);
|
||||||
|
|
||||||
uiControl(b)->Destroy = stackDestroy;
|
uiControl(b)->Destroy = boxDestroy;
|
||||||
uiControl(b)->Handle = stackHandle;
|
uiControl(b)->Handle = boxHandle;
|
||||||
uiControl(b)->SetParent = stackSetParent;
|
uiControl(b)->SetParent = boxSetParent;
|
||||||
uiControl(b)->PreferredSize = stackPreferredSize;
|
uiControl(b)->PreferredSize = boxPreferredSize;
|
||||||
uiControl(b)->Resize = stackResize;
|
uiControl(b)->Resize = boxResize;
|
||||||
uiControl(b)->Visible = stackVisible;
|
uiControl(b)->Visible = boxVisible;
|
||||||
uiControl(b)->Show = stackShow;
|
uiControl(b)->Show = boxShow;
|
||||||
uiControl(b)->Hide = stackHide;
|
uiControl(b)->Hide = boxHide;
|
||||||
uiControl(b)->ContainerShow = stackContainerShow;
|
uiControl(b)->ContainerShow = boxContainerShow;
|
||||||
uiControl(b)->ContainerHide = stackContainerHide;
|
uiControl(b)->ContainerHide = boxContainerHide;
|
||||||
uiControl(b)->Enable = stackEnable;
|
uiControl(b)->Enable = boxEnable;
|
||||||
uiControl(b)->Disable = stackDisable;
|
uiControl(b)->Disable = boxDisable;
|
||||||
uiControl(b)->ContainerEnable = stackContainerEnable;
|
uiControl(b)->ContainerEnable = boxContainerEnable;
|
||||||
uiControl(b)->ContainerDisable = stackContainerDisable;
|
uiControl(b)->ContainerDisable = boxContainerDisable;
|
||||||
|
|
||||||
uiStack(b)->Append = stackAppend;
|
uiBox(b)->Append = boxAppend;
|
||||||
uiStack(b)->Delete = stackDelete;
|
uiBox(b)->Delete = boxDelete;
|
||||||
uiStack(b)->Padded = stackPadded;
|
uiBox(b)->Padded = boxPadded;
|
||||||
uiStack(b)->SetPadded = stackSetPadded;
|
uiBox(b)->SetPadded = boxSetPadded;
|
||||||
|
|
||||||
return uiStack(b);
|
return uiBox(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiStack *uiNewVerticalStack(void)
|
uiBox *uiNewVerticalBox(void)
|
||||||
{
|
{
|
||||||
uiStack *ss;
|
uiBox *ss;
|
||||||
stack *b;
|
box *b;
|
||||||
|
|
||||||
ss = uiNewHorizontalStack();
|
ss = uiNewHorizontalBox();
|
||||||
b = (stack *) ss;
|
b = (box *) ss;
|
||||||
b->vertical = 1;
|
b->vertical = 1;
|
||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
176
test.c
176
test.c
|
@ -69,8 +69,8 @@ static void setCheckboxText(uiButton *b, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
#define nStacks 13
|
#define nBoxes 13
|
||||||
uiStack *stacks[nStacks];
|
uiBox *boxes[nBoxes];
|
||||||
uiCheckbox *spaced;
|
uiCheckbox *spaced;
|
||||||
|
|
||||||
static void setSpaced(int spaced)
|
static void setSpaced(int spaced)
|
||||||
|
@ -78,8 +78,8 @@ static void setSpaced(int spaced)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
uiWindowSetMargined(w, spaced);
|
uiWindowSetMargined(w, spaced);
|
||||||
for (i = 0; i < nStacks; i++)
|
for (i = 0; i < nBoxes; i++)
|
||||||
uiStackSetPadded(stacks[i], spaced);
|
uiBoxSetPadded(boxes[i], spaced);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void toggleSpaced(uiCheckbox *c, void *data)
|
static void toggleSpaced(uiCheckbox *c, void *data)
|
||||||
|
@ -108,7 +108,7 @@ static void showSpaced(uiButton *b, void *data)
|
||||||
|
|
||||||
if (uiWindowMargined(w))
|
if (uiWindowMargined(w))
|
||||||
msg[2] = '1';
|
msg[2] = '1';
|
||||||
if (uiStackPadded(stacks[0]))
|
if (uiBoxPadded(boxes[0]))
|
||||||
msg[6] = '1';
|
msg[6] = '1';
|
||||||
uiEntrySetText(e, msg);
|
uiEntrySetText(e, msg);
|
||||||
}
|
}
|
||||||
|
@ -151,36 +151,36 @@ static void setLabelText(uiButton *b, void *data)
|
||||||
uiFreeText(text);
|
uiFreeText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiStack *firstStack;
|
uiBox *firstBox;
|
||||||
uiStack *secondStack;
|
uiBox *secondBox;
|
||||||
uiLabel *movingLabel;
|
uiLabel *movingLabel;
|
||||||
|
|
||||||
static void moveToFirst(uiButton *b, void *data)
|
static void moveToFirst(uiButton *b, void *data)
|
||||||
{
|
{
|
||||||
uiStackDelete(secondStack, 1);
|
uiBoxDelete(secondBox, 1);
|
||||||
uiStackAppend(firstStack, uiControl(movingLabel), 1);
|
uiBoxAppend(firstBox, uiControl(movingLabel), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void moveToSecond(uiButton *b, void *data)
|
static void moveToSecond(uiButton *b, void *data)
|
||||||
{
|
{
|
||||||
uiStackDelete(firstStack, 1);
|
uiBoxDelete(firstBox, 1);
|
||||||
uiStackAppend(secondStack, uiControl(movingLabel), 1);
|
uiBoxAppend(secondBox, uiControl(movingLabel), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiStack *mainStack;
|
uiBox *mainBox;
|
||||||
uiStack *page1stack;
|
uiBox *page1box;
|
||||||
uiTab *tab;
|
uiTab *tab;
|
||||||
|
|
||||||
void movePage1Out(uiButton *b, void *data)
|
void movePage1Out(uiButton *b, void *data)
|
||||||
{
|
{
|
||||||
uiTabDeletePage(tab, 0);
|
uiTabDeletePage(tab, 0);
|
||||||
uiStackAppend(mainStack, uiControl(page1stack), 1);
|
uiBoxAppend(mainBox, uiControl(page1box), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPage1Back(uiButton *b, void *data)
|
void addPage1Back(uiButton *b, void *data)
|
||||||
{
|
{
|
||||||
uiStackDelete(mainStack, 1);
|
uiBoxDelete(mainBox, 1);
|
||||||
uiTabAddPage(tab, "Page 1", uiControl(page1stack));
|
uiTabAddPage(tab, "Page 1", uiControl(page1box));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -190,7 +190,7 @@ int main(int argc, char *argv[])
|
||||||
const char *err;
|
const char *err;
|
||||||
uiButton *getButton, *setButton;
|
uiButton *getButton, *setButton;
|
||||||
uiLabel *label;
|
uiLabel *label;
|
||||||
int page2stack;
|
int page2box;
|
||||||
|
|
||||||
memset(&o, 0, sizeof (uiInitOptions));
|
memset(&o, 0, sizeof (uiInitOptions));
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
|
@ -211,155 +211,155 @@ int main(int argc, char *argv[])
|
||||||
w = uiNewWindow("Hello", 320, 240);
|
w = uiNewWindow("Hello", 320, 240);
|
||||||
uiWindowOnClosing(w, onClosing, NULL);
|
uiWindowOnClosing(w, onClosing, NULL);
|
||||||
|
|
||||||
stacks[0] = uiNewVerticalStack();
|
boxes[0] = uiNewVerticalBox();
|
||||||
page1stack = stacks[0];
|
page1box = boxes[0];
|
||||||
|
|
||||||
e = uiNewEntry();
|
e = uiNewEntry();
|
||||||
uiStackAppend(stacks[0], uiControl(e), 0);
|
uiBoxAppend(boxes[0], uiControl(e), 0);
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
getButton = uiNewButton("Get Window Text");
|
getButton = uiNewButton("Get Window Text");
|
||||||
uiButtonOnClicked(getButton, getWindowText, w);
|
uiButtonOnClicked(getButton, getWindowText, w);
|
||||||
setButton = uiNewButton("Set Window Text");
|
setButton = uiNewButton("Set Window Text");
|
||||||
uiButtonOnClicked(setButton, setWindowText, w);
|
uiButtonOnClicked(setButton, setWindowText, w);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 1);
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
uiStackAppend(stacks[0], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
getButton = uiNewButton("Get Button Text");
|
getButton = uiNewButton("Get Button Text");
|
||||||
uiButtonOnClicked(getButton, getButtonText, getButton);
|
uiButtonOnClicked(getButton, getButtonText, getButton);
|
||||||
setButton = uiNewButton("Set Button Text");
|
setButton = uiNewButton("Set Button Text");
|
||||||
uiButtonOnClicked(setButton, setButtonText, getButton);
|
uiButtonOnClicked(setButton, setButtonText, getButton);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 1);
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
uiStackAppend(stacks[0], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// this will also be used to make sure tab stops work properly when inserted out of creation order, especially on Windows
|
// this will also be used to make sure tab stops work properly when inserted out of creation order, especially on Windows
|
||||||
spaced = uiNewCheckbox("Spaced");
|
spaced = uiNewCheckbox("Spaced");
|
||||||
uiCheckboxOnToggled(spaced, toggleSpaced, NULL);
|
uiCheckboxOnToggled(spaced, toggleSpaced, NULL);
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
getButton = uiNewButton("Get Checkbox Text");
|
getButton = uiNewButton("Get Checkbox Text");
|
||||||
uiButtonOnClicked(getButton, getCheckboxText, spaced);
|
uiButtonOnClicked(getButton, getCheckboxText, spaced);
|
||||||
setButton = uiNewButton("Set Checkbox Text");
|
setButton = uiNewButton("Set Checkbox Text");
|
||||||
uiButtonOnClicked(setButton, setCheckboxText, spaced);
|
uiButtonOnClicked(setButton, setCheckboxText, spaced);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 1);
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
uiStackAppend(stacks[0], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
label = uiNewLabel("Label");
|
label = uiNewLabel("Label");
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
getButton = uiNewButton("Get Label Text");
|
getButton = uiNewButton("Get Label Text");
|
||||||
uiButtonOnClicked(getButton, getLabelText, label);
|
uiButtonOnClicked(getButton, getLabelText, label);
|
||||||
setButton = uiNewButton("Set Label Text");
|
setButton = uiNewButton("Set Label Text");
|
||||||
uiButtonOnClicked(setButton, setLabelText, label);
|
uiButtonOnClicked(setButton, setLabelText, label);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 1);
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
uiStackAppend(stacks[0], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
uiStackAppend(stacks[i], uiControl(spaced), 1);
|
uiBoxAppend(boxes[i], uiControl(spaced), 1);
|
||||||
getButton = uiNewButton("On");
|
getButton = uiNewButton("On");
|
||||||
uiButtonOnClicked(getButton, forceSpacedOn, NULL);
|
uiButtonOnClicked(getButton, forceSpacedOn, NULL);
|
||||||
setButton = uiNewButton("Off");
|
setButton = uiNewButton("Off");
|
||||||
uiButtonOnClicked(setButton, forceSpacedOff, NULL);
|
uiButtonOnClicked(setButton, forceSpacedOff, NULL);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 0);
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 0);
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
||||||
setButton = uiNewButton("Show");
|
setButton = uiNewButton("Show");
|
||||||
uiButtonOnClicked(setButton, showSpaced, NULL);
|
uiButtonOnClicked(setButton, showSpaced, NULL);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 0);
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
||||||
uiStackAppend(stacks[0], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
getButton = uiNewButton("Button");
|
getButton = uiNewButton("Button");
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 1);
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
||||||
setButton = uiNewButton("Show");
|
setButton = uiNewButton("Show");
|
||||||
uiButtonOnClicked(setButton, showControl, getButton);
|
uiButtonOnClicked(setButton, showControl, getButton);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 0);
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
||||||
setButton = uiNewButton("Hide");
|
setButton = uiNewButton("Hide");
|
||||||
uiButtonOnClicked(setButton, hideControl, getButton);
|
uiButtonOnClicked(setButton, hideControl, getButton);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 0);
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
||||||
setButton = uiNewButton("Enable");
|
setButton = uiNewButton("Enable");
|
||||||
uiButtonOnClicked(setButton, enableControl, getButton);
|
uiButtonOnClicked(setButton, enableControl, getButton);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 0);
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
||||||
setButton = uiNewButton("Disable");
|
setButton = uiNewButton("Disable");
|
||||||
uiButtonOnClicked(setButton, disableControl, getButton);
|
uiButtonOnClicked(setButton, disableControl, getButton);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 0);
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
||||||
uiStackAppend(stacks[0], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
setButton = uiNewButton("Show Stack");
|
setButton = uiNewButton("Show Box");
|
||||||
uiButtonOnClicked(setButton, showControl, stacks[i - 1]);
|
uiButtonOnClicked(setButton, showControl, boxes[i - 1]);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
setButton = uiNewButton("Hide Stack");
|
setButton = uiNewButton("Hide Box");
|
||||||
uiButtonOnClicked(setButton, hideControl, stacks[i - 1]);
|
uiButtonOnClicked(setButton, hideControl, boxes[i - 1]);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
setButton = uiNewButton("Enable Stack");
|
setButton = uiNewButton("Enable Box");
|
||||||
uiButtonOnClicked(setButton, enableControl, stacks[i - 1]);
|
uiButtonOnClicked(setButton, enableControl, boxes[i - 1]);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
setButton = uiNewButton("Disable Stack");
|
setButton = uiNewButton("Disable Box");
|
||||||
uiButtonOnClicked(setButton, disableControl, stacks[i - 1]);
|
uiButtonOnClicked(setButton, disableControl, boxes[i - 1]);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 1);
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
||||||
uiStackAppend(stacks[0], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
uiStackAppend(stacks[0], uiControl(label), 0);
|
uiBoxAppend(boxes[0], uiControl(label), 0);
|
||||||
|
|
||||||
tab = uiNewTab();
|
tab = uiNewTab();
|
||||||
uiTabAddPage(tab, "Page 1", uiControl(stacks[0]));
|
uiTabAddPage(tab, "Page 1", uiControl(boxes[0]));
|
||||||
//TODO uiTabAddPage(tab, "Page 1", uiControl(uiNewVerticalStack()));
|
//TODO uiTabAddPage(tab, "Page 1", uiControl(uiNewVerticalBox()));
|
||||||
|
|
||||||
page2stack = i;
|
page2box = i;
|
||||||
stacks[i] = uiNewVerticalStack();
|
boxes[i] = uiNewVerticalBox();
|
||||||
uiTabAddPage(tab, "Page 2", uiControl(stacks[i]));
|
uiTabAddPage(tab, "Page 2", uiControl(boxes[i]));
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
firstStack = stacks[i];
|
firstBox = boxes[i];
|
||||||
getButton = uiNewButton("Move Here");
|
getButton = uiNewButton("Move Here");
|
||||||
uiButtonOnClicked(getButton, moveToFirst, NULL);
|
uiButtonOnClicked(getButton, moveToFirst, NULL);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 0);
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
||||||
movingLabel = uiNewLabel("This label moves!");
|
movingLabel = uiNewLabel("This label moves!");
|
||||||
uiStackAppend(stacks[i], uiControl(movingLabel), 1);
|
uiBoxAppend(boxes[i], uiControl(movingLabel), 1);
|
||||||
uiStackAppend(stacks[page2stack], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[page2box], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
secondStack = stacks[i];
|
secondBox = boxes[i];
|
||||||
getButton = uiNewButton("Move Here");
|
getButton = uiNewButton("Move Here");
|
||||||
uiButtonOnClicked(getButton, moveToSecond, NULL);
|
uiButtonOnClicked(getButton, moveToSecond, NULL);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 0);
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
||||||
uiStackAppend(stacks[page2stack], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[page2box], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
getButton = uiNewButton("Move Page 1 Out");
|
getButton = uiNewButton("Move Page 1 Out");
|
||||||
uiButtonOnClicked(getButton, movePage1Out, NULL);
|
uiButtonOnClicked(getButton, movePage1Out, NULL);
|
||||||
setButton = uiNewButton("Add Page 1 Back");
|
setButton = uiNewButton("Add Page 1 Back");
|
||||||
uiButtonOnClicked(setButton, addPage1Back, NULL);
|
uiButtonOnClicked(setButton, addPage1Back, NULL);
|
||||||
uiStackAppend(stacks[i], uiControl(getButton), 0);
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
||||||
uiStackAppend(stacks[i], uiControl(setButton), 0);
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
||||||
uiStackAppend(stacks[page2stack], uiControl(stacks[i]), 0);
|
uiBoxAppend(boxes[page2box], uiControl(boxes[i]), 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
stacks[i] = uiNewHorizontalStack();
|
boxes[i] = uiNewHorizontalBox();
|
||||||
mainStack = stacks[i];
|
mainBox = boxes[i];
|
||||||
uiStackAppend(stacks[i], uiControl(tab), 1);
|
uiBoxAppend(boxes[i], uiControl(tab), 1);
|
||||||
uiWindowSetChild(w, uiControl(mainStack));
|
uiWindowSetChild(w, uiControl(mainBox));
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i != nStacks) {
|
if (i != nBoxes) {
|
||||||
fprintf(stderr, "forgot to update nStacks (expected %d)\n", i);
|
fprintf(stderr, "forgot to update nBoxes (expected %d)\n", i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
uiWindowShow(w);
|
uiWindowShow(w);
|
||||||
|
|
6
ui.idl
6
ui.idl
|
@ -91,14 +91,14 @@ interface Button from Control {
|
||||||
};
|
};
|
||||||
func NewButton(text *const char) *Button;
|
func NewButton(text *const char) *Button;
|
||||||
|
|
||||||
interface Stack from Control {
|
interface Box from Control {
|
||||||
func Append(c *Control, stretchy int);
|
func Append(c *Control, stretchy int);
|
||||||
func Delete(index uintmax_t);
|
func Delete(index uintmax_t);
|
||||||
func Padded(void) int;
|
func Padded(void) int;
|
||||||
func SetPadded(padded int);
|
func SetPadded(padded int);
|
||||||
};
|
};
|
||||||
func NewHorizontalStack(void) *Stack;
|
func NewHorizontalBox(void) *Box;
|
||||||
func NewVerticalStack(void) *Stack;
|
func NewVerticalBox(void) *Box;
|
||||||
|
|
||||||
interface Entry from Control {
|
interface Entry from Control {
|
||||||
func Text(void) *char;
|
func Text(void) *char;
|
||||||
|
|
Loading…
Reference in New Issue