]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/tooltip.cpp
Misc validity fixes to samples/xrc/rc/*.xrc.
[wxWidgets.git] / src / gtk / tooltip.cpp
CommitLineData
90b1b133 1/////////////////////////////////////////////////////////////////////////////
9b5f1895 2// Name: src/gtk/tooltip.cpp
ff8bfdbb 3// Purpose: wxToolTip implementation
90b1b133 4// Author: Robert Roebling
90b1b133 5// Copyright: (c) 1998 Robert Roebling
65571936 6// Licence: wxWindows licence
90b1b133
RR
7/////////////////////////////////////////////////////////////////////////////
8
14f355c2
VS
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
cad880f5 12#if wxUSE_TOOLTIPS
f7f1f70f 13
90b1b133 14#include "wx/tooltip.h"
cdccdfab
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/window.h"
18#endif
90b1b133 19
9e691f46 20#include "wx/gtk/private.h"
90b1b133 21
301cd871
RR
22//-----------------------------------------------------------------------------
23// global data
24//-----------------------------------------------------------------------------
25
385e8575 26#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
d3b9f782 27static GtkTooltips *gs_tooltips = NULL;
385e8575 28#endif
ff8bfdbb 29
90b1b133 30//-----------------------------------------------------------------------------
b1170810 31// wxToolTip
90b1b133
RR
32//-----------------------------------------------------------------------------
33
b342f8f0
RD
34IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
35
b1170810 36wxToolTip::wxToolTip( const wxString &tip )
558a94bd 37 : m_text(tip)
b1170810 38{
d3b9f782 39 m_window = NULL;
b1170810 40}
90b1b133 41
301cd871 42void wxToolTip::SetTip( const wxString &tip )
b1170810 43{
301cd871 44 m_text = tip;
558a94bd
PC
45 if (m_window)
46 m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
301cd871
RR
47}
48
558a94bd 49void wxToolTip::GTKSetWindow(wxWindow* win)
301cd871 50{
558a94bd 51 wxASSERT(win);
301cd871 52 m_window = win;
558a94bd 53 m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
90b1b133
RR
54}
55
f7ce0e4a 56/* static */
558a94bd 57void wxToolTip::GTKApply(GtkWidget* widget, const char* tip)
f7ce0e4a 58{
85314957 59#if GTK_CHECK_VERSION(2, 12, 0)
385e8575 60 if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
558a94bd 61 gtk_widget_set_tooltip_text(widget, tip);
85314957
VZ
62 else
63#endif
64 {
385e8575 65#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
85314957
VZ
66 if ( !gs_tooltips )
67 gs_tooltips = gtk_tooltips_new();
f7ce0e4a 68
558a94bd 69 gtk_tooltips_set_tip(gs_tooltips, widget, tip, NULL);
385e8575 70#endif
85314957 71 }
f7ce0e4a
VZ
72}
73
90b1b133
RR
74void wxToolTip::Enable( bool flag )
75{
85314957 76#if GTK_CHECK_VERSION(2, 12, 0)
385e8575 77 if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
85314957
VZ
78 {
79 GtkSettings* settings = gtk_settings_get_default();
558a94bd
PC
80 if (settings)
81 gtk_settings_set_long_property(settings, "gtk-enable-tooltips", flag, NULL);
85314957 82 }
90b1b133 83 else
85314957
VZ
84#endif
85 {
385e8575 86#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
85314957 87 if (!gs_tooltips)
558a94bd 88 gs_tooltips = gtk_tooltips_new();
85314957
VZ
89
90 if (flag)
91 gtk_tooltips_enable( gs_tooltips );
92 else
93 gtk_tooltips_disable( gs_tooltips );
385e8575 94#endif
85314957 95 }
90b1b133
RR
96}
97
98void wxToolTip::SetDelay( long msecs )
99{
85314957 100#if GTK_CHECK_VERSION(2, 12, 0)
385e8575 101 if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
85314957
VZ
102 {
103 GtkSettings* settings = gtk_settings_get_default();
558a94bd
PC
104 if (settings)
105 gtk_settings_set_long_property(settings, "gtk-tooltip-timeout", msecs, NULL);
85314957
VZ
106 }
107 else
108#endif
109 {
385e8575 110#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
85314957 111 if (!gs_tooltips)
558a94bd 112 gs_tooltips = gtk_tooltips_new();
85314957 113
85314957 114 gtk_tooltips_set_delay( gs_tooltips, (int)msecs );
385e8575 115#endif
85314957 116 }
90b1b133 117}
dcf924a3 118
becac1ef
VZ
119void wxToolTip::SetAutoPop( long WXUNUSED(msecs) )
120{
121}
122
123void wxToolTip::SetReshow( long WXUNUSED(msecs) )
124{
125}
126
cdccdfab 127#endif // wxUSE_TOOLTIPS