OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TBarDescr Class Reference

Descriptor of Bar Implementation. More...

#include <owl/bardescr.h>

Public Types

enum  TGroup { FileGroup , EditGroup , ContainerGroup , ObjectGroup , WindowGroup , HelpGroup , NumGroups }
 Used by TBarDescr, the TGroup enum describes the following constants that define the index of the entry in the GroupCount array. More...
 

Public Member Functions

 TBarDescr ()
 Default constructor for a TBarDescr object.
 
 TBarDescr (TResId id, int fg, int eg, int cg, int og, int wg, int hg, TModule *module=&GetGlobalModule())
 Constructs a control bar descriptor from the resource indicated by id.
 
 TBarDescr (TResId id, TModule *module=&GetGlobalModule())
 Creates a control bar descriptor from the controlbar resource specified in the id parameter.
 
virtual ~TBarDescr ()
 Destroys the TBarDescr object.
 
TBarDescroperator= (const TBarDescr &original)
 
bool SetBitmap (TResId newResId, TModule *module)
 Set new bitmap for use in gadgets.
 
TResId GetId () const
 Gets the control bar resource ID used to construct the bar descriptor.
 
int GetGroupCount (int group) const
 Gets the number of gadgets in a specified group within the control bar.
 
bool RemoveGadgets (TGadgetWindow &destWindow)
 Removes all gadgets from destWindow.
 
void SetBuilder (const TGadgetFunctor &functor)
 
TGadgetFunctorGetBuilder ()
 
virtual bool Create (TGadgetWindow &destWindow)
 Inserts into destWindow's gadgets.
 
virtual bool Merge (const TBarDescr &sourceBarDescr, TGadgetWindow &destWindow)
 Merges this gadgets and sourceBarDescr gadgets and inserts them into destWindow's gadgets.
 
virtual bool Restore (TGadgetWindow &destWindow)
 Removes the gadgets in destWindow and then inserts these gadgets.
 

Protected Member Functions

 TBarDescr (const TBarDescr &node)
 Not implemented. Forbidden and protected contructor.
 
bool ExtractGroups ()
 Scan bar looking for separators that signify group divisions return whether we found any at all.
 

Friends

ipstreamoperator>> (ipstream &is, TBarDescr &m)
 
opstreamoperator<< (opstream &os, const TBarDescr &m)
 

Detailed Description

Descriptor of Bar Implementation.

TBarDescr describes your control bar and its functional groups.

TBarDescr provides an easy way for you to group gadgets on your control bar and to add new groups to an existing control bar. It uses a resource ID to identify the bar resource and an array of count values to indicate the number of gadgets in each group on the control bar.

The TGroup enum enumerates the six basic functional groups on a control bar: File, Edit, Container, Object, Window, and Help. TBarDescr's constructors simply initialize the members based on the arguments passed.

TFrameWindow::MergeBar actually performs the real work of merging the gadgets groups.

For a single document application (SDI), the gadgets are merged as soon as you load the application. See the sample program, bardescm, for an example of MDI control bar merging, and bardescr, for an example of SDI control bar merging.

One technique you can use to create a control bar involves invoking the TBarDescr constructor and passing the number of group counts for each gadgets selection.

For example, if your original gadgets groups included these items:

you might use the following group counts:

Group Count Menu
FileGroup 1 File
EditGroup 2 Edit Search
ContainerGroup 1 View
ObjectGroup 3 Page Paragraph Word
WindowGroup 1 Window
HelpGroup 1 Help

You would then invoke the constructor this way:

TBarDescr(IDM_MYMENU, 1, 2, 1, 3, 1, 1)
TBarDescr()
Default constructor for a TBarDescr object.
Definition bardescr.cpp:195

You can build the previous control bar by merging two control bars. When a zero is passed in the TBarDescr's constructor, the group indicated by the zero is filled in by the child control bar's group, if an item is specified, when the bar merging occurs. Set your application's parent frame control bar by specifying these gadget groups:

and passing these group counts in the constructor:

TBarDescr(IDM_FRAME, 1, 0, 1, 0, 1, 1)

Set the word-processor child control bar this way:

and pass these values in the constructor:

TBarDescr(IDM_WPROC, 0, 2, 0, 3, 0, 1)

If no child is active, only the frame menu will be active. When the word processor's child window becomes active, the child control bar is merged with the frame bar. Every group that is 0 in the child control bar leaves the parent's group intact. The previous example interleaves every group except for the last group, the Help group, in which the child replaces the frame bar.

By convention, the even groups (File, Container, Window) usually belong to the outside frame or container, and the odd groups (Edit, Object, Help) belong to the child or contained group.

If a -1 is used in a group count, the merger eliminates the parent's group without replacing it. For example, another child control bar, such as a calculator, could be added to your application in this way:

TBarDescr(IDM_WCALC, 0, 1, -1, 1, 0, 1)

In this example, the child's control group contributes nothing from the container group, and the parent's container group is removed. This produces a merged bar (with the View control bar selection eliminated as a result of the -1) that looks like this:

If you want to merge the following parent gadget groups

with these paint window gadget groups,

pass the following group counts in the constructor:

TBarDescr(IDM_WPAINT, 0, 1, 0, 2, 0, 1)

This produces the following merged control bar:

The simplest way to add groups to a control bar involves defining the control groups and adding separators in a resource file. Insert the term BUTTON -1 between each gadgets group and an additional separator if one of the gadgets groups is not present. For example, the resource file for Step 13 of the ObjectWindows tutorial defines the following gadgets groups and separators:

You can see the separators by loading Step13.rc into Resource Workshop.

Step13.cpp uses these commands from the resource file to set the main window and its menu, passing IDM_MDICMNDS as the parameter to SetMenuDescr function, as follows:

frame->SetBarDescr(new TBarDescr(IDB_DVMDI));

It produces the following menu groups:

TBarDescr's functions let you perform control bar merging similar to menu merging. That is, you can merge control bars from a MDI frame window, with those of an the MDI child window. When child is selected, the control bars of the child window merges with that of the frame window.

Definition at line 70 of file bardescr.h.

Member Enumeration Documentation

◆ TGroup

Used by TBarDescr, the TGroup enum describes the following constants that define the index of the entry in the GroupCount array.

Enumerator
FileGroup 

Index of the File gadget group count.

EditGroup 

Index of the Edit gadget group count.

ContainerGroup 

Index of the Container gadget group count.

ObjectGroup 

Index of the Object gadget group count.

WindowGroup 

Index of the Window gadget group count.

HelpGroup 

Index of the Help gadget group count.

NumGroups 

Total number of groups.

Definition at line 76 of file bardescr.h.

Constructor & Destructor Documentation

◆ TBarDescr() [1/4]

owl::TBarDescr::TBarDescr ( )

Default constructor for a TBarDescr object.

No menu resources or groups are specified. Constructs an empty control bar. For internal use only.

Definition at line 195 of file bardescr.cpp.

References NumGroups, SetBuilder(), and TGadget_FUNCTOR.

◆ TBarDescr() [2/4]

owl::TBarDescr::TBarDescr ( TResId id,
int fg,
int eg,
int cg,
int og,
int wg,
int hg,
TModule * module = &GetGlobalModule() )

Constructs a control bar descriptor from the resource indicated by id.

Places the gadgets in groups according the values of the fg, eg, cg, of, wg, and hg parameters. The fg, eg, cg, of, wg, and hg parameters represent the functional groups identified by the TGroup enum. Calls the function ExtractGroups to extract the group counts based on the separator items in the menu bar.

Definition at line 261 of file bardescr.cpp.

References ContainerGroup, EditGroup, ExtractGroups(), FileGroup, HelpGroup, ObjectGroup, SetBitmap(), SetBuilder(), TGadget_FUNCTOR, and WindowGroup.

◆ TBarDescr() [3/4]

owl::TBarDescr::TBarDescr ( TResId barResId,
TModule * module = &GetGlobalModule() )

Creates a control bar descriptor from the controlbar resource specified in the id parameter.

Calls the function ExtractGroups to extract the group counts based on the separator items in the control bar.

Definition at line 239 of file bardescr.cpp.

References ExtractGroups(), SetBitmap(), SetBuilder(), and TGadget_FUNCTOR.

◆ ~TBarDescr()

owl::TBarDescr::~TBarDescr ( )
virtual

Destroys the TBarDescr object.

Definition at line 287 of file bardescr.cpp.

◆ TBarDescr() [4/4]

Member Function Documentation

◆ Create()

bool owl::TBarDescr::Create ( TGadgetWindow & destWindow)
virtual

◆ ExtractGroups()

bool owl::TBarDescr::ExtractGroups ( )
protected

Scan bar looking for separators that signify group divisions return whether we found any at all.

Extracts the group counts from the loaded menu bar by counting the number of menus between separator items. After the group counts are extracted, the separators are removed. Returns true if separators (groups) were found; false otherwise.

Definition at line 495 of file bardescr.cpp.

References owl::TToolbarRes::GetCount(), owl::TToolbarRes::GetIds(), and NumGroups.

◆ GetBuilder()

TGadgetFunctor * owl::TBarDescr::GetBuilder ( )
inline

Definition at line 151 of file bardescr.h.

◆ GetGroupCount()

int owl::TBarDescr::GetGroupCount ( int group) const
inline

Gets the number of gadgets in a specified group within the control bar.

There are a maximum of six functional groups as defined by the TGroup enum. These groups include FileGroup, EditGroup, ContainerGroup, ObjectGroup, WindowGroup, and HelpGroup.

Definition at line 145 of file bardescr.h.

◆ GetId()

TResId owl::TBarDescr::GetId ( ) const
inline

Gets the control bar resource ID used to construct the bar descriptor.

Definition at line 136 of file bardescr.h.

◆ Merge()

bool owl::TBarDescr::Merge ( const TBarDescr & sourceBarDescr,
TGadgetWindow & destWindow )
virtual

Merges this gadgets and sourceBarDescr gadgets and inserts them into destWindow's gadgets.

Definition at line 375 of file bardescr.cpp.

References owl::TResource< T, resType >::IsOK(), NumGroups, RemoveGadgets(), and TYPESAFE_DOWNCAST.

◆ operator=()

TBarDescr & owl::TBarDescr::operator= ( const TBarDescr & original)

References owl::Module.

◆ RemoveGadgets()

bool owl::TBarDescr::RemoveGadgets ( TGadgetWindow & destWindow)

Removes all gadgets from destWindow.

Definition at line 474 of file bardescr.cpp.

References IDG_FLATHANDLE.

◆ Restore()

bool owl::TBarDescr::Restore ( TGadgetWindow & destWindow)
virtual

Removes the gadgets in destWindow and then inserts these gadgets.

Definition at line 437 of file bardescr.cpp.

References owl::TResource< T, resType >::IsOK(), NumGroups, RemoveGadgets(), and TYPESAFE_DOWNCAST.

◆ SetBitmap()

◆ SetBuilder()

void owl::TBarDescr::SetBuilder ( const TGadgetFunctor & functor)

Definition at line 295 of file bardescr.cpp.

Friends And Related Symbol Documentation

◆ operator<<

opstream & operator<< ( opstream & os,
const TBarDescr & m )
friend

◆ operator>>

ipstream & operator>> ( ipstream & is,
TBarDescr & m )
friend

The documentation for this class was generated from the following files: