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

TScrollBar Class Reference

Implements a scroll bar. More...

#include <views.h>

Inheritance diagram for TScrollBar::

TView TObject TStreamable List of all members.

Public Methods

 TScrollBar (const TRect &bounds)
virtual void draw ()
virtual TPalettegetPalette () const
virtual void handleEvent (TEvent &event)
virtual void scrollDraw ()
virtual int scrollStep (int part)
void setParams (int aValue, int aMin, int aMax, int aPgStep, int aArStep)
void setRange (int aMin, int aMax)
void setStep (int aPgStep, int aArStep)
void setValue (int aValue)
void drawPos (int pos)
int getPos ()
int getSize ()

Static Public Methods

TStreamablebuild ()

Public Attributes

int value
TScrollChars chars
int minVal
int maxVal
int pgStep
int arStep

Static Public Attributes

TScrollChars vChars
TScrollChars hChars
const char* const name

Protected Methods

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

Constructor & Destructor Documentation

TScrollBar::TScrollBar ( const TRect & bounds )
 

Creates and initializes a scroll bar with the given bounds by calling the TView constructor. Sets value, maxVal and minVal to zero. Sets pgStep and arStep to 1.

The shapes of the scroll bar parts are set to the defaults in chars data member.

If `bounds' produces size.x = 1, scroll bar is vertical; otherwise, it is horizontal. Vertical scroll bars have the growMode data member set to gfGrowLoX | gfGrowHiX | gfGrowHiY; horizontal scroll bars have the growMode data member set to gfGrowLoY | gfGrowHiX | gfGrowHiY.

TScrollBar::TScrollBar ( 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 * TScrollBar::build ( ) [static]
 

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

Reimplemented from TView.

void TScrollBar::draw ( ) [virtual]
 

Draws the scroll bar depending on the current bounds, value, and palette.

Reimplemented from TView.

void TScrollBar::drawPos ( int pos )
 

Undocumented.

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

Returns the default palette.

Reimplemented from TView.

int TScrollBar::getPos ( )
 

Undocumented.

int TScrollBar::getSize ( )
 

Undocumented.

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

Handles scroll bar events by calling TView::handleEvent(). Mouse events are broadcast to the scroll bar's owner, which must handle the implications of the scroll bar changes.

handleEvent() also determines which scroll bar part has received a mouse click (or equivalent keystroke). Data member value is adjusted according to the current arStep or pgStep values. The scroll bar indicator is redrawn.

Reimplemented from TView.

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

Reads from the input stream `is'.

Reimplemented from TView.

void TScrollBar::scrollDraw ( ) [virtual]
 

Is called whenever value data member changes. This virtual member function defaults by sending a cmScrollBarChanged message to the scroll bar's owner:

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

int TScrollBar::scrollStep ( int part ) [virtual]
 

By default, scrollStep() returns a positive or negative step value, depending on the scroll bar part given by `part', and the current values of arStep and pgStep. Parameter `part' should be one of the following constants:

 Constant     Value Meaning

 sbLeftArrow  0     Left arrow of horizontal scroll bar
 sbRightArrow 1     Right arrow of horizontal scroll bar
 sbPageLeft   2     Left paging area of horizontal scroll bar
 sbPageRight  3     Right paging area of horizontal scroll bar
 sbUpArrow    4     Top arrow of vertical scroll bar
 sbDownArrow  5     Bottom arrow of vertical scroll bar
 sbPageUp     6     Upper paging area of vertical scroll bar
 sbPageDown   7     Lower paging area of vertical scroll bar
 sbIndicator  8     Position indicator on scroll bar
 

These constants define the different areas of a TScrollBar in which the mouse can be clicked. The scrollStep() function converts these constants into actual scroll step values. Although defined, the sbIndicator constant is never passed to scrollStep().

void TScrollBar::setParams ( int aValue,
int aMin,
int aMax,
int aPgStep,
int aArStep )
 

Sets the value, minVal, maxVal, pgStep and arStep with the given argument values. Some adjustments are made if your arguments conflict.

The scroll bar is redrawn by calling drawView(). If value is changed, scrollDraw() is also called.

void TScrollBar::setRange ( int aMin,
int aMax )
 

Sets the legal range for value by setting minVal and maxVal to the given arguments `aMin' and `aMax'.

Calls setParams(), so drawView() and scrollDraw() will be called if the changes require the scroll bar to be redrawn.

void TScrollBar::setStep ( int aPgStep,
int aArStep )
 

Sets pgStep and arStep to the given arguments `aPgStep' and `aArStep'. Calls setParams() with the other arguments set to their current values.

void TScrollBar::setValue ( int aValue )
 

Sets value to `aValue' by calling setParams() with the other arguments set to their current values. Note: drawView() and scrollDraw() will be called if this call changes value.

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

Writes to the output stream `os'.

Reimplemented from TView.


Member Data Documentation

int TScrollBar::arStep
 

Variable arStep is the amount added or subtracted to the scroll bar's value data member when an arrow area is clicked (sbLeftArrow, sbRightArrow, sbUpArrow, or sbDownArrow) or the equivalent keystroke made.

The TScrollBar constructor sets arStep to 1 by default.

Definition at line 2281 of file views.h.

TScrollChars TScrollBar::chars
 

TScrollChars is defined as:

 typedef char TScrollChars[5];
 

Variable chars is set with the five basic character patterns used to draw the scroll bar parts.

Definition at line 2250 of file views.h.

TScrollChars TScrollBar::hChars [static]
 

Undocumented.

Definition at line 2289 of file views.h.

int TScrollBar::maxVal
 

Variable maxVal represents the maximum value for the value data member. The TScrollBar constructor sets maxVal to zero by default.

Definition at line 2260 of file views.h.

int TScrollBar::minVal
 

Variable minVal represents the minimum value for the value data member. The TScrollBar constructor sets minVal to zero by default.

Definition at line 2255 of file views.h.

const char *const TScrollBar::name [static]
 

Undocumented.

Reimplemented from TView.

Definition at line 2320 of file views.h.

int TScrollBar::pgStep
 

Variable pgStep is the amount added or subtracted to the scroll bar's value data member when a mouse click event occurs in any of the page areas (sbPageLeft, sbPageRight, sbPageUp, or sbPageDown) or an equivalent keystroke is detected (Ctrl-Left, Ctrl-Right, PgUp, or PgDn).

The TScrollBar constructor sets pgStep to 1 by default. You can change pgStep using setParams(), setStep() or TScroller::setLimit().

Definition at line 2272 of file views.h.

TScrollChars TScrollBar::vChars [static]
 

Undocumented.

Definition at line 2285 of file views.h.

int TScrollBar::value
 

This variable represents the current position of the scroll bar indicator. This marker moves along the scroll bar strip to indicate the relative position of the scrollable text being viewed relative to the total text available for scrolling.

The TScrollBar constructor sets value to zero by default.

Definition at line 2239 of file views.h.


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