ui/motif/tree.c

changeset 128
c284c15509a8
parent 60
7cd1b8890302
child 153
ee49d1852a5f
equal deleted inserted replaced
127:ce342364fad5 128:c284c15509a8
116 width = w; 116 width = w;
117 } 117 }
118 data = model->next(model); 118 data = model->next(model);
119 } 119 }
120 120
121 UiTableView *tableview = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiTableView));
122 tableview->widget = container;
123 tableview->list = model;
124 tableview->modelinfo = modelinfo;
125 model->observers = ui_add_observer(
126 model->observers,
127 (ui_callback)ui_table_update,
128 tableview);
129
121 // set new XmContainer width 130 // set new XmContainer width
122 XtVaSetValues(container, XmNwidth, width, NULL); 131 XtVaSetValues(container, XmNwidth, width, NULL);
123 132
124 // cleanup 133 // cleanup
125 for(int i=0;i<modelinfo->columns;i++) { 134 for(int i=0;i<modelinfo->columns;i++) {
126 XmStringFree(header[i]); 135 XmStringFree(header[i]);
127 } 136 }
128 XtFree((char*)header); 137 XtFree((char*)header);
129 138
130 return scrollw; 139 return scrollw;
140 }
141
142 void ui_table_update(UiEvent *event, UiTableView *view) {
143 // clear container
144 Widget *children;
145 int nc;
146
147 XtVaGetValues(
148 view->widget,
149 XmNchildren,
150 &children,
151 XmNnumChildren,
152 &nc,
153 NULL);
154
155 for(int i=0;i<nc;i++) {
156 XtDestroyWidget(children[i]);
157 }
158
159 UiList *model = view->list;
160
161 void *data = model->first(model);
162 int width = 0;
163 while(data) {
164 int w = ui_add_icon_gadget(view->widget, view->modelinfo, data);
165 if(w > width) {
166 width = w;
167 }
168 data = model->next(model);
169 }
170
131 } 171 }
132 172
133 #define UI_COL_CHAR_WIDTH 12 173 #define UI_COL_CHAR_WIDTH 12
134 174
135 int ui_add_icon_gadget(Widget container, UiModelInfo *modelinfo, void *data) { 175 int ui_add_icon_gadget(Widget container, UiModelInfo *modelinfo, void *data) {

mercurial