BBjFontChooserCancelEvent::getFontChooser


Description

In BBj 7.0 and later, this method returns the BBjFontChooser on which this event occurred.

Syntax

Return Value

Method

BBjFontChooser

getFontChooser()

Parameters

None.

Return Value

Returns a BBjFontChooser on which this event occurred.

Remarks

None.

Example

REM getFontChooser

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=100
Y=100
WIDTH=400
HEIGHT=250
TITLE$="BBjFontChooser"

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

REM Add a font chooser on the window
myFontChooser! = myWindow!.addFontChooser(101,0,0,WIDTH,HEIGHT)

REM Register the CALLBACK routines
CALLBACK(ON_FONTCHOOSER_APPROVE,OK,mySysGui!.getContext(),myFontChooser!.getID())
CALLBACK(ON_FONTCHOOSER_CANCEL,CANCEL,mySysGui!.getContext(),myFontChooser!.getID())
CALLBACK(ON_RESIZE,RESIZE,mySysGui!.getContext())
CALLBACK(ON_CLOSE,EOJ,mySysGui!.getContext())

REM Process Events
PROCESS_EVENTS

RESIZE:
myFontChooser!.setSize(myWindow!.getWidth(),myWindow!.getHeight())
RETURN

REM ' OK was pressed
OK:
TITLE$ = "Selected Font (OK)"
GOTO MESSAGE

REM ' OK was pressed
Cancel:
TITLE$ = "Selected Font (Cancel)"
GOTO MESSAGE

REM ' Print message and exit
MESSAGE:
gosub FontInfo
message$="<html><head> <!-- <DEFANGED_STYLE type='text/css'>p{font:"+html$+"} --> </DEFANGED_STYLE></head><body><p>"+info$+"</p></body></html>"
LET X=MSGBOX(MESSAGE$,0,TITLE$)
RELEASE

FontInfo:
FontChooser! = mySysGui!.getLastEvent().getFontChooser()
Font!=FontChooser!.getSelectedFont()
name$=Font!.getName()
style=Font!.getStyle()
size=Font!.getSize()
if style=0 then
style$="Plain"
html$=str(size)+"px "+name$
else
style$=""
if fnIsBitSet(style,Font!.FONT_BOLD) then
style$=style$+"Bold "
endif
if fnIsBitSet(style,Font!.FONT_ITALIC) then
style$=style$+"Italic "
endif
style$=cvs(style$,3)
html$=cvs(style$,8)+" "+str(size)+"px "+name$
endif
info$=name$+" "+style$+" "+str(size)
return

def fnIsBitSet(value,bit)
return sgn(dec(and(bin(value,4),bin(bit,4))))
fnend

REM ' Exit without selection
EOJ:
RELEASE

See Also

BBjAPI

BBj Object Syntax

BBjFontChooserApproveEvent

BBj Object Diagram for an illustration of the relationship between BBjObjects.



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.