Finished the initial run of box.c and GNUmakefile. Now to finally test the build which will break miserably! :D
This commit is contained in:
parent
25bbd58915
commit
67e87f213a
|
@ -5,6 +5,7 @@ osCFILES = \
|
||||||
windows/box.c \
|
windows/box.c \
|
||||||
windows/button.c \
|
windows/button.c \
|
||||||
windows/checkbox.c \
|
windows/checkbox.c \
|
||||||
|
windows/child.c \
|
||||||
windows/combobox.c \
|
windows/combobox.c \
|
||||||
windows/container.c \
|
windows/container.c \
|
||||||
windows/control.c \
|
windows/control.c \
|
||||||
|
|
|
@ -3,53 +3,46 @@
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
struct box {
|
struct box {
|
||||||
uiBox b;
|
uiWindowsControl c;
|
||||||
void (*baseCommitDestroy)(uiControl *);
|
HWND hwnd;
|
||||||
uintptr_t handle;
|
|
||||||
struct ptrArray *controls;
|
struct ptrArray *controls;
|
||||||
int vertical;
|
int vertical;
|
||||||
int padded;
|
int padded;
|
||||||
void (*baseResize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct boxControl {
|
#define ctrlStretchy(child) childFlag(child)
|
||||||
uiControl *c;
|
#define ctrlSetStretchy(child, stretchy) childSetFlag(child, stretchy)
|
||||||
int stretchy;
|
// 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
|
#define ctrlWidth(child) childIntmax(child, 0)
|
||||||
intmax_t height;
|
#define ctrlSetWidth(child, w) childSetIntmax(child, 0, w)
|
||||||
};
|
#define ctrlHeight(child) childIntmax(child, 1)
|
||||||
|
#define ctrlSetHeight(child, h) childSetIntmax(child, 1, h)
|
||||||
|
|
||||||
uiDefineControlType(uiBox, uiTypeBox, struct box)
|
static void onDestroy(uiBox *);
|
||||||
|
|
||||||
static void boxCommitDestroy(uiControl *c)
|
uiWindowsDefineControlWithOnDestroy(
|
||||||
|
uiBox, // type name
|
||||||
|
uiBoxType, // type function
|
||||||
|
onDestroy(this); // on destroy
|
||||||
|
)
|
||||||
|
|
||||||
|
static void onDestroy(uiBox *b)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) c;
|
struct child *bc;
|
||||||
struct boxControl *bc;
|
|
||||||
|
|
||||||
// don't chain up to base here; we need to destroy children ourselves first
|
|
||||||
while (b->controls->len != 0) {
|
while (b->controls->len != 0) {
|
||||||
bc = ptrArrayIndex(b->controls, struct boxControl *, 0);
|
bc = ptrArrayIndex(b->controls, struct boxControl *, 0);
|
||||||
uiControlSetParent(bc->c, NULL);
|
|
||||||
uiControlDestroy(bc->c);
|
|
||||||
ptrArrayDelete(b->controls, 0);
|
ptrArrayDelete(b->controls, 0);
|
||||||
uiFree(bc);
|
childDestroy(bc);
|
||||||
}
|
}
|
||||||
ptrArrayDestroy(b->controls);
|
ptrArrayDestroy(b->controls);
|
||||||
// NOW we can chain up to base
|
|
||||||
(*(b->baseCommitDestroy))(uiControl(b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintptr_t boxHandle(uiControl *c)
|
static void minimumSize(uiControl *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) c;
|
/* TODO
|
||||||
|
uiBox *b = uiBox(c);
|
||||||
return b->handle;
|
struct child *bc;
|
||||||
}
|
|
||||||
|
|
||||||
static void boxPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
|
||||||
{
|
|
||||||
struct box *b = (struct box *) c;
|
|
||||||
struct boxControl *bc;
|
|
||||||
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 box
|
// these two contain the largest preferred width and height of all stretchy controls in the box
|
||||||
|
@ -113,11 +106,13 @@ static void boxPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_
|
||||||
*height += nStretchy * maxStretchyHeight;
|
*height += nStretchy * maxStretchyHeight;
|
||||||
else
|
else
|
||||||
*width += nStretchy * maxStretchyWidth;
|
*width += nStretchy * maxStretchyWidth;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void boxResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) c;
|
/* TODO
|
||||||
|
uibox *b = uiBox(c);
|
||||||
struct boxControl *bc;
|
struct boxControl *bc;
|
||||||
int xpadding, ypadding;
|
int xpadding, ypadding;
|
||||||
uintmax_t nStretchy;
|
uintmax_t nStretchy;
|
||||||
|
@ -200,8 +195,10 @@ static void boxResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intm
|
||||||
x += bc->width + xpadding;
|
x += bc->width + xpadding;
|
||||||
}
|
}
|
||||||
uiFreeSizing(dchild);
|
uiFreeSizing(dchild);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
static int boxHasTabStops(uiControl *c)
|
static int boxHasTabStops(uiControl *c)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) c;
|
struct box *b = (struct box *) c;
|
||||||
|
@ -215,114 +212,97 @@ static int boxHasTabStops(uiControl *c)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static void boxContainerUpdateState(uiControl *c)
|
static void boxContainerUpdateState(uiControl *c)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) c;
|
struct box *b = (struct box *) c;
|
||||||
struct boxControl *bc;
|
struct child *bc;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
for (i = 0; i < b->controls->len; i++) {
|
for (i = 0; i < b->controls->len; i++) {
|
||||||
bc = ptrArrayIndex(b->controls, struct boxControl *, i);
|
bc = ptrArrayIndex(b->controls, struct child *, i);
|
||||||
uiControlUpdateState(bc->c);
|
childUpdateState(bc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void boxAppend(uiBox *ss, uiControl *c, int stretchy)
|
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) ss;
|
struct child *bc;
|
||||||
struct boxControl *bc;
|
|
||||||
uintptr_t zorder;
|
uintptr_t zorder;
|
||||||
int dozorder;
|
int dozorder;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
|
|
||||||
// start the zorder with the *CURRENT* first child
|
// start the zorder with the *CURRENT* first child
|
||||||
// this is in case we're adding a new first child
|
// this is in case we're adding a new first child
|
||||||
|
/* TODO
|
||||||
dozorder = 0;
|
dozorder = 0;
|
||||||
if (b->controls->len != 0) {
|
if (b->controls->len != 0) {
|
||||||
dozorder = 1;
|
dozorder = 1;
|
||||||
bc = ptrArrayIndex(b->controls, struct boxControl *, 0);
|
bc = ptrArrayIndex(b->controls, struct boxControl *, 0);
|
||||||
zorder = uiControlStartZOrder(bc->c);
|
zorder = uiControlStartZOrder(bc->c);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
bc = uiNew(struct boxControl);
|
bc = newChild(child, uiControl(b), b->hwnd);
|
||||||
bc->c = c;
|
ctrlSetStretchy(bc, stretchy);
|
||||||
bc->stretchy = stretchy;
|
|
||||||
uiControlSetParent(bc->c, uiControl(b));
|
|
||||||
ptrArrayAppend(b->controls, bc);
|
ptrArrayAppend(b->controls, bc);
|
||||||
uiControlQueueResize(uiControl(b));
|
uiControlQueueResize(uiControl(b));
|
||||||
|
|
||||||
|
/* TODO
|
||||||
// and now update the zorder for all controls
|
// and now update the zorder for all controls
|
||||||
if (dozorder)
|
if (dozorder)
|
||||||
for (i = 0; i < b->controls->len; i++) {
|
for (i = 0; i < b->controls->len; i++) {
|
||||||
bc = ptrArrayIndex(b->controls, struct boxControl *, i);
|
bc = ptrArrayIndex(b->controls, struct boxControl *, i);
|
||||||
zorder = uiControlSetZOrder(bc->c, zorder);
|
zorder = uiControlSetZOrder(bc->c, zorder);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void boxDelete(uiBox *ss, uintmax_t index)
|
void uiBoxDelete(uiBox *b, uintmax_t index)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) ss;
|
struct child *bc;
|
||||||
struct boxControl *bc;
|
|
||||||
uiControl *removed;
|
|
||||||
|
|
||||||
bc = ptrArrayIndex(b->controls, struct boxControl *, index);
|
bc = ptrArrayIndex(b->controls, struct child *, index);
|
||||||
removed = bc->c;
|
|
||||||
ptrArrayDelete(b->controls, index);
|
ptrArrayDelete(b->controls, index);
|
||||||
uiControlSetParent(removed, NULL);
|
childRemove(bc);
|
||||||
uiFree(bc);
|
|
||||||
uiControlQueueResize(uiControl(b));
|
uiControlQueueResize(uiControl(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int boxPadded(uiBox *ss)
|
int uiBoxPadded(uiBox *b)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) ss;
|
|
||||||
|
|
||||||
return b->padded;
|
return b->padded;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void boxSetPadded(uiBox *ss, int padded)
|
void uiBoxSetPadded(uiBox *b, int padded)
|
||||||
{
|
{
|
||||||
struct box *b = (struct box *) ss;
|
|
||||||
|
|
||||||
b->padded = padded;
|
b->padded = padded;
|
||||||
uiControlQueueResize(uiControl(b));
|
uiControlQueueResize(uiControl(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
uiBox *uiNewHorizontalBox(void)
|
static uiBox *finishNewBox(int vertical)
|
||||||
{
|
{
|
||||||
struct box *b;
|
uiBox *b;
|
||||||
|
|
||||||
b = (struct box *) uiNewControl(uiTypeBox());
|
b = (uiBox *) uiNewControl(uiBoxType());
|
||||||
|
|
||||||
b->handle = uiMakeContainer(uiControl(b));
|
b->hwnd = makeContainer();
|
||||||
|
|
||||||
|
b->vertical = vertical;
|
||||||
b->controls = newPtrArray();
|
b->controls = newPtrArray();
|
||||||
|
|
||||||
uiControl(b)->Handle = boxHandle;
|
uiWindowsFinishNewControl(b, uiBox);
|
||||||
uiControl(b)->PreferredSize = boxPreferredSize;
|
// TODO
|
||||||
b->baseResize = uiControl(b)->Resize;
|
|
||||||
uiControl(b)->Resize = boxResize;
|
|
||||||
uiControl(b)->HasTabStops = boxHasTabStops;
|
|
||||||
b->baseCommitDestroy = uiControl(b)->CommitDestroy;
|
|
||||||
uiControl(b)->CommitDestroy = boxCommitDestroy;
|
|
||||||
uiControl(b)->ContainerUpdateState = boxContainerUpdateState;
|
|
||||||
|
|
||||||
uiBox(b)->Append = boxAppend;
|
return b;
|
||||||
uiBox(b)->Delete = boxDelete;
|
}
|
||||||
uiBox(b)->Padded = boxPadded;
|
|
||||||
uiBox(b)->SetPadded = boxSetPadded;
|
|
||||||
|
|
||||||
return uiBox(b);
|
uiBox *uiNewHorizontalBox(void)
|
||||||
|
{
|
||||||
|
return finishNewBox(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiBox *uiNewVerticalBox(void)
|
uiBox *uiNewVerticalBox(void)
|
||||||
{
|
{
|
||||||
uiBox *bb;
|
return finishNewBox(1);
|
||||||
struct box *b;
|
|
||||||
|
|
||||||
bb = uiNewHorizontalBox();
|
|
||||||
b = (struct box *) bb;
|
|
||||||
b->vertical = 1;
|
|
||||||
return bb;
|
|
||||||
}
|
}
|
|
@ -15,6 +15,10 @@ struct child {
|
||||||
// This flag is for users of these functions.
|
// This flag is for users of these functions.
|
||||||
// For uiBox, this is "spaced".
|
// For uiBox, this is "spaced".
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
|
// These intmax_t variables are for users of these functions.
|
||||||
|
// For uiBox, these are "width" and "height".
|
||||||
|
intmax_t im[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct child *newChild(uiControl *child, uiControl *parent, HWND parentHWND)
|
struct child *newChild(uiControl *child, uiControl *parent, HWND parentHWND)
|
||||||
|
@ -133,3 +137,13 @@ void childSetFlag(struct child *c, int flag)
|
||||||
{
|
{
|
||||||
c->flag = flag;
|
c->flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intmax_t childIntmax(struct child *c, int n)
|
||||||
|
{
|
||||||
|
return c->im[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
void childSetIntmax(struct child *c, int n, intmax_t to)
|
||||||
|
{
|
||||||
|
c->im[n] = to;
|
||||||
|
}
|
||||||
|
|
|
@ -109,3 +109,5 @@ extern int childMargined(struct child *c);
|
||||||
extern void childSetMargined(struct child *c);
|
extern void childSetMargined(struct child *c);
|
||||||
extern int childFlag(struct child *c);
|
extern int childFlag(struct child *c);
|
||||||
extern void childSetFlag(struct child *c, int flag);
|
extern void childSetFlag(struct child *c, int flag);
|
||||||
|
extern intmax_t childIntmax(struct child *c, int n);
|
||||||
|
extern void childSetIntmax(struct child *c, int n, intmax_t to);
|
||||||
|
|
Loading…
Reference in New Issue