]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/dyntbar.h
Nuke #pragma implementation/interface's
[wxWidgets.git] / contrib / include / wx / fl / dyntbar.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dyntbar.h
3 // Purpose: wxDynamicToolBar header
4 // Author: Aleksandras Gluchovas
5 // Modified by:
6 // Created: ??/10/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __DYNTBAR_G__
13 #define __DYNTBAR_G__
14
15 #include "wx/tbarbase.h"
16 #include "wx/dynarray.h"
17 #include "wx/fl/fldefs.h"
18
19 /*
20 Tool layout item.
21 */
22
23 class WXDLLIMPEXP_FL wxToolLayoutItem : public wxObject
24 {
25 DECLARE_DYNAMIC_CLASS(wxToolLayoutItem)
26
27 public:
28 wxRect mRect;
29 bool mIsSeparator;
30 };
31
32 class WXDLLIMPEXP_FL wxDynToolInfo;
33
34 typedef wxToolLayoutItem* wxToolLayoutItemPtrT;
35 typedef wxDynToolInfo* wxDynToolInfoPtrT;
36
37 WXFL_DEFINE_ARRAY_PTR( wxToolLayoutItemPtrT, wxLayoutItemArrayT );
38 WXFL_DEFINE_ARRAY_PTR( wxDynToolInfoPtrT, wxDynToolInfoArrayT );
39
40 /*
41 This is a base class for layout algorithm implementations.
42 */
43
44 class WXDLLIMPEXP_FL LayoutManagerBase
45 {
46 public:
47 // Constructor.
48 virtual void Layout( const wxSize& parentDim,
49 wxSize& resultingDim,
50 wxLayoutItemArrayT& items,
51 int horizGap,
52 int vertGap ) = 0;
53
54 // Destructor.
55 virtual ~LayoutManagerBase() {}
56 };
57
58 /*
59 BagLayout lays out items in left-to-right order from
60 top to bottom.
61 */
62
63 class WXDLLIMPEXP_FL BagLayout : public LayoutManagerBase
64 {
65 public:
66 // Constructor.
67 virtual void Layout( const wxSize& parentDim,
68 wxSize& resultingDim,
69 wxLayoutItemArrayT& items,
70 int horizGap,
71 int vertGap );
72 };
73
74 /*
75 This class holds dynamic toolbar item information.
76 */
77
78 class WXDLLIMPEXP_FL wxDynToolInfo : public wxToolLayoutItem
79 {
80 DECLARE_DYNAMIC_CLASS(wxDynToolInfo)
81
82 public:
83 wxWindow* mpToolWnd;
84 int mIndex;
85 wxSize mRealSize;
86 };
87
88 // Layout orientations for tools
89
90 #define LO_HORIZONTAL 0
91 #define LO_VERTICAL 1
92 #define LO_FIT_TO_WINDOW 2
93
94 /*
95 wxDynamicToolBar manages containment and layout of tool windows.
96 */
97
98 class WXDLLIMPEXP_FL wxDynamicToolBar : public wxToolBarBase
99 {
100 protected:
101 friend class wxDynamicToolBarSerializer;
102
103 wxDynToolInfoArrayT mTools;
104 LayoutManagerBase* mpLayoutMan;
105
106 protected:
107 // Internal function for sizing tool windows.
108 virtual void SizeToolWindows();
109
110 public: /* public properties */
111
112 int mSepartorSize; // default: 8
113 int mVertGap; // default: 0
114 int mHorizGap; // default: 0
115
116 public:
117 // Default constructor.
118
119 wxDynamicToolBar();
120
121 // Constructor: see the documentation for wxToolBar for details.
122
123 wxDynamicToolBar(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
124 const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
125 const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
126
127 // Destructor.
128
129 ~wxDynamicToolBar(void);
130
131 // Creation function: see the documentation for wxToolBar for details.
132
133 bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
134 const long style = wxNO_BORDER, const int orientation = wxVERTICAL, const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
135
136 // Adds a tool. See the documentation for wxToolBar for details.
137
138 virtual void AddTool( int toolIndex,
139 wxWindow* pToolWindow,
140 const wxSize& size = wxDefaultSize );
141
142 // Adds a tool. See the documentation for wxToolBar for details.
143
144 virtual void AddTool( int toolIndex,
145 const wxString& imageFileName,
146 wxBitmapType imageFileType = wxBITMAP_TYPE_BMP,
147 const wxString& labelText = wxT(""), bool alignTextRight = false,
148 bool isFlat = true );
149 // Adds a tool. See the documentation for wxToolBar for details.
150
151 virtual void AddTool( int toolIndex, wxBitmap labelBmp,
152 const wxString& labelText = wxT(""), bool alignTextRight = false,
153 bool isFlat = true );
154
155 // Unhide method from parent.
156
157 virtual wxToolBarToolBase *AddTool (wxToolBarToolBase *tool)
158 { return wxToolBarBase::AddTool(tool); };
159
160 // Method from wxToolBarBase (for compatibility), only
161 // the first two arguments are valid.
162 // See the documentation for wxToolBar for details.
163
164 virtual wxToolBarToolBase *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
165 const bool toggle = false, const long xPos = wxDefaultCoord, const long yPos = wxDefaultCoord, wxObject *clientData = NULL,
166 const wxString& helpString1 = wxT(""), const wxString& helpString2 = wxT(""));
167
168 // Adds a separator. See the documentation for wxToolBar for details.
169
170 virtual void AddSeparator( wxWindow* pSepartorWnd );
171
172 // Unhide method from parent.
173
174 virtual wxToolBarToolBase *AddSeparator()
175 { return wxToolBarBase::AddSeparator(); };
176
177 // Returns tool information for the given tool index.
178
179 wxDynToolInfo* GetToolInfo( int toolIndex );
180
181 // Removes the given tool. Misspelt in order not to clash with a similar function
182 // in the base class.
183
184 void RemveTool( int toolIndex );
185
186 // Draws a separator. The default implementation draws a shaded line.
187
188 virtual void DrawSeparator( wxDynToolInfo& info, wxDC& dc );
189
190 // Performs layout. See definitions of orientation types.
191
192 virtual bool Layout();
193
194 // Returns the preferred dimension, taking the given dimension and a reference to the result.
195
196 virtual void GetPreferredDim( const wxSize& givenDim, wxSize& prefDim );
197
198 // Creates the default layout (BagLayout).
199
200 virtual LayoutManagerBase* CreateDefaultLayout() { return new BagLayout(); }
201
202 // Sets the layout for this toolbar.
203
204 virtual void SetLayout( LayoutManagerBase* pLayout );
205
206 // Enables or disables the given tool.
207
208 virtual void EnableTool(int toolIndex, bool enable = true);
209
210 // Responds to size events, calling Layout.
211
212 void OnSize( wxSizeEvent& event );
213
214 // Responds to paint events, drawing separators.
215
216 void OnPaint( wxPaintEvent& event );
217
218 // Responds to background erase events. Currently does nothing.
219
220 void OnEraseBackground( wxEraseEvent& event );
221
222 // Overriden from wxToolBarBase; does nothing.
223
224 virtual bool Realize(void);
225
226 // Finds a tool for the given position.
227
228 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
229 wxCoord y) const;
230
231 // Inserts a tool at the given position.
232
233 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
234
235 // Deletes a tool. The tool is still in m_tools list when this function is called, and it will
236 // only be deleted from it if it succeeds.
237
238 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
239
240 // Called when the tools enabled flag changes.
241
242 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
243
244 // Called when the tool is toggled.
245
246 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
247
248 // Called when the tools 'can be toggled' flag changes.
249
250 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
251
252 // Creates a toolbar tool.
253
254 virtual wxToolBarToolBase *CreateTool(int id,
255 const wxString& label,
256 const wxBitmap& bmpNormal,
257 const wxBitmap& bmpDisabled,
258 wxItemKind kind,
259 wxObject *clientData,
260 const wxString& shortHelp,
261 const wxString& longHelp);
262
263 // Creates a toolbar tool.
264
265 virtual wxToolBarToolBase *CreateTool(wxControl *control);
266
267 private:
268 DECLARE_EVENT_TABLE()
269 DECLARE_DYNAMIC_CLASS(wxDynamicToolBar)
270 };
271
272 #endif /* __DYNTBAR_G__ */
273