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

CToolBar

Methods Index

Heritage
Description
Usage
Environment
Enums
Protected Data Members
Constants
Public Methods
Constructor, Destructor, and Initializer Methods
Methods Specific to CToolBar
Methods Overridden from CSubview
Protected Methods

CToolBar


Heritage

Superclass: CSubview

Subclass: None


Description

CToolBar encapsulates the functionality of a tool bar (typically a view along the top of the window used as a short cut for menu items). CToolBar allows instances of any CView-derived classes to be placed on the tool bar and manages the geometry the contained views when the tool bar is sized.

CToolBars may be sized automatically (stuck to the side of an enclosure) or sized by the application.


Usage

The following example shows common usage of CToolBar:

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

// create the CToolBar in your window and add desired views
//(tools)
CMyWindow::CMyWindow(....)
{
...
itsToolBar = new CToolBar(this); // automatically
// sized to top

// use CMenuButton to add menu bar accelerators
new CMenuButton(itsToolBar, M_FILE_NEW, CImage(
"filenew.bmp" ));
new CMenuButton(itsToolBar, M_FILE_OPEN, CImage(
"fileopen.bmp"));
new CMenuButton(itsToolBar, M_FILE_SAVE, CImage(
"filesave.bmp"));

// use AppendSeparator to distinguish tool grouping
itsToolBar->AppendSeparator();

// use regular constructor to add any CView to toolbar
new NListEdit(itsToolBar, CRect(0, 0, 100, 100),
...);
new CButton(itsToolBar, CPoint(0, 0), "Font");
...

// arrange the subviews after adding contents
itsToolBar->ArrangeSubviews();
}

// Since menu buttons send DoMenuCommand's, handling of
// menu buttons is done by the same code which handles
// menus.
CMyWindow::DoMenuCommand(....)
{
...
}

// update toolbar menu accelerators when needed
//(ex. in update menus)
CMyWindow::UpdateMenus(CMenuBar *theMenuBar)
{
CWindow::UpdateMenus();
// make sure toolbar is in sync with menubar
itsToolBar->UpdateMenuButtons();
}
See the CMenuButton "Usage" section for a detailed example, including the usage of CToolBar.


Environment

CToolBar does not respond to changes in CEnvironment. The colors used to render a CToolBar may be set via the IToolBar method. Changes to the CEnvironment of a CToolBar will affect the subviews of the CToolBar.


Enums

enum AutosizeLocation { AL_NONE = 0, AL_TOP, AL_BOTTOM, AL_LEFT, AL_RIGHT };
Used to indicate which side of itsEnclosure the CToolBar will be sized to.


Protected Data Members

RWBitVec itsSeparators; Vector of separators
BOOLEAN itIsAutoSized; TRUE if automatically sized
AutosizeLocation itsAutoSizeLocation; Location for autosizing
COLOR itsLightShadowColor; Light shadow color
COLOR itsDarkShadowColor; Dark shadow color
COLOR itsFlatColor; Flat color
int itsBorderWidth; Pixel width of border
int itsSeparatorWidth; Pixel width of separators
RWHashDictionary *itsMenuButtons; List of contained CMenuButtons
CToolBarAttachment* itsAttachment Pointer to attachment object when toolbar can be attached/detached.


Constants

const int   TB_DefaultBorderWidth      = 2; /* pixels */
const int TB_DefaultSeparatorWidth = 5; /* pixels */
const COLOR TB_DefaultFlatColor = COLOR_LTGRAY;
const COLOR TB_DefaultLightShadowColor = COLOR_WHITE;
const COLOR TB_DefaultDarkShadowColor = COLOR_GRAY;
Default values for IToolBar.


Public Methods

Constructor, Destructor, and Initializer Methods

CToolBar(CSubview *theEnclosure, AutosizeLocation theLocation = AL_TOP);
CToolBar(CSubview *theEnclosure, const CRect &theFrame);
CToolBar(const CToolBar &theToolBar);
CToolBar& operator= (const CToolBar &theToolBar);
void IToolBar(
int theBorderWidth = TB_DefaultBorderWidth,
int theSeparatorWidth = TB_DefaultSeparatorWidth,
COLOR theFlatColor = TB_DefaultFlatColor,
COLOR theLightShadowColor = TB_DefaultLightShadowColor,
COLOR theDarkShadowColor = TB_DefaultDarkShadowColor);
virtual ~CToolBar();

Methods Specific to CToolBar

virtual void InsertSeparator(size_t theLocation);
void AppendSeparator(void);
virtual void RemoveSeparator(size_t theLocation);
virtual void RemoveAllSeparators(void);
virtual const RWBitVec& GetSeparators(void) const;
virtual void ArrangeSubviews(void);
void GetSpacingValues(
int *theBorderWidth,
int *theSeparatorWidth) const;
BOOLEAN IsAutoSized(void) const;
void SetAutoSized(
BOOLEAN isAutoSized,
AutosizeLocation theLocation = AL_TOP);
AutosizeLocation GetAutoSizeLocation(void) const;
void UpdateMenuButtons(void);
void UpdateMenuButton(MENU_TAG theMenuTag);

Methods Overridden from CSubview

virtual void AddSubview(const CView* theSubview);
virtual void RemoveSubview(const CView* theSubview);
virtual void DoSize(const CRect& theNewSize);
virtual void DoDraw(const CRect& theClippingRegion = MAXRect);
virtual void Draw(const CRect& theClippingRegion);
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 CToolBar &theToolBar);
void AutoSize(void);
virtual void InternalArrangeSubviews(
UNITS &theWidth, UNITS &theHeight,
BOOLEAN isSizingSubviews, UNITS &aMaxLeft);
UNITS HLogicalBorderSpace(void);
UNITS VLogicalBorderSpace(void);
void InsertMenuButton(MENU_TAG theMenuTag, CMenuButton *theButton);
void RemoveMenuButton(const CMenuButton *theButton);
void MoveView(size_t theFromLocation, size_t theToLocation);


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

support@xvt.com


Visit our online help desk for tech support

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