BBjTree::getNodeFont

Description

In BBj 24.01 and higher, this method returns the font of a BBjTree node.

Syntax

Return Value Method
BBjFont getNodeFont(int ID)

Parameters

Parameter Description
ID Specifies the node ID.

Return Value

Returns the font of a BBjTree node.

Remarks

If no font has been set on the node, this method returns BBjTree::getFont()

Example

rem ' BBjTree::getNodeFont

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = "BBjTree"
window! = sysgui!.addWindow(50,50,450,650,title$,$20090083$)
window!.setBackColor(BBjColor.WHITE)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
window!.setCallback(window!.ON_KEYPRESS,"keypress")

rem ' Define tree data
dim music$[2,4]
music$[0,0]="The Beatles"
music$[0,1]="Hey Jude"
music$[0,2]="Let It Be"
music$[0,3]="Twist and Shout"
music$[0,4]="Yesterday"
music$[1,0]="Paul Simon"
music$[1,1]="Bridge Over Troubled Water"
music$[1,2]="Hearts and Bones"
music$[1,3]="Kathy's Song"
music$[1,4]="The Sound of Silence"
music$[2,0]="Willie Nelson"
music$[2,1]="Always On My Mind"
music$[2,2]="Getting Over You"
music$[2,3]="Old Fords and Natural Stone"
music$[2,4]="This Morning"

dim image$[2,4]
rem ' fill in filenames here to set node-specific icons
image$[0,0]=""; rem "The Beatles"
image$[0,1]=""; rem "Hey Jude"
image$[0,2]=""; rem "Let It Be"
image$[0,3]=""; rem "Twist and Shout"
image$[0,4]=""; rem "Yesterday"
image$[1,0]=""; rem "Paul Simon"
image$[1,1]=""; rem "Bridge Over Troubled Water"
image$[1,2]=""; rem "Hearts and Bones"
image$[1,3]=""; rem "Kathy's Song"
image$[1,4]=""; rem "The Sound of Silence"
image$[2,0]=""; rem "Willie Nelson"
image$[2,1]=""; rem "Always On My Mind"
image$[2,2]=""; rem "Getting Over You"
image$[2,3]=""; rem "Old Fords and Natural Stone"
image$[2,4]=""; rem "This Morning"

families! = new BBjVector()
restore families
while 1
  dread family$,err=*break
  if family$ = "" then break
  families!.add(family$)
wend
sizes! = new BBjVector()
restore sizes
while 1
  dread size,err=*break
  if size = 0 then break
  sizes!.add(size)
wend

rem ' Create and populate tree
tree! = window!.addTree(101,25,25,400,400)
tree!.setFont(sysgui!.makeFont("Comic Sans MS",16,2))

tree!.putClientProperty("JTree.lineStyle","Angled")
tree!.putClientProperty("JTree.lineStyle","Horizontal")
rem tree!.putClientProperty("JTree.lineStyle","None")

gosub editable1
rem tree!.setTreeEditable(tree!.isEditable())

color! = tree!.getSelectedBackColor()
tree!.setSelectedBackColor(BBjColor.RED)
print "selected background color changed from ",color!," to ",
print tree!.getSelectedBackColor()
color! = tree!.getSelectedForeColor()
tree!.setSelectedForeColor(BBjColor.YELLOW)
print "selected foreground color changed from ",color!," to ",
print tree!.getSelectedForeColor()

rem ' https://docs.oracle.com/javase/tutorial//uiswing/components/tree.html
tree!.putClientProperty("JTree.lineStyle","None")

rem ' https://dwc.style/docs/#/dwc/BBjTree
tree!.setProperty("connect",false)

tree!.setSelectionMode(tree!.CONTIGUOUS_TREE_SELECTION)

tree!.setCollapsedIcon("collapsed.gif",err=*next)
tree!.setExpandedIcon("expanded.gif",err=*next)
tree!.setLeafIcon("leaf.png",err=*next)
tree!.setSelectedIcon("selected.png",err=*next)

im! = sysgui!.getImageManager()

collapsed$ = "com/basis/bbj/images/collapsed.gif"
collapsed! = im!.loadImageFromServerJar(collapsed$,err=*next)
if collapsed!<>null() then tree!.setCollapsedIcon(collapsed!)

expanded$ = "com/basis/bbj/images/expanded.gif"
expanded! = im!.loadImageFromServerJar(expanded$,err=*next)
if expanded!<>null() then tree!.setExpandedIcon(expanded!)

leaf$ = "com/basis/bbj/images/leaf.png"
leaf! = im!.loadImageFromServerJar(leaf$,err=*next)
if leaf!<>null() then tree!.setLeafIcon(leaf!)

selected$ = "com/basis/bbj/images/selected.png"
selected! = im!.loadImageFromServerJar(selected$,err=*next)
if selected!<>null() then tree!.setSelectedIcon(selected!)

root = 0
node = 0
root$ = "Musical Tree"
root$ = "<html><h2>" + root$ + " " + str(root) + "</h2></html>"
tree!.setRoot(root,root$)
tree!.setToolTipText(root,root$)
color! = sysgui!.makeColor(rnd(255),rnd(255),rnd(255))
tree!.setNodeForeColor(root,color!)
gosub font; tree!.setNodeFont(root,font!)
print node," ",tree!.getNodeFont(root)
for artist = 0 to 2
  node = node + 1
  artist$ = "<html><h3>"+music$[artist,0]+" "+str(node)+"</h3></html>"
  tree!.addExpandableNode(node,root,artist$)
  tree!.expandNode(node)
  tree!.setToolTipText(node,artist$)
  color! = sysgui!.makeColor(rnd(255),rnd(255),rnd(255))
  tree!.setNodeForeColor(node,color!)
  gosub font; tree!.setNodeFont(node,font!)
  print node," ",tree!.getNodeFont(node)
  if len(image$[artist,0]) then
     tree!.setNodeIcon(node,image$[artist,0])
  endif
  parent = node
  for song = 1 to 4
    node = node + 1
    song$ = music$[artist,song]+" "+str(node)
    tree!.addNode(node,parent,song$)
    tree!.setToolTipText(node,song$)
    color! = sysgui!.makeColor(rnd(255),rnd(255),rnd(255))
    tree!.setNodeForeColor(node,color!)
    gosub font; tree!.setNodeFont(node,font!)
    print node," ",tree!.getNodeFont(node)
    if len(image$[artist,song]) then
       tree!.setNodeIcon(node,image$[artist,song])
    endif
  next song
next artist

lastNode = node

rem tree!.expandTreeFromNode(0)

tree!.setCallback(tree!.ON_TREE_SELECT,"select")
tree!.setCallback(tree!.ON_TREE_DESELECT,"event")
tree!.setCallback(tree!.ON_TREE_EXPAND,"event")
tree!.setCallback(tree!.ON_TREE_COLLAPSE,"event")
tree!.setCallback(tree!.ON_TREE_EDIT_STOP,"event")
tree!.setCallback(tree!.ON_TREE_MOUSE_UP,"event")
tree!.setCallback(tree!.ON_TREE_MOUSE_DOWN,"event")
tree!.setCallback(tree!.ON_TREE_DOUBLE_CLICK,"event")
tree!.setCallback(tree!.ON_TREE_RIGHT_MOUSE_UP,"event")
tree!.setCallback(tree!.ON_TREE_RIGHT_MOUSE_DOWN,"event")
tree!.setCallback(tree!.ON_CONTROL_SCROLL,"scroll")
tree!.setCallback(tree!.ON_POPUP_REQUEST,"popup")

allNodes! = window!.addMenuButton(1,25,450,100,25,"All Nodes",$$)
allNodes!.setCallback(allNodes!.ON_BUTTON_PUSH,"allNodes")
expNodes! = window!.addMenuButton(2,125,450,100,25,"Expanded",$$)
expNodes!.setCallback(expNodes!.ON_BUTTON_PUSH,"expNodes")

backColor! = window!.addMenuButton(3,125,500,100,25,"backColor",$$)
backColor!.setCallback(backColor!.ON_BUTTON_PUSH,"backColor")

treeFont! = window!.addMenuButton(4,225,500,100,25,"treeFont",$$)
treeFont!.setCallback(treeFont!.ON_BUTTON_PUSH,"treeFont")

nodeFont! = window!.addMenuButton(5,325,500,100,25,"nodeFont",$$)
nodeFont!.setCallback(nodeFont!.ON_BUTTON_PUSH,"nodeFont")

flags$ = iff(tree!.isEnabled(),$0004$,$0000$)
enabled! = window!.addCheckBox(201,25,500,100,25,"Enabled",flags$)
enabled!.setCallback(enabled!.ON_CHECK_OFF,"enabled0")
enabled!.setCallback(enabled!.ON_CHECK_ON,"enabled1")

flags$ = iff(tree!.isEditable(),$0004$,$0000$)
editable! = window!.addCheckBox(202,25,550,100,25,"Editable",flags$)
editable!.setCallback(editable!.ON_CHECK_OFF,"editable0")
editable!.setCallback(editable!.ON_CHECK_ON,"editable1")

flags$ = iff(tree!.isOpaque(),$0004$,$0000$)
opaque! = window!.addCheckBox(203,125,550,100,25,"Opaque",flags$)
opaque!.setCallback(opaque!.ON_CHECK_OFF,"opaque0")
opaque!.setCallback(opaque!.ON_CHECK_ON,"opaque1")

flags$ = iff(info(3,6)="6",$0004$,$0000$)
noedge! = window!.addCheckBox(204,225,550,100,25,"No Edge",flags$)
noedge!.setCallback(noedge!.ON_CHECK_OFF,"noedge0")
noedge!.setCallback(noedge!.ON_CHECK_ON,"noedge1")

setImageSize! = window!.addCheckBox(205,25,600,150,25,"setImageSize",$0000$)
setImageSize!.setCallback(setImageSize!.ON_CHECK_ON,"setImageSize")
setImageSize!.setCallback(setImageSize!.ON_CHECK_OFF,"clearImageSize")

width = 32
height = 32
width! = window!.addInputN(206,155,600,75,25,$$,"###0",$$,width,height)
width!.setToolTipText("Width")
height! = window!.addInputN(207,255,600,75,25,$$,"###0",$$,width,height)
height!.setToolTipText("Height")

event = 0

dim event$:tmpl(sysgui),generic$:noticetpl(0,0)

process_events

eoj:
  release

families:
data "Arial", "Brush Script MT", "Courier New", "Garamond", "Georgia"
data "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana", ""
sizes:
data 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 0

font:
  family$ = families!.get(rnd(families!.size()))
  size = sizes!.get(rnd(sizes!.size()))
  style = rnd(4)
  font! = sysgui!.makeFont(family$,size,style)
return

treeFont:
  for node = 0 to lastNode
      gosub font; tree!.setNodeFont(node,null())
      print node," ",font!
  next node
  gosub font; tree!.setFont(font!)
return

nodeFont:
  for node = 0 to lastNode
      gosub font; tree!.setNodeFont(node,font!)
      print node," ",font!
  next node
return

backColor:
   color! = bbjapi().makeColor(rnd(255),rnd(255),rnd(255))
   print "setBackColor ",color!
   tree!.setBackColor(color!)
return

default:
   color! = null()
   print "setBackColor ",color!
   tree!.setBackColor(color!)
return

scrollable:
  print "Scrollable values:"
  print "isHorizontalScrollBarVisible=",tree!.isHorizontalScrollBarVisible()
  print "getHorizontalScrollBarWidth=",tree!.getHorizontalScrollBarWidth()
  print "getHorizontalScrollBarHeight=",tree!.getHorizontalScrollBarHeight()
  print "getHorizontalScrollBarPosition=",tree!.getHorizontalScrollBarPosition()
  print "isVerticalScrollBarVisible=",tree!.isVerticalScrollBarVisible()
  print "getVerticalScrollBarWidth=",tree!.getVerticalScrollBarWidth()
  print "getVerticalScrollBarHeight=",tree!.getVerticalScrollBarHeight()
  print "getVerticalScrollBarPosition=",tree!.getVerticalScrollBarPosition()
return

select:
  gosub event
  node = event!.getNodeID()
  if node=root then return
  tree!.selectNode(node)
return

event:
  event = event + 1
  event! = sysgui!.getLastEvent()
  event$ = sysgui!.getLastEventString()
  msg$ = event!.getEventName()+" "+str(event)+":"
  if event.code$ = "N" then
     generic$ = notice(sysgui,event.x)
     dim notice$:noticetpl(generic.objtype,event.flags)
     notice$ = generic$
     fields = pos($0a$=fattr(notice$,""),1,0)
     dim field$:"name["+str(fields)+"]:c(1*)"
     let field$=fattr(notice$,"")
     for field=1 to fields
       name$ = field.name$[field]
       info$ = fattr(notice$,name$,$$)
       msg$ = msg$ + " "+name$+"="
       if asc(info$)=1 then
          msg$ = msg$ + field(notice$,name$)
       else
          msg$ = msg$ + str(nfield(notice$,name$))
       endif
     next field
  endif
  event! = sysgui!.getLastEvent()
  msg$ = msg$ + " isDown="+Boolean.toString(event!.isDown(err=*next))
  msg$ = msg$ + " Selected node: "+str(tree!.getSelectedNode())
  print msg$
  System.err.println(msg$)
return

scroll:
  event = event + 1
  event! = sysgui!.getLastEvent()
  print event!.getEventName(),event,": orientation=",str(event!.getOrientation()),
  print " position=",str(event!.getPosition())," adjusting=",str(event!.isAdjusting())
return

popup:
  event! = sysgui!.getLastEvent()
  event$ = sysgui!.getLastEventString()
  print event!.getEventName()," X=",str(event.x)," Y=",str(event.y)
  print ""
return

resize:
  event! = sysgui!.getLastEvent()
  print "Resized; width=",str(event!.getWidth()),", height=",str(event!.getHeight())
  tree!.setSize(event!.getWidth()-50,tree!.getHeight())
return

allNodes:
  node = tree!.getSelectedNode()
  if node < 0 then i = msgbox("No selected node"); return
  count = tree!.getNumChildren(node)
  if count = 0 then i = msgbox("Node "+str(node)+" has no children"); return
  vector! = bbjapi().makeVector()
  for i = 0 to count - 1
      child = tree!.getChildAt(node,i)
      vector!.add(child)
  next i
  i = msgbox(vector!.toString(),0,"All child nodes of "+str(node))
return

expNodes:
  node = tree!.getSelectedNode()
  if node < 0 then i = msgbox("No selected node"); return
  count = tree!.getNumChildren(node)
  if count = 0 then i = msgbox("Node "+str(node)+" has no children"); return
  vector! = bbjapi().makeVector()
  expanded! = tree!.getExpandedNodes()
  for i = 0 to count - 1
      child = tree!.getChildAt(node,i)
      if expanded!.contains(child) then vector!.add(child)
  next i
  i = msgbox(vector!.toString(),0,"Expanded child nodes of "+str(node))
return

enabled0:
  tree!.setEnabled(0)
return

enabled1:
  tree!.setEnabled(1)
return

editable0:
  tree!.setEditable(0)
  tree!.setTreeEditable(0)
return

editable1:
  tree!.setEditable(1)
  tree!.setTreeEditable(1)
return

opaque0:
  tree!.setOpaque(0)
return

opaque1:
  tree!.setOpaque(1)
return

noedge0:
  tree!.setNoEdge(0)
print "getNoEdge ",tree!.getNoEdge()
return

noedge1:
  tree!.setNoEdge(1)
print "getNoEdge ",tree!.getNoEdge()
return

setImageSize:
  width = width!.getValue()
  height = height!.getValue()
  print "setImageSize",width,height
  tree!.setImageSize(width,height)
  print "getImageWidth",tree!.getImageWidth()
  print "getImageHeight",tree!.getImageHeight()
return

clearImageSize:
  print "clearImageSize"
  tree!.clearImageSize()
  print "getImageWidth",tree!.getImageWidth()
  print "getImageHeight",tree!.getImageHeight()
return

keypress:
  print fill(72,"=")
  event$ = sysgui!.getLastEventString()
  key=event.id,flags$=event.flags$
  print "Window Keypress: ",hta(event.id$)," Flags: ",
  print hta(event.flags$)+": """+cvs(event.id$,16)+"""",
  if key>255 then print "" else gosub key
  event! = sysgui!.getLastEvent()
  print "getOriginalControl(): ",event!.getOriginalControl()
  print "getKeyChar():",num(event!.getKeyChar())
  print "getKeyCode():",num(event!.getKeyCode()),": ",
  keycode=event!.getKeyCode()
  gosub keycode
  print "isShiftDown(): ",event!.isShiftDown()
  print "isControlDown(): ",event!.isControlDown()
  print "isAltDown(): ",event!.isAltDown()
  print "isCmdDown(): ",event!.isCmdDown()
  print fill(72,"=")
return
key:
  print ": ",
  if asc(and(flags$,$01$)) then print "SHIFT+",
  if asc(and(flags$,$02$)) then print "CTRL+",;key=key+64
  if asc(and(flags$,$04$)) then print "ALT+",
  if asc(and(flags$,$08$)) then print "CMD+",
  print cvs(chr(key),16)
return
keycode:
  keycode$=bin(keycode,2)
  if asc(and(keycode$,$1000$)) then print "SHIFT+",
  if asc(and(keycode$,$2000$)) then print "CTRL+",
  if asc(and(keycode$,$4000$)) then print "ALT+",
  if asc(and(keycode$,$8000$)) then print "CMD+",
 switch dec(and(keycode$,$0fff$))
  case dec($0009$); print "Tab"; break
  case dec($001b$); print "Escape"; break
  case dec($007f$); print "Delete"; break
  case dec($012d$); print "Up arrow"; break
  case dec($012e$); print "Down arrow"; break
  case dec($012f$); print "Right arrow"; break
  case dec($0130$); print "Left arrow"; break
  case dec($0131$); print "Page up"; break
  case dec($0132$); print "Page down"; break
  case dec($0133$); print "Home"; break
  case dec($0134$); print "End"; break
  case dec($0135$); print "Ctrl-Home"; break
  case dec($0136$); print "Ctrl-End"; break
  case dec($0138$); print "Insert"; break
  case dec($0139$); print "Ctrl-Right arrow"; break
  case dec($013a$); print "Ctrl-Left arrow"; break
  case dec($013b$); print "Backtab"; break
  case dec($013e$); print "Keypad 0"; break
  case dec($013f$); print "Keypad 1"; break
  case dec($0140$); print "Keypad 2"; break
  case dec($0141$); print "Keypad 3"; break
  case dec($0142$); print "Keypad 4"; break
  case dec($0143$); print "Keypad 5"; break
  case dec($0144$); print "Keypad 6"; break
  case dec($0145$); print "Keypad 7"; break
  case dec($0146$); print "Keypad 8"; break
  case dec($0147$); print "Keypad 9"; break
  case dec($014b$); print "F1"; break
  case dec($014c$); print "F2"; break
  case dec($014d$); print "F3"; break
  case dec($014e$); print "F4"; break
  case dec($014f$); print "F5"; break
  case dec($0150$); print "F6"; break
  case dec($0151$); print "F7"; break
  case dec($0152$); print "F8"; break
  case dec($0153$); print "F9"; break
  case dec($0154$); print "F10"; break
  case dec($0155$); print "F11"; break
  case dec($0156$); print "F12"; break
  case dec($0174$); print "Keypad *"; break
  case dec($0175$); print "Keypad -"; break
  case dec($0176$); print "Keypad +"; break
  case dec($0177$); print "Keypad /"; break
  case default; print """",chr(dec(and(keycode$,$00ff$))),""" ",keycode; break
 swend
return

ClosedVersion History

  • BBj 24.01 BBjTree::getNodeFont added.

See Also

BBjAPI

BBjSysGui

BBjControl

BBjTree::setNodeFont

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