]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/tooltip.cpp
allow customization of individual grid lines appearance (patch 1496015)
[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 static GtkTooltips *gs_tooltips = (GtkTooltips*) NULL;
28
29 //-----------------------------------------------------------------------------
30 // wxToolTip
31 //-----------------------------------------------------------------------------
32
33 IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
34
35 wxToolTip::wxToolTip( const wxString &tip )
36 {
37 m_text = tip;
38 m_window = (wxWindow*) NULL;
39 }
40
41 void wxToolTip::SetTip( const wxString &tip )
42 {
43 m_text = tip;
44 Apply( m_window );
45 }
46
47 void wxToolTip::Apply( wxWindow *win )
48 {
49 if (!win)
50 return;
51
52 if ( !gs_tooltips )
53 gs_tooltips = gtk_tooltips_new();
54
55 m_window = win;
56
57 if (m_text.empty())
58 m_window->ApplyToolTip( gs_tooltips, (wxChar*) NULL );
59 else
60 m_window->ApplyToolTip( gs_tooltips, m_text );
61 }
62
63 /* static */
64 void wxToolTip::Apply(GtkWidget *w, const wxCharBuffer& tip)
65 {
66 if ( !gs_tooltips )
67 gs_tooltips = gtk_tooltips_new();
68
69 gtk_tooltips_set_tip(gs_tooltips, w, tip, NULL);
70 }
71
72 void wxToolTip::Enable( bool flag )
73 {
74 if (!gs_tooltips)
75 return;
76
77 if (flag)
78 gtk_tooltips_enable( gs_tooltips );
79 else
80 gtk_tooltips_disable( gs_tooltips );
81 }
82
83 G_BEGIN_DECLS
84 void gtk_tooltips_set_delay (GtkTooltips *tooltips,
85 guint delay);
86 G_END_DECLS
87
88 void wxToolTip::SetDelay( long msecs )
89 {
90 if (!gs_tooltips)
91 return;
92
93 // FIXME: This is a deprecated function and might not even have an effect.
94 // Try to not use it, after which remove the prototype above.
95 gtk_tooltips_set_delay( gs_tooltips, (int)msecs );
96 }
97
98 #endif // wxUSE_TOOLTIPS