BBjWindow::addHorizontalSlider

Description

In BBj 7.00 and higher, this method adds a horizontal slider control to the BBjWindow.

Syntax

Return Value

Method

BBjSlider

addHorizontalSlider(int ID, number x, number y, number w, number h)

BBjSlider

addHorizontalSlider(int ID, number x, number y, number w, number h, string flags)

BBjSlider addHorizontalSlider(int ID)
BBjSlider addHorizontalSlider(int ID, string flags)
BBjSlider addHorizontalSlider()

BBjSlider

addHorizontalSlider(string flags)

Parameters

Parameter

Description

ID

Control ID number. It must be an integer between 1 and 32767 and be unique within a given top-level window.

x

Horizontal position of the upper-left corner of the control in current units.

y

Vertical position of the upper-left corner of the control in current units.

width

Width of the control in current units.

height

Height of the control in current units.

flags

Control flags, as follows:

Flag Description
$0001$ Sets the control to be initially disabled.
$0010$ Sets the control to be initially invisible.
$0800$ Draws a recessed client edge around the control.
$1000$ Draws a raised edge around the control.

 

Return Value

Returns the created horizontal BBjSlider object.

Remarks

If the ID parameter is not specified, a control ID is assigned dynamically using getAvailableControlID().

If the x, y, width, and height parameters are not specified, they are all initialized to 0. This is typically for use with DWC windows that dynamically arrange their contents (window creation flag $00100000$).

Example

rem ' BBjWindow::addHorizontalSlider

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(10,10,520,240,"Horizontal BBjSlider",$2009008f$)
window!.setCallback(sysgui!.ON_CLOSE,"eoj")
slider! = window!.addHorizontalSlider(100,10,10,500,50)
print "getOrientation()",slider!.getOrientation()," ",
switch slider!.getOrientation()
    case slider!.HORIZONTAL; print "HORIZONTAL"; break
    case slider!.VERTICAL; print "VERTICAL"; break
    case default; print "UNKNOWN"; break
swend
slider!.setBackColor(BBjColor.YELLOW)
slider!.setCallback(sysgui!.ON_CONTROL_SCROLL,"scroll")
slider!.setCallback(slider!.ON_GAINED_FOCUS,"event")
slider!.setCallback(slider!.ON_LOST_FOCUS,"event")
slider!.setCallback(slider!.ON_MOUSE_ENTER,"event")
slider!.setCallback(slider!.ON_MOUSE_EXIT,"event")
slider!.setCallback(slider!.ON_POPUP_REQUEST,"event")
slider!.setCallback(slider!.ON_RIGHT_MOUSE_DOWN,"event")
popup! = sysgui!.addPopupMenu()
item1! = popup!.addMenuItem(-1,"Popup Item 1")
item2! = popup!.addMenuItem(-1,"Popup Item 2")
item3! = popup!.addMenuItem(-1,"Popup Item 3")
slider!.setPopupMenu(popup!)
window!.addStaticText(201,5,105,60,25,"Minimum:",$8000$)
minimum = slider!.getMinimum()
minimum! = window!.addInputN(101,70,100,60,25,$$,"-###,##0",$$,minimum,minimum)
minimum!.setCallback(sysgui!.ON_EDIT_MODIFY,"minimum")
window!.addStaticText(202,5,135,60,25,"Maximum:",$8000$)
maximum = slider!.getMaximum()
maximum! = window!.addInputN(102,70,130,60,25,$$,"-###,##0",$$,maximum,maximum)
maximum!.setCallback(sysgui!.ON_EDIT_MODIFY,"maximum")
window!.addStaticText(203,5,165,60,25,"Value:",$8000$)
value = slider!.getValue()
value! = window!.addInputN(103,70,160,60,25,$$,"###,##0",$$,0,value)
value!.setCallback(sysgui!.ON_EDIT_MODIFY,"value")
label! = window!.addStaticText(204,130,105,125,25,"Tick Spacing",$8000$)
font! = label!.getFont()
font! = sysgui!.makeFont(font!.getName(),font!.getSize()+2,font!.BOLD)
label!.setFont(font!)
window!.addStaticText(205,130,135,60,25,"Major:",$8000$)
major = 20
major! = window!.addInputN(104,195,130,60,25,$$,"-###,##0",$$,major,major)
major!.setCallback(sysgui!.ON_EDIT_MODIFY,"major")
slider!.setMajorTickSpacing(major)
window!.addStaticText(206,130,165,60,25,"Minor:",$8000$)
minor = 5
minor! = window!.addInputN(105,195,160,60,25,$$,"-###,##0",$$,minor,minor)
minor!.setCallback(sysgui!.ON_EDIT_MODIFY,"minor")
slider!.setMinorTickSpacing(minor)
labels! = window!.addCheckBox(106,270,100,120,25,"Paint Labels",$0004$)
labels!.setCallback(sysgui!.ON_CHECK_ON,"labels_on")
labels!.setCallback(sysgui!.ON_CHECK_OFF,"labels_off")
slider!.setPaintLabels(labels!.isSelected())
ticks! = window!.addCheckBox(107,270,130,120,25,"Paint Ticks",$0004$)
ticks!.setCallback(sysgui!.ON_CHECK_ON,"ticks_on")
ticks!.setCallback(sysgui!.ON_CHECK_OFF,"ticks_off")
slider!.setPaintTicks(ticks!.isSelected())
snap! = window!.addCheckBox(108,270,160,120,25,"Snap To Ticks",$0004$)
snap!.setCallback(sysgui!.ON_CHECK_ON,"snap_on")
snap!.setCallback(sysgui!.ON_CHECK_OFF,"snap_off")
slider!.setSnapToTicks(snap!.isSelected())
width = slider!.getWidth()
width! = window!.addInputNSpinner(109,390,100,60,25,1,width)
width!.setToolTipText("Width")
width!.setValue(width)
width!.setCallback(sysgui!.ON_SPIN,"width")
height = slider!.getHeight()
height! = window!.addInputNSpinner(110,460,100,50,25,1,99)
height!.setToolTipText("Height")
height!.setValue(height)
height!.setCallback(sysgui!.ON_SPIN,"height")
labels! = window!.addCheckBox(111,390,130,120,25,"Custom Labels")
labels!.setCallback(sysgui!.ON_CHECK_ON,"custom_labels")
labels!.setCallback(sysgui!.ON_CHECK_OFF,"default_labels")
inverted! = window!.addCheckBox(112,390,160,120,25,"Inverted")
inverted!.setCallback(sysgui!.ON_CHECK_ON,"inverted_on")
inverted!.setCallback(sysgui!.ON_CHECK_OFF,"inverted_off")
slider!.setInverted(inverted!.isSelected())
enabled! = window!.addCheckBox(113,390,190,120,25,"Enabled",$0004$)
enabled!.setCallback(enabled!.ON_CHECK_ON,"setEnabled")
enabled!.setCallback(enabled!.ON_CHECK_OFF,"setEnabled")
statusbar! = window!.addStatusBar(99,$$)
statusbar!.setMinimumHeight(24)
vector! = bbjapi().makeVector()
vector!.add(530)
statusbar!.setSegments(vector!)
statusbar!.setTextAt(0,"Labels: "+slider!.getLabels().toString())
dim event$:tmpl(sysgui)
process_events

eoj:
release

scroll:
    event! = sysgui!.getLastEvent()
    event$ = sysgui!.getLastEventString()
    e$ = sysgui!.getLastEvent().toString(), e$ = e$(1,pos("@"=e$)-1)
    msg$ = e$+" code="+event.code$+" context="+str(event.context)+" id="+str(event.id)+" flags="+str(event.flags)+" x="+str(event.x)+" y="+str(event.y)+" pos="+str(event!.getPosition())+" adj? "+Boolean.toString(event!.isAdjusting())
    print msg$
    statusbar!.setTextAt(0,msg$)
    value = event!.getPosition()
    value!.setValue(value)
return

minimum:
    n = minimum!.getValue()
    if (n<>minimum) then
        slider!.setMinimum(n)
        minimum = n
        value!.setValue(slider!.getValue())
    endif
return

maximum:
    n = maximum!.getValue()
    if (n<>maximum) then
        slider!.setMaximum(n)
        maximum = n
        value!.setValue(slider!.getValue())
    endif
return

value:
    slider!.setValue(value!.getValue())
return

major:
    n = major!.getValue()
    if (n<>major) then
        slider!.setMajorTickSpacing(n)
        major = n
        value!.setValue(slider!.getValue())
        statusbar!.setTextAt(0,"Labels: "+slider!.getLabels().toString())
    endif
return

minor:
    n = minor!.getValue()
    if (n<>minor) then
        slider!.setMinorTickSpacing(n)
        minor = n
        value!.setValue(slider!.getValue())
        statusbar!.setTextAt(0,"Labels: "+slider!.getLabels().toString())
    endif
return

labels_on:
    slider!.setPaintLabels(1)
return

labels_off:
    slider!.setPaintLabels(0)
return

ticks_on:
    slider!.setPaintTicks(1)
return

ticks_off:
    slider!.setPaintTicks(0)
return

snap_on:
    slider!.setSnapToTicks(1)
return

snap_off:
    slider!.setSnapToTicks(0)
return

custom_labels:
    labels! = new java.util.TreeMap()
    n = rnd(10)
    range = slider!.getMaximum() - slider!.getMinimum()
    for i=1 to n
        label = slider!.getMinimum() + rnd(range)
        labels!.put(label,chr(rnd(26)+asc("A")))
    next i
    slider!.setLabels(labels!)
    statusbar!.setTextAt(0,"Labels: "+labels!.toString())
    statusbar!.setTextAt(0,"Labels: "+slider!.getLabels().toString())
return

default_labels:
    labels! = new java.util.TreeMap()
    slider!.setLabels(labels!)
    statusbar!.setTextAt(0,"Labels: "+slider!.getLabels().toString())
return

inverted_on:
    slider!.setInverted(1)
return

inverted_off:
    slider!.setInverted(0)
return

setEnabled:
    slider!.setEnabled(enabled!.isSelected())
return

event:
    event! = sysgui!.getLastEvent()
    event$ = event!.toString(), event$ = event$(1,pos("@"=event$)-1)
    control! = event!.getControl()
    control$ = control!.toString(), control$ = control$(1,pos("@"=control$)-1)
    print control$," ",event$
return

width:
    event! = sysgui!.getLastEvent()
    width = num(event!.getText())
    slider!.setSize(width,height)
return

height:
    event! = sysgui!.getLastEvent()
    height = num(event!.getText())
    slider!.setSize(width,height)
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.