Tooltip fixes: ignore keyboard events, immediately disable new tooltips,

show tooltips for box widgets.

Add docos for Fl_Widget::tooltip() methods.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2060 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-04-09 17:20:24 +00:00
parent 17374b20bb
commit 4586bf0fcc
7 changed files with 326 additions and 163 deletions

View File

@ -1,5 +1,10 @@
CHANGES IN FLTK 1.1.0b13 CHANGES IN FLTK 1.1.0b13
- Tooltips now appear for inactive and output widgets.
- Tooltips no longer steal keyboard events other than
ESCape.
- Tooltips are no longer delayed when moving between
adjacent widgets.
- fl_beep(FL_BEEP_DEFAULT) now uses the PC speaker under - fl_beep(FL_BEEP_DEFAULT) now uses the PC speaker under
Windows (0xFFFFFFFF) rather than an event sound. Windows (0xFFFFFFFF) rather than an event sound.
- The configure script didn't include the -mwindows or - The configure script didn't include the -mwindows or

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Tooltip.H,v 1.16.2.5 2002/01/01 15:11:28 easysw Exp $" // "$Id: Fl_Tooltip.H,v 1.16.2.6 2002/04/09 17:20:23 easysw Exp $"
// //
// Tooltip header file for the Fast Light Tool Kit (FLTK). // Tooltip header file for the Fast Light Tool Kit (FLTK).
// //
@ -30,17 +30,17 @@
#include <FL/Fl_Widget.H> #include <FL/Fl_Widget.H>
class Fl_TooltipBox; class Fl_Tooltip_Box;
class Fl_Menu_Window; class Fl_Tooltip_Window;
class FL_EXPORT Fl_Tooltip { class FL_EXPORT Fl_Tooltip {
friend class Fl_TooltipBox; friend class Fl_Tooltip_Box;
friend class Fl_Widget; friend class Fl_Widget;
static float delay_; static float delay_;
static Fl_TooltipBox *box; static Fl_Tooltip_Box *box;
static Fl_Menu_Window *window; static Fl_Tooltip_Window *window;
static Fl_Widget *widget; static Fl_Widget *widget;
static int shown; static int shown;
static unsigned color_; static unsigned color_;
@ -76,5 +76,5 @@ public:
#endif #endif
// //
// End of "$Id: Fl_Tooltip.H,v 1.16.2.5 2002/01/01 15:11:28 easysw Exp $". // End of "$Id: Fl_Tooltip.H,v 1.16.2.6 2002/04/09 17:20:23 easysw Exp $".
// //

View File

@ -69,10 +69,10 @@ to call <TT>redraw()</TT> after these. </P>
<LI><A href=#Fl_Widget.labelsize>labelsize</A></LI> <LI><A href=#Fl_Widget.labelsize>labelsize</A></LI>
<LI><A href=#Fl_Widget.labeltype>labeltype</A></LI> <LI><A href=#Fl_Widget.labeltype>labeltype</A></LI>
<LI><A href=#Fl_Widget.output>output</A></LI> <LI><A href=#Fl_Widget.output>output</A></LI>
<LI><A href=#Fl_Widget.parent>parent</A></LI>
</UL> </UL>
</TD><TD align=left valign=top> </TD><TD align=left valign=top>
<UL> <UL>
<LI><A href=#Fl_Widget.parent>parent</A></LI>
<LI><A href=#Fl_Widget.position>position</A></LI> <LI><A href=#Fl_Widget.position>position</A></LI>
<LI><A href=#Fl_Widget.redraw>redraw</A></LI> <LI><A href=#Fl_Widget.redraw>redraw</A></LI>
<LI><A href=#Fl_Widget.resize>resize</A></LI> <LI><A href=#Fl_Widget.resize>resize</A></LI>
@ -85,6 +85,7 @@ to call <TT>redraw()</TT> after these. </P>
</UL> </UL>
</TD><TD align=left valign=top> </TD><TD align=left valign=top>
<UL> <UL>
<LI><A href="#Fl_Widget.tooltip">tooltip</A></LI>
<LI><A href=#Fl_Widget.type>type</A></LI> <LI><A href=#Fl_Widget.type>type</A></LI>
<LI><A href=#Fl_Widget.user_data>user_data</A></LI> <LI><A href=#Fl_Widget.user_data>user_data</A></LI>
<LI><A href=#Fl_Widget.visible>visible</A></LI> <LI><A href=#Fl_Widget.visible>visible</A></LI>
@ -98,178 +99,268 @@ to call <TT>redraw()</TT> after these. </P>
</TD></TR> </TD></TR>
</TABLE> </TABLE>
</CENTER> </CENTER>
<H4><A NAME="Fl_Widget.Fl_Widget">Fl_Widget::Fl_Widget(int x, int y, int w, int h, const char*
<H4><A NAME="Fl_Widget.Fl_Widget">protected Fl_Widget::Fl_Widget(int x, int y, int w, int h, const char*
label=0);</A></H4> label=0);</A></H4>
This is the protected constructor for an Fl_Widget, but all derived
widgets have a matching public constructor. It takes a value for x(), <P>Creates a widget at the given position and size. The
y(), w(), h(), and an optional value for label(). <TT>Fl_Widget</TT> is a protected constructor, but all derived
widgets have a matching public constructor. It takes a value for
<TT>x()</TT>, <TT>y()</TT>, <TT>w()</TT>, <TT>h()</TT>, and an
optional value for <TT>label()</TT>.
<H4><A NAME="Fl_Widget.~Fl_Widget">virtual Fl_Widget::~Fl_Widget();</A></H4> <H4><A NAME="Fl_Widget.~Fl_Widget">virtual Fl_Widget::~Fl_Widget();</A></H4>
Destroying single widgets is not very common. It is your
responsibility to either remove() them from any enclosing group, or to <P>Destroys the widget. Destroying single widgets is not very
destroy that group <I>immediately</I> after destroying the children. common, and it is your responsibility to either
<TT>remove()</TT> them from any enclosing group or destroy that
group <I>immediately</I> after destroying the children. You
almost always want to destroy the parent group instead which
will destroy all of the child widgets and groups in that group.
<H4><A NAME="Fl_Widget.type">uchar Fl_Widget::type() const;</A></H4> <H4><A NAME="Fl_Widget.type">uchar Fl_Widget::type() const;</A></H4>
This value is used for Forms compatability and to simulate RTTI.
<P>Returns the widget type value, which is used for Forms
compatability and to simulate RTTI.
<H4><A name=Fl_Widget.x>short Fl_Widget::x() const</A> <H4><A name=Fl_Widget.x>short Fl_Widget::x() const</A>
<BR><A name=Fl_Widget.y>short Fl_Widget::y() const</A> <BR><A name=Fl_Widget.y>short Fl_Widget::y() const</A>
<BR><A name=Fl_Widget.w>short Fl_Widget::w() const</A> <BR><A name=Fl_Widget.w>short Fl_Widget::w() const</A>
<BR><A name=Fl_Widget.h>short Fl_Widget::h() const</A></H4> <BR><A name=Fl_Widget.h>short Fl_Widget::h() const</A></H4>
The position of the upper-left corner of the widget in its enclosing
Fl_Window (<I>not</I> its parent if that is not an Fl_Window), and its <P>Returns the position of the upper-left corner of the widget
width and height. in its enclosing Fl_Window (<I>not</I> its parent if that is not
an Fl_Window), and its width and height.
<H4><A name=Fl_Widget.resize>virtual void <H4><A name=Fl_Widget.resize>virtual void
Fl_Widget::resize(int x, int y, int w, int h)</A> Fl_Widget::resize(int x, int y, int w, int h)</A>
<BR><A name=Fl_Widget.position>void Fl_Widget::position(short x, short y)</A> <BR><A name=Fl_Widget.position>void Fl_Widget::position(short x, short y)</A>
<BR><A name=Fl_Widget.size>void Fl_Widget::size(short w, short h)</A></H4> <BR><A name=Fl_Widget.size>void Fl_Widget::size(short w, short h)</A></H4>
Change the size or position of the widget. This is a virtual function
so the widget may implement its own handling of resizing. The default <P>Change the size or position of the widget. This is a virtual
version does <I>not</I> do redraw(), that is the parent widget's function so that the widget may implement its own handling of
responsibility (this is because the parent may know a faster way to resizing. The default version does <I>not</I> call the
update the display, such as scrolling from the old position). <TT>redraw()</TT> method, but instead relies on the parent
<P><TT>position(x,y)</TT> is a shortcut for <TT>resize(x,y,w(),h())</TT> widget to do so because the parent may know a faster way to
, and <TT>size(w,h)</TT> is a shortcut for <TT>resize(x(),y(),w,h)</TT> update the display, such as scrolling from the old position.
. </P>
<P><TT>position(x,y)</TT> is a shortcut for <TT>resize(x,y,w(),h())</TT>,
and <TT>size(w,h)</TT> is a shortcut for <TT>resize(x(),y(),w,h)</TT>.</P>
<H4><A name=Fl_Widget.window>Fl_Window* Fl_Widget::window() const;</A></H4> <H4><A name=Fl_Widget.window>Fl_Window* Fl_Widget::window() const;</A></H4>
Return a pointer to the <A href=Fl_Window.html#Fl_Window><TT>Fl_Window</TT>
</A> that this widget is in (it will skip any and all parent widgets <P>Returns a pointer to the primary <A
between this and the window). Returns <TT>NULL</TT> if none. Note: href=Fl_Window.html#Fl_Window><TT>Fl_Window</TT></A> widget.
for an <TT>Fl_Window</TT>, this returns its <I>parent</I> window (if Returns <TT>NULL</TT> if no window is associated with this
any), not <I>this</I> window. widget. Note: for an <TT>Fl_Window</TT> widget, this returns
its <I>parent</I> window (if any), not <I>this</I> window.
<H4><A name=Fl_Widget.box>Fl_Boxtype Fl_Widget::box() const <H4><A name=Fl_Widget.box>Fl_Boxtype Fl_Widget::box() const
<BR> void Fl_Widget::box(Fl_Boxtype)</A></H4> <BR> void Fl_Widget::box(Fl_Boxtype)</A></H4>
The <TT>box()</TT> identifies a routine that draws the background of
the widget. See <A href="common.html#boxtypes">Box Types</A> for the <P>Gets or sets the box type for the widget, which identifies a
available types. The default depends on the widget, but is usually <TT> routine that draws the background of the widget. See <A
FL_NO_BOX</TT> or <TT>FL_UP_BOX</TT>. href="common.html#boxtypes">Box Types</A> for the available
types. The default depends on the widget, but is usually
<TT>FL_NO_BOX</TT> or <TT>FL_UP_BOX</TT>.
<H4><A name=Fl_Widget.color>Fl_Color Fl_Widget::color() const <H4><A name=Fl_Widget.color>Fl_Color Fl_Widget::color() const
<BR> void Fl_Widget::color(Fl_Color)</A></H4> <BR>void Fl_Widget::color(Fl_Color)
This color is passed to the box routine. Color is an index into an <BR>void Fl_Widget::color(Fl_Color, Fl_Color)</A></H4>
internal table of rgb colors. For most widgets this defaults to <TT>
FL_GRAY</TT>. See the <A href=enumerations.html#Enumerations> <P>Gets or sets the background color of the widget. The color is
enumeration list</A> for predefined colors. Use <A href="Fl.html#Fl.set_color"> passed to the box routine. The color is either an index into an
<TT>Fl::set_color()</TT></A> to redefine colors. internal table of RGB colors or an RGB color value generated
using <TT>fl_rgb_color()</TT>. The default for most widgets is
<TT>FL_GRAY</TT>. See the <A
href=enumerations.html#Enumerations>enumeration list</A> for
predefined colors. Use <A
href="Fl.html#Fl.set_color"><TT>Fl::set_color()</TT></A> to
redefine colors.
<P>The two color form sets both the background and selection
colors. See the description of the <A
HREF="#Fl_Widget.selection_color"><TT>selection_color()</TT></A>
method for more information.
<H4><A name=Fl_Widget.selection_color>Fl_Color <H4><A name=Fl_Widget.selection_color>Fl_Color
Fl_Widget::selection_color() const Fl_Widget::selection_color() const
<BR> void Fl_Widget::selection_color(Fl_Color)</A> <BR>void Fl_Widget::selection_color(Fl_Color)</A></H4>
<BR> void Fl_Widget::color(Fl_Color, Fl_Color)</H4>
For Forms compatibility a second color is defined. This is usually <P>Gets or sets the selection color, which is defined for Forms
used to color the widget when it is selected, although some widgets use compatibility and is usually used to color the widget when it is
this color for other purposes. You can set both colors at once with <TT> selected, although some widgets use this color for other
color(a,b)</TT>. purposes. You can set both colors at once with
<TT>color(a,b)</TT>.
<H4><A name=Fl_Widget.label>const char* Fl_Widget::label() const <H4><A name=Fl_Widget.label>const char* Fl_Widget::label() const
<BR> void Fl_Widget::label(const char*)</A></H4> <BR> void Fl_Widget::label(const char*)</A></H4>
The label is printed somewhere on the widget or next to it. The
string is <I>not</I> copied, the passed pointer is stored unchanged in <P>Get or set the current label pointer. The label is shown
the widget. somewhere on or next to the widget. The passed pointer is stored
unchanged in the widget (the string is <I>not</I> copied), so if
you need to set the label to a formatted value, make sure the
buffer is <TT>static</TT>, global, or allocated.
<H4><A name=Fl_Widget.labeltype>void Fl_Widget::label(Fl_Labeltype, <H4><A name=Fl_Widget.labeltype>void Fl_Widget::label(Fl_Labeltype,
const char*) const char*)
<BR> uchar Fl_Widget::labeltype() const <BR> uchar Fl_Widget::labeltype() const
<BR> void Fl_Widget::labeltype(Fl_Labeltype)</A></H4> <BR> void Fl_Widget::labeltype(Fl_Labeltype)</A></H4>
A <A href="common.html#labeltypes"><TT>labeltype</TT></A> identifies a routine that
draws the label of the widget. This can be used for special effects <P>Gets or sets the <A
such as emboss, or to use the <TT>label()</TT> pointer as another form href="common.html#labeltypes"><TT>labeltype</TT></A> which
of data such as a bitmap. The value <TT>FL_NORMAL_LABEL</TT> prints identifies the function that draws the label of the widget. This
the label as text. is generally used for special effects such as embossing or for
using the <TT>label()</TT> pointer as another form of data such
as an icon. The value <TT>FL_NORMAL_LABEL</TT> prints the label
as plain text.
<H4><A name=Fl_Widget.align>Fl_Align Fl_Widget::align() const <H4><A name=Fl_Widget.align>Fl_Align Fl_Widget::align() const
<BR> void Fl_Widget::align(Fl_Align)</A></H4> <BR> void Fl_Widget::align(Fl_Align)</A></H4>
How the label is printed next to or inside the widget. The default
value is <TT>FL_ALIGN_CENTER</TT>, which centers the label. The value <P>Gets or sets the label alignment, which controls how the
can be any of these constants or'd together: label is displayed next to or inside the widget. The default
value is <TT>FL_ALIGN_CENTER</TT>, which centers the label
inside the widget. The value can be any of these constants
bitwise-OR'd together:
<UL> <UL>
<LI><TT>FL_ALIGN_CENTER</TT></LI> <LI><TT>FL_ALIGN_BOTTOM</TT></LI>
<LI><TT>FL_ALIGN_TOP</TT></LI> <LI><TT>FL_ALIGN_CENTER</TT></LI>
<LI><TT>FL_ALIGN_BOTTOM</TT></LI> <LI><TT>FL_ALIGN_CLIP</TT></LI>
<LI><TT>FL_ALIGN_LEFT</TT></LI> <LI><TT>FL_ALIGN_INSIDE</TT></LI>
<LI><TT>FL_ALIGN_RIGHT</TT></LI> <LI><TT>FL_ALIGN_LEFT</TT></LI>
<LI><TT>FL_ALIGN_INSIDE</TT></LI> <LI><TT>FL_ALIGN_RIGHT</TT></LI>
<LI><TT>FL_ALIGN_CLIP</TT></LI> <LI><TT>FL_ALIGN_TEXT_OVER_IMAGE</TT></LI>
<LI><TT>FL_ALIGN_WRAP</TT></LI> <LI><TT>FL_ALIGN_TOP</TT></LI>
<LI><TT>FL_ALIGN_WRAP</TT></LI>
</UL> </UL>
<H4><A name=Fl_Widget.labelcolor>Fl_Color Fl_Widget::labelcolor() const <H4><A name=Fl_Widget.labelcolor>Fl_Color Fl_Widget::labelcolor() const
<BR> void Fl_Widget::labelcolor(Fl_Color)</A></H4> <BR> void Fl_Widget::labelcolor(Fl_Color)</A></H4>
This color is passed to the labeltype routine, and is typically the
color of the label text. This defaults to <TT>FL_BLACK</TT>. <P>Gets or sets the label color. The default color is <TT>FL_BLACK</TT>.
<H4><A name=Fl_Widget.labelfont>Fl_Font Fl_Widget::labelfont() const <H4><A name=Fl_Widget.labelfont>Fl_Font Fl_Widget::labelfont() const
<BR> void Fl_Widget::labelfont(Fl_Font)</A></H4> <BR> void Fl_Widget::labelfont(Fl_Font)</A></H4>
Fonts are identified by small 8-bit indexes into a table. See the <A href=enumerations.html#Enumerations>
enumeration list</A> for predefined typefaces. The default value uses a <P>Gets or sets the font to use. Fonts are identified by small
Helvetica typeface (Arial for Microsoft&reg; Windows&reg;). The function <A href="Fl.html#Fl.set_font"> 8-bit indexes into a table. See the <A
<TT>Fl::set_font() </TT></A> can define new typefaces. href=enumerations.html#Enumerations> enumeration list</A> for
predefined typefaces. The default value uses a Helvetica
typeface (Arial for Microsoft&reg; Windows&reg;). The function
<A href="Fl.html#Fl.set_font"><TT>Fl::set_font()</TT></A> can
define new typefaces.
<H4><A name=Fl_Widget.labelsize>uchar Fl_Widget::labelsize() const <H4><A name=Fl_Widget.labelsize>uchar Fl_Widget::labelsize() const
<BR> void Fl_Widget::labelsize(uchar)</A></H4> <BR>void Fl_Widget::labelsize(uchar)</A></H4>
Fonts are further identified by a point size. The default is 14.
<H4><A name=Fl_Widget.callback>typedef void (Fl_Callback)(Fl_Widget*, <P>Gets or sets the font size in pixels. The default size is 14
void*) pixels.
<BR> Fl_Callback* Fl_Widget::callback() const
<BR> void Fl_Widget::callback(Fl_Callback*, void* = 0)</A></H4> <H4><A name=Fl_Widget.callback>typedef void (Fl_Callback)(Fl_Widget*, void*)
Each widget has a single callback. You can set it or examine it with <BR>Fl_Callback* Fl_Widget::callback() const
these methods. <BR>void Fl_Widget::callback(Fl_Callback*, void* = 0)
<BR>void Fl_Widget::callback(void (*)(Fl_Widget*, long), long = 0)
<BR>void Fl_Widget::callback(void (*)(Fl_Widget*))</A></H4>
<P>Gets or sets the current callback function for the widget.
Each widget has a single callback.
<H4><A name=Fl_Widget.user_data>void* Fl_Widget::user_data() const <H4><A name=Fl_Widget.user_data>void* Fl_Widget::user_data() const
<BR> void Fl_Widget::user_data(void*)</A></H4> <BR>void Fl_Widget::user_data(void*)</A></H4>
You can also just change the <TT>void *</TT> second argument to the
callback with the <TT>user_data</TT> methods. <P>Gets or sets the current user data (<TT>void *</TT>) argument
<H4><A name=Fl_Widget.argument>void Fl_Widget::callback(void that is passed to the callback function.
(*)(Fl_Widget*, long), long = 0)
<BR> long Fl_Widget::argument() const <H4><A name=Fl_Widget.argument>long Fl_Widget::argument() const
<BR> void Fl_Widget::argument(long)</A></H4> <BR> void Fl_Widget::argument(long)</A></H4>
For convenience you can also define the callback as taking a long
argument. This is implemented by casting this to a <TT>Fl_Callback</TT> <P>Gets or sets the current user data (<TT>long</TT>) argument
and casting the <TT>long</TT> to a <TT>void *</TT> and may not be that is passed to the callback function.
portable to some machines.
<H4>void Fl_Widget::callback(void (*)(Fl_Widget*))</H4> <CENTER><TABLE BORDER="1" CELLPADDING="5" CELLSPACING="0" BGCOLOR="#cccccc">
For convenience you can also define the callback as taking only one <TR>
argument. This is implemented by casting this to a <TT>Fl_Callback</TT> <TD><B>Note:</B>
and may not be portable to some machines.
<P>This is implemented by casting the <TT>long</TT>
value to a <TT>void *</TT> and may not be portable on
some machines.
</TD>
</TR>
</TABLE></CENTER>
<H4><A name=Fl_Widget.do_callback>void Fl_Widget::do_callback() <H4><A name=Fl_Widget.do_callback>void Fl_Widget::do_callback()
<BR> void Fl_Widget::do_callback(Fl_Widget*, void* = 0) <BR> void Fl_Widget::do_callback(Fl_Widget*, void* = 0)
<BR> void Fl_Widget::do_callback(Fl_Widget*, long)</A></H4> <BR> void Fl_Widget::do_callback(Fl_Widget*, long)</A></H4>
You can cause a widget to do its callback at any time, and even pass
arbitrary arguments. <P>Causes a widget to invoke its callback function, optionally
with arbitrary arguments.
<H4><A name=Fl_Widget.changed>int Fl_Widget::changed() const</A> <H4><A name=Fl_Widget.changed>int Fl_Widget::changed() const</A>
<BR><A name=Fl_Widget.set_changed>void Fl_Widget::set_changed()</A> <BR><A name=Fl_Widget.set_changed>void Fl_Widget::set_changed()</A>
<BR><A name=Fl_Widget.clear_changed>void Fl_Widget::clear_changed()</A></H4> <BR><A name=Fl_Widget.clear_changed>void Fl_Widget::clear_changed()</A></H4>
<TT>Fl_Widget::changed()</TT> is a flag that is turned on when the user
changes the value stored in the widget. This is only used by <P><TT>Fl_Widget::changed()</TT> is a flag that is turned on
subclasses of <TT>Fl_Widget</TT> that store values, but is in the base when the user changes the value stored in the widget. This is
class so it is easier to scan all the widgets in a panel and <TT> only used by subclasses of <TT>Fl_Widget</TT> that store values,
do_callback()</TT> on the changed ones in response to an &quot;OK&quot; button. but is in the base class so it is easier to scan all the widgets
in a panel and <TT> do_callback()</TT> on the changed ones in
response to an &quot;OK&quot; button.
<P>Most widgets turn this flag off when they do the callback, and when <P>Most widgets turn this flag off when they do the callback, and when
the program sets the stored value. </P> the program sets the stored value. </P>
<H4><A name=Fl_Widget.when>Fl_When Fl_Widget::when() const <H4><A name=Fl_Widget.when>Fl_When Fl_Widget::when() const
<BR> void Fl_Widget::when(Fl_When)</A></H4> <BR> void Fl_Widget::when(Fl_When)</A></H4>
<TT>Fl_Widget::when()</TT> is a set of bitflags used by subclasses of <TT>
Fl_Widget</TT> to decide when to do the callback. If the value is zero <P><TT>Fl_Widget::when()</TT> is a set of bitflags used by
then the callback is never done. Other values are described in the subclasses of <TT> Fl_Widget</TT> to decide when to do the
individual widgets. This field is in the base class so that you can callback. If the value is zero then the callback is never
scan a panel and <TT>do_callback()</TT> on all the ones that don't do done. Other values are described in the individual widgets.
their own callbacks in response to an &quot;OK&quot; button. This field is in the base class so that you can scan a panel and
<TT>do_callback()</TT> on all the ones that don't do their own
callbacks in response to an &quot;OK&quot; button.
<H4><A name=Fl_Widget.default_callback>static void <H4><A name=Fl_Widget.default_callback>static void
Fl_Widget::default_callback(Fl_Widget*, void*)</A></H4> Fl_Widget::default_callback(Fl_Widget*, void*)</A></H4>
The default callback, which puts a pointer to the widget on the queue
returned by <A href="Fl.html#Fl.readqueue"><TT>Fl::readqueue()</TT></A> <P>The default callback, which puts a pointer to the widget on
. You may want to call this from your own callback. the queue returned by <A
href="Fl.html#Fl.readqueue"><TT>Fl::readqueue()</TT></A>. You
may want to call this from your own callback.
<H4><A name=Fl_Widget.visible>int Fl_Widget::visible() const</A><BR> <H4><A name=Fl_Widget.visible>int Fl_Widget::visible() const</A><BR>
<A name=Fl_Widget.visible_r>int Fl_Widget::visible_r() const</A><BR> <A name=Fl_Widget.visible_r>int Fl_Widget::visible_r() const</A><BR>
<A name=Fl_Widget.show>void Fl_Widget::show()</A><BR> <A name=Fl_Widget.show>void Fl_Widget::show()</A><BR>
<A name=Fl_Widget.hide>void Fl_Widget::hide()</A></H4> <A name=Fl_Widget.hide>void Fl_Widget::hide()</A></H4>
An invisible widget never gets redrawn and does not get events. The
<TT>visible()</TT> method returns true if the widget is set to be <P>An invisible widget never gets redrawn and does not get
visible.The <TT>visible_r()</TT> method returns true if the widget and events. The <TT>visible()</TT> method returns true if the
all of its parents are visible. A widget is only visible if widget is set to be visible.The <TT>visible_r()</TT> method
<TT>visible()</TT> is true on it <I>and all of its parents</I>. returns true if the widget and all of its parents are visible. A
widget is only visible if <TT>visible()</TT> is true on it
<I>and all of its parents</I>.
<P>Changing it will send <TT>FL_SHOW</TT> or <TT>FL_HIDE</TT> <P>Changing it will send <TT>FL_SHOW</TT> or <TT>FL_HIDE</TT>
events to the widget. <I>Do not change it if the parent is not events to the widget. <I>Do not change it if the parent is not
visible, as this will send false <TT>FL_SHOW</TT> or <TT>FL_HIDE</TT> visible, as this will send false <TT>FL_SHOW</TT> or <TT>FL_HIDE</TT>
events to the widget</I>. <TT>redraw()</TT> is called if necessary on events to the widget</I>. <TT>redraw()</TT> is called if necessary on
this or the parent. this or the parent.
<H4><A name=Fl_Widget.active>int Fl_Widget::active() const</A><BR> <H4><A name=Fl_Widget.active>int Fl_Widget::active() const</A><BR>
<A name=Fl_Widget.active_r>int Fl_Widget::active_r() const</A></BR> <A name=Fl_Widget.active_r>int Fl_Widget::active_r() const</A></BR>
<A name=Fl_Widget.activate>void Fl_Widget::activate()</A></BR> <A name=Fl_Widget.activate>void Fl_Widget::activate()</A></BR>
<A name=Fl_Widget.deactivate>void Fl_Widget::deactivate()</A></H4> <A name=Fl_Widget.deactivate>void Fl_Widget::deactivate()</A></H4>
<TT>Fl_Widget::active()</TT> returns whether the widget is active.
<TT>Fl_Widget::active_r()</TT> returns whether the widget and all of <P><TT>Fl_Widget::active()</TT> returns whether the widget is
its parents are active. An inactive widget does not get any events, active. <TT>Fl_Widget::active_r()</TT> returns whether the
but it does get redrawn. A widget is only active if <TT>active()</TT> is widget and all of its parents are active. An inactive widget
true on it <I>and all of its parents</I>. does not get any events, but it does get redrawn. A widget is
only active if <TT>active()</TT> is true on it <I>and all of its
parents</I>.
<P>Changing this value will send <TT>FL_ACTIVATE</TT> or <TT> <P>Changing this value will send <TT>FL_ACTIVATE</TT> or <TT>
FL_DEACTIVATE</TT> to the widget if <tt>active_r()</tt> is true. FL_DEACTIVATE</TT> to the widget if <tt>active_r()</tt> is true.
<P>Currently you cannot deactivate <TT>Fl_Window</TT> widgets. </P> <P>Currently you cannot deactivate <TT>Fl_Window</TT> widgets. </P>
@ -277,34 +368,47 @@ FL_DEACTIVATE</TT> to the widget if <tt>active_r()</tt> is true.
<H4><A name=Fl_Widget.output>int Fl_Widget::output() const</A><BR> <H4><A name=Fl_Widget.output>int Fl_Widget::output() const</A><BR>
<A name=Fl_Widget.set_output>void Fl_Widget::set_output()</A></BR> <A name=Fl_Widget.set_output>void Fl_Widget::set_output()</A></BR>
<A name=Fl_Widget.clear_output>void Fl_Widget::clear_output()</A></H4> <A name=Fl_Widget.clear_output>void Fl_Widget::clear_output()</A></H4>
<tt>output()</tt> means the same as <tt>!active()</tt> except it does
not change how the widget is drawn. The widget will not receive any
events. This is useful for making scrollbars or buttons that work as
displays rather than input devices.
<H4><A name=Fl_Widget.takesevents>int Fl_Widget::takesevents() const</A> <P><tt>output()</tt> means the same as <tt>!active()</tt> except
</H4> it does not change how the widget is drawn. The widget will not
This is the same as <TT>(active() &amp;&amp; visible() &amp;&amp; receive any events. This is useful for making scrollbars or
buttons that work as displays rather than input devices.
<H4><A name=Fl_Widget.takesevents>int Fl_Widget::takesevents() const</A></H4>
<P>This is the same as <TT>(active() &amp;&amp; visible() &amp;&amp;
!output())</TT> but is faster. !output())</TT> but is faster.
<H4><A name=Fl_Widget.redraw>void Fl_Widget::redraw()</A></H4> <H4><A name=Fl_Widget.redraw>void Fl_Widget::redraw()</A></H4>
Mark the widget as needing its <A HREF="subclassing.html#draw"><TT>draw()</TT></A> routine called.
<P>Marks the widget as needing its <A
HREF="subclassing.html#draw"><TT>draw()</TT></A> routine called.
<H4><A name=Fl_Widget.damage>uchar Fl_Widget::damage() const</A></H4> <H4><A name=Fl_Widget.damage>uchar Fl_Widget::damage() const</A></H4>
Non-zero if <A HREF="subclassing.html#draw"><TT>draw()</TT></A> needs to be called. Actually this is a
bit field that the widget subclass can use to figure out what parts to <P>Non-zero if <A
draw. HREF="subclassing.html#draw"><TT>draw()</TT></A> needs to be
called. The damage value is actually a bit field that the widget
subclass can use to figure out what parts to draw.
<H4><A name=Fl_Widget.parent>Fl_Group *Fl_Widget::parent() const</A></H4> <H4><A name=Fl_Widget.parent>Fl_Group *Fl_Widget::parent() const</A></H4>
Returns a pointer to the parent widget. Usually this is a <A
<P>Returns a pointer to the parent widget. Usually this is a <A
href=Fl_Group.html#Fl_Group> <TT>Fl_Group</TT></A> or <A href=Fl_Group.html#Fl_Group> <TT>Fl_Group</TT></A> or <A
HREF="Fl_Window.html#Fl_Window"><tt>Fl_Window</tt></a>. Returns HREF="Fl_Window.html#Fl_Window"><tt>Fl_Window</tt></a>. Returns
<tt>NULL</tt> if none. <tt>NULL</tt> if the widget has no parent.
<h4><a name="Fl_Widget.contains">int Fl_Widget::contains(Fl_Widget* b) const</A></H4> <h4><a name="Fl_Widget.contains">int Fl_Widget::contains(Fl_Widget* b) const</A></H4>
Returns true if <TT>b</TT> is a child of this widget, or is equal to
this widget. Returns false if <TT>b</TT> is <TT>NULL</TT>. <P>Returns 1 if <TT>b</TT> is a child of this widget, or is
equal to this widget. Returns 0 if <TT>b</TT> is <TT>NULL</TT>.
<H4><A name=Fl_Widget.inside>int Fl_Widget::inside(const Fl_Widget* a) <H4><A name=Fl_Widget.inside>int Fl_Widget::inside(const Fl_Widget* a)
const</A></H4> const</A></H4>
Returns true if this is a child of <TT>a</TT>, or is equal to <TT>a</TT>
. Returns false if <TT>a</TT> is <TT>NULL</TT>. <P>Returns 1 if this widget is a child of <TT>a</TT>, or is
equal to <TT>a</TT>. Returns 0 if <TT>a</TT> is <TT>NULL</TT>.
<H4><A name=Fl_Widget.take_focus>int Fl_Widget::take_focus()</A></H4> <H4><A name=Fl_Widget.take_focus>int Fl_Widget::take_focus()</A></H4>
Tries to make this widget be the <TT>Fl::focus()</TT> widget, by first Tries to make this widget be the <TT>Fl::focus()</TT> widget, by first
sending it an <TT>FL_FOCUS</TT> event, and if it returns non-zero, sending it an <TT>FL_FOCUS</TT> event, and if it returns non-zero,
@ -316,10 +420,30 @@ accepted the focus.
void Fl_Widget::deimage(Fl_Image* a)<BR> void Fl_Widget::deimage(Fl_Image* a)<BR>
void Fl_Widget::deimage(Fl_Image&amp; a)</H4> void Fl_Widget::deimage(Fl_Image&amp; a)</H4>
<P>Gets or sets the image to use as part of the widget label.
This image is used when drawing the widget in the inactive
state.
<H4><A name="Fl_Widget.image">Fl_Image* Fl_Widget::image()</A><BR> <H4><A name="Fl_Widget.image">Fl_Image* Fl_Widget::image()</A><BR>
void Fl_Widget::image(Fl_Image* a)<BR> void Fl_Widget::image(Fl_Image* a)<BR>
void Fl_Widget::image(Fl_Image&amp; a)</H4> void Fl_Widget::image(Fl_Image&amp; a)</H4>
<H4><A name="Fl_Widget.handle">int Fl_Widget::handle(int)</A></H4> <P>Gets or sets the image to use as part of the widget label.
This image is used when drawing the widget in the active state.
</BODY></HTML> <H4><A name="Fl_Widget.tooltip">const char *Fl_Widget::tooltip()<BR>
void Fl_Widget::tooltip(const char *t)</A></H4>
<P>Gets or sets a string of text to display in a popup tooltip
window when the user hovers the mouse over the widget. The
string is <I>not</I> copied, so make sure any formatted string
is stored in a <TT>static</TT>, global, or allocated buffer.
<H4><A name="Fl_Widget.handle">virtual int Fl_Widget::handle(int event)</A></H4>
<P>Handles the specified event. You normally don't call this
method directly, but instead let FLTK do it when the user
interacts with the widget.
</BODY>
</HTML>

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Box.cxx,v 1.4.2.3.2.1 2002/01/01 15:11:29 easysw Exp $" // "$Id: Fl_Box.cxx,v 1.4.2.3.2.2 2002/04/09 17:20:23 easysw Exp $"
// //
// Box widget for the Fast Light Tool Kit (FLTK). // Box widget for the Fast Light Tool Kit (FLTK).
// //
@ -26,13 +26,11 @@
#include <FL/Fl_Widget.H> #include <FL/Fl_Widget.H>
#include <FL/Fl_Box.H> #include <FL/Fl_Box.H>
// MRS - shouldn't we inline this?
void Fl_Box::draw() { void Fl_Box::draw() {
draw_box(); draw_box();
draw_label(); draw_label();
} }
// //
// End of "$Id: Fl_Box.cxx,v 1.4.2.3.2.1 2002/01/01 15:11:29 easysw Exp $". // End of "$Id: Fl_Box.cxx,v 1.4.2.3.2.2 2002/04/09 17:20:23 easysw Exp $".
// //

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Group.cxx,v 1.8.2.8.2.11 2002/02/24 17:52:17 matthiaswm Exp $" // "$Id: Fl_Group.cxx,v 1.8.2.8.2.12 2002/04/09 17:20:23 easysw Exp $"
// //
// Group widget for the Fast Light Tool Kit (FLTK). // Group widget for the Fast Light Tool Kit (FLTK).
// //
@ -28,6 +28,7 @@
// Fl_Window itself is a subclass of this, and most of the event // Fl_Window itself is a subclass of this, and most of the event
// handling is designed so windows themselves work correctly. // handling is designed so windows themselves work correctly.
#include <stdio.h>
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/Fl_Group.H> #include <FL/Fl_Group.H>
#include <FL/Fl_Window.H> #include <FL/Fl_Window.H>
@ -158,10 +159,11 @@ int Fl_Group::handle(int event) {
case FL_ENTER: case FL_ENTER:
Fl_Tooltip::enter(this); // tooltip Fl_Tooltip::enter(this); // tooltip
case FL_MOVE: case FL_MOVE:
for (i = children(); i--;) { for (i = children(); i--;) {
o = a[i]; o = a[i];
if (o->takesevents() && Fl::event_inside(o)) { if (o->visible() && Fl::event_inside(o)) {
if (o->contains(Fl::belowmouse())) { if (o->contains(Fl::belowmouse())) {
return send(o,FL_MOVE); return send(o,FL_MOVE);
} else if (send(o,FL_ENTER)) { } else if (send(o,FL_ENTER)) {
@ -239,13 +241,13 @@ int Fl_Group::handle(int event) {
default: default:
// For all other events, try to give to each child, starting at focus: // For all other events, try to give to each child, starting at focus:
for (i = 0; i < children(); i ++) for (i = 0; i < children(); i ++)
if (Fl::focus_ == child(i)) break; if (Fl::focus_ == a[i]) break;
if (i >= children()) i = 0; if (i >= children()) i = 0;
if (children()) { if (children()) {
for (int j = i;;) { for (int j = i;;) {
if (send(child(j), event)) return 1; if (send(a[j], event)) return 1;
j++; j++;
if (j >= children()) j = 0; if (j >= children()) j = 0;
if (j == i) break; if (j == i) break;
@ -585,5 +587,5 @@ void Fl_Group::draw_outside_label(const Fl_Widget& w) const {
} }
// //
// End of "$Id: Fl_Group.cxx,v 1.8.2.8.2.11 2002/02/24 17:52:17 matthiaswm Exp $". // End of "$Id: Fl_Group.cxx,v 1.8.2.8.2.12 2002/04/09 17:20:23 easysw Exp $".
// //

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Tooltip.cxx,v 1.38.2.10 2002/01/01 15:11:31 easysw Exp $" // "$Id: Fl_Tooltip.cxx,v 1.38.2.11 2002/04/09 17:20:24 easysw Exp $"
// //
// Tooltip source file for the Fast Light Tool Kit (FLTK). // Tooltip source file for the Fast Light Tool Kit (FLTK).
// //
@ -38,8 +38,8 @@
void (*Fl_Tooltip::tooltip_callback_)(void *) = Fl_Tooltip::tooltip_timeout; void (*Fl_Tooltip::tooltip_callback_)(void *) = Fl_Tooltip::tooltip_timeout;
void (*Fl_Tooltip::tooltip_exit_)(void *) = (void (*)(void *))Fl_Tooltip::tooltip_exit; void (*Fl_Tooltip::tooltip_exit_)(void *) = (void (*)(void *))Fl_Tooltip::tooltip_exit;
float Fl_Tooltip::delay_ = 0.5; float Fl_Tooltip::delay_ = 0.5;
Fl_TooltipBox *Fl_Tooltip::box = 0; Fl_Tooltip_Box *Fl_Tooltip::box = 0;
Fl_Menu_Window *Fl_Tooltip::window = 0; Fl_Tooltip_Window *Fl_Tooltip::window = 0;
Fl_Widget *Fl_Tooltip::widget = 0; Fl_Widget *Fl_Tooltip::widget = 0;
int Fl_Tooltip::shown = 0; int Fl_Tooltip::shown = 0;
unsigned Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1, unsigned Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
@ -49,21 +49,45 @@ int Fl_Tooltip::font_ = FL_HELVETICA;
int Fl_Tooltip::size_ = FL_NORMAL_SIZE; int Fl_Tooltip::size_ = FL_NORMAL_SIZE;
//
// Tooltip window class...
//
class Fl_Tooltip_Window : public Fl_Menu_Window {
public:
FL_EXPORT ~Fl_Tooltip_Window() {}
Fl_Tooltip_Window(int W, int H, const char *l = 0)
: Fl_Menu_Window(W,H,l) {}
Fl_Tooltip_Window(int X, int Y, int W, int H, const char *l = 0)
: Fl_Menu_Window(X,Y,W,H,l) {}
virtual FL_EXPORT int handle(int event);
};
int
Fl_Tooltip_Window::handle(int event) {
if (event == FL_KEYDOWN || event == FL_KEYUP || event == FL_SHORTCUT) return 0;
else return Fl_Menu_Window::handle(event);
}
// //
// Tooltip label class... // Tooltip label class...
// //
class Fl_TooltipBox : public Fl_Box { class Fl_Tooltip_Box : public Fl_Box {
public: public:
Fl_TooltipBox() : Fl_Box(0,0,10,10) { Fl_Tooltip_Box() : Fl_Box(0,0,10,10) {
color(Fl_Tooltip::color_); color(Fl_Tooltip::color_);
align(FL_ALIGN_CENTER); align(FL_ALIGN_CENTER);
box(FL_BORDER_BOX); box(FL_BORDER_BOX);
Fl_Tooltip::widget = 0; Fl_Tooltip::widget = 0;
} }
~Fl_TooltipBox() { } ~Fl_Tooltip_Box() { }
void draw() { void draw() {
tooltip(0); // Just in case tooltip(0); // Just in case
@ -110,6 +134,12 @@ public:
// when the pointer enters them // when the pointer enters them
void void
Fl_Tooltip::enter(Fl_Widget *w) { Fl_Tooltip::enter(Fl_Widget *w) {
// printf("Fl_Tooltip::enter(%p)\n", w);
// if (w) {
// printf(" label() = \"%s\"\n", w->label() ? w->label() : "(null)");
// printf(" visible() = %d\n", w->visible());
// printf(" active() = %d\n", w->active());
// }
if ((!w || !w->tooltip()) && tooltip_callback_ && window) { if ((!w || !w->tooltip()) && tooltip_callback_ && window) {
Fl::remove_timeout(tooltip_callback_); Fl::remove_timeout(tooltip_callback_);
window->hide(); window->hide();
@ -118,7 +148,8 @@ Fl_Tooltip::enter(Fl_Widget *w) {
} }
if (!tooltip_callback_ || !w || !w->tooltip()) return; if (!tooltip_callback_ || !w || !w->tooltip()) return;
Fl::remove_timeout(tooltip_callback_); Fl::remove_timeout(tooltip_callback_);
Fl::add_timeout(delay_, tooltip_callback_, w); if (window && window->shown()) (*tooltip_callback_)(w);
else Fl::add_timeout(delay_, tooltip_callback_, w);
} }
@ -153,13 +184,13 @@ Fl_Tooltip::tooltip_timeout(void *v) {
if (!window) { if (!window) {
Fl_Group* saveCurrent = Fl_Group::current(); Fl_Group* saveCurrent = Fl_Group::current();
Fl_Group::current(0); Fl_Group::current(0);
window = new Fl_Menu_Window(0, 0, 10, 10, 0); window = new Fl_Tooltip_Window(0, 0, 10, 10, 0);
window->clear_border(); window->clear_border();
window->box(FL_NO_BOX); window->box(FL_NO_BOX);
window->set_override(); window->set_override();
window->begin(); window->begin();
box = new Fl_TooltipBox; box = new Fl_Tooltip_Box;
box->color(FL_YELLOW); box->color(FL_YELLOW);
box->align(FL_ALIGN_CENTER); box->align(FL_ALIGN_CENTER);
window->resizable(box); window->resizable(box);
@ -189,5 +220,5 @@ Fl_Tooltip::tooltip_timeout(void *v) {
// //
// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.10 2002/01/01 15:11:31 easysw Exp $". // End of "$Id: Fl_Tooltip.cxx,v 1.38.2.11 2002/04/09 17:20:24 easysw Exp $".
// //

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.14 2002/01/07 20:40:02 easysw Exp $" // "$Id: Fl_Widget.cxx,v 1.5.2.4.2.15 2002/04/09 17:20:24 easysw Exp $"
// //
// Base widget class for the Fast Light Tool Kit (FLTK). // Base widget class for the Fast Light Tool Kit (FLTK).
// //
@ -68,7 +68,10 @@ Fl_Widget *Fl::readqueue() {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
int Fl_Widget::handle(int) {return 0;} int Fl_Widget::handle(int event) {
if (event == FL_ENTER || event == FL_LEAVE) return 1;
else return 0;
}
int FL_NORMAL_SIZE = 14; int FL_NORMAL_SIZE = 14;
@ -248,5 +251,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const {
} }
// //
// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.14 2002/01/07 20:40:02 easysw Exp $". // End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.15 2002/04/09 17:20:24 easysw Exp $".
// //