Add "rect" paramerer to wxRichToolTip::ShowFor().
Allow to show the tooltip at the exact specified position instead of placing it automatically. Closes #14862. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73050 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -594,6 +594,7 @@ All (GUI):
|
|||||||
- 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).
|
- Add possibility to delay showing wxRichToolTip (John Roberts).
|
||||||
|
- Add "rect" paramerer to wxRichToolTip::ShowFor() (John Roberts).
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ public:
|
|||||||
virtual void SetTipKind(wxTipKind tipKind);
|
virtual void SetTipKind(wxTipKind tipKind);
|
||||||
virtual void SetTitleFont(const wxFont& font);
|
virtual void SetTitleFont(const wxFont& font);
|
||||||
|
|
||||||
virtual void ShowFor(wxWindow* win);
|
virtual void ShowFor(wxWindow* win, wxRect* rect = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_title,
|
wxString m_title,
|
||||||
|
@@ -34,7 +34,7 @@ public:
|
|||||||
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;
|
||||||
|
|
||||||
virtual void ShowFor(wxWindow* win) = 0;
|
virtual void ShowFor(wxWindow* win, wxRect* rect = NULL) = 0;
|
||||||
|
|
||||||
virtual ~wxRichToolTipImpl() { }
|
virtual ~wxRichToolTipImpl() { }
|
||||||
|
|
||||||
|
@@ -87,8 +87,8 @@ public:
|
|||||||
// or colour appropriate for the current platform.
|
// or colour appropriate for the current platform.
|
||||||
void SetTitleFont(const wxFont& font);
|
void SetTitleFont(const wxFont& font);
|
||||||
|
|
||||||
// Show the tooltip for the given window.
|
// Show the tooltip for the given window and optionally a specified area.
|
||||||
void ShowFor(wxWindow* win);
|
void ShowFor(wxWindow* win, wxRect* rect = NULL);
|
||||||
|
|
||||||
// Non-virtual dtor as this class is not supposed to be derived from.
|
// Non-virtual dtor as this class is not supposed to be derived from.
|
||||||
~wxRichToolTip();
|
~wxRichToolTip();
|
||||||
|
@@ -175,15 +175,20 @@ public:
|
|||||||
void SetTitleFont(const wxFont& font);
|
void SetTitleFont(const wxFont& font);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Show the tooltip for the given window.
|
Show the tooltip for the given window and optionally specify where to
|
||||||
|
show the tooltip.
|
||||||
|
|
||||||
The tooltip tip points to the (middle of the) specified window which
|
By default the tooltip tip points to the (middle of the) specified
|
||||||
must be non-@NULL.
|
window which must be non-@NULL or, if @a rect is non-@NULL, the middle
|
||||||
|
of the specified wxRect.
|
||||||
|
|
||||||
Currently the native MSW implementation is used only if @a win is a
|
Currently the native MSW implementation is used only if @a win is a
|
||||||
wxTextCtrl. This limitation may be removed in the future.
|
wxTextCtrl and @a rect is @NULL. This limitation may be removed in the
|
||||||
|
future.
|
||||||
|
|
||||||
|
Parameter @a rect is new since wxWidgets 2.9.5.
|
||||||
*/
|
*/
|
||||||
void ShowFor(wxWindow* win);
|
void ShowFor(wxWindow* win, wxRect* rect = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructor.
|
Destructor.
|
||||||
|
@@ -73,11 +73,11 @@ void wxRichToolTip::SetTitleFont(const wxFont& font)
|
|||||||
m_impl->SetTitleFont(font);
|
m_impl->SetTitleFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRichToolTip::ShowFor(wxWindow* win)
|
void wxRichToolTip::ShowFor(wxWindow* win, wxRect* rect = NULL);
|
||||||
{
|
{
|
||||||
wxCHECK_RET( win, wxS("Must have a valid window") );
|
wxCHECK_RET( win, wxS("Must have a valid window") );
|
||||||
|
|
||||||
m_impl->ShowFor(win);
|
m_impl->ShowFor(win, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRichToolTip::~wxRichToolTip()
|
wxRichToolTip::~wxRichToolTip()
|
||||||
|
@@ -232,9 +232,14 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPosition()
|
void SetPosition(wxRect* rect)
|
||||||
{
|
{
|
||||||
wxPoint pos = GetTipPoint();
|
wxPoint pos;
|
||||||
|
|
||||||
|
if ( !rect || rect->IsEmpty() )
|
||||||
|
pos = GetTipPoint();
|
||||||
|
else
|
||||||
|
pos = wxPoint( rect->x + rect->width / 2, rect->y + rect->height / 2 );
|
||||||
|
|
||||||
// We want our anchor point to coincide with this position so offset
|
// We want our anchor point to coincide with this position so offset
|
||||||
// the position of the top left corner passed to Move() accordingly.
|
// the position of the top left corner passed to Move() accordingly.
|
||||||
@@ -668,7 +673,7 @@ void wxRichToolTipGenericImpl::SetTitleFont(const wxFont& font)
|
|||||||
m_titleFont = font;
|
m_titleFont = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRichToolTipGenericImpl::ShowFor(wxWindow* win)
|
void wxRichToolTipGenericImpl::ShowFor(wxWindow* win, wxRect* rect = NULL);
|
||||||
{
|
{
|
||||||
// Set the focus to the window the tooltip refers to to make it look active.
|
// Set the focus to the window the tooltip refers to to make it look active.
|
||||||
win->SetFocus();
|
win->SetFocus();
|
||||||
@@ -685,7 +690,7 @@ void wxRichToolTipGenericImpl::ShowFor(wxWindow* win)
|
|||||||
|
|
||||||
popup->SetBackgroundColours(m_colStart, m_colEnd);
|
popup->SetBackgroundColours(m_colStart, m_colEnd);
|
||||||
|
|
||||||
popup->SetPosition();
|
popup->SetPosition(rect);
|
||||||
// show or start the timer to delay showing the popup
|
// show or start the timer to delay showing the popup
|
||||||
popup->SetTimeoutAndShow( m_timeout, m_delay );
|
popup->SetTimeoutAndShow( m_timeout, m_delay );
|
||||||
}
|
}
|
||||||
|
@@ -151,13 +151,13 @@ public:
|
|||||||
wxRichToolTipGenericImpl::SetTitleFont(font);
|
wxRichToolTipGenericImpl::SetTitleFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void ShowFor(wxWindow* win)
|
virtual void ShowFor(wxWindow* win, wxRect* rect = NULL);
|
||||||
{
|
{
|
||||||
// TODO: We could use native tooltip control to show native balloon
|
// TODO: We could use native tooltip control to show native balloon
|
||||||
// tooltips for any window but right now we use the simple
|
// tooltips for any window but right now we use the simple
|
||||||
// EM_SHOWBALLOONTIP API which can only be used with text
|
// EM_SHOWBALLOONTIP API which can only be used with text
|
||||||
// controls.
|
// controls.
|
||||||
if ( m_canUseNative )
|
if ( m_canUseNative && !rect )
|
||||||
{
|
{
|
||||||
wxTextCtrl* const text = wxDynamicCast(win, wxTextCtrl);
|
wxTextCtrl* const text = wxDynamicCast(win, wxTextCtrl);
|
||||||
if ( text )
|
if ( text )
|
||||||
@@ -175,7 +175,7 @@ public:
|
|||||||
// Don't set m_canUseNative to false here, we could be able to use the
|
// Don't set m_canUseNative to false here, we could be able to use the
|
||||||
// native tooltips if we're called for a different window the next
|
// native tooltips if we're called for a different window the next
|
||||||
// time.
|
// time.
|
||||||
wxRichToolTipGenericImpl::ShowFor(win);
|
wxRichToolTipGenericImpl::ShowFor(win, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user