]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/tooltip.cpp
menu title is drawn in bold font and the commands from it are ignored
[wxWidgets.git] / src / gtk1 / 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/window.h"
15 #include "wx/tooltip.h"
16
17 #include "gtk/gtk.h"
18 #include "gdk/gdk.h"
19
20 //-----------------------------------------------------------------------------
21 // global data
22 //-----------------------------------------------------------------------------
23
24 static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
25 static GdkColor ss_bg;
26 static GdkColor ss_fg;
27
28 //-----------------------------------------------------------------------------
29 // wxToolTip
30 //-----------------------------------------------------------------------------
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 ss_fg.red = 0;
53 ss_fg.green = 0;
54 ss_fg.blue = 0;
55 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
56
57 ss_bg.red = 65535;
58 ss_bg.green = 65535;
59 ss_bg.blue = 50000;
60 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
61
62 gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
63 }
64
65 m_window = win;
66
67 if (m_text.IsEmpty())
68 m_window->ApplyToolTip( ss_tooltips, (char*) NULL );
69 else
70 m_window->ApplyToolTip( ss_tooltips, m_text );
71 }
72
73 void wxToolTip::Enable( bool flag )
74 {
75 if (!ss_tooltips) return;
76
77 if (flag)
78 gtk_tooltips_enable( ss_tooltips );
79 else
80 gtk_tooltips_disable( ss_tooltips );
81 }
82
83 void wxToolTip::SetDelay( long msecs )
84 {
85 if (!ss_tooltips) return;
86
87 gtk_tooltips_set_delay( ss_tooltips, msecs );
88 }
89