1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Widget header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// Copyright 1998-2005 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#ifndef Fl_Widget_H
|
|
|
|
#define Fl_Widget_H
|
|
|
|
|
|
|
|
#include "Enumerations.H"
|
|
|
|
|
|
|
|
class Fl_Widget;
|
|
|
|
class Fl_Window;
|
2001-10-23 01:15:11 +04:00
|
|
|
class Fl_Group;
|
2001-08-06 03:58:54 +04:00
|
|
|
class Fl_Image;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
typedef void (Fl_Callback )(Fl_Widget*, void*);
|
1999-03-18 23:04:13 +03:00
|
|
|
typedef Fl_Callback* Fl_Callback_p; // needed for BORLAND
|
1998-10-06 22:21:25 +04:00
|
|
|
typedef void (Fl_Callback0)(Fl_Widget*);
|
|
|
|
typedef void (Fl_Callback1)(Fl_Widget*, long);
|
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
struct FL_EXPORT Fl_Label {
|
1998-10-06 22:21:25 +04:00
|
|
|
const char* value;
|
2001-08-06 03:58:54 +04:00
|
|
|
Fl_Image* image;
|
|
|
|
Fl_Image* deimage;
|
1998-10-06 22:21:25 +04:00
|
|
|
uchar type;
|
|
|
|
uchar font;
|
|
|
|
uchar size;
|
2001-10-29 06:44:33 +03:00
|
|
|
unsigned color;
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw(int,int,int,int, Fl_Align) const ;
|
|
|
|
void measure(int&, int&) const ;
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
class FL_EXPORT Fl_Widget {
|
1998-10-06 22:21:25 +04:00
|
|
|
friend class Fl_Group;
|
|
|
|
|
2001-10-23 01:15:11 +04:00
|
|
|
Fl_Group* parent_;
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Callback* callback_;
|
|
|
|
void* user_data_;
|
|
|
|
short x_,y_,w_,h_;
|
|
|
|
Fl_Label label_;
|
2001-10-18 22:53:20 +04:00
|
|
|
int flags_;
|
2001-10-29 06:44:33 +03:00
|
|
|
unsigned color_;
|
|
|
|
unsigned color2_;
|
|
|
|
uchar type_;
|
1998-10-06 22:21:25 +04:00
|
|
|
uchar damage_;
|
|
|
|
uchar box_;
|
|
|
|
uchar align_;
|
|
|
|
uchar when_;
|
|
|
|
|
2001-08-02 01:24:49 +04:00
|
|
|
const char *tooltip_;
|
|
|
|
|
2004-04-06 22:37:20 +04:00
|
|
|
# if !defined(WIN32) || !defined(FL_DLL)
|
|
|
|
// "de-implement" the copy constructors, EXCEPT for when we are using the
|
|
|
|
// WIN32 DLL interface, in which case we can't hide them because Microsoft
|
|
|
|
// requires the copy constructors to implement subclassing...
|
2003-09-04 23:07:58 +04:00
|
|
|
Fl_Widget & operator=(const Fl_Widget &) { return *this; }
|
|
|
|
Fl_Widget(const Fl_Widget &) {}
|
2004-04-06 22:37:20 +04:00
|
|
|
# endif // !WIN32 || !FL_DLL
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
Fl_Widget(int,int,int,int,const char* =0);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2004-09-24 20:00:11 +04:00
|
|
|
void x(int v) {x_ = (short)v;}
|
|
|
|
void y(int v) {y_ = (short)v;}
|
|
|
|
void w(int v) {w_ = (short)v;}
|
|
|
|
void h(int v) {h_ = (short)v;}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2001-10-18 22:53:20 +04:00
|
|
|
int flags() const {return flags_;}
|
1998-10-06 22:21:25 +04:00
|
|
|
void set_flag(int c) {flags_ |= c;}
|
|
|
|
void clear_flag(int c) {flags_ &= ~c;}
|
2002-07-23 19:07:33 +04:00
|
|
|
enum {INACTIVE=1, INVISIBLE=2, OUTPUT=4, SHORTCUT_LABEL=64,
|
2004-11-23 22:47:52 +03:00
|
|
|
CHANGED=128, VISIBLE_FOCUS=512, COPIED_LABEL = 1024};
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw_box() const;
|
|
|
|
void draw_box(Fl_Boxtype, Fl_Color) const;
|
|
|
|
void draw_box(Fl_Boxtype, int,int,int,int, Fl_Color) const;
|
2001-11-03 08:11:34 +03:00
|
|
|
void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw_focus(Fl_Boxtype, int,int,int,int) const;
|
|
|
|
void draw_label() const;
|
|
|
|
void draw_label(int, int, int, int) const;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
virtual ~Fl_Widget();
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
virtual void draw() = 0;
|
|
|
|
virtual int handle(int);
|
2001-10-23 01:15:11 +04:00
|
|
|
Fl_Group* parent() const {return parent_;}
|
2002-08-09 05:09:49 +04:00
|
|
|
void parent(Fl_Group* p) {parent_ = p;} // for hacks only, Fl_Group::add()
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
uchar type() const {return type_;}
|
|
|
|
void type(uchar t) {type_ = t;}
|
|
|
|
|
|
|
|
int x() const {return x_;}
|
|
|
|
int y() const {return y_;}
|
|
|
|
int w() const {return w_;}
|
|
|
|
int h() const {return h_;}
|
2002-08-14 20:19:48 +04:00
|
|
|
virtual void resize(int,int,int,int);
|
|
|
|
int damage_resize(int,int,int,int);
|
2001-08-02 01:24:49 +04:00
|
|
|
void position(int X,int Y) {resize(X,Y,w_,h_);}
|
|
|
|
void size(int W,int H) {resize(x_,y_,W,H);}
|
|
|
|
|
|
|
|
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_;}
|
2001-10-29 06:44:33 +03:00
|
|
|
void color(unsigned a) {color_ = a;}
|
2001-08-02 01:24:49 +04:00
|
|
|
Fl_Color selection_color() const {return (Fl_Color)color2_;}
|
2001-10-29 06:44:33 +03:00
|
|
|
void selection_color(unsigned a) {color2_ = a;}
|
|
|
|
void color(unsigned a, unsigned b) {color_=a; color2_=b;}
|
2001-08-02 01:24:49 +04:00
|
|
|
const char* label() const {return label_.value;}
|
2004-11-23 22:47:52 +03:00
|
|
|
void label(const char* a);
|
|
|
|
void copy_label(const char* a);
|
2001-08-02 01:24:49 +04:00
|
|
|
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;}
|
2001-10-29 06:44:33 +03:00
|
|
|
void labelcolor(unsigned a) {label_.color=a;}
|
2001-08-02 01:24:49 +04:00
|
|
|
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;}
|
2001-08-06 03:58:54 +04:00
|
|
|
Fl_Image* image() {return label_.image;}
|
|
|
|
void image(Fl_Image* a) {label_.image=a;}
|
|
|
|
void image(Fl_Image& a) {label_.image=&a;}
|
|
|
|
Fl_Image* deimage() {return label_.deimage;}
|
|
|
|
void deimage(Fl_Image* a) {label_.deimage=a;}
|
|
|
|
void deimage(Fl_Image& a) {label_.deimage=&a;}
|
2001-08-02 01:24:49 +04:00
|
|
|
const char *tooltip() const {return tooltip_;}
|
2002-08-14 20:19:48 +04:00
|
|
|
void tooltip(const char *t);
|
2001-08-02 01:24:49 +04:00
|
|
|
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;}
|
|
|
|
|
|
|
|
int visible() const {return !(flags_&INVISIBLE);}
|
2002-08-14 20:19:48 +04:00
|
|
|
int visible_r() const;
|
|
|
|
void show();
|
|
|
|
void hide();
|
2001-08-02 01:24:49 +04:00
|
|
|
void set_visible() {flags_ &= ~INVISIBLE;}
|
|
|
|
void clear_visible() {flags_ |= INVISIBLE;}
|
|
|
|
int active() const {return !(flags_&INACTIVE);}
|
2002-08-14 20:19:48 +04:00
|
|
|
int active_r() const;
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
2001-08-02 01:24:49 +04:00
|
|
|
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;}
|
2002-08-14 20:19:48 +04:00
|
|
|
int take_focus();
|
2002-07-23 19:07:33 +04:00
|
|
|
void set_visible_focus() { flags_ |= VISIBLE_FOCUS; }
|
|
|
|
void clear_visible_focus() { flags_ &= ~VISIBLE_FOCUS; }
|
|
|
|
void visible_focus(int v) { if (v) set_visible_focus(); else clear_visible_focus(); }
|
|
|
|
int visible_focus() { return flags_ & VISIBLE_FOCUS; }
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
static void default_callback(Fl_Widget*, void*);
|
2004-07-27 20:02:21 +04:00
|
|
|
void do_callback() {callback_(this,user_data_); if (callback_ != default_callback) clear_changed();}
|
|
|
|
void do_callback(Fl_Widget* o,void* arg=0) {callback_(o,arg); if (callback_ != default_callback) clear_changed();}
|
|
|
|
void do_callback(Fl_Widget* o,long arg) {callback_(o,(void*)arg); if (callback_ != default_callback) clear_changed();}
|
2002-08-14 20:19:48 +04:00
|
|
|
int test_shortcut();
|
|
|
|
static int test_shortcut(const char*);
|
|
|
|
int contains(const Fl_Widget*) const ;
|
2001-08-02 01:24:49 +04:00
|
|
|
int inside(const Fl_Widget* o) const {return o ? o->contains(this) : 0;}
|
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
void redraw();
|
2002-10-04 19:59:29 +04:00
|
|
|
void redraw_label();
|
2001-08-02 01:24:49 +04:00
|
|
|
uchar damage() const {return damage_;}
|
|
|
|
void clear_damage(uchar c = 0) {damage_ = c;}
|
2002-08-14 20:19:48 +04:00
|
|
|
void damage(uchar c);
|
|
|
|
void damage(uchar c,int,int,int,int);
|
|
|
|
void draw_label(int, int, int, int, Fl_Align) const;
|
2002-08-09 05:09:49 +04:00
|
|
|
void measure_label(int& xx, int& yy) {label_.measure(xx,yy);}
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
Fl_Window* window() const ;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// back compatability only:
|
2001-08-02 01:24:49 +04:00
|
|
|
Fl_Color color2() const {return (Fl_Color)color2_;}
|
2001-10-29 06:44:33 +03:00
|
|
|
void color2(unsigned a) {color2_ = a;}
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// reserved type numbers (necessary for my cheapo RTTI) start here.
|
|
|
|
// grep the header files for "RESERVED_TYPE" to find the next available
|
|
|
|
// number.
|
|
|
|
#define FL_RESERVED_TYPE 100
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|