Exemplo n.º 1
0
static int motDialogMapMethod(Ihandle* ih)
{
  Widget dialog_manager;
  InativeHandle* parent;
  int mwm_decor = 0;
  int num_args = 0;
  Arg args[20];

  if (iupAttribGetInt(ih, "DIALOGFRAME")) 
  {
    iupAttribSetStr(ih, "RESIZE", "NO");
    iupAttribSetStr(ih, "MAXBOX", "NO");
    iupAttribSetStr(ih, "MINBOX", "NO");
  }

  /****************************/
  /* Create the dialog shell  */
  /****************************/

  if (iupAttribGet(ih, "TITLE"))
      mwm_decor |= MWM_DECOR_TITLE;
  if (iupAttribGetInt(ih, "MENUBOX"))
      mwm_decor |= MWM_DECOR_MENU;
  if (iupAttribGetInt(ih, "MINBOX"))
      mwm_decor |= MWM_DECOR_MINIMIZE;
  if (iupAttribGetInt(ih, "MAXBOX"))
      mwm_decor |= MWM_DECOR_MAXIMIZE;
  if (iupAttribGetInt(ih, "RESIZE"))
      mwm_decor |= MWM_DECOR_RESIZEH;
  if (iupAttribGetInt(ih, "BORDER"))
      mwm_decor |= MWM_DECOR_BORDER;

  iupmotSetArg(args, num_args, XmNmappedWhenManaged, False);  /* so XtRealizeWidget will not show the dialog */
  iupmotSetArg(args, num_args, XmNdeleteResponse, XmDO_NOTHING);
  iupmotSetArg(args, num_args, XmNallowShellResize, True); /* Used so the BulletinBoard can control the shell size */
  iupmotSetArg(args, num_args, XmNtitle, "");
  iupmotSetArg(args, num_args, XmNvisual, iupmot_visual);
  
  if (iupmotColorMap()) 
    iupmotSetArg(args, num_args, XmNcolormap, iupmotColorMap());

  if (mwm_decor != 0x7E) 
    iupmotSetArg(args, num_args, XmNmwmDecorations, mwm_decor);

  if (iupAttribGetInt(ih, "SAVEUNDER"))
    iupmotSetArg(args, num_args, XmNsaveUnder, True);

  parent = iupDialogGetNativeParent(ih);
  if (parent)
    ih->handle = XtCreatePopupShell(NULL, topLevelShellWidgetClass, (Widget)parent, args, num_args);
  else
    ih->handle = XtAppCreateShell(NULL, "dialog", topLevelShellWidgetClass, iupmot_display, args, num_args);

  if (!ih->handle)
    return IUP_ERROR;

  XmAddWMProtocolCallback(ih->handle, iupmot_wm_deletewindow, motDialogCBclose, (XtPointer)ih);

  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, StructureNotifyMask, False, (XtEventHandler)motDialogCBStructureNotifyEvent, (XtPointer)ih);

  XtAddCallback(ih->handle, XmNdestroyCallback, (XtCallbackProc)motDialogDestroyCallback, (XtPointer)ih);

  /*****************************/
  /* Create the dialog manager */
  /*****************************/

  dialog_manager = XtVaCreateManagedWidget(
              "dialog_manager",
              xmBulletinBoardWidgetClass,
              ih->handle,
              XmNmarginWidth, 0,
              XmNmarginHeight, 0,
              XmNwidth, 100,     /* set this to avoid size calculation problems */
              XmNheight, 100,
              XmNborderWidth, 0,
              XmNshadowThickness, 0,
              XmNnoResize, iupAttribGetInt(ih, "RESIZE")? False: True,
              XmNresizePolicy, XmRESIZE_NONE, /* no automatic resize of children */
              XmNuserData, ih, /* used only in motDialogConfigureNotify                   */
              XmNnavigationType, XmTAB_GROUP,
              NULL);

  XtOverrideTranslations(dialog_manager, XtParseTranslationTable("<Configure>: iupDialogConfigure()"));
  XtAddCallback(dialog_manager, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih);
  XtAddEventHandler(dialog_manager, KeyPressMask, False,(XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih);

  /* force the BGCOLOR to match the DLGBGCOLOR */
  motDialogSetBgColorAttrib(ih, IupGetGlobal("DLGBGCOLOR"));

  /* initialize the widget */
  XtRealizeWidget(ih->handle);

  /* child dialogs must be always on top of the parent */
  if (parent)
    XSetTransientForHint(iupmot_display, XtWindow(ih->handle), XtWindow(parent));

  if (mwm_decor != 0x7E)  /* some decoration was changed */
    motDialogSetWindowManagerStyle(ih);

  /* Ignore VISIBLE before mapping */
  iupAttribSetStr(ih, "VISIBLE", NULL);

  if (IupGetGlobal("_IUP_SET_DLGFGCOLOR"))
  {
    iupmotSetGlobalColorAttrib(dialog_manager, XmNforeground, "DLGFGCOLOR");
    IupSetGlobal("_IUP_SET_DLGFGCOLOR", NULL);
  }

  return IUP_NOERROR;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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;
}