First bunch of changes for the 1.1 branch - tooltips.

NOTE: looking into a problem with the tooltip not going away when
you ESCape a window (close it)...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1514 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2001-08-01 21:24:49 +00:00
parent 3cb5ebe0e8
commit bd06913057
13 changed files with 370 additions and 262 deletions

49
CHANGES
View File

@ -1,4 +1,51 @@
CHANGES SINCE FLTK 1.0.11
CHANGES IN FLTK 1.1.0
TODO - Added new image(), active_image(), and
inactive_image() methods to support image + text
labels more easily.
TODO - Added new alignment bit FL_ALIGN_TEXT_OVER_IMAGE.
- Added tooltip support using Jacques Tremblay's tooltip
patch.
TODO - Added keyboard navigation to all widgets.
PARTIAL - Added support for mouse wheels using the new
FL_MOUSEWHEEL event type.
TODO - Added the Fl_Check_Browser, Fl_FileBrowser,
Fl_FileChooser, Fl_FileIcon, Fl_HelpDialog,
Fl_HelpView, Fl_Tree_Browser, and Fl_Wizard widgets
from the bazaar.
TODO - Added 2.0 Fl_Text_Display and Fl_Text_Editor widgets
based on NEdit.
TODO - The Fl_Choice widget now looks more line a combo box
than a Motif option menu.
TODO - Moved the OpenGL widgets into a separate library
called fltkgl - this eliminates shared library
dependencies on OpenGL when no OpenGL functionality is
used/required.
TODO - Colors are now 32 bits in FLTK, allowing the use and
selection of 24-bit RGB values or 8-bit FLTK indexed
colors.
TODO - FLUID now supports the new Fl_CheckBrowser,
Fl_FileBrowser, Fl_FileIcon, Fl_HelpView,
Fl_Text_Display, Fl_Text_Editor, Fl_Tree_Browser, and
Fl_Wizard widgets.
TODO - Documentation updates.
TODO - Updated configure stuff to support shared libraries
under AIX (link to -lfltk_s)
TODO - Symbol labels can now contain regular text and
Fl_Browser font and color controls.
- Fl_Menu_Item::add() didn't use the flags that were
passed in.

View File

@ -1,5 +1,5 @@
//
// "$Id: Enumerations.H,v 1.18.2.14 2001/01/22 15:13:37 easysw Exp $"
// "$Id: Enumerations.H,v 1.18.2.14.2.1 2001/08/01 21:24:48 easysw Exp $"
//
// Enumerations for the Fast Light Tool Kit (FLTK).
//
@ -55,8 +55,8 @@
//
#define FL_MAJOR_VERSION 1
#define FL_MINOR_VERSION 0
#define FL_PATCH_VERSION 11
#define FL_MINOR_VERSION 1
#define FL_PATCH_VERSION 0
#define FL_VERSION ((double)FL_MAJOR_VERSION + \
(double)FL_MINOR_VERSION * 0.01 + \
(double)FL_PATCH_VERSION * 0.0001)
@ -82,7 +82,8 @@ enum Fl_Event { // events
FL_HIDE = 15,
FL_SHOW = 16,
FL_PASTE = 17,
FL_SELECTIONCLEAR = 18
FL_SELECTIONCLEAR = 18,
FL_MOUSEWHEEL = 19
};
enum Fl_When { // Fl_Widget::when():
@ -371,5 +372,5 @@ enum Fl_Damage {
#endif
//
// End of "$Id: Enumerations.H,v 1.18.2.14 2001/01/22 15:13:37 easysw Exp $".
// End of "$Id: Enumerations.H,v 1.18.2.14.2.1 2001/08/01 21:24:48 easysw Exp $".
//

View File

@ -1,9 +1,9 @@
//
// "$Id: Fl_Tooltip.H,v 1.16 2001/02/25 01:41:19 clip Exp $"
// "$Id: Fl_Tooltip.H,v 1.16.2.1 2001/08/01 21:24:48 easysw Exp $"
//
// Tooltip definitions for the Fast Light Tool Kit (FLTK).
// Tooltip header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-1999 by Bill Spitzak and others.
// Copyright 1998-2001 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@ -20,53 +20,60 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@easysw.com".
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//
#ifndef _FL_TOOLTIP_H_
#define _FL_TOOLTIP_H_
#ifndef _Fl_Tooltip_H_
#define _Fl_Tooltip_H_
#include <FL/Fl.H>
#include <FL/Fl_Widget.H>
class FL_API Fl_Tooltip {
public:
static float delay() { return delay_; }
static void delay(float f) { delay_ = f; }
static int enabled() { return enabled_; }
static void enable(int b = 1) { enabled_ = b; }
static void disable() { enable(0); }
// This is called when the pointer enters a widget,
// Also enter(0) gets rid of any displayed or pending tooltip:
static void (*enter)(Fl_Widget* w);
class Fl_TooltipBox;
class Fl_Menu_Window;
// A widget may also pop up tooltips for internal parts by calling this:
static void (*enter_area)(Fl_Widget* w, int X, int Y, int W, int H, const char* tip);
FL_EXPORT class Fl_Tooltip {
// This is called when a widget is destroyed or hidden:
static void (*exit)(Fl_Widget *w);
friend class Fl_TooltipBox;
friend class Fl_Widget;
static Fl_Style* style() { return default_style; }
static Fl_Font font() { return style()->label_font; }
static void font(Fl_Font i) { style()->label_font = i; }
static unsigned size() { return style()->label_size; }
static void size(unsigned s) { style()->label_size = s; }
static void color(Fl_Color c) { style()->color = c; }
static Fl_Color color() { return style()->color; }
static void textcolor(Fl_Color c) {style()->label_color = c; }
static Fl_Color textcolor() { return style()->label_color; }
static void boxtype(Fl_Boxtype b) {style()->box = b; }
static Fl_Boxtype boxtype() { return style()->box; }
private:
static Fl_Named_Style* default_style;
static float delay_;
static int enabled_;
static Fl_TooltipBox *box;
static Fl_Menu_Window *window;
static Fl_Widget *widget;
static int shown;
static uchar color_;
static int font_;
static int size_;
static void tooltip_timeout(void *);
static void tooltip_exit(Fl_Widget *);
static void (*tooltip_callback_)(void *);
static void (*tooltip_exit_)(void *);
public:
// These functions are user-called functions
static float tooltip_delay() { return delay_; }
static void tooltip_delay(float f) { delay_ = (f < 0.1) ? 0.1 : f; }
static int font() { return font_; }
static int size() { return size_; }
static void font(int i) { font_ = i; }
static void size(int s) { size_ = s; }
static void color(uchar c) { color_ = c; }
static uchar color() { return color_; }
static void enter(Fl_Widget *w);
static void exit(Fl_Widget *w);
static void enable() {tooltip_callback_ = tooltip_timeout; tooltip_exit_ = (void (*)(void *))tooltip_exit;}
static void disable() {tooltip_callback_ = 0; tooltip_exit_ = 0;}
};
#endif
//
// End of "$Id: Fl_Tooltip.H,v 1.16 2001/02/25 01:41:19 clip Exp $".
// End of "$Id: Fl_Tooltip.H,v 1.16.2.1 2001/08/01 21:24:48 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget.H,v 1.6.2.4 2001/01/22 15:13:38 easysw Exp $"
// "$Id: Fl_Widget.H,v 1.6.2.4.2.1 2001/08/01 21:24:48 easysw Exp $"
//
// Widget header file for the Fast Light Tool Kit (FLTK).
//
@ -27,6 +27,7 @@
#define Fl_Widget_H
#include "Enumerations.H"
#include "Fl_Tooltip.H"
class Fl_Widget;
class Fl_Window;
@ -46,7 +47,7 @@ struct Fl_Label {
FL_EXPORT void measure(int&, int&) const ;
};
class Fl_Widget {
FL_EXPORT class Fl_Widget {
friend class Fl_Group;
Fl_Widget* parent_;
@ -63,6 +64,8 @@ class Fl_Widget {
uchar align_;
uchar when_;
const char *tooltip_;
// "de-implement" the copy constructors:
Fl_Widget & operator=(const Fl_Widget &);
FL_EXPORT Fl_Widget(const Fl_Widget &);
@ -89,98 +92,100 @@ protected:
public:
virtual FL_EXPORT ~Fl_Widget();
virtual ~Fl_Widget();
virtual FL_EXPORT void draw() = 0;
virtual FL_EXPORT int handle(int);
FL_EXPORT Fl_Widget* parent() const {return parent_;}
FL_EXPORT void parent(Fl_Widget* w) {parent_ = w;} // for hacks only
virtual void draw() = 0;
virtual int handle(int);
Fl_Widget* parent() const {return parent_;}
void parent(Fl_Widget* w) {parent_ = w;} // for hacks only
FL_EXPORT uchar type() const {return type_;}
FL_EXPORT void type(uchar t) {type_ = t;}
uchar type() const {return type_;}
void type(uchar t) {type_ = t;}
FL_EXPORT int x() const {return x_;}
FL_EXPORT int y() const {return y_;}
FL_EXPORT int w() const {return w_;}
FL_EXPORT int h() const {return h_;}
virtual FL_EXPORT void resize(int,int,int,int);
FL_EXPORT int damage_resize(int,int,int,int);
FL_EXPORT void position(int X,int Y) {resize(X,Y,w_,h_);}
FL_EXPORT void size(int W,int H) {resize(x_,y_,W,H);}
int x() const {return x_;}
int y() const {return y_;}
int w() const {return w_;}
int h() const {return h_;}
virtual void resize(int,int,int,int);
int damage_resize(int,int,int,int);
void position(int X,int Y) {resize(X,Y,w_,h_);}
void size(int W,int H) {resize(x_,y_,W,H);}
FL_EXPORT Fl_Align align() const {return (Fl_Align)align_;}
FL_EXPORT void align(uchar a) {align_ = a;}
FL_EXPORT Fl_Boxtype box() const {return (Fl_Boxtype)box_;}
FL_EXPORT void box(Fl_Boxtype a) {box_ = a;}
FL_EXPORT Fl_Color color() const {return (Fl_Color)color_;}
FL_EXPORT void color(uchar a) {color_ = a;}
FL_EXPORT Fl_Color selection_color() const {return (Fl_Color)color2_;}
FL_EXPORT void selection_color(uchar a) {color2_ = a;}
FL_EXPORT void color(uchar a, uchar b) {color_=a; color2_=b;}
FL_EXPORT const char* label() const {return label_.value;}
FL_EXPORT void label(const char* a) {label_.value=a;}
FL_EXPORT void label(Fl_Labeltype a,const char* b) {label_.type = a; label_.value = b;}
FL_EXPORT Fl_Labeltype labeltype() const {return (Fl_Labeltype)label_.type;}
FL_EXPORT void labeltype(Fl_Labeltype a) {label_.type = a;}
FL_EXPORT Fl_Color labelcolor() const {return (Fl_Color)label_.color;}
FL_EXPORT void labelcolor(uchar a) {label_.color=a;}
FL_EXPORT Fl_Font labelfont() const {return (Fl_Font)label_.font;}
FL_EXPORT void labelfont(uchar a) {label_.font=a;}
FL_EXPORT uchar labelsize() const {return label_.size;}
FL_EXPORT void labelsize(uchar a) {label_.size=a;}
FL_EXPORT Fl_Callback_p callback() const {return callback_;}
FL_EXPORT void callback(Fl_Callback* c, void* p) {callback_=c; user_data_=p;}
FL_EXPORT void callback(Fl_Callback* c) {callback_=c;}
FL_EXPORT void callback(Fl_Callback0*c) {callback_=(Fl_Callback*)c;}
FL_EXPORT void callback(Fl_Callback1*c, long p=0) {callback_=(Fl_Callback*)c; user_data_=(void*)p;}
FL_EXPORT void* user_data() const {return user_data_;}
FL_EXPORT void user_data(void* v) {user_data_ = v;}
FL_EXPORT long argument() const {return (long)user_data_;}
FL_EXPORT void argument(long v) {user_data_ = (void*)v;}
FL_EXPORT Fl_When when() const {return (Fl_When)when_;}
FL_EXPORT void when(uchar i) {when_ = i;}
Fl_Align align() const {return (Fl_Align)align_;}
void align(uchar a) {align_ = a;}
Fl_Boxtype box() const {return (Fl_Boxtype)box_;}
void box(Fl_Boxtype a) {box_ = a;}
Fl_Color color() const {return (Fl_Color)color_;}
void color(uchar a) {color_ = a;}
Fl_Color selection_color() const {return (Fl_Color)color2_;}
void selection_color(uchar a) {color2_ = a;}
void color(uchar a, uchar b) {color_=a; color2_=b;}
const char* label() const {return label_.value;}
void label(const char* a) {label_.value=a;}
void label(Fl_Labeltype a,const char* b) {label_.type = a; label_.value = b;}
Fl_Labeltype labeltype() const {return (Fl_Labeltype)label_.type;}
void labeltype(Fl_Labeltype a) {label_.type = a;}
Fl_Color labelcolor() const {return (Fl_Color)label_.color;}
void labelcolor(uchar a) {label_.color=a;}
Fl_Font labelfont() const {return (Fl_Font)label_.font;}
void labelfont(uchar a) {label_.font=a;}
uchar labelsize() const {return label_.size;}
void labelsize(uchar a) {label_.size=a;}
const char *tooltip() const {return tooltip_;}
void tooltip(const char *t) {Fl_Tooltip::enable(); tooltip_ = t;}
Fl_Callback_p callback() const {return callback_;}
void callback(Fl_Callback* c, void* p) {callback_=c; user_data_=p;}
void callback(Fl_Callback* c) {callback_=c;}
void callback(Fl_Callback0*c) {callback_=(Fl_Callback*)c;}
void callback(Fl_Callback1*c, long p=0) {callback_=(Fl_Callback*)c; user_data_=(void*)p;}
void* user_data() const {return user_data_;}
void user_data(void* v) {user_data_ = v;}
long argument() const {return (long)user_data_;}
void argument(long v) {user_data_ = (void*)v;}
Fl_When when() const {return (Fl_When)when_;}
void when(uchar i) {when_ = i;}
FL_EXPORT int visible() const {return !(flags_&INVISIBLE);}
FL_EXPORT int visible_r() const;
FL_EXPORT void show();
FL_EXPORT void hide();
FL_EXPORT void set_visible() {flags_ &= ~INVISIBLE;}
FL_EXPORT void clear_visible() {flags_ |= INVISIBLE;}
FL_EXPORT int active() const {return !(flags_&INACTIVE);}
FL_EXPORT int active_r() const;
FL_EXPORT void activate();
FL_EXPORT void deactivate();
FL_EXPORT int output() const {return (flags_&OUTPUT);}
FL_EXPORT void set_output() {flags_ |= OUTPUT;}
FL_EXPORT void clear_output() {flags_ &= ~OUTPUT;}
FL_EXPORT int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));}
FL_EXPORT int changed() const {return flags_&CHANGED;}
FL_EXPORT void set_changed() {flags_ |= CHANGED;}
FL_EXPORT void clear_changed() {flags_ &= ~CHANGED;}
FL_EXPORT int take_focus();
int visible() const {return !(flags_&INVISIBLE);}
int visible_r() const;
void show();
void hide();
void set_visible() {flags_ &= ~INVISIBLE;}
void clear_visible() {flags_ |= INVISIBLE;}
int active() const {return !(flags_&INACTIVE);}
int active_r() const;
void activate();
void deactivate();
int output() const {return (flags_&OUTPUT);}
void set_output() {flags_ |= OUTPUT;}
void clear_output() {flags_ &= ~OUTPUT;}
int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));}
int changed() const {return flags_&CHANGED;}
void set_changed() {flags_ |= CHANGED;}
void clear_changed() {flags_ &= ~CHANGED;}
int take_focus();
static FL_EXPORT void default_callback(Fl_Widget*, void*);
FL_EXPORT void do_callback() {callback_(this,user_data_);}
FL_EXPORT void do_callback(Fl_Widget* o,void* arg=0) {callback_(o,arg);}
FL_EXPORT void do_callback(Fl_Widget* o,long arg) {callback_(o,(void*)arg);}
FL_EXPORT int test_shortcut();
static FL_EXPORT int test_shortcut(const char*);
FL_EXPORT int contains(const Fl_Widget*) const ;
FL_EXPORT int inside(const Fl_Widget* o) const {return o ? o->contains(this) : 0;}
static void default_callback(Fl_Widget*, void*);
void do_callback() {callback_(this,user_data_);}
void do_callback(Fl_Widget* o,void* arg=0) {callback_(o,arg);}
void do_callback(Fl_Widget* o,long arg) {callback_(o,(void*)arg);}
int test_shortcut();
static int test_shortcut(const char*);
int contains(const Fl_Widget*) const ;
int inside(const Fl_Widget* o) const {return o ? o->contains(this) : 0;}
FL_EXPORT void redraw();
FL_EXPORT uchar damage() const {return damage_;}
FL_EXPORT void clear_damage(uchar c = 0) {damage_ = c;}
FL_EXPORT void damage(uchar c);
FL_EXPORT void damage(uchar c,int,int,int,int);
FL_EXPORT void draw_label(int, int, int, int, Fl_Align) const;
FL_EXPORT void measure_label(int& x, int& y) {label_.measure(x,y);}
void redraw();
uchar damage() const {return damage_;}
void clear_damage(uchar c = 0) {damage_ = c;}
void damage(uchar c);
void damage(uchar c,int,int,int,int);
void draw_label(int, int, int, int, Fl_Align) const;
void measure_label(int& x, int& y) {label_.measure(x,y);}
FL_EXPORT Fl_Window* window() const ;
Fl_Window* window() const ;
// back compatability only:
FL_EXPORT Fl_Color color2() const {return (Fl_Color)color2_;}
FL_EXPORT void color2(uchar a) {color2_ = a;}
Fl_Color color2() const {return (Fl_Color)color2_;}
void color2(uchar a) {color2_ = a;}
};
// reserved type numbers (necessary for my cheapo RTTI) start here.
@ -191,5 +196,5 @@ public:
#endif
//
// End of "$Id: Fl_Widget.H,v 1.6.2.4 2001/01/22 15:13:38 easysw Exp $".
// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.1 2001/08/01 21:24:48 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
#
# "$Id: Makefile,v 1.12.2.6 2001/03/14 17:20:01 spitzak Exp $"
# "$Id: Makefile,v 1.12.2.6.2.1 2001/08/01 21:24:48 easysw Exp $"
#
# Top-level makefile for the Fast Light Tool Kit (FLTK).
#
@ -23,8 +23,7 @@
# Please report all bugs and problems to "fltk-bugs@fltk.org".
#
SHELL=/bin/sh
SHELL = /bin/sh
DIRS = src fluid test
all: makeinclude
@ -66,11 +65,15 @@ distclean: clean
rm -f config.log config.h config.status makeinclude
makeinclude: configure configh.in makeinclude.in
./configure
if test -f config.status; then \
./config.status --recheck; \
else \
./configure; \
fi
configure: configure.in
autoconf
#
# End of "$Id: Makefile,v 1.12.2.6 2001/03/14 17:20:01 spitzak Exp $".
# End of "$Id: Makefile,v 1.12.2.6.2.1 2001/08/01 21:24:48 easysw Exp $".
#

4
README
View File

@ -1,5 +1,5 @@
README - Fast Light Tool Kit (FLTK) Version 1.0.11
--------------------------------------------------
README - Fast Light Tool Kit (FLTK) Version 1.1.0
-------------------------------------------------
WHAT IS FLTK?

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl.cxx,v 1.24.2.41 2001/02/26 00:19:02 spitzak Exp $"
// "$Id: Fl.cxx,v 1.24.2.41.2.1 2001/08/01 21:24:49 easysw Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@ -605,6 +605,8 @@ int Fl::handle(int event, Fl_Window* window)
void Fl_Window::hide() {
clear_visible();
Fl_Tooltip::exit(this);
if (!shown()) return;
// remove from the list of windows:
@ -780,5 +782,5 @@ void Fl_Window::flush() {
}
//
// End of "$Id: Fl.cxx,v 1.24.2.41 2001/02/26 00:19:02 spitzak Exp $".
// End of "$Id: Fl.cxx,v 1.24.2.41.2.1 2001/08/01 21:24:49 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Button.cxx,v 1.4.2.6 2001/01/22 15:13:39 easysw Exp $"
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.1 2001/08/01 21:24:49 easysw Exp $"
//
// Button widget for the Fast Light Tool Kit (FLTK).
//
@ -26,6 +26,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tooltip.H> // tooltip
// There are a lot of subclasses, named Fl_*_Button. Some of
// them are implemented by setting the type() value and testing it
@ -60,11 +61,15 @@ int Fl_Button::handle(int event) {
int newval;
switch (event) {
case FL_ENTER:
Fl_Tooltip::enter(this); // tooltip
return 1; // tooltip
case FL_LEAVE:
// if ((value_?selection_color():color())==FL_GRAY) redraw();
Fl_Tooltip::exit(this); // tooltip
return 1;
case FL_PUSH:
case FL_DRAG:
Fl_Tooltip::exit(this); // tooltip
if (Fl::event_inside(this)) {
if (type() == FL_RADIO_BUTTON) newval = 1;
else newval = !oldval;
@ -77,6 +82,7 @@ int Fl_Button::handle(int event) {
}
return 1;
case FL_RELEASE:
Fl_Tooltip::exit(this); // tooltip
if (value_ == oldval) {
if (when() & FL_WHEN_NOT_CHANGED) do_callback();
return 1;
@ -118,5 +124,5 @@ Fl_Button::Fl_Button(int x,int y,int w,int h, const char *l)
}
//
// End of "$Id: Fl_Button.cxx,v 1.4.2.6 2001/01/22 15:13:39 easysw Exp $".
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.1 2001/08/01 21:24:49 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Group.cxx,v 1.8.2.8 2001/01/22 15:13:39 easysw Exp $"
// "$Id: Fl_Group.cxx,v 1.8.2.8.2.1 2001/08/01 21:24:49 easysw Exp $"
//
// Group widget for the Fast Light Tool Kit (FLTK).
//
@ -33,6 +33,7 @@
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <stdlib.h>
#include <FL/Fl_Tooltip.H> // tooltip
Fl_Group* Fl_Group::current_;
@ -120,9 +121,11 @@ int Fl_Group::handle(int event) {
return 0;
case FL_KEYBOARD:
Fl_Tooltip::exit(this); // tooltip
return navigation(navkey());
case FL_SHORTCUT:
Fl_Tooltip::exit(this); // tooltip
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && Fl::event_inside(o) && send(o,FL_SHORTCUT))
@ -137,6 +140,7 @@ int Fl_Group::handle(int event) {
return 0;
case FL_ENTER:
Fl_Tooltip::enter(this); // tooltip
case FL_MOVE:
for (i = children(); i--;) {
o = a[i];
@ -153,6 +157,7 @@ int Fl_Group::handle(int event) {
return 1;
case FL_PUSH:
Fl_Tooltip::exit(this); // tooltip
for (i = children(); i--;) {
o = a[i];
if (o->takesevents() && Fl::event_inside(o)) {
@ -180,6 +185,9 @@ int Fl_Group::handle(int event) {
}
return 1;
case FL_LEAVE: // tooltip
Fl_Tooltip::exit(this); // tooltip
default:
return 0;
@ -270,12 +278,18 @@ void Fl_Group::clear() {
for (int i=old_children; i--;) {
Fl_Widget* o = *a++;
// test the parent to see if child already destructed:
if (o->parent() == this) delete o;
if (o->parent() == this) {
Fl_Tooltip::exit(o);
delete o;
}
}
if (old_children > 1) free((void*)old_array);
}
Fl_Group::~Fl_Group() {clear();}
Fl_Group::~Fl_Group() {
Fl_Tooltip::exit(this);
clear();
}
void Fl_Group::insert(Fl_Widget &o, int index) {
if (o.parent()) {
@ -513,5 +527,5 @@ void Fl_Group::draw_outside_label(const Fl_Widget& w) const {
}
//
// End of "$Id: Fl_Group.cxx,v 1.8.2.8 2001/01/22 15:13:39 easysw Exp $".
// End of "$Id: Fl_Group.cxx,v 1.8.2.8.2.1 2001/08/01 21:24:49 easysw Exp $".
//

View File

@ -1,9 +1,9 @@
//
// "$Id: Fl_Tooltip.cxx,v 1.38 2001/07/23 09:50:05 spitzak Exp $"
// "$Id: Fl_Tooltip.cxx,v 1.38.2.1 2001/08/01 21:24:49 easysw Exp $"
//
// Tooltip code for the Fast Light Tool Kit (FLTK).
// Tooltip source file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-1999 by Bill Spitzak and others.
// Copyright 1998-2001 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@ -20,138 +20,157 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@easysw.com".
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//
#include <fltk/Fl_Tooltip.h>
#include <fltk/fl_draw.h>
#include <fltk/Fl_Menu_Window.h>
#include <FL/Fl.H>
#include <FL/Fl_Menu_Window.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>
float Fl_Tooltip::delay_ = 0.5f;
int Fl_Tooltip::enabled_ = 1;
#include <stdio.h>
#define MAX_WIDTH 400
//
// Fl_Tooltip global variables...
//
class Fl_TooltipBox : public Fl_Menu_Window {
void (*Fl_Tooltip::tooltip_callback_)(void *) = 0;
void (*Fl_Tooltip::tooltip_exit_)(void *) = 0;
float Fl_Tooltip::delay_ = 0.5;
Fl_TooltipBox *Fl_Tooltip::box = 0;
Fl_Menu_Window *Fl_Tooltip::window = 0;
Fl_Widget *Fl_Tooltip::widget = 0;
int Fl_Tooltip::shown = 0;
uchar Fl_Tooltip::color_ = FL_YELLOW;
int Fl_Tooltip::font_ = FL_HELVETICA;
int Fl_Tooltip::size_ = FL_NORMAL_SIZE;
//
// Tooltip label class...
//
class Fl_TooltipBox : public Fl_Box {
public:
Fl_TooltipBox() : Fl_Menu_Window(0, 0, 0, 0) {
style(Fl_Tooltip::default_style);}
void draw();
void layout();
Fl_TooltipBox() : Fl_Box(0,0,10,10) {
color(Fl_Tooltip::color_);
align(FL_ALIGN_CENTER);
box(FL_BORDER_BOX);
Fl_Tooltip::widget = 0;
}
~Fl_TooltipBox() { }
void draw() {
tooltip(0); // Just in case
if (!Fl_Tooltip::widget || !Fl_Tooltip::widget->tooltip())
return;
Fl_Window *widgetWindow = Fl_Tooltip::widget->window();
if (!widgetWindow) {
printf("!widgetWindow\n");
return;
}
int ww, hh;
ww = 0;
labelfont(Fl_Tooltip::font_);
labelsize(Fl_Tooltip::size_);
color(Fl_Tooltip::color_);
fl_font(Fl_Tooltip::font_, Fl_Tooltip::size_);
fl_measure(Fl_Tooltip::widget->tooltip(), ww, hh);
label(Fl_Tooltip::widget->tooltip());
int ox =
widgetWindow->x_root() + Fl_Tooltip::widget->x() + Fl_Tooltip::widget->w()/2;
int oy =
widgetWindow->y_root() + Fl_Tooltip::widget->y() + Fl_Tooltip::widget->h() + 10;
if (ox >= Fl::w())
ox = Fl::w() - ww - 6;
if (oy >= Fl::h())
oy = widgetWindow->y_root() + Fl_Tooltip::widget->y() - hh - 6;
parent()->resize(ox, oy, ww+6, hh+6);
draw_box();
draw_label();
}
};
static const char* tip;
static Fl_Widget* widget;
static Fl_TooltipBox *window = 0;
static int X,Y,W,H;
void Fl_TooltipBox::layout() {
fl_font(label_font(), label_size());
int ww, hh;
ww = MAX_WIDTH;
fl_measure(tip, ww, hh, FL_ALIGN_LEFT|FL_ALIGN_WRAP|FL_ALIGN_INSIDE);
ww += 6; hh += 6;
// find position on the screen of the widget:
int ox = Fl::event_x_root()+5;
//int ox = X+W/2;
int oy = Y + H+2;
for (Fl_Widget* p = widget; p; p = p->parent()) {
//ox += p->x();
oy += p->y();
}
if (ox+ww > Fl::w()) ox = Fl::w() - ww;
if (ox < 0) ox = 0;
if (H > 30) {
oy = Fl::event_y_root()+13;
if (oy+hh > Fl::h()) oy -= 23+hh;
} else {
if (oy+hh > Fl::h()) oy -= (4+hh+H);
}
if (oy < 0) oy = 0;
resize(ox, oy, ww, hh);
Fl_Menu_Window::layout();
}
void Fl_TooltipBox::draw() {
draw_box();
draw_label(3, 3, w()-6, h()-6, FL_ALIGN_LEFT|FL_ALIGN_WRAP|FL_ALIGN_INSIDE);
// This function is called by widgets
// when the pointer enters them
void
Fl_Tooltip::enter(Fl_Widget *w) {
if (!tooltip_callback_ || !w || !w->tooltip()) return;
Fl::add_timeout(delay_, tooltip_callback_, w);
}
static void tooltip_timeout(void*) {
if (Fl::grab()) return;
// This function must be called when
// an event != FL_MOVE has occured in
// the widget
void
Fl_Tooltip::exit(Fl_Widget *w) {
if (tooltip_exit_ && w && w->tooltip()) tooltip_exit_(w);
}
if (window) delete window;
void
Fl_Tooltip::tooltip_exit(Fl_Widget *w) {
Fl::remove_timeout(tooltip_callback_, w);
if ((w == widget || (widget && w == widget->window())) && shown && window) {
widget = 0;
window->hide();
shown = 0;
}
}
void
Fl_Tooltip::tooltip_timeout(void *v) {
if (!window) {
Fl_Group* saveCurrent = Fl_Group::current();
Fl_Group::current(0);
window = new Fl_TooltipBox;
window->set_override();
window = new Fl_Menu_Window(0, 0, 10, 10, 0);
window->clear_border();
window->box(FL_NO_BOX);
window->begin();
box = new Fl_TooltipBox;
box->color(FL_YELLOW);
box->align(FL_ALIGN_CENTER);
window->resizable(box);
window->end();
Fl_Group::current(saveCurrent);
// this cast bypasses the normal Fl_Window label() code:
((Fl_Widget*)window)->label(tip);
window->relayout();
window->show();
}
static int cheesy_flag = 0;
static void
tt_exit(Fl_Widget *w) {
if (!w || w != widget) return;
widget = 0;
Fl::remove_timeout((Fl_Timeout_Handler)tooltip_timeout);
if (window) {
// This flag makes sure that tootip_enter() isn't executed because of
// this destroy() which could cause unwanted recursion in tooltip_enter()
cheesy_flag = 1;
window->destroy();
cheesy_flag = 0;
}
}
static void
tt_enter_area(Fl_Widget* w, int X, int Y, int W, int H, const char* t) {
if (cheesy_flag) return;
if (w == widget && X == ::X && Y == ::Y && W == ::W && H == ::H && t == tip)
if (!v)
return;
tt_exit(widget);
widget = w; ::X = X; ::Y = Y; ::W = W; ::H = H; tip = t;
if (!t || !Fl_Tooltip::enabled()) return;
float d = Fl_Tooltip::delay();
if (d < .01f) d = .01f;
Fl::add_timeout(d, (Fl_Timeout_Handler)tooltip_timeout);
}
static void
tt_enter(Fl_Widget* w) {
if (cheesy_flag || w == widget) return;
if (!w || w == window) { tt_exit(widget); widget = 0; return; }
tt_enter_area(w, 0, 0, w->w(), w->h(), w->tooltip());
}
void Fl_Widget::tooltip(const char *tt) {
static int do_once = 0;
if (!do_once) {
do_once = 1;
Fl_Tooltip::enter = tt_enter;
Fl_Tooltip::enter_area = tt_enter_area;
Fl_Tooltip::exit = tt_exit;
if (shown && widget != (Fl_Widget *)v) {
tooltip_exit(widget);
}
widget = (Fl_Widget*) v;
Fl_Window *widgetWindow = widget->window();
if (widgetWindow) {
Fl::grab(*widgetWindow);
window->show();
Fl::release();
shown = 1;
} else {
widget = 0;
}
tooltip_ = tt;
}
static void revert(Fl_Style* s) {
s->box = FL_BORDER_BOX;
s->color = (Fl_Color)215;
s->label_color = FL_BLACK;
}
static Fl_Named_Style style("Tooltip", revert, &Fl_Tooltip::default_style);
Fl_Named_Style* Fl_Tooltip::default_style = &::style;
//
// End of "$Id: Fl_Tooltip.cxx,v 1.38 2001/07/23 09:50:05 spitzak Exp $".
// End of "$Id: Fl_Tooltip.cxx,v 1.38.2.1 2001/08/01 21:24:49 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
#
# "$Id: Makefile,v 1.18.2.14 2001/01/22 15:13:40 easysw Exp $"
# "$Id: Makefile,v 1.18.2.14.2.1 2001/08/01 21:24:49 easysw Exp $"
#
# Library makefile for the Fast Light Tool Kit (FLTK).
#
@ -71,6 +71,7 @@ CPPFILES = \
Fl_Slider.cxx \
Fl_Tabs.cxx \
Fl_Tile.cxx \
Fl_Tooltip.cxx \
Fl_Valuator.cxx \
Fl_Value_Input.cxx \
Fl_Value_Output.cxx \
@ -207,5 +208,5 @@ install: $(LIBRARY) $(DSONAME)
ln -s FL $(includedir)/Fl
#
# End of "$Id: Makefile,v 1.18.2.14 2001/01/22 15:13:40 easysw Exp $".
# End of "$Id: Makefile,v 1.18.2.14.2.1 2001/08/01 21:24:49 easysw Exp $".
#

View File

@ -1,5 +1,5 @@
//
// "$Id: buttons.cxx,v 1.4.2.3 2001/01/22 15:13:41 easysw Exp $"
// "$Id: buttons.cxx,v 1.4.2.3.2.1 2001/08/01 21:24:49 easysw Exp $"
//
// Another button test program for the Fast Light Tool Kit (FLTK).
//
@ -33,10 +33,11 @@
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Light_Button.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Tooltip.H>
int main(int argc, char ** argv) {
Fl_Window *window = new Fl_Window(320,130);
new Fl_Button(10, 10, 130, 30, "Fl_Button");
(new Fl_Button(10, 10, 130, 30, "Fl_Button"))->tooltip("This is a Tooltip.");
new Fl_Return_Button(150, 10, 160, 30, "Fl_Return_Button");
new Fl_Repeat_Button(10,50,130,30,"Fl_Repeat_Button");
new Fl_Light_Button(10,90,130,30,"Fl_Light_Button");
@ -48,5 +49,5 @@ int main(int argc, char ** argv) {
}
//
// End of "$Id: buttons.cxx,v 1.4.2.3 2001/01/22 15:13:41 easysw Exp $".
// End of "$Id: buttons.cxx,v 1.4.2.3.2.1 2001/08/01 21:24:49 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: demo.cxx,v 1.8.2.5 2001/01/22 15:13:41 easysw Exp $"
// "$Id: demo.cxx,v 1.8.2.5.2.1 2001/08/01 21:24:49 easysw Exp $"
//
// Main demo program for the Fast Light Tool Kit (FLTK).
//
@ -173,6 +173,8 @@ void push_menu(const char* nnn)
bn = numb2but(i,n-1);
but[bn]->show();
but[bn]->label(menus[men].iname[i]);
if (menus[men].icommand[i][0] != '@') but[bn]->tooltip(menus[men].icommand[i]);
else but[bn]->tooltip(0);
}
strcpy(stack[stsize],nnn);
stsize++;
@ -332,6 +334,6 @@ int main(int argc, char **argv) {
}
//
// End of "$Id: demo.cxx,v 1.8.2.5 2001/01/22 15:13:41 easysw Exp $".
// End of "$Id: demo.cxx,v 1.8.2.5.2.1 2001/08/01 21:24:49 easysw Exp $".
//