BBjDrawPanel::setOpaque

Description

In BBj 16.0 and higher, this method sets text to be opaque or transparent. Text plotted to the BBjDrawPanel using BBjDrawPanel::drawText may be rendered in different ways, depending on the BBjDrawPanel::setOpaque setting. Text can be opaque (the BBjDrawPanel::setBackColor color is plotted in a rectangle behind the text) or transparent (objects behind the text can be seen in the spaces between the letters). Text is not resized if the drawing is resized (the text is not scaled), so that a 10-point font will always be shown as a 10-point font, regardless of changes to the drawing surface. However, opaque text may be scaled, if desired.

Syntax

Return Value

Method

void

setOpaque(int style)

Parameters

Variable

Description

style

Text opacity style:

  • 0 = Transparent, not scaled
  • 1 = Opaque, not scaled
  • 2 = Opaque, scaled (default)

Return Value

None.

Remarks

None.

Example

rem ' BBjDrawPanel::setOpaque
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
fonts! = sysgui!.getSystemMetrics().getFontFamilies()
width = 450, height = 600
title$ = "BBjDrawPanel::setOpaque"
window! = sysgui!.addWindow(20,20,width,height,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
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")
opaque0! = window!.addRadioButton(102,10,330,100,25,"Transparent",$0020$)
opaque0!.setCallback(opaque0!.ON_CHECK_ON,"opaque0")
opaque1! = window!.addRadioButton(103,110,330,100,25,"Opaque",$0020$)
opaque1!.setCallback(opaque1!.ON_CHECK_ON,"opaque1")
opaque2! = window!.addRadioButton(104,210,330,120,25,"Opaque scaled",$0024$)
opaque2!.setCallback(opaque2!.ON_CHECK_ON,"opaque2")
opaque! = bbjapi().makeVector()
opaque!.add(opaque0!)
opaque!.add(opaque1!)
opaque!.add(opaque2!)
window!.addRadioGroup(opaque!)
button! = window!.addButton(1,345,330,80,25,"Random",$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"random")
drawpanel! = window!.getDrawPanel()
textcolor! = BBjColor.BLACK
backcolor! = BBjColor.YELLOW
gosub drawText
process_events
eoj:
  release
opaque0:
  drawpanel!.setOpaque(0)
  gosub drawText
return
opaque1:
  drawpanel!.setOpaque(1)
  gosub drawText
return
opaque2:
  drawpanel!.setOpaque(2)
  gosub drawText
return
random:
  font! = sysgui!.makeFont(fonts!.get(rnd(fonts!.size())),rnd(72),rnd(4))
  textcolor! = sysgui!.makeColor(rnd(255),rnd(255),rnd(255))
  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!)
  drawpanel!.setTextColor(textcolor!)
  drawpanel!.clearDrawing(window!.getBackColor())
  drawpanel!.setBackColor(backcolor!)
  drawpanel!.drawText(10,500,font$) 
  print "BBjDrawPanel::getTextColor = ",drawpanel!.getTextColor()
return

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjDrawPanel

OPAQUE Mnemonic - Set SYSGUI Text Transparency Mode

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