compilation fixes
[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 #ifdef __GNUG__
11 #pragma implementation "tooltip.h"
12 #endif
13
14 #ifdef wxUSE_TOOLTIPS
15
16 #include "wx/window.h"
17 #include "wx/tooltip.h"
18
19 #include "gtk/gtk.h"
20 #include "gdk/gdk.h"
21
22 //-----------------------------------------------------------------------------
23 // global data
24 //-----------------------------------------------------------------------------
25
26 static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
27 static GdkColor ss_bg;
28 static GdkColor ss_fg;
29
30 //-----------------------------------------------------------------------------
31 // wxToolTip
32 //-----------------------------------------------------------------------------
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 ss_fg.red = 0;
55 ss_fg.green = 0;
56 ss_fg.blue = 0;
57 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
58
59 ss_bg.red = 65535;
60 ss_bg.green = 65535;
61 ss_bg.blue = 50000;
62 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
63
64 gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
65 }
66
67 m_window = win;
68
69 if (m_text.IsEmpty())
70 m_window->ApplyToolTip( ss_tooltips, (char*) NULL );
71 else
72 m_window->ApplyToolTip( ss_tooltips, m_text );
73 }
74
75 void wxToolTip::Enable( bool flag )
76 {
77 if (!ss_tooltips) return;
78
79 if (flag)
80 gtk_tooltips_enable( ss_tooltips );
81 else
82 gtk_tooltips_disable( ss_tooltips );
83 }
84
85 void wxToolTip::SetDelay( long msecs )
86 {
87 if (!ss_tooltips) return;
88
89 gtk_tooltips_set_delay( ss_tooltips, msecs );
90 }
91 #endif
92