summaryrefslogtreecommitdiff
path: root/iup/src/mot/iupmot_tabs.c
diff options
context:
space:
mode:
Diffstat (limited to 'iup/src/mot/iupmot_tabs.c')
-rwxr-xr-xiup/src/mot/iupmot_tabs.c73
1 files changed, 33 insertions, 40 deletions
diff --git a/iup/src/mot/iupmot_tabs.c b/iup/src/mot/iupmot_tabs.c
index 7c8a6b5..cafc41d 100755
--- a/iup/src/mot/iupmot_tabs.c
+++ b/iup/src/mot/iupmot_tabs.c
@@ -52,8 +52,10 @@ void iupdrvTabsSetCurrentTab(Ihandle* ih, int pos)
{
Ihandle* child = IupGetChild(ih, pos);
Ihandle* prev_child = IupGetChild(ih, iupdrvTabsGetCurrentTab(ih));
- IupSetAttribute(child, "VISIBLE", "YES");
- IupSetAttribute(prev_child, "VISIBLE", "NO");
+ Widget child_manager = (Widget)iupAttribGet(child, "_IUPTAB_CONTAINER");
+ Widget prev_child_manager = (Widget)iupAttribGet(prev_child, "_IUPTAB_CONTAINER");
+ XtMapWidget(child_manager);
+ if (prev_child_manager) XtUnmapWidget(prev_child_manager);
XtVaSetValues(ih->handle, XmNcurrentPageNumber, pos, NULL);
}
@@ -200,7 +202,7 @@ static int motTabsSetTabTypeAttrib(Ihandle* ih, const char* value)
ih->data->type = ITABS_TOP;
if (ih->handle)
- motTabsUpdateTabType(ih);
+ motTabsUpdateTabType(ih); /* for this to work must be updated in map */
return 0;
}
@@ -313,8 +315,10 @@ void motTabsPageChangedCallback(Widget w, Ihandle* ih, XmNotebookCallbackStruct
IFnnn cb;
Ihandle* child = IupGetChild(ih, nptr->page_number);
Ihandle* prev_child = IupGetChild(ih, nptr->prev_page_number);
- IupSetAttribute(child, "VISIBLE", "YES");
- IupSetAttribute(prev_child, "VISIBLE", "NO");
+ Widget child_manager = (Widget)iupAttribGet(child, "_IUPTAB_CONTAINER");
+ Widget prev_child_manager = (Widget)iupAttribGet(prev_child, "_IUPTAB_CONTAINER");
+ XtMapWidget(child_manager);
+ if (prev_child_manager) XtUnmapWidget(prev_child_manager);
cb = (IFnnn)IupGetCallback(ih, "TABCHANGE_CB");
if (cb)
@@ -397,12 +401,12 @@ static void motTabsChildAddedMethod(Ihandle* ih, Ihandle* child)
/* Create tabs */
/* Label */
- iupmotSetArg(args, num_args, XmNlabelType, tabtitle? XmSTRING: XmPIXMAP);
- iupmotSetArg(args, num_args, XmNmarginHeight, 0);
- iupmotSetArg(args, num_args, XmNmarginWidth, 0);
+ iupMOT_SETARG(args, num_args, XmNlabelType, tabtitle? XmSTRING: XmPIXMAP);
+ iupMOT_SETARG(args, num_args, XmNmarginHeight, 0);
+ iupMOT_SETARG(args, num_args, XmNmarginWidth, 0);
/* Notebook Constraint */
- iupmotSetArg(args, num_args, XmNnotebookChildType, XmMAJOR_TAB);
- iupmotSetArg(args, num_args, XmNpageNumber, pos);
+ iupMOT_SETARG(args, num_args, XmNnotebookChildType, XmMAJOR_TAB);
+ iupMOT_SETARG(args, num_args, XmNpageNumber, pos);
tab_button = XtCreateManagedWidget("tab_button", xmPushButtonWidgetClass, ih->handle, args, num_args);
/* Disable Drag Source */
@@ -450,10 +454,8 @@ static void motTabsChildAddedMethod(Ihandle* ih, Ihandle* child)
iupAttribSetStr(child, "_IUPMOT_TABBUTTON", (char*)tab_button);
iupAttribSetInt(child, "_IUPMOT_TABNUMBER", pos);
- if (pos == iupdrvTabsGetCurrentTab(ih))
- IupSetAttribute(child, "VISIBLE", "YES");
- else
- IupSetAttribute(child, "VISIBLE", "NO");
+ if (pos != iupdrvTabsGetCurrentTab(ih))
+ XtUnmapWidget(child_manager);
}
}
@@ -464,20 +466,11 @@ static void motTabsChildRemovedMethod(Ihandle* ih, Ihandle* child)
Widget child_manager = (Widget)iupAttribGet(child, "_IUPTAB_CONTAINER");
if (child_manager)
{
- int cur_pos, pos;
+ int pos;
Widget tab_button = (Widget)iupAttribGet(child, "_IUPMOT_TABBUTTON");
- cur_pos = iupdrvTabsGetCurrentTab(ih);
pos = iupAttribGetInt(child, "_IUPMOT_TABNUMBER"); /* did not work when using XtVaGetValues(child_manager, XmNpageNumber) */
- if (cur_pos == pos)
- {
- if (cur_pos == 0)
- cur_pos = 1;
- else
- cur_pos--;
-
- iupdrvTabsSetCurrentTab(ih, cur_pos);
- }
+ iupTabsTestRemoveTab(ih, pos);
XtDestroyWidget(tab_button);
XtDestroyWidget(child_manager);
@@ -501,22 +494,22 @@ static int motTabsMapMethod(Ihandle* ih)
return IUP_ERROR;
/* Core */
- iupmotSetArg(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */
- iupmotSetArg(args, num_args, XmNx, 0); /* x-position */
- iupmotSetArg(args, num_args, XmNy, 0); /* y-position */
- iupmotSetArg(args, num_args, XmNwidth, 10); /* default width to avoid 0 */
- iupmotSetArg(args, num_args, XmNheight, 10); /* default height to avoid 0 */
+ iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */
+ iupMOT_SETARG(args, num_args, XmNx, 0); /* x-position */
+ iupMOT_SETARG(args, num_args, XmNy, 0); /* y-position */
+ iupMOT_SETARG(args, num_args, XmNwidth, 10); /* default width to avoid 0 */
+ iupMOT_SETARG(args, num_args, XmNheight, 10); /* default height to avoid 0 */
/* Manager */
- iupmotSetArg(args, num_args, XmNshadowThickness, 0);
- iupmotSetArg(args, num_args, XmNtraversalOn, True);
- iupmotSetArg(args, num_args, XmNhighlightThickness, 0);
+ iupMOT_SETARG(args, num_args, XmNshadowThickness, 0);
+ iupMOT_SETARG(args, num_args, XmNtraversalOn, True);
+ iupMOT_SETARG(args, num_args, XmNhighlightThickness, 0);
/* Notebook */
- iupmotSetArg(args, num_args, XmNbindingType, XmNONE);
- iupmotSetArg(args, num_args, XmNbindingWidth, 0);
- iupmotSetArg(args, num_args, XmNfirstPageNumber, 0); /* IupTabs index always starts with zero */
- iupmotSetArg(args, num_args, XmNbackPageSize, 0);
- iupmotSetArg(args, num_args, XmNbackPageNumber, 1);
- iupmotSetArg(args, num_args, XmNframeShadowThickness, 2);
+ iupMOT_SETARG(args, num_args, XmNbindingType, XmNONE);
+ iupMOT_SETARG(args, num_args, XmNbindingWidth, 0);
+ iupMOT_SETARG(args, num_args, XmNfirstPageNumber, 0); /* IupTabs index always starts with zero */
+ iupMOT_SETARG(args, num_args, XmNbackPageSize, 0);
+ iupMOT_SETARG(args, num_args, XmNbackPageNumber, 1);
+ iupMOT_SETARG(args, num_args, XmNframeShadowThickness, 2);
ih->handle = XtCreateManagedWidget(
iupDialogGetChildIdStr(ih), /* child identifier */
@@ -589,5 +582,5 @@ void iupdrvTabsInitClass(Iclass* ic)
iupClassRegisterAttribute(ic, "TABORIENTATION", iupTabsGetTabOrientationAttrib, NULL, IUPAF_SAMEASSYSTEM, "HORIZONTAL", IUPAF_READONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT); /* can not be set, always HORIZONTAL in Motif */
iupClassRegisterAttributeId(ic, "TABTITLE", NULL, motTabsSetTabTitleAttrib, IUPAF_NO_INHERIT);
iupClassRegisterAttributeId(ic, "TABIMAGE", NULL, motTabsSetTabImageAttrib, IUPAF_NO_INHERIT);
- iupClassRegisterAttribute(ic, "PADDING", iupTabsGetPaddingAttrib, motTabsSetPaddingAttrib, IUPAF_SAMEASSYSTEM, "0x0", IUPAF_NOT_MAPPED);
+ iupClassRegisterAttribute(ic, "PADDING", iupTabsGetPaddingAttrib, motTabsSetPaddingAttrib, IUPAF_SAMEASSYSTEM, "0x0", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
}