71 lines
1.0 KiB
C
71 lines
1.0 KiB
C
// 22 april 2015
|
|
#include "test.h"
|
|
|
|
struct thing {
|
|
void *ptr;
|
|
int type;
|
|
};
|
|
|
|
static struct thing *things = NULL;
|
|
static uintmax_t len = 0;
|
|
static uintmax_t cap = 0;
|
|
|
|
#define incr 32
|
|
|
|
static void *append(void *thing, int type)
|
|
{
|
|
if (len >= cap) {
|
|
cap += grow;
|
|
things = (struct thing *) realloc(uiBoxes, cap * sizeof (struct thing));
|
|
if (things == NULL)
|
|
die("reallocating things array in test/spaced.c append()");
|
|
}
|
|
things[len].ptr = thing;
|
|
things[len].type = type;
|
|
len++;
|
|
return things[len - 1].ptr;
|
|
}
|
|
|
|
enum types {
|
|
window,
|
|
box,
|
|
};
|
|
|
|
void setSpaced(int spaced)
|
|
{
|
|
uintmax_t i;
|
|
void *p;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
p = things[i].ptr;
|
|
switch (things[i],type) {
|
|
case window:
|
|
uiWindowSetMargined(uiWindow(p), spaced);
|
|
break;
|
|
case box:
|
|
uiBoxSetPadded(uiBox(p), spaced);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// TODO newWindow()
|
|
|
|
uiBox *newHorizontalBox(void)
|
|
{
|
|
uiBox *b;
|
|
|
|
b = uiNewHorizontalBox();
|
|
append(b, box);
|
|
return b;
|
|
}
|
|
|
|
uiBox *newVerticalBox(void)
|
|
{
|
|
uiBox *b;
|
|
|
|
b = uiNewVerticalBox();
|
|
append(b, box);
|
|
return b;
|
|
}
|