BBjTree::setSelectedIcon

Description

In BBj 11.00 and higher, this method sets the icon to be used for selected leaf nodes in the BBjTree control.

Syntax

Return Value Method
void setSelectedIcon(BBjImage image)
void setSelectedIcon(String file)

Parameters

Parameter Description
image Specifies the selected icon image of the node.
file Specifies the file name of the icon.

Return Value

None.

Remarks

If a full path is not specified for the file, the PREFIX will be used to search for the file.

Example

rem ' Set tree icons

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
pos = iff(info(3,6)="5",10,100)
title$ = "Tree Icons"
window! = sysgui!.addWindow(pos,pos,450,650,title$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")

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,400,600)
tree!.setCollapsedIcon("collapsed.gif")
tree!.setExpandedIcon("expanded.gif")
tree!.setLeafIcon("leaf.png")
tree!.setSelectedIcon("selected.png")
tree!.setTreeEditable(1)
root = 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!.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!.expandTreeFromNode(0)
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")
event = 0

process_events

eoj:
release

event:
    event = event + 1
    dim event$:tmpl(sysgui),generic$:noticetpl(0,0)
    event$ = sysgui!.getLastEventString()
    generic$ = notice(sysgui,event.x)
    dim notice$:noticetpl(generic.objtype,event.flags)
    notice$ = generic$
    e$ = sysgui!.getLastEvent().toString()
    e$ = e$(1,pos("@"=e$)-1)
    print e$,event,":",
    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
    print ""
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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