Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

TOutlineViewer Class Reference

Implements an outline viewer. More...

#include <outline.h>

Inheritance diagram for TOutlineViewer::

TScroller TView TObject TStreamable TOutline List of all members.

Public Methods

 TOutlineViewer (const TRect &bounds, TScrollBar *aHScrollBar, TScrollBar *aVScrollBar)
 TOutlineViewer (StreamableInit s)
virtual void adjust (TNode *node, Boolean expand)=0
virtual void draw ()
virtual void focused (int i)
virtual TNodegetChild (TNode *node, int i)=0
virtual char* getGraph (int level, long lines, ushort flags)
virtual int getNumChildren (TNode *node)=0
virtual TNodegetNode (int i)
virtual TPalettegetPalette () const
virtual TNodegetRoot ()=0
virtual char* getText (TNode *node)=0
virtual void handleEvent (TEvent &event)
virtual Boolean hasChildren (TNode *node)=0
virtual Boolean isExpanded (TNode *node)=0
virtual Boolean isSelected (int i)
virtual void selected (int i)
virtual void setState (ushort aState, Boolean enable)
void update ()
void expandAll (TNode *node)
TNodefirstThat (Boolean(*test)(TOutlineViewer *ov, TNode *node, int level, int position, long lines, ushort flags))
TNodeforEach (Boolean(*action)(TOutlineViewer *ov, TNode *cur, int level, int position, long lines, ushort flags))
char* createGraph (int level, long lines, ushort flags, int levWidth, int endWidth, const char *chars)

Static Public Methods

TStreamablebuild ()

Public Attributes

int foc

Static Public Attributes

const char* graphChars
const char* const name

Protected Methods

virtual void write (opstream &os)
virtual void* read (ipstream &is)

Static Protected Methods

void disposeNode (TNode *node)

Detailed Description

The outline viewer object type provides the abstract methods for displaying, expanding, and iterating the items in an outline.

TOutlineViewer, however, makes no assumptions about the actual items in the outline. Descendants of TOutlineViewer, such as TOutline, display outlines of specific kinds of items.

Definition at line 112 of file outline.h.


Constructor & Destructor Documentation

TOutlineViewer::TOutlineViewer ( const TRect & bounds,
TScrollBar * aHScrollBar,
TScrollBar * aVScrollBar )
 

Constructs an outline viewer object by first calling the constructor inherited from TScroller, passing `bounds', `aHScrollBar' and `aVScrollBar'. Sets growMode to gfGrowHiX + gfGrowHiY and sets foc data member to zero.

TOutlineViewer::TOutlineViewer ( StreamableInit s ) [inline]
 

Each streamable class needs a "builder" to allocate the correct memory for its objects together with the initialized virtual table pointers. This is achieved by calling this constructor with an argument of type StreamableInit.

Definition at line 359 of file outline.h.


Member Function Documentation

void TOutlineViewer::adjust ( TNode * node,
Boolean expand ) [pure virtual]
 

adjust() is an abstract method that descendant outline viewer types must override to show the child nodes of `node' if `expand' is True, or hide them if `expand' is False. Called when the user expands or collapses `node'. If hasChildren() returns False for `node', adjust() will never be called for that node.

Reimplemented in TOutline.

TStreamable * TOutlineViewer::build ( ) [static]
 

Called to create an object in certain stream-reading situations.

Reimplemented from TScroller.

Reimplemented in TOutline.

char * TOutlineViewer::createGraph ( int level,
long lines,
ushort flags,
int levWidth,
int endWidth,
const char * chars )
 

Undocumented.

void TOutlineViewer::disposeNode ( TNode * node ) [static, protected]
 

Undocumented.

void TOutlineViewer::draw ( ) [virtual]
 

Called to draw the outline view. Essentially, draw() calls getGraph() to get the graphical part of the outline, then appends the string returned from getText(). The line containing the focused node in the outline displays in a distinct color. Nodes whose child nodes are not displayed are highlighted.

Reimplemented from TView.

void TOutlineViewer::expandAll ( TNode * node )
 

If `node' has child nodes, expandAll() recursively expands `node' by calling adjust() with the expand parameter True, then expands all its child nodes by calling expandAll() for each of them.

TNode * TOutlineViewer::firstThat ( Boolean(* test)(TOutlineViewer *ov, TNode *node,int level, int position, long lines, ushort flags) )
 

firstThat() iterates over the nodes of the outline, calling the function pointed to by `test' until `test' returns True. `test' must point to a function with the following syntax:

 Boolean myIter(TOutlineViewer* ov, TNode* cur, int level, int position,
     long lines, ushort flags);
 

The parameters are documented in forEach().

void TOutlineViewer::focused ( int i ) [virtual]
 

Called whenever a node receives focus. The `i' parameter indicates the position of the newly focused node in the outline. By default, focused() just sets foc data member to `i'.

TNode * TOutlineViewer::forEach ( Boolean(* action)(TOutlineViewer *ov, TNode *cur, int level,int position, long lines, ushort flags) )
 

Iterates over all the nodes. `action' points to a function that forEach() calls for each node in the outline. The syntax for the iterator function is as follows:

 Boolean myIter(TOutlineViewer* ov, TNode* cur, int level, int position,
     long lines, ushort flags);
 

The parameters are as follows:

 Name     Description

 cur      A pointer to the node being checked.
 
 level    The level of the node (how many nodes are above it),
          zero-based. This can be used to a call to either
          getGraph() or createGraph().

 position The display order position of the node in the list. This can
          be used in a call to focused() or selected(). If in
          range, position - delta.Y is location the node is displayed
          on the view.

 lines    Bits indicating the active levels. This can be used in a call
          to getGraph() or createGraph(). It dicatates which
          horizontal lines need to be drawn.

 flags    Various flags for drawing. Can be used in a call to
          getGraph() or createGraph().
 
See also:
TOutlineViewer::firstThat

TNode * TOutlineViewer::getChild ( TNode * node,
int i ) [pure virtual]
 

getChild() is an abstract method (pure virtual) that descendant outline viewer types must override to return a pointer to the i-th child of the given `node'. If hasChildren() returns False, indicating that `node' has no child nodes, getChild() will not be called for that node. You can safely assume that when an outline viewer calls getChild(), the given node has at least `i' child nodes.

Reimplemented in TOutline.

char * TOutlineViewer::getGraph ( int level,
long lines,
ushort flags ) [virtual]
 

Returns a string of graphics characters to display to the left of the text returned by getText(). By default, getGraph() calls createGraph() with the default character values. You only need to override getGraph() if you want to change the appearance of the outline. For example, instead of calling createGraph() to show the hierarchy, you might return a string of characters to merely indent the text by a given amount for each level.

TNode * TOutlineViewer::getNode ( int i ) [virtual]
 

Returns a pointer to the i-th node in the outline; that is, the node shown `i' lines from the top of the complete outline.

int TOutlineViewer::getNumChildren ( TNode * node ) [pure virtual]
 

getNumChildren() is an abstract method (pure virtual) that descendant outline viewer types must override to return the number of child nodes in `node'. If hasChildren() returns False for `node', getNumChildren() will never be called.

Reimplemented in TOutline.

TPalette & TOutlineViewer::getPalette ( ) const [virtual]
 

Returns a reference to the default outline palette.

Reimplemented from TScroller.

TNode * TOutlineViewer::getRoot ( ) [pure virtual]
 

getRoot() is an abstract method that descendant outline viewer types must override to return a pointer to the root node of the outline.

Reimplemented in TOutline.

char * TOutlineViewer::getText ( TNode * node ) [pure virtual]
 

getText() is an abstract method (pure virtual) that descendant outline viewer types must override to return the text of `node'.

Reimplemented in TOutline.

void TOutlineViewer::handleEvent ( TEvent & event ) [virtual]
 

Handles most events for the outline viewer by calling the handleEvent() method inherited from TScroller, then handles certain mouse and keyboard events.

See also:
TScroller::handleEvent

Reimplemented from TScroller.

Boolean TOutlineViewer::hasChildren ( TNode * node ) [pure virtual]
 

hasChildren() is an abstract method (pure virtual) that descendant outline viewers must override to return True if the given `node' has child nodes and False if `node' has no child nodes.

If hasChildren() returns False for a particular node, the following functions are never called for that node: adjust(), expandAll(), getChild(), getNumChildren() and isExpanded(). Those methods can assume that if they are called, there are child nodes for them to act on.

Reimplemented in TOutline.

Boolean TOutlineViewer::isExpanded ( TNode * node ) [pure virtual]
 

isExpanded() is an abstract method (pure virtual) that descendant outline viewer types must override to return True if node's child nodes should be displayed. If hasChildren() returns False for `node', isExpanded() will never be called for that node.

Reimplemented in TOutline.

Boolean TOutlineViewer::isSelected ( int i ) [virtual]
 

Returns True if node `i' is selected. By default, TOutlineViewer assumes a single-selection outline, so it returns True if that node is focused. You can override isSelected() to handle multiple selections.

void * TOutlineViewer::read ( ipstream & is ) [protected, virtual]
 

Reads from the input stream `is'.

Reimplemented from TScroller.

Reimplemented in TOutline.

void TOutlineViewer::selected ( int i ) [virtual]
 

Called whenever a node is selected by the user, either by keyboard control or by the mouse. The `i' parameter indicates the position in the outline of the newly selected node. By default, selected() does nothing; descendant types can override selected() to perform some action in response to selection.

void TOutlineViewer::setState ( ushort aState,
Boolean enable ) [virtual]
 

Sets or clears the `aState' state flags for the view by calling the setState() method inherited from TScroller. If the new state includes a focus change, setState() calls drawView() to redraw the outline.

See also:
TScroller::setState

Reimplemented from TScroller.

void TOutlineViewer::update ( )
 

Updates the limits of the outline viewer. The limit in the vertical direction is number of nodes in the outline. The limit in the horizontal direction is the length of the longest displayed line.

Your program should call update() whenever the data in the outline changes. TOutlineViewer assumes that the outline is empty, so if the outline becomes non-empty during initialization, you must explicitly call update().

Also, if during the operation of the outline viewer the data being displayed change, you must call update() and the inherited drawView().

void TOutlineViewer::write ( opstream & os ) [protected, virtual]
 

Writes to the output stream `os'.

Reimplemented from TScroller.

Reimplemented in TOutline.


Member Data Documentation

int TOutlineViewer::foc
 

Indicates the item number of the focused node in the outline.

Definition at line 326 of file outline.h.

const char * TOutlineViewer::graphChars [static]
 

Undocumented.

Definition at line 330 of file outline.h.

const char *const TOutlineViewer::name [static]
 

Undocumented.

Reimplemented from TScroller.

Reimplemented in TOutline.

Definition at line 352 of file outline.h.


The documentation for this class was generated from the following file:
Generated at Sat Sep 22 20:19:30 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001