WgControlsBox Procedure
Displays slider and returns user-selected slider value.
Usage
WgControlsBox, value, lb, ub
Input Parameters
value — A named or unamed variable to be replaced by the user's selection.
lb — A scalar lower bound on the slider's range.
ub — A scalar upper bound on the slider's range.
Output Parameters
value — A float. The value returned from the slider widget.
note | wgcontrolsbox_output — A common block internal to WgControlsBox containing one variable, which is the slider value chosen by the user. When WgControlsBox is called stand-alone, it runs in its own event loop. Once the user finishes their slider selection control is passed back to the calling routine and the user's input is accessed through the variable value. However, if WgControlsBox is called from an existing widget application, the tool must use this widget's event loop. In this case, WgControlsBox is executed and control is passed back immediately to the calling widget application, before the user can submit the most recent value that they have chosen. To allow the widget application that calls WgControlsBox to have access to the most recent value chosen by the user, include this common block in the calling widget application. |
Keywords
Border — Specifies the width in pixels of the controls box and slider border.
Drag — If present and nonzero, the callback procedure is called while the slider is being dragged.
Default — The value that the slider should be initialized to. Must exist within the range set by lb, ub.
NoValueDisplay — If present and nonzero, the read-only text field above the slider displaying the slider's value will not be displayed.
Ndecimals — The number of decimals places to display for a floating-point slider, with ranges that include implied decimal numbers.
Height — Specifies the height in pixels of the slider. Ignored if the slider is a horizontal slider.
Hslider — When present and nonzero, creates a horizontally oriented slider. This is the default orientation.
Label — A string to label the slider.
Parent — The widget ID of the parent widget. If no parent is specified, the toolkit is initialized and WgControlBox runs in its own event loop.
Position — A two element vector containing the position, in pixels, of WgControlBox's upper-left corner where [0,0] is the upper-left corner of the display.
Shell — (Output) The ID of the newly created WgControlsBox widget.
Sliders — (Output) A single element long array containing the ID of the slider itself.
Title — A string containing the title for the widget.
Vslider — When present and nonzero, creates vertically oriented sliders.
Width — Specifies the width in pixels of the slider. Ignored if the slider is a vertical slider.
Discussion
If ub*10^ndecimals > 1e7, the return value is no longer accurate. In other words, the maximum of the slider range multiplied by the quantity ten raised to ndecimals cannot be greater than or equal to ten million, and this implies that the discretization of the slider values cannot be finer than one in ten million.
Example 1
WgControlsBox run as a stand-alone application.
.RUN
PRO BUTTONSCB, wid, which
COMMON workareaID, workArea
COMMON wgcontrolsbox_output, newValue
CASE which OF
1: BEGIN
WgControlsBox, junk, 10,100, Parent=workArea,$
Title='Hello!', $
/Drag, Ndecimals=3, Position=[100,600], $
Shell=shell, Default=12.345, Foreground='orange'
END
2: BEGIN
IF N_ELEMENTS(newValue) GT 0 THEN $
PM, newValue, Title='You chose:'$
ELSE BEGIN
PRINT, STRING(7B)
PRINT, 'Selection has not been made yet'
ENDELSE
END
ENDCASE
END
COMMON workareaID, workArea
topshell = WwInit('WgControlsBox_test', $
'WgControlsBox_test', workArea, /Vertical, $
Position=[256,256], Spacing=5, Height=100, $
Width=350)
buttons = WwButtonBox(workArea, $
['Call WgControlsBox', 'See result'], 'BUTTONSCB')
status=WwSetValue(topshell, /Display)
WwLoop
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.