Author: matt Date: 2011-05-27 08:48:29 -0700 (Fri, 27 May 2011) New Revision: 8745 Log: 123: compatibility headers additions for Fl_Widget
Modified: branches/branch-3.0/FL/Fl_Button.H branches/branch-3.0/FL/Fl_Group.H branches/branch-3.0/FL/Fl_Widget.H branches/branch-3.0/FL/Fl_Window.H branches/branch-3.0/fltk/Widget.h branches/branch-3.0/fltk3/Widget.h Modified: branches/branch-3.0/FL/Fl_Button.H =================================================================== --- branches/branch-3.0/FL/Fl_Button.H 2011-05-27 06:31:17 UTC (rev 8744) +++ branches/branch-3.0/FL/Fl_Button.H 2011-05-27 15:48:29 UTC (rev 8745) @@ -26,151 +26,43 @@ // http://www.fltk.org/str.php // -/* \file - Fl_Button widget . */ - #ifndef Fl_Button_H #define Fl_Button_H -#ifndef Fl_Widget_H #include "Fl_Widget.H" -#endif -// values for type() -#define FL_NORMAL_BUTTON 0 /**< value() will be set to 1 during the press of the button and - reverts back to 0 when the button is released */ -#define FL_TOGGLE_BUTTON 1 ///< value() toggles between 0 and 1 at every click of the button -#define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2) /**< is set to 1 at button press, and all other - buttons in the same group with <tt>type() == FL_RADIO_BUTTON</tt> - are set to zero.*/ -#define FL_HIDDEN_BUTTON 3 ///< for Forms compatibility +#define FL_NORMAL_BUTTON 0 +#define FL_TOGGLE_BUTTON 1 +#define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2) +#define FL_HIDDEN_BUTTON 3 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*); class Fl_Widget_Tracker; -/** - \class Fl_Button - \brief Buttons generate callbacks when they are clicked by the user. - - You control exactly when and how by changing the values for type() and - when(). Buttons can also generate callbacks in response to \c FL_SHORTCUT - events. The button can either have an explicit shortcut(int s) value or a - letter shortcut can be indicated in the label() with an '\&' character - before it. For the label shortcut it does not matter if \e Alt is held - down, but if you have an input field in the same window, the user will have - to hold down the \e Alt key so that the input field does not eat the event - first as an \c FL_KEYBOARD event. - - \todo Refactor the doxygen comments for Fl_Button type() documentation. - - For an Fl_Button object, the type() call returns one of: - \li \c FL_NORMAL_BUTTON (0): value() remains unchanged after button press. - \li \c FL_TOGGLE_BUTTON: value() is inverted after button press. - \li \c FL_RADIO_BUTTON: value() is set to 1 after button press, and all other - buttons in the current group with <tt>type() == FL_RADIO_BUTTON</tt> - are set to zero. - - \todo Refactor the doxygen comments for Fl_Button when() documentation. - - For an Fl_Button object, the following when() values are useful, the default - being \c FL_WHEN_RELEASE: - \li \c 0: The callback is not done, instead changed() is turned on. - \li \c FL_WHEN_RELEASE: The callback is done after the user successfully - clicks the button, or when a shortcut is typed. - \li \c FL_WHEN_CHANGED: The callback is done each time the value() changes - (when the user pushes and releases the button, and as the mouse is - dragged around in and out of the button). -*/ class FL_EXPORT Fl_Button : public Fl_Widget { - int shortcut_; - char value_; - char oldval; - uchar down_box_; - protected: - - static Fl_Widget_Tracker *key_release_tracker; + static void key_release_timeout(void*); void simulate_key_action(); - virtual void draw(); public: virtual int handle(int); - Fl_Button(int X, int Y, int W, int H, const char *L = 0); - int value(int v); - - /** - Returns the current value of the button (0 or 1). - */ char value() const {return value_;} - - /** - Same as \c value(1). - \see value(int v) - */ int set() {return value(1);} - - /** - Same as \c value(0). - \see value(int v) - */ int clear() {return value(0);} - - void setonly(); // this should only be called on FL_RADIO_BUTTONs - - /** - Returns the current shortcut key for the button. - \retval int - */ + void setonly(); int shortcut() const {return shortcut_;} - - /** - Sets the shortcut key to \c s. - Setting this overrides the use of '\&' in the label(). - The value is a bitwise OR of a key and a set of shift flags, for example: - <tt>FL_ALT | 'a'</tt>, or - <tt>FL_ALT | (FL_F + 10)</tt>, or just - <tt>'a'</tt>. - A value of 0 disables the shortcut. - - The key can be any value returned by Fl::event_key(), but will usually be - an ASCII letter. Use a lower-case letter unless you require the shift key - to be held down. - - The shift flags can be any set of values accepted by Fl::event_state(). - If the bit is on, that shift key must be pushed. Meta, Alt, Ctrl, and - Shift must be off if they are not in the shift flags (zero for the other - bits indicates a "don't care" setting). - \param[in] s bitwise OR of key and shift flags - */ void shortcut(int s) {shortcut_ = s;} - - /** - Returns the current down box type, which is drawn when value() is non-zero. - \retval Fl_Boxtype - */ Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;} - - /** - Sets the down box type. The default value of 0 causes FLTK to figure out - the correct matching down version of box(). - \param[in] b down box type - */ void down_box(Fl_Boxtype b) {down_box_ = b;} - - /// (for backwards compatibility) void shortcut(const char *s) {shortcut(fl_old_shortcut(s));} - - /// (for backwards compatibility) Fl_Color down_color() const {return selection_color();} - - /// (for backwards compatibility) void down_color(unsigned c) {selection_color(c);} }; Modified: branches/branch-3.0/FL/Fl_Group.H =================================================================== --- branches/branch-3.0/FL/Fl_Group.H 2011-05-27 06:31:17 UTC (rev 8744) +++ branches/branch-3.0/FL/Fl_Group.H 2011-05-27 15:48:29 UTC (rev 8745) @@ -25,21 +25,11 @@ // http://www.fltk.org/str.php // -/* \file - Fl_Group, Fl_End classes . */ - #ifndef Fl_Group_H #define Fl_Group_H #include "Fl_Widget.H" -/** - The Fl_Group class is the FLTK container widget. It maintains - an array of child widgets. These children can themselves be any widget - including Fl_Group. The most important subclass of Fl_Group - is Fl_Window, however groups can also be used to control radio buttons - or to enforce resize behavior. -*/ class FL_EXPORT Fl_Group : public Fl_Widget { #if 0 // FIXME: 123 int navigation(int); @@ -71,152 +61,36 @@ void begin(); static Fl_Group *current(); static void current(Fl_Group *g); - - /** - Returns how many child widgets the group has. - */ int children() const {return children_;} - /** - Returns array()[n]. <i>No range checking is done!</i> - */ Fl_Widget* child(int n) const {return array()[n];} int find(const Fl_Widget*) const; - /** - See int Fl_Group::find(const Fl_Widget *w) const - */ int find(const Fl_Widget& o) const {return find(&o);} Fl_Widget* const* array() const; - void resize(int,int,int,int); - /** - Creates a new Fl_Group widget using the given position, size, - and label string. The default boxtype is FL_NO_BOX. - */ virtual ~Fl_Group(); void add(Fl_Widget&); - /** - See void Fl_Group::add(Fl_Widget &w) - */ void add(Fl_Widget* o) {add(*o);} void insert(Fl_Widget&, int i); - /** - This does insert(w, find(before)). This will append the - widget if \p before is not in the group. - */ void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));} void remove(int index); void remove(Fl_Widget&); - /** - Removes the widget \p o from the group. - \sa void remove(Fl_Widget&) - */ void remove(Fl_Widget* o) {remove(*o);} void clear(); - - /** - See void Fl_Group::resizable(Fl_Widget *box) - */ void resizable(Fl_Widget& o) {resizable_ = &o;} - /** - The resizable widget defines the resizing box for the group. When the - group is resized it calculates a new size and position for all of its - children. Widgets that are horizontally or vertically inside the - dimensions of the box are scaled to the new size. Widgets outside the - box are moved. - - In these examples the gray area is the resizable: - - \image html resizebox1.png - - \image html resizebox2.png - - \image latex resizebox1.png "before resize" width=4cm - - \image latex resizebox2.png "after resize" width=4cm - - The resizable may be set to the group itself, in which case all the - contents are resized. This is the default value for Fl_Group, - although NULL is the default for Fl_Window and Fl_Pack. - - If the resizable is NULL then all widgets remain a fixed size - and distance from the top-left corner. - - It is possible to achieve any type of resize behavior by using an - invisible Fl_Box as the resizable and/or by using a hierarchy - of child Fl_Group's. - */ void resizable(Fl_Widget* o) {resizable_ = o;} - /** - See void Fl_Group::resizable(Fl_Widget *box) - */ Fl_Widget* resizable() const {return resizable_;} - /** - Adds a widget to the group and makes it the resizable widget. - */ void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);} void init_sizes(); - - /** - Controls whether the group widget clips the drawing of - child widgets to its bounding box. - - Set \p c to 1 if you want to clip the child widgets to the - bounding box. - - The default is to not clip (0) the drawing of child widgets. - */ void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); } - /** - Returns the current clipping mode. - - \return true, if clipping is enabled, false otherwise. - - \see void Fl_Group::clip_children(int c) - */ unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; } - - // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. virtual Fl_Group* as_group() { return this; } - - // back compatibility functions: - - /** - \deprecated This is for backwards compatibility only. You should use - \e W->%take_focus() instead. - \sa Fl_Widget::take_focus(); - */ void focus(Fl_Widget* W) {W->take_focus();} - - /** This is for forms compatibility only */ Fl_Widget* & _ddfdesign_kludge() {return resizable_;} - - /** This is for forms compatibility only */ void forms_end(); #endif }; -// dummy class used to end child groups in constructors for complex -// subclasses of Fl_Group: -/** - This is a dummy class that allows you to end a Fl_Group in a constructor list of a - class: - \code - class MyClass { - Fl_Group group; - Fl_Button button_in_group; - Fl_End end; - Fl_Button button_outside_group; - MyClass(); - }; - MyClass::MyClass() : - group(10,10,100,100), - button_in_group(20,20,60,30), - end(), - button_outside_group(10,120,60,30) - {} - \endcode -*/ class FL_EXPORT Fl_End { #if 0 // FIXME: 123 public: Modified: branches/branch-3.0/FL/Fl_Widget.H =================================================================== --- branches/branch-3.0/FL/Fl_Widget.H 2011-05-27 06:31:17 UTC (rev 8744) +++ branches/branch-3.0/FL/Fl_Widget.H 2011-05-27 15:48:29 UTC (rev 8745) @@ -70,24 +70,58 @@ }; +namespace fltk3 { + inline Fl_Widget *_3to1_widget(Widget *w) { return (Fl_Widget*)w->wrapper(); } + inline Fl_Window *_3to1_window(Widget *w) { return (Fl_Window*)w->wrapper(); } + inline Fl_Group *_3to1_group(Widget *w) { return (Fl_Group*)w->wrapper(); } + //inline Widget *_1to3_widget(Fl_Widget *w) { return ((fltk3::Widget*)_p); } +} + + class FL_EXPORT Fl_Widget : public fltk3::WidgetWrapper { + friend class Fl_Group; +private: + + Fl_Widget(const Fl_Widget &); /* make unavailable */ + + Fl_Widget& operator=(const Fl_Widget &); /* make unavailable */ + protected: - Fl_Widget() {} -#if 0 // FIXME: 123 - Fl_Widget(const Fl_Widget &); - Fl_Widget& operator=(const Fl_Widget &); + Fl_Widget() { /*blank */ } protected: - void x(int v) {x_ = v;} - void y(int v) {y_ = v;} - void w(int v) {w_ = v;} - void h(int v) {h_ = v;} - unsigned int flags() const {return flags_;} - void set_flag(unsigned int c) {flags_ |= c;} - void clear_flag(unsigned int c) {flags_ &= ~c;} + + void x(int v) { + ((fltk3::Widget*)_p)->x(v); + } + + void y(int v) { + ((fltk3::Widget*)_p)->y(v); + } + + void w(int v) { + ((fltk3::Widget*)_p)->w(v); + } + + void h(int v) { + ((fltk3::Widget*)_p)->h(v); + } + + unsigned int flags() const { + return ((fltk3::Widget*)_p)->flags(); + } + + void set_flag(unsigned int c) { + ((fltk3::Widget*)_p)->set_flag(c); + } + + void clear_flag(unsigned int c) { + ((fltk3::Widget*)_p)->clear_flag(c); + } + enum { INACTIVE = 1<<0, INVISIBLE = 1<<1, @@ -111,16 +145,39 @@ USERFLAG2 = 1<<30, USERFLAG1 = 1<<31 }; - void draw_box() const; - void draw_box(Fl_Boxtype t, Fl_Color c) const; - void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const; - void draw_backdrop() const; - void draw_focus() {draw_focus(box(),x(),y(),w(),h());} - void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const; - void draw_label() const; - void draw_label(int, int, int, int) const; -#endif + void draw_box() const { + ((fltk3::Widget*)_p)->draw_box(); + } + + void draw_box(Fl_Boxtype t, Fl_Color c) const { + ((fltk3::Widget*)_p)->draw_box(fltk3::_1to3_boxtype(t), fltk3::_1to3_color(c)); + } + + void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const { + ((fltk3::Widget*)_p)->draw_box(fltk3::_1to3_boxtype(t), x, y, w, h, fltk3::_1to3_color(c)); + } + + void draw_backdrop() const { + ((fltk3::Widget*)_p)->draw_backdrop(); + } + + void draw_focus() { + ((fltk3::Widget*)_p)->draw_focus(); + } + + void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const { + ((fltk3::Widget*)_p)->draw_focus(fltk3::_1to3_boxtype(t), x, y, w, h); + } + + void draw_label() const { + ((fltk3::Widget*)_p)->draw_label(); + } + + void draw_label(int x, int y, int w, int h) const { + ((fltk3::Widget*)_p)->draw_label(x, y, w, h); + } + public: Fl_Widget(int x, int y, int w, int h, const char *label=0L) { _p = new fltk3::Widget(x, y, w, h, label); @@ -131,23 +188,72 @@ virtual ~Fl_Widget(); virtual void draw() = 0; virtual int handle(int event); - Fl_Group* parent() const {return parent_;} - void parent(Fl_Group* p) {parent_ = p;} // for hacks only, use Fl_Group::add() - 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_;} virtual void resize(int x, int y, int w, int h); - 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_Align align() const {return label_.align_;} - void align(Fl_Align alignment) {label_.align_ = alignment;} - Fl_Boxtype box() const {return (Fl_Boxtype)box_;} + virtual void show(); + virtual void hide(); + virtual Fl_Group* as_group() {return 0;} + virtual Fl_Window* as_window() {return 0;} + virtual class Fl_Gl_Window* as_gl_window() {return 0;} #endif + Fl_Group *parent() const { + return fltk3::_3to1_group( ((fltk3::Widget*)_p)->parent() ); + } + + void parent(Fl_Group* p) { + ((fltk3::Widget*)_p)->parent( ((fltk3::Group*)((Fl_Widget*)p)->_p) ); + } + + Fl_Window* window() const { + return fltk3::_3to1_window( ((fltk3::Widget*)_p)->parent() ); + } + + uchar type() const { + return ((fltk3::Widget*)_p)->type(); + } + + void type(uchar t) { + ((fltk3::Widget*)_p)->type(t); + } + + int x() const { + return ((fltk3::Widget*)_p)->x(); + } + + int y() const { + return ((fltk3::Widget*)_p)->y(); + } + + int w() const { + return ((fltk3::Widget*)_p)->w(); + } + + int h() const { + return ((fltk3::Widget*)_p)->h(); + } + + int damage_resize(int,int,int,int); + + void position(int x, int y) { + ((fltk3::Widget*)_p)->position(x, y);; + } + + void size(int w, int h) { + ((fltk3::Widget*)_p)->size(w, h);; + } + + Fl_Align align() const { + return fltk3::_3to1_align(((fltk3::Widget*)_p)->align()); + } + + void align(Fl_Align a) { + ((fltk3::Widget*)_p)->align(fltk3::_1to3_align(a)); + } + + Fl_Boxtype box() const { + return fltk3::_3to1_boxtype(((fltk3::Widget*)_p)->box()); + } + void box(Fl_Boxtype new_box) { ((fltk3::Widget*)_p)->box( fltk3::_1to3_boxtype(new_box) ); } @@ -221,82 +327,251 @@ ((fltk3::Widget*)_p)->labelsize( fltk3::_1to3_fontsize(pix) ); } -#if 0 // FIXME: 123 - Fl_Image* image() {return label_.image;} - const Fl_Image* image() const {return label_.image;} - void image(Fl_Image* img) {label_.image=img;} - void image(Fl_Image& img) {label_.image=&img;} - Fl_Image* deimage() {return label_.deimage;} - const Fl_Image* deimage() const {return label_.deimage;} - void deimage(Fl_Image* img) {label_.deimage=img;} - void deimage(Fl_Image& img) {label_.deimage=&img;} - const char *tooltip() const {return tooltip_;} - void tooltip(const char *text); // see Fl_Tooltip - void copy_tooltip(const char *text); // see Fl_Tooltip - Fl_Callback_p callback() const {return callback_;} - void callback(Fl_Callback* cb, void* p) {callback_=cb; user_data_=p;} - void callback(Fl_Callback* cb) {callback_=cb;} - void callback(Fl_Callback0*cb) {callback_=(Fl_Callback*)cb;} - void callback(Fl_Callback1*cb, long p=0) {callback_=(Fl_Callback*)cb; user_data_=(void*)p;} - void* user_data() const {return user_data_;} - void user_data(void* v) {user_data_ = v;} - long argument() const {return (long)(fl_intptr_t)user_data_;} - void argument(long v) {user_data_ = (void*)v;} - Fl_When when() const {return (Fl_When)when_;} - void when(uchar i) {when_ = i;} - unsigned int visible() const {return !(flags_&INVISIBLE);} - int visible_r() const; - virtual void show(); - virtual void hide(); - void set_visible() {flags_ &= ~INVISIBLE;} - void clear_visible() {flags_ |= INVISIBLE;} - unsigned int active() const {return !(flags_&INACTIVE);} - int active_r() const; - void activate(); - void deactivate(); - unsigned int output() const {return (flags_&OUTPUT);} - void set_output() {flags_ |= OUTPUT;} - void clear_output() {flags_ &= ~OUTPUT;} - unsigned int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));} - unsigned int changed() const {return flags_&CHANGED;} - void set_changed() {flags_ |= CHANGED;} - void clear_changed() {flags_ &= ~CHANGED;} - int take_focus(); - 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(); } - unsigned int visible_focus() { return flags_ & VISIBLE_FOCUS; } - static void default_callback(Fl_Widget *cb, void *d); - void do_callback() {do_callback(this,user_data_);} - void do_callback(Fl_Widget* o,long arg) {do_callback(o,(void*)arg);} - void do_callback(Fl_Widget* o,void* arg=0); - int test_shortcut(); - static unsigned int label_shortcut(const char *t); - static int test_shortcut(const char*, const bool require_alt = false); - int contains(const Fl_Widget *w) const ; - int inside(const Fl_Widget* w) const {return w ? w->contains(this) : 0;} - void redraw(); - void redraw_label(); - uchar damage() const {return damage_;} - void clear_damage(uchar c = 0) {damage_ = c;} - void damage(uchar c); - void damage(uchar c, int x, int y, int w, int h); - void draw_label(int, int, int, int, Fl_Align) const; - void measure_label(int& ww, int& hh) const {label_.measure(ww, hh);} - Fl_Window* window() const ; - virtual Fl_Group* as_group() {return 0;} - virtual Fl_Window* as_window() {return 0;} - virtual class Fl_Gl_Window* as_gl_window() {return 0;} - Fl_Color color2() const {return (Fl_Color)color2_;} - void color2(unsigned a) {color2_ = a;} -#endif + Fl_Image* image() { + return 0L; // FIXME: 123 + } + + const Fl_Image* image() const { + return 0L; // FIXME: 123 + } + + void image(Fl_Image* img) { + // FIXME: 123 + } + + void image(Fl_Image& img) { + // FIXME: 123 + } + + Fl_Image* deimage() { + return 0L; // FIXME: 123 + } + + const Fl_Image* deimage() const { + return 0L; // FIXME: 123 + } + + void deimage(Fl_Image* img) { + // FIXME: 123 + } + + void deimage(Fl_Image& img) { + // FIXME: 123 + } + + const char *tooltip() const { + return ((fltk3::Widget*)_p)->tooltip(); + } + + void tooltip(const char *text) { + ((fltk3::Widget*)_p)->tooltip(text); + } + + void copy_tooltip(const char *text) { + ((fltk3::Widget*)_p)->copy_tooltip(text); + } + + Fl_Callback_p callback() const { + return (Fl_Callback_p)((fltk3::Widget*)_p)->callback(); + } + + void callback(Fl_Callback* cb, void* p) { + ((fltk3::Widget*)_p)->callback( (fltk3::Callback*)cb, p ); + } + + void callback(Fl_Callback* cb) { + ((fltk3::Widget*)_p)->callback( (fltk3::Callback*)cb ); + } + + void callback(Fl_Callback0*cb) { + ((fltk3::Widget*)_p)->callback( (fltk3::Callback0*)cb ); + } + + void callback(Fl_Callback1*cb, long p=0) { + ((fltk3::Widget*)_p)->callback( (fltk3::Callback1*)cb, p ); + } + + void *user_data() const { + return ((fltk3::Widget*)_p)->user_data(); + } + + void user_data(void *v) { + ((fltk3::Widget*)_p)->user_data(v); + } + + long argument() const { + return ((fltk3::Widget*)_p)->argument(); + } + + void argument(long v) { + ((fltk3::Widget*)_p)->argument(v); + } + + Fl_When when() const { + return fltk3::_3to1_when( ((fltk3::Widget*)_p)->when() ); + } + + void when(uchar i) { + ((fltk3::Widget*)_p)->when( fltk3::_1to3_when((Fl_When)i) ); + } + + unsigned int visible() const { + return ((fltk3::Widget*)_p)->visible(); + } + + int visible_r() const { + return ((fltk3::Widget*)_p)->visible_r(); + } + + void set_visible() { + ((fltk3::Widget*)_p)->set_visible(); + } + + void clear_visible() { + ((fltk3::Widget*)_p)->clear_visible(); + } + + unsigned int active() const { + return ((fltk3::Widget*)_p)->active(); + } + + int active_r() const { + return ((fltk3::Widget*)_p)->active_r(); + } + + void activate() { + ((fltk3::Widget*)_p)->activate(); + } + + void deactivate() { + ((fltk3::Widget*)_p)->deactivate(); + } + + unsigned int output() const { + return ((fltk3::Widget*)_p)->output(); + } + + void set_output() { + ((fltk3::Widget*)_p)->set_output(); + } + + void clear_output() { + ((fltk3::Widget*)_p)->clear_output(); + } + + unsigned int takesevents() const { + return ((fltk3::Widget*)_p)->takesevents(); + } + + unsigned int changed() const { + return ((fltk3::Widget*)_p)->changed(); + } + + void set_changed() { + ((fltk3::Widget*)_p)->set_changed(); + } + + void clear_changed() { + ((fltk3::Widget*)_p)->clear_changed(); + } + + int take_focus() { + return ((fltk3::Widget*)_p)->take_focus(); + } + + void set_visible_focus() { + ((fltk3::Widget*)_p)->set_visible_focus(); + } + + void clear_visible_focus() { + ((fltk3::Widget*)_p)->clear_visible_focus(); + } + + void visible_focus(int v) { + ((fltk3::Widget*)_p)->visible_focus(v); + } + + unsigned int visible_focus() { + return ((fltk3::Widget*)_p)->visible_focus(); + } + + static void default_callback(Fl_Widget *cb, void *d) { + fltk3::Widget::default_callback( (fltk3::Widget*)(cb->_p), d ); + } + + void do_callback() { + ((fltk3::Widget*)_p)->do_callback(); + } + + void do_callback(Fl_Widget* o,long arg) { + ((fltk3::Widget*)_p)->do_callback( (fltk3::Widget*)(o->_p), arg ); + } + + void do_callback(Fl_Widget* o,void* arg=0) { + ((fltk3::Widget*)_p)->do_callback( (fltk3::Widget*)(o->_p), arg ); + } + + int test_shortcut() { + return ((fltk3::Widget*)_p)->test_shortcut(); + } + + static unsigned int label_shortcut(const char *t) { + return fltk3::Widget::label_shortcut(t); + } + + static int test_shortcut(const char *s, const bool require_alt = false) { + return fltk3::Widget::test_shortcut(s, require_alt); + } + + int contains(const Fl_Widget *w) const { + return ((fltk3::Widget*)_p)->contains((fltk3::Widget*)(w->_p)); + } + + int inside(const Fl_Widget* w) const { + return ((fltk3::Widget*)_p)->inside((fltk3::Widget*)(w->_p)); + } + + void redraw() { + ((fltk3::Widget*)_p)->redraw(); + } + + void redraw_label() { + ((fltk3::Widget*)_p)->redraw_label(); + } + + uchar damage() const { + return fltk3::_3to1_damage( ((fltk3::Widget*)_p)->damage() ); + } + + void clear_damage(uchar c = 0) { + ((fltk3::Widget*)_p)->clear_damage(); + } + + void damage(uchar c) { + ((fltk3::Widget*)_p)->damage( fltk3::_1to3_damage((Fl_Damage)c) ); + } + + void damage(uchar c, int x, int y, int w, int h) { + ((fltk3::Widget*)_p)->damage( fltk3::_1to3_damage((Fl_Damage)c), x, y, w, h ); + } + + void draw_label(int x, int y, int w, int h, Fl_Align a) const { + ((fltk3::Widget*)_p)->draw_label( x, y, w, h, fltk3::_1to3_align(a) ); + } + + void measure_label(int& ww, int& hh) const { + ((fltk3::Widget*)_p)->measure_label( ww, hh ); + } + + Fl_Color color2() const { + return fltk3::_3to1_color(((fltk3::Widget*)_p)->color2()); + } + + void color2(unsigned a) { + ((fltk3::Widget*)_p)->color2( fltk3::_1to3_color(a) ); + } }; -/** - 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 Modified: branches/branch-3.0/FL/Fl_Window.H =================================================================== --- branches/branch-3.0/FL/Fl_Window.H 2011-05-27 06:31:17 UTC (rev 8744) +++ branches/branch-3.0/FL/Fl_Window.H 2011-05-27 15:48:29 UTC (rev 8745) @@ -25,9 +25,6 @@ // http://www.fltk.org/str.php // -/* \file - Fl_Window widget . */ - #ifndef Fl_Window_H #define Fl_Window_H @@ -41,76 +38,18 @@ class Fl_X; -/** - This widget produces an actual window. This can either be a main - window, with a border and title and all the window management controls, - or a "subwindow" inside a window. This is controlled by whether or not - the window has a parent(). - - Once you create a window, you usually add children Fl_Widget - 's to it by using window->add(child) for each new widget. - See Fl_Group for more information on how to add and remove children. - - There are several subclasses of Fl_Window that provide - double-buffering, overlay, menu, and OpenGL support. - - The window's callback is done if the user tries to close a window - using the window manager and Fl::modal() is zero or equal to the - window. Fl_Window has a default callback that calls Fl_Window::hide(). -*/ class FL_EXPORT Fl_Window : public Fl_Group { -#if 0 // FIXME: 123 - static char *default_xclass_; - - friend class Fl_X; - Fl_X *i; // points at the system-specific stuff - - const char* iconlabel_; - char* xclass_; - const void* icon_; - // size_range stuff: - int minw, minh, maxw, maxh; - int dw, dh, aspect; - uchar size_range_set; - // cursor stuff - Fl_Cursor cursor_default; - Fl_Color cursor_fg, cursor_bg; - void size_range_(); - void _Fl_Window(); // constructor innards - - // unimplemented copy ctor and assignment operator Fl_Window(const Fl_Window&); Fl_Window& operator=(const Fl_Window&); -protected: +#if 0 // FIXME: 123 - /** Stores the last window that was made current. See current() const */ - static Fl_Window *current_; +protected: + virtual void draw(); - /** Forces the window to be drawn, this window is also made current and calls draw(). */ virtual void flush(); - - /** - Sets an internal flag that tells FLTK and the window manager to - honor position requests. - - This is used internally and should not be needed by user code. - - \param[in] force 1 to set the FORCE_POSITION flag, 0 to clear it - */ - void force_position(int force) { - if (force) set_flag(FORCE_POSITION); - else clear_flag(FORCE_POSITION); - } - /** - Returns the internal state of the window's FORCE_POSITION flag. - - \retval 1 if flag is set - \retval 0 otherwise - - \see force_position(int) - */ + void force_position(int force); int force_position() const { return ((flags() & FORCE_POSITION)?1:0); } #endif @@ -121,246 +60,43 @@ } #if 0 // FIXME: 123 - /** Creates a window from the given position, size and title. - - \see Fl_Window(int w, int h, const char *title) - */ - Fl_Window(int x, int y, int w, int h, const char* title = 0); - /** - The destructor <I>also deletes all the children</I>. This allows a - whole tree to be deleted at once, without having to keep a pointer to - all the children in the user code. A kludge has been done so the - Fl_Window and all of its children can be automatic (local) - variables, but you must declare the Fl_Window <I>first</I> so - that it is destroyed last. - */ - virtual ~Fl_Window(); - + Fl_Window(int x, int y, int w, int h, const char* title = 0); + virtual ~Fl_Window(); virtual int handle(int); - - /** - Changes the size and position of the window. If shown() is true, - these changes are communicated to the window server (which may - refuse that size and cause a further resize). If shown() is - false, the size and position are used when show() is called. - See Fl_Group for the effect of resizing on the child widgets. - - You can also call the Fl_Widget methods size(x,y) and position(w,h), - which are inline wrappers for this virtual function. - - A top-level window can not force, but merely suggest a position and - size to the operating system. The window manager may not be willing or - able to display a window at the desired position or with the given - dimensions. It is up to the application developer to verify window - parameters after the resize request. - */ virtual void resize(int,int,int,int); - /** - Sets whether or not the window manager border is around the - window. The default value is true. void border(int) can be - used to turn the border on and off. <I>Under most X window - managers this does not work after show() has been called, - although SGI's 4DWM does work.</I> - */ void border(int b); - /** - Fast inline function to turn the window manager border - off. It only works before show() is called. - */ void clear_border() {set_flag(NOBORDER);} - /** See void Fl_Window::border(int) */ unsigned int border() const {return !(flags() & NOBORDER);} - /** Activates the flags NOBORDER|FL_OVERRIDE */ void set_override() {set_flag(NOBORDER|OVERRIDE);} - /** Returns non zero if FL_OVERRIDE flag is set, 0 otherwise. */ unsigned int override() const { return flags()&OVERRIDE; } - /** - A "modal" window, when shown(), will prevent any events from - being delivered to other windows in the same program, and will also - remain on top of the other windows (if the X window manager supports - the "transient for" property). Several modal windows may be shown at - once, in which case only the last one shown gets events. You can see - which window (if any) is modal by calling Fl::modal(). - */ void set_modal() {set_flag(MODAL);} - /** Returns true if this window is modal. */ unsigned int modal() const {return flags() & MODAL;} - /** - A "non-modal" window (terminology borrowed from Microsoft Windows) - acts like a modal() one in that it remains on top, but it has - no effect on event delivery. There are <I>three</I> states for a - window: modal, non-modal, and normal. - */ void set_non_modal() {set_flag(NON_MODAL);} - /** Returns true if this window is modal or non-modal. */ unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);} - - /** - Marks the window as a menu window. - - This is intended for internal use, but it can also be used if you - write your own menu handling. However, this is not recommended. - - This flag is used for correct "parenting" of windows in communication - with the windowing system. Modern X window managers can use different - flags to distinguish menu and tooltip windows from normal windows. - - This must be called before the window is shown and cannot be changed - later. - */ void set_menu_window() {set_flag(MENU_WINDOW);} - - /** Returns true if this window is a menu window. */ unsigned int menu_window() const {return flags() & MENU_WINDOW;} - - /** - Marks the window as a tooltip window. - - This is intended for internal use, but it can also be used if you - write your own tooltip handling. However, this is not recommended. - - This flag is used for correct "parenting" of windows in communication - with the windowing system. Modern X window managers can use different - flags to distinguish menu and tooltip windows from normal windows. - - This must be called before the window is shown and cannot be changed - later. - - \note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this - also \b clears the menu_window() state. - */ - void set_tooltip_window() { set_flag(TOOLTIP_WINDOW); - clear_flag(MENU_WINDOW); } - /** Returns true if this window is a tooltip window. */ + void set_tooltip_window(); unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;} - - /** - Positions the window so that the mouse is pointing at the given - position, or at the center of the given widget, which may be the - window itself. If the optional offscreen parameter is - non-zero, then the window is allowed to extend off the screen (this - does not work with some X window managers). \see position() - */ void hotspot(int x, int y, int offscreen = 0); - /** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */ void hotspot(const Fl_Widget*, int offscreen = 0); - /** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */ void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);} - - /** - Undoes the effect of a previous resize() or show() so that the next time - show() is called the window manager is free to position the window. - - This is for Forms compatibility only. - - \deprecated please use force_position(0) instead - */ void free_position() {clear_flag(FORCE_POSITION);} - /** - Sets the allowable range the user can resize this window to. - This only works for top-level windows. - <UL> - <LI>minw and minh are the smallest the window can be. - Either value must be greater than 0.</LI> - <LI>maxw and maxh are the largest the window can be. If either is - <I>equal</I> to the minimum then you cannot resize in that direction. - If either is zero then FLTK picks a maximum size in that direction - such that the window will fill the screen.</LI> - <LI>dw and dh are size increments. The window will be constrained - to widths of minw + N * dw, where N is any non-negative integer. - If these are less or equal to 1 they are ignored (this is ignored - on WIN32).</LI> - <LI>aspect is a flag that indicates that the window should preserve its - aspect ratio. This only works if both the maximum and minimum have - the same aspect ratio (ignored on WIN32 and by many X window managers). - </LI> - </UL> - - If this function is not called, FLTK tries to figure out the range - from the setting of resizable(): - <UL> - <LI>If resizable() is NULL (this is the default) then the window cannot - be resized and the resize border and max-size control will not be - displayed for the window.</LI> - <LI>If either dimension of resizable() is less than 100, then that is - considered the minimum size. Otherwise the resizable() has a minimum - size of 100.</LI> - <LI>If either dimension of resizable() is zero, then that is also the - maximum size (so the window cannot resize in that direction).</LI> - </UL> - - It is undefined what happens if the current size does not fit in the - constraints passed to size_range(). - */ - void size_range(int a, int b, int c=0, int d=0, int e=0, int f=0, int g=0) { - minw=a; minh=b; maxw=c; maxh=d; dw=e; dh=f; aspect=g; size_range_();} - - /** See void Fl_Window::label(const char*) */ + void size_range(int a, int b, int c=0, int d=0, int e=0, int f=0, int g=0); const char* label() const {return Fl_Widget::label();} - /** See void Fl_Window::iconlabel(const char*) */ const char* iconlabel() const {return iconlabel_;} - /** Sets the window title bar label. */ void label(const char*); - /** Sets the icon label. */ void iconlabel(const char*); - /** Sets the icon label. */ void label(const char* label, const char* iconlabel); // platform dependent void copy_label(const char* a); - static void default_xclass(const char*); static const char *default_xclass(); const char* xclass() const; void xclass(const char* c); const void* icon() const; void icon(const void * ic); - - /** - Returns non-zero if show() has been called (but not hide() - ). You can tell if a window is iconified with (w->shown() - && !w->visible()). - */ int shown() {return i != 0;} - /** - Puts the window on the screen. Usually (on X) this has the side - effect of opening the display. - - If the window is already shown then it is restored and raised to the - top. This is really convenient because your program can call show() - at any time, even if the window is already up. It also means that - show() serves the purpose of raise() in other toolkits. - - Fl_Window::show(int argc, char **argv) is used for top-level - windows and allows standard arguments to be parsed from the - command-line. - - \see Fl_Window::show(int argc, char **argv) - */ virtual void show(); - /** - Removes the window from the screen. If the window is already hidden or - has not been shown then this does nothing and is harmless. - */ virtual void hide(); - /** - Puts the window on the screen and parses command-line arguments. - - Usually (on X) this has the side effect of opening the display. - - This form should be used for top-level windows, at least for the - first (main) window. It allows standard arguments to be parsed - from the command-line. You can use \p argc and \p argv from - main(int argc, char **argv) for this call. - - The first call also sets up some system-specific internal - variables like the system colors. - - \todo explain which system parameters are set up. - - \param argc command-line argument count, usually from main() - \param argv command-line argument vector, usually from main() - - \see virtual void Fl_Window::show() - */ #endif void show(int argc, char **argv) { @@ -368,79 +104,18 @@ } #if 0 // FIXME: 123 - /** - Makes the window completely fill the screen, without any window - manager border visible. You must use fullscreen_off() to undo - this. This may not work with all window managers. - */ void fullscreen(); - /** - Turns off any side effects of fullscreen() and does - resize(x,y,w,h). - */ void fullscreen_off(int,int,int,int); - /** - Iconifies the window. If you call this when shown() is false - it will show() it as an icon. If the window is already - iconified this does nothing. - - Call show() to restore the window. - - When a window is iconified/restored (either by these calls or by the - user) the handle() method is called with FL_HIDE and - FL_SHOW events and visible() is turned on and off. - - There is no way to control what is drawn in the icon except with the - string passed to Fl_Window::xclass(). You should not rely on - window managers displaying the icons. - */ void iconize(); - int x_root() const ; int y_root() const ; - - static Fl_Window *current(); - /** - Sets things up so that the drawing functions in <FL/fl_draw.H> will go - into this window. This is useful for incremental update of windows, such - as in an idle callback, which will make your program behave much better - if it draws a slow graphic. <B>Danger: incremental update is very hard to - debug and maintain!</B> - - This method only works for the Fl_Window and Fl_Gl_Window derived classes. - */ + static Fl_Window *current(); void make_current(); - - // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. virtual Fl_Window* as_window() { return this; } - - /** - Changes the cursor for this window. This always calls the system, if - you are changing the cursor a lot you may want to keep track of how - you set it in a static variable and call this only if the new cursor - is different. - - The type Fl_Cursor is an enumeration defined in <FL/Enumerations.H>. - (Under X you can get any XC_cursor value by passing - Fl_Cursor((XC_foo/2)+1)). The colors only work on X, they are - not implemented on WIN32. - - For back compatibility only. - */ void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); // platform dependent void default_cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); static void default_callback(Fl_Window*, void* v); - - /** Returns the window width including any frame added by the window manager. - - Same as w() if applied to a subwindow. - */ int decorated_w(); - /** Returns the window height including any window title bar and any frame - added by the window manager. - - Same as h() if applied to a subwindow. - */ int decorated_h(); #endif Modified: branches/branch-3.0/fltk/Widget.h =================================================================== --- branches/branch-3.0/fltk/Widget.h 2011-05-27 06:31:17 UTC (rev 8744) +++ branches/branch-3.0/fltk/Widget.h 2011-05-27 15:48:29 UTC (rev 8745) @@ -294,39 +294,7 @@ void* foreach(const AssociationType&, AssociationFunctor&) const; bool remove(const AssociationType&, void* data); bool find(const AssociationType&, void* data) const; - -#ifdef FLTK_1_WIDGET // back-compatability section: - - Box* down_box() const { return box(); } - Box* slider() const { return buttonbox(); } - Box* box2() const { return box(); } - Box* fly_box() const { return box(); } - Color color2() const { return selection_color(); } - Color color3() const { return buttoncolor(); } - Color down_labelcolor() const { return selection_textcolor(); } - Color fly_color() const { return highlight_color(); } - Color selected_textcolor() const { return selection_textcolor(); } - Color cursor_color() const { return selection_color(); } - float text_size() const { return textsize(); } - float label_size() const { return labelsize(); } - - void down_box(Box* a) { box(a); } - void slider(Box* a) { buttonbox(a); } - void fly_box(Box*) { } - void color(Color a, Color b) { color(a); selection_color(b); } - void color2(Color a) { selection_color(a); } - void color3(Color a) { buttoncolor(a); } - void down_labelcolor(Color a) { selection_textcolor(a); } - void labelfont(unsigned a) { labelfont(font(a)); } - void fly_color(Color a) { highlight_color(a); } - void textfont(unsigned a) { textfont(font(a)); } - void selected_textcolor(Color a) { selection_textcolor(a); } - void cursor_color(Color a) { selection_color(a); } - void text_size(float n) { textsize(n); } - void label_size(float n) { labelsize(n); } - -#endif - + private: const char* label_; Modified: branches/branch-3.0/fltk3/Widget.h =================================================================== --- branches/branch-3.0/fltk3/Widget.h 2011-05-27 06:31:17 UTC (rev 8744) +++ branches/branch-3.0/fltk3/Widget.h 2011-05-27 15:48:29 UTC (rev 8745) @@ -50,6 +50,8 @@ typedef unsigned long fl_uintptr_t; #endif +class Fl_Widget; + namespace fltk3 { class Widget; class Group; @@ -111,6 +113,7 @@ */ class FLTK3_EXPORT Widget : public Rectangle { friend class Group; + friend class ::Fl_Widget; fltk3::Group* parent_; fltk3::Callback* callback_; @@ -859,7 +862,7 @@ \return a bitmap of flags describing the kind of damage to the widget \see damage(uchar), clear_damage(uchar) */ - uchar damage() const {return damage_;} + fltk3::Damage damage() const {return (fltk3::Damage)damage_;} /** Clears or sets the damage flags. Damage flags are cleared when parts of the widget drawing is repaired. _______________________________________________ fltk-commit mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-commit
