Sat, 14 Feb 2015 10:30:45 +0100
added toolbar combobox (Motif)
ui/motif/list.h | file | annotate | diff | comparison | revisions | |
ui/motif/toolbar.c | file | annotate | diff | comparison | revisions | |
ui/motif/toolbar.h | file | annotate | diff | comparison | revisions |
--- a/ui/motif/list.h Wed Feb 11 11:34:55 2015 +0100 +++ b/ui/motif/list.h Sat Feb 14 10:30:45 2015 +0100 @@ -48,6 +48,8 @@ UiListPtr *list; } UiListViewEventData; +void* ui_strmodel_getvalue(void *elm, int column); + XmStringTable ui_create_stringlist(UiList *list, ui_model_getvalue_f getvalue, int *count); void ui_listview_update(UiEvent *event, UiListView *view); void ui_list_selection_callback (Widget widget, UiListViewEventData *event, XtPointer data);
--- a/ui/motif/toolbar.c Wed Feb 11 11:34:55 2015 +0100 +++ b/ui/motif/toolbar.c Sat Feb 14 10:30:45 2015 +0100 @@ -34,6 +34,7 @@ #include "toolbar.h" #include "button.h" #include "stock.h" +#include "list.h" #include "../../ucx/mempool.h" #include "../common/context.h" @@ -145,6 +146,50 @@ ucx_map_cstr_put(toolbar_items, name, item); } +void ui_toolbar_combobox( + char *name, + UiList *list, + ui_model_getvalue_f getvalue, + ui_callback f, + void *udata) +{ + UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox)); + cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox; + cb->list = list; + cb->getvalue = getvalue; + cb->callback = f; + cb->userdata = udata; + + ucx_map_cstr_put(toolbar_items, name, cb); +} + +void ui_toolbar_combobox_str( + char *name, + UiList *list, + ui_callback f, + void *udata) +{ + ui_toolbar_combobox(name, list, ui_strmodel_getvalue, f, udata); +} + +void ui_toolbar_combobox_nv( + char *name, + char *listname, + ui_model_getvalue_f getvalue, + ui_callback f, + void *udata) +{ + UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV)); + cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox; + cb->listname = listname; + cb->getvalue = getvalue; + cb->callback = f; + cb->userdata = udata; + + ucx_map_cstr_put(toolbar_items, name, cb); +} + + void ui_toolbar_add_default(char *name) { char *s = strdup(name); defaults = ucx_list_append(defaults, s); @@ -287,3 +332,40 @@ void add_toolitem_st_toggle_widget(Widget parent, UiStToolItem *item, UiObject *obj) { } + +void add_toolbar_combobox(Widget tb, UiToolbarComboBox *item, UiObject *obj) { + UiListPtr *listptr = ucx_mempool_malloc( + obj->ctx->mempool, + sizeof(UiListPtr)); + UiListView *listview = ucx_mempool_malloc( + obj->ctx->mempool, + sizeof(UiListView)); + listptr->list = item->list; + + Arg args[8]; + XtSetArg(args[0], XmNshadowThickness, 1); + XtSetArg(args[1], XmNindicatorOn, XmINDICATOR_NONE); + XtSetArg(args[2], XmNtraversalOn, FALSE); + XtSetArg(args[3], XmNwidth, 120); + Widget combobox = XmCreateDropDownList(tb, "toolbar_combobox", args, 4); + XtManageChild(combobox); + listview->widget = combobox; + listview->list = listptr; + listview->getvalue = item->getvalue; + + ui_listview_update(NULL, listview); + + listptr->list->observers = ui_add_observer( + listptr->list->observers, + (ui_callback)ui_listview_update, + listview); + + if(item->callback) { + // TODO: + + } +} + +void add_toolbar_combobox_nv(Widget tb, UiToolbarComboBoxNV *item, UiObject *obj) { + +}
--- a/ui/motif/toolbar.h Wed Feb 11 11:34:55 2015 +0100 +++ b/ui/motif/toolbar.h Sat Feb 14 10:30:45 2015 +0100 @@ -41,6 +41,9 @@ typedef struct UiToolItem UiToolItem; typedef struct UiStToolItem UiStToolItem; +typedef struct UiToolbarComboBox UiToolbarComboBox; +typedef struct UiToolbarComboBoxNV UiToolbarComboBoxNV; + typedef void(*ui_toolbar_add_f)(Widget, UiToolItemI*, UiObject*); struct UiToolItemI { @@ -66,6 +69,22 @@ Boolean isimportant; }; +struct UiToolbarComboBox { + UiToolItemI item; + UiList *list; + ui_model_getvalue_f getvalue; + ui_callback callback; + void *userdata; +}; + +struct UiToolbarComboBoxNV { + UiToolItemI item; + char *listname; + ui_model_getvalue_f getvalue; + ui_callback callback; + void *userdata; +}; + void ui_toolbar_init(); Widget ui_create_toolbar(UiObject *obj, Widget parent); @@ -75,6 +94,9 @@ void add_toolitem_toggle_widget(Widget tb, UiToolItem *item, UiObject *obj); void add_toolitem_st_toggle_widget(Widget tb, UiStToolItem *item, UiObject *obj); +void add_toolbar_combobox(Widget tb, UiToolbarComboBox *item, UiObject *obj); +void add_toolbar_combobox_nv(Widget tb, UiToolbarComboBoxNV *item, UiObject *obj); + #ifdef __cplusplus } #endif