From 74c690bc83186311a0567b5d35edd30961104ed4 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 3 Oct 2009 02:22:31 +0000 Subject: some tooltips --- dw/fltkplatform.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'dw/fltkplatform.cc') diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 4ceca58d..e4d9a874 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -143,6 +145,45 @@ FltkColor * FltkColor::create (int col) return color; } +::fltk::Widget *FltkTooltip::widget = NULL; + +FltkTooltip::FltkTooltip (const char *text) : Tooltip(text) +{ + /* ::fltk::Tooltip really, really wants a Widget */ + if (!widget) + widget = new ::fltk::InvisibleBox(1, 1, 0, 0, NULL); + shown = false; +} + +FltkTooltip::~FltkTooltip () +{ + if (shown) + ::fltk::Tooltip::exit(); +} + +FltkTooltip *FltkTooltip::create (const char *text) +{ + return new FltkTooltip(text); +} + +void FltkTooltip::onEnter() +{ + Rectangle rect; + widget->get_absolute_rect(&rect); + ::fltk::Tooltip::enter(widget, rect, str); + shown = true; +} + +void FltkTooltip::onLeave() +{ + ::fltk::Tooltip::exit(); + shown = false; +} + +void FltkTooltip::onMotion() +{ +} + void FltkView::addFltkWidget (::fltk::Widget *widget, core::Allocation *allocation) { @@ -384,6 +425,11 @@ core::style::Color *FltkPlatform::createColor (int color) return FltkColor::create (color); } +core::style::Tooltip *FltkPlatform::createTooltip (const char *text) +{ + return FltkTooltip::create (text); +} + void FltkPlatform::copySelection(const char *text) { fltk::copy(text, strlen(text), false); -- cgit v1.2.3