XMSPINBOXVALIDATEPOSITION(3)
π XmSpinBoxValidatePosition π
okay bestie, we're in the library call section of the manual and today's main character is XmSpinBoxValidatePosition β the little utility that takes whatever chaotic thing a user typed into an XmSpinBox child and translates it into a valid position. no cap. let's get into it β¨
β¨ NAME β¨
XmSpinBoxValidatePosition β translate the current value of the specified XmSpinBox child into a valid position π
πΈ SYNOPSIS πΈ
#include <Xm/SpinBox.h>
int XmSpinBoxValidatePosition(
Widget textfield,
int *position);
π¦ DESCRIPTION π¦
So XmSpinBoxValidatePosition is a utility function, and it's there for apps that wanna implement their own policy for tracking user modifications to editable XmSpinBox children of type XmNUMERIC. The specifics of when and how the user's modifications actually take effect? that's entirely up to the application, bestie. it's giving "you're on your own, but here's a helper" π
text_fieldβ this argument specifies the widget ID of the child of theXmSpinBoxthat's being modified. the requirement ontext_fieldis that it holds theaccessTextualtrait (which is already a requirement for children ofXmSpinBoxanyway). this way,XmSpinBoxcan extract the string out of thetext_fieldwidget β even if it is not anXmTextField. iconic, honestly.positionβ the location pointed to by thepositionargument gets assigned the result of the translation done byXmSpinBoxValidatePosition. first,XmSpinBoxValidatePositionchecks to make sure this is anXmNUMERICXmSpinBoxchild. if it is not,XSmpinBoxValidatePositionsetspositionto the current position and returnsXmCURRENT_VALUE.
XmSpinBoxValidatePosition attempts to translate the input string to a floating point number. if this translation fails, XmSpinBoxValidatePosition sets position to the current position and returns XmCURRENT_VALUE. π
XmSpinBoxValidatePosition converts the floating point number to an integer using the XmNdecimalPoints resource. extra decimal places are truncated. the resulting integer is range checked to make sure it falls within the valid range defined by XmNminimumValue and XmNmaximumValue inclusive. if the input falls outside this range, XmSpinBoxValidatePosition sets position to the nearest limit and returns either XmMINIMUM_VALUE or XmMAXIMUM_VALUE. π₯
finally, XmSpinBoxValidatePosition checks the integer to make sure it belongs to the series defined by XmNminimumValue ... XmNminimumValue + ((n - 1) * XmNincrementValue). if the integer does not belong to this series, XmSpinBoxValidatePosition sets position to the nearest element which is less than or equal to the integer and returns XmINCREMENT_VALUE.
otherwise, XmSpinBoxValidatePosition assigns the integer to position and returns XmVALID_VALUE. slay β¨
π RETURN VALUE π
XmSpinBoxValidatePosition returns the status of the validation. the set of possible values returned is as follows:
XmCURRENT_VALUEβ Cannot convert, returning current position_value.XmMINIMUM_VALUEβ Less than min.XmMAXIMUM_VALUEβ More than max.XmINCREMENT_VALUEβ Not on increment.XmVALID_VALUEβ Okay. π«Ά
π EXAMPLES π
this first example demonstrates how the XmSpinBoxValidatePosition function could be used from inside an XmNmodifyVerifyCallback callback installed on the XmSpinBox or the XmSimpleSpinBox:
/*
* Install a callback on a spin box arrow press.
*/
XtAddCallback(sb, XmNmodifyVerifyCallback, ModifyVerifyCB, NULL);
XtAddCallback(simple_sb, XmNmodifyVerifyCallback, ModifyVerifyCB, NULL);
with the callback doing:
void ModifyVerifyCB(widget, call_data, client_data) {
XmSpinBoxCallbackStruct *cbs = (XmSpinBoxCallbackStruct*) call_data;
int position;
Widget textual = NULL;
if (XtIsSubclass(w, xmSimpleSpinBoxWidgetClass))
{
Arg args[1];
XtSetArg(args[0], XmNtextField, &textual);
XtGetValues(w, args, 1);
}
else if (XtIsSubclass(w, xmSpinBoxWidgetClass))
textual = cbs->widget;
else
textual = (Widget) NULL;
...
if (XmSpinBoxValidatePosition(textual, &position) == XmCURRENT_VALUE)
XBell(XtDisplay(w), 0);
else
cbs->position = position;
}
this second example demonstrates how the XmSpinBoxValidatePosition function could be used from inside an XmNactivateCallback callback installed on the TextField child of the XmSpinBox:
/*
* Install a callback on a spin box arrow press.
*/
XtAddCallback(tf, XmNactivateCallback, ModifyVerifyChildCB, NULL);
with the callback doing:
void ModifyVerifyChildCB(widget, call_data, client_data) {
int position;
Widget textual = widget;
Arg args[1];
if (XmSpinBoxValidatePosition (textual, &position) == XmCURRENT_VALUE)
XBell(XtDisplay(widget), 0);
/* Set the position constraint resource of the textfield */
XtSetArg(args[0], XmNposition, position);
XtSetValues(textual, args, 1);
}
π SEE ALSO π
XmSpinBox(3), XmCreateSpinBox(3)
and that's the whole page, bestie!! π this was the library call manual, filed under XmSpinBoxValidatePosition β go forth and validate those positions, you absolute icon ππΈβ¨
π¦ where this page comes from
- alpine 3.24: motif-doc 2.5.2-r0 Β· LGPL-2.1-or-later
- arch rolling: openmotif 2.3.8-4 Β· LGPL-2.1-or-later
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- epel 10: motif-devel 2.3.8-2.el10_2 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- nixos 26.05: motif 2.3.8
- nixpkgs unstable: motif 2.3.8
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms