Beispiel #1
0
static int motTextSetSpinValueAttrib(Ihandle* ih, const char* value)
{
  Widget spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (spinbox && XmIsSpinBox(spinbox))
  {
    int pos;
    if (iupStrToInt(value, &pos))
    {
      char* value = NULL;
      int min, max;
      ih->data->disable_callbacks = 1;
      XtVaGetValues(ih->handle, XmNminimumValue, &min, 
                                XmNmaximumValue, &max, NULL);
      if (pos < min) pos = min;
      if (pos > max) pos = max;
      if (iupAttribGet(ih, "_IUPMOT_SPIN_NOAUTO"))
        value = XmTextGetString(ih->handle);

      XtVaSetValues(ih->handle, XmNposition, pos, NULL);

      if (value)
      {
        iupmotTextSetString(ih->handle, value);
        XtFree(value);
      }
      ih->data->disable_callbacks = 0;
      return 1;
    }
  }
  return 0;
}
Beispiel #2
0
static int motTextSetValueAttrib(Ihandle* ih, const char* value)
{
  if (!value) value = "";
  motTextSetSpinValueAttrib(ih, value);
  /* disable callbacks */
  ih->data->disable_callbacks = 1;
  iupmotTextSetString(ih->handle, value);
  ih->data->disable_callbacks = 0;
  return 0;
}
Beispiel #3
0
static int motListSetValueAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->has_editbox)
  {
    Widget cbedit;
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    if (!value) value = "";

    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", "1"); /* disable callbacks */

    iupmotTextSetString(cbedit, value);

    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else 
  {
    if (ih->data->is_dropdown)
    {
      int pos;
      if (iupStrToInt(value, &pos)==1)
      {
        XtRemoveCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih);

        XtVaSetValues(ih->handle, XmNselectedPosition, pos-1, NULL);  /* IUP starts at 1 */
        iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", pos);

        XtAddCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih);
      }
    }
    else
    {
      if (!ih->data->is_multiple)
      {
        int pos;
        if (iupStrToInt(value, &pos)==1)
        {
          XmListSelectPos(ih->handle, pos, FALSE);   /* XmListSelectPos starts at 1 */
          iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", pos);
        }
        else
        {
          XmListDeselectAllItems(ih->handle);
          iupAttribSet(ih, "_IUPLIST_OLDVALUE", NULL);
        }
      }
      else
      {
        /* User has changed a multiple selection on a simple list. */
	      int i, count, len;

        /* Clear all selections */
        XmListDeselectAllItems(ih->handle);

        if (!value)
        {
          iupAttribSet(ih, "_IUPLIST_OLDVALUE", NULL);
          return 0;
        }

        XtVaGetValues(ih->handle, XmNitemCount, &count, NULL);
        len = strlen(value);
        if (len < count) 
          count = len;

        XtVaSetValues(ih->handle, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);

        /* update selection list */
        for (i = 0; i<count; i++)
        {
          if (value[i]=='+')
            XmListSelectPos(ih->handle, i+1, False);  /* XmListSelectPos starts at 1 */
        }

        XtVaSetValues(ih->handle, XmNselectionPolicy, XmEXTENDED_SELECT, 
                                  XmNselectionMode, XmNORMAL_MODE, NULL);  /* must also restore this */
        iupAttribSetStr(ih, "_IUPLIST_OLDVALUE", value);
      }
    }
  }

  return 0;
}