BBjFontChooser

Creation Path


BBjAPI

|

+--BBjSysGui

|

+--BBjWindow

|

+--BBjFontChooser

 

Description

In BBj 7.0 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

A BBjFontChooser object is created through the following BBjWindow methods:

 

Return Value

Method

BBjFontChooser

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

BBjFontChooser

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

BBjFontChooser

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

Methods of BBjFontChooser

Return Value

Method

void

approveSelection()

void

cancelSelection()

string

getApproveButtonText()

string

getCancelButtonText()

boolean

getControlButtonsAreShown()

boolean

getFontsScaled()

string

getPreviewMessage()

BBjFont

getSelectedFont()

void

setApproveButtonText(string text)

void

setCancelButtonText(string text)

void

setControlButtonsAreShown(boolean show)

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 p_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_FILECHOOSER_APPROVE

BBjFileChooserApproveEvent

FileChooser Approve Event

x

ON_FILECHOOSER_CANCEL

BBjFileChooserCancelEvent

FileChooser Cancel Event

x

ON_FILECHOOSER_CHANGE

BBjFileChooserChangeEvent

FileChooser 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

CSS

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

None.

Constants inherited from BBjControl

Example

REM Add a font 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=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,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:
REM Display a message notifying of the cancel
MESSAGE$="No font was chosen!"
LET X=MSGBOX(MESSAGE$)
RELEASE

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjFont

CALLBACK Verb - Register BBj Subroutine

Focusable

TabTraversable

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



______________________________________________________________________________________

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