]>
Commit | Line | Data |
---|---|---|
90b1b133 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: tooltip.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "tooltip.h" | |
12 | #endif | |
13 | ||
14 | #include "wx/tooltip.h" | |
15 | ||
16 | #include "gtk/gtk.h" | |
17 | #include "gdk/gdk.h" | |
18 | ||
19 | //----------------------------------------------------------------------------- | |
b1170810 | 20 | // wxToolTip |
90b1b133 RR |
21 | //----------------------------------------------------------------------------- |
22 | ||
b1170810 RR |
23 | wxToolTip::wxToolTip( const wxString &tip ) |
24 | { | |
25 | m_text = tip; | |
26 | ||
27 | m_tooltips = (GtkTooltips*) NULL; | |
28 | ||
29 | m_fg = new GdkColor; | |
30 | m_fg->red = 0; | |
31 | m_fg->green = 0; | |
32 | m_fg->blue = 0; | |
33 | ||
34 | m_bg = new GdkColor; | |
35 | m_bg->red = 65535; | |
36 | m_bg->green = 65535; | |
37 | m_bg->blue = 50000; | |
38 | } | |
90b1b133 | 39 | |
b1170810 RR |
40 | wxToolTip::~wxToolTip() |
41 | { | |
42 | gtk_object_unref( GTK_OBJECT(m_tooltips) ); | |
43 | ||
44 | delete m_fg; | |
45 | delete m_bg; | |
46 | } | |
90b1b133 | 47 | |
b1170810 | 48 | bool wxToolTip::Ok() |
90b1b133 | 49 | { |
b1170810 RR |
50 | return (m_tooltips); |
51 | } | |
52 | ||
53 | void wxToolTip::Create( GtkWidget *tool ) | |
54 | { | |
55 | if (!m_tooltips) | |
90b1b133 | 56 | { |
b1170810 | 57 | m_tooltips = gtk_tooltips_new(); |
90b1b133 | 58 | |
b1170810 RR |
59 | gdk_color_alloc( gtk_widget_get_colormap( tool ), m_fg ); |
60 | gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg ); | |
90b1b133 | 61 | |
b1170810 | 62 | gtk_tooltips_set_colors( m_tooltips, m_bg, m_fg ); |
90b1b133 RR |
63 | } |
64 | ||
b1170810 | 65 | gtk_tooltips_set_tip( m_tooltips, tool, m_text, (gchar*) NULL ); |
90b1b133 RR |
66 | } |
67 | ||
68 | void wxToolTip::Enable( bool flag ) | |
69 | { | |
b1170810 | 70 | if (!Ok()) return; |
90b1b133 RR |
71 | |
72 | if (flag) | |
b1170810 | 73 | gtk_tooltips_enable( m_tooltips ); |
90b1b133 | 74 | else |
b1170810 | 75 | gtk_tooltips_disable( m_tooltips ); |
90b1b133 RR |
76 | } |
77 | ||
78 | void wxToolTip::SetDelay( long msecs ) | |
79 | { | |
b1170810 | 80 | if (!Ok()) return; |
90b1b133 | 81 | |
b1170810 | 82 | gtk_tooltips_set_delay( m_tooltips, msecs ); |
90b1b133 RR |
83 | } |
84 |