BBjWindow::addEditBoxSpinner

Description

In BBj 7.00 and higher, this method creates a BBjEditBoxSpinner on the BBjWindow.

Syntax

Return Value

Method

BBjEditBoxSpinner

addEditBoxSpinner(int ID, number x, number y, number w, number h, string text$)

BBjEditBoxSpinner

addEditBoxSpinner(int ID, number x, number y, number w, number h, string text$, string flags$)

BBjEditBoxSpinner

addEditBoxSpinner(int ID, number x, number y, number w, number h, BBjVector list!)

BBjEditBoxSpinner

addEditBoxSpinner(int ID, number x, number y, number w, number h, BBjVector list!, string flags$)

BBjEditBoxSpinner addEditBoxSpinner(int ID, string text$)
BBjEditBoxSpinner addEditBoxSpinner(int ID, string text$, string flags$)
BBjEditBoxSpinner addEditBoxSpinner(int ID, BBjVector list!)
BBjEditBoxSpinner addEditBoxSpinner(int ID, BBjVector list!, string flags$)
BBjEditBoxSpinner addEditBoxSpinner(string text$)
BBjEditBoxSpinner addEditBoxSpinner(string text$, string flags$)
BBjEditBoxSpinner addEditBoxSpinner(BBjVector list!)
BBjEditBoxSpinner addEditBoxSpinner(BBjVector list!, string flags$)

Parameters

Variable

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.

text$

Newline ($0A$) separated list

list!

BBjVector containing elements of the spinner's list.

flags$

Control flags, as follows:

Flag Description
$0001$
Sets the control to be initially disabled.
$0010$ Sets the control to be initially invisible.
$0020$ Designates the control to be part of a keyboard navigation group.
$0100$ Passes the Home and Delete keys as Keypress Notify events
$0800$ Draws a recessed client edge around the control.
$1000$ Draws a raised edge around the control.

Return Value

Returns the created object.

Remarks

A BBjEditBoxSpinner adds spinner functionality to a standard BBjEditBox control.

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 'Databound controls sample for bindRecordSet

USE java.util.HashMap

rem 'Obtain the instance of the BBjAPI object
let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI)"X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Set addWindow param values
X = 200
Y = 200
WIDTH = 350
HEIGHT = 250
TITLE$="Programming Languages"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$00010083$)

rem 'Create programming language data
myLangList! = myAPI!.makeVector()
myDescMap! = new HashMap()

dummy = fnAddLanguage(myLangList!,
:                     myDescMap!,
:                     "BBx",
:                     "A Business BASIC developed by BASIS International, Ltd.")

dummy = fnAddLanguage(myLangList!,
:                     myDescMap!,
:                     "Java",
:                     "An Object-Oriented C++ derivative developed by Sun Microsystems")

dummy = fnAddLanguage(myLangList!,
:                     myDescMap!,
:                     "C++",
:                     "A low-level object oriented language developed by Bjarne Stroustrup")

rem 'Create the spinner
myLangSpinner! = myWindow!.addEditBoxSpinner(101, 10, 10, 96, 25, myLangList!)

rem 'Create the edit box for the name
myLangName! = myWindow!.addEditBox(103, 10, 45, 80, 25, myLangList!.get(0))

rem 'Create the CEDIT for the description
firstDesc$ = myDescMap!.get(myLangList!.get(0))
myLangDesc! = myWindow!.addCEdit(104, 10, 80, 240, 160, firstDesc$)
myLangDesc!.setLineWrap(1)

rem 'Create a button for controlling the slideshow
mySlideshowButton! = myWindow!.addButton(102, 220, 10, 120, 25, "Start Slideshow")

rem 'Create a button for adding new languages
myAddButton! = myWindow!.addButton(105, 260, 80, 80, 25, "Add")

rem 'Create a button for deleting existing languages
myRemoveButton! = myWindow!.addButton(106, 260, 115, 80, 25, "Remove")

rem 'Set callbacks
myWindow!.setCallback(myWindow!.ON_CLOSE,"APP_CLOSE")
myLangSpinner!.setCallback(myLangSpinner!.ON_SPIN, "SPIN")
myAddButton!.setCallback(myAddButton!.ON_BUTTON_PUSH, "ADD_LANGUAGE")
myRemoveButton!.setCallback(myRemoveButton!.ON_BUTTON_PUSH, "REMOVE_LANGUAGE")
mySlideshowButton!.setCallback(myRemoveButton!.ON_BUTTON_PUSH, "SLIDESHOW")

process_events

rem 'Callback for the ON_SPIN event
SPIN:
    rem 'Get the BBjSpinEvent
    ev! = myAPI!.getLastEvent()

    rem 'Get the text from the event and associated description
    currentValue$ = ev!.getText()
    currentDesc$ = myDescMap!.get(currentValue$)

    rem 'Set the name and description in the edit box and CEdit
    myLangName!.setText(currentValue$)
    myLangDesc!.setText(currentDesc$)
return

rem 'Callback for myAddButton! ON_BUTTON_PUSH
ADD_LANGUAGE:
    rem 'Check for existence of language, no duplicates
    langName$ = myLangName!.getText().trim()
    if (myDescMap!.containsKey(langName$))
        A = MSGBOX("Already have a language " + langName$)
    else
        rem 'Otherwise, add it to the list
        langDesc$ = myLangDesc!.getText()

        rem 'Get a copy of the current list, and add the new langauge
        myLangList! = myLangSpinner!.getSpinList()
        dummy = fnAddLanguage(myLangList!, myDescMap!, langName$, langDesc$)

        rem 'Set the modified list to be the current list
        myLangSpinner!.setSpinList(myLangList!)

        rem 'Find the new item's index and set the spinner on the new value
        index = myLangList!.indexOf(langName$)
        myLangSpinner!.setListIndex(index)
    endif
return

REMOVE_LANGUAGE:
    rem 'Get a copy of the list and the current item's index
    myLangList! = myLangSpinner!.getSpinList()
    index = myLangSpinner!.getListIndex()

    rem 'Remove that index from the spin list
    myLangList!.remove(index)

    rem 'set the modified spin list on the spinner
    myLangSpinner!.setSpinList(myLangList!)
    value$ = myLangSpinner!.getText()
    myLangName!.setText(value$)
    myLangDesc!.setText(myDescMap!.get(value$))
return

SLIDESHOW:
    rem 'If we show "Start", start the slide show
    if mySlideshowButton!.getText().startsWith("Start")
        rem 'Set the opposite action text on the button
        mySlideshowButton!.setText("Stop Slideshow")

        rem 'Disable the editing buttons
        myAddButton!.setEnabled(0)
        myRemoveButton!.setEnabled(0)

        rem 'Add the timer for the slideshow
        myAPI!.createTimer("timer", 3, "SLIDESHOW_TIMER")
    else

        rem 'Set the opposite action text on the button
        mySlideshowButton!.setText("Start Slideshow")

        rem 'Remove the timer
        myAPI!.removeTimer("timer")

        rem 'Re-enable the editing buttons
        myAddButton!.setEnabled(1)
        myRemoveButton!.setEnabled(1)
    endif
return

SLIDESHOW_TIMER:
    rem 'Ignore leftover timer event
    if (! myAddButton!.isEnabled())
        rem 'If at the end
        if (myLangSpinner!.getListIndex() = myLangSpinner!.getSpinList().size() - 1)
            rem 'roll around to the top
            myLangSpinner!.setListIndex(0)
        else
            rem 'Otherwise, spin up
            myLangSpinner!.spin(1)
        endif

        rem 'Note: the spin() method does not fire an event
        rem 'Must synchronize the fields manually

        myLangName$ = myLangSpinner!.getText()
        myLangName!.setText(myLangName$)
        myLangDesc!.setText(myDescMap!.get(myLangName$))
    endif
return

APP_CLOSE:
release

rem 'Utility function to add a language to the list and the description to
rem 'the map.
DEF fnAddLanguage(p_list!, p_map!, p_lang$, p_langDesc$)
p_list!.add(p_lang$)
p_map!.put(p_lang$, p_langDesc$)
return 0
FNEND

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

BBjEditBoxSpinner

BBjEditBox

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