BBjColorChooser::getCancelButtonText

Description

In BBj 7.0 and higher, this method returns the BBjColorChooser's cancel button text, which by default is "OK."

Syntax

Return Value

Method

string

getCancelButtonText()

Parameters

None.

Return Value

Returns the BBjColorChooser's, which by default is "OK."

Remarks

None.

Example

rem 'Add a color chooser 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 = 0
Y = 0
WIDTH = 350
HEIGHT = 250
TITLE$ = "BBj Text"

FORE_TEXT$ = "Set Foreground"
BACK_TEXT$ = "Set Background"

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

rem 'create the target controls for color selection
myWindow! = mySysGui!.addWindow(X, Y, WIDTH, HEIGHT, TITLE$,$00010083$)
myCEdit! = myWindow!.addCEdit(101, 10, 10, 190, 190, "Type here")

rem 'myFG! will represent the foreground color
myFG! = myWindow!.addStaticText(102, 234, 99, 32, 32, $$)
myFG!.setBackColor(myCEdit!.getForeColor())

rem 'myBG! will represent the background color
myBG! = myWindow!.addStaticText(103, 234, 141, 32, 32, $$)
myBG!.setBackColor(myCEdit!.getBackColor())

rem 'Create an invisible dialog for colorchooser in new context
mySysGui!.setContext(1)
myDialog! = mySysGui!.addWindow(X+WIDTH,Y,WIDTH,HEIGHT,"Choose Color",$00090012$)

rem 'Add a color chooser on the window
myColorChooser! = myDialog!.addColorChooser(101,0,0,350,250)

rem 'Set cancel button text
if (myColorChooser!.getCancelButtonText() <> "Reset") then
    myColorChooser!.setCancelButtonText("Reset")
endif

rem 'Register the CALLBACK routines
CALLBACK(ON_MOUSE_DOWN,CLICK,myWindow!.getContextID(),myWindow!.getID())
CALLBACK(ON_COLORCHOOSER_APPROVE,APPROVED,myDialog!.getContextID(),myColorChooser!.getID())
CALLBACK(ON_COLORCHOOSER_CANCEL,RESET,myDialog!.getContextID(),myColorChooser!.getID())
CALLBACK(ON_CLOSE,DO_CLOSE,myWindow!.getContextID())
CALLBACK(ON_CLOSE,CANCELLED,myDialog!.getContextID())

rem 'Process Events
process_events

rem 'Callback routine called when the colorchooser's OK button is pressed
APPROVED:
    myDialog!.setVisible(0)

    rem 'If foreground colorchooser, set the foreground
    if (myColorChooser!.getApproveButtonText() = FORE_TEXT$) then
        color! = myColorChooser!.getColor()
        myFG!.setBackColor(color!)
        myCEdit!.setForeColor(color!)
    else
        rem 'else if background colorchooser, set the background
        color! = myColorChooser!.getColor()
        myBG!.setBackColor(color!)
        myCEdit!.setBackColor(color!)
    endif
return

rem 'Callback routine called when the colorchooser's Cancel button is
rem 'pressed or the window is closed without selecting a color
CANCELLED:
    myDialog!.setVisible(0)
return

RESET:
    if (myColorChooser!.getApproveButtonText() = FORE_TEXT$) then
        myColorChooser!.setColor(myCEdit!.getForeColor())
    else
        myColorChooser!.setColor(myCEdit!.getBackColor())
    endif
return

rem 'Callback routine called when the color squares are clicked.
CLICK:
    ev! = myAPI!.getLastEvent()
    xclick = ev!.getX()
    yclick = ev!.getY()

    rem 'If in the foreground square, popup a foreground color chooser
    if (xclick >= myFG!.getX() AND xclick <= myFG!.getX() + myFG!.getWidth() AND yclick >= myFG!.getY() AND yclick <= myFG!.getY() + myFG!.getHeight()) then
        myColorChooser!.setColor(myFG!.getBackColor())
        myColorChooser!.setApproveButtonText(FORE_TEXT$)
        myDialog!.setVisible(1)
    endif

    rem 'If in the background square, popup a background color chooser
    if (xclick >= myBG!.getX() AND xclick <= myBG!.getX() + myBG!.getWidth() AND yclick >= myBG!.getY() AND yclick <= myBG!.getY() + myBG!.getHeight()) then
        myColorChooser!.setColor(myBG!.getBackColor())
        myColorChooser!.setApproveButtonText(BACK_TEXT$)
        myDialog!.setVisible(1)
    endif
return

DO_CLOSE:
release

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjColorChooser

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