diff options
author | corvid <corvid@lavabit.com> | 2011-05-30 13:22:57 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2011-05-30 13:22:57 +0000 |
commit | 6706b98088dc9982ef23a02661f7291ac6815469 (patch) | |
tree | 146b26ab7b54b52c30016e74c66fc2b5facd3a98 | |
parent | 9e16e1e3f9e8879cbb21e67582d103dba317193c (diff) |
Reintroduce @-escaping for tooltips.
I don't know what case I managed to test where I thought it was
unnecessary with 1.3. I do know that '&' has not been a problem...
-rw-r--r-- | dw/fltkplatform.cc | 18 | ||||
-rw-r--r-- | dw/fltkplatform.hh | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 00e1d07e..6d0b2ec4 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -191,10 +191,26 @@ FltkColor * FltkColor::create (int col) FltkTooltip::FltkTooltip (const char *text) : Tooltip(text) { + if (!strchr(text, '@')) { + escaped_str = NULL; + } else { + /* FLTK likes to interpret symbols, and so they must be escaped */ + const char *src = text; + char *dest = escaped_str = (char *) malloc(strlen(text) * 2 + 1); + + while (*src) { + if (*src == '@') + *dest++ = *src; + *dest++ = *src++; + } + *dest = '\0'; + } } FltkTooltip::~FltkTooltip () { + if (escaped_str) + free(escaped_str); } FltkTooltip *FltkTooltip::create (const char *text) @@ -207,7 +223,7 @@ void FltkTooltip::onEnter() Fl_Widget *widget = Fl::belowmouse(); Fl_Tooltip::enter_area(widget, widget->x(), widget->y(), widget->w(), - widget->h(), str); + widget->h(), escaped_str ? escaped_str : str); } void FltkTooltip::onLeave() diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 62bc3e0e..134b5c54 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -59,6 +59,7 @@ class FltkTooltip: public core::style::Tooltip private: FltkTooltip (const char *text); ~FltkTooltip (); + char *escaped_str; public: static FltkTooltip *create(const char *text); void onEnter(); |