static int motProgressBarMapMethod(Ihandle* ih) { int num_args = 0; Arg args[30]; /* 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 */ /* Primitive */ iupmotSetArg(args, num_args, XmNtraversalOn, False); iupmotSetArg(args, num_args, XmNhighlightThickness, 0); /* Scale */ iupmotSetArg(args, num_args, XmNminimum, 0); iupmotSetArg(args, num_args, XmNmaximum, SHRT_MAX); iupmotSetArg(args, num_args, XmNslidingMode, XmTHERMOMETER); /* thermometer effect */ iupmotSetArg(args, num_args, XmNsliderMark, XmNONE); iupmotSetArg(args, num_args, XmNeditable, False); iupmotSetArg(args, num_args, XmNshowValue, XmNONE); if (iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "VERTICAL")) { iupmotSetArg(args, num_args, XmNorientation, XmVERTICAL); if (ih->currentheight < ih->currentwidth) { int tmp = ih->currentheight; ih->currentheight = ih->currentwidth; ih->currentwidth = tmp; } } else iupmotSetArg(args, num_args, XmNorientation, XmHORIZONTAL); ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmScaleWidgetClass, /* 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 */ /* initialize the widget */ XtRealizeWidget(ih->handle); return IUP_NOERROR; }
int iupwinCreateWindow(Ihandle* ih, LPCTSTR lpClassName, DWORD dwExStyle, DWORD dwStyle, void* clientdata) { ih->serial = iupDialogGetChildId(ih); ih->handle = iupwinCreateWindowEx(iupChildTreeGetNativeParentHandle(ih), lpClassName, dwExStyle, dwStyle, ih->serial, clientdata); if (!ih->handle) return 0; /* associate HWND with Ihandle*, all Win32 controls must call this. */ iupwinHandleAdd(ih, ih->handle); /* replace the WinProc to handle base callbacks */ iupwinChangeWndProc(ih, iupwinBaseWndProc); return 1; }
int iupMenuGetChildId(Ihandle* ih) { Ihandle* dlg = IupGetDialog(ih); if (dlg) return iupDialogGetChildId(ih); else { int id; ih = iMenuGetTopMenu(ih); if (!ih) return -1; id = ih->data->child_id; if (id == 0) id = 100; /* initial number */ ih->data->child_id = id+1; return id; } }
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 */ /******************************/ iupmotSetArg(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */ iupmotSetArg(args, num_args, XmNscrollingPolicy, XmAPPLICATION_DEFINED); iupmotSetArg(args, num_args, XmNvisualPolicy, XmVARIABLE); iupmotSetArg(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC); /* can NOT be XmAS_NEEDED because XmAPPLICATION_DEFINED */ iupmotSetArg(args, num_args, XmNspacing, 0); /* no space between scrollbars and text */ iupmotSetArg(args, num_args, XmNborderWidth, 0); iupmotSetArg(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; iupmotSetArg(args, num_args, XmNeditMode, XmMULTI_LINE_EDIT); if (wordwrap) iupmotSetArg(args, num_args, XmNwordWrap, True); } else { widget_class = xmTextFieldWidgetClass; if (iupAttribGetBoolean(ih, "SPIN")) { Widget spinbox; num_args = 0; iupmotSetArg(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */ iupmotSetArg(args, num_args, XmNspacing, 0); /* no space between spin and text */ iupmotSetArg(args, num_args, XmNborderWidth, 0); iupmotSetArg(args, num_args, XmNshadowThickness, 0); iupmotSetArg(args, num_args, XmNmarginHeight, 0); iupmotSetArg(args, num_args, XmNmarginWidth, 0); iupmotSetArg(args, num_args, XmNarrowSize, 8); if (iupStrEqualNoCase(iupAttribGetStr(ih, "SPINALIGN"), "LEFT")) iupmotSetArg(args, num_args, XmNarrowLayout, XmARROWS_BEGINNING); else iupmotSetArg(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")) iupAttribSetStr(ih, "_IUPMOT_SPIN_NOAUTO", "1"); } num_args = 0; iupmotSetArg(args, num_args, XmNeditMode, XmSINGLE_LINE_EDIT); if (spin) { /* Spin Constraints */ iupmotSetArg(args, num_args, XmNspinBoxChildType, XmNUMERIC); iupmotSetArg(args, num_args, XmNminimumValue, 0); iupmotSetArg(args, num_args, XmNmaximumValue, 100); iupmotSetArg(args, num_args, XmNposition, 0); if (iupAttribGetBoolean(ih, "SPINWRAP")) iupmotSetArg(args, num_args, XmNwrap, TRUE); else iupmotSetArg(args, num_args, XmNwrap, FALSE); } else { 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 */ iupmotSetArg(args, num_args, XmNmarginHeight, 0); /* default padding */ iupmotSetArg(args, num_args, XmNmarginWidth, 0); if (iupAttribGetBoolean(ih, "CANFOCUS")) iupmotSetArg(args, num_args, XmNtraversalOn, True); else iupmotSetArg(args, num_args, XmNtraversalOn, False); iupmotSetArg(args, num_args, XmNnavigationType, XmTAB_GROUP); iupmotSetArg(args, num_args, XmNhighlightThickness, 2); iupmotSetArg(args, num_args, XmNverifyBell, False); iupmotSetArg(args, num_args, XmNspacing, 0); if (iupAttribGetBoolean(ih, "BORDER")) iupmotSetArg(args, num_args, XmNshadowThickness, 2); else iupmotSetArg(args, num_args, XmNshadowThickness, 0); if (ih->data->is_multiline) { if (ih->data->sb & IUP_SB_HORIZ) iupmotSetArg(args, num_args, XmNscrollHorizontal, True); else iupmotSetArg(args, num_args, XmNscrollHorizontal, False); if (ih->data->sb & IUP_SB_VERT) iupmotSetArg(args, num_args, XmNscrollVertical, True); else iupmotSetArg(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) { iupAttribSetStr(ih, "_IUP_EXTRAPARENT", (char*)parent); XtVaSetValues(parent, XmNworkWindow, ih->handle, NULL); } else if (spin) iupAttribSetStr(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); /* Disable Drag Source */ iupmotDisableDragSource(ih->handle); /* 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 motFrameMapMethod(Ihandle* ih) { char *title; int num_args = 0; Arg args[20]; Widget child_manager; if (!ih->parent) return IUP_ERROR; title = iupAttribGet(ih, "TITLE"); if (title) iupAttribSetStr(ih, "_IUPFRAME_HAS_TITLE", "1"); else { char* value = iupAttribGetStr(ih, "SUNKEN"); if (iupStrBoolean(value)) iupMOT_SETARG(args, num_args, XmNshadowType, XmSHADOW_IN); else iupMOT_SETARG(args, num_args, XmNshadowType, XmSHADOW_ETCHED_IN); if (iupAttribGet(ih, "BGCOLOR")) iupAttribSetStr(ih, "_IUPFRAME_HAS_BGCOLOR", "1"); } /* 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 */ /* Manager */ iupMOT_SETARG(args, num_args, XmNshadowThickness, 2); /* Frame */ iupMOT_SETARG(args, num_args, XmNmarginHeight, 0); /* no shadow margins */ iupMOT_SETARG(args, num_args, XmNmarginWidth, 0); /* no shadow margins */ ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmFrameWidgetClass, /* 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 */ if (title) { Widget title_label; num_args = 0; /* Label */ iupMOT_SETARG(args, num_args, XmNlabelType, XmSTRING); iupMOT_SETARG(args, num_args, XmNmarginHeight, 0); /* default padding */ iupMOT_SETARG(args, num_args, XmNmarginWidth, 0); /* Frame Constraint */ iupMOT_SETARG(args, num_args, XmNchildType, XmFRAME_TITLE_CHILD); title_label = XtCreateManagedWidget("title_label", xmLabelWidgetClass, ih->handle, args, num_args); iupmotSetString(title_label, XmNlabelString, title); iupAttribSetStr(ih, "_IUPMOT_FRAMELABEL", (char*)title_label); } child_manager = XtVaCreateManagedWidget( "child_manager", xmBulletinBoardWidgetClass, ih->handle, /* Core */ XmNborderWidth, 0, /* Manager */ XmNshadowThickness, 0, XmNnavigationType, XmTAB_GROUP, /* BulletinBoard */ XmNmarginWidth, 0, XmNmarginHeight, 0, XmNresizePolicy, XmRESIZE_NONE, /* no automatic resize of children */ /* Frame Constraint */ XmNchildType, XmFRAME_WORKAREA_CHILD, NULL); iupAttribSetStr(ih, "_IUPMOT_FRAMECONTAINER", (char*)child_manager); if (iupStrBoolean(IupGetGlobal("INPUTCALLBACKS"))) XtAddEventHandler(child_manager, PointerMotionMask, False, (XtEventHandler)iupmotDummyPointerMotionEvent, NULL); /* initialize the widget */ XtRealizeWidget(ih->handle); 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); /* 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 motProgressBarMapMethod(Ihandle* ih) { int num_args = 0; Arg args[30]; /* 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 */ iupMOT_SETARG(args, num_args, XmNtraversalOn, False); iupMOT_SETARG(args, num_args, XmNhighlightThickness, 0); /* Scale */ iupMOT_SETARG(args, num_args, XmNminimum, 0); iupMOT_SETARG(args, num_args, XmNmaximum, SHRT_MAX); iupMOT_SETARG(args, num_args, XmNsliderMark, XmNONE); iupMOT_SETARG(args, num_args, XmNsliderVisual, XmTROUGH_COLOR); iupMOT_SETARG(args, num_args, XmNeditable, False); iupMOT_SETARG(args, num_args, XmNshowValue, XmNONE); if (iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "VERTICAL")) { iupMOT_SETARG(args, num_args, XmNorientation, XmVERTICAL); if (ih->currentheight < ih->currentwidth) { int tmp = ih->currentheight; ih->currentheight = ih->currentwidth; ih->currentwidth = tmp; } } else iupMOT_SETARG(args, num_args, XmNorientation, XmHORIZONTAL); if (iupAttribGetBoolean(ih, "MARQUEE")) { ih->data->marquee = 1; ih->data->timer = IupTimer(); IupSetCallback(ih->data->timer, "ACTION_CB", (Icallback)motProgressBarTimeCb); IupSetAttribute(ih->data->timer, "TIME", "100"); iupAttribSet(ih->data->timer, "_IUP_PROGRESSBAR", (char*)ih); iupMOT_SETARG(args, num_args, XmNslidingMode, XmSLIDER); } else { iupMOT_SETARG(args, num_args, XmNslidingMode, XmTHERMOMETER); ih->data->marquee = 0; } ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmScaleWidgetClass, /* 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 */ XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); /* initialize the widget */ XtRealizeWidget(ih->handle); return IUP_NOERROR; }
static int winCanvasMapMethod(Ihandle* ih) { CLIENTCREATESTRUCT clientstruct; void *clientdata = NULL; char *classname; DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS, dwExStyle = 0; if (!ih->parent) return IUP_ERROR; if (ih->iclass->is_interactive) { if (iupAttribGetBoolean(ih, "CANFOCUS")) dwStyle |= WS_TABSTOP; } if (ih->firstchild) /* can be a container */ iupwinGetNativeParentStyle(ih, &dwExStyle, &dwStyle); if (iupAttribGetBoolean(ih, "BORDER")) dwStyle |= WS_BORDER; ih->data->sb = iupBaseGetScrollbar(ih); if (ih->data->sb & IUP_SB_HORIZ) dwStyle |= WS_HSCROLL; if (ih->data->sb & IUP_SB_VERT) dwStyle |= WS_VSCROLL; if (iupAttribGetBoolean(ih, "MDICLIENT")) { /* creating a MDI Client that will be inside the MDI Frame, it will work as parent of all MDI children */ Ihandle *winmenu = IupGetAttributeHandle(ih, "MDIMENU"); classname = "mdiclient"; dwStyle = WS_CHILD|WS_CLIPCHILDREN|WS_VSCROLL|WS_HSCROLL|MDIS_ALLCHILDSTYLES; dwExStyle = WS_EX_CLIENTEDGE; iupAttribSetStr(ih, "BORDER", "NO"); iupAttribSetStr(IupGetDialog(ih), "MDICLIENT_HANDLE", (char*)ih); clientdata = &clientstruct; clientstruct.hWindowMenu = winmenu? winmenu->handle: NULL; /* The system increments the identifier for each additional MDI child window the application creates, and reassigns identifiers when the application destroys a window to keep the range of identifiers contiguous. */ clientstruct.idFirstChild = IUP_MDI_FIRSTCHILD; } else classname = "IupCanvas"; ih->serial = iupDialogGetChildId(ih); ih->handle = CreateWindowEx(dwExStyle,/* extended style */ classname, /* window class */ NULL, /* title */ dwStyle, /* window style */ 0, /* x-position */ 0, /* y-position */ 10, /* default width to avoid 0 */ 10, /* default height to avoid 0 */ iupChildTreeGetNativeParentHandle(ih), /* window parent */ (HMENU)ih->serial, /* child identifier */ iupwin_hinstance, /* instance of app. */ clientdata); if (!ih->handle) return IUP_ERROR; /* associate HWND with Ihandle*, all Win32 controls must call this. */ iupwinHandleAdd(ih, ih->handle); if (iupAttribGetBoolean(ih, "MDICLIENT")) iupwinChangeProc(ih, iupwinBaseWinProc); else IupSetCallback(ih, "_IUPWIN_OLDPROC_CB", (Icallback)DefWindowProc); IupSetCallback(ih, "_IUPWIN_CTRLPROC_CB", (Icallback)winCanvasProc); /* configure for DROP of files */ if (IupGetCallback(ih, "DROPFILES_CB")) iupAttribSetStr(ih, "DROPFILESTARGET", "YES"); return IUP_NOERROR; }
static int motListMapMethod(Ihandle* ih) { int num_args = 0; Arg args[30]; Widget parent = iupChildTreeGetNativeParentHandle(ih); char* child_id = iupDialogGetChildIdStr(ih); if (ih->data->is_dropdown || ih->data->has_editbox) { /* could not set XmNmappedWhenManaged to False because the list and the edit box where not displayed */ /* iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); */ 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); 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, XmNshadowThickness, 2); if (ih->data->has_editbox) { if (ih->data->is_dropdown) iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX); /* hidden-list+edit */ else iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmCOMBO_BOX); /* visible-list+edit */ } else iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmDROP_DOWN_LIST); /* hidden-list */ /* XmComboBoxWidget inherits from XmManager, so it is a container with the actual list inside */ ih->handle = XtCreateManagedWidget( child_id, /* child identifier */ xmComboBoxWidgetClass, /* widget class */ parent, /* widget parent */ args, num_args); } else { Widget sb_win; /* 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 = "list"; /* Create the list */ num_args = 0; 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 */ 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, XmNshadowThickness, 2); iupMOT_SETARG(args, num_args, XmNlistMarginHeight, 0); /* default padding */ iupMOT_SETARG(args, num_args, XmNlistMarginWidth, 0); iupMOT_SETARG(args, num_args, XmNlistSpacing, 0); iupMOT_SETARG(args, num_args, XmNlistSizePolicy, XmCONSTANT); /* don't grow to fit, add scrollbar */ if (ih->data->is_multiple) iupMOT_SETARG(args, num_args, XmNselectionPolicy, XmEXTENDED_SELECT); else iupMOT_SETARG(args, num_args, XmNselectionPolicy, XmBROWSE_SELECT); if (iupAttribGetBoolean(ih, "AUTOHIDE")) iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmAS_NEEDED); else iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC); ih->handle = XtCreateManagedWidget( child_id, /* child identifier */ xmListWidgetClass, /* 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_dropdown || ih->data->has_editbox) { Widget cbedit, cblist; XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL); XtVaGetValues(ih->handle, XmNlist, &cblist, NULL); XtAddEventHandler(cbedit, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih); XtAddEventHandler(cbedit, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(cbedit, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddCallback(cbedit, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih); if (iupStrBoolean(IupGetGlobal("INPUTCALLBACKS"))) XtAddEventHandler(cbedit, PointerMotionMask, False, (XtEventHandler)iupmotDummyPointerMotionEvent, NULL); if (ih->data->has_editbox) { XtAddEventHandler(cbedit, KeyPressMask, False, (XtEventHandler)motListEditKeyPressEvent, (XtPointer)ih); XtAddCallback(cbedit, XmNmodifyVerifyCallback, (XtCallbackProc)motListEditModifyVerifyCallback, (XtPointer)ih); XtAddCallback(cbedit, XmNmotionVerifyCallback, (XtCallbackProc)motListEditMotionVerifyCallback, (XtPointer)ih); XtAddCallback(cbedit, XmNvalueChangedCallback, (XtCallbackProc)motListEditValueChangedCallback, (XtPointer)ih); iupAttribSet(ih, "_IUPMOT_DND_WIDGET", (char*)cbedit); } else XtAddEventHandler(cbedit, KeyPressMask, False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih); if (ih->data->is_dropdown) { XtVaSetValues(ih->handle, XmNvisibleItemCount, 5, NULL); XtAddCallback(XtParent(XtParent(cblist)), XmNpopupCallback, (XtCallbackProc)motListDropDownPopupCallback, (XtPointer)ih); XtAddCallback(XtParent(XtParent(cblist)), XmNpopdownCallback, (XtCallbackProc)motListDropDownPopdownCallback, (XtPointer)ih); } else { XtAddCallback(cblist, XmNdefaultActionCallback, (XtCallbackProc)motListDefaultActionCallback, (XtPointer)ih); XtAddEventHandler(cblist, PointerMotionMask, False, (XtEventHandler)iupmotPointerMotionEvent, (XtPointer)ih); XtAddEventHandler(cblist, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)iupmotButtonPressReleaseEvent, (XtPointer)ih); /* Disable Drag Source */ iupmotDisableDragSource(cblist); } } else { iupAttribSet(ih, "_IUP_EXTRAPARENT", (char*)parent); XtVaSetValues(parent, XmNworkWindow, ih->handle, NULL); XtAddEventHandler(ih->handle, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, KeyPressMask, False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, PointerMotionMask, False, (XtEventHandler)iupmotPointerMotionEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)iupmotButtonPressReleaseEvent, (XtPointer)ih); XtAddCallback(ih->handle, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih); XtAddCallback (ih->handle, XmNbrowseSelectionCallback, (XtCallbackProc)motListBrowseSelectionCallback, (XtPointer)ih); XtAddCallback (ih->handle, XmNextendedSelectionCallback, (XtCallbackProc)motListExtendedSelectionCallback, (XtPointer)ih); XtAddCallback (ih->handle, XmNdefaultActionCallback, (XtCallbackProc)motListDefaultActionCallback, (XtPointer)ih); } /* initialize the widget */ if (ih->data->is_dropdown || ih->data->has_editbox) XtRealizeWidget(ih->handle); else XtRealizeWidget(parent); /* Enable internal drag and drop support */ if((ih->data->show_dragdrop && !ih->data->is_dropdown && !ih->data->is_multiple) || (IupGetInt(ih, "DRAGDROPLIST"))) /* Enable drag and drop support between lists */ { motListEnableDragDrop(ih->handle); XtVaSetValues(ih->handle, XmNuserData, ih, NULL); /* to be used in motListDragStart and motListDragTransferProc */ } else iupmotDisableDragSource(ih->handle); /* Disable Drag Source */ if (IupGetGlobal("_IUP_RESET_TXTCOLORS")) { iupmotSetGlobalColorAttrib(ih->handle, XmNbackground, "TXTBGCOLOR"); iupmotSetGlobalColorAttrib(ih->handle, XmNforeground, "TXTFGCOLOR"); iupmotSetGlobalColorAttrib(ih->handle, XmNhighlightColor, "TXTHLCOLOR"); IupSetGlobal("_IUP_RESET_TXTCOLORS", NULL); } IupSetCallback(ih, "_IUP_XY2POS_CB", (Icallback)motListConvertXYToPos); iupListSetInitialItems(ih); return IUP_NOERROR; }
static int motValMapMethod(Ihandle* ih) { int num_args = 0; Arg args[30]; int show_ticks; /* 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 */ /* Primitive */ if (iupAttribGetBoolean(ih, "CANFOCUS")) iupmotSetArg(args, num_args, XmNtraversalOn, True); else iupmotSetArg(args, num_args, XmNtraversalOn, False); iupmotSetArg(args, num_args, XmNhighlightThickness, 2); iupmotSetArg(args, num_args, XmNnavigationType, XmTAB_GROUP); /* Scale */ iupmotSetArg(args, num_args, XmNminimum, 0); iupmotSetArg(args, num_args, XmNmaximum, SHRT_MAX); iupmotSetArg(args, num_args, XmNslidingMode, XmSLIDER); iupmotSetArg(args, num_args, XmNsliderMark, XmETCHED_LINE); iupmotSetArg(args, num_args, XmNsliderSize, 16); iupmotSetArg(args, num_args, XmNshowValue, XmNONE); if (ih->data->type == IVAL_HORIZONTAL) { iupmotSetArg(args, num_args, XmNorientation, XmHORIZONTAL); if (ih->data->inverted) iupmotSetArg(args, num_args, XmNprocessingDirection, XmMAX_ON_LEFT); else iupmotSetArg(args, num_args, XmNprocessingDirection, XmMAX_ON_RIGHT); } else { iupmotSetArg(args, num_args, XmNorientation, XmVERTICAL); if (ih->data->inverted) iupmotSetArg(args, num_args, XmNprocessingDirection, XmMAX_ON_TOP); else iupmotSetArg(args, num_args, XmNprocessingDirection, XmMAX_ON_BOTTOM); } ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmScaleWidgetClass, /* widget class */ iupChildTreeGetNativeParentHandle(ih), /* widget parent */ args, num_args); if (!ih->handle) return IUP_ERROR; /* callbacks */ XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); /* XmScale changes the default behavior of these, must set directly into the scrollbar */ /* XtAddEventHandler(ih->handle, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih); */ /* XtAddEventHandler(ih->handle, KeyPressMask, False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih); */ XtAddCallback(ih->handle, XmNdragCallback, (XtCallbackProc)motValValueChangedCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNvalueChangedCallback, (XtCallbackProc)motValValueChangedCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih); { Widget sb = XtNameToWidget(ih->handle, "Scrollbar"); /* TODO: Test this in other Motifs */ if (sb) { XtAddEventHandler(sb, FocusChangeMask, False, (XtEventHandler)motValFocusChangeEvent, (XtPointer)ih); XtAddEventHandler(sb, KeyPressMask, False, (XtEventHandler)motValKeyPressEvent, (XtPointer)ih); XtAddEventHandler(sb, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)motValButtonPressReleaseEvent, (XtPointer)ih); } } /* Ticks can only be created before XtRealizeWidget */ show_ticks = iupAttribGetInt(ih, "SHOWTICKS"); if (show_ticks) { if (show_ticks<2) show_ticks=2; ih->data->show_ticks = show_ticks; /* non zero value, can be changed later, but not to zero */ } ih->serial = iupDialogGetChildId(ih); /* must be after using the string */ /* initialize the widget */ XtRealizeWidget(ih->handle); return IUP_NOERROR; }
static int motLabelMapMethod(Ihandle* ih) { char* value; int num_args = 0; Arg args[20]; WidgetClass widget_class; value = iupAttribGet(ih, "SEPARATOR"); if (value) { widget_class = xmSeparatorWidgetClass; if (iupStrEqualNoCase(value, "HORIZONTAL")) { ih->data->type = IUP_LABEL_SEP_HORIZ; iupMOT_SETARG(args, num_args, XmNorientation, XmHORIZONTAL); } else /* "VERTICAL" */ { ih->data->type = IUP_LABEL_SEP_VERT; iupMOT_SETARG(args, num_args, XmNorientation, XmVERTICAL); } } else { value = iupAttribGet(ih, "IMAGE"); widget_class = xmLabelWidgetClass; if (value) { ih->data->type = IUP_LABEL_IMAGE; iupMOT_SETARG(args, num_args, XmNlabelType, XmPIXMAP); } else { ih->data->type = IUP_LABEL_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 */ iupMOT_SETARG(args, num_args, XmNtraversalOn, False); iupMOT_SETARG(args, num_args, XmNhighlightThickness, 0); /* 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); ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ widget_class, /* 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 */ XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)iupmotButtonPressReleaseEvent, (XtPointer)ih); if (iupStrBoolean(IupGetGlobal("INPUTCALLBACKS"))) XtAddEventHandler(ih->handle, PointerMotionMask, False, (XtEventHandler)iupmotDummyPointerMotionEvent, NULL); /* Drag Source is enabled by default in label */ iupmotDisableDragSource(ih->handle); /* initialize the widget */ XtRealizeWidget(ih->handle); if (ih->data->type == IUP_LABEL_TEXT) iupmotSetString(ih->handle, XmNlabelString, ""); 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->radio = 1; value = iupAttribGet(ih, "IMAGE"); if (value) { ih->data->type = IUP_TOGGLE_IMAGE; iupmotSetArg(args[num_args++], XmNlabelType, XmPIXMAP); } else { ih->data->type = IUP_TOGGLE_TEXT; iupmotSetArg(args[num_args++], XmNlabelType, XmSTRING); } /* 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 */ /* Primitive */ if (iupStrBoolean(iupAttribGetStr(ih, "CANFOCUS"))) iupmotSetArg(args[num_args++], XmNtraversalOn, True); else iupmotSetArg(args[num_args++], XmNtraversalOn, False); iupmotSetArg(args[num_args++], XmNhighlightThickness, 2); iupmotSetArg(args[num_args++], XmNnavigationType, XmTAB_GROUP); /* Label */ iupmotSetArg(args[num_args++], XmNrecomputeSize, False); /* no automatic resize from text */ iupmotSetArg(args[num_args++], XmNmarginHeight, 0); /* default padding */ iupmotSetArg(args[num_args++], XmNmarginWidth, 0); iupmotSetArg(args[num_args++], XmNmarginTop, 0); /* no extra margins */ iupmotSetArg(args[num_args++], XmNmarginLeft, 0); iupmotSetArg(args[num_args++], XmNmarginBottom, 0); iupmotSetArg(args[num_args++], XmNmarginRight, 0); if (radio) { iupmotSetArg(args[num_args++], XmNtoggleMode, XmTOGGLE_BOOLEAN); iupmotSetArg(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 */ iupAttribSetStr(ih, "VALUE","ON"); } } else { if (ih->data->type == IUP_TOGGLE_TEXT && iupAttribGetInt(ih, "3STATE")) iupmotSetArg(args[num_args++], XmNtoggleMode, XmTOGGLE_INDETERMINATE); else iupmotSetArg(args[num_args++], XmNtoggleMode, XmTOGGLE_BOOLEAN); iupmotSetArg(args[num_args++], XmNindicatorType, XmN_OF_MANY); } if (ih->data->type == IUP_TOGGLE_IMAGE) { iupmotSetArg(args[num_args++], XmNindicatorOn, XmINDICATOR_NONE); iupmotSetArg(args[num_args++], XmNalignment, XmALIGNMENT_CENTER); iupmotSetArg(args[num_args++], XmNshadowThickness, 2); } else { iupmotSetArg(args[num_args++], XmNspacing, 3); iupmotSetArg(args[num_args++], XmNindicatorOn, XmINDICATOR_CHECK_BOX); iupmotSetArg(args[num_args++], XmNalignment, XmALIGNMENT_BEGINNING); if (radio) { iupmotSetArg(args[num_args++], XmNindicatorSize, 13); iupmotSetArg(args[num_args++], XmNselectColor, iupmotColorGetPixel(0, 0, 0)); } else iupmotSetArg(args[num_args++], XmNindicatorSize, 15); iupmotSetArg(args[num_args++], XmNshadowThickness, 0); iupmotSetArg(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); 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); /* Disable Drag Source */ iupmotDisableDragSource(ih->handle); /* initialize the widget */ XtRealizeWidget(ih->handle); if (ih->data->type == IUP_TOGGLE_TEXT) iupmotSetString(ih->handle, XmNlabelString, ""); return IUP_NOERROR; }
static int motButtonMapMethod(Ihandle* ih) { int has_border = 1; char* value; int num_args = 0; Arg args[30]; value = iupAttribGet(ih, "IMAGE"); if (value) { ih->data->type = IUP_BUTTON_IMAGE; iupMOT_SETARG(args, num_args, XmNlabelType, XmPIXMAP); } else { ih->data->type = IUP_BUTTON_TEXT; iupMOT_SETARG(args, num_args, XmNlabelType, XmSTRING); } if (ih->data->type == IUP_BUTTON_IMAGE && iupAttribGet(ih, "IMPRESS") && !iupAttribGetBoolean(ih, "IMPRESSBORDER")) has_border = 0; /* 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 */ /* 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); /* PushButton */ iupMOT_SETARG(args, num_args, XmNfillOnArm, False); /* 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); ih->handle = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmPushButtonWidgetClass, /* 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 (has_border && iupAttribGetBoolean(ih, "FLAT")) { XtVaSetValues(ih->handle, XmNshadowThickness, 0, NULL); XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)motButtonEnterLeaveWindowEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)motButtonEnterLeaveWindowEvent, (XtPointer)ih); } else { if (!has_border) { /* In Motif the button will lose its focus feedback also */ XtVaSetValues(ih->handle, XmNhighlightThickness, 0, NULL); XtVaSetValues(ih->handle, XmNshadowThickness, 0, NULL); } else XtVaSetValues(ih->handle, XmNshadowThickness, 2, NULL); 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, XmNactivateCallback, (XtCallbackProc)motButtonActivateCallback, (XtPointer)ih); XtAddEventHandler(ih->handle, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)iupmotButtonPressReleaseEvent, (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_BUTTON_TEXT) iupmotSetXmString(ih->handle, XmNlabelString, ""); return IUP_NOERROR; }
static int motCanvasMapMethod(Ihandle* ih) { Widget sb_win; char *visual; int num_args = 0; Arg args[20]; if (!ih->parent) return IUP_ERROR; ih->data->sb = iupBaseGetScrollbar(ih); /*********************/ /* Create the parent */ /*********************/ iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); /* not visible when managed */ iupMOT_SETARG(args, num_args, XmNshadowThickness, 0); iupMOT_SETARG(args, num_args, XmNmarginWidth, 0); iupMOT_SETARG(args, num_args, XmNmarginHeight, 0); iupMOT_SETARG(args, num_args, XmNwidth, 100); /* set this to avoid size calculation problems */ iupMOT_SETARG(args, num_args, XmNheight, 100); iupMOT_SETARG(args, num_args, XmNresizePolicy, XmRESIZE_NONE); iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP); if (iupAttribGetBoolean(ih, "BORDER")) { iupMOT_SETARG(args, num_args, XmNborderWidth, 1); iupMOT_SETARG(args, num_args, XmNborderColor, iupmotColorGetPixelStr("0 0 0")); } else iupMOT_SETARG(args, num_args, XmNborderWidth, 0); sb_win = XtCreateManagedWidget( iupDialogGetChildIdStr(ih), /* child identifier */ xmBulletinBoardWidgetClass, /* widget class */ iupChildTreeGetNativeParentHandle(ih), /* widget parent */ args, num_args); if (!sb_win) return IUP_ERROR; ih->serial = iupDialogGetChildId(ih); /* must be after using the string */ /****************************/ /* Create the drawing area */ /****************************/ num_args = 0; iupMOT_SETARG(args, num_args, XmNmarginHeight, 0); /* no shadow margins */ iupMOT_SETARG(args, num_args, XmNmarginWidth, 0); /* no shadow margins */ iupMOT_SETARG(args, num_args, XmNshadowThickness, 0); iupMOT_SETARG(args, num_args, XmNresizePolicy, XmRESIZE_NONE); /* no automatic resize of children */ if (ih->iclass->is_interactive) { iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP); /* include in navigation */ if (iupAttribGetBoolean(ih, "CANFOCUS")) iupMOT_SETARG(args, num_args, XmNtraversalOn, True); else iupMOT_SETARG(args, num_args, XmNtraversalOn, False); } else { iupMOT_SETARG(args, num_args, XmNnavigationType, XmNONE); iupMOT_SETARG(args, num_args, XmNtraversalOn, False); } 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 */ visual = IupGetAttribute(ih, "VISUAL"); /* defined by the OpenGL Canvas or NULL */ if (visual) { Colormap colormap = (Colormap)iupAttribGet(ih, "COLORMAP"); if (colormap) iupMOT_SETARG(args, num_args, XmNcolormap,colormap); iupmotDialogSetVisual(ih, visual); } ih->handle = XtCreateManagedWidget( "draw_area", /* child identifier */ xmDrawingAreaWidgetClass, /* widget class */ sb_win, /* widget parent */ args, num_args); if (!ih->handle) { XtDestroyWidget(sb_win); return IUP_ERROR; } if (visual) iupmotDialogResetVisual(ih); iupAttribSet(ih, "_IUP_EXTRAPARENT", (char*)sb_win); { XSetWindowAttributes attrs; attrs.bit_gravity = ForgetGravity; /* For the DrawingArea widget gets Expose events when you resize it to be smaller. */ if (iupAttribGetBoolean(ih, "BACKINGSTORE")) attrs.backing_store = WhenMapped; else attrs.backing_store = NotUseful; XChangeWindowAttributes(iupmot_display, XtWindow(ih->handle), CWBitGravity|CWBackingStore, &attrs); } if (ih->data->sb & IUP_SB_HORIZ) { Widget sb_horiz = XtVaCreateManagedWidget("sb_horiz", xmScrollBarWidgetClass, sb_win, XmNorientation, XmHORIZONTAL, XmNsliderMark, XmTHUMB_MARK, XmNuserData, ih, NULL); XtAddCallback(sb_horiz, XmNvalueChangedCallback, motCanvasScrollbarCallback, (void*)IUP_SBPOSH); XtAddCallback(sb_horiz, XmNdragCallback, motCanvasScrollbarCallback, (void*)IUP_SBDRAGH); XtAddCallback(sb_horiz, XmNdecrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBLEFT); XtAddCallback(sb_horiz, XmNincrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBRIGHT); XtAddCallback(sb_horiz, XmNpageDecrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBPGLEFT); XtAddCallback(sb_horiz, XmNpageIncrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBPGRIGHT); iupAttribSet(ih, "_IUPMOT_SBHORIZ", (char*)sb_horiz); } if (ih->data->sb & IUP_SB_VERT) { Widget sb_vert = XtVaCreateManagedWidget("sb_vert", xmScrollBarWidgetClass, sb_win, XmNorientation, XmVERTICAL, XmNsliderMark, XmTHUMB_MARK, XmNuserData, ih, NULL); XtAddCallback(sb_vert, XmNvalueChangedCallback, motCanvasScrollbarCallback, (void*)IUP_SBPOSV); XtAddCallback(sb_vert, XmNdragCallback, motCanvasScrollbarCallback, (void*)IUP_SBDRAGV); XtAddCallback(sb_vert, XmNdecrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBUP); XtAddCallback(sb_vert, XmNincrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBDN); XtAddCallback(sb_vert, XmNpageDecrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBPGUP); XtAddCallback(sb_vert, XmNpageIncrementCallback, motCanvasScrollbarCallback, (void*)IUP_SBPGDN); iupAttribSet(ih, "_IUPMOT_SBVERT", (char*)sb_vert); } XtAddCallback(ih->handle, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNexposeCallback, (XtCallbackProc)motCanvasExposeCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNresizeCallback, (XtCallbackProc)motCanvasResizeCallback, (XtPointer)ih); XtAddCallback(ih->handle, XmNinputCallback, (XtCallbackProc)motCanvasInputCallback, (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)iupmotKeyPressEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, KeyReleaseMask, False, (XtEventHandler)iupmotCanvasKeyReleaseEvent, (XtPointer)ih); XtAddEventHandler(ih->handle, PointerMotionMask, False, (XtEventHandler)iupmotPointerMotionEvent, (XtPointer)ih); /* initialize the widget */ XtRealizeWidget(sb_win); motCanvasSetDXAttrib(ih, NULL); motCanvasSetDYAttrib(ih, NULL); return IUP_NOERROR; }