Added wxRichToolTip class.
It can be used to show more customizable tooltips than the native wxToolTip but at the price of using generic implementation in some cases (actually almost always now, with the exceptions of text control tooltips under MSW). Extra features include: - The balloon-like tooltip form. - Possibility to show an icon. - Title display in a different form. More customization could be added later. It should be also possible to fully implement this class natively under MSW. Update the dialogs sample to show the rich tooltips in action. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -976,6 +976,14 @@
|
||||
# endif
|
||||
#endif /* !defined(wxUSE_RICHMSGDLG) */
|
||||
|
||||
#ifndef wxUSE_RICHTOOLTIP
|
||||
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||
# error "wxUSE_RICHTOOLTIP must be defined, please read comment near the top of this file."
|
||||
# else
|
||||
# define wxUSE_RICHTOOLTIP 0
|
||||
# endif
|
||||
#endif /* !defined(wxUSE_RICHTOOLTIP) */
|
||||
|
||||
#ifndef wxUSE_SASH
|
||||
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||
# error "wxUSE_SASH must be defined, please read comment near the top of this file."
|
||||
|
59
include/wx/generic/private/richtooltip.h
Normal file
59
include/wx/generic/private/richtooltip.h
Normal file
@@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/generic/private/richtooltip.h
|
||||
// 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 $
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_
|
||||
#define _GENERIC_PRIVATE_RICHTOOLTIP_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxRichToolTipGenericImpl: defines generic wxRichToolTip implementation.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxRichToolTipGenericImpl : public wxRichToolTipImpl
|
||||
{
|
||||
public:
|
||||
wxRichToolTipGenericImpl(const wxString& title, const wxString& message) :
|
||||
m_title(title),
|
||||
m_message(message)
|
||||
{
|
||||
m_tipKind = wxTipKind_Auto;
|
||||
|
||||
// This is pretty arbitrary, we could follow MSW and use some multiple
|
||||
// of double-click time here.
|
||||
m_timeout = 5000;
|
||||
}
|
||||
|
||||
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 SetTipKind(wxTipKind tipKind);
|
||||
virtual void SetTitleFont(const wxFont& font);
|
||||
|
||||
virtual void ShowFor(wxWindow* win);
|
||||
|
||||
protected:
|
||||
wxString m_title,
|
||||
m_message;
|
||||
|
||||
private:
|
||||
wxIcon m_icon;
|
||||
|
||||
wxColour m_colStart,
|
||||
m_colEnd;
|
||||
|
||||
unsigned m_timeout;
|
||||
|
||||
wxTipKind m_tipKind;
|
||||
|
||||
wxFont m_titleFont;
|
||||
};
|
||||
|
||||
#endif // _WX_GENERIC_PRIVATE_RICHTOOLTIP_H_
|
@@ -1087,6 +1087,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
@@ -1087,6 +1087,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
@@ -1087,6 +1087,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
@@ -1087,6 +1087,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
@@ -81,9 +81,8 @@ public:
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
virtual bool SetShape(const wxRegion& region);
|
||||
// These accessors are Mac-specific and don't exist in other ports.
|
||||
const wxRegion& GetShape() const { return m_shape; }
|
||||
|
||||
#if wxUSE_GRAPHICS_CONTEXT
|
||||
const wxGraphicsPath& GetShapePath() { return m_shapePath; }
|
||||
#endif // wxUSE_GRAPHICS_CONTEXT
|
||||
|
@@ -1088,6 +1088,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
@@ -1087,6 +1087,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
44
include/wx/private/richtooltip.h
Normal file
44
include/wx/private/richtooltip.h
Normal file
@@ -0,0 +1,44 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/richtooltip.h
|
||||
// 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 $
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_RICHTOOLTIP_H_
|
||||
#define _WX_PRIVATE_RICHTOOLTIP_H_
|
||||
|
||||
#include "wx/richtooltip.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxRichToolTipImpl: defines wxRichToolTip implementation.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxRichToolTipImpl
|
||||
{
|
||||
public:
|
||||
// This is implemented in a platform-specific way.
|
||||
static wxRichToolTipImpl* Create(const wxString& title,
|
||||
const wxString& message);
|
||||
|
||||
// These methods simply mirror the public wxRichToolTip ones.
|
||||
virtual void SetBackgroundColour(const wxColour& col,
|
||||
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 SetTipKind(wxTipKind tipKind) = 0;
|
||||
virtual void SetTitleFont(const wxFont& font) = 0;
|
||||
|
||||
virtual void ShowFor(wxWindow* win) = 0;
|
||||
|
||||
virtual ~wxRichToolTipImpl() { }
|
||||
|
||||
protected:
|
||||
wxRichToolTipImpl() { }
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_RICHTOOLTIP_H_
|
99
include/wx/richtooltip.h
Normal file
99
include/wx/richtooltip.h
Normal file
@@ -0,0 +1,99 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/richtooltip.h
|
||||
// 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 $
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_RICHTOOLTIP_H_
|
||||
#define _WX_RICHTOOLTIP_H_
|
||||
|
||||
#if wxUSE_RICHTOOLTIP
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxColour;
|
||||
class WXDLLIMPEXP_FWD_CORE wxFont;
|
||||
class WXDLLIMPEXP_FWD_CORE wxIcon;
|
||||
|
||||
class wxRichToolTipImpl;
|
||||
|
||||
// This enum describes the kind of the tip shown which combines both the tip
|
||||
// position and appearance because the two are related (when the tip is
|
||||
// positioned asymmetrically, a right handed triangle is used but an
|
||||
// equilateral one when it's in the middle of a side).
|
||||
//
|
||||
// Automatic selects the tip appearance best suited for the current platform
|
||||
// and the position best suited for the window the tooltip is shown for, i.e.
|
||||
// chosen in such a way that the tooltip is always fully on screen.
|
||||
//
|
||||
// Other values describe the position of the tooltip itself, not the window it
|
||||
// relates to. E.g. wxTipKind_Top places the tip on the top of the tooltip and
|
||||
// so the tooltip itself is located beneath its associated window.
|
||||
enum wxTipKind
|
||||
{
|
||||
wxTipKind_None,
|
||||
wxTipKind_TopLeft,
|
||||
wxTipKind_Top,
|
||||
wxTipKind_TopRight,
|
||||
wxTipKind_BottomLeft,
|
||||
wxTipKind_Bottom,
|
||||
wxTipKind_BottomRight,
|
||||
wxTipKind_Auto
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxRichToolTip: a customizable but not necessarily native tooltip.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Notice that this class does not inherit from wxWindow.
|
||||
class WXDLLIMPEXP_ADV wxRichToolTip
|
||||
{
|
||||
public:
|
||||
// Ctor must specify the tooltip title and main message, additional
|
||||
// attributes can be set later.
|
||||
wxRichToolTip(const wxString& title, const wxString& message);
|
||||
|
||||
// Set the background colour: if two colours are specified, the background
|
||||
// is drawn using a gradient from top to bottom, otherwise a single solid
|
||||
// colour is used.
|
||||
void SetBackgroundColour(const wxColour& col,
|
||||
const wxColour& colEnd = wxColour());
|
||||
|
||||
// Set the small icon to show: either one of the standard information/
|
||||
// warning/error ones (the question icon doesn't make sense for a tooltip)
|
||||
// or a custom icon.
|
||||
void SetIcon(int icon = wxICON_INFORMATION);
|
||||
void SetIcon(const wxIcon& icon);
|
||||
|
||||
// Set timeout after which the tooltip should disappear, 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 can result in native version not being used).
|
||||
void SetTimeout(unsigned milliseconds);
|
||||
|
||||
// Choose the tip kind, possibly none. By default the tip is positioned
|
||||
// automatically, as if wxTipKind_Auto was used.
|
||||
void SetTipKind(wxTipKind tipKind);
|
||||
|
||||
// Set the title text font. By default it's emphasized using the font style
|
||||
// or colour appropriate for the current platform.
|
||||
void SetTitleFont(const wxFont& font);
|
||||
|
||||
// Show the tooltip for the given window.
|
||||
void ShowFor(wxWindow* win);
|
||||
|
||||
// Non-virtual dtor as this class is not supposed to be derived from.
|
||||
~wxRichToolTip();
|
||||
|
||||
private:
|
||||
wxRichToolTipImpl* const m_impl;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxRichToolTip);
|
||||
};
|
||||
|
||||
#endif // wxUSE_RICHTOOLTIP
|
||||
|
||||
#endif // _WX_RICHTOOLTIP_H_
|
@@ -1083,6 +1083,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
@@ -1086,6 +1086,14 @@
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_NOTIFICATION_MESSAGE 1
|
||||
|
||||
// wxRichToolTip is a customizable tooltip class which has more functionality
|
||||
// than the stock (but native, unlike this class) wxToolTip.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
|
||||
#define wxUSE_RICHTOOLTIP 1
|
||||
|
||||
// Use wxSashWindow class.
|
||||
//
|
||||
// Default is 1.
|
||||
|
Reference in New Issue
Block a user