2015-04-22 12:42:52 -05:00
|
|
|
// 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;
|
|
|
|
|
2015-04-22 16:54:05 -05:00
|
|
|
#define grow 32
|
2015-04-22 12:42:52 -05:00
|
|
|
|
|
|
|
static void *append(void *thing, int type)
|
|
|
|
{
|
|
|
|
if (len >= cap) {
|
|
|
|
cap += grow;
|
2015-04-22 16:54:05 -05:00
|
|
|
things = (struct thing *) realloc(things, cap * sizeof (struct thing));
|
2015-04-22 12:42:52 -05:00
|
|
|
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,
|
2015-04-28 20:47:18 -05:00
|
|
|
tab,
|
2015-05-11 21:35:16 -05:00
|
|
|
group,
|
2015-04-22 12:42:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
void setSpaced(int spaced)
|
|
|
|
{
|
|
|
|
uintmax_t i;
|
|
|
|
void *p;
|
2015-04-30 14:24:27 -05:00
|
|
|
uintmax_t j, n;
|
2015-04-22 12:42:52 -05:00
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
p = things[i].ptr;
|
2015-04-22 16:54:05 -05:00
|
|
|
switch (things[i].type) {
|
2015-04-22 12:42:52 -05:00
|
|
|
case window:
|
|
|
|
uiWindowSetMargined(uiWindow(p), spaced);
|
|
|
|
break;
|
|
|
|
case box:
|
|
|
|
uiBoxSetPadded(uiBox(p), spaced);
|
|
|
|
break;
|
2015-04-28 20:47:18 -05:00
|
|
|
case tab:
|
2015-04-30 14:24:27 -05:00
|
|
|
n = uiTabNumPages(uiTab(p));
|
|
|
|
for (j = 0; j < n; j++)
|
|
|
|
uiTabSetMargined(uiTab(p), j, spaced);
|
2015-04-28 20:47:18 -05:00
|
|
|
break;
|
2015-04-22 12:42:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-29 13:03:17 -05:00
|
|
|
void querySpaced(char out[12]) // more than enough
|
|
|
|
{
|
|
|
|
int m = 0;
|
|
|
|
int p = 0;
|
|
|
|
uintmax_t i;
|
|
|
|
void *pp;
|
2015-04-30 14:24:27 -05:00
|
|
|
uintmax_t j, n;
|
2015-04-29 13:03:17 -05:00
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
pp = things[i].ptr;
|
|
|
|
switch (things[i].type) {
|
|
|
|
case window:
|
2015-04-30 14:24:27 -05:00
|
|
|
if (uiWindowMargined(uiWindow(pp)))
|
|
|
|
m++;
|
2015-04-29 13:03:17 -05:00
|
|
|
break;
|
|
|
|
case box:
|
|
|
|
p = uiBoxPadded(uiBox(pp));
|
|
|
|
break;
|
2015-04-30 14:24:27 -05:00
|
|
|
case tab:
|
|
|
|
n = uiTabNumPages(uiTab(pp));
|
|
|
|
for (j = 0; j < n; j++)
|
|
|
|
if (uiTabMargined(uiTab(pp), j))
|
|
|
|
m++;
|
2015-04-29 13:03:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out[0] = 'm';
|
|
|
|
out[1] = ' ';
|
2015-04-30 14:24:27 -05:00
|
|
|
out[2] = '0' + m;
|
2015-04-29 13:03:17 -05:00
|
|
|
out[3] = ' ';
|
|
|
|
out[4] = 'p';
|
|
|
|
out[5] = ' ';
|
|
|
|
out[6] = '0';
|
|
|
|
if (p)
|
|
|
|
out[6] = '1';
|
|
|
|
out[7] = '\0';
|
|
|
|
}
|
|
|
|
|
2015-04-22 18:23:34 -05:00
|
|
|
uiWindow *newWindow(const char *title, int width, int height, int hasMenubar)
|
|
|
|
{
|
|
|
|
uiWindow *w;
|
|
|
|
|
|
|
|
w = uiNewWindow(title, width, height, hasMenubar);
|
|
|
|
append(w, window);
|
|
|
|
return w;
|
|
|
|
}
|
2015-04-22 12:42:52 -05:00
|
|
|
|
|
|
|
uiBox *newHorizontalBox(void)
|
|
|
|
{
|
|
|
|
uiBox *b;
|
|
|
|
|
2015-06-03 23:51:41 -05:00
|
|
|
b = (*newhbox)();
|
2015-04-22 12:42:52 -05:00
|
|
|
append(b, box);
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiBox *newVerticalBox(void)
|
|
|
|
{
|
|
|
|
uiBox *b;
|
|
|
|
|
2015-06-03 23:51:41 -05:00
|
|
|
b = (*newvbox)();
|
2015-04-22 12:42:52 -05:00
|
|
|
append(b, box);
|
|
|
|
return b;
|
|
|
|
}
|
2015-04-28 20:47:18 -05:00
|
|
|
|
|
|
|
uiTab *newTab(void)
|
|
|
|
{
|
|
|
|
uiTab *t;
|
|
|
|
|
|
|
|
t = uiNewTab();
|
|
|
|
append(t, tab);
|
|
|
|
return t;
|
|
|
|
}
|
2015-05-11 21:35:16 -05:00
|
|
|
|
|
|
|
uiGroup *newGroup(const char *text)
|
|
|
|
{
|
|
|
|
uiGroup *g;
|
|
|
|
|
|
|
|
g = uiNewGroup(text);
|
|
|
|
append(g, group);
|
|
|
|
return g;
|
|
|
|
}
|