Exemple #1
0
static int motValSetShowTicksAttrib(Ihandle* ih, const char* value)
{
  int tick_freq, show_ticks;

  if (!ih->data->show_ticks)  /* can only set if already not zero */
    return 0;

  show_ticks = atoi(value);
  if (show_ticks<2) show_ticks=2;
  ih->data->show_ticks = show_ticks;

  motValRemoveOldTicks(ih->handle);

  /* Defines the interval frequency for tick marks */
  tick_freq = SHRT_MAX/(show_ticks-1);
  XmScaleSetTicks(ih->handle, tick_freq, 0, 0, 8, 0, 0);
  return 0;
}
Exemple #2
0
static void 
InitScaleCombo (Widget w, XtPointer client_data, XtPointer call_data) 
{
    Arg			args[1];
    Widget		applyb, cbb, scale, selectb;
    Widget		spinb, sspinb_s, sspinb_n, textual;
    XtCallbackRec	sbModifyVerifyList[] = {
				{sb_ModifyVerifyCB, (caddr_t) NULL},
				{(XtCallbackProc) NULL, (caddr_t) NULL}
			    };
    XtCallbackRec	sbValueChangedList[] = {
				{sb_ValueChangedCB, (caddr_t) NULL},
				{(XtCallbackProc) NULL, (caddr_t) NULL}
			    };
    XtCallbackRec	tfActivateList[] = {
				{tf_ActivateCB, (caddr_t) NULL},
				{(XtCallbackProc) NULL, (caddr_t) NULL}
			    };
    XtCallbackRec	sbApplyList[] = {
				{sb_ApplyCB, (caddr_t) NULL},
				{(XtCallbackProc) NULL, (caddr_t) NULL}
			    };
    XtCallbackRec	sbCancelList[] = {
				{sb_CancelCB, (caddr_t) NULL},
				{(XtCallbackProc) NULL, (caddr_t) NULL}
			    };
    XtCallbackRec	sbOkList[] = {
				{sb_OkCB, (caddr_t) NULL},
				{(XtCallbackProc) NULL, (caddr_t) NULL}
			    };

    cbb = XtVaCreateWidget("ComboBox", xmComboBoxWidgetClass, w, NULL);
    XtRealizeWidget(cbb);
    XtManageChild(cbb);

    spinb = XtVaCreateWidget("SpinBox", xmSpinBoxWidgetClass, w,
			     XmNmodifyVerifyCallback, sbModifyVerifyList,
			     XmNvalueChangedCallback, sbValueChangedList,
			     NULL);
    XtRealizeWidget(spinb);
    XtManageChild(spinb);
    XtVaCreateManagedWidget("Date", xmTextFieldWidgetClass, spinb,
			    XmNactivateCallback, tfActivateList,
			    NULL);
    XtVaCreateManagedWidget("Month", xmTextFieldWidgetClass, spinb,
			    XmNactivateCallback, tfActivateList,
			    NULL);
    XtVaCreateManagedWidget("Year", xmTextFieldWidgetClass, spinb,
			    XmNactivateCallback, tfActivateList,
			    NULL);
    
    sspinb_n = XtVaCreateWidget(
		"SimpleSpinBoxNumeric", xmSimpleSpinBoxWidgetClass, w,
		XmNmodifyVerifyCallback, sbModifyVerifyList,
		XmNvalueChangedCallback, sbValueChangedList,
		NULL);
    textual = ssb_GetTextField(sspinb_n);
    XtSetArg(args[0], XmNactivateCallback, tfActivateList);
    XtSetValues(textual, args, 1);
    XtRealizeWidget(sspinb_n);
    XtManageChild(sspinb_n);

    sspinb_s = XtVaCreateWidget(
		"SimpleSpinBoxString", xmSimpleSpinBoxWidgetClass, w,
		XmNmodifyVerifyCallback, sbModifyVerifyList,
		XmNvalueChangedCallback, sbValueChangedList,
		NULL);
    textual = ssb_GetTextField(sspinb_s);
    XtSetArg(args[0], XmNactivateCallback, tfActivateList);
    XtSetValues(textual, args, 1);
    XtRealizeWidget(sspinb_s);
    XtManageChild(sspinb_s);

#ifdef SAMPLER_TEST_SSPINB
    XtVaSetValues(sspinb_n, XmNtextField, sspinb_s, NULL);
    XtVaSetValues(sspinb_n, XmNpositionType, XmPOSITION_INDEX, NULL);
    XtVaSetValues(spinb, XmNpositionType, XmPOSITION_INDEX, NULL);
#endif

#ifdef SAMPLER_TEST_SSPINB
    ssb_widgets[SSB_NUMERIC]  = sspinb_n;
    ssb_widgets[SSB_STRING]  = sspinb_s;

    sbApplyList[0].closure = (caddr_t) ssb_widgets;
    sbCancelList[0].closure = (caddr_t) ssb_widgets;
    sbOkList[0].closure = (caddr_t) ssb_widgets;

    selectb = XtVaCreateWidget(
		"SelectionBoxDebug", xmSelectionBoxWidgetClass, w,
		XmNapplyCallback, sbApplyList,
		XmNcancelCallback, sbCancelList,
		XmNokCallback, sbOkList,
		XmNdialogType, XmDIALOG_PROMPT,
		XmNmustMatch, False,
		NULL);
    XtRealizeWidget(selectb);
    XtManageChild(selectb);
    applyb = XmSelectionBoxGetChild(selectb, XmDIALOG_APPLY_BUTTON);
    XtManageChild(applyb);
#endif

    scale = XtVaCreateWidget("Scale", xmScaleWidgetClass, w, NULL);    
    XtRealizeWidget(scale);
    XtManageChild(scale);
    XmScaleSetTicks(scale, 
		    10, 1, 4,
		    20, 10, 5);

}