From 90b1b133da941cff3672e9b5283005a763115c9e Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 25 Jan 1999 13:57:06 +0000 Subject: [PATCH] Added wxToolTip git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/tooltip.h | 44 ++++++++++++++++++++++ include/wx/gtk1/tooltip.h | 44 ++++++++++++++++++++++ include/wx/tooltip.h | 19 ++++++++++ samples/controls/controls.cpp | 2 + src/gtk.inc | 1 + src/gtk/tooltip.cpp | 69 +++++++++++++++++++++++++++++++++++ src/gtk1/tooltip.cpp | 69 +++++++++++++++++++++++++++++++++++ 7 files changed, 248 insertions(+) create mode 100644 include/wx/gtk/tooltip.h create mode 100644 include/wx/gtk1/tooltip.h create mode 100644 include/wx/tooltip.h create mode 100644 src/gtk/tooltip.cpp create mode 100644 src/gtk1/tooltip.cpp diff --git a/include/wx/gtk/tooltip.h b/include/wx/gtk/tooltip.h new file mode 100644 index 0000000000..d8f7c0b8e3 --- /dev/null +++ b/include/wx/gtk/tooltip.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tooltip.h +// Purpose: +// Author: Robert Roebling +// Id: $Id$ +// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef __GTKTOOLTIPH__ +#define __GTKTOOLTIPH__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" +#include "wx/object.h" +#include "wx/window.h" + +//----------------------------------------------------------------------------- +// classes +//----------------------------------------------------------------------------- + +class wxToolTip; + +//----------------------------------------------------------------------------- +// wxToolTip +//----------------------------------------------------------------------------- + +class wxToolTip: public wxObject +{ +public: + + wxToolTip() {} + + static void Add( wxWindow *tool, const wxString &tip ); + static void Enable( bool flag ); + static void SetDelay( long msecs ); + + +}; + +#endif // __GTKTOOLTIPH__ diff --git a/include/wx/gtk1/tooltip.h b/include/wx/gtk1/tooltip.h new file mode 100644 index 0000000000..d8f7c0b8e3 --- /dev/null +++ b/include/wx/gtk1/tooltip.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tooltip.h +// Purpose: +// Author: Robert Roebling +// Id: $Id$ +// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef __GTKTOOLTIPH__ +#define __GTKTOOLTIPH__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" +#include "wx/object.h" +#include "wx/window.h" + +//----------------------------------------------------------------------------- +// classes +//----------------------------------------------------------------------------- + +class wxToolTip; + +//----------------------------------------------------------------------------- +// wxToolTip +//----------------------------------------------------------------------------- + +class wxToolTip: public wxObject +{ +public: + + wxToolTip() {} + + static void Add( wxWindow *tool, const wxString &tip ); + static void Enable( bool flag ); + static void SetDelay( long msecs ); + + +}; + +#endif // __GTKTOOLTIPH__ diff --git a/include/wx/tooltip.h b/include/wx/tooltip.h new file mode 100644 index 0000000000..a7719973be --- /dev/null +++ b/include/wx/tooltip.h @@ -0,0 +1,19 @@ +#ifndef _WX_TOOLTIP_H_BASE_ +#define _WX_TOOLTIP_H_BASE_ + +#if defined(__WXMSW__) +#include "wx/msw/tooltip.h" +#elif defined(__WXMOTIF__) +#include "wx/motif/tooltip.h" +#elif defined(__WXGTK__) +#include "wx/gtk/tooltip.h" +#elif defined(__WXQT__) +#include "wx/qt/tooltip.h" +#elif defined(__WXMAC__) +#include "wx/mac/tooltip.h" +#elif defined(__WXSTUBS__) +#include "wx/stubs/tooltip.h" +#endif + +#endif + // _WX_TOOLTIP_H_BASE_ diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 424dad13ac..f9a4752eea 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -28,6 +28,7 @@ #include "wx/imaglist.h" #include "wx/spinbutt.h" #include "wx/clipbrd.h" +#include "wx/tooltip.h" #if defined(__WXGTK__) || defined(__WXMOTIF__) #define USE_XPM @@ -336,6 +337,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); + wxToolTip::Add( button, "Press here to set italic font" ); // button->SetForegroundColour( "red" ); m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); m_checkbox->SetValue(FALSE); diff --git a/src/gtk.inc b/src/gtk.inc index 3befc8c23e..c2fa2e4460 100644 --- a/src/gtk.inc +++ b/src/gtk.inc @@ -116,6 +116,7 @@ LIB_CPP_SRC=\ gtk/tbargtk.cpp \ gtk/textctrl.cpp \ gtk/timer.cpp \ + gtk/tooltip.cpp \ gtk/utilsgtk.cpp \ gtk/utilsres.cpp \ gtk/window.cpp \ diff --git a/src/gtk/tooltip.cpp b/src/gtk/tooltip.cpp new file mode 100644 index 0000000000..bc5df460c6 --- /dev/null +++ b/src/gtk/tooltip.cpp @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tooltip.cpp +// Purpose: +// Author: Robert Roebling +// Id: $Id$ +// Copyright: (c) 1998 Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "tooltip.h" +#endif + +#include "wx/tooltip.h" + +#include "gtk/gtk.h" +#include "gdk/gdk.h" + +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +GtkTooltips *gs_tooltips = (GtkTooltips*) NULL; +GdkColor gs_tooltip_bg; +GdkColor gs_tooltip_fg; + +//----------------------------------------------------------------------------- +// wxToolTip +//----------------------------------------------------------------------------- + +void wxToolTip::Add( wxWindow *tool, const wxString &tip ) +{ + if (!gs_tooltips) + { + gs_tooltips = gtk_tooltips_new(); + + gs_tooltip_fg.red = 0; + gs_tooltip_fg.green = 0; + gs_tooltip_fg.blue = 0; + gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_fg ); + + gs_tooltip_bg.red = 65535; + gs_tooltip_bg.green = 65535; + gs_tooltip_bg.blue = 50000; + gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_bg ); + + gtk_tooltips_set_colors( gs_tooltips, &gs_tooltip_bg, &gs_tooltip_fg ); + } + + gtk_tooltips_set_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL ); +} + +void wxToolTip::Enable( bool flag ) +{ + if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + + if (flag) + gtk_tooltips_enable( gs_tooltips ); + else + gtk_tooltips_disable( gs_tooltips ); +} + +void wxToolTip::SetDelay( long msecs ) +{ + if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + + gtk_tooltips_set_delay( gs_tooltips, msecs ); +} + diff --git a/src/gtk1/tooltip.cpp b/src/gtk1/tooltip.cpp new file mode 100644 index 0000000000..bc5df460c6 --- /dev/null +++ b/src/gtk1/tooltip.cpp @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tooltip.cpp +// Purpose: +// Author: Robert Roebling +// Id: $Id$ +// Copyright: (c) 1998 Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "tooltip.h" +#endif + +#include "wx/tooltip.h" + +#include "gtk/gtk.h" +#include "gdk/gdk.h" + +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +GtkTooltips *gs_tooltips = (GtkTooltips*) NULL; +GdkColor gs_tooltip_bg; +GdkColor gs_tooltip_fg; + +//----------------------------------------------------------------------------- +// wxToolTip +//----------------------------------------------------------------------------- + +void wxToolTip::Add( wxWindow *tool, const wxString &tip ) +{ + if (!gs_tooltips) + { + gs_tooltips = gtk_tooltips_new(); + + gs_tooltip_fg.red = 0; + gs_tooltip_fg.green = 0; + gs_tooltip_fg.blue = 0; + gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_fg ); + + gs_tooltip_bg.red = 65535; + gs_tooltip_bg.green = 65535; + gs_tooltip_bg.blue = 50000; + gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_bg ); + + gtk_tooltips_set_colors( gs_tooltips, &gs_tooltip_bg, &gs_tooltip_fg ); + } + + gtk_tooltips_set_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL ); +} + +void wxToolTip::Enable( bool flag ) +{ + if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + + if (flag) + gtk_tooltips_enable( gs_tooltips ); + else + gtk_tooltips_disable( gs_tooltips ); +} + +void wxToolTip::SetDelay( long msecs ) +{ + if (!gs_tooltips) gs_tooltips = gtk_tooltips_new(); + + gtk_tooltips_set_delay( gs_tooltips, msecs ); +} + -- 2.45.2