]>
Commit | Line | Data |
---|---|---|
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/tooltip.h" | |
22 | #include "wx/window.h" | |
23 | ||
24 | #include "wx/gtk/private.h" | |
25 | ||
26 | //----------------------------------------------------------------------------- | |
27 | // global data | |
28 | //----------------------------------------------------------------------------- | |
29 | ||
30 | static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL; | |
31 | ||
32 | //----------------------------------------------------------------------------- | |
33 | // wxToolTip | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
36 | IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject) | |
37 | ||
38 | wxToolTip::wxToolTip( const wxString &tip ) | |
39 | { | |
40 | m_text = tip; | |
41 | m_window = (wxWindow*) NULL; | |
42 | } | |
43 | ||
44 | void wxToolTip::SetTip( const wxString &tip ) | |
45 | { | |
46 | m_text = tip; | |
47 | Apply( m_window ); | |
48 | } | |
49 | ||
50 | void 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 | ||
67 | void 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 | ||
77 | void 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 |