aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-10-10 03:04:12 +0000
committercorvid <corvid@lavabit.com>2009-10-10 03:04:12 +0000
commit5d4f5b8d2c471ef679f4929836e889f4ee9982fa (patch)
treece5203662884435f89ebb6ca0387bcaf07b2a51c /dw
parentd6b5833b9cc32f78400c15fb9305f06f1ac97927 (diff)
tooltip workaround for chars special to fltk
Diffstat (limited to 'dw')
-rw-r--r--dw/fltkplatform.cc24
-rw-r--r--dw/fltkplatform.hh1
2 files changed, 24 insertions, 1 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index e4d9a874..3309d5c5 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -153,12 +153,34 @@ FltkTooltip::FltkTooltip (const char *text) : Tooltip(text)
if (!widget)
widget = new ::fltk::InvisibleBox(1, 1, 0, 0, NULL);
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 ()
{
if (shown)
::fltk::Tooltip::exit();
+ if (escaped_str)
+ free(escaped_str);
}
FltkTooltip *FltkTooltip::create (const char *text)
@@ -170,7 +192,7 @@ void FltkTooltip::onEnter()
{
Rectangle rect;
widget->get_absolute_rect(&rect);
- ::fltk::Tooltip::enter(widget, rect, str);
+ ::fltk::Tooltip::enter(widget, rect, escaped_str ? escaped_str : str);
shown = true;
}
diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh
index d83f34ea..1d9a7521 100644
--- a/dw/fltkplatform.hh
+++ b/dw/fltkplatform.hh
@@ -49,6 +49,7 @@ private:
FltkTooltip (const char *text);
~FltkTooltip ();
bool shown;
+ char *escaped_str; /* fltk WORKAROUND */
static ::fltk::Widget *widget;
public:
static FltkTooltip *create(const char *text);