diff --git a/CHANGES b/CHANGES index 2b8343a52..e7eb7c220 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,9 @@ CHANGES IN FLTK 1.1.5rc3 - Documentation updates (STR #505, STR #513) - Updated PNG library source to 1.2.6 + wutil patch. - Updated ZLIB library source to 1.2.1. + - Tooltips would not reappear on the same widget, and + the initial tooltip delay was not used after a tooltip + was shown (STR #465) - Fixed a compile problem with the Linux 2.6 threading support (STR #483) - Fixed problems with 2-byte Xpm files on 64-bit diff --git a/FL/Fl_Tooltip.H b/FL/Fl_Tooltip.H index 3c90ae8b6..c1d008ca0 100644 --- a/FL/Fl_Tooltip.H +++ b/FL/Fl_Tooltip.H @@ -1,5 +1,5 @@ // -// "$Id: Fl_Tooltip.H,v 1.16.2.12 2004/04/11 04:38:54 easysw Exp $" +// "$Id: Fl_Tooltip.H,v 1.16.2.13 2004/09/12 20:26:23 easysw Exp $" // // Tooltip header file for the Fast Light Tool Kit (FLTK). // @@ -52,6 +52,11 @@ public: static Fl_Color color() { return (Fl_Color)color_; } static void textcolor(unsigned c) { textcolor_ = c; } static Fl_Color textcolor() { return (Fl_Color)textcolor_; } + + // These should not be public, but Fl_Widget::tooltip() needs them... + static void enter_(Fl_Widget* w); + static void exit_(Fl_Widget *w); + private: static float delay_; static float hoverdelay_; @@ -66,5 +71,5 @@ private: #endif // -// End of "$Id: Fl_Tooltip.H,v 1.16.2.12 2004/04/11 04:38:54 easysw Exp $". +// End of "$Id: Fl_Tooltip.H,v 1.16.2.13 2004/09/12 20:26:23 easysw Exp $". // diff --git a/src/Fl.cxx b/src/Fl.cxx index 00924a3f0..2ed58bada 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.24.2.41.2.67 2004/09/09 21:34:45 matthiaswm Exp $" +// "$Id: Fl.cxx,v 1.24.2.41.2.68 2004/09/12 20:26:23 easysw Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -36,6 +36,10 @@ #include #include "flstring.h" +#ifdef DEBUG +# include +#endif // DEBUG + // // Globals... @@ -482,6 +486,9 @@ void (*Fl_Tooltip::exit)(Fl_Widget *) = nothing; // X says the focus or mouse window have changed. void fl_fix_focus() { +#ifdef DEBUG + puts("fl_fix_focus();"); +#endif // DEBUG if (Fl::grab()) return; // don't do anything while grab is on. @@ -535,6 +542,10 @@ extern Fl_Widget *fl_selection_requestor; // from Fl_x.cxx // desirable behavior and caused flwm to crash. void fl_throw_focus(Fl_Widget *o) { +#ifdef DEBUG + printf("fl_throw_focus(o=%p)\n", o); +#endif // DEBUG + if (o->contains(Fl::pushed())) Fl::pushed_ = 0; #ifndef WIN32 if (o->contains(fl_selection_requestor)) fl_selection_requestor = 0; @@ -594,6 +605,10 @@ int Fl::handle(int e, Fl_Window* window) return 1; case FL_PUSH: +#ifdef DEBUG + printf("Fl::handle(e=%d, window=%p);\n", e, window); +#endif // DEBUG + if (grab()) wi = grab(); else if (modal() && wi != modal()) return 0; pushed_ = wi; @@ -631,7 +646,12 @@ int Fl::handle(int e, Fl_Window* window) if (grab()) wi = grab(); {Fl_Widget* pbm = belowmouse(); int ret = (wi && send(e, wi, window)); - if (pbm != belowmouse()) Fl_Tooltip::enter(belowmouse()); + if (pbm != belowmouse()) { +#ifdef DEBUG + printf("Fl::handle(e=%d, window=%p);\n", e, window); +#endif // DEBUG + Fl_Tooltip::enter(belowmouse()); + } return ret;} case FL_RELEASE: { @@ -657,6 +677,10 @@ int Fl::handle(int e, Fl_Window* window) return 1; case FL_KEYBOARD: +#ifdef DEBUG + printf("Fl::handle(e=%d, window=%p);\n", e, window); +#endif // DEBUG + Fl_Tooltip::enter((Fl_Widget*)0); fl_xfocus = window; // this should not happen! But maybe it does: @@ -695,12 +719,20 @@ int Fl::handle(int e, Fl_Window* window) return 0; case FL_ENTER: +#ifdef DEBUG + printf("Fl::handle(e=%d, window=%p);\n", e, window); +#endif // DEBUG + fl_xmousewin = window; fl_fix_focus(); Fl_Tooltip::enter(belowmouse()); return 1; case FL_LEAVE: +#ifdef DEBUG + printf("Fl::handle(e=%d, window=%p);\n", e, window); +#endif // DEBUG + if (!pushed_) { belowmouse(0); Fl_Tooltip::enter(0); @@ -1020,5 +1052,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl.cxx,v 1.24.2.41.2.67 2004/09/09 21:34:45 matthiaswm Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.41.2.68 2004/09/12 20:26:23 easysw Exp $". // diff --git a/src/Fl_Tooltip.cxx b/src/Fl_Tooltip.cxx index 1431e9327..352b2c26f 100644 --- a/src/Fl_Tooltip.cxx +++ b/src/Fl_Tooltip.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Tooltip.cxx,v 1.38.2.29 2004/04/11 04:38:58 easysw Exp $" +// "$Id: Fl_Tooltip.cxx,v 1.38.2.30 2004/09/12 20:26:23 easysw Exp $" // // Tooltip source file for the Fast Light Tool Kit (FLTK). // @@ -98,12 +98,20 @@ void Fl_TooltipBox::draw() { static char recent_tooltip; static void recent_timeout(void*) { +#ifdef DEBUG + puts("recent_timeout();"); +#endif // DEBUG + recent_tooltip = 0; } static char recursion; static void tooltip_timeout(void*) { +#ifdef DEBUG + puts("tooltip_timeout();"); +#endif // DEBUG + if (recursion) return; recursion = 1; if (!tip || !*tip) { @@ -125,12 +133,40 @@ static void tooltip_timeout(void*) { recursion = 0; } +// If this widget or one of it's parents has a tooltip, enter it. This +// will do nothing if this is the current widget (even if the mouse moved +// out so an exit() was done and then moved back in). If no tooltip can +// be found do Fl_Tooltip::exit_(). If you don't want this behavior (for instance +// if you want the tooltip to reappear when the mouse moves back in) +// call the fancier enter_area() below. +void +Fl_Tooltip::enter_(Fl_Widget* w) { +#ifdef DEBUG + printf("Fl_Tooltip::enter_(w=%p)\n", w); + printf(" window=%p\n", window); +#endif // DEBUG + + // find the enclosing group with a tooltip: + Fl_Widget* tw = w; + for (;;) { + if (!tw) {exit_(0); return;} + if (tw == widget_) return; + if (tw->tooltip()) break; + tw = tw->parent(); + } + enter_area(w, 0, 0, w->w(), w->h(), tw->tooltip()); +} + // Acts as though enter(widget) was done but does not pop up a // tooltip. This is useful to prevent a tooltip from reappearing when -// a modal overlapping window is deleted. Fltk does this automatically +// a modal overlapping window is deleted. FLTK does this automatically // when you click the mouse button. void Fl_Tooltip::current(Fl_Widget* w) { - enter(0); +#ifdef DEBUG + printf("Fl_Tooltip::current(w=%p)\n", w); +#endif // DEBUG + + exit_(0); // find the enclosing group with a tooltip: Fl_Widget* tw = w; for (;;) { @@ -138,20 +174,20 @@ void Fl_Tooltip::current(Fl_Widget* w) { if (tw->tooltip()) break; tw = tw->parent(); } - // act just like tt_enter() except we can remember a zero: + // act just like Fl_Tooltip::enter_() except we can remember a zero: widget_ = w; } -// This is called when a widget is destroyed: -static void -tt_exit(Fl_Widget *w) { +// Hide any visible tooltip. +void +Fl_Tooltip::exit_(Fl_Widget *w) { #ifdef DEBUG - printf("tt_exit(w=%p)\n", w); - printf(" widget=%p, window=%p\n", Fl_Tooltip::current(), window); + printf("Fl_Tooltip::exit_(w=%p)\n", w); + printf(" widget=%p, window=%p\n", widget_, window); #endif // DEBUG - if (!Fl_Tooltip::current()) return; - Fl_Tooltip::current(0); + if (!widget_) return; + widget_ = 0; Fl::remove_timeout(tooltip_timeout); Fl::remove_timeout(recent_timeout); if (window) window->hide(); @@ -161,26 +197,10 @@ tt_exit(Fl_Widget *w) { } } -static void -tt_enter(Fl_Widget* wp) { -#ifdef DEBUG - printf("tt_enter(wp=%p)\n", wp); - printf(" window=%p\n", window); -#endif // DEBUG - - // find the enclosing group with a tooltip: - Fl_Widget* w = wp; - while (w && !w->tooltip()) { - //if (w == window) return; // don't do anything if pointed at tooltip - w = w->parent(); - } - if (!w) { - Fl_Tooltip::enter_area(0, 0, 0, 0, 0, 0); - } else { - Fl_Tooltip::enter_area(w,0,0,w->w(), w->h(), w->tooltip()); - } -} - +// Get ready to display a tooltip. The widget and the xywh box inside +// it define an area the tooltip is for, this along with the current +// mouse position places the tooltip (the mouse is assummed to point +// inside or near the box). void Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char* t) { @@ -192,13 +212,11 @@ Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char* t) if (recursion) return; if (!t || !*t || !enabled()) { - if (window) window->hide(); - Fl::remove_timeout(tooltip_timeout); - Fl::remove_timeout(recent_timeout); + exit_(0); return; } // do nothing if it is the same: - if (wid==widget_ && x==X && y==Y && w==W && h==H && t==tip) return; + if (wid==widget_ /*&& x==X && y==Y && w==W && h==H*/ && t==tip) return; Fl::remove_timeout(tooltip_timeout); Fl::remove_timeout(recent_timeout); // remember it: @@ -212,7 +230,7 @@ Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char* t) // possible fix for the Windows titlebar, it seems to want the // window to be destroyed, moving it messes up the parenting: if (window) window->hide(); -#endif +#endif // WIN32 tooltip_timeout(0); } else { if (window) window->hide(); @@ -228,13 +246,13 @@ Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char* t) void Fl_Widget::tooltip(const char *tt) { static char beenhere = 0; if (!beenhere) { - beenhere = 1; - Fl_Tooltip::enter = tt_enter; - Fl_Tooltip::exit = tt_exit; + beenhere = 1; + Fl_Tooltip::enter = Fl_Tooltip::enter_; + Fl_Tooltip::exit = Fl_Tooltip::exit_; } tooltip_ = tt; } // -// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.29 2004/04/11 04:38:58 easysw Exp $". +// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.30 2004/09/12 20:26:23 easysw Exp $". //