]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/tooltip.cpp
give the panel 3D grey colour by default: as it's not a native control, we must give...
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "tooltip.h"
12 #endif
13
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
16
17 #include "wx/setup.h"
18
19 #if wxUSE_TOOLTIPS
20
21 #include "wx/window.h"
22 #include "wx/tooltip.h"
23
24 #include "wx/gtk/private.h"
25
26 extern GdkFont *GtkGetDefaultGuiFont();
27
28 //-----------------------------------------------------------------------------
29 // global data
30 //-----------------------------------------------------------------------------
31
32 static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
33 static GdkColor ss_bg;
34 static GdkColor ss_fg;
35
36 //-----------------------------------------------------------------------------
37 // wxToolTip
38 //-----------------------------------------------------------------------------
39
40 IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
41
42 wxToolTip::wxToolTip( const wxString &tip )
43 {
44 m_text = tip;
45 m_window = (wxWindow*) NULL;
46 }
47
48 void wxToolTip::SetTip( const wxString &tip )
49 {
50 m_text = tip;
51 Apply( m_window );
52 }
53
54 void wxToolTip::Apply( wxWindow *win )
55 {
56 if (!win) return;
57
58 if (!ss_tooltips)
59 {
60 ss_tooltips = gtk_tooltips_new();
61
62 ss_fg.red = 0;
63 ss_fg.green = 0;
64 ss_fg.blue = 0;
65 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
66
67 ss_bg.red = 65535;
68 ss_bg.green = 65535;
69 ss_bg.blue = 50000;
70 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
71
72 gtk_tooltips_force_window( ss_tooltips );
73
74 GtkStyle *g_style =
75 gtk_style_copy(
76 gtk_widget_get_style( ss_tooltips->tip_window ) );
77
78 g_style->fg[GTK_STATE_NORMAL] = ss_fg;
79 g_style->bg[GTK_STATE_NORMAL] = ss_bg;
80
81 gtk_widget_set_style( ss_tooltips->tip_window, g_style );
82 }
83
84 m_window = win;
85
86 if (m_text.IsEmpty())
87 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
88 else
89 m_window->ApplyToolTip( ss_tooltips, m_text );
90 }
91
92 void wxToolTip::Enable( bool flag )
93 {
94 if (!ss_tooltips) return;
95
96 if (flag)
97 gtk_tooltips_enable( ss_tooltips );
98 else
99 gtk_tooltips_disable( ss_tooltips );
100 }
101
102 void wxToolTip::SetDelay( long msecs )
103 {
104 if (!ss_tooltips)
105 return;
106
107 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
108 }
109
110 #endif
111