BBjWindow::addToolButton

Description

Adds a tool button control in the BBjWindow.

Syntax

Return Value

Method

BBjToolButton

addToolButton(int ID, number x, number y, number w, number h, string title)

BBjToolButton

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

BBjToolButton

addToolButton(int ID, string title)

BBjToolButton

addToolButton(int ID, string title, string flags)

BBjToolButton

addToolButton(string title)

BBjToolButton

addToolButton(string title, 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 tab control.

y

Vertical position of the upper-left corner of the tab control.

width

Width of the control in current units.

height

Height of the control in current units.

title

Tool button title. The title can be ordinary text or "BITMAP=", followed by a path name. (PREFIX is not searched.) If the BITMAP= syntax is used, an attempt is made to locate and load a bitmapped image (see the 'IMAGE' mnemonic) from that file. If it succeeds, the image is drawn in the button. Otherwise the text, complete with "BITMAP=", is displayed. The title or bitmap can be changed at any time with the 'TITLE' mnemonic. Including the '&' before a character in the title causes it to be an accelerator.

flags

Control flags, as follows:

Flag Description
$0001$ Sets the control to be initially disabled.
$0002$ Places title text to the left of the control.
$0004$ Sets the control to be initially checked.
$0010$ Sets the control to be initially invisible.
$0020$ Designates the control to be part of a keyboard navigation group.
$0400$ Creates a "click on, click off" toggle button.
$0800$ Draws a recessed client edge around the control.
$1000$ Draws a raised edge around the control.
$2000$ Left-justifies tool button text.
$4000$ Centers tool button text.
$8000$ Right-justifies tool button text.

Return Value

Returns the created BBjToolButton object.

Remarks

A tool button:

  • Displays additional information (mouse position, mouse button, Ctrl and Shift key status).

  • Can display either text or a picture (bitmap).

  • Can operate normally or as a toggle (click on, click off).

  • Can use the 'COLORSET' or 'OPTIONS' mnemonic to modify the displayed color.

  • Cannot be focused with keyboard navigation commands.

  • Does not include a "focus rectangle" when it has focus.

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 'Add a tool button to a window

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 = 10
Y = 10
WIDTH = 200
HEIGHT = 200
TITLE$="BBj Window"

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

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

rem 'Add a tool button on the window
myToolButton! = myWindow!.addToolButton(101,50,100,90,30,"Tool Button",$0800$)

rem 'Register the CALLBACK routines
CALLBACK(ON_TOOL_BUTTON_PUSH,TOOL_BUTTON_PUSHED,mySysGui!.getContext(),myToolButton!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

rem 'Process Events
process_events

rem 'Callback routine called when the tool button is pressed
TOOL_BUTTON_PUSHED:
    rem 'Create the BBjColor Object using colorNum constant
    myColorRed! = mySysGui!.makeColor(mySysGui!.RED)

    rem 'Set the tool button forecolor to RED
    myToolButton!.setForeColor(myColorRed!)
return

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

'TBUTTON' Mnemonic

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