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