]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/tooltip.cpp
simplify/cleanup wxTheXXXList and wxGDIObject code (patch 1452023 from Paul Cornett)
[wxWidgets.git] / src / gtk1 / tooltip.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/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 #include "wx/window.h"
17
18 #include "wx/gtk1/private.h"
19
20 //-----------------------------------------------------------------------------
21 // global data
22 //-----------------------------------------------------------------------------
23
24 static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
25
26 //-----------------------------------------------------------------------------
27 // wxToolTip
28 //-----------------------------------------------------------------------------
29
30 IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
31
32 wxToolTip::wxToolTip( const wxString &tip )
33 {
34 m_text = tip;
35 m_window = (wxWindow*) NULL;
36 }
37
38 void wxToolTip::SetTip( const wxString &tip )
39 {
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)
49 {
50 ss_tooltips = gtk_tooltips_new();
51 }
52
53 m_window = win;
54
55 if (m_text.IsEmpty())
56 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
57 else
58 m_window->ApplyToolTip( ss_tooltips, m_text );
59 }
60
61 void wxToolTip::Enable( bool flag )
62 {
63 if (!ss_tooltips) return;
64
65 if (flag)
66 gtk_tooltips_enable( ss_tooltips );
67 else
68 gtk_tooltips_disable( ss_tooltips );
69 }
70
71 void wxToolTip::SetDelay( long msecs )
72 {
73 if (!ss_tooltips)
74 return;
75
76 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
77 }
78
79 #endif