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