TBarDescr
TBarDescr
Header File
<owl/bardescr.h>
Description
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.
TBarDescr works in the same way as TMenuDescr.
Examples:
1) bardescr.zip Consist two examples of
using TBarDescr in SDI and MDI application.
2) docview.zip Example of using
TBarDescr in DocView Application
Constructors
TBarDescr::TBarDescr
Form 1
TBarDescr(TResId
id, int fg, int eg, int cg, int og, int wg, int hg, TModule* module = ::Module);
Form 2
TBarDescr(TResId
id, TModule* module = ::Module);
Description
Form 1: Constructs a
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
control bar.
Form 2: Creates a bar
descriptor from the bar resource specified in the id parameter. Calls the function
ExtractGroups to extract the group counts based on the separator items in the control bar.
~TBarDescr
Syntax
~TBarDescr();
Description
Destroys the TBarDescr
object.
Public Member Functions
Merge operator=
Syntax
TBarDescr& operator =(const TBarDescr&
original);
SetBitmap
Syntax
bool SetBitmap(const TResId newResId, TModule*
module);
Description
Set new bitmap for control bar (Currently set also bar new resource)
GetId
Syntax
TResId GetId() const;
Description
Gets the bar resource ID used to construct the
bar descriptor.
GetGroupCount
Syntax
int GetGroupCount(int group) const;
Description
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.
RemoveGadgets
Syntax
bool RemoveGadgets(TGadgetWindow&
destWindow);
Description
Removes gadgets from control bar but not destroys them.
SetBuilder
Syntax
void SetBuilder(const TGadgetFunctor&
functor);
Description
Set GadgetFunctor, see GetBuilder.
GetBuilder
Syntax
TGadgetFunctor* GetBuilder();
Description
GadgetFunctor, this is a pointer to Functor
that holds an C++ Callback. TBarDescr constructs by default GadgetFunctor as functions
that simple return TButtonGadget* for every ID, and TSeparatorGadget for ID = 0:
static TGadget* CreateGadget(int index, int
id, bool& usecell)
{
usecell = false;
if(id == 0)
return new
TSeparatorGadget(6);
usecell = true;
return new TButtonGadget(index, id,
TButtonGadget::Command,false,TButtonGadget::Up,true);
}
Where parameters:
index - Index in the
Bar resource description.
id - Control ID.
usecell - set it to true if control
uses sared bitmap from bitmnap resource.
You can set this property to function or to member function
Example:
1) Use static function
static TGadget* CreateGadget(int index, int id, bool& usecell)
{
usecell = false;
if(id == 0)
return new TSeparatorGadget(6);
if(id == IDC_MYTEXTGADGET)
return new TTextGadget(id, "some
text");
usecell = true;
return new TButtonGadget(index, id, TButtonGadget::Command,false,TButtonGadget::Up,true);
}
......
BarDescr.SetBuilder(TGadget_FUNCTOR(CreateGadget));
2) Use member function
TGadget* TMyWindow::MyHandle(int cellIdx,int cmdId,bool& usecell)
{
...
}
...
BarDescr.SetBuilder(TGadget_MFUNCTOR(myWndPtr,&TMyWindow::MyHandle)) - member
function
or
BarDescr.SetBuilder(TGadget_MFUNCTOR(this,&TMyWindow::MyHandle)) - member function
Virtual functions for derived classes:
virtual bool Create(TGadgetWindow&
destWindow);
virtual bool Merge(const TBarDescr&
sourceBarDescr, TGadgetWindow& destWindow);
virtual bool Restore(TGadgetWindow&
destWindow);
Public Data Members
GadgetBuilder - Old not supported class member, For backward
compatibility
Revised: February 08, 2000.