]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: toolbar.h | |
3 | // Purpose: wxToolBar class | |
d90895ac | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
d90895ac | 6 | // Created: 10/17/98 |
0e320a79 | 7 | // RCS-ID: $Id$ |
d90895ac DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_TOOLBAR_H_ | |
13 | #define _WX_TOOLBAR_H_ | |
14 | ||
d90895ac | 15 | #if wxUSE_TOOLBAR |
063807f6 | 16 | #include "wx/timer.h" |
0e320a79 DW |
17 | #include "wx/tbarbase.h" |
18 | ||
6c0fdfbb DW |
19 | #define ID_TOOLTIMER 100 |
20 | #define ID_TOOLEXPTIMER 101 | |
21 | ||
0e320a79 DW |
22 | class WXDLLEXPORT wxToolBar: public wxToolBarBase |
23 | { | |
97fdfcc9 DW |
24 | public: |
25 | /* | |
26 | * Public interface | |
27 | */ | |
28 | ||
6c0fdfbb DW |
29 | wxToolBar() |
30 | : m_vToolTimer(this, ID_TOOLTIMER) | |
31 | , m_vToolExpTimer(this, ID_TOOLEXPTIMER) | |
32 | { Init(); } | |
97fdfcc9 DW |
33 | |
34 | inline wxToolBar( wxWindow* pParent | |
35 | ,wxWindowID vId | |
36 | ,const wxPoint& rPos = wxDefaultPosition | |
37 | ,const wxSize& rSize = wxDefaultSize | |
d697657f | 38 | ,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL |
97fdfcc9 | 39 | ,const wxString& rName = wxToolBarNameStr |
6c0fdfbb DW |
40 | ) : m_vToolTimer(this, ID_TOOLTIMER) |
41 | , m_vToolExpTimer(this, ID_TOOLEXPTIMER) | |
97fdfcc9 | 42 | { |
d697657f | 43 | Init(); |
97fdfcc9 DW |
44 | Create( pParent |
45 | ,vId | |
46 | ,rPos | |
47 | ,rSize | |
48 | ,lStyle | |
49 | ,rName | |
50 | ); | |
51 | } | |
d697657f DW |
52 | virtual ~wxToolBar(); |
53 | ||
97fdfcc9 DW |
54 | bool Create( wxWindow* pParent |
55 | ,wxWindowID vId | |
56 | ,const wxPoint& rPos = wxDefaultPosition | |
57 | ,const wxSize& rSize = wxDefaultSize | |
d697657f | 58 | ,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL |
97fdfcc9 DW |
59 | ,const wxString& rName = wxToolBarNameStr |
60 | ); | |
61 | ||
97fdfcc9 | 62 | |
d697657f DW |
63 | // |
64 | // Override/implement base class virtuals | |
65 | // | |
66 | virtual wxToolBarToolBase* FindToolForPosition( wxCoord vX | |
67 | ,wxCoord vY | |
97fdfcc9 | 68 | ) const; |
d697657f DW |
69 | virtual bool Realize(void); |
70 | virtual void SetRows(int nRows); | |
97fdfcc9 | 71 | |
b6f4144e DW |
72 | // |
73 | // Special overrides for OS/2 | |
74 | // | |
75 | virtual wxToolBarToolBase* InsertControl( size_t nPos | |
76 | ,wxControl* pControl | |
77 | ); | |
78 | virtual wxToolBarToolBase* InsertSeparator(size_t nPos); | |
79 | virtual wxToolBarToolBase* InsertTool( size_t nPos | |
80 | ,int nId | |
81 | ,const wxString& rsLabel | |
82 | ,const wxBitmap& rBitmap | |
83 | ,const wxBitmap& rBmpDisabled = wxNullBitmap | |
84 | ,wxItemKind eKind = wxITEM_NORMAL | |
85 | ,const wxString& rsShortHelp = wxEmptyString | |
86 | ,const wxString& rsLongHelp = wxEmptyString | |
87 | ,wxObject* pClientData = NULL | |
88 | ); | |
89 | wxToolBarToolBase* InsertTool( size_t nPos | |
90 | ,int nId | |
91 | ,const wxBitmap& rBitmap | |
92 | ,const wxBitmap& rBmpDisabled = wxNullBitmap | |
93 | ,bool bToggle = FALSE | |
94 | ,wxObject* pClientData = NULL | |
95 | ,const wxString& rsShortHelp = wxEmptyString | |
96 | ,const wxString& rsLongHelp = wxEmptyString | |
97 | ) | |
98 | { | |
99 | return InsertTool( nPos | |
100 | ,nId | |
101 | ,wxEmptyString | |
102 | ,rBitmap | |
103 | ,rBmpDisabled | |
104 | ,bToggle ? wxITEM_CHECK : wxITEM_NORMAL | |
105 | ,rsShortHelp | |
106 | ,rsLongHelp | |
107 | ,pClientData | |
108 | ); | |
109 | } | |
110 | virtual bool DeleteTool(int nId); | |
111 | virtual bool DeleteToolByPos(size_t nPos); | |
112 | ||
d697657f DW |
113 | // |
114 | // Event handlers | |
115 | // | |
116 | void OnPaint(wxPaintEvent& event); | |
117 | void OnSize(wxSizeEvent& event); | |
118 | void OnMouseEvent(wxMouseEvent& event); | |
119 | void OnKillFocus(wxFocusEvent& event); | |
d90895ac | 120 | |
0e320a79 | 121 | protected: |
d697657f DW |
122 | // |
123 | // Common part of all ctors | |
124 | // | |
125 | void Init(); | |
126 | ||
127 | // | |
128 | // Implement base class pure virtuals | |
129 | // | |
130 | virtual wxToolBarToolBase* DoAddTool( int id | |
131 | ,const wxString& label | |
132 | ,const wxBitmap& bitmap | |
133 | ,const wxBitmap& bmpDisabled | |
134 | ,wxItemKind kind | |
135 | ,const wxString& shortHelp = wxEmptyString | |
136 | ,const wxString& longHelp = wxEmptyString | |
137 | ,wxObject *clientData = NULL | |
138 | ,wxCoord xPos = -1 | |
139 | ,wxCoord yPos = -1 | |
140 | ); | |
141 | ||
142 | virtual bool DoInsertTool( size_t nPos | |
143 | ,wxToolBarToolBase* pTool | |
144 | ); | |
145 | virtual bool DoDeleteTool( size_t nPos | |
146 | , wxToolBarToolBase* pTool | |
147 | ); | |
148 | ||
149 | virtual void DoEnableTool( wxToolBarToolBase* pTool | |
150 | ,bool bEnable | |
151 | ); | |
152 | virtual void DoToggleTool( wxToolBarToolBase* pTool | |
153 | ,bool bToggle | |
154 | ); | |
155 | virtual void DoSetToggle( wxToolBarToolBase* pTool | |
156 | ,bool bToggle | |
157 | ); | |
97fdfcc9 DW |
158 | |
159 | virtual wxToolBarToolBase* CreateTool( int vId | |
3437f881 | 160 | ,const wxString& rsLabel |
d697657f DW |
161 | ,const wxBitmap& rBmpNormal |
162 | ,const wxBitmap& rBmpDisabled | |
163 | ,wxItemKind eKind | |
97fdfcc9 | 164 | ,wxObject* pClientData |
d697657f DW |
165 | ,const wxString& rsShortHelp |
166 | ,const wxString& rsLongHelp | |
97fdfcc9 DW |
167 | ); |
168 | virtual wxToolBarToolBase* CreateTool(wxControl* pControl); | |
169 | ||
d697657f DW |
170 | // |
171 | // Helpers | |
172 | // | |
173 | void DrawTool(wxToolBarToolBase *tool); | |
174 | virtual void DrawTool( wxDC& rDC | |
175 | ,wxToolBarToolBase* pTool | |
176 | ); | |
177 | virtual void SpringUpButton(int nIndex); | |
178 | ||
179 | int m_nCurrentRowsOrColumns; | |
180 | int m_nPressedTool; | |
181 | int m_nCurrentTool; | |
182 | wxCoord m_vLastX; | |
183 | wxCoord m_vLastY; | |
184 | wxCoord m_vMaxWidth; | |
185 | wxCoord m_vMaxHeight; | |
186 | wxCoord m_vXPos; | |
187 | wxCoord m_vYPos; | |
188 | wxCoord m_vTextX; | |
189 | wxCoord m_vTextY; | |
97fdfcc9 | 190 | |
d697657f DW |
191 | private: |
192 | void LowerTool( wxToolBarToolBase* pTool | |
193 | ,bool bLower = TRUE | |
194 | ); | |
195 | void RaiseTool( wxToolBarToolBase* pTool | |
196 | ,bool bRaise = TRUE | |
197 | ); | |
6c0fdfbb | 198 | void OnTimer(wxTimerEvent& rEvent); |
97fdfcc9 | 199 | |
d697657f | 200 | static bool m_bInitialized; |
97fdfcc9 | 201 | |
6c0fdfbb DW |
202 | wxTimer m_vToolTimer; |
203 | wxTimer m_vToolExpTimer; | |
05facebb DW |
204 | wxToolTip* m_pToolTip; |
205 | wxCoord m_vXMouse; | |
206 | wxCoord m_vYMouse; | |
6c0fdfbb | 207 | |
4f5c180e DW |
208 | // |
209 | // Virtual function hiding supression | |
210 | virtual wxToolBarToolBase *InsertTool (size_t nPos, wxToolBarToolBase* pTool) | |
211 | { | |
212 | return( wxToolBarBase::InsertTool( nPos | |
213 | ,pTool | |
214 | )); | |
215 | } | |
216 | ||
97fdfcc9 DW |
217 | DECLARE_EVENT_TABLE() |
218 | DECLARE_DYNAMIC_CLASS(wxToolBar) | |
0e320a79 DW |
219 | }; |
220 | ||
d90895ac DW |
221 | #endif // wxUSE_TOOLBAR |
222 | ||
0e320a79 DW |
223 | #endif |
224 | // _WX_TOOLBAR_H_ |