]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/tooltip.cpp
fixed yet another memory leak in LoadGnomeDataFromKeyFile() (coverity checker CID 51)
[wxWidgets.git] / src / gtk / tooltip.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk/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// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#if wxUSE_TOOLTIPS
14
15#include "wx/tooltip.h"
16#include "wx/window.h"
17
18#include "wx/gtk/private.h"
19
20//-----------------------------------------------------------------------------
21// global data
22//-----------------------------------------------------------------------------
23
24static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
25
26//-----------------------------------------------------------------------------
27// wxToolTip
28//-----------------------------------------------------------------------------
29
30IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
31
32wxToolTip::wxToolTip( const wxString &tip )
33{
34 m_text = tip;
35 m_window = (wxWindow*) NULL;
36}
37
38void wxToolTip::SetTip( const wxString &tip )
39{
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)
49 {
50 ss_tooltips = gtk_tooltips_new();
51 }
52
53 m_window = win;
54
55 if (m_text.IsEmpty())
56 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
57 else
58 m_window->ApplyToolTip( ss_tooltips, m_text );
59}
60
61void wxToolTip::Enable( bool flag )
62{
63 if (!ss_tooltips) return;
64
65 if (flag)
66 gtk_tooltips_enable( ss_tooltips );
67 else
68 gtk_tooltips_disable( ss_tooltips );
69}
70
71G_BEGIN_DECLS
72void gtk_tooltips_set_delay (GtkTooltips *tooltips,
73 guint delay);
74G_END_DECLS
75
76void wxToolTip::SetDelay( long msecs )
77{
78 if (!ss_tooltips)
79 return;
80
81 // FIXME: This is a deprecated function and might not even have an effect.
82 // Try to not use it, after which remove the prototype above.
83 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
84}
85
86#endif