]>
Commit | Line | Data |
---|---|---|
90b1b133 | 1 | ///////////////////////////////////////////////////////////////////////////// |
9b5f1895 | 2 | // Name: src/gtk1/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" |
e1bf3ad3 | 16 | #include "wx/window.h" |
90b1b133 | 17 | |
3cbab641 | 18 | #include "wx/gtk1/private.h" |
90b1b133 | 19 | |
301cd871 RR |
20 | //----------------------------------------------------------------------------- |
21 | // global data | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
24 | static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL; | |
ff8bfdbb | 25 | |
90b1b133 | 26 | //----------------------------------------------------------------------------- |
b1170810 | 27 | // wxToolTip |
90b1b133 RR |
28 | //----------------------------------------------------------------------------- |
29 | ||
b342f8f0 RD |
30 | IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject) |
31 | ||
b1170810 RR |
32 | wxToolTip::wxToolTip( const wxString &tip ) |
33 | { | |
34 | m_text = tip; | |
301cd871 | 35 | m_window = (wxWindow*) NULL; |
b1170810 | 36 | } |
90b1b133 | 37 | |
301cd871 | 38 | void wxToolTip::SetTip( const wxString &tip ) |
b1170810 | 39 | { |
301cd871 RR |
40 | m_text = tip; |
41 | Apply( m_window ); | |
42 | } | |
43 | ||
44 | void wxToolTip::Apply( wxWindow *win ) | |
45 | { | |
46 | if (!win) return; | |
47 | ||
48 | if (!ss_tooltips) | |
90b1b133 | 49 | { |
301cd871 | 50 | ss_tooltips = gtk_tooltips_new(); |
90b1b133 | 51 | } |
ff8bfdbb | 52 | |
301cd871 | 53 | m_window = win; |
ff8bfdbb | 54 | |
301cd871 | 55 | if (m_text.IsEmpty()) |
05939a81 | 56 | m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL ); |
301cd871 RR |
57 | else |
58 | m_window->ApplyToolTip( ss_tooltips, m_text ); | |
90b1b133 RR |
59 | } |
60 | ||
61 | void wxToolTip::Enable( bool flag ) | |
62 | { | |
301cd871 | 63 | if (!ss_tooltips) return; |
ff8bfdbb | 64 | |
90b1b133 | 65 | if (flag) |
301cd871 | 66 | gtk_tooltips_enable( ss_tooltips ); |
90b1b133 | 67 | else |
301cd871 | 68 | gtk_tooltips_disable( ss_tooltips ); |
90b1b133 RR |
69 | } |
70 | ||
71 | void wxToolTip::SetDelay( long msecs ) | |
72 | { | |
b02da6b1 VZ |
73 | if (!ss_tooltips) |
74 | return; | |
ff8bfdbb | 75 | |
b02da6b1 | 76 | gtk_tooltips_set_delay( ss_tooltips, (int)msecs ); |
90b1b133 | 77 | } |
dcf924a3 | 78 | |
f7f1f70f | 79 | #endif |