]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/tooltip.cpp
Added EVT_GRID_EDITOR_CREATED and wxGridEditorCreatedEvent so the user
[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/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 extern GdkFont *GtkGetDefaultGuiFont();
25
26 //-----------------------------------------------------------------------------
27 // global data
28 //-----------------------------------------------------------------------------
29
30 static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
31 static GdkColor ss_bg;
32 static GdkColor ss_fg;
33
34 //-----------------------------------------------------------------------------
35 // wxToolTip
36 //-----------------------------------------------------------------------------
37
38 wxToolTip::wxToolTip( const wxString &tip )
39 {
40 m_text = tip;
41 m_window = (wxWindow*) NULL;
42 }
43
44 void wxToolTip::SetTip( const wxString &tip )
45 {
46 m_text = tip;
47 Apply( m_window );
48 }
49
50 void wxToolTip::Apply( wxWindow *win )
51 {
52 if (!win) return;
53
54 if (!ss_tooltips)
55 {
56 ss_tooltips = gtk_tooltips_new();
57
58 ss_fg.red = 0;
59 ss_fg.green = 0;
60 ss_fg.blue = 0;
61 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
62
63 ss_bg.red = 65535;
64 ss_bg.green = 65535;
65 ss_bg.blue = 50000;
66 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
67
68 #if (GTK_MINOR_VERSION > 0)
69 gtk_tooltips_force_window( ss_tooltips );
70
71 GtkStyle *g_style =
72 gtk_style_copy(
73 gtk_widget_get_style( ss_tooltips->tip_window ) );
74
75 g_style->fg[GTK_STATE_NORMAL] = ss_fg;
76 g_style->bg[GTK_STATE_NORMAL] = ss_bg;
77 gdk_font_unref( g_style->font );
78 g_style->font = gdk_font_ref( GtkGetDefaultGuiFont() );
79
80 gtk_widget_set_style( ss_tooltips->tip_window, g_style );
81 #else
82 gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
83 #endif
84 }
85
86 m_window = win;
87
88 if (m_text.IsEmpty())
89 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
90 else
91 m_window->ApplyToolTip( ss_tooltips, m_text );
92 }
93
94 void wxToolTip::Enable( bool flag )
95 {
96 if (!ss_tooltips) return;
97
98 if (flag)
99 gtk_tooltips_enable( ss_tooltips );
100 else
101 gtk_tooltips_disable( ss_tooltips );
102 }
103
104 void wxToolTip::SetDelay( long msecs )
105 {
106 if (!ss_tooltips)
107 return;
108
109 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
110 }
111
112 #endif
113