BBjFontChooser::getPreviewMessage

Description

In BBj 7.0 and higher, this method returns the BBjFontChooser's preview message.

Syntax

Return Value

Method

string

getPreviewMessage()

Parameters

None.

Return Value

Returns the BBjFontChooser's preview message.

Remarks

None.

Example

rem 'Get font chooser preview message

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 'Set a Locale-sensitive preview message
Locale$ = stbl("!LOCALE")
Message$="The quick brown fox jumps over the lazy dog."
if (pos("de"=Locale$) = 1) then
:  Message$="Franz jagt im komplett verwahrlosten Taxi quer durch Bayern."
if (pos("es"=Locale$) = 1) then
:  Message$="El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja."
if (pos("fr"=Locale$) = 1) then
:  Message$="Servez à ce monsieur une bière et des kiwis.";
:  Message$="Voix ambiguë d'un coeur qui au zéphyr préfère les jattes de kiwis."
if (pos("it"=Locale$) = 1) then
:  Message$="Cantami o diva del pelide Achille l'ira funesta. 123456890"
if (pos("nl"=Locale$) = 1) then
:  Message$="Pa's wijze lynx bezag vroom het fikse aquaduct."
if (pos("sv"=Locale$) = 1) then
:  Message$="Flygande bäckasiner söka hwila på mjuka tuvor 1234567890"

myFontChooser!.setPreviewMessage(Message$)
Message$ = myFontChooser!.getPreviewMessage()

rem 'Register the CALLBACK routines
CALLBACK(ON_FONTCHOOSER_APPROVE,APPROVE,mySysGui!.getContext(),myFontChooser!.getID())
CALLBACK(ON_FONTCHOOSER_CANCEL,CANCEL,mySysGui!.getContext(),myFontChooser!.getID())
CALLBACK(ON_RESIZE,RESIZE,mySysGui!.getContext())
CALLBACK(ON_CLOSE,CANCEL,mySysGui!.getContext())

rem 'Process Events
process_events

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

rem 'Callback routine called when the fontchooser's OK button is pressed
APPROVE:
    rem 'Display a message with the approprate font
    gosub FontInfo
    message$="<html><head><style type = 'text/css'>p{font:"+html$+"}</style></head><body><p>"+info$+"</p></body></html>"
    let X = MSGBOX(MESSAGE$,0,"Selected Font")
release

FontInfo:
    Font! = myFontChooser!.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 'Callback routine called when the fontchooser's Cancel button is
rem 'pressed or the window is closed without selecting a font
CANCEL:
release

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjFontChooser

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