// 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;
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;
// 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"
// forward declarations
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_FWD_CORE wxToolTip;
class WXDLLIMPEXP_FWD_CORE wxWindow;
//-----------------------------------------------------------------------------
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;
DECLARE_ABSTRACT_CLASS(wxToolTip)
};
-#endif // __GTKTOOLTIPH__
+#endif // _WX_GTKTOOLTIP_H_
#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
// 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)
}
#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;
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);
}
}
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 );
}
}
-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;
- gtk_settings_set_long_property(settings, "gtk-tooltip-timeout", msecs, NULL);
+ 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 );
}
}
#if wxUSE_TOOLTIPS
void wxWindowGTK::DoSetToolTip( wxToolTip *tip )
{
- wxWindowBase::DoSetToolTip(tip);
-
- if (m_tooltip)
- {
- m_tooltip->GTKApply( (wxWindow *)this );
- }
- else
+ if (m_tooltip != tip)
{
- GtkWidget *w = GetConnectWidget();
- wxToolTip::GTKApply(w, NULL);
+ wxWindowBase::DoSetToolTip(tip);
+
+ if (m_tooltip)
+ m_tooltip->GTKSetWindow(static_cast<wxWindow*>(this));
+ else
+ 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