fltk::Tooltip Class Reference

Inherits fltk::MenuWindow.

List of all members.

Public Types

typedef const char *(* Generator )(Widget *, void *)

Public Member Functions

void draw ()
void layout ()

Static Public Member Functions

static void current (Widget *)
static void * current_data ()
static Generator current_generator ()
static const Rectanglecurrent_rectangle ()
static Widgetcurrent_widget ()
static void delay (float f)
static float delay ()
static void disable ()
static void enable (bool b=true)
static bool enabled ()
static void enter (Widget *)
static void enter (Widget *, const Rectangle &, const char *text)
static void enter (Widget *, const Rectangle &, Generator, void *=0)
static void exit ()
static Tooltipinstance ()

Static Public Attributes

static NamedStyledefault_style


Detailed Description

This is the class of window that pops up to display a tooltip (with the yellow color and 1-pixel border).

In addition Toolip provides number of static functions for managing a single private instance, and making this pop up when the mouse is pointing at various rectangles in the GUI. FLTK calls these as the mouse moves between widgets, and a widget's handle() method can call these to present tooltips for various parts of itself.

You can change the appearance of the tooltips by modifying the contents of Tooltip::default_style.


Member Function Documentation

void Tooltip::layout (  )  [virtual]

void Tooltip::delay ( float  f  )  [inline, static]

Set the time (in seconds) before tooltips pop up after enter() is called. Any time less than .1 causes the tooltip to pop up instantly.

void Tooltip::enable ( bool  b = true  )  [inline, static]

If set to false tooltips never appear. Setting delay() really large will do the same thing, but this function is provided as most people find it more clear.

void Tooltip::disable (  )  [inline, static]

Same as enable(false);

void Tooltip::enter ( Widget widget,
const Rectangle rectangle,
Tooltip::Generator  generator,
void *  data = 0 
) [static]

Get ready to display a tooltip. The widget and the rectangle inside it define an area the tooltip is for. The mouse is assummed to currently be inside this rectangle.

After a timeout period a tooltip is created and it will appear at the edge of the rectangle. If enter() with a different widget, generator, or data is called, or exit() is called, the tooltip will not appear.

The generator callback is for deferring the calculation of the text until it is actually needed. Just before popping up the tooltip generator is called with the widget and data as arguments, and it should return a pointer to a static buffer containing the tooltip text. You can use '@' commands to insert arbitrary fltk::Symbol graphics into it. If generator returns NULL no tooltip will be popped up.

References fltk::Widget::add_timeout(), exit(), and fltk::Widget::remove_timeout().

Referenced by enter(), and fltk::handle().

void Tooltip::enter ( Widget widget,
const Rectangle rectangle,
const char *  text 
) [static]

Same as the previous enter() except the tooltip is defined by the string constant passed as text. The text must be in a static location that will still exist when the tooltip pops up!

If widget or text is NULL then exit() is done instead and no tooltip appears.

References enter(), and exit().

void Tooltip::enter ( Widget w  )  [static]

Locates either widget or the closest parent with an non-null Widget::tooltip() value and then does an enter() using this widget's area and that widget's tooltip(). If widget is NULL or there is no tooltip found then exit() is done instead.

This is automatically called by FLTK when Widget::below_mouse() is changed.

References enter(), exit(), fltk::Rectangle::h(), fltk::Widget::parent(), fltk::Rectangle::Rectangle(), fltk::Widget::tooltip(), and fltk::Rectangle::w().

void Tooltip::current ( Widget w  )  [static]

Acts as though enter(widget) was done but does not pop up a tooltip. However, this makes it ignore a subsequent call to enter() for this same widget. This is useful to prevent a tooltip from reappearing when a modal overlapping window is deleted. FLTK does this automatically when a popup window disappears.

References exit(), fltk::Widget::parent(), and fltk::Widget::tooltip().

void Tooltip::exit (  )  [static]

Indicate that the mouse is no longer pointing at a tooltip area. Makes any visible tooltip disappear and cancel any pending one. No tooltip will appear until after enter() is called again.

References fltk::Widget::add_timeout(), fltk::ANY_BUTTON, fltk::event_state(), and fltk::Widget::remove_timeout().

Referenced by current(), enter(), and fltk::handle().

Widget * Tooltip::current_widget (  )  [inline, static]

Last widget passed to enter(), or NULL if exit() was called.

Referenced by fltk::Widget::throw_focus().

const Rectangle & Tooltip::current_rectangle (  )  [inline, static]

Last rectangle passed to enter()

Tooltip::Generator Tooltip::current_generator (  )  [inline, static]

Last generator function passed to enter();

void * Tooltip::current_data (  )  [inline, static]

Last data for the generator function passed to enter().

Tooltip * Tooltip::instance (  )  [inline, static]

The Tooltip window that is used to display tooltips in response to enter(). This is NULL before the first tooltip is shown to the user.


Member Data Documentation

The Tooltip::default_style controls how the automatic tooltip appears. It defaults to the yellow color() and a box() of BORDER_BOX. You may also want to set the textfont(), textsize(), textcolor().

Reimplemented from fltk::MenuWindow.


Wed Jun 17 08:58:19 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.