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