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
This commit is contained in:
parent
0bb4ad85f3
commit
6a1b3ead3f
@ -140,6 +140,7 @@ All (GUI):
|
|||||||
- wxString <-> wxColour conversions in wxColour class (Francesco Montorsi).
|
- wxString <-> wxColour conversions in wxColour class (Francesco Montorsi).
|
||||||
- Fixed bug with ignoring blank lines in multiline wxGrid cell labels
|
- Fixed bug with ignoring blank lines in multiline wxGrid cell labels
|
||||||
- Added wxTextAttr::Merge() (Marcin Simonides)
|
- Added wxTextAttr::Merge() (Marcin Simonides)
|
||||||
|
- Added wxTB_NO_TOOLTIPS style (Igor Korot)
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@ -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
|
\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.}
|
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\_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}
|
\end{twocollist}
|
||||||
|
|
||||||
See also \helpref{window styles overview}{windowstyles}. Note that the Win32
|
See also \helpref{window styles overview}{windowstyles}. Note that the Win32
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = wxTB_HORIZONTAL,
|
||||||
const wxString& name = wxToolBarNameStr )
|
const wxString& name = wxToolBarNameStr )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
@ -49,7 +49,10 @@ enum
|
|||||||
|
|
||||||
// show the text and the icons alongside, not vertically stacked (Win32/GTK)
|
// show the text and the icons alongside, not vertically stacked (Win32/GTK)
|
||||||
wxTB_HORZ_LAYOUT = 0x0800,
|
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
|
#if wxUSE_TOOLBAR
|
||||||
|
@ -111,6 +111,7 @@ public:
|
|||||||
void OnToggleToolbarSize(wxCommandEvent& event);
|
void OnToggleToolbarSize(wxCommandEvent& event);
|
||||||
void OnToggleToolbarOrient(wxCommandEvent& event);
|
void OnToggleToolbarOrient(wxCommandEvent& event);
|
||||||
void OnToggleToolbarRows(wxCommandEvent& event);
|
void OnToggleToolbarRows(wxCommandEvent& event);
|
||||||
|
void OnToggleTooltips(wxCommandEvent& event);
|
||||||
void OnToggleCustomDisabled(wxCommandEvent& event);
|
void OnToggleCustomDisabled(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); }
|
void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); }
|
||||||
@ -149,7 +150,8 @@ private:
|
|||||||
bool m_smallToolbar,
|
bool m_smallToolbar,
|
||||||
m_horzToolbar,
|
m_horzToolbar,
|
||||||
m_horzText,
|
m_horzText,
|
||||||
m_useCustomDisabled;
|
m_useCustomDisabled,
|
||||||
|
m_showTooltips;
|
||||||
size_t m_rows; // 1 or 2 only
|
size_t m_rows; // 1 or 2 only
|
||||||
|
|
||||||
// the number of print buttons we have (they're added/removed dynamically)
|
// the number of print buttons we have (they're added/removed dynamically)
|
||||||
@ -175,6 +177,7 @@ enum
|
|||||||
IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200,
|
IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200,
|
||||||
IDM_TOOLBAR_TOGGLETOOLBARORIENT,
|
IDM_TOOLBAR_TOGGLETOOLBARORIENT,
|
||||||
IDM_TOOLBAR_TOGGLETOOLBARROWS,
|
IDM_TOOLBAR_TOGGLETOOLBARROWS,
|
||||||
|
IDM_TOOLBAR_TOGGLETOOLTIPS,
|
||||||
IDM_TOOLBAR_TOGGLECUSTOMDISABLED,
|
IDM_TOOLBAR_TOGGLECUSTOMDISABLED,
|
||||||
IDM_TOOLBAR_ENABLEPRINT,
|
IDM_TOOLBAR_ENABLEPRINT,
|
||||||
IDM_TOOLBAR_DELETEPRINT,
|
IDM_TOOLBAR_DELETEPRINT,
|
||||||
@ -218,6 +221,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows)
|
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_TOGGLECUSTOMDISABLED, MyFrame::OnToggleCustomDisabled)
|
||||||
|
|
||||||
EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint)
|
EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint)
|
||||||
@ -302,6 +306,11 @@ void MyFrame::RecreateToolbar()
|
|||||||
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_HORZ_LAYOUT);
|
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_HORZ_LAYOUT);
|
||||||
style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
|
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 )
|
if ( style & wxTB_TEXT && !(style & wxTB_NOICONS) && m_horzText )
|
||||||
style |= wxTB_HORZ_LAYOUT;
|
style |= wxTB_HORZ_LAYOUT;
|
||||||
|
|
||||||
@ -354,9 +363,9 @@ void MyFrame::RecreateToolbar()
|
|||||||
toolBarBitmaps[n] =
|
toolBarBitmaps[n] =
|
||||||
wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h));
|
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_NEW, _T("New"), toolBarBitmaps[Tool_new], _T("New file"));
|
||||||
toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[Tool_open], _T("Open 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_horzToolbar = true;
|
||||||
m_horzText = false;
|
m_horzText = false;
|
||||||
m_useCustomDisabled = false;
|
m_useCustomDisabled = false;
|
||||||
|
m_showTooltips = true;
|
||||||
|
|
||||||
m_rows = 1;
|
m_rows = 1;
|
||||||
m_nPrint = 1;
|
m_nPrint = 1;
|
||||||
|
|
||||||
@ -469,6 +480,10 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
_T("Toggle number of &rows\tCtrl-R"),
|
_T("Toggle number of &rows\tCtrl-R"),
|
||||||
_T("Toggle number of toolbar rows between 1 and 2"));
|
_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,
|
tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLECUSTOMDISABLED,
|
||||||
_T("Use c&ustom disabled images\tCtrl-U"),
|
_T("Use c&ustom disabled images\tCtrl-U"),
|
||||||
_T("Switch between using system-generated and custom disabled images"));
|
_T("Switch between using system-generated and custom disabled images"));
|
||||||
@ -507,6 +522,7 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, true);
|
menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, true);
|
||||||
|
menuBar->Check(IDM_TOOLBAR_TOGGLETOOLTIPS, true);
|
||||||
|
|
||||||
// Create the toolbar
|
// Create the toolbar
|
||||||
RecreateToolbar();
|
RecreateToolbar();
|
||||||
@ -630,6 +646,13 @@ void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event))
|
|||||||
//RecreateToolbar(); -- this is unneeded
|
//RecreateToolbar(); -- this is unneeded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
m_showTooltips = !m_showTooltips;
|
||||||
|
|
||||||
|
RecreateToolbar();
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnToggleCustomDisabled(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnToggleCustomDisabled(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
m_useCustomDisabled = !m_useCustomDisabled;
|
m_useCustomDisabled = !m_useCustomDisabled;
|
||||||
|
@ -317,8 +317,7 @@ bool wxToolBar::Create( wxWindow *parent,
|
|||||||
ConnectWidget( m_widget );
|
ConnectWidget( m_widget );
|
||||||
gtk_widget_show(GTK_WIDGET(m_toolbar));
|
gtk_widget_show(GTK_WIDGET(m_toolbar));
|
||||||
}
|
}
|
||||||
|
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), !(style & wxTB_NO_TOOLTIPS) );
|
||||||
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
|
|
||||||
|
|
||||||
// FIXME: there is no such function for toolbars in 2.0
|
// FIXME: there is no such function for toolbars in 2.0
|
||||||
#if 0
|
#if 0
|
||||||
@ -346,7 +345,16 @@ void wxToolBar::GtkSetStyle()
|
|||||||
void wxToolBar::SetWindowStyleFlag( long style )
|
void wxToolBar::SetWindowStyleFlag( long style )
|
||||||
{
|
{
|
||||||
wxToolBarBase::SetWindowStyleFlag(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 )
|
if ( m_toolbar )
|
||||||
GtkSetStyle();
|
GtkSetStyle();
|
||||||
}
|
}
|
||||||
|
@ -376,8 +376,7 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
(style & ~wxBORDER_MASK) | wxBORDER_NONE, exstyle
|
(style & ~wxBORDER_MASK) | wxBORDER_NONE, exstyle
|
||||||
);
|
);
|
||||||
|
|
||||||
// always include this one, it never hurts and setting it later
|
if ( !(style & wxTB_NO_TOOLTIPS) )
|
||||||
// only if we do have tooltips wouldn't work
|
|
||||||
msStyle |= TBSTYLE_TOOLTIPS;
|
msStyle |= TBSTYLE_TOOLTIPS;
|
||||||
|
|
||||||
if ( style & (wxTB_FLAT | wxTB_HORZ_LAYOUT) )
|
if ( style & (wxTB_FLAT | wxTB_HORZ_LAYOUT) )
|
||||||
@ -1118,6 +1117,8 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl),
|
|||||||
WXLPARAM lParam,
|
WXLPARAM lParam,
|
||||||
WXLPARAM *WXUNUSED(result))
|
WXLPARAM *WXUNUSED(result))
|
||||||
{
|
{
|
||||||
|
if( !HasFlag(wxTB_NO_TOOLTIPS) )
|
||||||
|
{
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
// First check if this applies to us
|
// First check if this applies to us
|
||||||
NMHDR *hdr = (NMHDR *)lParam;
|
NMHDR *hdr = (NMHDR *)lParam;
|
||||||
@ -1128,7 +1129,7 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl),
|
|||||||
if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) )
|
if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0);
|
HWND toolTipWnd = (HWND)::SendMessage(GetHwnd(), TB_GETTOOLTIPS, 0, 0);
|
||||||
if ( toolTipWnd != hdr->hwndFrom )
|
if ( toolTipWnd != hdr->hwndFrom )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1136,15 +1137,14 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl),
|
|||||||
int id = (int)ttText->hdr.idFrom;
|
int id = (int)ttText->hdr.idFrom;
|
||||||
|
|
||||||
wxToolBarToolBase *tool = FindById(id);
|
wxToolBarToolBase *tool = FindById(id);
|
||||||
if ( !tool )
|
if ( tool )
|
||||||
return false;
|
|
||||||
|
|
||||||
return HandleTooltipNotify(code, lParam, tool->GetShortHelp());
|
return HandleTooltipNotify(code, lParam, tool->GetShortHelp());
|
||||||
#else
|
#else
|
||||||
wxUnusedVar(lParam);
|
wxUnusedVar(lParam);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user