2015-10-08 18:20:06 -05:00
|
|
|
// 8 october 2015
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
static uiArea *area;
|
|
|
|
static uiCombobox *which;
|
2015-10-09 09:09:55 -05:00
|
|
|
static uiSpinbox *hamount;
|
|
|
|
static uiSpinbox *vamount;
|
2015-10-08 18:20:06 -05:00
|
|
|
|
|
|
|
struct handler {
|
|
|
|
uiAreaHandler ah;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct handler handler;
|
|
|
|
|
|
|
|
static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
|
|
|
{
|
2015-10-09 14:09:08 -05:00
|
|
|
runDrawTest(uiComboboxSelected(which), p);
|
2015-10-08 18:20:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
|
|
|
|
{
|
2015-10-09 09:09:55 -05:00
|
|
|
return uiSpinboxValue(hamount);
|
2015-10-08 18:20:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
|
|
|
{
|
2015-10-09 09:09:55 -05:00
|
|
|
return uiSpinboxValue(vamount);
|
2015-10-08 18:20:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
|
|
|
|
{
|
2015-10-09 09:09:55 -05:00
|
|
|
// TODO make a checkbox
|
|
|
|
return uiSpinboxValue(hamount) == 0 && uiSpinboxValue(vamount) == 0;
|
2015-10-08 18:20:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
|
|
|
{
|
|
|
|
printf("mouse (%d,%d):(%d,%d) down:%d up:%d count:%d mods:%x held:%x\n",
|
|
|
|
(int) e->X,
|
|
|
|
(int) e->Y,
|
|
|
|
(int) e->HScrollPos,
|
|
|
|
(int) e->VScrollPos,
|
|
|
|
(int) e->Down,
|
|
|
|
(int) e->Up,
|
|
|
|
(int) e->Count,
|
|
|
|
(uint32_t) e->Modifiers,
|
|
|
|
e->Held1To64);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void handlerDragBroken(uiAreaHandler *ah, uiArea *a)
|
|
|
|
{
|
|
|
|
printf("drag broken\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handlerKeyEvent(uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e)
|
|
|
|
{
|
|
|
|
char k[4];
|
|
|
|
|
|
|
|
k[0] = '\'';
|
|
|
|
k[1] = e->Key;
|
|
|
|
k[2] = '\'';
|
|
|
|
k[3] = '\0';
|
|
|
|
if (e->Key == 0) {
|
|
|
|
k[0] = '0';
|
|
|
|
k[1] = '\0';
|
|
|
|
}
|
|
|
|
printf("key key:%s extkey:%d mod:%d mods:%d up:%d\n",
|
|
|
|
k,
|
|
|
|
(int) e->ExtKey,
|
|
|
|
(int) e->Modifier,
|
|
|
|
(int) e->Modifiers,
|
|
|
|
e->Up);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-09 09:09:55 -05:00
|
|
|
static void onAmountChanged(uiSpinbox *s, void *data)
|
|
|
|
{
|
|
|
|
uiAreaUpdateScroll(area);
|
|
|
|
}
|
|
|
|
|
2015-10-09 12:47:02 -05:00
|
|
|
static void shouldntHappen(uiCombobox *c, void *data)
|
|
|
|
{
|
2015-10-09 12:54:34 -05:00
|
|
|
fprintf(stderr, "YOU SHOULD NOT SEE THIS. If you do, uiComboboxSetSelected() is triggering uiComboboxOnSelected(), which it should not.\n");
|
2015-10-09 12:47:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void redraw(uiCombobox *c, void *data)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2015-10-08 18:20:06 -05:00
|
|
|
uiBox *makePage6(void)
|
|
|
|
{
|
|
|
|
uiBox *page6;
|
|
|
|
uiBox *hbox;
|
|
|
|
|
|
|
|
handler.ah.Draw = handlerDraw;
|
|
|
|
handler.ah.HScrollMax = handlerHScrollMax;
|
|
|
|
handler.ah.VScrollMax = handlerVScrollMax;
|
|
|
|
handler.ah.RedrawOnResize = handlerRedrawOnResize;
|
|
|
|
handler.ah.MouseEvent = handlerMouseEvent;
|
|
|
|
handler.ah.DragBroken = handlerDragBroken;
|
|
|
|
handler.ah.KeyEvent = handlerKeyEvent;
|
|
|
|
|
|
|
|
page6 = newVerticalBox();
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
uiBoxAppend(page6, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
which = uiNewCombobox();
|
2015-10-09 12:47:02 -05:00
|
|
|
populateComboboxWithTests(which);
|
|
|
|
// this is to make sure that uiComboboxOnSelected() doesn't trigger with uiComboboxSetSelected()
|
|
|
|
uiComboboxOnSelected(which, shouldntHappen, NULL);
|
|
|
|
uiComboboxSetSelected(which, 0);
|
|
|
|
uiComboboxOnSelected(which, redraw, NULL);
|
2015-10-08 18:20:06 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(which), 0);
|
|
|
|
|
2015-10-09 09:09:55 -05:00
|
|
|
// make these first in case the area handler calls the information as part of the constructor
|
|
|
|
hamount = uiNewSpinbox(0, 100000);
|
|
|
|
uiSpinboxOnChanged(hamount, onAmountChanged, NULL);
|
|
|
|
vamount = uiNewSpinbox(0, 100000);
|
|
|
|
uiSpinboxOnChanged(vamount, onAmountChanged, NULL);
|
|
|
|
|
2015-10-08 18:20:06 -05:00
|
|
|
area = uiNewArea((uiAreaHandler *) (&handler));
|
|
|
|
uiBoxAppend(page6, uiControl(area), 1);
|
|
|
|
|
2015-10-09 09:09:55 -05:00
|
|
|
hbox = newHorizontalBox();
|
|
|
|
uiBoxAppend(hbox, uiControl(uiNewLabel("H ")), 0);
|
|
|
|
uiBoxAppend(hbox, uiControl(hamount), 0);
|
|
|
|
uiBoxAppend(hbox, uiControl(uiNewLabel(" V ")), 0);
|
|
|
|
uiBoxAppend(hbox, uiControl(vamount), 0);
|
|
|
|
uiBoxAppend(page6, uiControl(hbox), 0);
|
|
|
|
|
2015-10-08 18:20:06 -05:00
|
|
|
return page6;
|
|
|
|
}
|