- Added wxControl::GetSizeFromTextSize() (Manuel Martin).
- Optionally allow showing tooltips for disabled ribbon buttons (wxBen).
- Add wxTL_NO_HEADER style to wxTreeListCtrl (robboto).
+- Add possibility to delay showing wxRichToolTip (John Roberts).
wxGTK:
// Purpose: wxRichToolTipGenericImpl declaration.
// Author: Vadim Zeitlin
// 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>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// This is pretty arbitrary, we could follow MSW and use some multiple
// of double-click time here.
m_timeout = 5000;
+ m_delay = 0;
}
virtual void SetBackgroundColour(const wxColour& col,
const wxColour& colEnd);
virtual void SetCustomIcon(const wxIcon& 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 SetTitleFont(const wxFont& font);
wxColour m_colStart,
m_colEnd;
- unsigned m_timeout;
+ unsigned m_timeout,
+ m_delay;
wxTipKind m_tipKind;
// Purpose: wxRichToolTipImpl declaration.
// Author: Vadim Zeitlin
// 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>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
const wxColour& colEnd) = 0;
virtual void SetCustomIcon(const wxIcon& 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 SetTitleFont(const wxFont& font) = 0;
// Purpose: Declaration of wxRichToolTip class.
// Author: Vadim Zeitlin
// 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>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// elapses but this method can be used to change this or also disable
// hiding the tooltip automatically entirely by passing 0 in this parameter
// (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
// automatically, as if wxTipKind_Auto was used.
//@}
/**
- 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
- time elapses but this method can be used to change this or also disable
- hiding the tooltip automatically entirely by passing 0 in this parameter
- (but doing this will prevent the native MSW version from being used).
+ By default the tooltip is shown immediately and hidden after a
+ system-dependent interval of time elapses. This method can be used to
+ change this or also disable hiding the tooltip automatically entirely
+ 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
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.
WXSIZEOF(bgStyles), bgStyles,
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 );
m_timeouts = new wxRadioBox(this, wxID_ANY, "Timeout:",
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(timeouts), timeouts,
1, wxRA_SPECIFY_ROWS);
m_timeouts->SetSelection(Timeout_Default);
+ m_timeDelay = new wxCheckBox(this, wxID_ANY, "Delay show" );
// Lay them out.
m_textBody->SetMinSize(wxSize(300, 200));
sizer->Add(m_tipKinds, wxSizerFlags().Centre().Border());
sizer->Add(m_bgStyles, wxSizerFlags().Centre().Border());
sizer->Add(m_timeouts, wxSizerFlags().Centre().Border());
+ sizer->Add(m_timeDelay, wxSizerFlags().Centre().Border());
wxBoxSizer* const sizerBtns = new wxBoxSizer(wxHORIZONTAL);
sizerBtns->Add(btnShowText, wxSizerFlags().Border(wxRIGHT));
sizerBtns->Add(btnShowBtn, wxSizerFlags().Border(wxLEFT));
break;
}
+ int delay = m_timeDelay->IsChecked() ? 500 : 0;
+
switch ( m_timeouts->GetSelection() )
{
case Timeout_None:
- tip.SetTimeout(0);
+ // Don't call SetTimeout unnecessarily
+ // or msw will show generic impl
+ if ( delay )
+ tip.SetTimeout(0, delay);
break;
case Timeout_Default:
break;
case Timeout_3sec:
- tip.SetTimeout(3000);
+ tip.SetTimeout(3000, delay);
break;
}
wxRadioBox* m_tipKinds;
wxRadioBox* m_bgStyles;
wxRadioBox* m_timeouts;
+ wxCheckBox* m_timeDelay;
};
void MyFrame::OnRichTipDialog(wxCommandEvent& WXUNUSED(event))
// Purpose: wxRichToolTip implementation common to all platforms.
// Author: Vadim Zeitlin
// 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>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
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)
// Purpose: Implementation of wxRichToolTip.
// Author: Vadim Zeitlin
// 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>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
}
}
- void DoShow()
+ void SetPosition()
{
wxPoint pos = GetTipPoint();
pos -= m_anchorPos;
Move(pos, wxSIZE_NO_ADJUSTMENTS);
+ }
+ void DoShow()
+ {
Popup();
}
- void SetTimeout(unsigned timeout)
+ void SetTimeoutAndShow(unsigned timeout, unsigned delay)
{
- if ( !timeout )
+ if ( !timeout && !delay )
+ {
+ DoShow();
return;
+ }
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:
// Timer event handler hides the tooltip when the timeout expires.
void OnTimer(wxTimerEvent& WXUNUSED(event))
{
- // Doing "Notify" here ensures that our OnDismiss() is called and so we
- // also Destroy() ourselves. We could use Dismiss() and call Destroy()
- // explicitly from here as well.
- DismissAndNotify();
+ if ( !m_delayShow )
+ {
+ // Doing "Notify" here ensures that our OnDismiss() is called and so we
+ // also Destroy() ourselves. We could use Dismiss() and call Destroy()
+ // explicitly from here as well.
+ DismissAndNotify();
+
+ return;
+ }
+
+ m_delayShow = false;
+
+ if ( m_timeout )
+ m_timer.Start(m_timeout, true);
+
+ DoShow();
}
// The timer counting down the time until we're hidden.
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);
};
}
}
-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)
popup->SetBackgroundColours(m_colStart, m_colEnd);
- popup->DoShow();
-
- popup->SetTimeout(m_timeout);
+ popup->SetPosition();
+ // show or start the timer to delay showing the popup
+ popup->SetTimeoutAndShow( m_timeout, m_delay );
}
// Currently only wxMSW provides a native implementation.
// Purpose: Native MSW implementation of wxRichToolTip.
// Author: Vadim Zeitlin
// 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>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
}
}
- virtual void SetTimeout(unsigned milliseconds)
+ virtual void SetTimeout(unsigned millisecondsTimeout,
+ unsigned millisecondsDelay)
{
- // We don't support changing the timeout (maybe TTM_SETDELAYTIME could
- // be used for this?).
+ // We don't support changing the timeout or the delay
+ // (maybe TTM_SETDELAYTIME could be used for this?).
m_canUseNative = false;
- wxRichToolTipGenericImpl::SetTimeout(milliseconds);
+ wxRichToolTipGenericImpl::SetTimeout(millisecondsTimeout,
+ millisecondsDelay);
}
virtual void SetTipKind(wxTipKind tipKind)