diff -r 458831c574f4 -r 0ec8a5f17782 ui/motif/toolbar.c --- a/ui/motif/toolbar.c Sat May 10 15:43:22 2014 +0200 +++ b/ui/motif/toolbar.c Sat May 10 18:52:22 2014 +0200 @@ -48,9 +48,11 @@ UiToolItem *item = malloc(sizeof(UiToolItem)); item->item.add_to = (ui_toolbar_add_f)add_toolitem_widget; item->label = label; + item->image = NULL; item->callback = f; item->userdata = userdata; item->groups = NULL; + item->isimportant = FALSE; ucx_map_cstr_put(toolbar_items, name, item); } @@ -66,6 +68,7 @@ item->callback = f; item->userdata = userdata; item->groups = NULL; + item->isimportant = FALSE; // add groups va_list ap; @@ -79,6 +82,69 @@ ucx_map_cstr_put(toolbar_items, name, item); } +void ui_toolitem_img(char *name, char *label, char *img, ui_callback f, void *udata) { + // TODO + + UiToolItem *item = malloc(sizeof(UiToolItem)); + item->item.add_to = (ui_toolbar_add_f)add_toolitem_widget; + item->label = label; + item->image = img; + item->callback = f; + item->userdata = udata; + item->groups = NULL; + item->isimportant = FALSE; + + ucx_map_cstr_put(toolbar_items, name, item); +} + + +void ui_toolitem_toggle_stgr(char *name, char *stockid, ui_callback f, void *udata, ...) { + // TODO + + UiStToolItem *item = malloc(sizeof(UiStToolItem)); + item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_toggle_widget; + item->stockid = stockid; + item->callback = f; + item->userdata = udata; + item->groups = NULL; + item->isimportant = FALSE; + + // add groups + va_list ap; + va_start(ap, udata); + int group; + while((group = va_arg(ap, int)) != -1) { + item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group); + } + va_end(ap); + + ucx_map_cstr_put(toolbar_items, name, item); +} + +void ui_toolitem_toggle_imggr(char *name, char *label, char *img, ui_callback f, void *udata, ...) { + // TODO + + UiToolItem *item = malloc(sizeof(UiToolItem)); + item->item.add_to = (ui_toolbar_add_f)add_toolitem_toggle_widget; + item->label = label; + item->image = img; + item->callback = f; + item->userdata = udata; + item->groups = NULL; + item->isimportant = FALSE; + + // add groups + va_list ap; + va_start(ap, udata); + int group; + while((group = va_arg(ap, int)) != -1) { + item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group); + } + va_end(ap); + + ucx_map_cstr_put(toolbar_items, name, item); +} + void ui_toolbar_add_default(char *name) { char *s = strdup(name); defaults = ucx_list_append(defaults, s); @@ -158,6 +224,7 @@ XmString label = XmStringCreateLocalized(stock_item->label); XtSetArg(args[0], XmNlabelString, label); XtSetArg(args[1], XmNshadowThickness, 1); + //XtSetArg(args[2], XmNhighlightThickness, 0); Widget button = XmCreatePushButton(parent, "toolbar_button", args, 2); XmStringFree(label); @@ -182,3 +249,39 @@ uic_add_group_widget(obj->ctx, button, item->groups); } } + +void add_toolitem_toggle_widget(Widget parent, UiToolItem *item, UiObject *obj) { + Arg args[8]; + + XmString label = XmStringCreateLocalized(item->label); + XtSetArg(args[0], XmNlabelString, label); + XtSetArg(args[1], XmNshadowThickness, 1); + XtSetArg(args[2], XmNindicatorOn, XmINDICATOR_NONE); + Widget button = XmCreateToggleButton(parent, "toolbar_toggle_button", args, 3); + + XmStringFree(label); + + if(item->callback) { + UiEventData *event = ucx_mempool_malloc( + obj->ctx->mempool, + sizeof(UiEventData)); + event->obj = obj; + event->user_data = item->userdata; + event->callback = item->callback; + XtAddCallback( + button, + XmNvalueChangedCallback, + (XtCallbackProc)ui_toggle_button_callback, + event); + } + + XtManageChild(button); + + if(item->groups) { + uic_add_group_widget(obj->ctx, button, item->groups); + } +} + +void add_toolitem_st_toggle_widget(Widget parent, UiStToolItem *item, UiObject *obj) { + +}