]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/tooltip.cpp
added new files which were generated by bakefile but were not in cvs for some reason
[wxWidgets.git] / src / gtk / tooltip.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #include "wx/setup.h"
14
15 #if wxUSE_TOOLTIPS
16
17 #include "wx/tooltip.h"
18 #include "wx/window.h"
19
20 #include "wx/gtk/private.h"
21
22 //-----------------------------------------------------------------------------
23 // global data
24 //-----------------------------------------------------------------------------
25
26 static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
27
28 //-----------------------------------------------------------------------------
29 // wxToolTip
30 //-----------------------------------------------------------------------------
31
32 IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
33
34 wxToolTip::wxToolTip( const wxString &tip )
35 {
36 m_text = tip;
37 m_window = (wxWindow*) NULL;
38 }
39
40 void wxToolTip::SetTip( const wxString &tip )
41 {
42 m_text = tip;
43 Apply( m_window );
44 }
45
46 void wxToolTip::Apply( wxWindow *win )
47 {
48 if (!win) return;
49
50 if (!ss_tooltips)
51 {
52 ss_tooltips = gtk_tooltips_new();
53 }
54
55 m_window = win;
56
57 if (m_text.IsEmpty())
58 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
59 else
60 m_window->ApplyToolTip( ss_tooltips, m_text );
61 }
62
63 void wxToolTip::Enable( bool flag )
64 {
65 if (!ss_tooltips) return;
66
67 if (flag)
68 gtk_tooltips_enable( ss_tooltips );
69 else
70 gtk_tooltips_disable( ss_tooltips );
71 }
72
73 void wxToolTip::SetDelay( long msecs )
74 {
75 if (!ss_tooltips)
76 return;
77
78 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
79 }
80
81 #endif
82