no changes
[wxWidgets.git] / samples / toolbar / toolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: toolbar.cpp
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #include <wx/wx.h>
29 #endif
30
31 #include <wx/toolbar.h>
32 #include <wx/log.h>
33 #include <wx/image.h>
34
35 // define this to 1 to use wxToolBarSimple instead of the native one
36 #define USE_GENERIC_TBAR 0
37
38 // define this to use XPMs everywhere (by default, BMPs are used under Win)
39 // BMPs use less space, but aren't compiled into the executable on other platforms
40 #ifdef __WXMSW__
41 #define USE_XPM_BITMAPS 0
42 #else
43 #define USE_XPM_BITMAPS 1
44 #endif
45
46 #if USE_GENERIC_TBAR
47 #if !wxUSE_TOOLBAR_SIMPLE
48 #error wxToolBarSimple is not compiled in, set wxUSE_TOOLBAR_SIMPLE \
49 to 1 in setup.h and recompile the library.
50 #else
51 #include <wx/tbarsmpl.h>
52 #endif
53 #endif // USE_GENERIC_TBAR
54
55 #if USE_XPM_BITMAPS && defined(__WXMSW__) && !wxUSE_XPM_IN_MSW
56 #error You need to enable XPM support to use XPM bitmaps with toolbar!
57 #endif // USE_XPM_BITMAPS
58
59 // ----------------------------------------------------------------------------
60 // resources
61 // ----------------------------------------------------------------------------
62
63 #if USE_XPM_BITMAPS
64 #include "mondrian.xpm"
65 #include "bitmaps/new.xpm"
66 #include "bitmaps/open.xpm"
67 #include "bitmaps/save.xpm"
68 #include "bitmaps/copy.xpm"
69 #include "bitmaps/cut.xpm"
70 #include "bitmaps/preview.xpm" // paste XPM
71 #include "bitmaps/print.xpm"
72 #include "bitmaps/help.xpm"
73 #endif // USE_XPM_BITMAPS
74
75 // ----------------------------------------------------------------------------
76 // classes
77 // ----------------------------------------------------------------------------
78
79 // Define a new application
80 class MyApp : public wxApp
81 {
82 public:
83 bool OnInit();
84 };
85
86 // Define a new frame
87 class MyFrame: public wxFrame
88 {
89 public:
90 MyFrame(wxFrame *parent,
91 wxWindowID id = -1,
92 const wxString& title = "wxToolBar Sample",
93 const wxPoint& pos = wxDefaultPosition,
94 const wxSize& size = wxDefaultSize,
95 long style = wxDEFAULT_FRAME_STYLE);
96
97 void RecreateToolbar();
98
99 void OnQuit(wxCommandEvent& event);
100 void OnAbout(wxCommandEvent& event);
101
102 void OnSize(wxSizeEvent& event);
103
104 void OnToggleToolbar(wxCommandEvent& event);
105 void OnToggleAnotherToolbar(wxCommandEvent& event);
106
107 void OnToggleToolbarSize(wxCommandEvent& event);
108 void OnToggleToolbarOrient(wxCommandEvent& event);
109 void OnToggleToolbarRows(wxCommandEvent& event);
110
111 void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); }
112 void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); }
113 void OnInsertPrint(wxCommandEvent& event);
114 void OnChangeToolTip(wxCommandEvent& event);
115 void OnToggleHelp(wxCommandEvent& WXUNUSED(event)) { DoToggleHelp(); }
116
117 void OnToolbarStyle(wxCommandEvent& event);
118
119 void OnToolLeftClick(wxCommandEvent& event);
120 void OnToolEnter(wxCommandEvent& event);
121
122 void OnCombo(wxCommandEvent& event);
123
124 void OnUpdateCopyAndCut(wxUpdateUIEvent& event);
125
126 #if USE_GENERIC_TBAR
127 virtual wxToolBar *OnCreateToolBar(long style,
128 wxWindowID id,
129 const wxString& name );
130 #endif // USE_GENERIC_TBAR
131
132 private:
133 void DoEnablePrint();
134 void DoDeletePrint();
135 void DoToggleHelp();
136
137 void LayoutChildren();
138
139 bool m_smallToolbar,
140 m_horzToolbar;
141 size_t m_rows; // 1 or 2 only
142
143 wxTextCtrl *m_textWindow;
144
145 wxToolBar *m_tbar;
146
147 DECLARE_EVENT_TABLE()
148 };
149
150 // ----------------------------------------------------------------------------
151 // constants
152 // ----------------------------------------------------------------------------
153
154 const int ID_TOOLBAR = 500;
155
156 static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
157
158 enum
159 {
160 IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200,
161 IDM_TOOLBAR_TOGGLETOOLBARORIENT,
162 IDM_TOOLBAR_TOGGLETOOLBARROWS,
163 IDM_TOOLBAR_ENABLEPRINT,
164 IDM_TOOLBAR_DELETEPRINT,
165 IDM_TOOLBAR_INSERTPRINT,
166 IDM_TOOLBAR_TOGGLEHELP,
167 IDM_TOOLBAR_TOGGLE_TOOLBAR,
168 IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR,
169 IDM_TOOLBAR_CHANGE_TOOLTIP,
170 IDM_TOOLBAR_SHOW_TEXT,
171 IDM_TOOLBAR_SHOW_ICONS,
172 IDM_TOOLBAR_SHOW_BOTH,
173
174 ID_COMBO = 1000
175 };
176
177 // ----------------------------------------------------------------------------
178 // event tables
179 // ----------------------------------------------------------------------------
180
181 // Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
182 // help button.
183
184 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
185 EVT_SIZE(MyFrame::OnSize)
186
187 EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
188 EVT_MENU(wxID_HELP, MyFrame::OnAbout)
189
190 EVT_MENU(IDM_TOOLBAR_TOGGLE_TOOLBAR, MyFrame::OnToggleToolbar)
191 EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, MyFrame::OnToggleAnotherToolbar)
192
193 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
194 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
195 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows)
196
197 EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint)
198 EVT_MENU(IDM_TOOLBAR_DELETEPRINT, MyFrame::OnDeletePrint)
199 EVT_MENU(IDM_TOOLBAR_INSERTPRINT, MyFrame::OnInsertPrint)
200 EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp)
201 EVT_MENU(IDM_TOOLBAR_CHANGE_TOOLTIP, MyFrame::OnChangeToolTip)
202
203 EVT_MENU_RANGE(IDM_TOOLBAR_SHOW_TEXT, IDM_TOOLBAR_SHOW_BOTH,
204 MyFrame::OnToolbarStyle)
205
206 EVT_MENU(-1, MyFrame::OnToolLeftClick)
207
208 EVT_COMBOBOX(ID_COMBO, MyFrame::OnCombo)
209
210 EVT_TOOL_ENTER(ID_TOOLBAR, MyFrame::OnToolEnter)
211
212 EVT_UPDATE_UI(wxID_COPY, MyFrame::OnUpdateCopyAndCut)
213 EVT_UPDATE_UI(wxID_CUT, MyFrame::OnUpdateCopyAndCut)
214 END_EVENT_TABLE()
215
216 // ============================================================================
217 // implementation
218 // ============================================================================
219
220 // ----------------------------------------------------------------------------
221 // MyApp
222 // ----------------------------------------------------------------------------
223
224 IMPLEMENT_APP(MyApp)
225
226 // The `main program' equivalent, creating the windows and returning the
227 // main frame
228 bool MyApp::OnInit()
229 {
230 // Create the main frame window
231 MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
232 "wxToolBar Sample",
233 wxPoint(100, 100), wxSize(550, 300));
234
235 frame->Show(TRUE);
236
237 frame->SetStatusText("Hello, wxWindows");
238
239 SetTopWindow(frame);
240
241 return TRUE;
242 }
243
244 void MyFrame::RecreateToolbar()
245 {
246 // delete and recreate the toolbar
247 wxToolBarBase *toolBar = GetToolBar();
248 long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
249
250 delete toolBar;
251
252 SetToolBar(NULL);
253
254 style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL);
255 style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
256
257 toolBar = CreateToolBar(style, ID_TOOLBAR);
258
259 // Set up toolbar
260 wxBitmap toolBarBitmaps[8];
261
262 #if USE_XPM_BITMAPS
263 toolBarBitmaps[0] = wxBitmap(new_xpm);
264 toolBarBitmaps[1] = wxBitmap(open_xpm);
265 toolBarBitmaps[2] = wxBitmap(save_xpm);
266 toolBarBitmaps[3] = wxBitmap(copy_xpm);
267 toolBarBitmaps[4] = wxBitmap(cut_xpm);
268 toolBarBitmaps[5] = wxBitmap(paste_xpm);
269 toolBarBitmaps[6] = wxBitmap(print_xpm);
270 toolBarBitmaps[7] = wxBitmap(help_xpm);
271 #else // !USE_XPM_BITMAPS
272 toolBarBitmaps[0] = wxBITMAP(new);
273 toolBarBitmaps[1] = wxBITMAP(open);
274 toolBarBitmaps[2] = wxBITMAP(save);
275 toolBarBitmaps[3] = wxBITMAP(copy);
276 toolBarBitmaps[4] = wxBITMAP(cut);
277 toolBarBitmaps[5] = wxBITMAP(paste);
278 toolBarBitmaps[6] = wxBITMAP(print);
279 toolBarBitmaps[7] = wxBITMAP(help);
280 #endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
281
282 if ( !m_smallToolbar )
283 {
284 int w = 2*toolBarBitmaps[0].GetWidth(),
285 h = 2*toolBarBitmaps[0].GetHeight();
286 for ( size_t n = 0; n < WXSIZEOF(toolBarBitmaps); n++ )
287 {
288 toolBarBitmaps[n] =
289 wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h));
290 }
291
292 toolBar->SetToolBitmapSize(wxSize(w, h));
293 }
294
295 toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[0], _T("New file"));
296 toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[1], _T("Open file"));
297
298 // neither the generic nor Motif native toolbars really support this
299 #if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXMOTIF__) && !defined(__WXX11__)
300 // adding a combo to a vertical toolbar is not very smart
301 if ( m_horzToolbar )
302 {
303 wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, "", wxDefaultPosition, wxSize(200,-1) );
304 combo->Append("This");
305 combo->Append("is a");
306 combo->Append("combobox");
307 combo->Append("in a");
308 combo->Append("toolbar");
309 toolBar->AddControl(combo);
310 }
311 #endif // toolbars which don't support controls
312
313 toolBar->AddTool(wxID_SAVE, _T("Save"), toolBarBitmaps[2], _T("Toggle button 1"), wxITEM_CHECK);
314 toolBar->AddTool(wxID_COPY, _T("Copy"), toolBarBitmaps[3], _T("Toggle button 2"), wxITEM_CHECK);
315 toolBar->AddTool(wxID_CUT, _T("Cut"), toolBarBitmaps[4], _T("Toggle/Untoggle help button"));
316 toolBar->AddTool(wxID_PASTE, _T("Paste"), toolBarBitmaps[5], _T("Paste"));
317 toolBar->AddTool(wxID_PRINT, _T("Print"), toolBarBitmaps[6], _T("Delete this tool"));
318 toolBar->AddSeparator();
319 toolBar->AddTool(wxID_HELP, _T("Help"), toolBarBitmaps[7], _T("Help button"), wxITEM_CHECK);
320
321 // after adding the buttons to the toolbar, must call Realize() to reflect
322 // the changes
323 toolBar->Realize();
324
325 toolBar->SetRows(m_horzToolbar ? m_rows : 10 / m_rows);
326 }
327
328 // ----------------------------------------------------------------------------
329 // MyFrame
330 // ----------------------------------------------------------------------------
331
332 // Define my frame constructor
333 MyFrame::MyFrame(wxFrame* parent,
334 wxWindowID id,
335 const wxString& title,
336 const wxPoint& pos,
337 const wxSize& size,
338 long style)
339 : wxFrame(parent, id, title, pos, size, style)
340 {
341 m_tbar = NULL;
342 m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
343
344 m_smallToolbar = TRUE;
345 m_horzToolbar = TRUE;
346 m_rows = 1;
347
348 // Give it a status line
349 CreateStatusBar();
350
351 // Give it an icon
352 SetIcon(wxICON(mondrian));
353
354 // Make a menubar
355 wxMenu *tbarMenu = new wxMenu;
356 tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLE_TOOLBAR,
357 "Toggle &toolbar\tCtrl-Z",
358 "Show or hide the toolbar");
359
360 tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR,
361 "Toggle &another toolbar\tCtrl-A",
362 "Show/hide another test toolbar");
363
364 tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARSIZE,
365 "&Toggle toolbar size\tCtrl-S",
366 "Toggle between big/small toolbar");
367
368 tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARORIENT,
369 "Toggle toolbar &orientation\tCtrl-O",
370 "Toggle toolbar orientation");
371
372 tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARROWS,
373 "Toggle number of &rows\tCtrl-R",
374 "Toggle number of toolbar rows between 1 and 2");
375
376 tbarMenu->AppendSeparator();
377
378 tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, "&Enable print button\tCtrl-E", "");
379 tbarMenu->Append(IDM_TOOLBAR_DELETEPRINT, "&Delete print button\tCtrl-D", "");
380 tbarMenu->Append(IDM_TOOLBAR_INSERTPRINT, "&Insert print button\tCtrl-I", "");
381 tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, "Toggle &help button\tCtrl-T", "");
382 tbarMenu->AppendSeparator();
383 tbarMenu->Append(IDM_TOOLBAR_CHANGE_TOOLTIP, "Change tool tip", "");
384 tbarMenu->AppendSeparator();
385 tbarMenu->AppendRadioItem(IDM_TOOLBAR_SHOW_TEXT, "Show &text\tAlt-T");
386 tbarMenu->AppendRadioItem(IDM_TOOLBAR_SHOW_ICONS, "Show &icons\tAlt-I");
387 tbarMenu->AppendRadioItem(IDM_TOOLBAR_SHOW_BOTH, "Show &both\tAlt-B");
388
389 wxMenu *fileMenu = new wxMenu;
390 fileMenu->Append(wxID_EXIT, "E&xit\tAlt-X", "Quit toolbar sample" );
391
392 wxMenu *helpMenu = new wxMenu;
393 helpMenu->Append(wxID_HELP, "&About", "About toolbar sample");
394
395 wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE );
396
397 menuBar->Append(fileMenu, "&File");
398 menuBar->Append(tbarMenu, "&Toolbar");
399 menuBar->Append(helpMenu, "&Help");
400
401 // Associate the menu bar with the frame
402 SetMenuBar(menuBar);
403
404 menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, TRUE);
405
406 // Create the toolbar
407 RecreateToolbar();
408 }
409
410 #if USE_GENERIC_TBAR
411
412 wxToolBar* MyFrame::OnCreateToolBar(long style,
413 wxWindowID id,
414 const wxString& name)
415 {
416 return (wxToolBar *)new wxToolBarSimple(this, id,
417 wxDefaultPosition, wxDefaultSize,
418 style, name);
419 }
420
421 #endif // USE_GENERIC_TBAR
422
423 void MyFrame::LayoutChildren()
424 {
425 wxSize size = GetClientSize();
426
427 int offset;
428 if ( m_tbar )
429 {
430 m_tbar->SetSize(-1, size.y);
431 m_tbar->Move(0, 0);
432
433 offset = m_tbar->GetSize().x;
434 }
435 else
436 {
437 offset = 0;
438 }
439
440 m_textWindow->SetSize(offset, 0, size.x - offset, size.y);
441 }
442
443 void MyFrame::OnSize(wxSizeEvent& event)
444 {
445 if ( m_tbar )
446 {
447 LayoutChildren();
448 }
449 else
450 {
451 event.Skip();
452 }
453 }
454
455 void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event))
456 {
457 wxToolBar *tbar = GetToolBar();
458
459 if ( !tbar )
460 {
461 RecreateToolbar();
462 }
463 else
464 {
465 delete tbar;
466
467 SetToolBar(NULL);
468 }
469 }
470
471 void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
472 {
473 if ( m_tbar )
474 {
475 delete m_tbar;
476 m_tbar = NULL;
477 }
478 else
479 {
480 long style = GetToolBar()->GetWindowStyle();
481 style &= ~wxTB_HORIZONTAL;
482 style |= wxTB_VERTICAL;
483
484 m_tbar = new wxToolBar(this, -1,
485 wxDefaultPosition, wxDefaultSize,
486 style);
487
488 m_tbar->SetMargins(4, 4);
489
490 m_tbar->AddRadioTool(wxID_NEW, _T("First"), wxBITMAP(new));
491 m_tbar->AddRadioTool(wxID_OPEN, _T("Second"), wxBITMAP(open));
492 m_tbar->AddRadioTool(wxID_SAVE, _T("Third"), wxBITMAP(save));
493 m_tbar->AddSeparator();
494 m_tbar->AddTool(wxID_HELP, _T("Help"), wxBITMAP(help));
495
496 m_tbar->Realize();
497 }
498
499 LayoutChildren();
500 }
501
502 void MyFrame::OnToggleToolbarSize(wxCommandEvent& WXUNUSED(event))
503 {
504 m_smallToolbar = !m_smallToolbar;
505
506 RecreateToolbar();
507 }
508
509 void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event))
510 {
511 // m_rows may be only 1 or 2
512 m_rows = 3 - m_rows;
513
514 GetToolBar()->SetRows(m_horzToolbar ? m_rows : 10 / m_rows);
515
516 //RecreateToolbar(); -- this is unneeded
517 }
518
519 void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event))
520 {
521 m_horzToolbar = !m_horzToolbar;
522
523 RecreateToolbar();
524 }
525
526 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
527 {
528 Close(TRUE);
529 }
530
531 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
532 {
533 (void)wxMessageBox("wxWindows toolbar sample", "About wxToolBar");
534 }
535
536 void MyFrame::OnToolLeftClick(wxCommandEvent& event)
537 {
538 wxString str;
539 str.Printf( _T("Clicked on tool %d\n"), event.GetId());
540 m_textWindow->WriteText( str );
541
542 if (event.GetId() == wxID_HELP)
543 {
544 if ( event.GetExtraLong() != 0 )
545 m_textWindow->WriteText( _T("Help button down now.\n") );
546 else
547 m_textWindow->WriteText( _T("Help button up now.\n") );
548 }
549
550 if (event.GetId() == wxID_COPY)
551 {
552 DoEnablePrint();
553 }
554
555 if (event.GetId() == wxID_CUT)
556 {
557 DoToggleHelp();
558 }
559
560 if (event.GetId() == wxID_PRINT)
561 {
562 DoDeletePrint();
563 }
564 }
565
566 void MyFrame::OnCombo(wxCommandEvent& event)
567 {
568 wxLogStatus(_T("Combobox string '%s' selected"), event.GetString().c_str());
569 }
570
571 void MyFrame::DoEnablePrint()
572 {
573 wxToolBarBase *tb = GetToolBar();
574 if (tb->GetToolEnabled(wxID_PRINT))
575 tb->EnableTool( wxID_PRINT, FALSE );
576 else
577 tb->EnableTool( wxID_PRINT, TRUE );
578 }
579
580 void MyFrame::DoDeletePrint()
581 {
582 wxToolBarBase *tb = GetToolBar();
583
584 tb->DeleteTool( wxID_PRINT );
585 }
586
587 void MyFrame::DoToggleHelp()
588 {
589 wxToolBarBase *tb = GetToolBar();
590 tb->ToggleTool( wxID_HELP, !tb->GetToolState( wxID_HELP ) );
591 }
592
593 void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent& event)
594 {
595 event.Enable( m_textWindow->CanCopy() );
596 }
597
598 void MyFrame::OnChangeToolTip(wxCommandEvent& WXUNUSED(event))
599 {
600 GetToolBar()->SetToolShortHelp(wxID_NEW, _T("New toolbar button"));
601 }
602
603 void MyFrame::OnToolbarStyle(wxCommandEvent& event)
604 {
605 long style = GetToolBar()->GetWindowStyle();
606 style &= ~(wxTB_NOICONS | wxTB_TEXT);
607
608 switch ( event.GetId() )
609 {
610 case IDM_TOOLBAR_SHOW_TEXT:
611 style |= wxTB_NOICONS | wxTB_TEXT;
612 break;
613
614 case IDM_TOOLBAR_SHOW_ICONS:
615 // nothing to do
616 break;
617
618 case IDM_TOOLBAR_SHOW_BOTH:
619 style |= wxTB_TEXT;
620 }
621
622 GetToolBar()->SetWindowStyle(style);
623 }
624
625 void MyFrame::OnInsertPrint(wxCommandEvent& WXUNUSED(event))
626 {
627 wxBitmap bmp = wxBITMAP(print);
628
629 GetToolBar()->InsertTool(0, wxID_PRINT, bmp, wxNullBitmap,
630 FALSE, (wxObject *) NULL,
631 "Delete this tool",
632 "This button was inserted into the toolbar");
633
634 GetToolBar()->Realize();
635 }
636
637 void MyFrame::OnToolEnter(wxCommandEvent& event)
638 {
639 if (event.GetSelection() > -1)
640 {
641 wxString str;
642 str.Printf(_T("This is tool number %d"), event.GetSelection());
643 SetStatusText(str);
644 }
645 else
646 SetStatusText("");
647 }
648