TSelex / TSelector
Fonte: source/classes/tselex.prg, source/classes/selector.prg
Inherits from: TControl (both)
TSelex is a segmented slider control with a draggable thumb that lets users pick from a discrete set of options. TSelector is a circular / radial dial control for selecting a value along an arc. Both provide visual selection with gradient rendering and keyboard/mouse interaction.
TSelex — Segmented Slider
Key DATA Members
DATA Type Description
aOptionsArray Array of option labels displayed along the track
bOnSelectCodeblock Code block fired when an option is selected
nOptionNumeric Currently selected option index (1-based)
nClrThumbNumeric Thumb color (RGB)
aGradOutArray Gradient for the outer track area
aGradInArray Gradient for the inner track area
nRoundNumeric Corner radius for the track background
Methods
Method Description
New( nRow, nCol, nW, nH, oWnd, lPixel, aOptions, bOnSelect, ... )Create a segmented slider with gradient and thumb parameters
SetOption( nOption )Programmatically select an option by index
GoNext( lRefresh )Move selection to the next option
GoPrev( lRefresh )Move selection to the previous option
AddOption( cText )Append a new option to the slider
InsertOption( cText, nPos )Insert an option at a specific position
DelOption( nOption )Remove an option by index
SetText( cText, nOption )Change the text of an existing option
TSelector — Radial Dial
Key DATA Members
DATA Type Description
nPosNumeric Current angular position in radians
nArcNumeric Total arc length in radians
nRadiusNumeric Dial radius in pixels
nMinNumeric Minimum value of the dial range
nMaxNumeric Maximum value of the dial range
nMarksNumeric Number of tick marks along the arc (0 = none)
lExactLogical Snap to nearest tick mark when dragging
Methods
Method Description
New( nRow, nCol, bSetGet, nAngle1, nAngle2, nMin, nMax, nMarks, lExact, oWnd, ... )Create a radial dial with angular range and value bounds
Set( nVal )Set the dial to a specific value
nGetPos( nVal )Convert a value to its angular position
nGetVal( nPos )Convert an angular position to its corresponding value
PlaceMark( nPos, nStep )Place a visual tick mark at a position
Example: Segmented Slider and Radial Dial
#include "FiveWin.ch"
function Main()
local oWnd, oSelex, oSelector, nOpt := 1, nVal := 5
DEFINE WINDOW oWnd TITLE "TSelex + TSelector Demo" SIZE 400, 300
@ 20, 20 SELEX oSelex VAR nOpt OPTIONS { "Low", "Med", "High" } ;
SIZE 200, 30 OF oWnd
@ 80, 20 SELECTOR oSelector VAR nVal ;
ANGLES 180, 540 MIN 0 MAX 10 ;
MARKS 11 EXACT OF oWnd SIZE 120, 120
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
TSelex tracks are rendered with two gradient layers (aGradOut = outer track, aGradIn = inner highlight).
The thumb is drawn as a rounded rectangle; its size is controlled by nWidthThumb / nHeightThumb.
TSelector uses an angular coordinate system. Angles are specified in degrees; the constructor converts them to radians internally.
When lExact is true and marks are defined, the dial snaps to the nearest mark on mouse release.
Both controls support keyboard navigation (arrow keys for TSelex, arrows for TSelector).
Veja Também ← tselector | tsemanticindex →