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.
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.
∇DEMO_Trackbar;VERSION;⎕IO;CB_TRACK;CB_CLOSE;X;DEMO  ⍝ Sample function demonstrating use of the Trackbar object  ⍝  ⍝ The windows version of this function demonstrates features not  ⍝ available on the Mac or Linux. The Mac/Linux Trackbar is very simple.  ⎕IO←1  VERSION←'⎕' ⎕WI 'version'  :If VERSION=1  ⍝ Running under Windows:  DEMO←'⎕' ⎕NEW 'Dialog' ⋄ DEMO.title←'Trackbar Example' ⋄ DEMO.scale←1  DEMO.TBar.New 'Trackbar' ⋄ DEMO.TBar.where←2 1  DEMO.TBar.style←1 ⋄ DEMO.TBar.value←35  DEMO.Label1.New 'Label' ⋄ DEMO.Label1.where←1 1  DEMO.Label1.caption←'Move slider to set threshold'  DEMO.Label2.New 'Label' ⋄ DEMO.Label2.where←6 1 ⋄ DEMO.Label2.color←255  DEMO.Label2.caption←''  ⍝  ⍝ Create a callback which will run when the user closes the window  ⍝ This prevents the window being closed asynchronously  DEMO.onClose←'→'  ⍝  ⍝ Must show window now, otherwise it won't appear until after loop below  DEMO.Show  ⍝  :While 1  ⍝ Loop round until the CB_CLOSE callback has run  ⍝ Set some random value in the 'selection' property  DEMO.TBar.selection←(0,?80)  X←⎕WE 0.3 ⍝ Process events for up to 300 ms  :If (¯1↑DEMO.TBar.selection)<DEMO.TBar.value  DEMO.Label2.caption←''  :Else  DEMO.Label2.caption←'Threshold exceeded'  :End  :End  :Else  ⍝ Running under MacOS or Linux:  DEMO←'⎕' ⎕NEW 'Dialog' ⋄ DEMO.title←'Trackbar Example' ⋄ DEMO.scale←1  DEMO.TBar.New 'Trackbar' ⋄ DEMO.TBar.where←2 1  DEMO.TBar.style←1 ⋄ DEMO.TBar.value←35  DEMO.Lab.New 'Label' ⋄ DEMO.Lab.where←4 1  DEMO.Lab.caption←'Value: 35'  ⍝  ⍝  ⍝ Create a callback function which will run when user spins the control  0 0⍴⎕FX 'CB_TRACK;X' 'X←DEMO.TBar.value' 'DEMO.Lab.caption←"Value ",⍕1↑X'  DEMO.TBar.onChange←'CB_TRACK'  ⍝  ⍝ Wait for the user to close the window  0 0⍴⎕WE DEMO  :EndIf ∇
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
onChange onClick onClose onDblClick onDestroy onDragDrop onDragEnd onDragEnter onDragLeave onDragOver onDragStart onFocus onHide onKeyDown onKeyPress onKeyUp onMouseDown onMouseMove onMouseUp onOpen onSend onShow onUnFocus
Copyright © 1996-2010 MicroAPL Ltd