rem ' isRootVisible
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = "BBjTree"
pos = iff(info(3,6)="5",10,100)
window! = sysgui!.addWindow(pos,pos,250,450,title$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
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"
rem ' Create and populate tree
tree! = window!.addTree(101,25,25,200,350)
tree!.setSelectionMode(tree!.SINGLE_TREE_SELECTION)
root = 0
node = 0
root$ = "Musical Tree"
root$ = "<html><h2>" + root$ + "</h2></html>"
tree!.setRoot(root,root$)
tree!.setToolTipText(root,root$)
color! = sysgui!.makeColor(rnd(255),rnd(255),rnd(255))
tree!.setNodeForeColor(root,color!)
for artist = 0 to 2
node = node + 1
artist$ = "<html><h3>"+music$[artist,0]+"</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!)
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]
tree!.addNode(node,parent,song$)
tree!.setToolTipText(node,song$)
color! = sysgui!.makeColor(rnd(255),rnd(255),rnd(255))
tree!.setNodeForeColor(node,color!)
if (len(image$[artist,song])) then
tree!.setNodeIcon(node,image$[artist,song])
endif
next song
next artist
tree!.setCallback(tree!.ON_TREE_SELECT,"event")
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")
rem 'tree!.setCallback(tree!.ON_POPUP_REQUEST,"event")
setRootVisible! = window!.addCheckBox(102,25,400,200,25,"setRootVisible",$0004$)
setRootVisible!.setCallback(setRootVisible!.ON_CHECK_ON,"setRootVisibleOn")
setRootVisible!.setCallback(setRootVisible!.ON_CHECK_OFF,"setRootVisibleOff")
event = 0
process_events
eoj:
release
setRootVisibleOn:
tree!.setRootVisible(1)
print "isRootVisible? ",tree!.isRootVisible()
return
setRootVisibleOff:
tree!.setRootVisible(0)
print "isRootVisible? ",tree!.isRootVisible()
return
event:
event = event + 1
dim event$:tmpl(sysgui),generic$:noticetpl(0,0)
event$ = sysgui!.getLastEventString()
e$ = sysgui!.getLastEvent().toString()
e$ = e$(1,pos("@"=e$)-1)
print e$,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$,$$)
print " ",name$,"=",
if (asc(info$) = 1) then
print field(notice$,name$),
else
print str(nfield(notice$,name$)),
endif
next field
endif
print ""
print "Selected node:",tree!.getSelectedNode()
print ""
return
resize:
event! = sysgui!.getLastEvent()
print "Resized; width=",str(event!.getWidth()),", height=",str(event!.getHeight())
return
setRootVisibleOff:
tree!.setRootVisible(0)
print "isRootVisible? ",tree!.isRootVisible()
return
event:
event = event + 1
dim event$:tmpl(sysgui),generic$:noticetpl(0,0)
event$ = sysgui!.getLastEventString()
e$ = sysgui!.getLastEvent().toString()
e$ = e$(1,pos("@"=e$)-1)
print e$,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$,$$)
print " ",name$,"=",
if (asc(info$) = 1) then
print field(notice$,name$),
else
print str(nfield(notice$,name$)),
endif
next field
endif
print ""
print "Selected node:",tree!.getSelectedNode()
print ""
return
resize:
event! = sysgui!.getLastEvent()
print "Resized; width=",str(event!.getWidth()),", height=",str(event!.getHeight())
return
|