static int motTextMapMethod(Ihandle* ih) { int num_args = 0; Arg args[30]; Widget parent = iupChildTreeGetNativeParentHandle(ih); char* child_id = iupDialogGetChildIdStr(ih); int spin = 0; WidgetClass widget_class = xmTextWidgetClass; if (ih->data->is_multiline) { Widget sb_win; int wordwrap = 0; if (iupAttribGetBoolean(ih, "WORDWRAP")) { wordwrap = 1; ih->data->sb &= ~IUP_SB_HORIZ; /* must remove the horizontal scroolbar */ } /******************************/ /* Create the scrolled window */ /******************************/ iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */ iupMOT_SETARG(args, num_args, XmNscrollingPolicy, XmAPPLICATION_DEFINED); iupMOT_SETARG(args, num_args, XmNvisualPolicy, XmVARIABLE); iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC); /* can NOT be XmAS_NEEDED because XmAPPLICATION_DEFINED */ iupMOT_SETARG(args, num_args, XmNspacing, 0); /* no space between scrollbars and text */ iupMOT_SETARG(args, num_args, XmNborderWidth, 0); iupMOT_SETARG(args, num_args, XmNshadowThickness, 0); sb_win = XtCreateManagedWidget( child_id, /* child identifier */ xmScrolledWindowWidgetClass, /* widget class */ parent, /* widget parent */ args, num_args); if (!sb_win) return IUP_ERROR; parent = sb_win; child_id = "text"; num_args = 0; iupMOT_SETARG(args, num_args, XmNeditMode, XmMULTI_LINE_EDIT); if (wordwrap) iupMOT_SETARG(args, num_args, XmNwordWrap, True); } else { widget_class = xmTextFieldWidgetClass; if (iupAttribGetBoolean(ih, "SPIN")) { Widget spinbox; num_args = 0; iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */ iupMOT_SETARG(args, num_args, XmNspacing, 0); /* no space between spin and text */ iupMOT_SETARG(args, num_args, XmNborderWidth, 0); iupMOT_SETARG(args, num_args, XmNshadowThickness, 0); iupMOT_SETARG(args, num_args, XmNmarginHeight, 0); iupMOT_SETARG(args, num_args, XmNmarginWidth, 0); iupMOT_SETARG(args, num_args, XmNarrowSize, 8); if (iupStrEqualNoCase(iupAttribGetStr(ih, "SPINALIGN"), "LEFT")) iupMOT_SETARG(args, num_args, XmNarrowLayout, XmARROWS_BEGINNING); else iupMOT_SETARG(args, num_args, XmNarrowLayout, XmARROWS_END); spinbox = XtCreateManagedWidget( child_id, /* child identifier */ xmSpinBoxWidgetClass, /* widget class */ parent, /* widget parent */ args, num_args); if (!spinbox) return IUP_ERROR; XtAddCallback(spinbox, XmNmodifyVerifyCallback, (XtCallbackProc)motTextSpinModifyVerifyCallback, (XtPointer)ih); parent = spinbox; child_id = "text"; spin = 1; if (!iupAttribGetBoolean(ih, "SPINAUTO")) iupAttribSet(ih, "_IUPMOT_SPIN_NOAUTO", "1"); } num_args = 0; iupMOT_SETARG(args, num_args, XmNeditMode, XmSINGLE_LINE_EDIT); if (spin) { /* Spin Constraints */ iupMOT_SETARG(args, num_args, XmNspinBoxChildType, XmNUMERIC); iupMOT_SETARG(args, num_args, XmNminimumValue, 0); iupMOT_SETARG(args, num_args, XmNmaximumValue, 100); iupMOT_SETARG(args, num_args, XmNposition, 0); if (iupAttribGetBoolean(ih, "SPINWRAP")) iupMOT_SETARG(args, num_args, XmNwrap, TRUE); else iupMOT_SETARG(args, num_args, XmNwrap, FALSE); } else { 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 */ iupMOT_SETARG(args, num_args, XmNmarginHeight, 0); /* default padding */ iupMOT_SETARG(args, num_args, XmNmarginWidth, 0); if (iupAttribGetBoolean(ih, "CANFOCUS")) iupMOT_SETARG(args, num_args, XmNtraversalOn, True); else iupMOT_SETARG(args, num_args, XmNtraversalOn, False); iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP); iupMOT_SETARG(args, num_args, XmNhighlightThickness, 2); iupMOT_SETARG(args, num_args, XmNverifyBell, False); iupMOT_SETARG(args, num_args, XmNspacing, 0); if (iupAttribGetBoolean(ih, "BORDER")) iupMOT_SETARG(args, num_args, XmNshadowThickness, 2); else iupMOT_SETARG(args, num_args, XmNshadowThickness, 0); if (ih->data->is_multiline) { if (ih->data->sb & IUP_SB_HORIZ) iupMOT_SETARG(args, num_args, XmNscrollHorizontal, True); else iupMOT_SETARG(args, num_args, XmNscrollHorizontal, False); if (ih->data->sb & IUP_SB_VERT) iupMOT_SETARG(args, num_args, XmNscrollVertical, True); else iupMOT_SETARG(args, num_args, XmNscrollVertical, False); } ih->handle = XtCreateManagedWidget( child_id, /* child identifier */ widget_class, /* widget class */ parent, /* widget parent */ args, num_args); if (!ih->handle) return IUP_ERROR; ih->serial = iupDialogGetChildId(ih); /* must be after using the string */ if (ih->data->is_multiline) { iupAttribSet(ih, "_IUP_EXTRAPARENT", (char*)parent); XtVaSetValues(parent, XmNworkWindow, ih->handle, NULL); } else if (spin) iupAttribSet(ih, "_IUP_EXTRAPARENT", (char*)parent); XtAddCallback(ih->handle, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih); XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, KeyPressMask, False, (XtEventHandler)motTextKeyPressEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, PointerMotionMask, False, (XtEventHandler)iupmotPointerMotionEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)iupmotButtonPressReleaseEvent, (XtPointer)ih); XtAddCallback(ih->handle, XmNmodifyVerifyCallback, (XtCallbackProc)motTextModifyVerifyCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNmotionVerifyCallback, (XtCallbackProc)motTextMotionVerifyCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNvalueChangedCallback, (XtCallbackProc)motTextValueChangedCallback, (XtPointer)ih); /* initialize the widget */ if (ih->data->is_multiline || spin) XtRealizeWidget(parent); else XtRealizeWidget(ih->handle); if (IupGetGlobal("_IUP_RESET_TXTCOLORS")) { iupmotSetGlobalColorAttrib(ih->handle, XmNbackground, "TXTBGCOLOR"); iupmotSetGlobalColorAttrib(ih->handle, XmNforeground, "TXTFGCOLOR"); IupSetGlobal("_IUP_RESET_TXTCOLORS", NULL); } IupSetCallback(ih, "_IUP_XY2POS_CB", (Icallback)motTextConvertXYToPos); return IUP_NOERROR; }
static int motTabsMapMethod(Ihandle* ih) { int num_args = 0; Arg args[30]; if (!ih->parent) 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 */ /* Manager */ iupmotSetArg(args, num_args, XmNshadowThickness, 0); iupmotSetArg(args, num_args, XmNtraversalOn, True); iupmotSetArg(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); ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmNotebookWidgetClass, /* widget class */ iupChildTreeGetNativeParentHandle(ih), /* widget parent */ args, num_args); if (!ih->handle) return IUP_ERROR; ih->serial = iupDialogGetChildId(ih); /* must be after using the string */ /* Disable page scroller */ { Widget scroller; scroller = XtNameToWidget(ih->handle, "*PageScroller"); XtUnmanageChild(scroller); } /* Callbacks */ XtAddCallback(ih->handle, XmNpageChangedCallback, (XtCallbackProc)motTabsPageChangedCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih); /* update Tab position */ motTabsUpdateTabType(ih); /* current value is now given by the native system */ iupAttribSetStr(ih, "_IUPTABS_VALUE_HANDLE", NULL); /* initialize the widget */ XtRealizeWidget(ih->handle); /* Create pages and tabs */ if (ih->firstchild) { Ihandle* child; for (child = ih->firstchild; child; child = child->brother) motTabsChildAddedMethod(ih, child); } return IUP_NOERROR; }
static int motToggleMapMethod(Ihandle* ih) { Ihandle* radio = iupRadioFindToggleParent(ih); char* value; int num_args = 0; Arg args[40]; if (radio) ih->data->is_radio = 1; value = iupAttribGet(ih, "IMAGE"); if (value) { ih->data->type = IUP_TOGGLE_IMAGE; iupMOT_SETARG(args, num_args, XmNlabelType, XmPIXMAP); } else { ih->data->type = IUP_TOGGLE_TEXT; iupMOT_SETARG(args, num_args, XmNlabelType, XmSTRING); } /* Core */ 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 */ /* Primitive */ if (iupAttribGetBoolean(ih, "CANFOCUS")) iupMOT_SETARG(args, num_args, XmNtraversalOn, True); else iupMOT_SETARG(args, num_args, XmNtraversalOn, False); iupMOT_SETARG(args, num_args, XmNhighlightThickness, 2); iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP); /* Label */ iupMOT_SETARG(args, num_args, XmNrecomputeSize, False); /* no automatic resize from text */ iupMOT_SETARG(args, num_args, XmNmarginHeight, 0); /* default padding */ iupMOT_SETARG(args, num_args, XmNmarginWidth, 0); iupMOT_SETARG(args, num_args, XmNmarginTop, 0); /* no extra margins */ iupMOT_SETARG(args, num_args, XmNmarginLeft, 0); iupMOT_SETARG(args, num_args, XmNmarginBottom, 0); iupMOT_SETARG(args, num_args, XmNmarginRight, 0); if (ih->data->is_radio) { iupMOT_SETARG(args, num_args, XmNtoggleMode, XmTOGGLE_BOOLEAN); iupMOT_SETARG(args, num_args, XmNindicatorType, XmONE_OF_MANY_ROUND); if (!iupAttribGet(radio, "_IUPMOT_LASTTOGGLE")) { /* this is the first toggle in the radio, and the last toggle with VALUE=ON */ iupAttribSet(ih, "VALUE","ON"); } /* make sure it has at least one name */ if (!iupAttribGetHandleName(ih)) iupAttribSetHandleName(ih); } else { if (ih->data->type == IUP_TOGGLE_TEXT && iupAttribGetBoolean(ih, "3STATE")) iupMOT_SETARG(args, num_args, XmNtoggleMode, XmTOGGLE_INDETERMINATE); else iupMOT_SETARG(args, num_args, XmNtoggleMode, XmTOGGLE_BOOLEAN); iupMOT_SETARG(args, num_args, XmNindicatorType, XmN_OF_MANY); } if (ih->data->type == IUP_TOGGLE_IMAGE) { iupMOT_SETARG(args, num_args, XmNindicatorOn, XmINDICATOR_NONE); iupMOT_SETARG(args, num_args, XmNalignment, XmALIGNMENT_CENTER); iupMOT_SETARG(args, num_args, XmNshadowThickness, 2); } else { iupMOT_SETARG(args, num_args, XmNspacing, 3); iupMOT_SETARG(args, num_args, XmNindicatorOn, XmINDICATOR_CHECK_BOX); iupMOT_SETARG(args, num_args, XmNalignment, XmALIGNMENT_BEGINNING); if (ih->data->is_radio) { iupMOT_SETARG(args, num_args, XmNindicatorSize, 13); iupMOT_SETARG(args, num_args, XmNselectColor, iupmotColorGetPixel(0, 0, 0)); } else iupMOT_SETARG(args, num_args, XmNindicatorSize, 15); iupMOT_SETARG(args, num_args, XmNshadowThickness, 0); iupMOT_SETARG(args, num_args, XmNdetailShadowThickness, 2); } ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmToggleButtonWidgetClass, /* widget class */ iupChildTreeGetNativeParentHandle(ih), /* widget parent */ args, num_args); if (!ih->handle) return IUP_ERROR; ih->serial = iupDialogGetChildId(ih); /* must be after using the string */ XtAddCallback(ih->handle, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih); if (ih->data->type == IUP_TOGGLE_IMAGE && ih->data->flat) { XtVaSetValues(ih->handle, XmNshadowThickness, 0, NULL); XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)motToggleEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)motToggleEnterLeaveWindowEvent, (XtPointer)ih); } else { XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); } XtAddEventHandler(ih->handle, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, KeyPressMask, False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih); XtAddCallback(ih->handle, XmNvalueChangedCallback, (XtCallbackProc)motToggleValueChangedCallback, (XtPointer)ih); if (iupStrBoolean(IupGetGlobal("INPUTCALLBACKS"))) XtAddEventHandler(ih->handle, PointerMotionMask, False, (XtEventHandler)iupmotDummyPointerMotionEvent, NULL); /* Disable Drag Source */ iupmotDisableDragSource(ih->handle); /* initialize the widget */ XtRealizeWidget(ih->handle); if (ih->data->type == IUP_TOGGLE_TEXT) iupmotSetXmString(ih->handle, XmNlabelString, ""); return IUP_NOERROR; }