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