clean up wxGTK tooltip code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67298 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -82,11 +82,7 @@ public:
|
||||
|
||||
// implementation from now on
|
||||
|
||||
GtkWidget *GetConnectWidget();
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
void GTKApplyToolTip( GtkTooltips *tips, const gchar *tip );
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
virtual GtkWidget *GetConnectWidget();
|
||||
|
||||
struct _GtkTreeView *m_treeview;
|
||||
struct _GtkListStore *m_liststore;
|
||||
|
@@ -131,7 +131,7 @@ public:
|
||||
void GtkDisableEvents();
|
||||
void GtkEnableEvents();
|
||||
#if wxUSE_TOOLTIPS
|
||||
void GTKApplyToolTip( GtkTooltips *tips, const gchar *tip );
|
||||
virtual void GTKApplyToolTip(const char* tip);
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
wxRadioBoxButtonsInfoList m_buttonsInfo;
|
||||
|
@@ -7,10 +7,9 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __GTKTOOLTIPH__
|
||||
#define __GTKTOOLTIPH__
|
||||
#ifndef _WX_GTKTOOLTIP_H_
|
||||
#define _WX_GTKTOOLTIP_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/object.h"
|
||||
|
||||
@@ -18,7 +17,6 @@
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxToolTip;
|
||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -43,15 +41,10 @@ public:
|
||||
wxString GetTip() const { return m_text; }
|
||||
|
||||
wxWindow *GetWindow() const { return m_window; }
|
||||
bool IsOk() const { return m_window != NULL; }
|
||||
|
||||
|
||||
// this forwards back to wxWindow::GTKApplyToolTip()
|
||||
void GTKApply( wxWindow *win );
|
||||
|
||||
// this just sets the given tooltip for the specified widget
|
||||
// tip must be UTF-8 encoded
|
||||
static void GTKApply(GtkWidget *w, const gchar *tip);
|
||||
// Implementation
|
||||
void GTKSetWindow(wxWindow* win);
|
||||
static void GTKApply(GtkWidget* widget, const char* tip);
|
||||
|
||||
private:
|
||||
wxString m_text;
|
||||
@@ -60,4 +53,4 @@ private:
|
||||
DECLARE_ABSTRACT_CLASS(wxToolTip)
|
||||
};
|
||||
|
||||
#endif // __GTKTOOLTIPH__
|
||||
#endif // _WX_GTKTOOLTIP_H_
|
||||
|
@@ -218,7 +218,7 @@ public:
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
// applies tooltip to the widget (tip must be UTF-8 encoded)
|
||||
virtual void GTKApplyToolTip( GtkTooltips *tips, const gchar *tip );
|
||||
virtual void GTKApplyToolTip(const char* tip);
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
// Called when a window should delay showing itself
|
||||
|
@@ -841,23 +841,6 @@ int wxListBox::DoListHitTest(const wxPoint& point) const
|
||||
// helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
void wxListBox::GTKApplyToolTip( GtkTooltips *tips, const gchar *tip )
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
if (!gtk_check_version(2, 12, 0))
|
||||
{
|
||||
gtk_widget_set_tooltip_text(GTK_WIDGET( m_treeview ), tip);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// RN: Is this needed anymore?
|
||||
gtk_tooltips_set_tip( tips, GTK_WIDGET( m_treeview ), tip, NULL );
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
GtkWidget *wxListBox::GetConnectWidget()
|
||||
{
|
||||
// the correct widget for listbox events (such as mouse clicks for example)
|
||||
|
@@ -565,7 +565,7 @@ void wxRadioBox::GTKWidgetDoSetMnemonic(GtkWidget* w)
|
||||
}
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
void wxRadioBox::GTKApplyToolTip(GtkTooltips * WXUNUSED(tips), const gchar *tip)
|
||||
void wxRadioBox::GTKApplyToolTip(const char* tip)
|
||||
{
|
||||
// set this tooltip for all radiobuttons which don't have their own tips
|
||||
unsigned n = 0;
|
||||
|
@@ -33,48 +33,38 @@ static GtkTooltips *gs_tooltips = NULL;
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
|
||||
|
||||
wxToolTip::wxToolTip( const wxString &tip )
|
||||
: m_text(tip)
|
||||
{
|
||||
m_text = tip;
|
||||
m_window = NULL;
|
||||
}
|
||||
|
||||
void wxToolTip::SetTip( const wxString &tip )
|
||||
{
|
||||
m_text = tip;
|
||||
GTKApply( m_window );
|
||||
if (m_window)
|
||||
m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
|
||||
}
|
||||
|
||||
void wxToolTip::GTKApply( wxWindow *win )
|
||||
void wxToolTip::GTKSetWindow(wxWindow* win)
|
||||
{
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
if ( !gs_tooltips )
|
||||
gs_tooltips = gtk_tooltips_new();
|
||||
|
||||
wxASSERT(win);
|
||||
m_window = win;
|
||||
|
||||
if (m_text.empty())
|
||||
m_window->GTKApplyToolTip( gs_tooltips, NULL );
|
||||
else
|
||||
m_window->GTKApplyToolTip( gs_tooltips, wxGTK_CONV_SYS(m_text) );
|
||||
m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxToolTip::GTKApply(GtkWidget *w, const gchar *tip)
|
||||
void wxToolTip::GTKApply(GtkWidget* widget, const char* tip)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
if (!gtk_check_version(2, 12, 0))
|
||||
{
|
||||
gtk_widget_set_tooltip_text(w, tip);
|
||||
}
|
||||
gtk_widget_set_tooltip_text(widget, tip);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if ( !gs_tooltips )
|
||||
gs_tooltips = gtk_tooltips_new();
|
||||
|
||||
gtk_tooltips_set_tip(gs_tooltips, w, tip, NULL);
|
||||
gtk_tooltips_set_tip(gs_tooltips, widget, tip, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,15 +74,14 @@ void wxToolTip::Enable( bool flag )
|
||||
if (!gtk_check_version(2, 12, 0))
|
||||
{
|
||||
GtkSettings* settings = gtk_settings_get_default();
|
||||
if(!settings)
|
||||
return;
|
||||
gtk_settings_set_long_property(settings, "gtk-enable-tooltips", flag?TRUE:FALSE, NULL);
|
||||
if (settings)
|
||||
gtk_settings_set_long_property(settings, "gtk-enable-tooltips", flag, NULL);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (!gs_tooltips)
|
||||
return;
|
||||
gs_tooltips = gtk_tooltips_new();
|
||||
|
||||
if (flag)
|
||||
gtk_tooltips_enable( gs_tooltips );
|
||||
@@ -101,29 +90,21 @@ void wxToolTip::Enable( bool flag )
|
||||
}
|
||||
}
|
||||
|
||||
G_BEGIN_DECLS
|
||||
void gtk_tooltips_set_delay (GtkTooltips *tooltips,
|
||||
guint delay);
|
||||
G_END_DECLS
|
||||
|
||||
void wxToolTip::SetDelay( long msecs )
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
if (!gtk_check_version(2, 12, 0))
|
||||
{
|
||||
GtkSettings* settings = gtk_settings_get_default();
|
||||
if(!settings)
|
||||
return;
|
||||
if (settings)
|
||||
gtk_settings_set_long_property(settings, "gtk-tooltip-timeout", msecs, NULL);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (!gs_tooltips)
|
||||
return;
|
||||
gs_tooltips = gtk_tooltips_new();
|
||||
|
||||
// FIXME: This is a deprecated function and might not even have an effect.
|
||||
// Try to not use it, after which remove the prototype above.
|
||||
gtk_tooltips_set_delay( gs_tooltips, (int)msecs );
|
||||
}
|
||||
}
|
||||
|
@@ -3777,34 +3777,21 @@ void wxWindowGTK::ClearBackground()
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
void wxWindowGTK::DoSetToolTip( wxToolTip *tip )
|
||||
{
|
||||
if (m_tooltip != tip)
|
||||
{
|
||||
wxWindowBase::DoSetToolTip(tip);
|
||||
|
||||
if (m_tooltip)
|
||||
{
|
||||
m_tooltip->GTKApply( (wxWindow *)this );
|
||||
}
|
||||
m_tooltip->GTKSetWindow(static_cast<wxWindow*>(this));
|
||||
else
|
||||
{
|
||||
GtkWidget *w = GetConnectWidget();
|
||||
wxToolTip::GTKApply(w, NULL);
|
||||
GTKApplyToolTip(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindowGTK::GTKApplyToolTip( GtkTooltips *tips, const gchar *tip )
|
||||
void wxWindowGTK::GTKApplyToolTip(const char* tip)
|
||||
{
|
||||
GtkWidget *w = GetConnectWidget();
|
||||
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
if (!gtk_check_version(2, 12, 0))
|
||||
{
|
||||
gtk_widget_set_tooltip_text (w, tip);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
gtk_tooltips_set_tip(tips, w, tip, NULL);
|
||||
}
|
||||
wxToolTip::GTKApply(GetConnectWidget(), tip);
|
||||
}
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
|
Reference in New Issue
Block a user