BBjMDI::addToolButton

Description

In BBj 3.0 and higher, this method adds a tool button control to the BBjMDI window.

Syntax

Return Value

Method

BBjToolButton

addToolButton(int ID, int x, int y, int width, int height, string title)

BBjToolButton

addToolButton(int ID, int x, int y, int width, int height, string title, string flags)

Parameters

Variable

Description

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

Ignored.

y

Ignored.

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 - Draw Bitmapped Image (SYSGUI)) 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.

$0004$

Sets the control to be initially checked.

$0010$

Sets the control to be initially invisible.

$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.

Example

rem 'retrieve the MDIProxy

rem 'MDI! = BBjAPI().getMDI()
rem 'create an MDI Window
rem 'window! = mdi!.makeMDIWindow(50, 50, 800, 600, "MDI Window")
mdi!.createMDIWindow(50, 50, 800, 600, "MDI Window")

rem 'add menu items to the MDI Window
rem 'menuBar! = mdi!.addMenuBar()
AMenu! = menuBar!.addMenu(20,"Sample menu")
MenuItem201! = AMenu!.addMenuItem(201, "Set BBj Command line params")
MenuItem202! = AMenu!.addMenuItem(202, "Set Program Command line params")
MenuItem203! = AMenu!.addMenuItem(203, "Run Program")
MenuItem204! = AMenu!.addMenuItem(204, "add toolbars")
MenuItem205! = AMenu!.addMenuItem(205, "Enable MDI WindowsMenu")

rem 'set callbacks
rem 'MenuItem201!.setCallback(menuBar!.ON_MENU_ITEM_SELECT, "selected_201")
MenuItem202!.setCallback(menuBar!.ON_MENU_ITEM_SELECT, "selected_202")
MenuItem203!.setCallback(menuBar!.ON_MENU_ITEM_SELECT, "selected_203")
MenuItem204!.setCallback(menuBar!.ON_MENU_ITEM_SELECT, "selected_204")
MenuItem205!.setCallback(menuBar!.ON_MENU_ITEM_SELECT, "selected_205")
CALLBACK(ON_CLOSE,APP_CLOSE,mdi!.MDI_CONTEXT)

rem 'Process Events
rem 'process_events
rem 'Callback routine called when the user closes the application window
rem 'APP_CLOSE:
    mdi!.closeAll()
return

selected_201:
    print (0,ERR = doReturn) 'GETS'("","commandLineParams: ", cmdLineParams$)
    read cmdLineParams$
return

selected_202:
    print (0,ERR = doReturn) 'GETS'("","ProgramParams: ", programParams$)
    read programParams$
return

selected_203:
    filename$ = fileopen("choose file","/","","")
    if filename$ <> "::CANCEL::"
        command$ = "bbj " + cmdLineParams$ + " " + filename$ + " - " + programParams$ + " &"
        print "scalling: " , command$
        x = scall(command$)
    endif
return

selected_204:
    tb1! = mdi!.addToolButton(101,0,0,20,20,"1",$4000$)
    tb2! = mdi!.addToolButton(102,0,0,20,20,"2",$4000$)
    tb3! = mdi!.addToolButton(103,0,0,20,20,"3",$4000$)
    tb1!.setCallback(tb1!.ON_TOOL_BUTTON_PUSH,"tb1")
    tb2!.setCallback(tb1!.ON_TOOL_BUTTON_PUSH,"tb2")
    tb3!.setCallback(tb1!.ON_TOOL_BUTTON_PUSH,"tb3")
    menuItem204!.setEnabled( 0 )
return

TB1:
    print "1"
return

TB2:
    print "2"
return

TB3:
    print "3"
return

selected_205:
    mdi!.enableMDIWindowMenu()
    menuItem205!.setEnabled( 0 )
return

doReturn:
return

See Also

BBjAPI

BBjMDI

Object Variables

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