]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/tooltip.cpp
Optimized sizers to not call CalcMin more often than neccessary
[wxWidgets.git] / src / gtk / tooltip.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "tooltip.h"
12#endif
13
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
17#include "wx/setup.h"
18
19#if wxUSE_TOOLTIPS
20
21#include "wx/window.h"
22#include "wx/tooltip.h"
23
24#include "wx/gtk/private.h"
25
26//-----------------------------------------------------------------------------
27// global data
28//-----------------------------------------------------------------------------
29
30static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
31
32//-----------------------------------------------------------------------------
33// wxToolTip
34//-----------------------------------------------------------------------------
35
36IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
37
38wxToolTip::wxToolTip( const wxString &tip )
39{
40 m_text = tip;
41 m_window = (wxWindow*) NULL;
42}
43
44void wxToolTip::SetTip( const wxString &tip )
45{
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)
55 {
56 ss_tooltips = gtk_tooltips_new();
57 }
58
59 m_window = win;
60
61 if (m_text.IsEmpty())
62 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
63 else
64 m_window->ApplyToolTip( ss_tooltips, m_text );
65}
66
67void wxToolTip::Enable( bool flag )
68{
69 if (!ss_tooltips) return;
70
71 if (flag)
72 gtk_tooltips_enable( ss_tooltips );
73 else
74 gtk_tooltips_disable( ss_tooltips );
75}
76
77void wxToolTip::SetDelay( long msecs )
78{
79 if (!ss_tooltips)
80 return;
81
82 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
83}
84
85#endif
86