]>
Commit | Line | Data |
---|---|---|
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 | ||
d3b9f782 | 27 | static GtkTooltips *gs_tooltips = NULL; |
ff8bfdbb | 28 | |
90b1b133 | 29 | //----------------------------------------------------------------------------- |
b1170810 | 30 | // wxToolTip |
90b1b133 RR |
31 | //----------------------------------------------------------------------------- |
32 | ||
b342f8f0 RD |
33 | IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject) |
34 | ||
b1170810 RR |
35 | wxToolTip::wxToolTip( const wxString &tip ) |
36 | { | |
37 | m_text = tip; | |
d3b9f782 | 38 | m_window = NULL; |
b1170810 | 39 | } |
90b1b133 | 40 | |
301cd871 | 41 | void wxToolTip::SetTip( const wxString &tip ) |
b1170810 | 42 | { |
301cd871 | 43 | m_text = tip; |
7fc8b9a4 | 44 | GTKApply( m_window ); |
301cd871 RR |
45 | } |
46 | ||
7fc8b9a4 | 47 | void wxToolTip::GTKApply( wxWindow *win ) |
301cd871 | 48 | { |
f7ce0e4a VZ |
49 | if (!win) |
50 | return; | |
301cd871 | 51 | |
f7ce0e4a | 52 | if ( !gs_tooltips ) |
6cae7af2 | 53 | gs_tooltips = gtk_tooltips_new(); |
ff8bfdbb | 54 | |
301cd871 | 55 | m_window = win; |
ff8bfdbb | 56 | |
cdccdfab | 57 | if (m_text.empty()) |
7fc8b9a4 | 58 | m_window->GTKApplyToolTip( gs_tooltips, NULL ); |
301cd871 | 59 | else |
7fc8b9a4 | 60 | m_window->GTKApplyToolTip( gs_tooltips, wxGTK_CONV_SYS(m_text) ); |
90b1b133 RR |
61 | } |
62 | ||
f7ce0e4a | 63 | /* static */ |
7fc8b9a4 | 64 | void wxToolTip::GTKApply(GtkWidget *w, const gchar *tip) |
f7ce0e4a | 65 | { |
85314957 VZ |
66 | #if GTK_CHECK_VERSION(2, 12, 0) |
67 | if (!gtk_check_version(2, 12, 0)) | |
68 | { | |
69 | gtk_widget_set_tooltip_text(w, tip); | |
70 | } | |
71 | else | |
72 | #endif | |
73 | { | |
74 | if ( !gs_tooltips ) | |
75 | gs_tooltips = gtk_tooltips_new(); | |
f7ce0e4a | 76 | |
85314957 VZ |
77 | gtk_tooltips_set_tip(gs_tooltips, w, tip, NULL); |
78 | } | |
f7ce0e4a VZ |
79 | } |
80 | ||
90b1b133 RR |
81 | void wxToolTip::Enable( bool flag ) |
82 | { | |
85314957 VZ |
83 | #if GTK_CHECK_VERSION(2, 12, 0) |
84 | if (!gtk_check_version(2, 12, 0)) | |
85 | { | |
86 | GtkSettings* settings = gtk_settings_get_default(); | |
87 | if(!settings) | |
88 | return; | |
89 | gtk_settings_set_long_property(settings, "gtk-enable-tooltips", flag?TRUE:FALSE, NULL); | |
90 | } | |
90b1b133 | 91 | else |
85314957 VZ |
92 | #endif |
93 | { | |
94 | if (!gs_tooltips) | |
95 | return; | |
96 | ||
97 | if (flag) | |
98 | gtk_tooltips_enable( gs_tooltips ); | |
99 | else | |
100 | gtk_tooltips_disable( gs_tooltips ); | |
101 | } | |
90b1b133 RR |
102 | } |
103 | ||
1efb5db8 MR |
104 | G_BEGIN_DECLS |
105 | void gtk_tooltips_set_delay (GtkTooltips *tooltips, | |
106 | guint delay); | |
107 | G_END_DECLS | |
108 | ||
90b1b133 RR |
109 | void wxToolTip::SetDelay( long msecs ) |
110 | { | |
85314957 VZ |
111 | #if GTK_CHECK_VERSION(2, 12, 0) |
112 | if (!gtk_check_version(2, 12, 0)) | |
113 | { | |
114 | GtkSettings* settings = gtk_settings_get_default(); | |
115 | if(!settings) | |
116 | return; | |
117 | gtk_settings_set_long_property(settings, "gtk-tooltip-timeout", msecs, NULL); | |
118 | } | |
119 | else | |
120 | #endif | |
121 | { | |
122 | if (!gs_tooltips) | |
123 | return; | |
124 | ||
125 | // FIXME: This is a deprecated function and might not even have an effect. | |
126 | // Try to not use it, after which remove the prototype above. | |
127 | gtk_tooltips_set_delay( gs_tooltips, (int)msecs ); | |
128 | } | |
90b1b133 | 129 | } |
dcf924a3 | 130 | |
becac1ef VZ |
131 | void wxToolTip::SetAutoPop( long WXUNUSED(msecs) ) |
132 | { | |
133 | } | |
134 | ||
135 | void wxToolTip::SetReshow( long WXUNUSED(msecs) ) | |
136 | { | |
137 | } | |
138 | ||
cdccdfab | 139 | #endif // wxUSE_TOOLTIPS |