SLIDER WIDGET(3W) — OLIT
WIDGET CLASS NAME
Slider
SYNOPSIS
f4#include <Intrinsic.h>
#include <StringDefs.h>
#include <OpenLook.h>
#include <Slider.h>
widget = XtCreateWidget(name, sliderWidgetClass, ...)
DESCRIPTION
Slider Components
The Slider widget controls the setting of a numeric value; a horizontal slider is shown in the diagram Horizontal Slider.
Figure 1 Horizontal Slider
It consists of the following elements:
—Top (Left) Anchor
—Bottom (Right) Anchor
—Drag Box
—Bar (typically)
—Shaded Bar (typically)
—Current Value (not visible)
—Minimum Value (not visible)
—Maximum Value (not visible)
The Current Value is the numeric value a user attempts to change with the Slider widget. Drag Box Motion
As visual feedback to the user, the Drag Box moves up or down (or left or right) along the Bar as the Current Value changes.
Figure 2 Vertical Slider Dragging SELECT
The user can change the Current Value by dragging the Drag Box with SELECT. The pressing of SELECT must start with the pointer in the Drag Box, but the Drag Box (and the Current Value) track the pointer motion regardless of where it goes while SELECT is pressed. This means it is not possible for the user to change the Current Value by first pressing SELECT outside the Drag Box and then moving the pointer into it. Only the component of the pointer motion parallel to the Bar is tracked, and the motion of the Drag Box (and change in the Current Value) are limited by the length of the Bar. Clicking SELECT
Clicking SELECT above the Drag Box for a vertical slider, or to the right for a horizontal slider, increases the Current Value by an application-specified amount, moves the Drag Box to correspond to the new Current Value, and moves the pointer to keep it on the Drag Box. Clicking SELECT to the other side of the Drag Box decreases the value by the same amount and moves the Drag Box and pointer accordingly. Pressing SELECT repeats this action. Moving Drag Box to Limits
Clicking SELECT on one of the Bottom/Left or Top/Right Anchors causes the Current Value to take on the Minimum Value or Maximum Value, respectively, and moves the Drag Box to the limit in the direction of the Anchor. If the Drag Box is already at the limit, nothing happens.
Clicking SELECT on an Anchor highlights the Anchor while the Current Value is changed. Application Notification
The application finds out about a change in the Current Value on the release of SELECT for either the drag or click. It is responsible for providing any feedback to the end user deemed appropriate, such as updating the Current Value in a text field. Slider Coloration
the diagram Slider Coloration illustrates the resources that affect the coloration of the Slider widget.
Figure 3 Slider Coloration
RESOURCES
Table 1 Slider Resource Set Slider Resource Set\\∗(cO
Name Type Default Access XtNancestorSensitive Boolean TRUE G∗
XtNbackground Pixel White SGI†
XtNbackgroundPixmap Pixmap (none) SGI†
XtNdepth int (parent’s) GI
XtNdestroyCallback XtCallbackList NULL SI
XtNforeground Pixel Black SGI†
XtNgranularity int 1 SGI
XtNheight Dimension (calculated) SGI
XtNinitialDelay int 500 SGI XtNmappedWhenManaged Boolean TRUE SGI
XtNrepeatRate int 100 SGI
XtNsensitive Boolean TRUE GI∗
XtNsliderMax int 100 SGI
XtNsliderMin int 0 SGI
XtNsliderMoved XtCallbackList NULL SI
XtNsliderValue int 0 SGI
XtNuserData XtPointer NULL SGI
XtNwidth Dimension (calculated) SGI
XtNx Position 0 SGI
XtNy Position 0 SGI XtNforeground
This resource defines the foreground color for the widget.
See the note about the interaction of this resource with other color resources under the description of the XtNbackground resource in CORE(3W). XtNgranularity
Range of Values:
1 ≤ XtNgranularity ≤ (XtNsliderMax - XtNsliderMin)
Clicking SELECT on the Bar or Shaded Bar attempts to change the Current Value by the amount given in this resource. Dragging the Drag Box with SELECT changes the Current Value by this amount before the XtNsliderMoved callbacks are issued. XtNinitialDelay
Range of Values:
0 < XtNinitialDelay
This resource gives the time, in milliseconds, before the first action occurs when SELECT is pressed on the Bar or Shaded Bar. Note that millisecond timing precision may not be possible for all implementations, so the value may be rounded up to the nearest available unit by the toolkit. XtNorientation
Range of Values:
OL_HORIZONTAL/"horizontal"
OL_VERTICAL/"vertical"
This resource defines the direction for the visual presentation of the widget. XtNrepeatRate
Range of Values:
0 < XtNrepeatRate
This resource gives the time, in milliseconds, between repeated actions when SELECT is pressed on the Bar or Shaded Bar. Note that millisecond timing precision may not be possible for all implementations, so the value may be rounded up to the nearest available unit by the toolkit. XtNsliderMax
XtNsliderMin
Range of Values:
XtNsliderMin < XtNsliderMax
These two resources give the range of values tracked by the Slider widget. Mathematically, the range is open on the right; that is, the range is the following subset of the set of integers:
This is independent of the Drag Box displayed in the Slider
widget. The Slider widget is responsible for taking into account the size of the Drag Box when relating the physical range of movement to the range of values.
Figure 4 Drag Box Range of Movement XtNsliderMoved
This resource defines the callback list used when the Slider widget is manipulated. The call_data parameter is a pointer to the Current Value; an XtGetValue() inside the callback will return the previous an XtGetValue() inside the callback will return the previous value. XtNsliderValue
Range of Values:
XtNsliderMin ≤ XtNsliderValue ≤ XtNsliderMax
This resource gives the current position of the Drag Box, in the range [ XtNsliderMin , XtNsliderMax ]. The Slider widget keeps this resource up to date; however, an application can also get the current value through the XtNsliderMoved callbacks.
Sun Release 4.1 — Last change: 1/8/90