Tooltips would not reappear on the same widget, and the initial

tooltip delay was not used after a tooltip was shown (STR #465)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3822 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2004-09-12 20:26:23 +00:00
parent 35af1c00cc
commit 70dd6151c1
4 changed files with 103 additions and 45 deletions

View File

@ -3,6 +3,9 @@ CHANGES IN FLTK 1.1.5rc3
- Documentation updates (STR #505, STR #513) - Documentation updates (STR #505, STR #513)
- Updated PNG library source to 1.2.6 + wutil patch. - Updated PNG library source to 1.2.6 + wutil patch.
- Updated ZLIB library source to 1.2.1. - 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 - Fixed a compile problem with the Linux 2.6 threading
support (STR #483) support (STR #483)
- Fixed problems with 2-byte Xpm files on 64-bit - Fixed problems with 2-byte Xpm files on 64-bit

View File

@ -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). // Tooltip header file for the Fast Light Tool Kit (FLTK).
// //
@ -52,6 +52,11 @@ public:
static Fl_Color color() { return (Fl_Color)color_; } static Fl_Color color() { return (Fl_Color)color_; }
static void textcolor(unsigned c) { textcolor_ = c; } static void textcolor(unsigned c) { textcolor_ = c; }
static Fl_Color textcolor() { return (Fl_Color)textcolor_; } 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: private:
static float delay_; static float delay_;
static float hoverdelay_; static float hoverdelay_;
@ -66,5 +71,5 @@ private:
#endif #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 $".
// //

View File

@ -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). // Main event handling code for the Fast Light Tool Kit (FLTK).
// //
@ -36,6 +36,10 @@
#include <stdlib.h> #include <stdlib.h>
#include "flstring.h" #include "flstring.h"
#ifdef DEBUG
# include <stdio.h>
#endif // DEBUG
// //
// Globals... // Globals...
@ -482,6 +486,9 @@ void (*Fl_Tooltip::exit)(Fl_Widget *) = nothing;
// X says the focus or mouse window have changed. // X says the focus or mouse window have changed.
void fl_fix_focus() { void fl_fix_focus() {
#ifdef DEBUG
puts("fl_fix_focus();");
#endif // DEBUG
if (Fl::grab()) return; // don't do anything while grab is on. 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. // desirable behavior and caused flwm to crash.
void fl_throw_focus(Fl_Widget *o) { 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; if (o->contains(Fl::pushed())) Fl::pushed_ = 0;
#ifndef WIN32 #ifndef WIN32
if (o->contains(fl_selection_requestor)) fl_selection_requestor = 0; if (o->contains(fl_selection_requestor)) fl_selection_requestor = 0;
@ -594,6 +605,10 @@ int Fl::handle(int e, Fl_Window* window)
return 1; return 1;
case FL_PUSH: case FL_PUSH:
#ifdef DEBUG
printf("Fl::handle(e=%d, window=%p);\n", e, window);
#endif // DEBUG
if (grab()) wi = grab(); if (grab()) wi = grab();
else if (modal() && wi != modal()) return 0; else if (modal() && wi != modal()) return 0;
pushed_ = wi; pushed_ = wi;
@ -631,7 +646,12 @@ int Fl::handle(int e, Fl_Window* window)
if (grab()) wi = grab(); if (grab()) wi = grab();
{Fl_Widget* pbm = belowmouse(); {Fl_Widget* pbm = belowmouse();
int ret = (wi && send(e, wi, window)); 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;} return ret;}
case FL_RELEASE: { case FL_RELEASE: {
@ -657,6 +677,10 @@ int Fl::handle(int e, Fl_Window* window)
return 1; return 1;
case FL_KEYBOARD: case FL_KEYBOARD:
#ifdef DEBUG
printf("Fl::handle(e=%d, window=%p);\n", e, window);
#endif // DEBUG
Fl_Tooltip::enter((Fl_Widget*)0); Fl_Tooltip::enter((Fl_Widget*)0);
fl_xfocus = window; // this should not happen! But maybe it does: 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; return 0;
case FL_ENTER: case FL_ENTER:
#ifdef DEBUG
printf("Fl::handle(e=%d, window=%p);\n", e, window);
#endif // DEBUG
fl_xmousewin = window; fl_xmousewin = window;
fl_fix_focus(); fl_fix_focus();
Fl_Tooltip::enter(belowmouse()); Fl_Tooltip::enter(belowmouse());
return 1; return 1;
case FL_LEAVE: case FL_LEAVE:
#ifdef DEBUG
printf("Fl::handle(e=%d, window=%p);\n", e, window);
#endif // DEBUG
if (!pushed_) { if (!pushed_) {
belowmouse(0); belowmouse(0);
Fl_Tooltip::enter(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 $".
// //

View File

@ -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). // Tooltip source file for the Fast Light Tool Kit (FLTK).
// //
@ -98,12 +98,20 @@ void Fl_TooltipBox::draw() {
static char recent_tooltip; static char recent_tooltip;
static void recent_timeout(void*) { static void recent_timeout(void*) {
#ifdef DEBUG
puts("recent_timeout();");
#endif // DEBUG
recent_tooltip = 0; recent_tooltip = 0;
} }
static char recursion; static char recursion;
static void tooltip_timeout(void*) { static void tooltip_timeout(void*) {
#ifdef DEBUG
puts("tooltip_timeout();");
#endif // DEBUG
if (recursion) return; if (recursion) return;
recursion = 1; recursion = 1;
if (!tip || !*tip) { if (!tip || !*tip) {
@ -125,12 +133,40 @@ static void tooltip_timeout(void*) {
recursion = 0; 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 // Acts as though enter(widget) was done but does not pop up a
// tooltip. This is useful to prevent a tooltip from reappearing when // 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. // when you click the mouse button.
void Fl_Tooltip::current(Fl_Widget* w) { 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: // find the enclosing group with a tooltip:
Fl_Widget* tw = w; Fl_Widget* tw = w;
for (;;) { for (;;) {
@ -138,20 +174,20 @@ void Fl_Tooltip::current(Fl_Widget* w) {
if (tw->tooltip()) break; if (tw->tooltip()) break;
tw = tw->parent(); 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; widget_ = w;
} }
// This is called when a widget is destroyed: // Hide any visible tooltip.
static void void
tt_exit(Fl_Widget *w) { Fl_Tooltip::exit_(Fl_Widget *w) {
#ifdef DEBUG #ifdef DEBUG
printf("tt_exit(w=%p)\n", w); printf("Fl_Tooltip::exit_(w=%p)\n", w);
printf(" widget=%p, window=%p\n", Fl_Tooltip::current(), window); printf(" widget=%p, window=%p\n", widget_, window);
#endif // DEBUG #endif // DEBUG
if (!Fl_Tooltip::current()) return; if (!widget_) return;
Fl_Tooltip::current(0); widget_ = 0;
Fl::remove_timeout(tooltip_timeout); Fl::remove_timeout(tooltip_timeout);
Fl::remove_timeout(recent_timeout); Fl::remove_timeout(recent_timeout);
if (window) window->hide(); if (window) window->hide();
@ -161,26 +197,10 @@ tt_exit(Fl_Widget *w) {
} }
} }
static void // Get ready to display a tooltip. The widget and the xywh box inside
tt_enter(Fl_Widget* wp) { // it define an area the tooltip is for, this along with the current
#ifdef DEBUG // mouse position places the tooltip (the mouse is assummed to point
printf("tt_enter(wp=%p)\n", wp); // inside or near the box).
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());
}
}
void void
Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char* t) 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 (recursion) return;
if (!t || !*t || !enabled()) { if (!t || !*t || !enabled()) {
if (window) window->hide(); exit_(0);
Fl::remove_timeout(tooltip_timeout);
Fl::remove_timeout(recent_timeout);
return; return;
} }
// do nothing if it is the same: // 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(tooltip_timeout);
Fl::remove_timeout(recent_timeout); Fl::remove_timeout(recent_timeout);
// remember it: // 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 // possible fix for the Windows titlebar, it seems to want the
// window to be destroyed, moving it messes up the parenting: // window to be destroyed, moving it messes up the parenting:
if (window) window->hide(); if (window) window->hide();
#endif #endif // WIN32
tooltip_timeout(0); tooltip_timeout(0);
} else { } else {
if (window) window->hide(); 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) { void Fl_Widget::tooltip(const char *tt) {
static char beenhere = 0; static char beenhere = 0;
if (!beenhere) { if (!beenhere) {
beenhere = 1; beenhere = 1;
Fl_Tooltip::enter = tt_enter; Fl_Tooltip::enter = Fl_Tooltip::enter_;
Fl_Tooltip::exit = tt_exit; Fl_Tooltip::exit = Fl_Tooltip::exit_;
} }
tooltip_ = tt; 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 $".
// //