Did scrolling for the uiArea test and uiArea itself on GTK+.
This commit is contained in:
parent
752467b543
commit
5d19387811
30
test/page6.c
30
test/page6.c
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
static uiArea *area;
|
static uiArea *area;
|
||||||
static uiCombobox *which;
|
static uiCombobox *which;
|
||||||
|
static uiSpinbox *hamount;
|
||||||
|
static uiSpinbox *vamount;
|
||||||
|
|
||||||
struct handler {
|
struct handler {
|
||||||
uiAreaHandler ah;
|
uiAreaHandler ah;
|
||||||
|
@ -226,20 +228,18 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
|
|
||||||
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
|
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
|
||||||
{
|
{
|
||||||
// TODO
|
return uiSpinboxValue(hamount);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
||||||
{
|
{
|
||||||
// TODO
|
return uiSpinboxValue(vamount);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
|
static int handlerRedrawOnResize(uiAreaHandler *a, uiArea *area)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO make a checkbox
|
||||||
return 1;
|
return uiSpinboxValue(hamount) == 0 && uiSpinboxValue(vamount) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
||||||
|
@ -282,6 +282,11 @@ static int handlerKeyEvent(uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void onAmountChanged(uiSpinbox *s, void *data)
|
||||||
|
{
|
||||||
|
uiAreaUpdateScroll(area);
|
||||||
|
}
|
||||||
|
|
||||||
uiBox *makePage6(void)
|
uiBox *makePage6(void)
|
||||||
{
|
{
|
||||||
uiBox *page6;
|
uiBox *page6;
|
||||||
|
@ -303,8 +308,21 @@ uiBox *makePage6(void)
|
||||||
which = uiNewCombobox();
|
which = uiNewCombobox();
|
||||||
uiBoxAppend(hbox, uiControl(which), 0);
|
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));
|
area = uiNewArea((uiAreaHandler *) (&handler));
|
||||||
uiBoxAppend(page6, uiControl(area), 1);
|
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;
|
return page6;
|
||||||
}
|
}
|
||||||
|
|
17
unix/area.c
17
unix/area.c
|
@ -23,6 +23,9 @@ struct areaWidgetClass {
|
||||||
struct uiArea {
|
struct uiArea {
|
||||||
uiUnixControl c;
|
uiUnixControl c;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
GtkContainer *scontainer;
|
||||||
|
GtkScrolledWindow *sw;
|
||||||
|
GtkWidget *areaWidget;
|
||||||
GtkDrawingArea *drawingArea;
|
GtkDrawingArea *drawingArea;
|
||||||
areaWidget *area;
|
areaWidget *area;
|
||||||
};
|
};
|
||||||
|
@ -571,13 +574,19 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
|
|
||||||
a = (uiArea *) uiNewControl(uiAreaType());
|
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,
|
"area-handler", ah,
|
||||||
NULL));
|
NULL));
|
||||||
a->drawingArea = GTK_DRAWING_AREA(a->widget);
|
a->drawingArea = GTK_DRAWING_AREA(a->areaWidget);
|
||||||
a->area = areaWidget(a->widget);
|
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);
|
uiUnixFinishNewControl(a, uiArea);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue