XmSPINBOX_USER_DEFINED
Name | Class | Type | Default | Access |
XmNgetValueProc | XmCGetValueProc | SpinboxGetValueProc | dynamic | CSG |
XmNgetValueData | XmCGetValueData | XtPointer | NULL | CSG |
XmNshowValueProc | XmCShowValueProc | SpinboxShowValueProc | dynamic | CSG |
XmNshowValueData | XmCShowValueData | XtPointer | NULL | CSG |
all of the built-in types have built-in get and show functions, so the user need not set
them except when setting XmNspinboxType to XmSPINBOX_USER_DEFINED
.
typedef Boolean (SpinboxGetValueProc) ( Widget spinbox, XtPointer client_data, const char *buffer, size_t buffer_len, long *num );XmNgetValueProc takes a SpinboxGetValueProc function. Its parameters are:
If the conversion is successful, it should return True. If it fails, it should return False. If the function fails, the value will not be set and the spinbox's XmNvalueChangedCallbacks will not be called.
As a basic example, if the get_value function for XmSPINBOX_NUMBER
had no decimal places, it could read:
Boolean default_get_value ( Widget w, XtPointer client_data, const char *buffer, size_t buflen, long *value ) { errno = 0; *value = strtol ( buffer, NULL, 10 ); return ( !errno ); }
and the get_value function for XmSPINBOX_CLOCK
might read
Boolean clock_get_value ( Widget w, XtPointer client_data, const char *buffer, size_t buflen, int *value ) { long hr, min=0; char *pchar; errno = 0; hr = strtol ( buffer, &pchar, 10 ); if ( *pchar=':' ) min = strtol ( ++pchar, &pchar, 10 ); *value = hr*60 + min; return ( !errno );
Note that the checks to see if the value is within XmNminimum and XmNmaximum are handled by the Spinbox widget, so the XmNgetValueProc doesn't need to check for that.
typedef void (SpinboxShowValueProc) ( Widget spinbox, XtPointer client_data, long num, char *buffer, size_t maxlen );XmNshowValueProc takes a SpinboxShowValueProc function. Its parameters are:
In practice, the maxlen will be no less than 128 characters, so space should never be a problem.
As an example, if the show_value function for XmSPINBOX_NUMBER
had no decimal places, it might read:
void default_show_value ( Widget w, XtPointer client_data, long value, char *buffer, size_t maxlen ) { (void) sprintf ( buffer "%ld", value ); }
and the show_value function for XmSPINBOX_CLOCK_HM
might read:
void clock_show_value ( Widget w, XtPointer client_data, long value, char *buffer, size_t maxlen ) { (void) sprintf ( buffer, "%02ld:%02ld", value/60, value%60 ); }