OWLNext 7.0
Borland's Object Windows Library for the modern age
|
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. | |
TBarDescr & | operator= (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) |
TGadgetFunctor * | GetBuilder () |
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 | |
ipstream & | operator>> (ipstream &is, TBarDescr &m) |
opstream & | operator<< (opstream &os, const TBarDescr &m) |
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:
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:
Set the word-processor child control bar this way:
and pass these values in the constructor:
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:
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:
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:
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.
Used by TBarDescr, the TGroup enum describes the following constants that define the index of the entry in the GroupCount array.
Definition at line 76 of file bardescr.h.
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.
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.
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.
|
virtual |
Destroys the TBarDescr object.
Definition at line 287 of file bardescr.cpp.
|
protected |
Not implemented. Forbidden and protected contructor.
Definition at line 211 of file bardescr.cpp.
References CHECK, ExtractGroups(), owl::TToolbarRes::GetBitmap(), owl::TToolbarRes::GetCount(), owl::TToolbarRes::GetHeight(), owl::TToolbarRes::GetWidth(), owl::TBitmap::Height(), owl::TResource< T, resType >::IsOK(), owl::TColor::LtGray, owl::NoAutoDelete, SetBuilder(), and TGadget_FUNCTOR.
|
virtual |
Inserts into destWindow's gadgets.
Definition at line 350 of file bardescr.cpp.
References owl::TToolbarRes::GetBitmap(), GetBuilder(), owl::TToolbarRes::GetCount(), owl::TToolbarRes::GetHeight(), owl::TToolbarRes::GetWidth(), owl::TBitmap::Height(), and owl::TResource< T, resType >::IsOK().
|
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.
|
inline |
Definition at line 151 of file bardescr.h.
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.
|
inline |
Gets the control bar resource ID used to construct the bar descriptor.
Definition at line 136 of file bardescr.h.
|
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.
References owl::Module.
bool owl::TBarDescr::RemoveGadgets | ( | TGadgetWindow & | destWindow | ) |
Removes all gadgets from destWindow.
Definition at line 474 of file bardescr.cpp.
References IDG_FLATHANDLE.
|
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.
Set new bitmap for use in gadgets.
Definition at line 302 of file bardescr.cpp.
References owl::TToolbarRes::GetBitmap(), owl::TToolbarRes::GetCount(), owl::TModule::GetHandle(), owl::TToolbarRes::GetHeight(), owl::TToolbarRes::GetWidth(), owl::TBitmap::Height(), owl::TResource< T, resType >::IsOK(), owl::TColor::LtGray, and owl::NoAutoDelete.
void owl::TBarDescr::SetBuilder | ( | const TGadgetFunctor & | functor | ) |
Definition at line 295 of file bardescr.cpp.