Did scrolling for the uiArea test and uiArea itself on GTK+.

This commit is contained in:
Pietro Gagliardi 2015-10-09 10:09:55 -04:00
parent 752467b543
commit 5d19387811
2 changed files with 37 additions and 10 deletions

View File

@ -3,6 +3,8 @@
static uiArea *area;
static uiCombobox *which;
static uiSpinbox *hamount;
static uiSpinbox *vamount;
struct handler {
uiAreaHandler ah;
@ -226,20 +228,18 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
{
// TODO
return 0;
return uiSpinboxValue(hamount);
}
static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
{
// TODO
return 0;
return uiSpinboxValue(vamount);
}
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
{
// TODO
return 1;
// TODO make a checkbox
return uiSpinboxValue(hamount) == 0 && uiSpinboxValue(vamount) == 0;
}
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
@ -282,6 +282,11 @@ static int handlerKeyEvent(uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e)
return 0;
}
static void onAmountChanged(uiSpinbox *s, void *data)
{
uiAreaUpdateScroll(area);
}
uiBox *makePage6(void)
{
uiBox *page6;
@ -303,8 +308,21 @@ uiBox *makePage6(void)
which = uiNewCombobox();
uiBoxAppend(hbox, uiControl(which), 0);
// 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);
area = uiNewArea((uiAreaHandler *) (&handler));
uiBoxAppend(page6, uiControl(area), 1);
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);
return page6;
}

View File

@ -23,6 +23,9 @@ struct areaWidgetClass {
struct uiArea {
uiUnixControl c;
GtkWidget *widget;
GtkContainer *scontainer;
GtkScrolledWindow *sw;
GtkWidget *areaWidget;
GtkDrawingArea *drawingArea;
areaWidget *area;
};
@ -571,13 +574,19 @@ uiArea *uiNewArea(uiAreaHandler *ah)
a = (uiArea *) uiNewControl(uiAreaType());
a->widget = GTK_WIDGET(g_object_new(areaWidgetType,
a->widget = gtk_scrolled_window_new(NULL, NULL);
a->scontainer = GTK_CONTAINER(a->widget);
a->sw = GTK_SCROLLED_WINDOW(a->widget);
a->areaWidget = GTK_WIDGET(g_object_new(areaWidgetType,
"area-handler", ah,
NULL));
a->drawingArea = GTK_DRAWING_AREA(a->widget);
a->area = areaWidget(a->widget);
a->drawingArea = GTK_DRAWING_AREA(a->areaWidget);
a->area = areaWidget(a->areaWidget);
// TODO wrap in scrolled window
gtk_container_add(a->scontainer, a->areaWidget);
// and make the area visible; only the scrolled window's visibility is controlled by libui
gtk_widget_show(a->areaWidget);
uiUnixFinishNewControl(a, uiArea);