[Classes] [Prev] [Next] [Methods]

CStatusBar

Methods Index

Heritage
Description
Usage
Environment
Protected Data Members
Constants
Helper Classes
Public Methods
Constructor, Destructor, and Initializer Methods
CView Interaction Methods
Methods Overridden from CSubview
Protected Methods

CStatusBar


Heritage

Superclass: CSubview

Subclass: None


Description

The CStatusBar class encapsulates the functionality of a status bar (i.e., typically, a view along the bottom of the window used to display application status). You can assign status fields to a CStatusBar object. These assigned fields can be modified at runtime, using their application-assigned field IDs.

You can create and update a CStatusBar object that displays textual status using the AppendField(... CStringRW ...), SetFieldStatus, and GetFieldStatus convenience methods.

A CStatusBar object is not limited to displaying textual status. You can also place an instance of a CView-derived class in a CStatusBar and accessed the class through its field ID.


Usage

The following example shows the common usage of the CStatusBar class:

// keep a pointer to the CStatusBar in your window
class CMyWindow : public CWindow {
...
protected:
CStatusBar *itsStatusBar;
};

// create the CStatusBar in your window and add
// desired fields
const long COORDS_FIELD = ...
const long STATUS_FIELD = ...
CMyWindow::CMyWindow(....)
{
...
itsStatusBar = new CStatusBar(this);
itsStatusBar->AppendField(STATUS_FIELD,
"Initial Status");
itsStatusBar->AppendField(COORDS_FIELD, "0,
0", 100);
...
}

// update the status bar fields when needed
// in your application
itsStatusBar->SetFieldStatus(STATUS_FIELD,
"Save succeeded.");
...

void CMyWindow::DoMouseMove(CPoint theLoc, ....)
{
char aStatus[20];
// update COORDS_FIELD to mouse move
// coordinates
sprintf(aStatus, " %d, %d", (int)theLoc.H(),
(int)theLoc.V());
itsStatusBar->SetFieldStatus(COORDS_FIELD,
aStatus);
...
}

Note: TDI support is not provided directly by this class. Instead, you may attach TDI connections to the views in each status field (available via GetField()).


Environment

A CStatusBar object does not respond to changes in its CEnvironment object. You can set the colors used to render a CStatusBar in the IStatusBar method. Changes to the CEnvironment object of a CStatusBar do however affect the views that the CStatusBar encloses.


Protected Data Members

RWGSlist(
CStatusField)
itsFields; List of status fields
RWHashDictionary itsFieldIndices; The mapping field IDs to indices
BOOLEAN itIsAutoSized; Indicates whether the status bar is automatically sized; if TRUE, it is
COLOR itsFlatColor; The flat color
COLOR itsLightShadowColor; The light shadow color
COLOR itsDarkShadowColor; The dark shadow color
int itsBorderWidth; The pixel width of the outer border
int itsFieldBorderWidth; The pixel width of the field border
int itsSeparatorWidth; The pixel width of separators
int itsHPadding; The horizontal padding around the status text
int itsVPadding; The vertical padding around the status text

Constants

To indicate a special size for the field, you can pass the following two constants to the SizeField method:

const UNITS SB_FitToView = 0.0F;
const UNITS
SB_FillToWidth = -1.0F;
SB_FitToView indicates that the field should be the minimum width which will fit the enclosed view. It is important to note that this width will not be recalculated if the size of the enclosed view changes. Thus, SB_FitToView is most useful for sizing fields which will not be changing is width (such as a CPicture).

SB_FillToWidth indicates that the field should be as wide as possible, taking up the remainder of the status bar width which is not used by other fields. If several fields have width SB_FillToWidth, they will divide up the remaining space evenly among themselves. Fields with width SB_FillToWidth will be automatically resized when the CStatusBar sizes.

const unsigned SB_NoIndex = UNIT_MAX;
const long     SB_NoId = -1L;
SB_NoIndex and SB_NoId are used as returns values for CStatusBar methods which return a field index or id. Both indicate that the field was not found.

Helper Classes

struct CStatusField {
long itsId;
UNITS itsRequestedWidth;
UNITS itsActualWidth;
CView *itsView;
BOOLEAN itIsInset;
BOOLEAN itIsVisible;
};
declare(RWGSlist,CStatusField)
Helper class used by CStatusBar to store field data.


Public Methods

Constructor, Destructor, and Initializer Methods

CStatusBar(CSubview *theEnclosure);
CStatusBar(CSubview *theEnclosure, const CRect &theFrame);
CStatusBar(const CStatusBar& theStatusBar);
CStatusBar& operator= (const CStatusBar& theStatusBar);
void IStatusBar(
int theBorderWidth = SB_DefaultBorderWidth,
int theFieldBorderWidth = SB_DefaultFieldBorderWidth,
int theSeparatorWidth = SB_DefaultSeparatorWidth,
int theHPadding = SB_DefaultHPadding,
int theVPadding = SB_DefaultVPadding,
COLOR theFlatColor = SB_DefaultFlatColor,
COLOR theLightShadowColor = SB_DefaultLightShadowColor,
COLOR theDarkShadowColor = SB_DefaultDarkShadowColor);
virtual ~CStatusBar();
The following methods are provided as convenience methods for interacting with CStatusBars containing text items. This is the interface that should be used unless you are placing non-text items in the status bar.

virtual BOOLEAN AppendField(
long theFieldId,
const CStringRW &theInitialStatus,
UNITS theWidth = SB_FillToWidth);
virtual BOOLEAN InsertField(
unsigned theIndex,
long theFieldId,
const CStringRW &theInitialStatus,
UNITS theWidth = SB_FillToWidth;
virtual void SetFieldStatus(
long theFieldId, const CStringRW &theStatus,
BOOLEAN isShown = TRUE);
virtual CStringRW GetFieldStatus(long theFieldId) const;

CView Interaction Methods

The following methods are used for interacting with a CStatusBar that contains arbitrary CViews.

virtual BOOLEAN AppendField(
long theFieldId,
CView *theFieldView, // theFieldView is consumed
UNITS theWidth = SB_FitToView,
BOOLEAN isInset = TRUE);
virtual BOOLEAN InsertField(
unsigned theIndex,
long theFieldId,
CView *theFieldView, // theFieldView is consumed
UNITS theWidth = SB_FitToView,
BOOLEAN isInset = TRUE);
virtual long AddField(
CView *theFieldView, // theFieldView is consumed
UNITS theWidth = SB_FitToView,
BOOLEAN isInset = TRUE);
virtual CView *GetField(long theFieldId) const;
virtual void RemoveField(long theFieldId);
virtual void ShowField(long theFieldId);
virtual void HideField(long theFieldId);
virtual void ShowAllFields(void);
virtual void HideAllFields(void);
virtual void RemoveAllFields(
BOOLEAN itDeletesSubviews = TRUE);
virtual void SizeField(long theFieldId, UNITS theSize = SB_FitToView);
virtual unsigned GetFieldIndex(long theFieldId) const;
virtual long GetFieldId(unsigned theIndex) const;
virtual unsigned GetNumFields(void) const;
virtual UNITS GetFieldWidth(long theFieldId) const;
virtual BOOLEAN  IsFieldInset(long theFieldId) const;
virtual BOOLEAN  IsFieldVisible(long theFieldId) const;
virtual void ArrangeSubviews(void);
void GetSpacingValues(
int *theBorderWidth,
int *theFieldBorderWidth,
int *theSeparatorWidth,
int *theHPadding,
int *theVPadding) const;
BOOLEAN IsAutoSized(void) const;
void SetAutoSized(BOOLEAN isAutoSized);

Methods Overridden from CSubview

virtual void RemoveSubview(const CView* theSubview);
virtual void DoShow(void);
virtual void DoSize(const CRect& theNewSize);
virtual void Draw(const CRect& theClippingRegion);
virtual void DoDraw(const CRect& theClippingRegion = MAXRect);
virtual void DoSetFont(const CFont &theNewFont, BOOLEAN isUpdate = FALSE);
virtual void DoSetEnvironment(const CEnvironment& theNewEnvironment, BOOLEAN isUpdate = FALSE);
virtual void SetSizing(BOOLEAN isSizable):
virtual void SetDragging( BOOLEAN isDraggable );

Protected Methods

void Copy(const CStatusBar& theStatBar);
void SetFieldIndices(void);
CStatusField *GetStatusField(long theId) const;


[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.