Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

PtSlider

A widget for choosing a value from a range

Class hierarchy:

PtWidgetPtBasicPtGaugePtSlider

For more information, see the diagram of the widget hierarchy.

PhAB icon:

PtSlider button in PhAB

Public header:

<photon/PtSlider.h>

Description:

A PtSlider widget lets you choose numerical values within a specified range from minimum to maximum.


PtSlider


A PtSlider widget.

A slider consists of a narrow trough (representing the total range), a movable handle, and optional tick marks. The handle — which appears on top of the trough — represents the current position within the range. You can specify the size of the handle by setting Pt_ARG_SLIDER_HANDLE_WIDTH.

If you want to create your own style of slider, you can specify:


Custom PtSlider


A PtSlider widget with a custom handle and trough.

You need to set Pt_ARG_SLIDER_FLAGS appropriately to use these images.

Mouse actions

When you press the mouse button, the result depends on the location of the pointer.

If the pointer is: Then:
In the trough The handle moves up or down one slider multiple
On the handle A drag is started

If you hold down the Ctrl key and click in the trough, the handle jumps to the position of the pointer.

Keyboard actions

If you press: The handle moves:
Up one increment
Down one increment
Right one increment
Left one increment
Pg Up Up/right one “page”
Pg Down Down/left one “page”
Home To the minimum value
End To the maximum value

where:

New resources:

Resource C type Pt type Default
Pt_ARG_SLIDER_FLAGS short int Flag 0
Pt_ARG_SLIDER_HANDLE_COLOR PgColor_t Scalar PgGrey(217)
Pt_ARG_SLIDER_HANDLE_WIDTH short int Scalar 15
Pt_ARG_SLIDER_IMAGE PhImage_t * Image NULL
Pt_ARG_SLIDER_INCREMENT unsigned short Scalar 1
Pt_ARG_SLIDER_MULTIPLE unsigned short Scalar 10
Pt_ARG_SLIDER_TICK_MAJOR_DIV unsigned long Scalar 10
Pt_ARG_SLIDER_TROUGH_IMAGE1 PhImage_t * Image NULL
Pt_ARG_SLIDER_TROUGH_IMAGE2 PhImage_t * Image NULL
Pt_CB_SLIDER_MOVE PtCallback_t * Link NULL

Pt_ARG_SLIDER_FLAGS

C type Pt type Default
short int Flag 0

Valid flags:

Pt_SLIDER_IMAGE
Use the image specified by Pt_ARG_SLIDER_IMAGE as the slider handle.
Pt_SLIDER_TROUGH_IMAGE
Use the images specified by Pt_ARG_SLIDER_TROUGH_IMAGE1 and Pt_ARG_SLIDER_TROUGH_IMAGE2 as the trough.

Pt_ARG_SLIDER_HANDLE_COLOR

C type Pt type Default
PgColor_t Scalar PgGrey(217)

The color of the slider handle. See PgColor_t in the Photon Library Reference.

Pt_ARG_SLIDER_HANDLE_WIDTH

C type Pt type Default
short int Scalar 15

The width of the slider handle.

Pt_ARG_SLIDER_IMAGE

C type Pt type Default
PhImage_t * Image NULL

You can use this resource to create your own style of slider. It specifies an image to be used as the slider's handle. For more information about the PhImage_t structure, see the Photon Library Reference.


Note: The widget ignores this resource unless you set Pt_SLIDER_IMAGE in Pt_ARG_SLIDER_FLAGS.

Pt_ARG_SLIDER_INCREMENT

C type Pt type Default
unsigned short Scalar 1

The slider increment when you press the cursor keys.

Pt_ARG_SLIDER_MULTIPLE

C type Pt type Default
unsigned short Scalar 10

The slider increment when you click the pointer button in the trough, or you press Pg Up or Pg Down.

Pt_ARG_SLIDER_TICK_MAJOR_DIV

C type Pt type Default
unsigned long Scalar 10

The number of major divisions.

Pt_ARG_SLIDER_TROUGH_IMAGE1, Pt_ARG_SLIDER_TROUGH_IMAGE2

C type Pt type Default
PhImage_t * Image NULL

You can use these resources to create your own style of slider. Use them to specify the images to be displayed as the trough. The slider becomes the same size as Pt_ARG_SLIDER_TROUGH_IMAGE1.


Note: The widget ignores these resources unless you set Pt_SLIDER_TROUGH_IMAGE in Pt_ARG_SLIDER_FLAGS.

If you specify just Pt_ARG_SLIDER_TROUGH_IMAGE1, it's used as the background for the entire slider.

If you specify both images:


Note: If the image specified by Pt_ARG_SLIDER_TROUGH_IMAGE2 is a different size than the one specified by Pt_ARG_SLIDER_TROUGH_IMAGE1, you should use a non-transparent color to avoid drawing artifacts when the handle position changes.

By default, the maximum value is on the right side of a horizontal slider. The widget displays the first image to the left of the handle, and the second image to the right. If you set Pt_GAUGE_MAX_ON_LEFT in the Pt_ARG_GAUGE_FLAGS resource (inherited from PtGauge), the widget displays the first image to the right of the handle, and the second image to the left.

You get similar results with a vertical slider if you set Pt_GAUGE_MAX_ON_TOP.


Note: The images aren't rotated if you change the slider's Pt_ARG_ORIENTATION resource (inherited from PtGauge). You should create horizontal images for a horizontal slider, and vertical images for a vertical slider.

For more information about the PhImage_t structure, see the Photon Library Reference.

Pt_CB_SLIDER_MOVE

C type Pt type Default
PtCallback_t * Link NULL

A list of PtCallback_t structures that define the callbacks that the slider invokes when the handle position changes.

If you've set the Pt_CALLBACKS_ACTIVE bit set in the widget's Pt_ARG_FLAGS resource, these callbacks are also invoked when your application changes the handle position by calling PtSetResource() or PtSetResources().

Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:

reason
Pt_CB_SLIDER_MOVE
reason_subtype
One of the following:
event
A pointer to a PhEvent_t structure that describes the event that caused the callback to be invoked, or NULL if there's no event.
cbdata
A pointer to a PtSliderCallback_t structure that contains at least the following member:
int position;
A value corresponding to the slider handle's location.

These callbacks should return Pt_CONTINUE.

Inherited resources:

If the widget modifies an inherited resource, the “Default override” column indicates the new value. This modification affects any subclasses of the widget.

Resource Inherited from Default override
Pt_ARG_ANCHOR_FLAGS PtWidget
Pt_ARG_ANCHOR_OFFSETS PtWidget
Pt_ARG_AREA PtWidget
Pt_ARG_BANDWIDTH_THRESHOLD PtBasic Not used by this class.
Pt_ARG_BASIC_FLAGS PtBasic
Pt_ARG_BEVEL_WIDTH PtWidget 1
Pt_ARG_BITMAP_CURSOR PtWidget
Pt_ARG_BEVEL_COLOR PtBasic
Pt_ARG_BEVEL_CONTRAST PtBasic
Pt_ARG_COLOR PtBasic Pg_GRAY
Pt_ARG_CONTRAST PtBasic
Pt_ARG_CURSOR_COLOR PtWidget
Pt_ARG_CURSOR_TYPE PtWidget
Pt_ARG_DARK_BEVEL_COLOR PtBasic
Pt_ARG_DARK_FILL_COLOR PtBasic
Pt_ARG_DATA PtWidget
Pt_ARG_DIM PtWidget
Pt_ARG_EFLAGS PtWidget
Pt_ARG_EXTENT PtWidget
Pt_ARG_FILL_COLOR PtBasic
Pt_ARG_FILL_PATTERN PtBasic
Pt_ARG_FLAGS PtWidget |=Pt_GETS_FOCUS
Pt_ARG_GAUGE_FLAGS PtGauge |= Pt_GAUGE_MAX_ON_TOP
Pt_ARG_GAUGE_FONT PtGauge
Pt_ARG_GAUGE_H_ALIGN PtGauge Not used by this class.
Pt_ARG_GAUGE_V_ALIGN PtGauge Not used by this class.
Pt_ARG_GAUGE_VALUE PtGauge
Pt_ARG_GAUGE_VALUE_PREFIX PtGauge Not used by this class.
Pt_ARG_GAUGE_VALUE_SUFFIX PtGauge Not used by this class.
Pt_ARG_GRID_LAYOUT_DATA PtWidget
Pt_ARG_HEIGHT PtWidget
Pt_ARG_HELP_TOPIC PtWidget
Pt_ARG_HIGHLIGHT_ROUNDNESS PtBasic
Pt_ARG_INLINE_COLOR PtBasic
Pt_ARG_LAYOUT_DATA PtWidget
Pt_ARG_LIGHT_BEVEL_COLOR PtBasic
Pt_ARG_LIGHT_FILL_COLOR PtBasic
Pt_ARG_MARGIN_HEIGHT PtBasic 0
Pt_ARG_MARGIN_WIDTH PtBasic 0
Pt_ARG_MAXIMUM PtGauge
Pt_ARG_MAXIMUM_DIM PtWidget
Pt_ARG_MINIMUM PtGauge
Pt_ARG_MINIMUM_DIM PtWidget
Pt_ARG_ORIENTATION PtGauge Pt_HORIZONTAL
Pt_ARG_OUTLINE_COLOR PtBasic
Pt_ARG_POINTER PtWidget
Pt_ARG_POS PtWidget
Pt_ARG_RESIZE_FLAGS PtWidget
Pt_ARG_ROW_LAYOUT_DATA PtWidget
Pt_ARG_STYLE PtBasic
Pt_ARG_TRANS_PATTERN PtBasic
Pt_ARG_USER_DATA PtWidget
Pt_ARG_WIDTH PtWidget
Pt_CB_ACTIVATE PtBasic
Pt_CB_ARM PtBasic
Pt_CB_BLOCKED PtWidget
Pt_CB_DESTROYED PtWidget
Pt_CB_DISARM PtBasic
Pt_CB_DND PtWidget
Pt_CB_FILTER PtWidget
Pt_CB_GOT_FOCUS PtBasic
Pt_CB_HOTKEY PtWidget
Pt_CB_IS_DESTROYED PtWidget
Pt_CB_LOST_FOCUS PtBasic
Pt_CB_MENU PtBasic
Pt_CB_OUTBOUND PtWidget
Pt_CB_RAW PtWidget
Pt_CB_REALIZED PtWidget
Pt_CB_REPEAT PtBasic
Pt_CB_UNREALIZED PtWidget