BBjFontChooser

Description

In BBj 7.00 and higher, the BBjFontChooser object provides methods for manipulating a GUI font chooser control and an interface to allow users to select fonts, for example, in a preferences dialog.

Implemented Interfaces

DropTarget, Focusable, TabTraversable

Creation

BBjAPI > BBjSysGui > BBjWindow > BBjFontChooser

A BBjFontChooser object is created through the following BBjWindow methods:

Return Value

Method

BBjFontChooser

addFontChooser(int ID, number x, number y, number width, int height)

BBjFontChooser

addFontChooser(int ID, number x, number y, number width, number height, BBjFont font)

BBjFontChooser

addFontChooser(int ID, number x, number y, number width, number height, BBjFont font, string flags)

BBjFontChooser addFontChooser(int ID)
BBjFontChooser addFontChooser(int ID, BBjFont font!)
BBjFontChooser addFontChooser(int ID, BBjFont font!, string flags)
BBjFontChooser addFontChooser()
BBjFontChooser addFontChooser(BBjFont font!)

BBjFontChooser

addFontChooser(BBjFont font!, string flags)

Methods of BBjFontChooser

Return Value

Method

void

approveSelection()

void

cancelSelection()

string

getApproveButtonText()

string

getCancelButtonText()

boolean

getControlButtonsAreShown()

BBjVector getFontFamilies()
BBjVector getFontSizes()

boolean

getFontsScaled()

string

getPreviewMessage()

BBjFont

getSelectedFont()

void

setApproveButtonText(string text)

void

setCancelButtonText(string text)

void

setControlButtonsAreShown(boolean show)

void setFontFamilies(BBjVector families)
void setFontSizes(BBjVector sizes)

void

setFontsScaled(boolean scale)

void

setPreviewMessage(string message)

void

setSelectedFont(BBjFont font)

Methods of BBjFontChooser implemented for DropTarget

Return Value Method
int getDropActions()
void setDropActions(int actions)
BBjVector getDropTypes()
void setDropTypes(BBjVector types)

Methods of BBjFontChooser implemented for Focusable

Return Value Method
boolean isFocusable()
void setFocusable(boolean focus)

Methods of BBjFontChooser implemented for TabTraversable

Return Value Method
boolean isTabTraversable()
void setTabTraversable(boolean trav)

Methods of BBjFontChooser inherited from BBjControl

Events

Callback Code

Object-oriented Event

Read Record Event

Code

ON_DROP_TARGET_DROP

BBjDropTargetDropEvent

Drop Target Drop Event

D

ON_FONTCHOOSER_APPROVE

BBjFontChooserApproveEvent FontChooser Approve Event x

ON_FONTCHOOSER_CANCEL

BBjFontChooserCancelEvent

FontChooser Cancel Event

x

ON_FONTCHOOSER_CHANGE

BBjFontChooserChangeEvent

FontChooser Change Event

x

ON_GAINED_FOCUS

BBjGainedFocusEvent

Control Focus Gained/Lost Event

f

ON_LOST_FOCUS

BBjLostFocusEvent

Control Focus Gained/Lost Event

f

ON_MOUSE_ENTER

BBjMouseEnterEvent

Mouse Enter/Exit Event

E

ON_MOUSE_EXIT

BBjMouseExitEvent

Mouse Enter/Exit Event

E

ON_POPUP_REQUEST

BBjPopupRequestEvent

Popup Request Event

r

ON_RIGHT_MOUSE_DOWN

BBjRightMouseDownEvent

Right Mouse Button Down Event

R

BUI logoCSS

The visual appearance of BUI controls is defined using CSS (cascading style sheets) rules. Easily change the default colors, border, and other settings by customizing these rules, all without changing any application code. See CSS API for a high-level overview of BUI CSS.

For a BBjFontChooser sample program, refer to (demo, code). The BBjFontChooser defines the following style names:

.BBjChooser

.BBjFontChooser

.BBjFontChooser.bbj-disabled

.BBjFontChooser-familyPanel

.BBjFontChooser-familyLabel

.BBjFontChooser-familyText

.BBjFontChooser-familyList

.BBjFontChooser-stylePanel

.BBjFontChooser-styleLabel

.BBjFontChooser-styleText

.BBjFontChooser-styleList

.BBjFontChooser-sizePanel

.BBjFontChooser-sizeLabel

.BBjFontChooser-sizeText

.BBjFontChooser-sizeList

.BBjFontChooser-preview

.BBjChooser-button-panel

.BBjChooser-button

.BBjChooser-approveButton

.BBjChooser-cancelButton

Remarks

If the ID parameter is not specified, a control ID is assigned dynamically using getAvailableControlID().

If the x, y, width, and height parameters are not specified, they are all initialized to 0. This is typically for use with DWC windows that dynamically arrange their contents (window creation flag $00100000$).

Constants inherited from BBjControl

Example

rem ' BBjFontChooser

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
width = 500, height = 400
title$ = "BBjFontChooser"
window! = sysgui!.addWindow(25,25,width+50,height+100,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
fontchooser! = window!.addFontChooser(101,25,25,width,height)
fontchooser!.setCallback(fontchooser!.ON_FONTCHOOSER_CHANGE,"change")
fontchooser!.setCallback(fontchooser!.ON_FONTCHOOSER_APPROVE,"approve")
fontchooser!.setCallback(fontchooser!.ON_FONTCHOOSER_CANCEL,"cancel")

rem 'fontchooser!.setCallback(fontchooser!.ON_GAINED_FOCUS,"event")
rem 'fontchooser!.setCallback(fontchooser!.ON_LOST_FOCUS,"event")
rem 'fontchooser!.setCallback(fontchooser!.ON_MOUSE_ENTER,"event")
rem 'fontchooser!.setCallback(fontchooser!.ON_MOUSE_EXIT,"event")
button! = window!.addButton(1,width+25-120,height+50,120,25,"Random",$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"random")
status! = window!.addStatusBar(99)
fonts! = sysgui!.getSystemMetrics().getFontFamilies()
gosub random
process_events

eoj:
release

status:
    status!.setText(status$)
    print status$
return

resize:
    event! = sysgui!.getLastEvent()
    fontchooser!.setSize(event!.getWidth()-50,event!.getHeight()-80)
    button!.setLocation(event!.getWidth()-120-25,event!.getHeight()-30)
    status$ = event!.getEventName()+" width="+str(event!.getWidth())+",height="+str(event!.getHeight())
    gosub status
return

random:
    font! = sysgui!.makeFont(fonts!.get(rnd(fonts!.size())),rnd(72),rnd(4))
    fontchooser!.setSelectedFont(font!)
    status$ = "setSelectedFont "+str(font!)
    gosub status
return

change:
    event! = sysgui!.getLastEvent()
    event$ = event!.getEventName()
    status$ = event$+": "+str(event!.getFont())
    gosub status
return

approve:
    event! = sysgui!.getLastEvent()
    event$ = event!.getEventName()
    status$ = event$+": "+str(event!.getFont())
    gosub status
return

cancel:
    event! = sysgui!.getLastEvent()
    event$ = event!.getEventName()
    print event$
    status$ = event$
    gosub status
return

event:
    event! = sysgui!.getLastEvent()
    event$ = event!.getEventName()
    print event$
    status$ = event$
    gosub status
return

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjFont

CALLBACK Verb - Register BBj Subroutine

DWC Component: dwc-font-chooser

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