]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/tooltip.cpp
correcting a missing redraw area on certain resize operations when window has a border
[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
ff8bfdbb 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
ff8bfdbb 21#include "wx/window.h"
90b1b133
RR
22#include "wx/tooltip.h"
23
9e691f46 24#include "wx/gtk/private.h"
90b1b133 25
f6bcfd97
BP
26extern GdkFont *GtkGetDefaultGuiFont();
27
301cd871
RR
28//-----------------------------------------------------------------------------
29// global data
30//-----------------------------------------------------------------------------
31
32static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL;
33static GdkColor ss_bg;
34static GdkColor ss_fg;
ff8bfdbb 35
90b1b133 36//-----------------------------------------------------------------------------
b1170810 37// wxToolTip
90b1b133
RR
38//-----------------------------------------------------------------------------
39
b342f8f0
RD
40IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
41
b1170810
RR
42wxToolTip::wxToolTip( const wxString &tip )
43{
44 m_text = tip;
301cd871 45 m_window = (wxWindow*) NULL;
b1170810 46}
90b1b133 47
301cd871 48void wxToolTip::SetTip( const wxString &tip )
b1170810 49{
301cd871
RR
50 m_text = tip;
51 Apply( m_window );
52}
53
54void wxToolTip::Apply( wxWindow *win )
55{
56 if (!win) return;
57
58 if (!ss_tooltips)
90b1b133 59 {
301cd871 60 ss_tooltips = gtk_tooltips_new();
ff8bfdbb
VZ
61
62 ss_fg.red = 0;
301cd871
RR
63 ss_fg.green = 0;
64 ss_fg.blue = 0;
65 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg );
ff8bfdbb 66
301cd871
RR
67 ss_bg.red = 65535;
68 ss_bg.green = 65535;
69 ss_bg.blue = 50000;
70 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg );
ff8bfdbb 71
02e8b87f 72 gtk_tooltips_force_window( ss_tooltips );
b342f8f0
RD
73
74 GtkStyle *g_style =
02e8b87f
RR
75 gtk_style_copy(
76 gtk_widget_get_style( ss_tooltips->tip_window ) );
b342f8f0 77
02e8b87f
RR
78 g_style->fg[GTK_STATE_NORMAL] = ss_fg;
79 g_style->bg[GTK_STATE_NORMAL] = ss_bg;
9e691f46 80
02e8b87f 81 gtk_widget_set_style( ss_tooltips->tip_window, g_style );
90b1b133 82 }
ff8bfdbb 83
301cd871 84 m_window = win;
ff8bfdbb 85
301cd871 86 if (m_text.IsEmpty())
05939a81 87 m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL );
301cd871
RR
88 else
89 m_window->ApplyToolTip( ss_tooltips, m_text );
90b1b133
RR
90}
91
92void wxToolTip::Enable( bool flag )
93{
301cd871 94 if (!ss_tooltips) return;
ff8bfdbb 95
90b1b133 96 if (flag)
301cd871 97 gtk_tooltips_enable( ss_tooltips );
90b1b133 98 else
301cd871 99 gtk_tooltips_disable( ss_tooltips );
90b1b133
RR
100}
101
102void wxToolTip::SetDelay( long msecs )
103{
b02da6b1
VZ
104 if (!ss_tooltips)
105 return;
ff8bfdbb 106
b02da6b1 107 gtk_tooltips_set_delay( ss_tooltips, (int)msecs );
90b1b133 108}
dcf924a3 109
f7f1f70f 110#endif
90b1b133 111