changeset 1389:0512fbb08abf

Added dw_window_set_tooltip() for adding bubble help to most controls. Mac, Windows and GTK should be supported... OS/2 coming soon.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 26 Nov 2011 21:00:14 +0000
parents 8fe15c1648c9
children 58c084177e3e
files dw.h gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c os2/dw.def readme template/dw.c win/dw-mingw.def win/dw.c win/dw.def
diffstat 11 files changed, 88 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Sat Nov 26 20:20:41 2011 +0000
+++ b/dw.h	Sat Nov 26 21:00:14 2011 +0000
@@ -1536,6 +1536,7 @@
 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len);
 char * API dw_window_get_text(HWND handle);
 void API dw_window_set_text(HWND handle, char *text);
+void API dw_window_set_tooltip(HWND handle, char *bubbletext);
 int API dw_window_set_border(HWND handle, int border);
 void API dw_window_disable(HWND handle);
 void API dw_window_enable(HWND handle);
--- a/gtk/dw.c	Sat Nov 26 20:20:41 2011 +0000
+++ b/gtk/dw.c	Sat Nov 26 21:00:14 2011 +0000
@@ -4393,7 +4393,7 @@
    {
       tooltips = gtk_tooltips_new();
       gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
-      gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
+      gtk_object_set_data(GTK_OBJECT(tmp), "_dw_tooltip", (gpointer)tooltips);
    }
    gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
    DW_MUTEX_UNLOCK;
@@ -4454,7 +4454,7 @@
    {
       tooltips = gtk_tooltips_new();
       gtk_tooltips_set_tip( tooltips, button, text, NULL );
-      gtk_object_set_data( GTK_OBJECT(button), "tooltip", (gpointer)tooltips );
+      gtk_object_set_data( GTK_OBJECT(button), "_dw_tooltip", (gpointer)tooltips );
    }
    gtk_object_set_data( GTK_OBJECT(button), "_dw_id", GINT_TO_POINTER(id) );
    DW_MUTEX_UNLOCK;
@@ -4491,7 +4491,7 @@
    {
       tooltips = gtk_tooltips_new();
       gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
-      gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
+      gtk_object_set_data(GTK_OBJECT(tmp), "_dw_tooltip", (gpointer)tooltips);
    }
    gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
    DW_MUTEX_UNLOCK;
@@ -4924,6 +4924,24 @@
 }
 
 /*
+ * Sets the text used for a given window's floating bubble help.
+ * Parameters:
+ *       handle: Handle to the window (widget).
+ *       bubbletext: The text in the floating bubble tooltip.
+ */
+void API dw_window_set_tooltip(HWND handle, char *bubbletext)
+{
+   int _locked_by_me = FALSE;
+   GtkTooltips *tooltips;
+
+   DW_MUTEX_LOCK;
+   tooltips = gtk_tooltips_new();
+   gtk_tooltips_set_tip(tooltips, handle, bubbletext ? bubbletext : "", NULL);
+   gtk_object_set_data(GTK_OBJECT(tmp), "_dw_tooltip", (gpointer)tooltips);
+   DW_MUTEX_UNLOCK;
+}
+
+/*
  * Gets the text used for a given window.
  * Parameters:
  *       handle: Handle to the window.
--- a/gtk3/dw.c	Sat Nov 26 20:20:41 2011 +0000
+++ b/gtk3/dw.c	Sat Nov 26 21:00:14 2011 +0000
@@ -4335,6 +4335,21 @@
 }
 
 /*
+ * Sets the text used for a given window's floating bubble help.
+ * Parameters:
+ *       handle: Handle to the window (widget).
+ *       bubbletext: The text in the floating bubble tooltip.
+ */
+void API dw_window_set_tooltip(HWND handle, char *bubbletext)
+{
+   int _locked_by_me = FALSE;
+
+   DW_MUTEX_LOCK;
+   gtk_widget_set_tooltip_text(tmp, bubbletext);
+   DW_MUTEX_UNLOCK;
+}
+
+/*
  * Gets the text used for a given window.
  * Parameters:
  *       handle: Handle to the window.
--- a/mac/dw.m	Sat Nov 26 20:20:41 2011 +0000
+++ b/mac/dw.m	Sat Nov 26 21:00:14 2011 +0000
@@ -8161,6 +8161,18 @@
 }
 
 /*
+ * Sets the text used for a given window's floating bubble help.
+ * Parameters:
+ *       handle: Handle to the window (widget).
+ *       bubbletext: The text in the floating bubble tooltip.
+ */
+void API dw_window_set_tooltip(HWND handle, char *bubbletext)
+{
+    id object = handle;
+    [object setToolTip:[NSString stringWithUTF8String:bubbletext]];
+}
+
+/*
  * Disables given window (widget).
  * Parameters:
  *       handle: Handle to the window.
--- a/os2/dw.c	Sat Nov 26 20:20:41 2011 +0000
+++ b/os2/dw.c	Sat Nov 26 21:00:14 2011 +0000
@@ -6317,6 +6317,19 @@
 }
 
 /*
+ * Sets the text used for a given window's floating bubble help.
+ * Parameters:
+ *       handle: Handle to the window (widget).
+ *       bubbletext: The text in the floating bubble tooltip.
+ */
+void API dw_window_set_tooltip(HWND handle, char *bubbletext)
+{
+    /* TODO: Fill this in with generic bubble help code...
+     * like we do for the bitmap buttons.
+     */
+}
+
+/*
  * Gets the text used for a given window.
  * Parameters:
  *       handle: Handle to the window.
--- a/os2/dw.def	Sat Nov 26 20:20:41 2011 +0000
+++ b/os2/dw.def	Sat Nov 26 21:00:14 2011 +0000
@@ -67,6 +67,7 @@
   dw_bitmap_new                          @80
   dw_window_set_bitmap_from_data         @81
   dw_window_get_font                     @82
+  dw_window_set_tooltip                  @83
 
   dw_button_new                          @90
   dw_bitmapbutton_new                    @91
--- a/readme	Sat Nov 26 20:20:41 2011 +0000
+++ b/readme	Sat Nov 26 21:00:14 2011 +0000
@@ -36,6 +36,8 @@
     Now you can use dw_window_destroy() on menu items handles also.
 Added dw_app_dir() which attempts to locate private application data
     for the current platform.  
+Added dw_window_set_tooltip() for adding tooltips to most widgets.
+    All platforms supported except OS/2 which will be coming soon.
 Fixed bubble help not being displayed on Windows.
 Fixed menu bar items remaining highlighted on Mac.
 
--- a/template/dw.c	Sat Nov 26 20:20:41 2011 +0000
+++ b/template/dw.c	Sat Nov 26 21:00:14 2011 +0000
@@ -2807,6 +2807,16 @@
 }
 
 /*
+ * Sets the text used for a given window's floating bubble help.
+ * Parameters:
+ *       handle: Handle to the window (widget).
+ *       bubbletext: The text in the floating bubble tooltip.
+ */
+void API dw_window_set_tooltip(HWND handle, char *bubbletext)
+{
+}
+
+/*
  * Disables given window (widget).
  * Parameters:
  *       handle: Handle to the window.
--- a/win/dw-mingw.def	Sat Nov 26 20:20:41 2011 +0000
+++ b/win/dw-mingw.def	Sat Nov 26 21:00:14 2011 +0000
@@ -64,6 +64,7 @@
   dw_bitmap_new                          @80
   dw_window_set_bitmap_from_data         @81
   dw_window_get_font                     @82
+  dw_window_set_tooltip                  @83
 
   dw_button_new                          @90
   dw_bitmapbutton_new                    @91
--- a/win/dw.c	Sat Nov 26 20:20:41 2011 +0000
+++ b/win/dw.c	Sat Nov 26 21:00:14 2011 +0000
@@ -6190,6 +6190,17 @@
 }
 
 /*
+ * Sets the text used for a given window's floating bubble help.
+ * Parameters:
+ *       handle: Handle to the window (widget).
+ *       bubbletext: The text in the floating bubble tooltip.
+ */
+void API dw_window_set_tooltip(HWND handle, char *bubbletext)
+{
+    _create_tooltip(handle, bubbletext);
+}
+
+/*
  * Gets the text used for a given window.
  * Parameters:
  *       handle: Handle to the window.
--- a/win/dw.def	Sat Nov 26 20:20:41 2011 +0000
+++ b/win/dw.def	Sat Nov 26 21:00:14 2011 +0000
@@ -64,6 +64,7 @@
   dw_bitmap_new                          @80
   dw_window_set_bitmap_from_data         @81
   dw_window_get_font                     @82
+  dw_window_set_tooltip                  @83
 
   dw_button_new                          @90
   dw_bitmapbutton_new                    @91