1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
'\" t
...\" SpinBoxV.sgm /main/7 1996/09/08 21:02:39 rws $
.de P!
.fl
\!!1 setgray
.fl
\\&.\"
.fl
\!!0 setgray
.fl \" force out current output buffer
\!!save /psv exch def currentpoint translate 0 0 moveto
\!!/showpage{}def
.fl \" prolog
.sy sed -e 's/^/!/' \\$1\" bring in postscript file
\!!psv restore
.
.de pF
.ie \\*(f1 .ds f1 \\n(.f
.el .ie \\*(f2 .ds f2 \\n(.f
.el .ie \\*(f3 .ds f3 \\n(.f
.el .ie \\*(f4 .ds f4 \\n(.f
.el .tm ? font overflow
.ft \\$1
..
.de fP
.ie !\\*(f4 \{\
. ft \\*(f4
. ds f4\"
' br \}
.el .ie !\\*(f3 \{\
. ft \\*(f3
. ds f3\"
' br \}
.el .ie !\\*(f2 \{\
. ft \\*(f2
. ds f2\"
' br \}
.el .ie !\\*(f1 \{\
. ft \\*(f1
. ds f1\"
' br \}
.el .tm ? font underflow
..
.ds f1\"
.ds f2\"
.ds f3\"
.ds f4\"
.ta 8n 16n 24n 32n 40n 48n 56n 64n 72n
.TH "XmSpinBoxValidatePosition" "library call"
.SH "NAME"
\fBXmSpinBoxValidatePosition\fP \(em translate the current value of the specified XmSpinBox child
into a valid position
.SH "SYNOPSIS"
.PP
.nf
#include <Xm/SpinBox\&.h>
\fBint \fBXmSpinBoxValidatePosition\fP\fR(
\fBWidget \fBtextfield\fR\fR,
\fBint \fB*position\fR\fR);
.fi
.SH "DESCRIPTION"
.PP
The
\fBXmSpinBoxValidatePosition\fP function
is a utility that can be used by applications wanting to
implement a policy for tracking user modifications to editable
\fBXmSpinBox\fP children of type
\fBXmNUMERIC\fP\&. The specifics of when and how the user\&'s
modifications take effect is left up to the application\&.
.IP "\fItext_field\fP" 10
The \fItext_field\fP argument specifies the
widget ID of the child of the \fBXmSpinBox\fP that is
being modified\&. The requirement on \fItext_field\fP
is that it holds the
\fBaccessTextual\fP trait (already a requirement for
children of \fBXmSpinBox\fP)\&. This way,
\fBXmSpinBox\fP can extract the string out of the
\fItext_field\fP widget (even if it is not an
\fBXmTextField\fP)\&.
.IP "\fIposition\fP" 10
The location pointed to by the position argument is assigned the result
of the translation done by \fBXmSpinBoxValidatePosition\fP\&.
\fBXmSpinBoxValidatePosition\fP first checks to make sure this is an
\fBXmNUMERIC\fP \fBXmSpinBox\fP child\&. If it is not,
\fBXSmpinBoxValidatePosition\fP sets position to the current
position and returns \fBXmCURRENT_VALUE\fP\&.
.PP
\fBXmSpinBoxValidatePosition\fP
attempts to translate the input string to a floating point number\&. If
this translation fails,
\fBXmSpinBoxValidatePosition\fP sets position to the current position and
returns \fBXmCURRENT_VALUE\fP\&.
.PP
\fBXmSpinBoxValidatePosition\fP converts the floating point number to an integer using the
\fBXmNdecimalPoints\fP resource\&. Extra decimal places are truncated\&. The resulting integer is range
checked to make sure it falls within the valid range defined by \fBXmNminimumValue\fP and
\fBXmNmaximumValue\fP inclusive\&. If the input falls outside this range,
\fBXmSpinBoxValidatePosition\fP sets position to the nearest limit and returns either
\fBXmMINIMUM_VALUE\fP or \fBXmMAXIMUM_VALUE\fP\&.
.PP
Finally, \fBXmSpinBoxValidatePosition\fP checks the integer to make sure it belongs to the series
defined by \fBXmNminimumValue \&.\&.\&. XmNminimumValue + ((n - 1) * XmNincrementValue)\fP\&. If
the integer does not belong to this series, \fBXmSpinBoxValidatePosition\fP sets position to the
nearest element which is less than or equal to the integer and returns
\fBXmINCREMENT_VALUE\fP\&.
.PP
Otherwise, \fBXmSpinBoxValidatePosition\fP assigns the integer to position and returns
\fBXmVALID_VALUE\fP\&.
.SH "RETURN VALUE"
.PP
The
\fBXmSpinBoxValidatePosition\fP function returns the status of the validation\&.
The set of possible values returned is as follows:
.IP "\fBXmCURRENT_VALUE\fP" 10
Cannot convert, returning current position_value\&.
.IP "\fBXmMINIMUM_VALUE\fP" 10
Less than min\&.
.IP "\fBXmMAXIMUM_VALUE\fP" 10
More than max\&.
.IP "\fBXmINCREMENT_VALUE\fP" 10
Not on increment\&.
.IP "\fBXmVALID_VALUE\fP" 10
Okay\&.
.SH "EXAMPLES"
.PP
This first example demonstrates how the \fBXmSpinBoxValidatePosition\fP
function could be used from inside an
\fBXmNmodifyVerifyCallback\fP callback installed on the
\fBXmSpinBox\fP or the
\fBXmSimpleSpinBox\fP:
.PP
.nf
\f(CW/*
* Install a callback on a spin box arrow press\&.
*/
XtAddCallback(sb, XmNmodifyVerifyCallback, ModifyVerifyCB, NULL);
XtAddCallback(simple_sb, XmNmodifyVerifyCallback, ModifyVerifyCB, NULL);\fR
.fi
.PP
.PP
with the callback doing:
.PP
.nf
\f(CWvoid 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;
}\fR
.fi
.PP
.PP
This second example demonstrates how the \fBXmSpinBoxValidatePosition\fP
function could be used from inside an
\fBXmNactivateCallback\fP callback installed on
the \fBTextField\fP child of the \fBXmSpinBox\fP:
.PP
.nf
\f(CW/*
* Install a callback on a spin box arrow press\&.
*/
XtAddCallback(tf, XmNactivateCallback, ModifyVerifyChildCB, NULL);\fR
.fi
.PP
.PP
with the callback doing:
.PP
.nf
\f(CWvoid 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);
}\fR
.fi
.PP
.SH "SEE ALSO"
.PP
\fBXmSpinBox\fP(3),
\fBXmCreateSpinBox\fP(3)
...\" created by instant / docbook-to-man, Sun 22 Dec 1996, 20:30
|