ui/motif/tree.c

changeset 128
c284c15509a8
parent 60
7cd1b8890302
child 153
ee49d1852a5f
--- a/ui/motif/tree.c	Wed Jul 13 16:40:59 2016 +0200
+++ b/ui/motif/tree.c	Sat Sep 17 19:32:44 2016 +0200
@@ -118,6 +118,15 @@
         data = model->next(model);
     }
     
+    UiTableView *tableview = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiTableView));
+    tableview->widget = container;
+    tableview->list = model;
+    tableview->modelinfo = modelinfo;
+    model->observers = ui_add_observer(
+            model->observers,
+            (ui_callback)ui_table_update,
+            tableview);
+    
     // set new XmContainer width
     XtVaSetValues(container, XmNwidth, width, NULL);
     
@@ -130,6 +139,37 @@
     return scrollw;
 }
 
+void ui_table_update(UiEvent *event, UiTableView *view) {
+    // clear container
+    Widget *children;
+    int nc;
+
+    XtVaGetValues(
+            view->widget,
+            XmNchildren,
+            &children,
+            XmNnumChildren,
+            &nc,
+            NULL);
+
+    for(int i=0;i<nc;i++) {
+        XtDestroyWidget(children[i]);
+    }
+    
+    UiList *model = view->list;
+    
+    void *data = model->first(model);
+    int width = 0;
+    while(data) {
+        int w = ui_add_icon_gadget(view->widget, view->modelinfo, data);
+        if(w > width) {
+            width = w;
+        }
+        data = model->next(model);
+    }
+    
+}
+
 #define UI_COL_CHAR_WIDTH 12
 
 int ui_add_icon_gadget(Widget container, UiModelInfo *modelinfo, void *data) {

mercurial