1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxToolBar sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx/wx.h".
21 #include "wx/wxprec.h"
31 #include <wx/toolbar.h>
35 // define this to 1 to use wxToolBarSimple instead of the native one
36 #define USE_GENERIC_TBAR 0
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
41 #define USE_XPM_BITMAPS 0
43 #define USE_XPM_BITMAPS 1
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.
51 #include <wx/tbarsmpl.h>
53 #endif // USE_GENERIC_TBAR
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
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
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
75 // ----------------------------------------------------------------------------
77 // ----------------------------------------------------------------------------
79 // Define a new application
80 class MyApp
: public wxApp
87 class MyFrame
: public wxFrame
90 MyFrame(wxFrame
*parent
,
91 wxWindowID id
= wxID_ANY
,
92 const wxString
& title
= _T("wxToolBar Sample"),
93 const wxPoint
& pos
= wxDefaultPosition
,
94 const wxSize
& size
= wxDefaultSize
,
95 long style
= wxDEFAULT_FRAME_STYLE
|wxCLIP_CHILDREN
|wxNO_FULL_REPAINT_ON_RESIZE
);
97 void RecreateToolbar();
99 void OnQuit(wxCommandEvent
& event
);
100 void OnAbout(wxCommandEvent
& event
);
102 void OnSize(wxSizeEvent
& event
);
104 void OnToggleToolbar(wxCommandEvent
& event
);
105 void OnToggleAnotherToolbar(wxCommandEvent
& event
);
106 void OnToggleHorizontalText(wxCommandEvent
& WXUNUSED(event
));
108 void OnToggleToolbarSize(wxCommandEvent
& event
);
109 void OnToggleToolbarOrient(wxCommandEvent
& event
);
110 void OnToggleToolbarRows(wxCommandEvent
& event
);
112 void OnEnablePrint(wxCommandEvent
& WXUNUSED(event
)) { DoEnablePrint(); }
113 void OnDeletePrint(wxCommandEvent
& WXUNUSED(event
)) { DoDeletePrint(); }
114 void OnInsertPrint(wxCommandEvent
& event
);
115 void OnChangeToolTip(wxCommandEvent
& event
);
116 void OnToggleHelp(wxCommandEvent
& WXUNUSED(event
)) { DoToggleHelp(); }
117 void OnToggleRadioBtn(wxCommandEvent
& event
);
119 void OnToolbarStyle(wxCommandEvent
& event
);
121 void OnToolLeftClick(wxCommandEvent
& event
);
122 void OnToolRightClick(wxCommandEvent
& event
);
123 void OnToolEnter(wxCommandEvent
& event
);
125 void OnCombo(wxCommandEvent
& event
);
127 void OnUpdateCopyAndCut(wxUpdateUIEvent
& event
);
128 void OnUpdateToggleHorzText(wxUpdateUIEvent
& event
);
129 void OnUpdateToggleRadioBtn(wxUpdateUIEvent
& event
)
130 { event
.Enable( m_tbar
!= NULL
); }
133 virtual wxToolBar
*OnCreateToolBar(long style
,
135 const wxString
& name
);
136 #endif // USE_GENERIC_TBAR
139 void DoEnablePrint();
140 void DoDeletePrint();
143 void LayoutChildren();
148 size_t m_rows
; // 1 or 2 only
150 // the number of print buttons we have (they're added/removed dynamically)
153 wxTextCtrl
*m_textWindow
;
157 DECLARE_EVENT_TABLE()
160 // ----------------------------------------------------------------------------
162 // ----------------------------------------------------------------------------
164 const int ID_TOOLBAR
= 500;
166 static const long TOOLBAR_STYLE
= wxTB_FLAT
| wxTB_DOCKABLE
| wxTB_TEXT
;
170 IDM_TOOLBAR_TOGGLETOOLBARSIZE
= 200,
171 IDM_TOOLBAR_TOGGLETOOLBARORIENT
,
172 IDM_TOOLBAR_TOGGLETOOLBARROWS
,
173 IDM_TOOLBAR_ENABLEPRINT
,
174 IDM_TOOLBAR_DELETEPRINT
,
175 IDM_TOOLBAR_INSERTPRINT
,
176 IDM_TOOLBAR_TOGGLEHELP
,
177 IDM_TOOLBAR_TOGGLERADIOBTN1
,
178 IDM_TOOLBAR_TOGGLERADIOBTN2
,
179 IDM_TOOLBAR_TOGGLERADIOBTN3
,
180 IDM_TOOLBAR_TOGGLE_TOOLBAR
,
181 IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
,
182 IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR
,
183 IDM_TOOLBAR_CHANGE_TOOLTIP
,
184 IDM_TOOLBAR_SHOW_TEXT
,
185 IDM_TOOLBAR_SHOW_ICONS
,
186 IDM_TOOLBAR_SHOW_BOTH
,
195 // ----------------------------------------------------------------------------
197 // ----------------------------------------------------------------------------
199 // Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
202 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
203 EVT_SIZE(MyFrame::OnSize
)
205 EVT_MENU(wxID_EXIT
, MyFrame::OnQuit
)
206 EVT_MENU(wxID_HELP
, MyFrame::OnAbout
)
208 EVT_MENU(IDM_TOOLBAR_TOGGLE_TOOLBAR
, MyFrame::OnToggleToolbar
)
209 EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR
, MyFrame::OnToggleAnotherToolbar
)
210 EVT_MENU(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
, MyFrame::OnToggleHorizontalText
)
212 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE
, MyFrame::OnToggleToolbarSize
)
213 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT
, MyFrame::OnToggleToolbarOrient
)
214 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS
, MyFrame::OnToggleToolbarRows
)
216 EVT_MENU(IDM_TOOLBAR_ENABLEPRINT
, MyFrame::OnEnablePrint
)
217 EVT_MENU(IDM_TOOLBAR_DELETEPRINT
, MyFrame::OnDeletePrint
)
218 EVT_MENU(IDM_TOOLBAR_INSERTPRINT
, MyFrame::OnInsertPrint
)
219 EVT_MENU(IDM_TOOLBAR_TOGGLEHELP
, MyFrame::OnToggleHelp
)
220 EVT_MENU_RANGE(IDM_TOOLBAR_TOGGLERADIOBTN1
, IDM_TOOLBAR_TOGGLERADIOBTN3
,
221 MyFrame::OnToggleRadioBtn
)
222 EVT_MENU(IDM_TOOLBAR_CHANGE_TOOLTIP
, MyFrame::OnChangeToolTip
)
224 EVT_MENU_RANGE(IDM_TOOLBAR_SHOW_TEXT
, IDM_TOOLBAR_SHOW_BOTH
,
225 MyFrame::OnToolbarStyle
)
227 EVT_MENU(wxID_ANY
, MyFrame::OnToolLeftClick
)
229 EVT_COMBOBOX(ID_COMBO
, MyFrame::OnCombo
)
231 EVT_TOOL_ENTER(ID_TOOLBAR
, MyFrame::OnToolEnter
)
232 EVT_TOOL_RCLICKED(wxID_ANY
, MyFrame::OnToolRightClick
)
234 EVT_UPDATE_UI(wxID_COPY
, MyFrame::OnUpdateCopyAndCut
)
235 EVT_UPDATE_UI(wxID_CUT
, MyFrame::OnUpdateCopyAndCut
)
237 EVT_UPDATE_UI_RANGE(IDM_TOOLBAR_TOGGLERADIOBTN1
,
238 IDM_TOOLBAR_TOGGLERADIOBTN3
,
239 MyFrame::OnUpdateToggleRadioBtn
)
240 EVT_UPDATE_UI(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
,
241 MyFrame::OnUpdateToggleHorzText
)
244 // ============================================================================
246 // ============================================================================
248 // ----------------------------------------------------------------------------
250 // ----------------------------------------------------------------------------
254 // The `main program' equivalent, creating the windows and returning the
258 // Create the main frame window
259 MyFrame
* frame
= new MyFrame((wxFrame
*) NULL
, wxID_ANY
,
260 _T("wxToolBar Sample"),
262 wxDefaultPosition
, wxDefaultSize
264 wxPoint(100, 100), wxSize(550, 300)
271 frame
->SetStatusText(_T("Hello, wxWidgets"));
279 void MyFrame::RecreateToolbar()
282 // On Windows CE, we should not delete the
283 // previous toolbar in case it contains the menubar.
284 // We'll try to accommodate this usage in due course.
285 wxToolBar
* toolBar
= CreateToolBar();
287 // delete and recreate the toolbar
288 wxToolBarBase
*toolBar
= GetToolBar();
289 long style
= toolBar
? toolBar
->GetWindowStyle() : TOOLBAR_STYLE
;
295 style
&= ~(wxTB_HORIZONTAL
| wxTB_VERTICAL
| wxTB_HORZ_LAYOUT
);
296 style
|= m_horzToolbar
? wxTB_HORIZONTAL
: wxTB_VERTICAL
;
298 if ( style
& wxTB_TEXT
&& !(style
& wxTB_NOICONS
) && m_horzText
)
299 style
|= wxTB_HORZ_LAYOUT
;
301 toolBar
= CreateToolBar(style
, ID_TOOLBAR
);
305 wxBitmap toolBarBitmaps
[8];
308 toolBarBitmaps
[0] = wxBitmap(new_xpm
);
309 toolBarBitmaps
[1] = wxBitmap(open_xpm
);
310 toolBarBitmaps
[2] = wxBitmap(save_xpm
);
311 toolBarBitmaps
[3] = wxBitmap(copy_xpm
);
312 toolBarBitmaps
[4] = wxBitmap(cut_xpm
);
313 toolBarBitmaps
[5] = wxBitmap(paste_xpm
);
314 toolBarBitmaps
[6] = wxBitmap(print_xpm
);
315 toolBarBitmaps
[7] = wxBitmap(help_xpm
);
316 #else // !USE_XPM_BITMAPS
317 toolBarBitmaps
[0] = wxBITMAP(new);
318 toolBarBitmaps
[1] = wxBITMAP(open
);
319 toolBarBitmaps
[2] = wxBITMAP(save
);
320 toolBarBitmaps
[3] = wxBITMAP(copy
);
321 toolBarBitmaps
[4] = wxBITMAP(cut
);
322 toolBarBitmaps
[5] = wxBITMAP(paste
);
323 toolBarBitmaps
[6] = wxBITMAP(print
);
324 toolBarBitmaps
[7] = wxBITMAP(help
);
325 #endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
327 if ( !m_smallToolbar
)
329 int w
= 2*toolBarBitmaps
[0].GetWidth(),
330 h
= 2*toolBarBitmaps
[0].GetHeight();
331 for ( size_t n
= 0; n
< WXSIZEOF(toolBarBitmaps
); n
++ )
334 wxBitmap(toolBarBitmaps
[n
].ConvertToImage().Scale(w
, h
));
337 toolBar
->SetToolBitmapSize(wxSize(w
, h
));
340 toolBar
->AddTool(wxID_NEW
, _T("New"), toolBarBitmaps
[0], _T("New file"));
341 toolBar
->AddTool(wxID_OPEN
, _T("Open"), toolBarBitmaps
[1], _T("Open file"));
343 // the generic toolbar doesn't really support this
344 #if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
345 // adding a combo to a vertical toolbar is not very smart
348 wxComboBox
*combo
= new wxComboBox(toolBar
, ID_COMBO
, _T(""), wxDefaultPosition
, wxSize(200,wxDefaultCoord
) );
349 combo
->Append(_T("This"));
350 combo
->Append(_T("is a"));
351 combo
->Append(_T("combobox"));
352 combo
->Append(_T("in a"));
353 combo
->Append(_T("toolbar"));
354 toolBar
->AddControl(combo
);
356 #endif // toolbars which don't support controls
358 toolBar
->AddTool(wxID_SAVE
, _T("Save"), toolBarBitmaps
[2], _T("Toggle button 1"), wxITEM_CHECK
);
359 toolBar
->AddTool(wxID_COPY
, _T("Copy"), toolBarBitmaps
[3], _T("Toggle button 2"), wxITEM_CHECK
);
360 toolBar
->AddTool(wxID_CUT
, _T("Cut"), toolBarBitmaps
[4], _T("Toggle/Untoggle help button"));
361 toolBar
->AddTool(wxID_PASTE
, _T("Paste"), toolBarBitmaps
[5], _T("Paste"));
362 toolBar
->AddTool(wxID_PRINT
, _T("Print"), toolBarBitmaps
[6], _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."));
363 toolBar
->AddSeparator();
364 toolBar
->AddTool(wxID_HELP
, _T("Help"), toolBarBitmaps
[7], _T("Help button"), wxITEM_CHECK
);
366 // after adding the buttons to the toolbar, must call Realize() to reflect
370 toolBar
->SetRows(m_horzToolbar
? m_rows
: 10 / m_rows
);
373 // ----------------------------------------------------------------------------
375 // ----------------------------------------------------------------------------
377 // Define my frame constructor
378 MyFrame::MyFrame(wxFrame
* parent
,
380 const wxString
& title
,
384 : wxFrame(parent
, id
, title
, pos
, size
, style
)
388 m_smallToolbar
= true;
389 m_horzToolbar
= true;
395 // Give it a status line
400 SetIcon(wxICON(mondrian
));
403 wxMenu
*tbarMenu
= new wxMenu
;
404 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLE_TOOLBAR
,
405 _T("Toggle &toolbar\tCtrl-Z"),
406 _T("Show or hide the toolbar"));
408 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR
,
409 _T("Toggle &another toolbar\tCtrl-A"),
410 _T("Show/hide another test toolbar"));
412 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
,
413 _T("Toggle hori&zontal text\tCtrl-H"),
414 _T("Show text under/alongside the icon"));
416 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARSIZE
,
417 _T("&Toggle toolbar size\tCtrl-S"),
418 _T("Toggle between big/small toolbar"));
420 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARORIENT
,
421 _T("Toggle toolbar &orientation\tCtrl-O"),
422 _T("Toggle toolbar orientation"));
424 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARROWS
,
425 _T("Toggle number of &rows\tCtrl-R"),
426 _T("Toggle number of toolbar rows between 1 and 2"));
428 tbarMenu
->AppendSeparator();
430 tbarMenu
->Append(IDM_TOOLBAR_ENABLEPRINT
, _T("&Enable print button\tCtrl-E"), _T(""));
431 tbarMenu
->Append(IDM_TOOLBAR_DELETEPRINT
, _T("&Delete print button\tCtrl-D"), _T(""));
432 tbarMenu
->Append(IDM_TOOLBAR_INSERTPRINT
, _T("&Insert print button\tCtrl-I"), _T(""));
433 tbarMenu
->Append(IDM_TOOLBAR_TOGGLEHELP
, _T("Toggle &help button\tCtrl-T"), _T(""));
434 tbarMenu
->AppendSeparator();
435 tbarMenu
->Append(IDM_TOOLBAR_TOGGLERADIOBTN1
, _T("Toggle &1st radio button\tCtrl-1"), _T(""));
436 tbarMenu
->Append(IDM_TOOLBAR_TOGGLERADIOBTN2
, _T("Toggle &2nd radio button\tCtrl-2"), _T(""));
437 tbarMenu
->Append(IDM_TOOLBAR_TOGGLERADIOBTN3
, _T("Toggle &3rd radio button\tCtrl-3"), _T(""));
438 tbarMenu
->AppendSeparator();
439 tbarMenu
->Append(IDM_TOOLBAR_CHANGE_TOOLTIP
, _T("Change tool tip"), _T(""));
440 tbarMenu
->AppendSeparator();
441 tbarMenu
->AppendRadioItem(IDM_TOOLBAR_SHOW_TEXT
, _T("Show &text\tAlt-T"));
442 tbarMenu
->AppendRadioItem(IDM_TOOLBAR_SHOW_ICONS
, _T("Show &icons\tAlt-I"));
443 tbarMenu
->AppendRadioItem(IDM_TOOLBAR_SHOW_BOTH
, _T("Show &both\tAlt-B"));
445 wxMenu
*fileMenu
= new wxMenu
;
446 fileMenu
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"), _T("Quit toolbar sample") );
448 wxMenu
*helpMenu
= new wxMenu
;
449 helpMenu
->Append(wxID_HELP
, _T("&About"), _T("About toolbar sample"));
451 wxMenuBar
* menuBar
= new wxMenuBar( wxMB_DOCKABLE
);
453 menuBar
->Append(fileMenu
, _T("&File"));
454 menuBar
->Append(tbarMenu
, _T("&Toolbar"));
455 menuBar
->Append(helpMenu
, _T("&Help"));
457 // Associate the menu bar with the frame
460 menuBar
->Check(IDM_TOOLBAR_SHOW_BOTH
, true);
462 // Create the toolbar
465 m_textWindow
= new wxTextCtrl(this, wxID_ANY
, _T(""), wxPoint(0, 0), wxDefaultSize
, wxTE_MULTILINE
);
470 wxToolBar
* MyFrame::OnCreateToolBar(long style
,
472 const wxString
& name
)
474 return (wxToolBar
*)new wxToolBarSimple(this, id
,
475 wxDefaultPosition
, wxDefaultSize
,
479 #endif // USE_GENERIC_TBAR
481 void MyFrame::LayoutChildren()
483 wxSize size
= GetClientSize();
488 m_tbar
->SetSize(wxDefaultCoord
, size
.y
);
491 offset
= m_tbar
->GetSize().x
;
498 m_textWindow
->SetSize(offset
, 0, size
.x
- offset
, size
.y
);
501 void MyFrame::OnSize(wxSizeEvent
& event
)
513 void MyFrame::OnToggleToolbar(wxCommandEvent
& WXUNUSED(event
))
515 wxToolBar
*tbar
= GetToolBar();
529 void MyFrame::OnToggleHorizontalText(wxCommandEvent
& WXUNUSED(event
))
531 m_horzText
= !m_horzText
;
536 void MyFrame::OnToggleAnotherToolbar(wxCommandEvent
& WXUNUSED(event
))
545 long style
= GetToolBar()->GetWindowStyle();
546 style
&= ~wxTB_HORIZONTAL
;
547 style
|= wxTB_VERTICAL
;
549 m_tbar
= new wxToolBar(this, wxID_ANY
,
550 wxDefaultPosition
, wxDefaultSize
,
553 m_tbar
->SetMargins(4, 4);
555 m_tbar
->AddRadioTool(IDM_TOOLBAR_OTHER_1
, _T("First"), wxBITMAP(new));
556 m_tbar
->AddRadioTool(IDM_TOOLBAR_OTHER_2
, _T("Second"), wxBITMAP(open
));
557 m_tbar
->AddRadioTool(IDM_TOOLBAR_OTHER_3
, _T("Third"), wxBITMAP(save
));
558 m_tbar
->AddSeparator();
559 m_tbar
->AddTool(wxID_HELP
, _T("Help"), wxBITMAP(help
));
567 void MyFrame::OnToggleToolbarSize(wxCommandEvent
& WXUNUSED(event
))
569 m_smallToolbar
= !m_smallToolbar
;
574 void MyFrame::OnToggleToolbarRows(wxCommandEvent
& WXUNUSED(event
))
576 // m_rows may be only 1 or 2
579 GetToolBar()->SetRows(m_horzToolbar
? m_rows
: 10 / m_rows
);
581 //RecreateToolbar(); -- this is unneeded
584 void MyFrame::OnToggleToolbarOrient(wxCommandEvent
& WXUNUSED(event
))
586 m_horzToolbar
= !m_horzToolbar
;
591 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
596 void MyFrame::OnAbout(wxCommandEvent
& event
)
598 if ( event
.IsChecked() )
599 m_textWindow
->WriteText( _T("Help button down now.\n") );
601 m_textWindow
->WriteText( _T("Help button up now.\n") );
603 (void)wxMessageBox(_T("wxWidgets toolbar sample"), _T("About wxToolBar"));
606 void MyFrame::OnToolLeftClick(wxCommandEvent
& event
)
609 str
.Printf( _T("Clicked on tool %d\n"), event
.GetId());
610 m_textWindow
->WriteText( str
);
612 if (event
.GetId() == wxID_COPY
)
617 if (event
.GetId() == wxID_CUT
)
622 if (event
.GetId() == wxID_PRINT
)
628 void MyFrame::OnToolRightClick(wxCommandEvent
& event
)
630 m_textWindow
->AppendText(
631 wxString::Format(_T("Tool %d right clicked.\n"), event
.GetInt()));
634 void MyFrame::OnCombo(wxCommandEvent
& event
)
636 wxLogStatus(_T("Combobox string '%s' selected"), event
.GetString().c_str());
639 void MyFrame::DoEnablePrint()
644 wxToolBarBase
*tb
= GetToolBar();
645 tb
->EnableTool(wxID_PRINT
, !tb
->GetToolEnabled(wxID_PRINT
));
648 void MyFrame::DoDeletePrint()
653 wxToolBarBase
*tb
= GetToolBar();
654 tb
->DeleteTool( wxID_PRINT
);
659 void MyFrame::DoToggleHelp()
661 wxToolBarBase
*tb
= GetToolBar();
662 tb
->ToggleTool( wxID_HELP
, !tb
->GetToolState( wxID_HELP
) );
665 void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent
& event
)
667 event
.Enable( m_textWindow
->CanCopy() );
670 void MyFrame::OnUpdateToggleHorzText(wxUpdateUIEvent
& event
)
672 wxToolBar
*tbar
= GetToolBar();
673 event
.Enable( tbar
&&
674 tbar
->HasFlag(wxTB_TEXT
) &&
675 !tbar
->HasFlag(wxTB_NOICONS
) );
678 void MyFrame::OnChangeToolTip(wxCommandEvent
& WXUNUSED(event
))
680 GetToolBar()->SetToolShortHelp(wxID_NEW
, _T("New toolbar button"));
683 void MyFrame::OnToolbarStyle(wxCommandEvent
& event
)
685 long style
= GetToolBar()->GetWindowStyle();
686 style
&= ~(wxTB_NOICONS
| wxTB_TEXT
);
688 switch ( event
.GetId() )
690 case IDM_TOOLBAR_SHOW_TEXT
:
691 style
|= wxTB_NOICONS
| wxTB_TEXT
;
694 case IDM_TOOLBAR_SHOW_ICONS
:
698 case IDM_TOOLBAR_SHOW_BOTH
:
702 GetToolBar()->SetWindowStyle(style
);
705 void MyFrame::OnInsertPrint(wxCommandEvent
& WXUNUSED(event
))
709 wxToolBarBase
*tb
= GetToolBar();
710 tb
->InsertTool(0, wxID_PRINT
, _T("New print"),
711 wxBITMAP(print
), wxNullBitmap
,
713 _T("Delete this tool"),
714 _T("This button was inserted into the toolbar"));
716 // must call Realize() after adding a new button
720 void MyFrame::OnToolEnter(wxCommandEvent
& event
)
723 if (event
.GetSelection() > -1)
726 str
.Printf(_T("This is tool number %d"), event
.GetSelection());
730 SetStatusText(_T(""));
733 #endif // wxUSE_STATUSBAR
736 void MyFrame::OnToggleRadioBtn(wxCommandEvent
& event
)
740 m_tbar
->ToggleTool(IDM_TOOLBAR_OTHER_1
+
741 event
.GetId() - IDM_TOOLBAR_TOGGLERADIOBTN1
, true);