]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxToolTip
authorRobert Roebling <robert@roebling.de>
Mon, 25 Jan 1999 13:57:06 +0000 (13:57 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 25 Jan 1999 13:57:06 +0000 (13:57 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/tooltip.h [new file with mode: 0644]
include/wx/gtk1/tooltip.h [new file with mode: 0644]
include/wx/tooltip.h [new file with mode: 0644]
samples/controls/controls.cpp
src/gtk.inc
src/gtk/tooltip.cpp [new file with mode: 0644]
src/gtk1/tooltip.cpp [new file with mode: 0644]

diff --git a/include/wx/gtk/tooltip.h b/include/wx/gtk/tooltip.h
new file mode 100644 (file)
index 0000000..d8f7c0b
--- /dev/null
@@ -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 (file)
index 0000000..d8f7c0b
--- /dev/null
@@ -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 (file)
index 0000000..a771997
--- /dev/null
@@ -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_
index 424dad13ac7dba6d90e506fa9349da1a73d7fc44..f9a4752eea493e6d40ab23dc940109bfe192d639 100644 (file)
@@ -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);
index 3befc8c23e6afe04a1bbbf4ed78f1dbad97fd27b..c2fa2e44606fe049cac26114668fac5f962a19b9 100644 (file)
@@ -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 (file)
index 0000000..bc5df46
--- /dev/null
@@ -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 (file)
index 0000000..bc5df46
--- /dev/null
@@ -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 );
+}
+