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")
    myColorChooser!.setCancelButtonText("Reset")
FI

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$)
    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!)
FI
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$)
    myColorChooser!.setColor(myCEdit!.getForeColor())
ELSE
    myColorChooser!.setColor(myCEdit!.getBackColor())
FI
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())
    myColorChooser!.setColor(myFG!.getBackColor())
    myColorChooser!.setApproveButtonText(FORE_TEXT$)
    myDialog!.setVisible(1)
FI
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())
    myColorChooser!.setColor(myBG!.getBackColor())
    myColorChooser!.setApproveButtonText(BACK_TEXT$)
    myDialog!.setVisible(1)
FI
RETURN

DO_CLOSE:
    RELEASE

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjColorChooser

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