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