From: Vadim Zeitlin Date: Sun, 28 May 2006 17:17:02 +0000 (+0000) Subject: added wxTB_NO_TOOLTIPS (heavily modified patch 1458009) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6a1b3ead3fd406e870042014eb7bd117586f4fff added wxTB_NO_TOOLTIPS (heavily modified patch 1458009) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39379 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index f5b55d7fe8..8c7ebd96a3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -140,6 +140,7 @@ All (GUI): - wxString <-> wxColour conversions in wxColour class (Francesco Montorsi). - Fixed bug with ignoring blank lines in multiline wxGrid cell labels - Added wxTextAttr::Merge() (Marcin Simonides) +- Added wxTB_NO_TOOLTIPS style (Igor Korot) wxMSW: diff --git a/docs/latex/wx/toolbar.tex b/docs/latex/wx/toolbar.tex index 6ec2b91e40..8a24b78c24 100644 --- a/docs/latex/wx/toolbar.tex +++ b/docs/latex/wx/toolbar.tex @@ -71,6 +71,7 @@ use this option under Windows XP with true colour: \twocolitem{\windowstyle{wxTB\_HORZ\_LAYOUT}}{Shows the text and the icons alongside, not vertically stacked (Windows and GTK 2 only). This style must be used with wxTB\_TEXT.} \twocolitem{\windowstyle{wxTB\_HORZ\_TEXT}}{Combination of wxTB\_HORZ\_LAYOUT and wxTB\_TEXT.} +\twocolitem{\windowstyle{wxTB\_NO\_TOOLTIPS}{Don't show the short help tooltips for the tools when the mouse hovers over them.} \end{twocollist} See also \helpref{window styles overview}{windowstyles}. Note that the Win32 diff --git a/include/wx/gtk/tbargtk.h b/include/wx/gtk/tbargtk.h index 0b688d0ffa..cc064460cd 100644 --- a/include/wx/gtk/tbargtk.h +++ b/include/wx/gtk/tbargtk.h @@ -25,7 +25,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = 0, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr ) { Init(); diff --git a/include/wx/toolbar.h b/include/wx/toolbar.h index d66f010f17..b7b8cc3f29 100644 --- a/include/wx/toolbar.h +++ b/include/wx/toolbar.h @@ -49,7 +49,10 @@ enum // show the text and the icons alongside, not vertically stacked (Win32/GTK) wxTB_HORZ_LAYOUT = 0x0800, - wxTB_HORZ_TEXT = wxTB_HORZ_LAYOUT | wxTB_TEXT + wxTB_HORZ_TEXT = wxTB_HORZ_LAYOUT | wxTB_TEXT, + + // don't show the toolbar short help tooltips + wxTB_NO_TOOLTIPS = 0x1000 }; #if wxUSE_TOOLBAR diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index e7a02de316..26928541ed 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -111,6 +111,7 @@ public: void OnToggleToolbarSize(wxCommandEvent& event); void OnToggleToolbarOrient(wxCommandEvent& event); void OnToggleToolbarRows(wxCommandEvent& event); + void OnToggleTooltips(wxCommandEvent& event); void OnToggleCustomDisabled(wxCommandEvent& event); void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); } @@ -149,7 +150,8 @@ private: bool m_smallToolbar, m_horzToolbar, m_horzText, - m_useCustomDisabled; + m_useCustomDisabled, + m_showTooltips; size_t m_rows; // 1 or 2 only // the number of print buttons we have (they're added/removed dynamically) @@ -175,6 +177,7 @@ enum IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200, IDM_TOOLBAR_TOGGLETOOLBARORIENT, IDM_TOOLBAR_TOGGLETOOLBARROWS, + IDM_TOOLBAR_TOGGLETOOLTIPS, IDM_TOOLBAR_TOGGLECUSTOMDISABLED, IDM_TOOLBAR_ENABLEPRINT, IDM_TOOLBAR_DELETEPRINT, @@ -218,6 +221,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize) EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient) EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows) + EVT_MENU(IDM_TOOLBAR_TOGGLETOOLTIPS, MyFrame::OnToggleTooltips) EVT_MENU(IDM_TOOLBAR_TOGGLECUSTOMDISABLED, MyFrame::OnToggleCustomDisabled) EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint) @@ -302,6 +306,11 @@ void MyFrame::RecreateToolbar() style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_HORZ_LAYOUT); style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL; + if ( m_showTooltips ) + style &= ~wxTB_NO_TOOLTIPS; + else + style |= wxTB_NO_TOOLTIPS; + if ( style & wxTB_TEXT && !(style & wxTB_NOICONS) && m_horzText ) style |= wxTB_HORZ_LAYOUT; @@ -354,10 +363,10 @@ void MyFrame::RecreateToolbar() toolBarBitmaps[n] = wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h)); } - - toolBar->SetToolBitmapSize(wxSize(w, h)); } + toolBar->SetToolBitmapSize(wxSize(w, h)); + toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[Tool_new], _T("New file")); toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[Tool_open], _T("Open file")); @@ -432,6 +441,8 @@ MyFrame::MyFrame(wxFrame* parent, m_horzToolbar = true; m_horzText = false; m_useCustomDisabled = false; + m_showTooltips = true; + m_rows = 1; m_nPrint = 1; @@ -469,6 +480,10 @@ MyFrame::MyFrame(wxFrame* parent, _T("Toggle number of &rows\tCtrl-R"), _T("Toggle number of toolbar rows between 1 and 2")); + tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLTIPS, + _T("Show &tooltips\tCtrl-L"), + _T("Show tooltips for the toolbar tools")); + tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLECUSTOMDISABLED, _T("Use c&ustom disabled images\tCtrl-U"), _T("Switch between using system-generated and custom disabled images")); @@ -507,6 +522,7 @@ MyFrame::MyFrame(wxFrame* parent, SetMenuBar(menuBar); menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, true); + menuBar->Check(IDM_TOOLBAR_TOGGLETOOLTIPS, true); // Create the toolbar RecreateToolbar(); @@ -630,6 +646,13 @@ void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event)) //RecreateToolbar(); -- this is unneeded } +void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event)) +{ + m_showTooltips = !m_showTooltips; + + RecreateToolbar(); +} + void MyFrame::OnToggleCustomDisabled(wxCommandEvent& WXUNUSED(event)) { m_useCustomDisabled = !m_useCustomDisabled; diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index cbe4087f73..e56eba64a1 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -317,8 +317,7 @@ bool wxToolBar::Create( wxWindow *parent, ConnectWidget( m_widget ); gtk_widget_show(GTK_WIDGET(m_toolbar)); } - - gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); + gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), !(style & wxTB_NO_TOOLTIPS) ); // FIXME: there is no such function for toolbars in 2.0 #if 0 @@ -346,7 +345,16 @@ void wxToolBar::GtkSetStyle() void wxToolBar::SetWindowStyleFlag( long style ) { wxToolBarBase::SetWindowStyleFlag(style); - + if( style & wxTB_TOOLTIPS ) + { + if( m_toolbar ) + gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); + } + else + { + if( m_toolbar ) + gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), FALSE ); + } if ( m_toolbar ) GtkSetStyle(); } diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 606e581cd9..1068ff35ed 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -376,9 +376,8 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const (style & ~wxBORDER_MASK) | wxBORDER_NONE, exstyle ); - // always include this one, it never hurts and setting it later - // only if we do have tooltips wouldn't work - msStyle |= TBSTYLE_TOOLTIPS; + if ( !(style & wxTB_NO_TOOLTIPS) ) + msStyle |= TBSTYLE_TOOLTIPS; if ( style & (wxTB_FLAT | wxTB_HORZ_LAYOUT) ) { @@ -1118,33 +1117,34 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *WXUNUSED(result)) { + if( !HasFlag(wxTB_NO_TOOLTIPS) ) + { #if wxUSE_TOOLTIPS - // First check if this applies to us - NMHDR *hdr = (NMHDR *)lParam; + // First check if this applies to us + NMHDR *hdr = (NMHDR *)lParam; - // the tooltips control created by the toolbar is sometimes Unicode, even - // in an ANSI application - this seems to be a bug in comctl32.dll v5 - UINT code = hdr->code; - if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) ) - return false; + // the tooltips control created by the toolbar is sometimes Unicode, even + // in an ANSI application - this seems to be a bug in comctl32.dll v5 + UINT code = hdr->code; + if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) ) + return false; - HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0); - if ( toolTipWnd != hdr->hwndFrom ) - return false; + HWND toolTipWnd = (HWND)::SendMessage(GetHwnd(), TB_GETTOOLTIPS, 0, 0); + if ( toolTipWnd != hdr->hwndFrom ) + return false; - LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam; - int id = (int)ttText->hdr.idFrom; + LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam; + int id = (int)ttText->hdr.idFrom; - wxToolBarToolBase *tool = FindById(id); - if ( !tool ) - return false; - - return HandleTooltipNotify(code, lParam, tool->GetShortHelp()); + wxToolBarToolBase *tool = FindById(id); + if ( tool ) + return HandleTooltipNotify(code, lParam, tool->GetShortHelp()); #else - wxUnusedVar(lParam); + wxUnusedVar(lParam); +#endif + } return false; -#endif } // ----------------------------------------------------------------------------