]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/tooltip.cpp
adapting to init pattern
[wxWidgets.git] / src / gtk / tooltip.cpp
CommitLineData
90b1b133 1/////////////////////////////////////////////////////////////////////////////
9b5f1895 2// Name: src/gtk/tooltip.cpp
ff8bfdbb 3// Purpose: wxToolTip implementation
90b1b133
RR
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
90b1b133
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
cad880f5 13#if wxUSE_TOOLTIPS
f7f1f70f 14
90b1b133 15#include "wx/tooltip.h"
cdccdfab
WS
16
17#ifndef WX_PRECOMP
18 #include "wx/window.h"
19#endif
90b1b133 20
9e691f46 21#include "wx/gtk/private.h"
90b1b133 22
301cd871
RR
23//-----------------------------------------------------------------------------
24// global data
25//-----------------------------------------------------------------------------
26
385e8575 27#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
d3b9f782 28static GtkTooltips *gs_tooltips = NULL;
385e8575 29#endif
ff8bfdbb 30
90b1b133 31//-----------------------------------------------------------------------------
b1170810 32// wxToolTip
90b1b133
RR
33//-----------------------------------------------------------------------------
34
b342f8f0
RD
35IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
36
b1170810 37wxToolTip::wxToolTip( const wxString &tip )
558a94bd 38 : m_text(tip)
b1170810 39{
d3b9f782 40 m_window = NULL;
b1170810 41}
90b1b133 42
301cd871 43void wxToolTip::SetTip( const wxString &tip )
b1170810 44{
301cd871 45 m_text = tip;
558a94bd
PC
46 if (m_window)
47 m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
301cd871
RR
48}
49
558a94bd 50void wxToolTip::GTKSetWindow(wxWindow* win)
301cd871 51{
558a94bd 52 wxASSERT(win);
301cd871 53 m_window = win;
558a94bd 54 m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
90b1b133
RR
55}
56
f7ce0e4a 57/* static */
558a94bd 58void wxToolTip::GTKApply(GtkWidget* widget, const char* tip)
f7ce0e4a 59{
85314957 60#if GTK_CHECK_VERSION(2, 12, 0)
385e8575 61 if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
558a94bd 62 gtk_widget_set_tooltip_text(widget, tip);
85314957
VZ
63 else
64#endif
65 {
385e8575 66#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
85314957
VZ
67 if ( !gs_tooltips )
68 gs_tooltips = gtk_tooltips_new();
f7ce0e4a 69
558a94bd 70 gtk_tooltips_set_tip(gs_tooltips, widget, tip, NULL);
385e8575 71#endif
85314957 72 }
f7ce0e4a
VZ
73}
74
90b1b133
RR
75void wxToolTip::Enable( bool flag )
76{
85314957 77#if GTK_CHECK_VERSION(2, 12, 0)
385e8575 78 if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
85314957
VZ
79 {
80 GtkSettings* settings = gtk_settings_get_default();
558a94bd
PC
81 if (settings)
82 gtk_settings_set_long_property(settings, "gtk-enable-tooltips", flag, NULL);
85314957 83 }
90b1b133 84 else
85314957
VZ
85#endif
86 {
385e8575 87#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
85314957 88 if (!gs_tooltips)
558a94bd 89 gs_tooltips = gtk_tooltips_new();
85314957
VZ
90
91 if (flag)
92 gtk_tooltips_enable( gs_tooltips );
93 else
94 gtk_tooltips_disable( gs_tooltips );
385e8575 95#endif
85314957 96 }
90b1b133
RR
97}
98
99void wxToolTip::SetDelay( long msecs )
100{
85314957 101#if GTK_CHECK_VERSION(2, 12, 0)
385e8575 102 if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
85314957
VZ
103 {
104 GtkSettings* settings = gtk_settings_get_default();
558a94bd
PC
105 if (settings)
106 gtk_settings_set_long_property(settings, "gtk-tooltip-timeout", msecs, NULL);
85314957
VZ
107 }
108 else
109#endif
110 {
385e8575 111#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
85314957 112 if (!gs_tooltips)
558a94bd 113 gs_tooltips = gtk_tooltips_new();
85314957 114
85314957 115 gtk_tooltips_set_delay( gs_tooltips, (int)msecs );
385e8575 116#endif
85314957 117 }
90b1b133 118}
dcf924a3 119
becac1ef
VZ
120void wxToolTip::SetAutoPop( long WXUNUSED(msecs) )
121{
122}
123
124void wxToolTip::SetReshow( long WXUNUSED(msecs) )
125{
126}
127
cdccdfab 128#endif // wxUSE_TOOLTIPS