diff --git a/test/GNUfiles.mk b/test/GNUfiles.mk index fc8eae8c..8da0c317 100644 --- a/test/GNUfiles.mk +++ b/test/GNUfiles.mk @@ -12,6 +12,7 @@ CFILES += \ test/page6.c \ test/page7.c \ test/page7a.c \ + test/page7b.c \ test/spaced.c HFILES += \ diff --git a/test/page7.c b/test/page7.c index 6061b2c3..044098a5 100644 --- a/test/page7.c +++ b/test/page7.c @@ -5,11 +5,20 @@ uiBox *makePage7(void) { uiBox *page7; uiGroup *group; + uiBox *box2; page7 = newHorizontalBox(); group = makePage7a(); uiBoxAppend(page7, uiControl(group), 1); + box2 = newVerticalBox(); + uiBoxAppend(page7, uiControl(box2), 1); + + group = makePage7b(); + uiBoxAppend(box2, uiControl(group), 1); + + uiBoxAppend(box2, uiControl(uiNewLabel("")), 1); + return page7; } diff --git a/test/page7b.c b/test/page7b.c new file mode 100644 index 00000000..b59cb41a --- /dev/null +++ b/test/page7b.c @@ -0,0 +1,68 @@ +// 13 october 2015 +#include "test.h" + +static uiArea *area; +static uiCheckbox *label; + +struct handler { + uiAreaHandler ah; +}; + +static struct handler handler; + +static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p) +{ + // do nothing +} + +static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e) +{ + char pos[128]; + + snprintf(pos, 127, "X %g Y %g", e->X, e->Y); + uiCheckboxSetText(label, pos); +} + +static void handlerMouseCrossed(uiAreaHandler *ah, uiArea *a, int left) +{ + uiCheckboxSetChecked(label, !left); +} + +static void handlerDragBroken(uiAreaHandler *ah, uiArea *a) +{ + // do nothing +} + +static int handlerKeyEvent(uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e) +{ + if (e->Key == 'h' && !e->Up) { + // TODO hide the widget momentarily on the h key + return 1; + } + return 0; +} + +uiGroup *makePage7b(void) +{ + uiGroup *group; + uiBox *box; + + handler.ah.Draw = handlerDraw; + handler.ah.MouseEvent = handlerMouseEvent; + handler.ah.MouseCrossed = handlerMouseCrossed; + handler.ah.DragBroken = handlerDragBroken; + handler.ah.KeyEvent = handlerKeyEvent; + + group = newGroup("Scrolling Mouse Test"); + + box = newVerticalBox(); + uiGroupSetChild(group, uiControl(box)); + + area = uiNewScrollingArea((uiAreaHandler *) (&handler), 5000, 5000); + uiBoxAppend(box, uiControl(area), 1); + + label = uiNewCheckbox(""); + uiBoxAppend(box, uiControl(label), 0); + + return group; +} diff --git a/test/test.h b/test/test.h index 8f4faf45..7fd133a7 100644 --- a/test/test.h +++ b/test/test.h @@ -60,5 +60,8 @@ extern uiBox *makePage7(void); // page7a.c extern uiGroup *makePage7a(void); +// page7b.c +extern uiGroup *makePage7b(void); + // page8.c extern uiBox *makePage8(void); diff --git a/unix/area.c b/unix/area.c index 39fd248d..712d05d2 100644 --- a/unix/area.c +++ b/unix/area.c @@ -64,16 +64,6 @@ static void areaWidget_init(areaWidget *aw) GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - // TODO are these still needed? -/* - // for scrolling - // TODO do we need GDK_TOUCH_MASK? - gtk_widget_add_events(GTK_WIDGET(aw), - GDK_SCROLL_MASK | - GDK_TOUCH_MASK | - GDK_SMOOTH_SCROLL_MASK); -*/ - gtk_widget_set_can_focus(GTK_WIDGET(aw), TRUE); clickCounterReset(&(aw->cc));