2015-10-08 18:20:06 -05:00
|
|
|
// 8 october 2015
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
static uiArea *area;
|
|
|
|
static uiCombobox *which;
|
2015-11-27 10:49:06 -06:00
|
|
|
static uiCheckbox *swallowKeys;
|
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 void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
|
|
|
{
|
2015-12-17 18:30:28 -06:00
|
|
|
printf("mouse (%g,%g):(%g,%g) down:%d up:%d count:%d mods:%x held:%x\n",
|
|
|
|
e->X,
|
|
|
|
e->Y,
|
|
|
|
e->AreaWidth,
|
|
|
|
e->AreaHeight,
|
2015-10-08 18:20:06 -05:00
|
|
|
(int) e->Down,
|
|
|
|
(int) e->Up,
|
|
|
|
(int) e->Count,
|
|
|
|
(uint32_t) e->Modifiers,
|
|
|
|
e->Held1To64);
|
|
|
|
}
|
|
|
|
|
2015-12-17 18:30:28 -06:00
|
|
|
static void handlerMouseCrossed(uiAreaHandler *ah, uiArea *a, int left)
|
|
|
|
{
|
|
|
|
printf("mouse crossed %d\n", left);
|
|
|
|
}
|
|
|
|
|
2015-10-08 18:20:06 -05:00
|
|
|
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);
|
2015-11-27 10:49:06 -06:00
|
|
|
return uiCheckboxChecked(swallowKeys);
|
2015-10-08 18:20:06 -05:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2015-10-09 14:27:57 -05:00
|
|
|
uiAreaQueueRedrawAll(area);
|
2015-10-09 12:47:02 -05:00
|
|
|
}
|
|
|
|
|
2015-10-08 18:20:06 -05:00
|
|
|
uiBox *makePage6(void)
|
|
|
|
{
|
|
|
|
uiBox *page6;
|
|
|
|
uiBox *hbox;
|
|
|
|
|
|
|
|
handler.ah.Draw = handlerDraw;
|
|
|
|
handler.ah.MouseEvent = handlerMouseEvent;
|
2015-12-17 18:30:28 -06:00
|
|
|
handler.ah.MouseCrossed = handlerMouseCrossed;
|
2015-10-08 18:20:06 -05:00
|
|
|
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);
|
|
|
|
|
|
|
|
area = uiNewArea((uiAreaHandler *) (&handler));
|
|
|
|
uiBoxAppend(page6, uiControl(area), 1);
|
|
|
|
|
2015-11-27 10:49:06 -06:00
|
|
|
swallowKeys = uiNewCheckbox("Consider key events handled");
|
|
|
|
uiBoxAppend(page6, uiControl(swallowKeys), 0);
|
|
|
|
|
2015-10-08 18:20:06 -05:00
|
|
|
return page6;
|
|
|
|
}
|