]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/tooltip.cpp
24 bit depth
[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
65571936 7// Licence: wxWindows licence
90b1b133
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
ff8bfdbb 11 #pragma implementation "tooltip.h"
90b1b133
RR
12#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
a9d6a93c 17#include "wx/setup.h"
cad880f5
RR
18
19#if wxUSE_TOOLTIPS
f7f1f70f 20
90b1b133 21#include "wx/tooltip.h"
e1bf3ad3 22#include "wx/window.h"
90b1b133 23
9e691f46 24#include "wx/gtk/private.h"
90b1b133 25
301cd871
RR
26//-----------------------------------------------------------------------------
27// global data
28//-----------------------------------------------------------------------------
29
30static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
ff8bfdbb 31
90b1b133 32//-----------------------------------------------------------------------------
b1170810 33// wxToolTip
90b1b133
RR
34//-----------------------------------------------------------------------------
35
b342f8f0
RD
36IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
37
b1170810
RR
38wxToolTip::wxToolTip( const wxString &tip )
39{
40 m_text = tip;
301cd871 41 m_window = (wxWindow*) NULL;
b1170810 42}
90b1b133 43
301cd871 44void wxToolTip::SetTip( const wxString &tip )
b1170810 45{
301cd871
RR
46 m_text = tip;
47 Apply( m_window );
48}
49
50void wxToolTip::Apply( wxWindow *win )
51{
52 if (!win) return;
53
54 if (!ss_tooltips)
90b1b133 55 {
301cd871 56 ss_tooltips = gtk_tooltips_new();
90b1b133 57 }
ff8bfdbb 58
301cd871 59 m_window = win;
ff8bfdbb 60
301cd871 61 if (m_text.IsEmpty())
05939a81 62 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
301cd871
RR
63 else
64 m_window->ApplyToolTip( ss_tooltips, m_text );
90b1b133
RR
65}
66
67void wxToolTip::Enable( bool flag )
68{
301cd871 69 if (!ss_tooltips) return;
ff8bfdbb 70
90b1b133 71 if (flag)
301cd871 72 gtk_tooltips_enable( ss_tooltips );
90b1b133 73 else
301cd871 74 gtk_tooltips_disable( ss_tooltips );
90b1b133
RR
75}
76
77void wxToolTip::SetDelay( long msecs )
78{
b02da6b1
VZ
79 if (!ss_tooltips)
80 return;
ff8bfdbb 81
b02da6b1 82 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
90b1b133 83}
dcf924a3 84
f7f1f70f 85#endif
90b1b133 86