00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00031 #ifndef Fl_Widget_H
00032 #define Fl_Widget_H
00033
00034 #include "Enumerations.H"
00035
00039 #ifdef _WIN64
00040 #include <stdint.h>
00041 typedef intptr_t fl_intptr_t;
00042 typedef uintptr_t fl_uintptr_t;
00043 #else
00044 typedef long fl_intptr_t;
00045 typedef unsigned long fl_uintptr_t;
00046 #endif
00047
00048 class Fl_Widget;
00049 class Fl_Window;
00050 class Fl_Group;
00051 class Fl_Image;
00052
00054 typedef void (Fl_Callback )(Fl_Widget*, void*);
00056 typedef Fl_Callback* Fl_Callback_p;
00058 typedef void (Fl_Callback0)(Fl_Widget*);
00060 typedef void (Fl_Callback1)(Fl_Widget*, long);
00061
00069 struct FL_EXPORT Fl_Label {
00071 const char* value;
00073 Fl_Image* image;
00075 Fl_Image* deimage;
00077 Fl_Font font;
00079 Fl_Fontsize size;
00081 Fl_Color color;
00083 Fl_Align align_;
00085 uchar type;
00086
00088 void draw(int,int,int,int, Fl_Align) const ;
00089 void measure(int &w, int &h) const ;
00090 };
00091
00092
00105 class FL_EXPORT Fl_Widget {
00106 friend class Fl_Group;
00107
00108 Fl_Group* parent_;
00109 Fl_Callback* callback_;
00110 void* user_data_;
00111 int x_,y_,w_,h_;
00112 Fl_Label label_;
00113 unsigned int flags_;
00114 Fl_Color color_;
00115 Fl_Color color2_;
00116 uchar type_;
00117 uchar damage_;
00118 uchar box_;
00119 uchar when_;
00120
00121 const char *tooltip_;
00122
00124 Fl_Widget(const Fl_Widget &);
00126 Fl_Widget& operator=(const Fl_Widget &);
00127
00128 protected:
00129
00140 Fl_Widget(int x, int y, int w, int h, const char *label=0L);
00141
00143 void x(int v) {x_ = v;}
00145 void y(int v) {y_ = v;}
00147 void w(int v) {w_ = v;}
00149 void h(int v) {h_ = v;}
00151 unsigned int flags() const {return flags_;}
00153 void set_flag(unsigned int c) {flags_ |= c;}
00155 void clear_flag(unsigned int c) {flags_ &= ~c;}
00159 enum {
00160 INACTIVE = 1<<0,
00161 INVISIBLE = 1<<1,
00162 OUTPUT = 1<<2,
00163 NOBORDER = 1<<3,
00164 FORCE_POSITION = 1<<4,
00165 NON_MODAL = 1<<5,
00166 SHORTCUT_LABEL = 1<<6,
00167 CHANGED = 1<<7,
00168 OVERRIDE = 1<<8,
00169 VISIBLE_FOCUS = 1<<9,
00170 COPIED_LABEL = 1<<10,
00171 CLIP_CHILDREN = 1<<11,
00172 MENU_WINDOW = 1<<12,
00173 TOOLTIP_WINDOW = 1<<13,
00174 MODAL = 1<<14,
00175 NO_OVERLAY = 1<<15,
00176 GROUP_RELATIVE = 1<<16,
00177 COPIED_TOOLTIP = 1<<17,
00178
00179 USERFLAG3 = 1<<29,
00180 USERFLAG2 = 1<<30,
00181 USERFLAG1 = 1<<31
00182 };
00183 void draw_box() const;
00184 void draw_box(Fl_Boxtype t, Fl_Color c) const;
00185 void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const;
00186 void draw_backdrop() const;
00188 void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
00189 void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const;
00190 void draw_label() const;
00191 void draw_label(int, int, int, int) const;
00192
00193 public:
00194
00203 virtual ~Fl_Widget();
00204
00221 virtual void draw() = 0;
00222
00239 virtual int handle(int event);
00240
00246 Fl_Group* parent() const {return parent_;}
00247
00256 void parent(Fl_Group* p) {parent_ = p;}
00257
00266 uchar type() const {return type_;}
00267
00271 void type(uchar t) {type_ = t;}
00272
00276 int x() const {return x_;}
00277
00281 int y() const {return y_;}
00282
00286 int w() const {return w_;}
00287
00291 int h() const {return h_;}
00292
00312 virtual void resize(int x, int y, int w, int h);
00313
00315 int damage_resize(int,int,int,int);
00316
00324 void position(int X,int Y) {resize(X,Y,w_,h_);}
00325
00333 void size(int W,int H) {resize(x_,y_,W,H);}
00334
00347 Fl_Align align() const {return label_.align_;}
00348
00356 void align(Fl_Align alignment) {label_.align_ = alignment;}
00357
00362 Fl_Boxtype box() const {return (Fl_Boxtype)box_;}
00363
00371 void box(Fl_Boxtype new_box) {box_ = new_box;}
00372
00377 Fl_Color color() const {return color_;}
00378
00389 void color(Fl_Color bg) {color_ = bg;}
00390
00395 Fl_Color selection_color() const {return color2_;}
00396
00405 void selection_color(Fl_Color a) {color2_ = a;}
00406
00414 void color(Fl_Color bg, Fl_Color sel) {color_=bg; color2_=sel;}
00415
00420 const char* label() const {return label_.value;}
00421
00432 void label(const char* text);
00433
00444 void copy_label(const char *new_label);
00445
00449 void label(Fl_Labeltype a, const char* b) {label_.type = a; label_.value = b;}
00450
00455 Fl_Labeltype labeltype() const {return (Fl_Labeltype)label_.type;}
00456
00465 void labeltype(Fl_Labeltype a) {label_.type = a;}
00466
00471 Fl_Color labelcolor() const {return label_.color;}
00472
00477 void labelcolor(Fl_Color c) {label_.color=c;}
00478
00486 Fl_Font labelfont() const {return label_.font;}
00487
00495 void labelfont(Fl_Font f) {label_.font=f;}
00496
00501 Fl_Fontsize labelsize() const {return label_.size;}
00502
00507 void labelsize(Fl_Fontsize pix) {label_.size=pix;}
00508
00513 Fl_Image* image() {return label_.image;}
00514 const Fl_Image* image() const {return label_.image;}
00515
00520 void image(Fl_Image* img) {label_.image=img;}
00521
00526 void image(Fl_Image& img) {label_.image=&img;}
00527
00532 Fl_Image* deimage() {return label_.deimage;}
00533 const Fl_Image* deimage() const {return label_.deimage;}
00534
00539 void deimage(Fl_Image* img) {label_.deimage=img;}
00540
00545 void deimage(Fl_Image& img) {label_.deimage=&img;}
00546
00551 const char *tooltip() const {return tooltip_;}
00552
00553 void tooltip(const char *text);
00554 void copy_tooltip(const char *text);
00555
00560 Fl_Callback_p callback() const {return callback_;}
00561
00567 void callback(Fl_Callback* cb, void* p) {callback_=cb; user_data_=p;}
00568
00573 void callback(Fl_Callback* cb) {callback_=cb;}
00574
00579 void callback(Fl_Callback0*cb) {callback_=(Fl_Callback*)cb;}
00580
00586 void callback(Fl_Callback1*cb, long p=0) {callback_=(Fl_Callback*)cb; user_data_=(void*)p;}
00587
00592 void* user_data() const {return user_data_;}
00593
00598 void user_data(void* v) {user_data_ = v;}
00599
00602 long argument() const {return (long)(fl_intptr_t)user_data_;}
00603
00608 void argument(long v) {user_data_ = (void*)v;}
00609
00618 Fl_When when() const {return (Fl_When)when_;}
00619
00651 void when(uchar i) {when_ = i;}
00652
00657 unsigned int visible() const {return !(flags_&INVISIBLE);}
00658
00663 int visible_r() const;
00664
00679 virtual void show();
00680
00684 virtual void hide();
00685
00690 void set_visible() {flags_ &= ~INVISIBLE;}
00691
00696 void clear_visible() {flags_ |= INVISIBLE;}
00697
00702 unsigned int active() const {return !(flags_&INACTIVE);}
00703
00708 int active_r() const;
00709
00715 void activate();
00716
00731 void deactivate();
00732
00741 unsigned int output() const {return (flags_&OUTPUT);}
00742
00746 void set_output() {flags_ |= OUTPUT;}
00747
00751 void clear_output() {flags_ &= ~OUTPUT;}
00752
00758 unsigned int takesevents() const {
00759 return !output() && active_r() && visible_r();
00760 }
00761
00777 unsigned int changed() const {return flags_&CHANGED;}
00778
00782 void set_changed() {flags_ |= CHANGED;}
00783
00787 void clear_changed() {flags_ &= ~CHANGED;}
00788
00796 int take_focus();
00797
00804 void set_visible_focus() { flags_ |= VISIBLE_FOCUS; }
00805
00810 void clear_visible_focus() { flags_ &= ~VISIBLE_FOCUS; }
00811
00816 void visible_focus(int v) { if (v) set_visible_focus(); else clear_visible_focus(); }
00817
00822 unsigned int visible_focus() { return flags_ & VISIBLE_FOCUS; }
00823
00831 static void default_callback(Fl_Widget *cb, void *d);
00832
00837 void do_callback() {do_callback(this,user_data_);}
00838
00845 void do_callback(Fl_Widget* o,long arg) {do_callback(o,(void*)arg);}
00846
00847
00848
00849 void do_callback(Fl_Widget* o,void* arg=0);
00850
00851
00852 int test_shortcut();
00853
00854 static unsigned int label_shortcut(const char *t);
00855
00856 static int test_shortcut(const char*, const bool require_alt = false);
00857
00863 int contains(const Fl_Widget *w) const ;
00864
00871 int inside(const Fl_Widget* w) const {return w ? w->contains(this) : 0;}
00872
00876 void redraw();
00877
00882 void redraw_label();
00883
00890 uchar damage() const {return damage_;}
00891
00904 void clear_damage(uchar c = 0) {damage_ = c;}
00905
00911 void damage(uchar c);
00912
00919 void damage(uchar c, int x, int y, int w, int h);
00920
00921 void draw_label(int, int, int, int, Fl_Align) const;
00922
00926 void measure_label(int& ww, int& hh) const {label_.measure(ww, hh);}
00927
00933 Fl_Window* window() const ;
00934
00941 virtual Fl_Group* as_group() {return 0;}
00942
00949 virtual Fl_Window* as_window() {return 0;}
00950
00956 virtual class Fl_Gl_Window* as_gl_window() {return 0;}
00957
00961 Fl_Color color2() const {return (Fl_Color)color2_;}
00962
00966 void color2(unsigned a) {color2_ = a;}
00967 };
00968
00974 #define FL_RESERVED_TYPE 100
00975
00976 #endif
00977
00978
00979
00980