]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/dyntbar.h
Modified Files:
[wxWidgets.git] / contrib / include / wx / fl / dyntbar.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: No names yet.
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by:
6 // Created: ??/10/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
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 // layout item
23
24 class wxToolLayoutItem : public wxObject
25 {
26 public:
27 wxRect mRect;
28 bool mIsSeparator;
29 };
30
31 class wxDynToolInfo;
32
33 typedef wxToolLayoutItem* wxToolLayoutItemPtrT;
34 typedef wxDynToolInfo* wxDynToolInfoPtrT;
35
36
37 WX_DEFINE_ARRAY( wxToolLayoutItemPtrT, wxLayoutItemArrayT );
38 WX_DEFINE_ARRAY( wxDynToolInfoPtrT, wxDynToolInfoArrayT );
39
40 // base class for layouting algorithm implementations
41
42 class LayoutManagerBase
43 {
44 public:
45 virtual void Layout( const wxSize& parentDim,
46 wxSize& resultingDim,
47 wxLayoutItemArrayT& items,
48 int horizGap,
49 int vertGap ) = 0;
50
51 virtual ~LayoutManagerBase() {}
52 };
53
54 // layouts items in left-to-right order from
55 // top towards bottom
56
57 class BagLayout : public LayoutManagerBase
58 {
59 public:
60 virtual void Layout( const wxSize& parentDim,
61 wxSize& resultingDim,
62 wxLayoutItemArrayT& items,
63 int horizGap,
64 int vertGap );
65 };
66
67 class wxDynToolInfo : public wxToolLayoutItem
68 {
69 DECLARE_DYNAMIC_CLASS(wxDynToolInfo)
70
71 public:
72 wxWindow* mpToolWnd;
73 int mIndex;
74 wxSize mRealSize;
75 };
76
77 // layouting orientations for tools
78
79 #define LO_HORIZONTAL 0
80 #define LO_VERTICAL 1
81 #define LO_FIT_TO_WINDOW 2
82
83 // class manages containment and layouting of tool-windows
84
85 class wxDynamicToolBar : public wxToolBarBase
86 {
87 DECLARE_DYNAMIC_CLASS(wxDynamicToolBar)
88 protected:
89
90 friend class wxDynamicToolBarSerializer;
91
92 wxDynToolInfoArrayT mTools;
93 LayoutManagerBase* mpLayoutMan;
94
95 protected:
96 virtual void SizeToolWindows();
97
98 public: /* public properties */
99
100 int mSepartorSize; // default: 8
101 int mVertGap; // default: 0
102 int mHorizGap; // default: 0
103
104 public:
105 wxDynamicToolBar();
106
107 wxDynamicToolBar(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
108 const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
109 const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
110
111 ~wxDynamicToolBar(void);
112
113 bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
114 const long style = wxNO_BORDER, const int orientation = wxVERTICAL, const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
115
116 // overridables
117
118 virtual void AddTool( int toolIndex,
119 wxWindow* pToolWindow,
120 const wxSize& size = wxDefaultSize );
121
122 virtual void AddTool( int toolIndex,
123 const wxString& imageFileName,
124 wxBitmapType imageFileType = wxBITMAP_TYPE_BMP,
125 const wxString& labelText = "", bool alignTextRight = FALSE,
126 bool isFlat = TRUE );
127 virtual void AddTool( int toolIndex, wxBitmap labelBmp,
128 const wxString& labelText = "", bool alignTextRight = FALSE,
129 bool isFlat = TRUE );
130
131 // method from wxToolBarBase (for compatibility), only
132 // first two arguments are valid
133
134 virtual wxToolBarToolBase *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
135 const bool toggle = FALSE, const long xPos = -1, const long yPos = -1, wxObject *clientData = NULL,
136 const wxString& helpString1 = "", const wxString& helpString2 = "");
137
138 virtual void AddSeparator( wxWindow* pSepartorWnd = NULL );
139
140 wxDynToolInfo* GetToolInfo( int toolIndex );
141
142 void RemveTool( int toolIndex );
143
144 // the default implementation draws shaded line
145 virtual void DrawSeparator( wxDynToolInfo& info, wxDC& dc );
146
147 // see definitions of orientation types
148 virtual bool Layout();
149
150 virtual void GetPreferredDim( const wxSize& givenDim, wxSize& prefDim );
151
152 virtual LayoutManagerBase* CreateDefaulLayout() { return new BagLayout(); }
153
154 virtual void SetLayout( LayoutManagerBase* pLayout );
155
156 virtual void EnableTool(const int toolIndex, const bool enable = TRUE);
157
158 // event handlers
159
160 void OnSize( wxSizeEvent& event );
161 void OnPaint( wxPaintEvent& event );
162 void OnEraseBackground( wxEraseEvent& event );
163
164 // overriden from wxToolBarBase
165
166 virtual bool Realize(void);
167
168 // stuff from the 2.1.15
169
170 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
171 wxCoord y) const;
172
173
174 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
175
176 // the tool is still in m_tools list when this function is called, it will
177 // only be deleted from it if it succeeds
178 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
179
180 // called when the tools enabled flag changes
181 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
182
183 // called when the tool is toggled
184 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
185
186 // called when the tools "can be toggled" flag changes
187 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
188
189 // the functions to create toolbar tools
190 virtual wxToolBarToolBase *CreateTool(int id,
191 const wxBitmap& bitmap1,
192 const wxBitmap& bitmap2,
193 bool toggle,
194 wxObject *clientData,
195 const wxString& shortHelpString,
196 const wxString& longHelpString);
197 virtual wxToolBarToolBase *CreateTool(wxControl *control);
198
199
200 DECLARE_EVENT_TABLE()
201 };
202
203 #endif /* __DYNTBAR_G__ */
204