BBjTree::getNodeForeColor

Description

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

Syntax

Return Value

Method

BBjColor

getNodeForeColor(int node)

Parameters

Variable

Description

node

Specifies the node ID.

Return Value

Returns the foreground (text) color of a BBjTree node.

Remarks

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)

FI

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$+"."

FI

REM Display the user selection

print message$

RETURN

REM Callback routine called when the user closes the application window

APP_CLOSE:

RELEASE

RETURN

See Also

BBjAPI

BBjSysGui

BBjControl

BBjTree::setNodeForeColor

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