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