changeset 1902:06fb15f69228

disable symbol-interpretation in labels There was some discussion of how to do this last month in fltk-dev http://fltk.org/newsgroups.php?s10630+gfltk.development+v10640+T0
author corvid <corvid@lavabit.com>
date Wed, 09 Feb 2011 01:31:14 +0000
parents 249bbc275f58
children 631c40949a94
files dw/fltkcomplexbutton.cc dw/fltkplatform.cc dw/fltkplatform.hh dw/fltkui.cc src/dillo.cc
diffstat 5 files changed, 26 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkcomplexbutton.cc	Tue Feb 08 06:22:05 2011 +0000
+++ b/dw/fltkcomplexbutton.cc	Wed Feb 09 01:31:14 2011 +0000
@@ -173,7 +173,6 @@
   down_box(FL_NO_BOX);
   value_ = oldval = 0;
   shortcut_ = 0;
-  set_flag(SHORTCUT_LABEL);
 }
 
 ComplexButton::~ComplexButton() {
--- a/dw/fltkplatform.cc	Tue Feb 08 06:22:05 2011 +0000
+++ b/dw/fltkplatform.cc	Wed Feb 09 01:31:14 2011 +0000
@@ -191,26 +191,6 @@
 FltkTooltip::FltkTooltip (const char *text) : Tooltip(text)
 {
    shown = false;
-
-   if (!text || !strpbrk(text, "&@")) {
-      escaped_str = NULL;
-   } else {
-      /*
-       * WORKAROUND: ::fltk::Tooltip::tooltip_timeout() makes instance_
-       * if necessary, and immediately uses it. This means that we can't
-       * get our hands on it to set RAW_LABEL until after it has been shown
-       * once. So let's escape the special characters ourselves.
-       */
-      const char *src = text;
-      char *dest = escaped_str = (char *) malloc(strlen(text) * 2 + 1);
-
-      while (*src) {
-         if (*src == '&' || *src == '@')
-            *dest++ = *src;
-         *dest++ = *src++;
-      }
-      *dest = '\0';
-   }
 }
 
 FltkTooltip::~FltkTooltip ()
@@ -221,8 +201,6 @@
    if (shown)
       Fl_Tooltip::exit();
 #endif
-   if (escaped_str)
-      free(escaped_str);
 }
 
 FltkTooltip *FltkTooltip::create (const char *text)
@@ -235,7 +213,7 @@
    Fl_Widget *widget = Fl::belowmouse();
 
    Fl_Tooltip::enter_area(widget, widget->x(), widget->y(), widget->w(),
-                          widget->h(), escaped_str ? escaped_str : str);
+                          widget->h(), str);
    shown = true;
 }
 
--- a/dw/fltkplatform.hh	Tue Feb 08 06:22:05 2011 +0000
+++ b/dw/fltkplatform.hh	Wed Feb 09 01:31:14 2011 +0000
@@ -60,7 +60,6 @@
    FltkTooltip (const char *text);
    ~FltkTooltip ();
    bool shown;
-   char *escaped_str; /* fltk WORKAROUND */
 public:
    static FltkTooltip *create(const char *text);
    void onEnter();
--- a/dw/fltkui.cc	Tue Feb 08 06:22:05 2011 +0000
+++ b/dw/fltkui.cc	Wed Feb 09 01:31:14 2011 +0000
@@ -244,7 +244,6 @@
    Fl_Button *button =
         new Fl_Button (allocation->x, allocation->y, allocation->width,
                        allocation->ascent + allocation->descent, label);
-// button->clear_flag (SHORTCUT_LABEL);
    button->callback (widgetCallback, this);
    button->when (FL_WHEN_RELEASE);
    return button;
@@ -736,7 +735,6 @@
    Fl_Check_Button *cb =
       new Fl_Check_Button (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
-// cb->clear_flag (SHORTCUT_LABEL);
    return cb;
 }
 
@@ -848,7 +846,6 @@
    Fl_Button *button =
       new Fl_Round_Button (allocation->x, allocation->y, allocation->width,
                            allocation->ascent + allocation->descent);
-// button->clear_flag (SHORTCUT_LABEL);
    button->when (FL_WHEN_CHANGED);
    button->callback (widgetCallback, this);
    button->type (FL_TOGGLE_BUTTON);
@@ -1061,7 +1058,6 @@
    tree->showroot(0);
    tree->connectorstyle(FL_TREE_CONNECTOR_NONE);
    tree->marginleft(-14);
-// tree->clear_flag (SHORTCUT_LABEL);
    tree->callback(widgetCallback,this);
    tree->when(FL_WHEN_CHANGED);
 
--- a/src/dillo.cc	Tue Feb 08 06:22:05 2011 +0000
+++ b/src/dillo.cc	Wed Feb 09 01:31:14 2011 +0000
@@ -24,8 +24,9 @@
 #include <signal.h>
 #include <locale.h>
 
+#include <FL/Fl.H>
 #include <FL/Fl_Window.H>
-#include <FL/Fl.H>
+#include <FL/fl_draw.H>
 
 #include "msg.h"
 #include "paths.hh"
@@ -167,6 +168,25 @@
    }
    return opt_id;
 }
+
+static void custLabelDraw(const Fl_Label* o, int X, int Y, int W, int H,
+                          Fl_Align align)
+{
+   const int interpret_symbols = 0;
+
+   fl_font(o->font, o->size);
+   fl_color((Fl_Color)o->color);
+   fl_draw(o->value, X, Y, W, H, align, o->image, interpret_symbols);
+}
+
+static void custLabelMeasure(const Fl_Label* o, int& W, int& H)
+{
+   const int interpret_symbols = 0;
+
+   fl_font(o->font, o->size);
+   fl_measure(o->value, W, H, interpret_symbols);
+}
+
 #if 0
 PORT1.3
 /*
@@ -318,6 +338,10 @@
 
    // Sets WM_CLASS hint on X11
    Fl_Window::default_xclass("dillo");
+
+   // Disable '@' interpretation in labels
+   Fl::set_labeltype(FL_NORMAL_LABEL, custLabelDraw, custLabelMeasure);
+
 #if 0
 PORT1.3
    checkPreferredFonts();