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