Skip to content
Snippets Groups Projects
Commit 4765281b authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Merge branch 'new-tooltips'

parents 83b333c3 f4e56269
No related branches found
No related tags found
No related merge requests found
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
#include "drawContext.h" #include "drawContext.h"
#include "Navigator.h" #include "Navigator.h"
#define NEW_TOOLTIPS 1
#if defined(NEW_TOOLTIPS) #if defined(NEW_TOOLTIPS)
#include <FL/Fl_Menu_Window.H> #include <FL/Fl_Menu_Window.H>
#include <FL/Fl_Tooltip.H>
#include <FL/fl_draw.H> #include <FL/fl_draw.H>
class tooltipWindow : public Fl_Menu_Window { class tooltipWindow : public Fl_Menu_Window {
...@@ -32,11 +35,14 @@ public: ...@@ -32,11 +35,14 @@ public:
} }
void draw() void draw()
{ {
draw_box(FL_BORDER_BOX, 0, 0, w(), h(), Fl_Color(175)); draw_box(FL_BORDER_BOX, 0, 0, w(), h(), Fl_Tooltip::color());
fl_color(FL_BLACK); fl_color(Fl_Tooltip::textcolor());
fl_font(labelfont(), labelsize()); fl_font(Fl_Tooltip::font(), Fl_Tooltip::size());
fl_draw(_text, 3, 3, w() - 6, h() - 6, int X = Fl_Tooltip::margin_width();
Fl_Align(FL_ALIGN_LEFT | FL_ALIGN_WRAP)); int Y = Fl_Tooltip::margin_height();
int W = w() - (Fl_Tooltip::margin_width() * 2);
int H = h() - (Fl_Tooltip::margin_height() * 2);
fl_draw(_text, X, Y, W, H, Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_WRAP), 0, 1);
} }
int handle(int e) int handle(int e)
{ {
...@@ -49,12 +55,14 @@ public: ...@@ -49,12 +55,14 @@ public:
void value(const std::string &s) void value(const std::string &s)
{ {
strncpy(_text, s.c_str(), 1023); strncpy(_text, s.c_str(), 1023);
// recalc size of window _text[1023] = '\n';
fl_font(labelfont(), labelsize()); fl_font(Fl_Tooltip::font(), Fl_Tooltip::size());
int W = w(), H = h(); int ww = Fl_Tooltip::wrap_width();
fl_measure(_text, W, H, 0); int hh = 0;
W += 8; fl_measure(_text, ww, hh, 1);
size(W, H); ww += (Fl_Tooltip::margin_width() * 2);
hh += (Fl_Tooltip::margin_height() * 2);
size(ww, hh);
redraw(); redraw();
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment