]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/tooltip.cpp
44759110bfc0c378c24c95b2c768984740e40f5d
[wxWidgets.git] / src / gtk / tooltip.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tooltip.cpp
3 // Purpose:
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 #include "wx/tooltip.h"
15
16 #include "gtk/gtk.h"
17 #include "gdk/gdk.h"
18
19 //-----------------------------------------------------------------------------
20 // global data
21 //-----------------------------------------------------------------------------
22
23 static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
24 static GdkColor ss_bg;
25 static GdkColor ss_fg;
26
27 //-----------------------------------------------------------------------------
28 // wxToolTip
29 //-----------------------------------------------------------------------------
30
31 wxToolTip::wxToolTip( const wxString &tip )
32 {
33 m_text = tip;
34 m_window = (wxWindow*) NULL;
35 }
36
37 bool wxToolTip::Ok() const
38 {
39 return (m_window);
40 }
41
42 wxString wxToolTip::GetTip() const
43 {
44 return m_text;
45 }
46
47 void wxToolTip::SetTip( const wxString &tip )
48 {
49 m_text = tip;
50 Apply( m_window );
51 }
52
53 void wxToolTip::Apply( wxWindow *win )
54 {
55 if (!win) return;
56
57 if (!ss_tooltips)
58 {
59 ss_tooltips = gtk_tooltips_new();
60
61 ss_fg.red = 0;
62 ss_fg.green = 0;
63 ss_fg.blue = 0;
64 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
65
66 ss_bg.red = 65535;
67 ss_bg.green = 65535;
68 ss_bg.blue = 50000;
69 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
70
71 gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
72 }
73
74 m_window = win;
75
76 if (m_text.IsEmpty())
77 m_window->ApplyToolTip( ss_tooltips, (char*) NULL );
78 else
79 m_window->ApplyToolTip( ss_tooltips, m_text );
80 }
81
82 void wxToolTip::Enable( bool flag )
83 {
84 if (!ss_tooltips) return;
85
86 if (flag)
87 gtk_tooltips_enable( ss_tooltips );
88 else
89 gtk_tooltips_disable( ss_tooltips );
90 }
91
92 void wxToolTip::SetDelay( long msecs )
93 {
94 if (!ss_tooltips) return;
95
96 gtk_tooltips_set_delay( ss_tooltips, msecs );
97 }
98