# HG changeset patch # User Olaf Wintermann # Date 1453924537 -3600 # Node ID 49bc645df8b71f31c189fb295af962f5b8eb0cc8 # Parent d7a7fb79b5f7877da7311bb79510acfce6b483da added scrolledwindow (GTK) diff -r d7a7fb79b5f7 -r 49bc645df8b7 application/main.c --- a/application/main.c Wed Jan 27 12:52:39 2016 +0100 +++ b/application/main.c Wed Jan 27 20:55:37 2016 +0100 @@ -141,24 +141,27 @@ ui_context_closefunc(obj->ctx, window_close, NULL); ///* - ui_hbox(obj); + ui_scrolledwindow(obj); -//* ui_vbox(obj); - drawingarea = ui_drawingarea(obj, draw, NULL); - ctxmenu = ui_contextmenu_w(obj, drawingarea); - ui_widget_menuitem(obj, "Test1", NULL, NULL); - ui_widget_menuitem(obj, "Test2", NULL, NULL); - ui_widget_menuitem(obj, "Test3", NULL, NULL); - ui_widget_menuitem(obj, "Test4", NULL, NULL); - ui_drawingarea_mousehandler(obj, drawingarea, click, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_button(obj, "Test", NULL, NULL); + ui_end(obj); -//*/ - - ui_vscrollbar(obj, &range, action_scroll, NULL); - range.setrange(&range, 0, 100); - range.setextent(&range, 20); - range.set(&range, 0); ui_end(obj); //*/ diff -r d7a7fb79b5f7 -r 49bc645df8b7 ui/gtk/container.c --- a/ui/gtk/container.c Wed Jan 27 12:52:39 2016 +0100 +++ b/ui/gtk/container.c Wed Jan 27 20:55:37 2016 +0100 @@ -183,6 +183,22 @@ } #endif +UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) { + UiContainer *ct = ucx_mempool_calloc( + obj->ctx->mempool, + 1, + sizeof(UiContainer)); + ct->widget = scrolledwindow; + ct->add = ui_scrolledwindow_container_add; + return ct; +} + +void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { + gtk_container_add(GTK_CONTAINER(ct->widget), widget); + ui_reset_layout(ct->layout); + ct->current = widget; +} + UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) { UiTabViewContainer *ct = ucx_mempool_calloc( obj->ctx->mempool, @@ -308,6 +324,18 @@ return widget; } +UIWIDGET ui_scrolledwindow(UiObject *obj) { + UiContainer *ct = uic_get_current_container(obj); + GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); + ct->add(ct, sw, TRUE); + + UiObject *newobj = uic_object_new(obj, sw); + newobj->container = ui_scrolledwindow_container(obj, sw); + uic_obj_add(obj, newobj); + + return sw; +} + UIWIDGET ui_tabview(UiObject *obj) { GtkWidget *tabview = gtk_notebook_new(); gtk_notebook_set_show_border(GTK_NOTEBOOK(tabview), FALSE); diff -r d7a7fb79b5f7 -r 49bc645df8b7 ui/gtk/container.h --- a/ui/gtk/container.h Wed Jan 27 12:52:39 2016 +0100 +++ b/ui/gtk/container.h Wed Jan 27 20:55:37 2016 +0100 @@ -102,6 +102,9 @@ UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid); void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); +UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow); +void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); + UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview); void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); diff -r d7a7fb79b5f7 -r 49bc645df8b7 ui/motif/graphics.c --- a/ui/motif/graphics.c Wed Jan 27 12:52:39 2016 +0100 +++ b/ui/motif/graphics.c Wed Jan 27 20:55:37 2016 +0100 @@ -37,8 +37,8 @@ static void ui_drawingarea_expose(Widget widget, XtPointer u, XtPointer c) { UiDrawEvent *drawevent = u; - XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *)c; - XEvent *event = cbs->event; + //XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *)c; + //XEvent *event = cbs->event; Display *dpy = XtDisplay(widget); UiEvent ev; @@ -90,6 +90,8 @@ XmNexposeCallback, ui_drawingarea_expose, event); + + XtVaSetValues(drawingarea, XmNuserData, event, NULL); } XtManageChild(drawingarea); @@ -137,12 +139,20 @@ } void ui_drawingarea_getsize(UIWIDGET drawingarea, int *width, int *height) { - // TODO + XtVaGetValues( + drawingarea, + XmNwidth, + width, + XmNheight, + height, + NULL); } void ui_drawingarea_redraw(UIWIDGET drawingarea) { - XClearArea(XtDisplay(drawingarea), drawingarea->core.window, 0, 0, drawingarea->core.width, drawingarea->core.height, True); - + //XClearArea(XtDisplay(drawingarea), drawingarea->core.window, 0, 0, drawingarea->core.width, drawingarea->core.height, True); + UiDrawEvent *event; + XtVaGetValues(drawingarea, XmNuserData, &event, NULL); + ui_drawingarea_expose(drawingarea, event, NULL); } diff -r d7a7fb79b5f7 -r 49bc645df8b7 ui/ui/toolkit.h --- a/ui/ui/toolkit.h Wed Jan 27 12:52:39 2016 +0100 +++ b/ui/ui/toolkit.h Wed Jan 27 20:55:37 2016 +0100 @@ -275,6 +275,8 @@ UIWIDGET ui_grid(UiObject *obj); UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing); +UIWIDGET ui_scrolledwindow(UiObject *obj); + UIWIDGET ui_sidebar(UiObject *obj); void ui_end(UiObject *obj);