BBjTree::setNodeForeColor

Description

In BBj 10.00 and higher, this method sets the foreground (text) color of a BBjTree node.

Syntax

Return Value Method
void setNodeForeColor(int ID, BBjColor color)

Parameters

Parameter Description
ID Specifies the node ID.
color Specifies the color.

Return Value

None.

Example

rem 'Set node-specific text colors

rem 'Obtain the instance of the BBjAPI object
let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI) "X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Constants
WINDOW_X = 200,WINDOW_Y = 200
WINDOW_W = 300,WINDOW_H = 250
TREE_ID = 101
TREE_X = 0,TREE_Y = 0
TREE_W = WINDOW_W,TREE_H = WINDOW_H
PARENT_ID = 0
NODE_ID = 0
TITLE$="Musical Tree"
TRUE = 1
FALSE = 0
OK = 0
QOUTE$ = CHR(34)

rem 'Create array to hold ARTIST and songs
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 Waters",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"

rem 'Create the main window
myWindow! = mySysGui!.addWindow(WINDOW_X,WINDOW_Y,WINDOW_W,WINDOW_H,TITLE$,$0093$,$02$)

rem 'Create the tree control on the window
myMusicalTree! = myWindow!.addTree(TREE_ID,TREE_X,TREE_Y,TREE_W,TREE_H)
myMusicalTree!.setForeColor(BBjAPI().makeColor(192,192,192))

rem 'Create root node of tree
myMusicalTree!.setRoot(PARENT_ID,TITLE$)

rem 'Add nodes to tree
FOR ARTIST = 0 TO 2
    NODE_ID = NODE_ID+1
    myMusicalTree!.addExpandableNode(NODE_ID,PARENT_ID,MUSIC$[ARTIST,0])
    color! = BBjAPI().makeColor(rnd(255),rnd(255),rnd(255))
    myMusicalTree!.setNodeForeColor(node_id,color!)
    myMusicalTree!.setToolTipText(node_id,str(color!))
    SONG_PARENT_ID = NODE_ID
    FOR SONG = 1 TO 4
        NODE_ID = NODE_ID+1
        myMusicalTree!.addNode(NODE_ID,SONG_PARENT_ID,MUSIC$[ARTIST,SONG])
        color! = BBjAPI().makeColor(rnd(255),rnd(255),rnd(255))
        myMusicalTree!.setNodeForeColor(node_id,color!)
        myMusicalTree!.setToolTipText(node_id,str(color!))
    NEXT SONG
NEXT ARTIST

rem 'Show the window
myWindow!.setVisible(TRUE)

rem 'Register the CALLBACK routines
CALLBACK(ON_TREE_SELECT,DO_SELECTION,mySysGui!.getContext(),myMusicalTree!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

rem 'Process Events
process_events

rem 'Callback routine called when the user selects a node of the tree control
DO_SELECTION:
    rem 'Get the selected node
    let NODE = myMusicalTree!.getSelectedNode()

    rem 'Get the node text
    let NODE_DATA$ = myMusicalTree!.getNodeText(NODE)

    rem 'Check if node is a child
    let CHILD_NODE = myMusicalTree!.isNodeLeaf(NODE)
    if (CHILD_NODE) then
        rem 'If child node get the parent node
        CHILD_DATA$ = NODE_DATA$
        NODE = myMusicalTree!.getParentNode(NODE)
        NODE_DATA$ = myMusicalTree!.getNodeText(NODE)
    endif

    rem 'Create the selected display message
    MESSAGE$="You have selected "+NODE_DATA$
    if (CHILD_NODE) then
        MESSAGE$ = MESSAGE$+"'s hit song, "+QOUTE$+CHILD_DATA$+"."+QOUTE$
    else
        MESSAGE$ = MESSAGE$+"."
    endif

    rem 'Display the user selection
    print message$
return

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

BBjTree::getNodeForeColor

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