diff -r 25e5390cce41 -r 62205699cd0e ui/motif/container.c --- a/ui/motif/container.c Tue Jul 22 09:51:17 2014 +0200 +++ b/ui/motif/container.c Tue Jul 22 19:15:44 2014 +0200 @@ -98,7 +98,7 @@ XtSetArg(args[3], XmNleftAttachment, XmATTACH_FORM); XtSetArg(args[4], XmNrightAttachment, XmATTACH_FORM); XtSetArg(args[5], XmNtopAttachment, XmATTACH_FORM); - Widget tabbar = XmCreateRowColumn(tabview, "toolbar", args, 6); + Widget tabbar = XmCreateForm(tabview, "toolbar", args, 6); XtManageChild(tabbar); XtSetArg(args[0], XmNleftAttachment, XmATTACH_FORM); @@ -155,34 +155,88 @@ content->container = ui_frame_container(content, frame); content->next = NULL; - // add tab button + // add tab button + v->tabs = ucx_list_append_a(view->ctx->mempool->allocator, v->tabs, tab); + XmString label = XmStringCreateLocalized("tab"); XtSetArg(args[0], XmNlabelString, label); XtSetArg(args[1], XmNshadowThickness, 1); XtSetArg(args[2], XmNtraversalOn, FALSE); - Widget button = XmCreatePushButton(v->tabbar, "tab_button", args, 3); - XtManageChild(button); - XtAddCallback( - button, - XmNactivateCallback, - (XtCallbackProc)ui_tab_button_callback, - tab); + XtSetArg(args[3], XmNtopAttachment, XmATTACH_FORM); + XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM); + XtSetArg(args[5], XmNhighlightThickness, 0); + XtSetArg(args[6], XmNindicatorOn, XmINDICATOR_NONE); + Widget button = XmCreateToggleButton(v->tabbar, "tab_button", args, 7); tab->tabbedpane = v; tab->content = content; tab->tab_button = button; - v->tabs = ucx_list_append_a(view->ctx->mempool->allocator, v->tabs, tab); + // layout + int is_first = 1; + size_t count = ucx_list_size(v->tabs); + int part = 100 / count; + int pos = 0; + int i = 0; + UCX_FOREACH(elm, v->tabs) { + UiTab *tt = elm->data; + if(is_first) { + XtVaSetValues( + tt->tab_button, + XmNleftAttachment, + XmATTACH_FORM, + XmNrightAttachment, + XmATTACH_POSITION, + XmNrightPosition, + pos + part, + NULL); + is_first = FALSE; + } else if(i < count - 1) { + XtVaSetValues( + tt->tab_button, + XmNleftAttachment, + XmATTACH_POSITION, + XmNleftPosition, + pos, + XmNrightAttachment, + XmATTACH_POSITION, + XmNrightPosition, + pos + part, + NULL); + } else { + XtVaSetValues( + tt->tab_button, + XmNleftAttachment, + XmATTACH_POSITION, + XmNleftPosition, + pos, + XmNrightAttachment, + XmATTACH_FORM, + NULL); + } + pos += part; + i++; + } + + + XtManageChild(button); + XtAddCallback( + button, + XmNvalueChangedCallback, + (XtCallbackProc)ui_tab_button_callback, + tab); + v->current = tab; ui_change_tab(v, tab); return content; } -void ui_tab_button_callback(Widget widget, UiTab *tab, XtPointer d) { +void ui_tab_button_callback(Widget widget, UiTab *tab, XtPointer d) { MotifTabbedPane *t = tab->tabbedpane; if(t->current) { XtUnmanageChild(t->current->content->widget); + XtVaSetValues(t->current->tab_button, XmNset, 0, NULL); } XtManageChild(tab->content->widget);