]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/dyntbar.h
make pen/brush parameters const
[wxWidgets.git] / contrib / include / wx / fl / dyntbar.h
CommitLineData
8e08b761 1/////////////////////////////////////////////////////////////////////////////
4cbc57f0
JS
2// Name: dyntbar.h
3// Purpose: wxDynamicToolBar header
8e08b761
JS
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: ??/10/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
4cbc57f0 9// Licence: wxWindows licence
8e08b761
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __DYNTBAR_G__
13#define __DYNTBAR_G__
14
8e08b761
JS
15#include "wx/tbarbase.h"
16#include "wx/dynarray.h"
2b5f62a0 17#include "wx/fl/fldefs.h"
8e08b761 18
4cbc57f0
JS
19/*
20Tool layout item.
21*/
8e08b761 22
510b9edb 23class WXDLLIMPEXP_FL wxToolLayoutItem : public wxObject
8e08b761 24{
b2995a23
GT
25 DECLARE_DYNAMIC_CLASS(wxToolLayoutItem)
26
8e08b761 27public:
4cbc57f0
JS
28 wxRect mRect;
29 bool mIsSeparator;
8e08b761
JS
30};
31
510b9edb 32class WXDLLIMPEXP_FL wxDynToolInfo;
8e08b761
JS
33
34typedef wxToolLayoutItem* wxToolLayoutItemPtrT;
35typedef wxDynToolInfo* wxDynToolInfoPtrT;
36
659f8ec3
MB
37WXFL_DEFINE_ARRAY_PTR( wxToolLayoutItemPtrT, wxLayoutItemArrayT );
38WXFL_DEFINE_ARRAY_PTR( wxDynToolInfoPtrT, wxDynToolInfoArrayT );
8e08b761 39
4cbc57f0
JS
40/*
41This is a base class for layout algorithm implementations.
42*/
8e08b761 43
510b9edb 44class WXDLLIMPEXP_FL LayoutManagerBase
8e08b761
JS
45{
46public:
4cbc57f0
JS
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() {}
8e08b761
JS
56};
57
4cbc57f0
JS
58/*
59BagLayout lays out items in left-to-right order from
60top to bottom.
61*/
8e08b761 62
510b9edb 63class WXDLLIMPEXP_FL BagLayout : public LayoutManagerBase
8e08b761
JS
64{
65public:
4cbc57f0
JS
66 // Constructor.
67 virtual void Layout( const wxSize& parentDim,
68 wxSize& resultingDim,
69 wxLayoutItemArrayT& items,
70 int horizGap,
71 int vertGap );
8e08b761
JS
72};
73
4cbc57f0
JS
74/*
75This class holds dynamic toolbar item information.
76*/
77
510b9edb 78class WXDLLIMPEXP_FL wxDynToolInfo : public wxToolLayoutItem
8e08b761 79{
4cbc57f0 80 DECLARE_DYNAMIC_CLASS(wxDynToolInfo)
8e08b761
JS
81
82public:
4cbc57f0
JS
83 wxWindow* mpToolWnd;
84 int mIndex;
85 wxSize mRealSize;
8e08b761
JS
86};
87
4cbc57f0 88// Layout orientations for tools
8e08b761
JS
89
90#define LO_HORIZONTAL 0
91#define LO_VERTICAL 1
92#define LO_FIT_TO_WINDOW 2
93
4cbc57f0
JS
94/*
95wxDynamicToolBar manages containment and layout of tool windows.
96*/
8e08b761 97
510b9edb 98class WXDLLIMPEXP_FL wxDynamicToolBar : public wxToolBarBase
8e08b761 99{
b2995a23 100protected:
4cbc57f0 101 friend class wxDynamicToolBarSerializer;
8e08b761 102
4cbc57f0
JS
103 wxDynToolInfoArrayT mTools;
104 LayoutManagerBase* mpLayoutMan;
8e08b761
JS
105
106protected:
4cbc57f0
JS
107 // Internal function for sizing tool windows.
108 virtual void SizeToolWindows();
8e08b761
JS
109
110public: /* public properties */
111
4cbc57f0
JS
112 int mSepartorSize; // default: 8
113 int mVertGap; // default: 0
114 int mHorizGap; // default: 0
115
8e08b761 116public:
4cbc57f0
JS
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.
8e08b761 128
4cbc57f0 129 ~wxDynamicToolBar(void);
8e08b761 130
4cbc57f0 131 // Creation function: see the documentation for wxToolBar for details.
8e08b761 132
4cbc57f0
JS
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);
8e08b761 135
4cbc57f0 136 // Adds a tool. See the documentation for wxToolBar for details.
8e08b761 137
4cbc57f0
JS
138 virtual void AddTool( int toolIndex,
139 wxWindow* pToolWindow,
8252c9ca
GD
140 const wxSize& size = wxDefaultSize );
141
4cbc57f0
JS
142 // Adds a tool. See the documentation for wxToolBar for details.
143
144 virtual void AddTool( int toolIndex,
8252c9ca
GD
145 const wxString& imageFileName,
146 wxBitmapType imageFileType = wxBITMAP_TYPE_BMP,
c82c42d4
WS
147 const wxString& labelText = wxT(""), bool alignTextRight = false,
148 bool isFlat = true );
4cbc57f0
JS
149 // Adds a tool. See the documentation for wxToolBar for details.
150
151 virtual void AddTool( int toolIndex, wxBitmap labelBmp,
c82c42d4
WS
152 const wxString& labelText = wxT(""), bool alignTextRight = false,
153 bool isFlat = true );
8e08b761 154
8552e6f0
MB
155 // Unhide method from parent.
156
157 virtual wxToolBarToolBase *AddTool (wxToolBarToolBase *tool)
158 { return wxToolBarBase::AddTool(tool); };
159
4cbc57f0
JS
160 // Method from wxToolBarBase (for compatibility), only
161 // the first two arguments are valid.
162 // See the documentation for wxToolBar for details.
8e08b761 163
4cbc57f0 164 virtual wxToolBarToolBase *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
422d0ff0 165 const bool toggle = false, const long xPos = wxDefaultCoord, const long yPos = wxDefaultCoord, wxObject *clientData = NULL,
873a543b 166 const wxString& helpString1 = wxT(""), const wxString& helpString2 = wxT(""));
8e08b761 167
4cbc57f0
JS
168 // Adds a separator. See the documentation for wxToolBar for details.
169
8552e6f0 170 virtual void AddSeparator( wxWindow* pSepartorWnd );
4cbb46c9 171
8552e6f0
MB
172 // Unhide method from parent.
173
174 virtual wxToolBarToolBase *AddSeparator()
175 { return wxToolBarBase::AddSeparator(); };
4cbc57f0
JS
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.
8e08b761 187
4cbc57f0 188 virtual void DrawSeparator( wxDynToolInfo& info, wxDC& dc );
8e08b761 189
4cbc57f0 190 // Performs layout. See definitions of orientation types.
8e08b761 191
4cbc57f0 192 virtual bool Layout();
8e08b761 193
4cbc57f0 194 // Returns the preferred dimension, taking the given dimension and a reference to the result.
8e08b761 195
4cbc57f0 196 virtual void GetPreferredDim( const wxSize& givenDim, wxSize& prefDim );
8e08b761 197
4cbc57f0 198 // Creates the default layout (BagLayout).
8e08b761 199
4cbc57f0 200 virtual LayoutManagerBase* CreateDefaultLayout() { return new BagLayout(); }
8e08b761 201
4cbc57f0 202 // Sets the layout for this toolbar.
8e08b761 203
4cbc57f0 204 virtual void SetLayout( LayoutManagerBase* pLayout );
8e08b761 205
4cbc57f0 206 // Enables or disables the given tool.
8e08b761 207
c82c42d4 208 virtual void EnableTool(int toolIndex, bool enable = true);
8e08b761 209
4cbc57f0 210 // Responds to size events, calling Layout.
8e08b761 211
4cbc57f0
JS
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.
8e08b761
JS
227
228 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
229 wxCoord y) const;
230
4cbc57f0 231 // Inserts a tool at the given position.
8e08b761
JS
232
233 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
234
4cbc57f0
JS
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
8e08b761
JS
238 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
239
4cbc57f0
JS
240 // Called when the tools enabled flag changes.
241
8e08b761
JS
242 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
243
4cbc57f0
JS
244 // Called when the tool is toggled.
245
8e08b761
JS
246 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
247
4cbc57f0
JS
248 // Called when the tools 'can be toggled' flag changes.
249
8e08b761
JS
250 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
251
4cbc57f0
JS
252 // Creates a toolbar tool.
253
8e08b761 254 virtual wxToolBarToolBase *CreateTool(int id,
349f1d8e
VZ
255 const wxString& label,
256 const wxBitmap& bmpNormal,
257 const wxBitmap& bmpDisabled,
258 wxItemKind kind,
8e08b761 259 wxObject *clientData,
349f1d8e
VZ
260 const wxString& shortHelp,
261 const wxString& longHelp);
8e08b761 262
4cbc57f0
JS
263 // Creates a toolbar tool.
264
265 virtual wxToolBarToolBase *CreateTool(wxControl *control);
8e08b761 266
349f1d8e 267private:
4cbc57f0 268 DECLARE_EVENT_TABLE()
349f1d8e 269 DECLARE_DYNAMIC_CLASS(wxDynamicToolBar)
8e08b761
JS
270};
271
272#endif /* __DYNTBAR_G__ */
273