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

TListViewer Class Reference

An abstract class from which you can derive list viewers of various kinds, such as TListBox. More...

#include <views.h>

Inheritance diagram for TListViewer::

TView TObject TStreamable TColorGroupList TColorItemList THistoryViewer TListBox TDirListBox TSortedListBox TFileList List of all members.

Public Methods

 TListViewer (const TRect &bounds, ushort aNumCols, TScrollBar *aHScrollBar, TScrollBar *aVScrollBar)
virtual void changeBounds (const TRect &bounds)
virtual void draw ()
virtual void focusItem (short item)
virtual TPalettegetPalette () const
virtual void getText (char *dest, short item, short maxLen)
virtual Boolean isSelected (short item)
virtual void handleEvent (TEvent &event)
virtual void selectItem (short item)
void setRange (short aRange)
virtual void setState (ushort aState, Boolean enable)
virtual void focusItemNum (short item)
virtual void shutDown ()

Static Public Methods

TStreamablebuild ()

Public Attributes

TScrollBarhScrollBar
TScrollBarvScrollBar
short numCols
short topItem
short focused
short range

Static Public Attributes

char separatorChar
const char* const name

Protected Methods

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

Detailed Description

TListViewer is an abstract class from which you can derive list viewers of various kinds, such as TListBox. TListViewer's members offer the following functionality:

  1. A view for displaying linked lists of items (but no list)
  2. Control over one or two scroll bars
  3. Basic scrolling of lists in two dimensions
  4. Reading and writing the view and its scroll bars from and to a stream
  5. Ability to use a mouse or the keyboard to select (highlight) items on list
  6. Draw member function that copes with resizing and scrolling
TListViewer has an abstract getText() method, so you need to supply the mechanism for creating and manipulating the text of the items to be displayed.

TListViewer has no list storage mechanism of its own. Use it to display scrollable lists of arrays, linked lists, or similar data structures. You can also use its descendants, such as TListBox, which associates a collection with a list viewer.

Definition at line 2584 of file views.h.


Constructor & Destructor Documentation

TListViewer::TListViewer ( const TRect & bounds,
ushort aNumCols,
TScrollBar * aHScrollBar,
TScrollBar * aVScrollBar )
 

Creates and initializes a TListViewer object with the given size by first calling TView::TView(bounds).

The numCols data member is set to `aNumCols'. TView::options is set to (ofFirstClick | ofSelectable) so that mouse clicks that select this view will be passed first to handleEvent().

The TView::eventMask is set to evBroadcast. The initial values of range and focused are zero.

You can supply pointers to vertical and/or horizontal scroll bars by way of the `aVScrollBar' and `aHScrollBar' arguments. Setting either or both to 0 suppresses one or both scroll bars. These two pointer arguments are assigned to the vScrollBar and hScrollBar data members.

TListViewer::TListViewer ( StreamableInit ) [protected]
 

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.


Member Function Documentation

TStreamable * TListViewer::build ( ) [static]
 

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

Reimplemented from TView.

Reimplemented in TColorGroupList, TColorItemList, TListBox, TSortedListBox, TFileList, and TDirListBox.

void TListViewer::changeBounds ( const TRect & bounds ) [virtual]
 

Changes the size of the TListViewer object by calling TView::changeBounds(bounds). If a horizontal scroll bar has been assigned, TScrollBar::pgStep is updated by way of TScrollBar::setStep().

See also:
TView::changeBounds

Reimplemented from TView.

void TListViewer::draw ( ) [virtual]
 

Draws the TListViewer object with the default palette by repeatedly calling getText() for each visible item. Takes into account the focused and selected items and whether the view is sfActive.

See also:
TView::state

Reimplemented from TView.

void TListViewer::focusItem ( short item ) [virtual]
 

Makes the given item focused by setting the focused data member to `item'. Also sets the TScrollBar::value data member of the vertical scroll bar (if any) to `item' and adjusts topItem.

Reimplemented in TColorGroupList, TColorItemList, and TFileList.

void TListViewer::focusItemNum ( short item ) [virtual]
 

Used internally by focusItem(). Makes the given item focused by setting the focused data member to `item'.

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

Returns the default TListViewer palette string.

Reimplemented from TView.

Reimplemented in THistoryViewer.

void TListViewer::getText ( char * dest,
short item,
short maxLen ) [virtual]
 

Derived classes must override it with a function that writes a string not exceeding `maxLen' at address `dest', given an item index referenced by `item'.

Note that draw() needs to call getText().

Reimplemented in TColorGroupList, TColorItemList, TListBox, THistoryViewer, TFileList, and TDirListBox.

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

Handles events by first calling TView::handleEvent(event).

See also:
TView::handleEvent

Mouse clicks and "auto" movements over the list will change the focused item. Items can be selected with double mouse clicks.

Keyboard events are handled as follows: Spacebar selects the currently focused item; the arrow keys, PgUp, PgDn, Ctrl-PgDn, Ctrl-PgUp, Home, and End keys are tracked to set the focused item.

Broadcast events from the scroll bars are handled by changing the focused item and redrawing the view as required.

Reimplemented from TView.

Reimplemented in TColorGroupList, TColorItemList, THistoryViewer, and TSortedListBox.

Boolean TListViewer::isSelected ( short item ) [virtual]
 

Returns True if the given item is selected (focused), that is, if `item' == focused.

Reimplemented in TDirListBox.

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

Reads from the input stream `is'.

Reimplemented from TView.

Reimplemented in TColorGroupList, TListBox, and TSortedListBox.

void TListViewer::selectItem ( short item ) [virtual]
 

Selects the item'th element of the list, then broadcasts this fact to the owning group by calling:

 message(owner, evBroadcast, cmListItemSelected, this);
 
See also:
message

Reimplemented in TFileList, and TDirListBox.

void TListViewer::setRange ( short aRange )
 

Sets the range data member to `aRange'.

If a vertical scroll bar has been assigned, its parameters are adjusted as necessary (and TScrollBar::drawView() is invoked if redrawing is needed).

If the currently focused item falls outside the new range, the focused data member is set to zero.

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

Calls TView::setState(aState, enable) to change the TListViewer object's state. Depending on the `aState' argument, this can result in displaying or hiding the view.

See also:
TView::setState , TView::state

Additionally, if `aState' is sfSelected and sfActive, the scroll bars are redrawn; if `aState' is sfSelected but not sfActive, the scroll bars are hidden.

Reimplemented from TView.

Reimplemented in TDirListBox.

void TListViewer::shutDown ( ) [virtual]
 

Used internally by TObject::destroy() to ensure correct destruction of derived and related objects. shutDown() is overridden in many classes to ensure the proper setting of related data members when destroy() is called.

Reimplemented from TView.

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

Writes to the output stream `os'.

Reimplemented from TView.

Reimplemented in TColorGroupList, and TListBox.


Member Data Documentation

short TListViewer::focused
 

The item number of the focused item. Items are numbered from 0 to range - 1. Initially set to 0, the first item, focused can be changed by mouse click or Spacebar selection.

Definition at line 2734 of file views.h.

TScrollBar * TListViewer::hScrollBar
 

Pointer to the horizontal scroll bar associated with this view. If 0, the view does not have such a scroll bar.

Definition at line 2712 of file views.h.

const char *const TListViewer::name [static]
 

Undocumented.

Reimplemented from TView.

Reimplemented in TColorGroupList, TColorItemList, TListBox, TSortedListBox, TFileList, and TDirListBox.

Definition at line 2767 of file views.h.

short TListViewer::numCols
 

The number of columns in the list control.

Definition at line 2721 of file views.h.

short TListViewer::range
 

The current total number of items in the list. Items are numbered from 0 to range - 1.

Definition at line 2739 of file views.h.

char TListViewer::separatorChar [static]
 

Undocumented.

Definition at line 2743 of file views.h.

short TListViewer::topItem
 

The item number of the top item to be displayed. This value changes during scrolling. Items are numbered from 0 to range - 1. This number depends on the number of columns, the size of the view, and the value of variable range.

Definition at line 2728 of file views.h.

TScrollBar * TListViewer::vScrollBar
 

Pointer to the vertical scroll bar associated with this view. If 0, the view does not have such a scroll bar.

Definition at line 2717 of file views.h.


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