Topic: APLX Help : System Classes : List of Classes : Trackbar
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

Trackbar


Description

The Trackbar class implements a control which allows the user to move a slider to select a value. It is somewhat like a scroll bar in functionality, although the appearance is different. Under Windows, it also allows the programmer to display a current selection range, and to define the position of the tick marks along the control.

Trackbar properties

The main Trackbar properties are:

style: The basic style is 0 for Vertical and 1 for Horizontal. Under Windows, you can also add one of more of:

      0 = Ticks on bottom or right side. 
      2 = Ticks on top or left side.
      4 = Ticks on both sides.
      8 = Hide tick marks but display slider (Windows only).

value: The current slider position, as an integer scalar.

range: A two-element integer vector giving the minimum and maximum values (default 0 100)

selection: A two-element integer vector giving the 'selection' start and end, or an empty vector if there is no selection. This property is ignored under MacOS and Linux.

increment: A two-element vector giving the amount by which the value will change when the Page Up/Down keys are pressed, and the amount by which the value will change when the use clicks in the track or presses an arrow key. This property is ignored under MacOS because keyboard operation of the Trackbar is not supported.

sliderlen: The length of the slider in current scale units, or 0 to make it invisible. This property is ignored under MacOS and Linux.

tickinterval: The interval at which ticks appear, or 0 if just at Min and Max, or hidden. This property is ignored under MacOS.

ticks: An integer vector of user-defined tick positions (overrides tickinterval). This property is ignored under MacOS and Linux.

tickpos: A read-only matrix giving the values and positions of the tick marks. This property is not available under MacOS and Linux.

sliderwhere: A read-only property returning the position of the slider. This property is not available under MacOS and Linux.

The onChange callback is invoked when the user moves the slider.

Example

      ∇DEMO_Trackbar;VERSION;⎕IO;CB_TRACK;CB_CLOSE;X;DEMO
[1]  ⍝ Sample function demonstrating use of the Trackbar object
[2]  ⍝
[3]  ⍝ The windows version of this function demonstrates features not
[4]  ⍝ available on the Mac or Linux. The Mac/Linux Trackbar is very simple.
[5]   ⎕IO←1
[6]   VERSION←'⎕' ⎕WI 'version'
[7]   :If VERSION[2]=1
[8]     ⍝ Running under Windows:
[9]     DEMO←'⎕' ⎕NEW 'Dialog' ⋄ DEMO.title←'Trackbar Example' ⋄ DEMO.scale←1
[10]    DEMO.TBar.New 'Trackbar' ⋄ DEMO.TBar.where←2 1
[11]    DEMO.TBar.style←1 ⋄ DEMO.TBar.value←35
[12]    DEMO.Label1.New 'Label' ⋄ DEMO.Label1.where←1 1
[13]    DEMO.Label1.caption←'Move slider to set threshold'
[14]    DEMO.Label2.New 'Label' ⋄ DEMO.Label2.where←6 1 ⋄ DEMO.Label2.color←255
[15]    DEMO.Label2.caption←''
[16]    ⍝
[17]    ⍝ Create a callback which will run when the user closes the window
[18]    ⍝ This prevents the window being closed asynchronously
[19]    DEMO.onClose←'→'
[20]    ⍝
[21]    ⍝ Must show window now, otherwise it won't appear until after loop below
[22]    DEMO.Show
[23]    ⍝
[24]    :While 1
[25]    ⍝ Loop round until the CB_CLOSE callback has run
[26]    ⍝ Set some random value in the 'selection' property
[27]      DEMO.TBar.selection←(0,?80)
[28]      X←⎕WE 0.3 ⍝ Process events for up to 300 ms
[29]      :If (¯1↑DEMO.TBar.selection)<DEMO.TBar.value
[30]        DEMO.Label2.caption←''
[31]      :Else
[32]        DEMO.Label2.caption←'Threshold exceeded'
[33]      :End
[34]    :End
[35]  :Else
[36]    ⍝ Running under MacOS or Linux:
[37]    DEMO←'⎕' ⎕NEW 'Dialog' ⋄ DEMO.title←'Trackbar Example' ⋄ DEMO.scale←1
[38]    DEMO.TBar.New 'Trackbar' ⋄ DEMO.TBar.where←2 1
[39]    DEMO.TBar.style←1 ⋄ DEMO.TBar.value←35
[40]    DEMO.Lab.New 'Label' ⋄ DEMO.Lab.where←4 1
[41]    DEMO.Lab.caption←'Value: 35'
[42]    ⍝
[43]    ⍝
[44]    ⍝ Create a callback function which will run when user spins the control
[45]    0 0⍴⎕FX 'CB_TRACK;X' 'X←DEMO.TBar.value' 'DEMO.Lab.caption←"Value ",⍕1↑X'
[46]    DEMO.TBar.onChange←'CB_TRACK'
[47]    ⍝
[48]    ⍝ Wait for the user to close the window
[49]    0 0⍴⎕WE DEMO
[50]  :EndIf
      ∇

Properties

align anchors aquaadjust autodraw caption children class color data doublebuffered dragsource droptarget enabled events extent handle increment maxsize methods minsize name opened order pointer properties range scale selection self size sliderlen sourceformats style tabstop targetformats tickinterval tickpos ticks tie tooltip units value visible where winptr

Methods

Click Clienttoscreen Close Create Delete Draw Focus Hide New Open Paint Resize Screentoclient Send Set Show Trigger

Callbacks

onChange onClick onClose onDblClick onDestroy onDragDrop onDragEnd onDragEnter onDragLeave onDragOver onDragStart onFocus onHide onKeyDown onKeyPress onKeyUp onMouseDown onMouseMove onMouseUp onOpen onSend onShow onUnFocus


Topic: APLX Help : System Classes : List of Classes : Trackbar
[ Previous | Next | Contents | Index | APL Home ]