BBjDrawPanel::drawText

Description

In BBj 16.0 and higher, this method draws the specified text starting at position (x,y) on the BBjDrawPanel using the current text color and font.

Syntax

Return Value

Method

void

drawText(number x, number y, string text)

Parameters

Variable

Description

x

Horizontal location of the base of the beginning of the text.

y

Vertical location of the base of the beginning of the text.

text

Text to be drawn.

Return Value

None.

Remarks

None.

Example

rem ' BBjDrawPanel::drawText

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
fonts! = sysgui!.getSystemMetrics().getFontFamilies()
width = 1200, height = 600
title$ = "BBjDrawPanel::drawText"
window! = sysgui!.addWindow(20,20,width,height,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setTrack(0)
window!.setSize(450,height)
font! = sysgui!.makeFont(fonts!.get(rnd(fonts!.size())),rnd(72),rnd(4))
chooser! = window!.addFontChooser(101,25,25,400,300,font!)
chooser!.setCallback(chooser!.ON_FONTCHOOSER_CHANGE,"font")
chooser!.setCallback(chooser!.ON_FONTCHOOSER_APPROVE,"font")
button! = window!.addButton(1,345,330,80,25,"Random",$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"random")
drawpanel! = window!.getDrawPanel()
gosub drawText
process_events

eoj:
release

random:
    font! = sysgui!.makeFont(fonts!.get(rnd(fonts!.size())),rnd(72),rnd(4))
    print "setSelectedFont ",font!
    chooser!.setSelectedFont(font!)
    gosub drawText
return

font:
    event! = sysgui!.getLastEvent()
    event$ = event!.toString(), event$ = event$(1,pos("@"=event$)-1)
    font! = event!.getFont()
    print event$,": ",font!
    gosub drawText
return

drawText:
    font$ = font!.getName()+" "+str(font!.getSize())
    style$ = chr(font!.getStyle())
    if dec(and(style$,$01$)) then font$ = font$ + " bold"
    if dec(and(style$,$02$)) then font$ = font$ + " italic"
    if dec(and(style$,$10$)) then font$ = font$ + " underline"
    window!.setFont(font!)
    color! = sysgui!.makeColor(rnd(255),rnd(255),rnd(255))
    drawpanel!.setTextColor(color!)
    drawpanel!.clearDrawing()
    drawpanel!.drawText(10,500,font$)
    print "BBjDrawPanel::getTextColor = ",drawpanel!.getTextColor()
return

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjDrawPanel

PLOTTEXT Mnemonic - Plot Text (SYSGUI)

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