]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/tooltip.cpp
warnings suppressed
[wxWidgets.git] / src / gtk / tooltip.cpp
CommitLineData
90b1b133
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: tooltip.cpp
ff8bfdbb 3// Purpose: wxToolTip implementation
90b1b133
RR
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
ff8bfdbb 7// Licence: wxWindows licence
90b1b133
RR
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
ff8bfdbb 11 #pragma implementation "tooltip.h"
90b1b133
RR
12#endif
13
a9d6a93c 14#include "wx/setup.h"
cad880f5
RR
15
16#if wxUSE_TOOLTIPS
f7f1f70f 17
ff8bfdbb 18#include "wx/window.h"
90b1b133
RR
19#include "wx/tooltip.h"
20
21#include "gtk/gtk.h"
22#include "gdk/gdk.h"
23
301cd871
RR
24//-----------------------------------------------------------------------------
25// global data
26//-----------------------------------------------------------------------------
27
28static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
29static GdkColor ss_bg;
30static GdkColor ss_fg;
ff8bfdbb 31
90b1b133 32//-----------------------------------------------------------------------------
b1170810 33// wxToolTip
90b1b133
RR
34//-----------------------------------------------------------------------------
35
b1170810
RR
36wxToolTip::wxToolTip( const wxString &tip )
37{
38 m_text = tip;
301cd871 39 m_window = (wxWindow*) NULL;
b1170810 40}
90b1b133 41
301cd871 42void wxToolTip::SetTip( const wxString &tip )
b1170810 43{
301cd871
RR
44 m_text = tip;
45 Apply( m_window );
46}
47
48void wxToolTip::Apply( wxWindow *win )
49{
50 if (!win) return;
51
52 if (!ss_tooltips)
90b1b133 53 {
301cd871 54 ss_tooltips = gtk_tooltips_new();
ff8bfdbb
VZ
55
56 ss_fg.red = 0;
301cd871
RR
57 ss_fg.green = 0;
58 ss_fg.blue = 0;
59 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
ff8bfdbb 60
301cd871
RR
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 );
ff8bfdbb
VZ
65
66 gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg );
90b1b133 67 }
ff8bfdbb 68
301cd871 69 m_window = win;
ff8bfdbb 70
301cd871
RR
71 if (m_text.IsEmpty())
72 m_window->ApplyToolTip( ss_tooltips, (char*) NULL );
73 else
74 m_window->ApplyToolTip( ss_tooltips, m_text );
90b1b133
RR
75}
76
77void wxToolTip::Enable( bool flag )
78{
301cd871 79 if (!ss_tooltips) return;
ff8bfdbb 80
90b1b133 81 if (flag)
301cd871 82 gtk_tooltips_enable( ss_tooltips );
90b1b133 83 else
301cd871 84 gtk_tooltips_disable( ss_tooltips );
90b1b133
RR
85}
86
87void wxToolTip::SetDelay( long msecs )
88{
301cd871 89 if (!ss_tooltips) return;
ff8bfdbb 90
301cd871 91 gtk_tooltips_set_delay( ss_tooltips, msecs );
90b1b133 92}
f7f1f70f 93#endif
90b1b133 94