Skip to content

Commit

Permalink
Add Fl_Tooltip::hoverdelay() method and code (STR #126)
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3102 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Sep 14, 2003
1 parent 8c56fa7 commit f6769ce
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.1.5rc1

- Added new hoverdelay() to Fl_Tooltip to control how
quickly recent tooltips appear (STR #126)
- FLUID now sets the size range when a window is shown.
This seems to be necessary with some window managers
(STR #166)
Expand Down
7 changes: 5 additions & 2 deletions FL/Fl_Tooltip.H
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Tooltip.H,v 1.16.2.10 2003/01/30 21:40:28 easysw Exp $"
// "$Id: Fl_Tooltip.H,v 1.16.2.11 2003/09/14 14:11:06 easysw Exp $"
//
// Tooltip header file for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -33,6 +33,8 @@ class FL_EXPORT Fl_Tooltip {
public:
static float delay() { return delay_; }
static void delay(float f) { delay_ = f; }
static float hoverdelay() { return hoverdelay_; }
static void hoverdelay(float f) { hoverdelay_ = f; }
static int enabled() { return enabled_; }
static void enable(int b = 1) { enabled_ = b;}
static void disable() { enabled_ = 0; }
Expand All @@ -52,6 +54,7 @@ public:
static Fl_Color textcolor() { return (Fl_Color)textcolor_; }
private:
static float delay_;
static float hoverdelay_;
static int enabled_;
static unsigned color_;
static unsigned textcolor_;
Expand All @@ -63,5 +66,5 @@ private:
#endif

//
// End of "$Id: Fl_Tooltip.H,v 1.16.2.10 2003/01/30 21:40:28 easysw Exp $".
// End of "$Id: Fl_Tooltip.H,v 1.16.2.11 2003/09/14 14:11:06 easysw Exp $".
//
19 changes: 13 additions & 6 deletions documentation/Fl_Tooltip.html
Expand Up @@ -36,6 +36,7 @@ <H3>Methods</H3>
<LI><A HREF="#Fl_Tooltip.enter_area">enter_area</A></LI>
<LI><A HREF="#Fl_Tooltip.exit">exit</A></LI>
<LI><A HREF="#Fl_Tooltip.font">font</A></LI>
<LI><A HREF="#Fl_Tooltip.hoverdelay">hoverdelay</A></LI>
<LI><A HREF="#Fl_Tooltip.size">size</A></LI>
<LI><A HREF="#Fl_Tooltip.textcolor">textcolor</A></LI>

Expand Down Expand Up @@ -86,21 +87,27 @@ <H4><A NAME="Fl_Tooltip.color">void color(unsigned c);<BR>
<P>Gets or sets the background color for tooltips. The default
background color is a pale yellow.

<H4><A NAME="Fl_Tooltip.textcolor">void textcolor(unsigned c);<BR>
Fl_Color textcolor();</A></H4>

<P>Gets or sets the color of the text in the tooltip. The default is
black.

<H4><A NAME="Fl_Tooltip.font">void font(int i);<BR>
int font();</A></H4>

<P>Gets or sets the typeface for the tooltip text.

<H4><A NAME="Fl_Tooltip.hoverdelay">void hoverdelay(float f);<BR>
float hoverdelay();</A></H4>

<P>Gets or sets the tooltip hover delay, the delay between tooltips.
The default delay is 0.2 seconds.

<H4><A NAME="Fl_Tooltip.size">void size(int s);<BR>
int size();</A></H4>

<P>Gets or sets the size of the tooltip text.

<H4><A NAME="Fl_Tooltip.textcolor">void textcolor(unsigned c);<BR>
Fl_Color textcolor();</A></H4>

<P>Gets or sets the color of the text in the tooltip. The default is
black.

</BODY>
</HTML>
12 changes: 8 additions & 4 deletions src/Fl_Tooltip.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Tooltip.cxx,v 1.38.2.27 2003/01/30 21:42:53 easysw Exp $"
// "$Id: Fl_Tooltip.cxx,v 1.38.2.28 2003/09/14 14:11:06 easysw Exp $"
//
// Tooltip source file for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -30,6 +30,7 @@
#include <stdio.h>

float Fl_Tooltip::delay_ = 1.0f;
float Fl_Tooltip::hoverdelay_ = 0.2f;
int Fl_Tooltip::enabled_ = 1;
unsigned Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
FL_NUM_GREEN - 1,
Expand Down Expand Up @@ -156,7 +157,7 @@ tt_exit(Fl_Widget *w) {
if (window) window->hide();
if (recent_tooltip) {
if (Fl::event_state() & FL_BUTTONS) recent_tooltip = 0;
else Fl::add_timeout(.2f, recent_timeout);
else Fl::add_timeout(Fl_Tooltip::hoverdelay(), recent_timeout);
}
}

Expand Down Expand Up @@ -203,7 +204,10 @@ Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char* t)
// remember it:
widget_ = wid; X = x; Y = y; W = w; H = h; tip = t;
// popup the tooltip immediately if it was recently up:
if (recent_tooltip || Fl_Tooltip::delay() < .1) {
if (recent_tooltip) {
if (window) window->hide();
Fl::add_timeout(Fl_Tooltip::hoverdelay(), tooltip_timeout);
} else if (Fl_Tooltip::delay() < .1) {
#ifdef WIN32
// possible fix for the Windows titlebar, it seems to want the
// window to be destroyed, moving it messes up the parenting:
Expand Down Expand Up @@ -232,5 +236,5 @@ void Fl_Widget::tooltip(const char *tt) {
}

//
// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.27 2003/01/30 21:42:53 easysw Exp $".
// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.28 2003/09/14 14:11:06 easysw Exp $".
//

0 comments on commit f6769ce

Please sign in to comment.