]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/tooltip.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxToolTip implementation
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "tooltip.h"
18 #include "wx/window.h"
19 #include "wx/tooltip.h"
24 extern GdkFont
*GtkGetDefaultGuiFont();
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 static GtkTooltips
*ss_tooltips
= (GtkTooltips
*) NULL
;
31 static GdkColor ss_bg
;
32 static GdkColor ss_fg
;
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 IMPLEMENT_ABSTRACT_CLASS(wxToolTip
, wxObject
)
40 wxToolTip::wxToolTip( const wxString
&tip
)
43 m_window
= (wxWindow
*) NULL
;
46 void wxToolTip::SetTip( const wxString
&tip
)
52 void wxToolTip::Apply( wxWindow
*win
)
58 ss_tooltips
= gtk_tooltips_new();
63 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_fg
);
68 gdk_color_alloc( gtk_widget_get_default_colormap(), &ss_bg
);
70 #if (GTK_MINOR_VERSION > 0)
71 gtk_tooltips_force_window( ss_tooltips
);
75 gtk_widget_get_style( ss_tooltips
->tip_window
) );
77 g_style
->fg
[GTK_STATE_NORMAL
] = ss_fg
;
78 g_style
->bg
[GTK_STATE_NORMAL
] = ss_bg
;
79 gdk_font_unref( g_style
->font
);
80 g_style
->font
= gdk_font_ref( GtkGetDefaultGuiFont() );
82 gtk_widget_set_style( ss_tooltips
->tip_window
, g_style
);
84 gtk_tooltips_set_colors( ss_tooltips
, &ss_bg
, &ss_fg
);
91 m_window
->ApplyToolTip( ss_tooltips
, (wxChar
*) NULL
);
93 m_window
->ApplyToolTip( ss_tooltips
, m_text
);
96 void wxToolTip::Enable( bool flag
)
98 if (!ss_tooltips
) return;
101 gtk_tooltips_enable( ss_tooltips
);
103 gtk_tooltips_disable( ss_tooltips
);
106 void wxToolTip::SetDelay( long msecs
)
111 gtk_tooltips_set_delay( ss_tooltips
, (int)msecs
);