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 // ----------------------------------------------------------------------------
63 #if !defined(__WXMSW__) && !defined(__WXPM__)
64 #include "mondrian.xpm"
68 #include "bitmaps/new.xpm"
69 #include "bitmaps/open.xpm"
70 #include "bitmaps/save.xpm"
71 #include "bitmaps/copy.xpm"
72 #include "bitmaps/cut.xpm"
73 #include "bitmaps/preview.xpm" // paste XPM
74 #include "bitmaps/print.xpm"
75 #include "bitmaps/help.xpm"
76 #endif // USE_XPM_BITMAPS
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
82 // Define a new application
83 class MyApp
: public wxApp
90 class MyFrame
: public wxFrame
93 MyFrame(wxFrame
*parent
,
94 wxWindowID id
= wxID_ANY
,
95 const wxString
& title
= _T("wxToolBar Sample"),
96 const wxPoint
& pos
= wxDefaultPosition
,
97 const wxSize
& size
= wxDefaultSize
,
98 long style
= wxDEFAULT_FRAME_STYLE
|wxCLIP_CHILDREN
|wxNO_FULL_REPAINT_ON_RESIZE
);
100 void RecreateToolbar();
102 void OnQuit(wxCommandEvent
& event
);
103 void OnAbout(wxCommandEvent
& event
);
105 void OnSize(wxSizeEvent
& event
);
107 void OnToggleToolbar(wxCommandEvent
& event
);
108 void OnToggleAnotherToolbar(wxCommandEvent
& event
);
109 void OnToggleHorizontalText(wxCommandEvent
& WXUNUSED(event
));
111 void OnToggleToolbarSize(wxCommandEvent
& event
);
112 void OnToggleToolbarOrient(wxCommandEvent
& event
);
113 void OnToggleToolbarRows(wxCommandEvent
& event
);
114 void OnToggleCustomDisabled(wxCommandEvent
& event
);
116 void OnEnablePrint(wxCommandEvent
& WXUNUSED(event
)) { DoEnablePrint(); }
117 void OnDeletePrint(wxCommandEvent
& WXUNUSED(event
)) { DoDeletePrint(); }
118 void OnInsertPrint(wxCommandEvent
& event
);
119 void OnChangeToolTip(wxCommandEvent
& event
);
120 void OnToggleHelp(wxCommandEvent
& WXUNUSED(event
)) { DoToggleHelp(); }
121 void OnToggleRadioBtn(wxCommandEvent
& event
);
123 void OnToolbarStyle(wxCommandEvent
& event
);
125 void OnToolLeftClick(wxCommandEvent
& event
);
126 void OnToolRightClick(wxCommandEvent
& event
);
127 void OnToolEnter(wxCommandEvent
& event
);
129 void OnCombo(wxCommandEvent
& event
);
131 void OnUpdateCopyAndCut(wxUpdateUIEvent
& event
);
132 void OnUpdateToggleHorzText(wxUpdateUIEvent
& event
);
133 void OnUpdateToggleRadioBtn(wxUpdateUIEvent
& event
)
134 { event
.Enable( m_tbar
!= NULL
); }
137 virtual wxToolBar
*OnCreateToolBar(long style
,
139 const wxString
& name
);
140 #endif // USE_GENERIC_TBAR
143 void DoEnablePrint();
144 void DoDeletePrint();
147 void LayoutChildren();
153 size_t m_rows
; // 1 or 2 only
155 // the number of print buttons we have (they're added/removed dynamically)
158 wxTextCtrl
*m_textWindow
;
162 DECLARE_EVENT_TABLE()
165 // ----------------------------------------------------------------------------
167 // ----------------------------------------------------------------------------
169 const int ID_TOOLBAR
= 500;
171 static const long TOOLBAR_STYLE
= wxTB_FLAT
| wxTB_DOCKABLE
| wxTB_TEXT
;
175 IDM_TOOLBAR_TOGGLETOOLBARSIZE
= 200,
176 IDM_TOOLBAR_TOGGLETOOLBARORIENT
,
177 IDM_TOOLBAR_TOGGLETOOLBARROWS
,
178 IDM_TOOLBAR_TOGGLECUSTOMDISABLED
,
179 IDM_TOOLBAR_ENABLEPRINT
,
180 IDM_TOOLBAR_DELETEPRINT
,
181 IDM_TOOLBAR_INSERTPRINT
,
182 IDM_TOOLBAR_TOGGLEHELP
,
183 IDM_TOOLBAR_TOGGLERADIOBTN1
,
184 IDM_TOOLBAR_TOGGLERADIOBTN2
,
185 IDM_TOOLBAR_TOGGLERADIOBTN3
,
186 IDM_TOOLBAR_TOGGLE_TOOLBAR
,
187 IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
,
188 IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR
,
189 IDM_TOOLBAR_CHANGE_TOOLTIP
,
190 IDM_TOOLBAR_SHOW_TEXT
,
191 IDM_TOOLBAR_SHOW_ICONS
,
192 IDM_TOOLBAR_SHOW_BOTH
,
201 // ----------------------------------------------------------------------------
203 // ----------------------------------------------------------------------------
205 // Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
208 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
209 EVT_SIZE(MyFrame::OnSize
)
211 EVT_MENU(wxID_EXIT
, MyFrame::OnQuit
)
212 EVT_MENU(wxID_HELP
, MyFrame::OnAbout
)
214 EVT_MENU(IDM_TOOLBAR_TOGGLE_TOOLBAR
, MyFrame::OnToggleToolbar
)
215 EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR
, MyFrame::OnToggleAnotherToolbar
)
216 EVT_MENU(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
, MyFrame::OnToggleHorizontalText
)
218 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE
, MyFrame::OnToggleToolbarSize
)
219 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT
, MyFrame::OnToggleToolbarOrient
)
220 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS
, MyFrame::OnToggleToolbarRows
)
221 EVT_MENU(IDM_TOOLBAR_TOGGLECUSTOMDISABLED
, MyFrame::OnToggleCustomDisabled
)
223 EVT_MENU(IDM_TOOLBAR_ENABLEPRINT
, MyFrame::OnEnablePrint
)
224 EVT_MENU(IDM_TOOLBAR_DELETEPRINT
, MyFrame::OnDeletePrint
)
225 EVT_MENU(IDM_TOOLBAR_INSERTPRINT
, MyFrame::OnInsertPrint
)
226 EVT_MENU(IDM_TOOLBAR_TOGGLEHELP
, MyFrame::OnToggleHelp
)
227 EVT_MENU_RANGE(IDM_TOOLBAR_TOGGLERADIOBTN1
, IDM_TOOLBAR_TOGGLERADIOBTN3
,
228 MyFrame::OnToggleRadioBtn
)
229 EVT_MENU(IDM_TOOLBAR_CHANGE_TOOLTIP
, MyFrame::OnChangeToolTip
)
231 EVT_MENU_RANGE(IDM_TOOLBAR_SHOW_TEXT
, IDM_TOOLBAR_SHOW_BOTH
,
232 MyFrame::OnToolbarStyle
)
234 EVT_MENU(wxID_ANY
, MyFrame::OnToolLeftClick
)
236 EVT_COMBOBOX(ID_COMBO
, MyFrame::OnCombo
)
238 EVT_TOOL_ENTER(ID_TOOLBAR
, MyFrame::OnToolEnter
)
239 EVT_TOOL_RCLICKED(wxID_ANY
, MyFrame::OnToolRightClick
)
241 EVT_UPDATE_UI(wxID_COPY
, MyFrame::OnUpdateCopyAndCut
)
242 EVT_UPDATE_UI(wxID_CUT
, MyFrame::OnUpdateCopyAndCut
)
244 EVT_UPDATE_UI_RANGE(IDM_TOOLBAR_TOGGLERADIOBTN1
,
245 IDM_TOOLBAR_TOGGLERADIOBTN3
,
246 MyFrame::OnUpdateToggleRadioBtn
)
247 EVT_UPDATE_UI(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
,
248 MyFrame::OnUpdateToggleHorzText
)
251 // ============================================================================
253 // ============================================================================
255 // ----------------------------------------------------------------------------
257 // ----------------------------------------------------------------------------
261 // The `main program' equivalent, creating the windows and returning the
265 // Create the main frame window
266 MyFrame
* frame
= new MyFrame((wxFrame
*) NULL
, wxID_ANY
,
267 _T("wxToolBar Sample"),
269 wxDefaultPosition
, wxDefaultSize
271 wxPoint(100, 100), wxSize(550, 300)
278 frame
->SetStatusText(_T("Hello, wxWidgets"));
286 void MyFrame::RecreateToolbar()
289 // On Windows CE, we should not delete the
290 // previous toolbar in case it contains the menubar.
291 // We'll try to accommodate this usage in due course.
292 wxToolBar
* toolBar
= CreateToolBar();
294 // delete and recreate the toolbar
295 wxToolBarBase
*toolBar
= GetToolBar();
296 long style
= toolBar
? toolBar
->GetWindowStyle() : TOOLBAR_STYLE
;
302 style
&= ~(wxTB_HORIZONTAL
| wxTB_VERTICAL
| wxTB_HORZ_LAYOUT
);
303 style
|= m_horzToolbar
? wxTB_HORIZONTAL
: wxTB_VERTICAL
;
305 if ( style
& wxTB_TEXT
&& !(style
& wxTB_NOICONS
) && m_horzText
)
306 style
|= wxTB_HORZ_LAYOUT
;
308 toolBar
= CreateToolBar(style
, ID_TOOLBAR
);
325 wxBitmap toolBarBitmaps
[Tool_Max
];
328 #define INIT_TOOL_BMP(bmp) \
329 toolBarBitmaps[Tool_##bmp] = wxBitmap(bmp##_xpm)
330 #else // !USE_XPM_BITMAPS
331 #define INIT_TOOL_BMP(bmp) \
332 toolBarBitmaps[Tool_##bmp] = wxBITMAP(bmp)
333 #endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
340 INIT_TOOL_BMP(paste
);
341 INIT_TOOL_BMP(print
);
344 int w
= toolBarBitmaps
[Tool_new
].GetWidth(),
345 h
= toolBarBitmaps
[Tool_new
].GetHeight();
347 if ( !m_smallToolbar
)
352 for ( size_t n
= Tool_new
; n
< WXSIZEOF(toolBarBitmaps
); n
++ )
355 wxBitmap(toolBarBitmaps
[n
].ConvertToImage().Scale(w
, h
));
358 toolBar
->SetToolBitmapSize(wxSize(w
, h
));
361 toolBar
->AddTool(wxID_NEW
, _T("New"), toolBarBitmaps
[Tool_new
], _T("New file"));
362 toolBar
->AddTool(wxID_OPEN
, _T("Open"), toolBarBitmaps
[Tool_open
], _T("Open file"));
364 // the generic toolbar doesn't really support this
365 #if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
366 // adding a combo to a vertical toolbar is not very smart
369 wxComboBox
*combo
= new wxComboBox(toolBar
, ID_COMBO
, wxEmptyString
, wxDefaultPosition
, wxSize(200,wxDefaultCoord
) );
370 combo
->Append(_T("This"));
371 combo
->Append(_T("is a"));
372 combo
->Append(_T("combobox"));
373 combo
->Append(_T("in a"));
374 combo
->Append(_T("toolbar"));
375 toolBar
->AddControl(combo
);
377 #endif // toolbars which don't support controls
379 toolBar
->AddTool(wxID_SAVE
, _T("Save"), toolBarBitmaps
[Tool_save
], _T("Toggle button 1"), wxITEM_CHECK
);
380 toolBar
->AddTool(wxID_COPY
, _T("Copy"), toolBarBitmaps
[Tool_copy
], _T("Toggle button 2"), wxITEM_CHECK
);
381 toolBar
->AddTool(wxID_CUT
, _T("Cut"), toolBarBitmaps
[Tool_cut
], _T("Toggle/Untoggle help button"));
382 toolBar
->AddTool(wxID_PASTE
, _T("Paste"), toolBarBitmaps
[Tool_paste
], _T("Paste"));
384 if ( m_useCustomDisabled
)
386 wxBitmap
bmpDisabled(w
, h
);
389 dc
.SelectObject(bmpDisabled
);
390 dc
.DrawBitmap(toolBarBitmaps
[Tool_print
], 0, 0);
392 wxPen
pen(*wxRED
, 5);
394 dc
.DrawLine(0, 0, w
, h
);
397 toolBar
->AddTool(wxID_PRINT
, _T("Print"), toolBarBitmaps
[Tool_print
],
402 toolBar
->AddTool(wxID_PRINT
, _T("Print"), toolBarBitmaps
[Tool_print
],
403 _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."));
406 toolBar
->AddSeparator();
407 toolBar
->AddTool(wxID_HELP
, _T("Help"), toolBarBitmaps
[Tool_help
], _T("Help button"), wxITEM_CHECK
);
409 // after adding the buttons to the toolbar, must call Realize() to reflect
413 toolBar
->SetRows(m_horzToolbar
? m_rows
: 10 / m_rows
);
416 // ----------------------------------------------------------------------------
418 // ----------------------------------------------------------------------------
420 // Define my frame constructor
421 MyFrame::MyFrame(wxFrame
* parent
,
423 const wxString
& title
,
427 : wxFrame(parent
, id
, title
, pos
, size
, style
)
431 m_smallToolbar
= true;
432 m_horzToolbar
= true;
434 m_useCustomDisabled
= false;
439 // Give it a status line
444 SetIcon(wxICON(mondrian
));
447 wxMenu
*tbarMenu
= new wxMenu
;
448 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLE_TOOLBAR
,
449 _T("Toggle &toolbar\tCtrl-Z"),
450 _T("Show or hide the toolbar"));
452 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR
,
453 _T("Toggle &another toolbar\tCtrl-A"),
454 _T("Show/hide another test toolbar"));
456 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT
,
457 _T("Toggle hori&zontal text\tCtrl-H"),
458 _T("Show text under/alongside the icon"));
460 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARSIZE
,
461 _T("&Toggle toolbar size\tCtrl-S"),
462 _T("Toggle between big/small toolbar"));
464 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARORIENT
,
465 _T("Toggle toolbar &orientation\tCtrl-O"),
466 _T("Toggle toolbar orientation"));
468 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARROWS
,
469 _T("Toggle number of &rows\tCtrl-R"),
470 _T("Toggle number of toolbar rows between 1 and 2"));
472 tbarMenu
->AppendCheckItem(IDM_TOOLBAR_TOGGLECUSTOMDISABLED
,
473 _T("Use c&ustom disabled images\tCtrl-U"),
474 _T("Switch between using system-generated and custom disabled images"));
477 tbarMenu
->AppendSeparator();
479 tbarMenu
->Append(IDM_TOOLBAR_ENABLEPRINT
, _T("&Enable print button\tCtrl-E"), wxEmptyString
);
480 tbarMenu
->Append(IDM_TOOLBAR_DELETEPRINT
, _T("&Delete print button\tCtrl-D"), wxEmptyString
);
481 tbarMenu
->Append(IDM_TOOLBAR_INSERTPRINT
, _T("&Insert print button\tCtrl-I"), wxEmptyString
);
482 tbarMenu
->Append(IDM_TOOLBAR_TOGGLEHELP
, _T("Toggle &help button\tCtrl-T"), wxEmptyString
);
483 tbarMenu
->AppendSeparator();
484 tbarMenu
->Append(IDM_TOOLBAR_TOGGLERADIOBTN1
, _T("Toggle &1st radio button\tCtrl-1"), wxEmptyString
);
485 tbarMenu
->Append(IDM_TOOLBAR_TOGGLERADIOBTN2
, _T("Toggle &2nd radio button\tCtrl-2"), wxEmptyString
);
486 tbarMenu
->Append(IDM_TOOLBAR_TOGGLERADIOBTN3
, _T("Toggle &3rd radio button\tCtrl-3"), wxEmptyString
);
487 tbarMenu
->AppendSeparator();
488 tbarMenu
->Append(IDM_TOOLBAR_CHANGE_TOOLTIP
, _T("Change tool tip"), wxEmptyString
);
489 tbarMenu
->AppendSeparator();
490 tbarMenu
->AppendRadioItem(IDM_TOOLBAR_SHOW_TEXT
, _T("Show &text\tAlt-T"));
491 tbarMenu
->AppendRadioItem(IDM_TOOLBAR_SHOW_ICONS
, _T("Show &icons\tAlt-I"));
492 tbarMenu
->AppendRadioItem(IDM_TOOLBAR_SHOW_BOTH
, _T("Show &both\tAlt-B"));
494 wxMenu
*fileMenu
= new wxMenu
;
495 fileMenu
->Append(wxID_EXIT
, _T("E&xit\tAlt-X"), _T("Quit toolbar sample") );
497 wxMenu
*helpMenu
= new wxMenu
;
498 helpMenu
->Append(wxID_HELP
, _T("&About"), _T("About toolbar sample"));
500 wxMenuBar
* menuBar
= new wxMenuBar( wxMB_DOCKABLE
);
502 menuBar
->Append(fileMenu
, _T("&File"));
503 menuBar
->Append(tbarMenu
, _T("&Toolbar"));
504 menuBar
->Append(helpMenu
, _T("&Help"));
506 // Associate the menu bar with the frame
509 menuBar
->Check(IDM_TOOLBAR_SHOW_BOTH
, true);
511 // Create the toolbar
514 m_textWindow
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxPoint(0, 0), wxDefaultSize
, wxTE_MULTILINE
);
519 wxToolBar
* MyFrame::OnCreateToolBar(long style
,
521 const wxString
& name
)
523 return (wxToolBar
*)new wxToolBarSimple(this, id
,
524 wxDefaultPosition
, wxDefaultSize
,
528 #endif // USE_GENERIC_TBAR
530 void MyFrame::LayoutChildren()
532 wxSize size
= GetClientSize();
537 m_tbar
->SetSize(0, 0, wxDefaultCoord
, size
.y
);
539 offset
= m_tbar
->GetSize().x
;
546 m_textWindow
->SetSize(offset
, 0, size
.x
- offset
, size
.y
);
549 void MyFrame::OnSize(wxSizeEvent
& event
)
561 void MyFrame::OnToggleToolbar(wxCommandEvent
& WXUNUSED(event
))
563 wxToolBar
*tbar
= GetToolBar();
577 void MyFrame::OnToggleHorizontalText(wxCommandEvent
& WXUNUSED(event
))
579 m_horzText
= !m_horzText
;
584 void MyFrame::OnToggleAnotherToolbar(wxCommandEvent
& WXUNUSED(event
))
593 long style
= GetToolBar() ? GetToolBar()->GetWindowStyle()
595 style
&= ~wxTB_HORIZONTAL
;
596 style
|= wxTB_VERTICAL
;
598 m_tbar
= new wxToolBar(this, wxID_ANY
,
599 wxDefaultPosition
, wxDefaultSize
,
602 m_tbar
->SetMargins(4, 4);
604 m_tbar
->AddRadioTool(IDM_TOOLBAR_OTHER_1
, _T("First"), wxBITMAP(new));
605 m_tbar
->AddRadioTool(IDM_TOOLBAR_OTHER_2
, _T("Second"), wxBITMAP(open
));
606 m_tbar
->AddRadioTool(IDM_TOOLBAR_OTHER_3
, _T("Third"), wxBITMAP(save
));
607 m_tbar
->AddSeparator();
608 m_tbar
->AddTool(wxID_HELP
, _T("Help"), wxBITMAP(help
));
616 void MyFrame::OnToggleToolbarSize(wxCommandEvent
& WXUNUSED(event
))
618 m_smallToolbar
= !m_smallToolbar
;
623 void MyFrame::OnToggleToolbarRows(wxCommandEvent
& WXUNUSED(event
))
625 // m_rows may be only 1 or 2
628 GetToolBar()->SetRows(m_horzToolbar
? m_rows
: 10 / m_rows
);
630 //RecreateToolbar(); -- this is unneeded
633 void MyFrame::OnToggleCustomDisabled(wxCommandEvent
& WXUNUSED(event
))
635 m_useCustomDisabled
= !m_useCustomDisabled
;
640 void MyFrame::OnToggleToolbarOrient(wxCommandEvent
& WXUNUSED(event
))
642 m_horzToolbar
= !m_horzToolbar
;
647 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
652 void MyFrame::OnAbout(wxCommandEvent
& event
)
654 if ( event
.IsChecked() )
655 m_textWindow
->WriteText( _T("Help button down now.\n") );
657 m_textWindow
->WriteText( _T("Help button up now.\n") );
659 (void)wxMessageBox(_T("wxWidgets toolbar sample"), _T("About wxToolBar"));
662 void MyFrame::OnToolLeftClick(wxCommandEvent
& event
)
665 str
.Printf( _T("Clicked on tool %d\n"), event
.GetId());
666 m_textWindow
->WriteText( str
);
668 if (event
.GetId() == wxID_COPY
)
673 if (event
.GetId() == wxID_CUT
)
678 if (event
.GetId() == wxID_PRINT
)
684 void MyFrame::OnToolRightClick(wxCommandEvent
& event
)
686 m_textWindow
->AppendText(
687 wxString::Format(_T("Tool %d right clicked.\n"),
688 (int) event
.GetInt()));
691 void MyFrame::OnCombo(wxCommandEvent
& event
)
693 wxLogStatus(_T("Combobox string '%s' selected"), event
.GetString().c_str());
696 void MyFrame::DoEnablePrint()
701 wxToolBarBase
*tb
= GetToolBar();
702 tb
->EnableTool(wxID_PRINT
, !tb
->GetToolEnabled(wxID_PRINT
));
705 void MyFrame::DoDeletePrint()
710 wxToolBarBase
*tb
= GetToolBar();
711 tb
->DeleteTool( wxID_PRINT
);
716 void MyFrame::DoToggleHelp()
718 wxToolBarBase
*tb
= GetToolBar();
719 tb
->ToggleTool( wxID_HELP
, !tb
->GetToolState( wxID_HELP
) );
722 void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent
& event
)
724 event
.Enable( m_textWindow
->CanCopy() );
727 void MyFrame::OnUpdateToggleHorzText(wxUpdateUIEvent
& event
)
729 wxToolBar
*tbar
= GetToolBar();
730 event
.Enable( tbar
&&
731 tbar
->HasFlag(wxTB_TEXT
) &&
732 !tbar
->HasFlag(wxTB_NOICONS
) );
735 void MyFrame::OnChangeToolTip(wxCommandEvent
& WXUNUSED(event
))
737 GetToolBar()->SetToolShortHelp(wxID_NEW
, _T("New toolbar button"));
740 void MyFrame::OnToolbarStyle(wxCommandEvent
& event
)
742 long style
= GetToolBar()->GetWindowStyle();
743 style
&= ~(wxTB_NOICONS
| wxTB_TEXT
);
745 switch ( event
.GetId() )
747 case IDM_TOOLBAR_SHOW_TEXT
:
748 style
|= wxTB_NOICONS
| wxTB_TEXT
;
751 case IDM_TOOLBAR_SHOW_ICONS
:
755 case IDM_TOOLBAR_SHOW_BOTH
:
759 GetToolBar()->SetWindowStyle(style
);
762 void MyFrame::OnInsertPrint(wxCommandEvent
& WXUNUSED(event
))
766 wxToolBarBase
*tb
= GetToolBar();
767 tb
->InsertTool(0, wxID_PRINT
, _T("New print"),
768 wxBITMAP(print
), wxNullBitmap
,
770 _T("Delete this tool"),
771 _T("This button was inserted into the toolbar"));
773 // must call Realize() after adding a new button
777 void MyFrame::OnToolEnter(wxCommandEvent
& event
)
780 if (event
.GetSelection() > -1)
783 str
.Printf(_T("This is tool number %d"), event
.GetSelection());
787 SetStatusText(wxEmptyString
);
790 #endif // wxUSE_STATUSBAR
793 void MyFrame::OnToggleRadioBtn(wxCommandEvent
& event
)
797 m_tbar
->ToggleTool(IDM_TOOLBAR_OTHER_1
+
798 event
.GetId() - IDM_TOOLBAR_TOGGLERADIOBTN1
, true);