Add possibility to delay showing wxRichToolTip.
Optionally show the tooltip after a delay instead of doing it immediately when Show() is called. Closes #14846. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72997 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -593,6 +593,7 @@ All (GUI):
|
|||||||
- Added wxControl::GetSizeFromTextSize() (Manuel Martin).
|
- Added wxControl::GetSizeFromTextSize() (Manuel Martin).
|
||||||
- Optionally allow showing tooltips for disabled ribbon buttons (wxBen).
|
- Optionally allow showing tooltips for disabled ribbon buttons (wxBen).
|
||||||
- Add wxTL_NO_HEADER style to wxTreeListCtrl (robboto).
|
- Add wxTL_NO_HEADER style to wxTreeListCtrl (robboto).
|
||||||
|
- Add possibility to delay showing wxRichToolTip (John Roberts).
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
// Purpose: wxRichToolTipGenericImpl declaration.
|
// Purpose: wxRichToolTipGenericImpl declaration.
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Created: 2011-10-18
|
// Created: 2011-10-18
|
||||||
// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -30,13 +30,15 @@ public:
|
|||||||
// This is pretty arbitrary, we could follow MSW and use some multiple
|
// This is pretty arbitrary, we could follow MSW and use some multiple
|
||||||
// of double-click time here.
|
// of double-click time here.
|
||||||
m_timeout = 5000;
|
m_timeout = 5000;
|
||||||
|
m_delay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetBackgroundColour(const wxColour& col,
|
virtual void SetBackgroundColour(const wxColour& col,
|
||||||
const wxColour& colEnd);
|
const wxColour& colEnd);
|
||||||
virtual void SetCustomIcon(const wxIcon& icon);
|
virtual void SetCustomIcon(const wxIcon& icon);
|
||||||
virtual void SetStandardIcon(int icon);
|
virtual void SetStandardIcon(int icon);
|
||||||
virtual void SetTimeout(unsigned milliseconds);
|
virtual void SetTimeout(unsigned milliseconds,
|
||||||
|
unsigned millisecondsDelay = 0);
|
||||||
virtual void SetTipKind(wxTipKind tipKind);
|
virtual void SetTipKind(wxTipKind tipKind);
|
||||||
virtual void SetTitleFont(const wxFont& font);
|
virtual void SetTitleFont(const wxFont& font);
|
||||||
|
|
||||||
@@ -52,7 +54,8 @@ private:
|
|||||||
wxColour m_colStart,
|
wxColour m_colStart,
|
||||||
m_colEnd;
|
m_colEnd;
|
||||||
|
|
||||||
unsigned m_timeout;
|
unsigned m_timeout,
|
||||||
|
m_delay;
|
||||||
|
|
||||||
wxTipKind m_tipKind;
|
wxTipKind m_tipKind;
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
// Purpose: wxRichToolTipImpl declaration.
|
// Purpose: wxRichToolTipImpl declaration.
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Created: 2011-10-18
|
// Created: 2011-10-18
|
||||||
// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -29,7 +29,8 @@ public:
|
|||||||
const wxColour& colEnd) = 0;
|
const wxColour& colEnd) = 0;
|
||||||
virtual void SetCustomIcon(const wxIcon& icon) = 0;
|
virtual void SetCustomIcon(const wxIcon& icon) = 0;
|
||||||
virtual void SetStandardIcon(int icon) = 0;
|
virtual void SetStandardIcon(int icon) = 0;
|
||||||
virtual void SetTimeout(unsigned milliseconds) = 0;
|
virtual void SetTimeout(unsigned milliseconds,
|
||||||
|
unsigned millisecondsShowdelay = 0) = 0;
|
||||||
virtual void SetTipKind(wxTipKind tipKind) = 0;
|
virtual void SetTipKind(wxTipKind tipKind) = 0;
|
||||||
virtual void SetTitleFont(const wxFont& font) = 0;
|
virtual void SetTitleFont(const wxFont& font) = 0;
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
// Purpose: Declaration of wxRichToolTip class.
|
// Purpose: Declaration of wxRichToolTip class.
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Created: 2011-10-07
|
// Created: 2011-10-07
|
||||||
// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -76,7 +76,8 @@ public:
|
|||||||
// elapses but this method can be used to change this or also disable
|
// elapses but this method can be used to change this or also disable
|
||||||
// hiding the tooltip automatically entirely by passing 0 in this parameter
|
// hiding the tooltip automatically entirely by passing 0 in this parameter
|
||||||
// (but doing this can result in native version not being used).
|
// (but doing this can result in native version not being used).
|
||||||
void SetTimeout(unsigned milliseconds);
|
// Optionally specify a show delay.
|
||||||
|
void SetTimeout(unsigned milliseconds, unsigned millisecondsShowdelay = 0);
|
||||||
|
|
||||||
// Choose the tip kind, possibly none. By default the tip is positioned
|
// Choose the tip kind, possibly none. By default the tip is positioned
|
||||||
// automatically, as if wxTipKind_Auto was used.
|
// automatically, as if wxTipKind_Auto was used.
|
||||||
|
@@ -133,17 +133,21 @@ public:
|
|||||||
//@}
|
//@}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set timeout after which the tooltip should disappear, in milliseconds.
|
Set timeout after which the tooltip should disappear and
|
||||||
|
optionally set a delay before the tooltip is shown, in milliseconds.
|
||||||
|
|
||||||
By default the tooltip is hidden after system-dependent interval of
|
By default the tooltip is shown immediately and hidden after a
|
||||||
time elapses but this method can be used to change this or also disable
|
system-dependent interval of time elapses. This method can be used to
|
||||||
hiding the tooltip automatically entirely by passing 0 in this parameter
|
change this or also disable hiding the tooltip automatically entirely
|
||||||
(but doing this will prevent the native MSW version from being used).
|
by passing 0 in this parameter (but doing this will prevent the native
|
||||||
|
MSW version from being used).
|
||||||
|
|
||||||
Notice that the tooltip will always be hidden if the user presses a key
|
Notice that the tooltip will always be hidden if the user presses a key
|
||||||
or clicks a mouse button.
|
or clicks a mouse button.
|
||||||
|
|
||||||
|
Parameter @a millisecondsDelay is new since wxWidgets 2.9.5.
|
||||||
*/
|
*/
|
||||||
void SetTimeout(unsigned milliseconds);
|
void SetTimeout(unsigned millisecondsTimeout, unsigned millisecondsDelay = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Choose the tip kind, possibly none.
|
Choose the tip kind, possibly none.
|
||||||
|
@@ -1854,13 +1854,14 @@ public:
|
|||||||
WXSIZEOF(bgStyles), bgStyles,
|
WXSIZEOF(bgStyles), bgStyles,
|
||||||
1, wxRA_SPECIFY_ROWS);
|
1, wxRA_SPECIFY_ROWS);
|
||||||
|
|
||||||
const wxString timeouts[] = { "&None", "&Default", "&3 seconds" };
|
const wxString timeouts[] = { "&None", "&Default (no delay)", "&3 seconds" };
|
||||||
wxCOMPILE_TIME_ASSERT( WXSIZEOF(timeouts) == Timeout_Max, TmMismatch );
|
wxCOMPILE_TIME_ASSERT( WXSIZEOF(timeouts) == Timeout_Max, TmMismatch );
|
||||||
m_timeouts = new wxRadioBox(this, wxID_ANY, "Timeout:",
|
m_timeouts = new wxRadioBox(this, wxID_ANY, "Timeout:",
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
WXSIZEOF(timeouts), timeouts,
|
WXSIZEOF(timeouts), timeouts,
|
||||||
1, wxRA_SPECIFY_ROWS);
|
1, wxRA_SPECIFY_ROWS);
|
||||||
m_timeouts->SetSelection(Timeout_Default);
|
m_timeouts->SetSelection(Timeout_Default);
|
||||||
|
m_timeDelay = new wxCheckBox(this, wxID_ANY, "Delay show" );
|
||||||
|
|
||||||
// Lay them out.
|
// Lay them out.
|
||||||
m_textBody->SetMinSize(wxSize(300, 200));
|
m_textBody->SetMinSize(wxSize(300, 200));
|
||||||
@@ -1872,6 +1873,7 @@ public:
|
|||||||
sizer->Add(m_tipKinds, wxSizerFlags().Centre().Border());
|
sizer->Add(m_tipKinds, wxSizerFlags().Centre().Border());
|
||||||
sizer->Add(m_bgStyles, wxSizerFlags().Centre().Border());
|
sizer->Add(m_bgStyles, wxSizerFlags().Centre().Border());
|
||||||
sizer->Add(m_timeouts, wxSizerFlags().Centre().Border());
|
sizer->Add(m_timeouts, wxSizerFlags().Centre().Border());
|
||||||
|
sizer->Add(m_timeDelay, wxSizerFlags().Centre().Border());
|
||||||
wxBoxSizer* const sizerBtns = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* const sizerBtns = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizerBtns->Add(btnShowText, wxSizerFlags().Border(wxRIGHT));
|
sizerBtns->Add(btnShowText, wxSizerFlags().Border(wxRIGHT));
|
||||||
sizerBtns->Add(btnShowBtn, wxSizerFlags().Border(wxLEFT));
|
sizerBtns->Add(btnShowBtn, wxSizerFlags().Border(wxLEFT));
|
||||||
@@ -1972,17 +1974,22 @@ private:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int delay = m_timeDelay->IsChecked() ? 500 : 0;
|
||||||
|
|
||||||
switch ( m_timeouts->GetSelection() )
|
switch ( m_timeouts->GetSelection() )
|
||||||
{
|
{
|
||||||
case Timeout_None:
|
case Timeout_None:
|
||||||
tip.SetTimeout(0);
|
// Don't call SetTimeout unnecessarily
|
||||||
|
// or msw will show generic impl
|
||||||
|
if ( delay )
|
||||||
|
tip.SetTimeout(0, delay);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Timeout_Default:
|
case Timeout_Default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Timeout_3sec:
|
case Timeout_3sec:
|
||||||
tip.SetTimeout(3000);
|
tip.SetTimeout(3000, delay);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1997,6 +2004,7 @@ private:
|
|||||||
wxRadioBox* m_tipKinds;
|
wxRadioBox* m_tipKinds;
|
||||||
wxRadioBox* m_bgStyles;
|
wxRadioBox* m_bgStyles;
|
||||||
wxRadioBox* m_timeouts;
|
wxRadioBox* m_timeouts;
|
||||||
|
wxCheckBox* m_timeDelay;
|
||||||
};
|
};
|
||||||
|
|
||||||
void MyFrame::OnRichTipDialog(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnRichTipDialog(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
// Purpose: wxRichToolTip implementation common to all platforms.
|
// Purpose: wxRichToolTip implementation common to all platforms.
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Created: 2011-10-18
|
// Created: 2011-10-18
|
||||||
// RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -57,9 +57,10 @@ void wxRichToolTip::SetIcon(const wxIcon& icon)
|
|||||||
m_impl->SetCustomIcon(icon);
|
m_impl->SetCustomIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRichToolTip::SetTimeout(unsigned milliseconds)
|
void wxRichToolTip::SetTimeout(unsigned milliseconds,
|
||||||
|
unsigned millisecondsDelay)
|
||||||
{
|
{
|
||||||
m_impl->SetTimeout(milliseconds);
|
m_impl->SetTimeout(milliseconds, millisecondsDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRichToolTip::SetTipKind(wxTipKind tipKind)
|
void wxRichToolTip::SetTipKind(wxTipKind tipKind)
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
// Purpose: Implementation of wxRichToolTip.
|
// Purpose: Implementation of wxRichToolTip.
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Created: 2011-10-07
|
// Created: 2011-10-07
|
||||||
// RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -232,7 +232,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoShow()
|
void SetPosition()
|
||||||
{
|
{
|
||||||
wxPoint pos = GetTipPoint();
|
wxPoint pos = GetTipPoint();
|
||||||
|
|
||||||
@@ -241,18 +241,30 @@ public:
|
|||||||
pos -= m_anchorPos;
|
pos -= m_anchorPos;
|
||||||
|
|
||||||
Move(pos, wxSIZE_NO_ADJUSTMENTS);
|
Move(pos, wxSIZE_NO_ADJUSTMENTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoShow()
|
||||||
|
{
|
||||||
Popup();
|
Popup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTimeout(unsigned timeout)
|
void SetTimeoutAndShow(unsigned timeout, unsigned delay)
|
||||||
{
|
{
|
||||||
if ( !timeout )
|
if ( !timeout && !delay )
|
||||||
|
{
|
||||||
|
DoShow();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Connect(wxEVT_TIMER, wxTimerEventHandler(wxRichToolTipPopup::OnTimer));
|
Connect(wxEVT_TIMER, wxTimerEventHandler(wxRichToolTipPopup::OnTimer));
|
||||||
|
|
||||||
m_timer.Start(timeout, true /* one shot */);
|
m_timeout = timeout; // set for use in OnTimer if we have a delay
|
||||||
|
m_delayShow = delay != 0;
|
||||||
|
|
||||||
|
if ( !m_delayShow )
|
||||||
|
DoShow();
|
||||||
|
|
||||||
|
m_timer.Start((delay ? delay : timeout), true /* one shot */);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -559,11 +571,23 @@ private:
|
|||||||
|
|
||||||
// Timer event handler hides the tooltip when the timeout expires.
|
// Timer event handler hides the tooltip when the timeout expires.
|
||||||
void OnTimer(wxTimerEvent& WXUNUSED(event))
|
void OnTimer(wxTimerEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if ( !m_delayShow )
|
||||||
{
|
{
|
||||||
// Doing "Notify" here ensures that our OnDismiss() is called and so we
|
// Doing "Notify" here ensures that our OnDismiss() is called and so we
|
||||||
// also Destroy() ourselves. We could use Dismiss() and call Destroy()
|
// also Destroy() ourselves. We could use Dismiss() and call Destroy()
|
||||||
// explicitly from here as well.
|
// explicitly from here as well.
|
||||||
DismissAndNotify();
|
DismissAndNotify();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_delayShow = false;
|
||||||
|
|
||||||
|
if ( m_timeout )
|
||||||
|
m_timer.Start(m_timeout, true);
|
||||||
|
|
||||||
|
DoShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -574,6 +598,12 @@ private:
|
|||||||
// The timer counting down the time until we're hidden.
|
// The timer counting down the time until we're hidden.
|
||||||
wxTimer m_timer;
|
wxTimer m_timer;
|
||||||
|
|
||||||
|
// We will need to accesss the timeout period when delaying showing tooltip.
|
||||||
|
int m_timeout;
|
||||||
|
|
||||||
|
// If true, delay showing the tooltip.
|
||||||
|
bool m_delayShow;
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxRichToolTipPopup);
|
wxDECLARE_NO_COPY_CLASS(wxRichToolTipPopup);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -621,9 +651,11 @@ void wxRichToolTipGenericImpl::SetStandardIcon(int icon)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRichToolTipGenericImpl::SetTimeout(unsigned milliseconds)
|
void wxRichToolTipGenericImpl::SetTimeout(unsigned millisecondsTimeout,
|
||||||
|
unsigned millisecondsDelay)
|
||||||
{
|
{
|
||||||
m_timeout = milliseconds;
|
m_delay = millisecondsDelay;
|
||||||
|
m_timeout = millisecondsTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRichToolTipGenericImpl::SetTipKind(wxTipKind tipKind)
|
void wxRichToolTipGenericImpl::SetTipKind(wxTipKind tipKind)
|
||||||
@@ -653,9 +685,9 @@ void wxRichToolTipGenericImpl::ShowFor(wxWindow* win)
|
|||||||
|
|
||||||
popup->SetBackgroundColours(m_colStart, m_colEnd);
|
popup->SetBackgroundColours(m_colStart, m_colEnd);
|
||||||
|
|
||||||
popup->DoShow();
|
popup->SetPosition();
|
||||||
|
// show or start the timer to delay showing the popup
|
||||||
popup->SetTimeout(m_timeout);
|
popup->SetTimeoutAndShow( m_timeout, m_delay );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently only wxMSW provides a native implementation.
|
// Currently only wxMSW provides a native implementation.
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
// Purpose: Native MSW implementation of wxRichToolTip.
|
// Purpose: Native MSW implementation of wxRichToolTip.
|
||||||
// Author: Vadim Zeitlin
|
// Author: Vadim Zeitlin
|
||||||
// Created: 2011-10-18
|
// Created: 2011-10-18
|
||||||
// RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -123,13 +123,15 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetTimeout(unsigned milliseconds)
|
virtual void SetTimeout(unsigned millisecondsTimeout,
|
||||||
|
unsigned millisecondsDelay)
|
||||||
{
|
{
|
||||||
// We don't support changing the timeout (maybe TTM_SETDELAYTIME could
|
// We don't support changing the timeout or the delay
|
||||||
// be used for this?).
|
// (maybe TTM_SETDELAYTIME could be used for this?).
|
||||||
m_canUseNative = false;
|
m_canUseNative = false;
|
||||||
|
|
||||||
wxRichToolTipGenericImpl::SetTimeout(milliseconds);
|
wxRichToolTipGenericImpl::SetTimeout(millisecondsTimeout,
|
||||||
|
millisecondsDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetTipKind(wxTipKind tipKind)
|
virtual void SetTipKind(wxTipKind tipKind)
|
||||||
|
Reference in New Issue
Block a user