OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
bardescr.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1998 by Yura Bidus, All Rights Reserved
4//
5/// \file
6/// Class definition for TBarDescr.
7//
8//----------------------------------------------------------------------------
9
10#if !defined(OWL_BARDESCR_H) // Sentry, use file only if it's not already included.
11#define OWL_BARDESCR_H
12
13#include <owl/private/defs.h>
14#if defined(BI_HAS_PRAGMA_ONCE)
15# pragma once
16#endif
17
18#include <owl/resource.h>
19
20namespace owl {
21
22class TResId;
23class _OWLCLASS TGadget;
24class _OWLCLASS TGadgetWindow;
25class _OWLCLASS TCelArray;
26
27template <class R, class T1, class T2, class T3> class TFunctor3;
28// TGadgetFunctor is a ptr to a fn taking 4 parameters, and returning TGadget*
30
31#define TGadget_FUNCTOR(func) TFunctionTranslator3<TGadget*,int,int, bool&, TGadget* (*)(int,int, bool&)>(func)
32#define TGadget_MFUNCTOR(obj,memberFunc) TMemberTranslator3<TGadget*,int,int, bool&, TGadget*(obj::*)(int,int, bool&)>(obj, memberFunc);
33
34//
35// static TGadget* MyHandle(int cellIdx,int cmdId,bool& usecell)
36//{
37// usecell == false;
38// if(cmdId==0)
39// return new TSeparatorGadget(6);
40// usecell == true;
41// return new TButtonGadget(index, id, TButtonGadget::Command,false,TButtonGadget::Up,true);
42//}
43// Funct = TGadget_FUNCTOR(MyHandle) - function
44//
45// or:
46//
47// TGadget* TMyWindow::MyHandle(int cellIdx,int cmdId,bool& usecell)
48//{
49// usecell == false;
50// if(cmdId==0)
51// return new TSeparatorGadget(6);
52// usecell == true;
53// return new TButtonGadget(index, id, TButtonGadget::Command,false,TButtonGadget::Up,true);
54//}
55// Funct = TGadget_MFUNCTOR(myWndPtr,&TMyWindow::MyHandle) - member function
56// Funct = TGadget_MFUNCTOR(this,&TMyWindow::MyHandle) - member function
57//
58
59
60#include <owl/preclass.h>
61
63
64/// \addtogroup gadgets
65/// @{
66//
67/// \class TBarDescr
68/// Descriptor of Bar Implementation
69//
71{
72 public:
73
74/// Used by TBarDescr, the TGroup enum describes the following constants that define
75/// the index of the entry in the GroupCount array.
76 enum TGroup
77 {
78 FileGroup, ///< Index of the File gadget group count
79 EditGroup, ///< Index of the Edit gadget group count
80 ContainerGroup, ///< Index of the Container gadget group count
81 ObjectGroup, ///< Index of the Object gadget group count
82 WindowGroup, ///< Index of the Window gadget group count
83 HelpGroup, ///< Index of the Help gadget group count
84 NumGroups ///< Total number of groups
85 };
86 public:
87 TBarDescr(); // for internal use
88 TBarDescr(TResId id, int fg, int eg, int cg, int og, int wg, int hg,
89 TModule* module = &GetGlobalModule());
90 TBarDescr(TResId id, TModule* module = &GetGlobalModule());
91 virtual ~TBarDescr();
92
94
95 bool SetBitmap(TResId newResId, TModule* module);
96 TResId GetId() const;
97 int GetGroupCount(int group) const;
98 bool RemoveGadgets(TGadgetWindow& destWindow);
99 void SetBuilder(const TGadgetFunctor& functor);
100 TGadgetFunctor* GetBuilder();
101
102 virtual bool Create(TGadgetWindow& destWindow);
103 virtual bool Merge(const TBarDescr& sourceBarDescr, TGadgetWindow& destWindow);
104 virtual bool Restore(TGadgetWindow& destWindow);
105
106 protected:
107 TBarDescr(const TBarDescr& node);
108 bool ExtractGroups();
109
111 int GroupCount[NumGroups]; ///< An array of values indicating the number of pop-up menus in each group on the
112 ///< menu bar.
113 TToolbarRes* BarRes; ///< Points to the TToolbarRes object that owns this TBarDescr.
114 TCelArray* CelArray; ///< Points to the TCelArray object that owns this TBarDescr.
115 TResId Id; ///< The resource ID for the bar. The resource ID is passed in the constructors to
116 ///< identify the tool bar resource.
117 TModule* Module; ///< Points to the TModule object that owns this TBarDescr.
118 TGadgetFunctor* GadgetFunctor;
119
120 private:
121 TBarDescrGdArray* Gadgets; // internal usage
122
125};
126/// @}
127
128
129#include <owl/posclass.h>
130
131//
132// inlines
133//
134
135/// Gets the control bar resource ID used to construct the bar descriptor.
136inline TResId TBarDescr::GetId() const {
137 return Id;
138}
139
140//
141/// Gets the number of gadgets in a specified group within the control bar. There
142/// are a maximum of six functional groups as defined by the TGroup enum. These
143/// groups include FileGroup, EditGroup, ContainerGroup, ObjectGroup, WindowGroup,
144/// and HelpGroup.
145inline int TBarDescr::GetGroupCount(int group) const {
146 return GroupCount[group];
147}
148//
149//
150//
152 return GadgetFunctor;
153}
154//
155//
156
157} // OWL namespace
158
159
160#endif // __bardescr_h sentry.
161
162
Descriptor of Bar Implementation.
Definition bardescr.h:71
int GetGroupCount(int group) const
Gets the number of gadgets in a specified group within the control bar.
Definition bardescr.h:145
TResId GetId() const
Gets the control bar resource ID used to construct the bar descriptor.
Definition bardescr.h:136
TGadgetFunctor * GetBuilder()
Definition bardescr.h:151
TGroup
Used by TBarDescr, the TGroup enum describes the following constants that define the index of the ent...
Definition bardescr.h:77
@ FileGroup
Index of the File gadget group count.
Definition bardescr.h:78
@ EditGroup
Index of the Edit gadget group count.
Definition bardescr.h:79
@ HelpGroup
Index of the Help gadget group count.
Definition bardescr.h:83
@ WindowGroup
Index of the Window gadget group count.
Definition bardescr.h:82
@ ObjectGroup
Index of the Object gadget group count.
Definition bardescr.h:81
@ ContainerGroup
Index of the Container gadget group count.
Definition bardescr.h:80
TCelArray is a horizontal array of cels (a unit of animation) created by slicing a portion of or an e...
Definition celarray.h:35
Functor with 3 parameters, return R.
Definition functor.h:589
Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a window and lets you dynam...
Definition gadgetwi.h:122
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
Base class for writing streamable objects.
Definition objstrm.h:480
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
TModule * Module
Definition global.cpp:34
TFunctor3< TGadget *, int, int, bool & > TGadgetFunctor
Definition bardescr.h:29
TModule & GetGlobalModule()
Definition global.cpp:48
#define protected_data
Definition defs.h:208
#define _OWLCFUNC(p)
Definition defs.h:342
#define _OWLCLASS
Definition defs.h:338
Defines classes handling Windows resources.