X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..ff1865910312d960737474a75a77737d5ce94864:/samples/toolbar/toolbar.cpp diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index ce30338920..c839ceee55 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -31,6 +31,7 @@ #include #include #include +#include // define this to 1 to use wxToolBarSimple instead of the native one #define USE_GENERIC_TBAR 0 @@ -109,6 +110,7 @@ public: void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); } void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); } void OnInsertPrint(wxCommandEvent& event); + void OnChangeToolTip(wxCommandEvent& event); void OnToggleHelp(wxCommandEvent& WXUNUSED(event)) { DoToggleHelp(); } void OnToolLeftClick(wxCommandEvent& event); @@ -150,6 +152,8 @@ private: const int ID_TOOLBAR = 500; +static const long TOOLBAR_STYLE = wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE; + enum { IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200, @@ -161,6 +165,7 @@ enum IDM_TOOLBAR_TOGGLEHELP, IDM_TOOLBAR_TOGGLEFULLSCREEN, IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, + IDM_TOOLBAR_CHANGE_TOOLTIP, ID_COMBO = 1000 }; @@ -189,6 +194,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(IDM_TOOLBAR_INSERTPRINT, MyFrame::OnInsertPrint) EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp) EVT_MENU(IDM_TOOLBAR_TOGGLEFULLSCREEN, MyFrame::OnToggleFullScreen) + EVT_MENU(IDM_TOOLBAR_CHANGE_TOOLTIP, MyFrame::OnChangeToolTip) EVT_MENU(-1, MyFrame::OnToolLeftClick) @@ -236,7 +242,7 @@ void MyFrame::RecreateToolbar() SetToolBar(NULL); - long style = wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE; + long style = TOOLBAR_STYLE; style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL; toolBar = CreateToolBar(style, ID_TOOLBAR); @@ -295,12 +301,15 @@ void MyFrame::RecreateToolbar() // adding a combo to a vertical toolbar is not very smart if ( m_horzToolbar ) { - wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO); + wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, "", wxDefaultPosition, wxSize(200,-1) ); combo->Append("This"); combo->Append("is a"); combo->Append("combobox"); combo->Append("in a"); combo->Append("toolbar"); +/* + wxTextCtrl *combo = new wxTextCtrl( toolBar, -1, "", wxDefaultPosition, wxSize(80,-1) ); +*/ toolBar->AddControl(combo); } #endif // toolbars which don't support controls @@ -378,11 +387,10 @@ MyFrame::MyFrame(wxFrame* parent, tbarMenu->Append(IDM_TOOLBAR_DELETEPRINT, "&Delete print button\tCtrl-D", ""); tbarMenu->Append(IDM_TOOLBAR_INSERTPRINT, "&Insert print button\tCtrl-I", ""); tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, "Toggle &help button\tCtrl-T", ""); - -#ifdef __WXMSW__ + tbarMenu->AppendSeparator(); + tbarMenu->Append(IDM_TOOLBAR_CHANGE_TOOLTIP, "Change tool tip", ""); tbarMenu->AppendSeparator(); tbarMenu->Append(IDM_TOOLBAR_TOGGLEFULLSCREEN, "Toggle &full screen mode\tCtrl-F", ""); -#endif wxMenu *fileMenu = new wxMenu; fileMenu->Append(wxID_EXIT, "E&xit", "Quit toolbar sample" ); @@ -459,7 +467,7 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) { m_tbar = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, - wxTB_VERTICAL); + TOOLBAR_STYLE | wxTB_VERTICAL); m_tbar->AddTool(wxID_HELP, wxBITMAP(help), wxNullBitmap, FALSE, NULL, @@ -567,6 +575,11 @@ void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent& event) event.Enable( m_textWindow->CanCopy() ); } +void MyFrame::OnChangeToolTip(wxCommandEvent& WXUNUSED(event)) +{ + GetToolBar()->SetToolShortHelp(wxID_NEW, _T("New toolbar button")); +} + void MyFrame::OnInsertPrint(wxCommandEvent& WXUNUSED(event)) { wxBitmap bmp = wxBITMAP(print); @@ -593,8 +606,6 @@ void MyFrame::OnToolEnter(wxCommandEvent& event) void MyFrame::OnToggleFullScreen(wxCommandEvent& event) { -#ifdef __WXMSW__ ShowFullScreen(!IsFullScreen()); -#endif }