]>
Commit | Line | Data |
---|---|---|
14d1ccd8 | 1 | ///////////////////////////////////////////////////////////////////////////// |
fc6bbc6d | 2 | // Name: toolbar.cpp |
14d1ccd8 JS |
3 | // Purpose: wxToolBar sample |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
ad9bb75f | 9 | // Licence: wxWindows licence |
14d1ccd8 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
ad9bb75f VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14d1ccd8 | 20 | // For compilers that support precompilation, includes "wx/wx.h". |
92a19c2e | 21 | #include "wx/wxprec.h" |
14d1ccd8 JS |
22 | |
23 | #ifdef __BORLANDC__ | |
ad9bb75f | 24 | #pragma hdrstop |
14d1ccd8 JS |
25 | #endif |
26 | ||
27 | #ifndef WX_PRECOMP | |
5f4d35b8 | 28 | #include "wx/wx.h" |
14d1ccd8 JS |
29 | #endif |
30 | ||
5f4d35b8 WS |
31 | #include "wx/toolbar.h" |
32 | #include "wx/log.h" | |
33 | #include "wx/image.h" | |
5e3b8b93 | 34 | #include "wx/filedlg.h" |
8bbe427f | 35 | |
f6bcfd97 | 36 | // define this to use XPMs everywhere (by default, BMPs are used under Win) |
0ed1d09c | 37 | // BMPs use less space, but aren't compiled into the executable on other platforms |
f6bcfd97 BP |
38 | #ifdef __WXMSW__ |
39 | #define USE_XPM_BITMAPS 0 | |
40 | #else | |
41 | #define USE_XPM_BITMAPS 1 | |
42 | #endif | |
43 | ||
f6bcfd97 BP |
44 | #if USE_XPM_BITMAPS && defined(__WXMSW__) && !wxUSE_XPM_IN_MSW |
45 | #error You need to enable XPM support to use XPM bitmaps with toolbar! | |
46 | #endif // USE_XPM_BITMAPS | |
47 | ||
ad9bb75f VZ |
48 | // ---------------------------------------------------------------------------- |
49 | // resources | |
50 | // ---------------------------------------------------------------------------- | |
14d1ccd8 | 51 | |
5f4d35b8 | 52 | #if !defined(__WXMSW__) && !defined(__WXPM__) |
ad9bb75f | 53 | #include "mondrian.xpm" |
5f4d35b8 WS |
54 | #endif |
55 | ||
56 | #if USE_XPM_BITMAPS | |
ad9bb75f VZ |
57 | #include "bitmaps/new.xpm" |
58 | #include "bitmaps/open.xpm" | |
59 | #include "bitmaps/save.xpm" | |
60 | #include "bitmaps/copy.xpm" | |
61 | #include "bitmaps/cut.xpm" | |
5ef2e633 | 62 | #include "bitmaps/preview.xpm" // paste XPM |
ad9bb75f | 63 | #include "bitmaps/print.xpm" |
ad9bb75f | 64 | #include "bitmaps/help.xpm" |
f6bcfd97 | 65 | #endif // USE_XPM_BITMAPS |
ad9bb75f | 66 | |
7a976304 VZ |
67 | enum Positions |
68 | { | |
69 | TOOLBAR_LEFT, | |
70 | TOOLBAR_TOP, | |
71 | TOOLBAR_RIGHT, | |
72 | TOOLBAR_BOTTOM | |
73 | }; | |
74 | ||
ad9bb75f VZ |
75 | // ---------------------------------------------------------------------------- |
76 | // classes | |
77 | // ---------------------------------------------------------------------------- | |
78 | ||
79 | // Define a new application | |
5ef2e633 | 80 | class MyApp : public wxApp |
ad9bb75f VZ |
81 | { |
82 | public: | |
83 | bool OnInit(); | |
ad9bb75f | 84 | }; |
47908e25 | 85 | |
ad9bb75f VZ |
86 | // Define a new frame |
87 | class MyFrame: public wxFrame | |
88 | { | |
89 | public: | |
90 | MyFrame(wxFrame *parent, | |
bc2ec626 | 91 | wxWindowID id = wxID_ANY, |
ab1ca7b3 | 92 | const wxString& title = _T("wxToolBar Sample"), |
ad9bb75f VZ |
93 | const wxPoint& pos = wxDefaultPosition, |
94 | const wxSize& size = wxDefaultSize, | |
229de929 | 95 | long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE); |
14d1ccd8 | 96 | |
5ef2e633 VZ |
97 | void RecreateToolbar(); |
98 | ||
ad9bb75f VZ |
99 | void OnQuit(wxCommandEvent& event); |
100 | void OnAbout(wxCommandEvent& event); | |
101 | ||
f6bcfd97 BP |
102 | void OnSize(wxSizeEvent& event); |
103 | ||
ba0abe3c | 104 | void OnToggleToolbar(wxCommandEvent& event); |
f6bcfd97 | 105 | void OnToggleAnotherToolbar(wxCommandEvent& event); |
96dc4236 | 106 | void OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event)); |
f6bcfd97 | 107 | |
5ef2e633 | 108 | void OnToggleToolbarSize(wxCommandEvent& event); |
7a976304 | 109 | void OnChangeOrientation(wxCommandEvent& event); |
98066234 | 110 | void OnToggleToolbarRows(wxCommandEvent& event); |
6a1b3ead | 111 | void OnToggleTooltips(wxCommandEvent& event); |
8d0a7b56 | 112 | void OnToggleCustomDisabled(wxCommandEvent& event); |
5ef2e633 | 113 | |
ad4ae6ed VZ |
114 | void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); } |
115 | void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); } | |
bdc72a22 | 116 | void OnInsertPrint(wxCommandEvent& event); |
a1f79c1e | 117 | void OnChangeToolTip(wxCommandEvent& event); |
ad4ae6ed | 118 | void OnToggleHelp(wxCommandEvent& WXUNUSED(event)) { DoToggleHelp(); } |
3bf4189d | 119 | void OnToggleRadioBtn(wxCommandEvent& event); |
ad9bb75f | 120 | |
ec483b11 | 121 | void OnToolbarStyle(wxCommandEvent& event); |
5e3b8b93 | 122 | void OnToolbarCustomBitmap(wxCommandEvent& event); |
ec483b11 | 123 | |
ad9bb75f | 124 | void OnToolLeftClick(wxCommandEvent& event); |
e052a316 | 125 | void OnToolRightClick(wxCommandEvent& event); |
ad9bb75f | 126 | |
1c383dba VZ |
127 | void OnCombo(wxCommandEvent& event); |
128 | ||
5ef2e633 | 129 | void OnUpdateCopyAndCut(wxUpdateUIEvent& event); |
96dc4236 | 130 | void OnUpdateToggleHorzText(wxUpdateUIEvent& event); |
3bf4189d VZ |
131 | void OnUpdateToggleRadioBtn(wxUpdateUIEvent& event) |
132 | { event.Enable( m_tbar != NULL ); } | |
5ef2e633 | 133 | |
ad9bb75f VZ |
134 | private: |
135 | void DoEnablePrint(); | |
97d7bfb8 | 136 | void DoDeletePrint(); |
ad9bb75f VZ |
137 | void DoToggleHelp(); |
138 | ||
f6bcfd97 BP |
139 | void LayoutChildren(); |
140 | ||
5ef2e633 | 141 | bool m_smallToolbar, |
8d0a7b56 | 142 | m_horzText, |
6a1b3ead VZ |
143 | m_useCustomDisabled, |
144 | m_showTooltips; | |
98066234 VZ |
145 | size_t m_rows; // 1 or 2 only |
146 | ||
2b5f62a0 VZ |
147 | // the number of print buttons we have (they're added/removed dynamically) |
148 | size_t m_nPrint; | |
149 | ||
7a976304 VZ |
150 | // store toolbar position for future use |
151 | Positions m_toolbarPosition; | |
152 | ||
f6bcfd97 BP |
153 | wxTextCtrl *m_textWindow; |
154 | ||
155 | wxToolBar *m_tbar; | |
ad9bb75f | 156 | |
5e3b8b93 VZ |
157 | // the path to the custom bitmap for the test toolbar tool |
158 | wxString m_pathBmp; | |
159 | ||
ad9bb75f VZ |
160 | DECLARE_EVENT_TABLE() |
161 | }; | |
162 | ||
163 | // ---------------------------------------------------------------------------- | |
164 | // constants | |
165 | // ---------------------------------------------------------------------------- | |
166 | ||
167 | const int ID_TOOLBAR = 500; | |
168 | ||
dd46ee66 | 169 | static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT; |
86f65864 | 170 | |
ad9bb75f | 171 | enum |
14d1ccd8 | 172 | { |
5ef2e633 | 173 | IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200, |
98066234 | 174 | IDM_TOOLBAR_TOGGLETOOLBARROWS, |
6a1b3ead | 175 | IDM_TOOLBAR_TOGGLETOOLTIPS, |
8d0a7b56 | 176 | IDM_TOOLBAR_TOGGLECUSTOMDISABLED, |
ad9bb75f | 177 | IDM_TOOLBAR_ENABLEPRINT, |
97d7bfb8 | 178 | IDM_TOOLBAR_DELETEPRINT, |
bdc72a22 | 179 | IDM_TOOLBAR_INSERTPRINT, |
1c383dba | 180 | IDM_TOOLBAR_TOGGLEHELP, |
3bf4189d VZ |
181 | IDM_TOOLBAR_TOGGLERADIOBTN1, |
182 | IDM_TOOLBAR_TOGGLERADIOBTN2, | |
183 | IDM_TOOLBAR_TOGGLERADIOBTN3, | |
ba0abe3c | 184 | IDM_TOOLBAR_TOGGLE_TOOLBAR, |
96dc4236 | 185 | IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT, |
f6bcfd97 | 186 | IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, |
a1f79c1e | 187 | IDM_TOOLBAR_CHANGE_TOOLTIP, |
ec483b11 VZ |
188 | IDM_TOOLBAR_SHOW_TEXT, |
189 | IDM_TOOLBAR_SHOW_ICONS, | |
190 | IDM_TOOLBAR_SHOW_BOTH, | |
5e3b8b93 | 191 | IDM_TOOLBAR_CUSTOM_PATH, |
7a976304 VZ |
192 | IDM_TOOLBAR_TOP_ORIENTATION, |
193 | IDM_TOOLBAR_LEFT_ORIENTATION, | |
5b2acc3a | 194 | IDM_TOOLBAR_BOTTOM_ORIENTATION, |
7a976304 | 195 | IDM_TOOLBAR_RIGHT_ORIENTATION, |
3bf4189d VZ |
196 | IDM_TOOLBAR_OTHER_1, |
197 | IDM_TOOLBAR_OTHER_2, | |
198 | IDM_TOOLBAR_OTHER_3, | |
199 | ||
5b2acc3a RR |
200 | ID_COMBO = 1000, |
201 | ID_SPIN = 1001 | |
ad9bb75f | 202 | }; |
14d1ccd8 | 203 | |
ad9bb75f VZ |
204 | // ---------------------------------------------------------------------------- |
205 | // event tables | |
206 | // ---------------------------------------------------------------------------- | |
14d1ccd8 | 207 | |
ad9bb75f VZ |
208 | // Notice that wxID_HELP will be processed for the 'About' menu and the toolbar |
209 | // help button. | |
14d1ccd8 | 210 | |
ad9bb75f | 211 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) |
f6bcfd97 BP |
212 | EVT_SIZE(MyFrame::OnSize) |
213 | ||
ad9bb75f VZ |
214 | EVT_MENU(wxID_EXIT, MyFrame::OnQuit) |
215 | EVT_MENU(wxID_HELP, MyFrame::OnAbout) | |
14d1ccd8 | 216 | |
ba0abe3c | 217 | EVT_MENU(IDM_TOOLBAR_TOGGLE_TOOLBAR, MyFrame::OnToggleToolbar) |
f6bcfd97 | 218 | EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, MyFrame::OnToggleAnotherToolbar) |
96dc4236 | 219 | EVT_MENU(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT, MyFrame::OnToggleHorizontalText) |
f6bcfd97 | 220 | |
7a976304 | 221 | EVT_MENU_RANGE(IDM_TOOLBAR_TOP_ORIENTATION, IDM_TOOLBAR_RIGHT_ORIENTATION, MyFrame::OnChangeOrientation) |
5ef2e633 | 222 | EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize) |
98066234 | 223 | EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows) |
6a1b3ead | 224 | EVT_MENU(IDM_TOOLBAR_TOGGLETOOLTIPS, MyFrame::OnToggleTooltips) |
8d0a7b56 | 225 | EVT_MENU(IDM_TOOLBAR_TOGGLECUSTOMDISABLED, MyFrame::OnToggleCustomDisabled) |
5ef2e633 | 226 | |
ad9bb75f | 227 | EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint) |
97d7bfb8 | 228 | EVT_MENU(IDM_TOOLBAR_DELETEPRINT, MyFrame::OnDeletePrint) |
bdc72a22 | 229 | EVT_MENU(IDM_TOOLBAR_INSERTPRINT, MyFrame::OnInsertPrint) |
ad9bb75f | 230 | EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp) |
3bf4189d VZ |
231 | EVT_MENU_RANGE(IDM_TOOLBAR_TOGGLERADIOBTN1, IDM_TOOLBAR_TOGGLERADIOBTN3, |
232 | MyFrame::OnToggleRadioBtn) | |
a1f79c1e | 233 | EVT_MENU(IDM_TOOLBAR_CHANGE_TOOLTIP, MyFrame::OnChangeToolTip) |
14d1ccd8 | 234 | |
ec483b11 VZ |
235 | EVT_MENU_RANGE(IDM_TOOLBAR_SHOW_TEXT, IDM_TOOLBAR_SHOW_BOTH, |
236 | MyFrame::OnToolbarStyle) | |
237 | ||
5e3b8b93 VZ |
238 | EVT_MENU(IDM_TOOLBAR_CUSTOM_PATH, MyFrame::OnToolbarCustomBitmap) |
239 | ||
bc2ec626 | 240 | EVT_MENU(wxID_ANY, MyFrame::OnToolLeftClick) |
14d1ccd8 | 241 | |
1c383dba VZ |
242 | EVT_COMBOBOX(ID_COMBO, MyFrame::OnCombo) |
243 | ||
e052a316 | 244 | EVT_TOOL_RCLICKED(wxID_ANY, MyFrame::OnToolRightClick) |
5ef2e633 VZ |
245 | |
246 | EVT_UPDATE_UI(wxID_COPY, MyFrame::OnUpdateCopyAndCut) | |
247 | EVT_UPDATE_UI(wxID_CUT, MyFrame::OnUpdateCopyAndCut) | |
96dc4236 | 248 | |
3bf4189d VZ |
249 | EVT_UPDATE_UI_RANGE(IDM_TOOLBAR_TOGGLERADIOBTN1, |
250 | IDM_TOOLBAR_TOGGLERADIOBTN3, | |
251 | MyFrame::OnUpdateToggleRadioBtn) | |
96dc4236 VZ |
252 | EVT_UPDATE_UI(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT, |
253 | MyFrame::OnUpdateToggleHorzText) | |
ad9bb75f | 254 | END_EVENT_TABLE() |
14d1ccd8 | 255 | |
ad9bb75f VZ |
256 | // ============================================================================ |
257 | // implementation | |
258 | // ============================================================================ | |
14d1ccd8 | 259 | |
ad9bb75f VZ |
260 | // ---------------------------------------------------------------------------- |
261 | // MyApp | |
262 | // ---------------------------------------------------------------------------- | |
14d1ccd8 | 263 | |
ad9bb75f | 264 | IMPLEMENT_APP(MyApp) |
14d1ccd8 | 265 | |
ad9bb75f VZ |
266 | // The `main program' equivalent, creating the windows and returning the |
267 | // main frame | |
268 | bool MyApp::OnInit() | |
269 | { | |
270 | // Create the main frame window | |
bc2ec626 | 271 | MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY, |
ab1ca7b3 | 272 | _T("wxToolBar Sample"), |
5e3b8b93 | 273 | wxPoint(100, 100), wxSize(550, 300)); |
14d1ccd8 | 274 | |
bc2ec626 | 275 | frame->Show(true); |
7fb23305 | 276 | |
8520f137 | 277 | #if wxUSE_STATUSBAR |
be5a51fb | 278 | frame->SetStatusText(_T("Hello, wxWidgets")); |
0cfc2a92 | 279 | #endif |
7fb23305 | 280 | |
5e3b8b93 VZ |
281 | wxInitAllImageHandlers(); |
282 | ||
7fb23305 VZ |
283 | SetTopWindow(frame); |
284 | ||
bc2ec626 | 285 | return true; |
14d1ccd8 JS |
286 | } |
287 | ||
5ef2e633 | 288 | void MyFrame::RecreateToolbar() |
14d1ccd8 | 289 | { |
bf95a04f JS |
290 | #ifdef __WXWINCE__ |
291 | // On Windows CE, we should not delete the | |
292 | // previous toolbar in case it contains the menubar. | |
34621cc5 | 293 | // We'll try to accommodate this usage in due course. |
bf95a04f JS |
294 | wxToolBar* toolBar = CreateToolBar(); |
295 | #else | |
5ef2e633 | 296 | // delete and recreate the toolbar |
ad4ae6ed | 297 | wxToolBarBase *toolBar = GetToolBar(); |
ec483b11 VZ |
298 | long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE; |
299 | ||
5ef2e633 | 300 | delete toolBar; |
14d1ccd8 | 301 | |
5ef2e633 VZ |
302 | SetToolBar(NULL); |
303 | ||
7a976304 VZ |
304 | style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT); |
305 | switch( m_toolbarPosition ) | |
306 | { | |
307 | case TOOLBAR_LEFT: | |
308 | style |= wxTB_LEFT; | |
309 | break; | |
310 | case TOOLBAR_TOP: | |
311 | style |= wxTB_TOP; | |
312 | break; | |
313 | case TOOLBAR_RIGHT: | |
314 | style |= wxTB_RIGHT; | |
315 | break; | |
316 | case TOOLBAR_BOTTOM: | |
5b2acc3a | 317 | style |= wxTB_BOTTOM; |
7a976304 VZ |
318 | break; |
319 | } | |
96dc4236 | 320 | |
6a1b3ead VZ |
321 | if ( m_showTooltips ) |
322 | style &= ~wxTB_NO_TOOLTIPS; | |
323 | else | |
324 | style |= wxTB_NO_TOOLTIPS; | |
325 | ||
96dc4236 VZ |
326 | if ( style & wxTB_TEXT && !(style & wxTB_NOICONS) && m_horzText ) |
327 | style |= wxTB_HORZ_LAYOUT; | |
5ef2e633 VZ |
328 | |
329 | toolBar = CreateToolBar(style, ID_TOOLBAR); | |
bf95a04f | 330 | #endif |
5ef2e633 VZ |
331 | |
332 | // Set up toolbar | |
8d0a7b56 VZ |
333 | enum |
334 | { | |
335 | Tool_new, | |
336 | Tool_open, | |
337 | Tool_save, | |
338 | Tool_copy, | |
339 | Tool_cut, | |
340 | Tool_paste, | |
341 | Tool_print, | |
342 | Tool_help, | |
343 | Tool_Max | |
344 | }; | |
345 | ||
346 | wxBitmap toolBarBitmaps[Tool_Max]; | |
5ef2e633 | 347 | |
f6bcfd97 | 348 | #if USE_XPM_BITMAPS |
8d0a7b56 VZ |
349 | #define INIT_TOOL_BMP(bmp) \ |
350 | toolBarBitmaps[Tool_##bmp] = wxBitmap(bmp##_xpm) | |
f6bcfd97 | 351 | #else // !USE_XPM_BITMAPS |
8d0a7b56 VZ |
352 | #define INIT_TOOL_BMP(bmp) \ |
353 | toolBarBitmaps[Tool_##bmp] = wxBITMAP(bmp) | |
f6bcfd97 | 354 | #endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS |
40515a21 | 355 | |
8d0a7b56 VZ |
356 | INIT_TOOL_BMP(new); |
357 | INIT_TOOL_BMP(open); | |
358 | INIT_TOOL_BMP(save); | |
359 | INIT_TOOL_BMP(copy); | |
360 | INIT_TOOL_BMP(cut); | |
361 | INIT_TOOL_BMP(paste); | |
362 | INIT_TOOL_BMP(print); | |
363 | INIT_TOOL_BMP(help); | |
364 | ||
365 | int w = toolBarBitmaps[Tool_new].GetWidth(), | |
366 | h = toolBarBitmaps[Tool_new].GetHeight(); | |
367 | ||
5ef2e633 VZ |
368 | if ( !m_smallToolbar ) |
369 | { | |
8d0a7b56 VZ |
370 | w *= 2; |
371 | h *= 2; | |
372 | ||
373 | for ( size_t n = Tool_new; n < WXSIZEOF(toolBarBitmaps); n++ ) | |
40515a21 VZ |
374 | { |
375 | toolBarBitmaps[n] = | |
368d59f0 | 376 | wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h)); |
40515a21 | 377 | } |
5ef2e633 | 378 | } |
14d1ccd8 | 379 | |
6a1b3ead VZ |
380 | toolBar->SetToolBitmapSize(wxSize(w, h)); |
381 | ||
e112f019 VZ |
382 | toolBar->AddTool(wxID_NEW, _T("New"), |
383 | toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_NORMAL, | |
384 | _T("New file"), _T("This is help for new file tool")); | |
385 | toolBar->AddTool(wxID_OPEN, _T("Open"), | |
386 | toolBarBitmaps[Tool_open], wxNullBitmap, wxITEM_NORMAL, | |
387 | _T("Open file"), _T("This is help for open file tool")); | |
14d1ccd8 | 388 | |
aae91497 | 389 | // the generic toolbar doesn't really support this |
27cc9142 | 390 | #if wxUSE_TOOLBAR_NATIVE && !defined(__WXX11__) || defined(__WXUNIVERSAL__) |
5ef2e633 | 391 | // adding a combo to a vertical toolbar is not very smart |
7a976304 | 392 | if ( !( toolBar->IsVertical() ) ) |
5ef2e633 | 393 | { |
5f4d35b8 | 394 | wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, wxEmptyString, wxDefaultPosition, wxSize(200,wxDefaultCoord) ); |
2b5f62a0 VZ |
395 | combo->Append(_T("This")); |
396 | combo->Append(_T("is a")); | |
397 | combo->Append(_T("combobox")); | |
398 | combo->Append(_T("in a")); | |
399 | combo->Append(_T("toolbar")); | |
5ef2e633 | 400 | toolBar->AddControl(combo); |
6bbb8a8d | 401 | |
5b2acc3a RR |
402 | //wxSpinCtrl *spin = new wxSpinCtrl( toolBar, ID_SPIN, wxT("0"), wxDefaultPosition, wxSize(80,wxDefaultCoord), 0, 100, 0 ); |
403 | //toolBar->AddControl( spin ); | |
5ef2e633 | 404 | } |
ad4ae6ed | 405 | #endif // toolbars which don't support controls |
14d1ccd8 | 406 | |
8d0a7b56 VZ |
407 | toolBar->AddTool(wxID_SAVE, _T("Save"), toolBarBitmaps[Tool_save], _T("Toggle button 1"), wxITEM_CHECK); |
408 | toolBar->AddTool(wxID_COPY, _T("Copy"), toolBarBitmaps[Tool_copy], _T("Toggle button 2"), wxITEM_CHECK); | |
409 | toolBar->AddTool(wxID_CUT, _T("Cut"), toolBarBitmaps[Tool_cut], _T("Toggle/Untoggle help button")); | |
410 | toolBar->AddTool(wxID_PASTE, _T("Paste"), toolBarBitmaps[Tool_paste], _T("Paste")); | |
411 | ||
412 | if ( m_useCustomDisabled ) | |
413 | { | |
414 | wxBitmap bmpDisabled(w, h); | |
415 | { | |
416 | wxMemoryDC dc; | |
417 | dc.SelectObject(bmpDisabled); | |
418 | dc.DrawBitmap(toolBarBitmaps[Tool_print], 0, 0); | |
419 | ||
420 | wxPen pen(*wxRED, 5); | |
421 | dc.SetPen(pen); | |
422 | dc.DrawLine(0, 0, w, h); | |
423 | } | |
424 | ||
425 | toolBar->AddTool(wxID_PRINT, _T("Print"), toolBarBitmaps[Tool_print], | |
426 | bmpDisabled); | |
427 | } | |
428 | else | |
429 | { | |
430 | toolBar->AddTool(wxID_PRINT, _T("Print"), toolBarBitmaps[Tool_print], | |
431 | _T("Delete this tool. This is a very long tooltip to test whether it does the right thing when the tooltip is more than Windows can cope with.")); | |
432 | } | |
433 | ||
40515a21 | 434 | toolBar->AddSeparator(); |
8d0a7b56 | 435 | toolBar->AddTool(wxID_HELP, _T("Help"), toolBarBitmaps[Tool_help], _T("Help button"), wxITEM_CHECK); |
13437238 | 436 | |
5e3b8b93 VZ |
437 | if ( !m_pathBmp.empty() ) |
438 | { | |
439 | // create a tool with a custom bitmap for testing | |
440 | wxImage img(m_pathBmp); | |
441 | if ( img.Ok() ) | |
442 | { | |
443 | if ( img.GetWidth() > w && img.GetHeight() > h ) | |
444 | img = img.GetSubImage(wxRect(0, 0, w, h)); | |
445 | ||
446 | toolBar->AddSeparator(); | |
447 | toolBar->AddTool(wxID_ANY, _T("Custom"), img); | |
448 | } | |
449 | } | |
450 | ||
5ef2e633 VZ |
451 | // after adding the buttons to the toolbar, must call Realize() to reflect |
452 | // the changes | |
453 | toolBar->Realize(); | |
98066234 | 454 | |
7a976304 | 455 | toolBar->SetRows(!(toolBar->IsVertical()) ? m_rows : 10 / m_rows); |
14d1ccd8 JS |
456 | } |
457 | ||
ad9bb75f VZ |
458 | // ---------------------------------------------------------------------------- |
459 | // MyFrame | |
460 | // ---------------------------------------------------------------------------- | |
13437238 JS |
461 | |
462 | // Define my frame constructor | |
7fb23305 VZ |
463 | MyFrame::MyFrame(wxFrame* parent, |
464 | wxWindowID id, | |
465 | const wxString& title, | |
466 | const wxPoint& pos, | |
467 | const wxSize& size, | |
468 | long style) | |
469 | : wxFrame(parent, id, title, pos, size, style) | |
14d1ccd8 | 470 | { |
f6bcfd97 | 471 | m_tbar = NULL; |
98066234 | 472 | |
bc2ec626 | 473 | m_smallToolbar = true; |
bc2ec626 | 474 | m_horzText = false; |
8d0a7b56 | 475 | m_useCustomDisabled = false; |
6a1b3ead VZ |
476 | m_showTooltips = true; |
477 | ||
98066234 | 478 | m_rows = 1; |
2b5f62a0 | 479 | m_nPrint = 1; |
ad9bb75f | 480 | |
8520f137 | 481 | #if wxUSE_STATUSBAR |
ad9bb75f VZ |
482 | // Give it a status line |
483 | CreateStatusBar(); | |
0cfc2a92 | 484 | #endif |
ad9bb75f VZ |
485 | |
486 | // Give it an icon | |
487 | SetIcon(wxICON(mondrian)); | |
488 | ||
489 | // Make a menubar | |
490 | wxMenu *tbarMenu = new wxMenu; | |
ba0abe3c | 491 | tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLE_TOOLBAR, |
2b5f62a0 VZ |
492 | _T("Toggle &toolbar\tCtrl-Z"), |
493 | _T("Show or hide the toolbar")); | |
ba0abe3c VZ |
494 | |
495 | tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, | |
2b5f62a0 VZ |
496 | _T("Toggle &another toolbar\tCtrl-A"), |
497 | _T("Show/hide another test toolbar")); | |
ba0abe3c | 498 | |
96dc4236 VZ |
499 | tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT, |
500 | _T("Toggle hori&zontal text\tCtrl-H"), | |
501 | _T("Show text under/alongside the icon")); | |
502 | ||
ba0abe3c | 503 | tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARSIZE, |
2b5f62a0 VZ |
504 | _T("&Toggle toolbar size\tCtrl-S"), |
505 | _T("Toggle between big/small toolbar")); | |
ba0abe3c | 506 | |
ba0abe3c | 507 | tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARROWS, |
2b5f62a0 VZ |
508 | _T("Toggle number of &rows\tCtrl-R"), |
509 | _T("Toggle number of toolbar rows between 1 and 2")); | |
5ef2e633 | 510 | |
6a1b3ead VZ |
511 | tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLTIPS, |
512 | _T("Show &tooltips\tCtrl-L"), | |
513 | _T("Show tooltips for the toolbar tools")); | |
514 | ||
8d0a7b56 VZ |
515 | tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLECUSTOMDISABLED, |
516 | _T("Use c&ustom disabled images\tCtrl-U"), | |
517 | _T("Switch between using system-generated and custom disabled images")); | |
518 | ||
519 | ||
7a976304 VZ |
520 | tbarMenu->AppendSeparator(); |
521 | tbarMenu->AppendRadioItem(IDM_TOOLBAR_TOP_ORIENTATION, | |
522 | _T("Set toolbar at the top of the window"), | |
523 | _T("Set toolbar at the top of the window")); | |
524 | tbarMenu->AppendRadioItem(IDM_TOOLBAR_LEFT_ORIENTATION, | |
525 | _T("Set toolbar at the left of the window"), | |
526 | _T("Set toolbar at the left of the window")); | |
527 | tbarMenu->AppendRadioItem(IDM_TOOLBAR_BOTTOM_ORIENTATION, | |
5b2acc3a RR |
528 | _T("Set toolbar at the bottom of the window"), |
529 | _T("Set toolbar at the bottom of the window")); | |
7a976304 VZ |
530 | tbarMenu->AppendRadioItem(IDM_TOOLBAR_RIGHT_ORIENTATION, |
531 | _T("Set toolbar at the right edge of the window"), | |
532 | _T("Set toolbar at the right edge of the window")); | |
5ef2e633 VZ |
533 | tbarMenu->AppendSeparator(); |
534 | ||
5e3b8b93 VZ |
535 | tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, _T("&Enable print button\tCtrl-E")); |
536 | tbarMenu->Append(IDM_TOOLBAR_DELETEPRINT, _T("&Delete print button\tCtrl-D")); | |
537 | tbarMenu->Append(IDM_TOOLBAR_INSERTPRINT, _T("&Insert print button\tCtrl-I")); | |
538 | tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, _T("Toggle &help button\tCtrl-T")); | |
a1f79c1e | 539 | tbarMenu->AppendSeparator(); |
5e3b8b93 VZ |
540 | tbarMenu->Append(IDM_TOOLBAR_TOGGLERADIOBTN1, _T("Toggle &1st radio button\tCtrl-1")); |
541 | tbarMenu->Append(IDM_TOOLBAR_TOGGLERADIOBTN2, _T("Toggle &2nd radio button\tCtrl-2")); | |
542 | tbarMenu->Append(IDM_TOOLBAR_TOGGLERADIOBTN3, _T("Toggle &3rd radio button\tCtrl-3")); | |
3bf4189d | 543 | tbarMenu->AppendSeparator(); |
5e3b8b93 | 544 | tbarMenu->Append(IDM_TOOLBAR_CHANGE_TOOLTIP, _T("Change tool tip")); |
ec483b11 | 545 | tbarMenu->AppendSeparator(); |
f5e6e431 VZ |
546 | tbarMenu->AppendRadioItem(IDM_TOOLBAR_SHOW_TEXT, _T("Show &text\tCtrl-Alt-T")); |
547 | tbarMenu->AppendRadioItem(IDM_TOOLBAR_SHOW_ICONS, _T("Show &icons\tCtrl-Alt-I")); | |
548 | tbarMenu->AppendRadioItem(IDM_TOOLBAR_SHOW_BOTH, _T("Show &both\tCtrl-Alt-B")); | |
5e3b8b93 VZ |
549 | tbarMenu->AppendSeparator(); |
550 | tbarMenu->Append(IDM_TOOLBAR_CUSTOM_PATH, _T("Custom &bitmap...\tCtrl-B")); | |
b487a08f | 551 | |
ad9bb75f | 552 | wxMenu *fileMenu = new wxMenu; |
2b5f62a0 | 553 | fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit toolbar sample") ); |
ad9bb75f | 554 | |
ad9bb75f | 555 | wxMenu *helpMenu = new wxMenu; |
2b5f62a0 | 556 | helpMenu->Append(wxID_HELP, _T("&About"), _T("About toolbar sample")); |
ad9bb75f VZ |
557 | |
558 | wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE ); | |
559 | ||
2b5f62a0 VZ |
560 | menuBar->Append(fileMenu, _T("&File")); |
561 | menuBar->Append(tbarMenu, _T("&Toolbar")); | |
562 | menuBar->Append(helpMenu, _T("&Help")); | |
ad9bb75f VZ |
563 | |
564 | // Associate the menu bar with the frame | |
565 | SetMenuBar(menuBar); | |
566 | ||
bc2ec626 | 567 | menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, true); |
6a1b3ead | 568 | menuBar->Check(IDM_TOOLBAR_TOGGLETOOLTIPS, true); |
c631abda | 569 | |
7a976304 VZ |
570 | menuBar->Check(IDM_TOOLBAR_TOP_ORIENTATION, true ); |
571 | m_toolbarPosition = TOOLBAR_TOP; | |
ad9bb75f | 572 | // Create the toolbar |
5ef2e633 | 573 | RecreateToolbar(); |
949b8e62 | 574 | |
5b2acc3a | 575 | m_textWindow = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); |
5ef2e633 | 576 | } |
ad9bb75f | 577 | |
5b2acc3a RR |
578 | #if USE_GENERIC_TBAR |
579 | ||
580 | wxToolBar* MyFrame::OnCreateToolBar(long style, | |
581 | wxWindowID id, | |
582 | const wxString& name) | |
583 | { | |
584 | return (wxToolBar *)new wxToolBarSimple(this, id, | |
585 | wxDefaultPosition, wxDefaultSize, | |
586 | style, name); | |
587 | } | |
588 | ||
589 | #endif // USE_GENERIC_TBAR | |
590 | ||
f6bcfd97 BP |
591 | void MyFrame::LayoutChildren() |
592 | { | |
593 | wxSize size = GetClientSize(); | |
594 | ||
595 | int offset; | |
596 | if ( m_tbar ) | |
597 | { | |
7a7d2a14 | 598 | m_tbar->SetSize(0, 0, wxDefaultCoord, size.y); |
f6bcfd97 BP |
599 | |
600 | offset = m_tbar->GetSize().x; | |
601 | } | |
602 | else | |
603 | { | |
604 | offset = 0; | |
605 | } | |
606 | ||
607 | m_textWindow->SetSize(offset, 0, size.x - offset, size.y); | |
608 | } | |
609 | ||
610 | void MyFrame::OnSize(wxSizeEvent& event) | |
611 | { | |
612 | if ( m_tbar ) | |
613 | { | |
614 | LayoutChildren(); | |
615 | } | |
616 | else | |
617 | { | |
618 | event.Skip(); | |
619 | } | |
620 | } | |
621 | ||
ba0abe3c VZ |
622 | void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event)) |
623 | { | |
624 | wxToolBar *tbar = GetToolBar(); | |
625 | ||
626 | if ( !tbar ) | |
627 | { | |
628 | RecreateToolbar(); | |
629 | } | |
630 | else | |
631 | { | |
632 | delete tbar; | |
633 | ||
634 | SetToolBar(NULL); | |
635 | } | |
636 | } | |
637 | ||
96dc4236 VZ |
638 | void MyFrame::OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event)) |
639 | { | |
640 | m_horzText = !m_horzText; | |
641 | ||
642 | RecreateToolbar(); | |
643 | } | |
644 | ||
f6bcfd97 BP |
645 | void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) |
646 | { | |
647 | if ( m_tbar ) | |
648 | { | |
649 | delete m_tbar; | |
650 | m_tbar = NULL; | |
651 | } | |
652 | else | |
653 | { | |
8927d6d1 VZ |
654 | long style = GetToolBar() ? GetToolBar()->GetWindowStyle() |
655 | : TOOLBAR_STYLE; | |
ec483b11 VZ |
656 | style &= ~wxTB_HORIZONTAL; |
657 | style |= wxTB_VERTICAL; | |
658 | ||
bc2ec626 | 659 | m_tbar = new wxToolBar(this, wxID_ANY, |
f6bcfd97 | 660 | wxDefaultPosition, wxDefaultSize, |
ec483b11 VZ |
661 | style); |
662 | ||
69c14ebe VZ |
663 | m_tbar->SetMargins(4, 4); |
664 | ||
3bf4189d VZ |
665 | m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_1, _T("First"), wxBITMAP(new)); |
666 | m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_2, _T("Second"), wxBITMAP(open)); | |
667 | m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_3, _T("Third"), wxBITMAP(save)); | |
ec483b11 VZ |
668 | m_tbar->AddSeparator(); |
669 | m_tbar->AddTool(wxID_HELP, _T("Help"), wxBITMAP(help)); | |
670 | ||
f6bcfd97 BP |
671 | m_tbar->Realize(); |
672 | } | |
673 | ||
674 | LayoutChildren(); | |
675 | } | |
676 | ||
5ef2e633 VZ |
677 | void MyFrame::OnToggleToolbarSize(wxCommandEvent& WXUNUSED(event)) |
678 | { | |
679 | m_smallToolbar = !m_smallToolbar; | |
ad9bb75f | 680 | |
5ef2e633 | 681 | RecreateToolbar(); |
7fb23305 VZ |
682 | } |
683 | ||
98066234 VZ |
684 | void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event)) |
685 | { | |
686 | // m_rows may be only 1 or 2 | |
687 | m_rows = 3 - m_rows; | |
688 | ||
7a976304 | 689 | GetToolBar()->SetRows(!(GetToolBar()->IsVertical()) ? m_rows : 10 / m_rows); |
98066234 | 690 | |
9fb35cf1 | 691 | //RecreateToolbar(); -- this is unneeded |
98066234 VZ |
692 | } |
693 | ||
6a1b3ead VZ |
694 | void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event)) |
695 | { | |
696 | m_showTooltips = !m_showTooltips; | |
697 | ||
698 | RecreateToolbar(); | |
699 | } | |
700 | ||
8d0a7b56 VZ |
701 | void MyFrame::OnToggleCustomDisabled(wxCommandEvent& WXUNUSED(event)) |
702 | { | |
703 | m_useCustomDisabled = !m_useCustomDisabled; | |
704 | ||
705 | RecreateToolbar(); | |
706 | } | |
707 | ||
7a976304 | 708 | void MyFrame::OnChangeOrientation(wxCommandEvent& event) |
7fb23305 | 709 | { |
7a976304 VZ |
710 | switch( event.GetId() ) |
711 | { | |
712 | case IDM_TOOLBAR_LEFT_ORIENTATION: | |
713 | m_toolbarPosition = TOOLBAR_LEFT; | |
714 | break; | |
715 | case IDM_TOOLBAR_TOP_ORIENTATION: | |
716 | m_toolbarPosition = TOOLBAR_TOP; | |
717 | break; | |
718 | case IDM_TOOLBAR_RIGHT_ORIENTATION: | |
719 | m_toolbarPosition = TOOLBAR_RIGHT; | |
720 | break; | |
721 | case IDM_TOOLBAR_BOTTOM_ORIENTATION: | |
722 | m_toolbarPosition = TOOLBAR_BOTTOM; | |
723 | break; | |
724 | } | |
5ef2e633 | 725 | RecreateToolbar(); |
14d1ccd8 JS |
726 | } |
727 | ||
47908e25 | 728 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) |
14d1ccd8 | 729 | { |
bc2ec626 | 730 | Close(true); |
14d1ccd8 JS |
731 | } |
732 | ||
e08bbf37 | 733 | void MyFrame::OnAbout(wxCommandEvent& event) |
14d1ccd8 | 734 | { |
e08bbf37 VZ |
735 | if ( event.IsChecked() ) |
736 | m_textWindow->WriteText( _T("Help button down now.\n") ); | |
737 | else | |
738 | m_textWindow->WriteText( _T("Help button up now.\n") ); | |
739 | ||
be5a51fb | 740 | (void)wxMessageBox(_T("wxWidgets toolbar sample"), _T("About wxToolBar")); |
13437238 | 741 | } |
14d1ccd8 | 742 | |
13437238 JS |
743 | void MyFrame::OnToolLeftClick(wxCommandEvent& event) |
744 | { | |
e179bd65 RR |
745 | wxString str; |
746 | str.Printf( _T("Clicked on tool %d\n"), event.GetId()); | |
747 | m_textWindow->WriteText( str ); | |
ad9bb75f | 748 | |
e179bd65 RR |
749 | if (event.GetId() == wxID_COPY) |
750 | { | |
7fb23305 | 751 | DoEnablePrint(); |
e179bd65 | 752 | } |
ad9bb75f | 753 | |
e179bd65 RR |
754 | if (event.GetId() == wxID_CUT) |
755 | { | |
7fb23305 | 756 | DoToggleHelp(); |
e179bd65 | 757 | } |
1c4f8f8d | 758 | |
97d7bfb8 RR |
759 | if (event.GetId() == wxID_PRINT) |
760 | { | |
761 | DoDeletePrint(); | |
762 | } | |
14d1ccd8 JS |
763 | } |
764 | ||
e052a316 VZ |
765 | void MyFrame::OnToolRightClick(wxCommandEvent& event) |
766 | { | |
767 | m_textWindow->AppendText( | |
60c474a0 MB |
768 | wxString::Format(_T("Tool %d right clicked.\n"), |
769 | (int) event.GetInt())); | |
e052a316 VZ |
770 | } |
771 | ||
1c383dba VZ |
772 | void MyFrame::OnCombo(wxCommandEvent& event) |
773 | { | |
774 | wxLogStatus(_T("Combobox string '%s' selected"), event.GetString().c_str()); | |
775 | } | |
776 | ||
7fb23305 VZ |
777 | void MyFrame::DoEnablePrint() |
778 | { | |
2b5f62a0 VZ |
779 | if ( !m_nPrint ) |
780 | return; | |
781 | ||
ad4ae6ed | 782 | wxToolBarBase *tb = GetToolBar(); |
2b5f62a0 | 783 | tb->EnableTool(wxID_PRINT, !tb->GetToolEnabled(wxID_PRINT)); |
7fb23305 VZ |
784 | } |
785 | ||
97d7bfb8 RR |
786 | void MyFrame::DoDeletePrint() |
787 | { | |
2b5f62a0 VZ |
788 | if ( !m_nPrint ) |
789 | return; | |
1c4f8f8d | 790 | |
2b5f62a0 | 791 | wxToolBarBase *tb = GetToolBar(); |
97d7bfb8 | 792 | tb->DeleteTool( wxID_PRINT ); |
2b5f62a0 VZ |
793 | |
794 | m_nPrint--; | |
97d7bfb8 RR |
795 | } |
796 | ||
7fb23305 VZ |
797 | void MyFrame::DoToggleHelp() |
798 | { | |
ad4ae6ed | 799 | wxToolBarBase *tb = GetToolBar(); |
7fb23305 VZ |
800 | tb->ToggleTool( wxID_HELP, !tb->GetToolState( wxID_HELP ) ); |
801 | } | |
802 | ||
5ef2e633 VZ |
803 | void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent& event) |
804 | { | |
96dc4236 VZ |
805 | event.Enable( m_textWindow->CanCopy() ); |
806 | } | |
807 | ||
808 | void MyFrame::OnUpdateToggleHorzText(wxUpdateUIEvent& event) | |
809 | { | |
810 | wxToolBar *tbar = GetToolBar(); | |
811 | event.Enable( tbar && | |
812 | tbar->HasFlag(wxTB_TEXT) && | |
813 | !tbar->HasFlag(wxTB_NOICONS) ); | |
5ef2e633 VZ |
814 | } |
815 | ||
a1f79c1e VZ |
816 | void MyFrame::OnChangeToolTip(wxCommandEvent& WXUNUSED(event)) |
817 | { | |
818 | GetToolBar()->SetToolShortHelp(wxID_NEW, _T("New toolbar button")); | |
819 | } | |
820 | ||
ec483b11 VZ |
821 | void MyFrame::OnToolbarStyle(wxCommandEvent& event) |
822 | { | |
823 | long style = GetToolBar()->GetWindowStyle(); | |
824 | style &= ~(wxTB_NOICONS | wxTB_TEXT); | |
825 | ||
826 | switch ( event.GetId() ) | |
827 | { | |
828 | case IDM_TOOLBAR_SHOW_TEXT: | |
829 | style |= wxTB_NOICONS | wxTB_TEXT; | |
830 | break; | |
831 | ||
832 | case IDM_TOOLBAR_SHOW_ICONS: | |
833 | // nothing to do | |
834 | break; | |
835 | ||
836 | case IDM_TOOLBAR_SHOW_BOTH: | |
837 | style |= wxTB_TEXT; | |
838 | } | |
839 | ||
840 | GetToolBar()->SetWindowStyle(style); | |
841 | } | |
842 | ||
5e3b8b93 VZ |
843 | void MyFrame::OnToolbarCustomBitmap(wxCommandEvent& WXUNUSED(event)) |
844 | { | |
845 | m_pathBmp = wxFileSelector(_T("Custom bitmap path")); | |
846 | ||
847 | RecreateToolbar(); | |
848 | } | |
849 | ||
bdc72a22 VZ |
850 | void MyFrame::OnInsertPrint(wxCommandEvent& WXUNUSED(event)) |
851 | { | |
2b5f62a0 | 852 | m_nPrint++; |
bdc72a22 | 853 | |
2b5f62a0 VZ |
854 | wxToolBarBase *tb = GetToolBar(); |
855 | tb->InsertTool(0, wxID_PRINT, _T("New print"), | |
856 | wxBITMAP(print), wxNullBitmap, | |
857 | wxITEM_NORMAL, | |
858 | _T("Delete this tool"), | |
859 | _T("This button was inserted into the toolbar")); | |
860 | ||
861 | // must call Realize() after adding a new button | |
862 | tb->Realize(); | |
bdc72a22 VZ |
863 | } |
864 | ||
3bf4189d VZ |
865 | void MyFrame::OnToggleRadioBtn(wxCommandEvent& event) |
866 | { | |
867 | if ( m_tbar ) | |
868 | { | |
869 | m_tbar->ToggleTool(IDM_TOOLBAR_OTHER_1 + | |
870 | event.GetId() - IDM_TOOLBAR_TOGGLERADIOBTN1, true); | |
871 | } | |
872 | } |