]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/tooltip.cpp
add missing ! accidentally dropped in last commit
[wxWidgets.git] / src / gtk / tooltip.cpp
CommitLineData
90b1b133 1/////////////////////////////////////////////////////////////////////////////
9b5f1895 2// Name: src/gtk/tooltip.cpp
ff8bfdbb 3// Purpose: wxToolTip implementation
90b1b133
RR
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
90b1b133
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
cad880f5 13#if wxUSE_TOOLTIPS
f7f1f70f 14
90b1b133 15#include "wx/tooltip.h"
cdccdfab
WS
16
17#ifndef WX_PRECOMP
18 #include "wx/window.h"
19#endif
90b1b133 20
9e691f46 21#include "wx/gtk/private.h"
90b1b133 22
301cd871
RR
23//-----------------------------------------------------------------------------
24// global data
25//-----------------------------------------------------------------------------
26
6cae7af2 27static GtkTooltips *gs_tooltips = (GtkTooltips*) NULL;
ff8bfdbb 28
90b1b133 29//-----------------------------------------------------------------------------
b1170810 30// wxToolTip
90b1b133
RR
31//-----------------------------------------------------------------------------
32
b342f8f0
RD
33IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
34
b1170810
RR
35wxToolTip::wxToolTip( const wxString &tip )
36{
37 m_text = tip;
301cd871 38 m_window = (wxWindow*) NULL;
b1170810 39}
90b1b133 40
301cd871 41void wxToolTip::SetTip( const wxString &tip )
b1170810 42{
301cd871
RR
43 m_text = tip;
44 Apply( m_window );
45}
46
47void wxToolTip::Apply( wxWindow *win )
48{
f7ce0e4a
VZ
49 if (!win)
50 return;
301cd871 51
f7ce0e4a 52 if ( !gs_tooltips )
6cae7af2 53 gs_tooltips = gtk_tooltips_new();
ff8bfdbb 54
301cd871 55 m_window = win;
ff8bfdbb 56
cdccdfab 57 if (m_text.empty())
6e5f6c7c 58 m_window->ApplyToolTip( gs_tooltips, NULL );
301cd871 59 else
6e5f6c7c 60 m_window->ApplyToolTip( gs_tooltips, wxGTK_CONV_SYS(m_text) );
90b1b133
RR
61}
62
f7ce0e4a 63/* static */
6e5f6c7c 64void wxToolTip::Apply(GtkWidget *w, const gchar *tip)
f7ce0e4a
VZ
65{
66 if ( !gs_tooltips )
67 gs_tooltips = gtk_tooltips_new();
68
69 gtk_tooltips_set_tip(gs_tooltips, w, tip, NULL);
70}
71
90b1b133
RR
72void wxToolTip::Enable( bool flag )
73{
f7ce0e4a
VZ
74 if (!gs_tooltips)
75 return;
ff8bfdbb 76
90b1b133 77 if (flag)
6cae7af2 78 gtk_tooltips_enable( gs_tooltips );
90b1b133 79 else
6cae7af2 80 gtk_tooltips_disable( gs_tooltips );
90b1b133
RR
81}
82
1efb5db8
MR
83G_BEGIN_DECLS
84void gtk_tooltips_set_delay (GtkTooltips *tooltips,
85 guint delay);
86G_END_DECLS
87
90b1b133
RR
88void wxToolTip::SetDelay( long msecs )
89{
6cae7af2 90 if (!gs_tooltips)
b02da6b1 91 return;
ff8bfdbb 92
1efb5db8
MR
93 // FIXME: This is a deprecated function and might not even have an effect.
94 // Try to not use it, after which remove the prototype above.
6cae7af2 95 gtk_tooltips_set_delay( gs_tooltips, (int)msecs );
90b1b133 96}
dcf924a3 97
becac1ef
VZ
98void wxToolTip::SetAutoPop( long WXUNUSED(msecs) )
99{
100}
101
102void wxToolTip::SetReshow( long WXUNUSED(msecs) )
103{
104}
105
cdccdfab 106#endif // wxUSE_TOOLTIPS