Author: AlbrechtS Date: 2009-02-18 01:27:54 -0800 (Wed, 18 Feb 2009) New Revision: 6664 Log: Modified all public widget draw methods to be protected.
ToDo: Documentation updates. Modified: branches/branch-1.3/ branches/branch-1.3/FL/Fl_Cairo_Window.H branches/branch-1.3/FL/Fl_File_Input.H branches/branch-1.3/FL/Fl_Gl_Window.H branches/branch-1.3/FL/Fl_Input.H branches/branch-1.3/FL/Fl_Pack.H branches/branch-1.3/FL/Fl_Slider.H branches/branch-1.3/FL/Fl_Value_Input.H branches/branch-1.3/FL/Fl_Value_Output.H branches/branch-1.3/FL/Fl_Value_Slider.H branches/branch-1.3/src/Fl_Value_Input.cxx Property changes on: branches/branch-1.3 ___________________________________________________________________ Name: merge-url - http://svn.easysw.com/public/fltk/fltk/branches/branch-1.3 Name: merge-revision - 6345 Modified: branches/branch-1.3/FL/Fl_Cairo_Window.H =================================================================== --- branches/branch-1.3/FL/Fl_Cairo_Window.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Cairo_Window.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -45,7 +45,7 @@ /** This defines a pre-configured cairo fltk window. - This class overloads for you the virtual draw() method, + This class overloads the virtual draw() method for you, so that the only thing you have to do is to provide your cairo code. All cairo context handling is achieved transparently. \note You can alternatively define your custom cairo fltk window, @@ -55,23 +55,28 @@ the current window. \see Fl_Window::current() */ class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window { + public: - Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {} - /** Overloaded to provide cairo callback support */ - void draw() { - Fl_Double_Window::draw(); - // manual method ? if yes explicitly get a cairo_context here - if (!Fl::cairo_autolink_context()) - Fl::cairo_make_current(this); - if (draw_cb_) draw_cb_(this, Fl::cairo_cc()); - } - /** This defines the cairo draw calback prototype that you must further */ - typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def); - /** - You must provide a draw callback which will implement your cairo rendering, - This method will permit you to set you \a cb cairo callback. - */ - void set_draw_cb(cairo_draw_cb cb){draw_cb_=cb;} + Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {} + +protected: + /** Overloaded to provide cairo callback support */ + void draw() { + Fl_Double_Window::draw(); + // manual method ? if yes explicitly get a cairo_context here + if (!Fl::cairo_autolink_context()) + Fl::cairo_make_current(this); + if (draw_cb_) draw_cb_(this, Fl::cairo_cc()); + } + +public: + /** This defines the cairo draw callback prototype that you must further */ + typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def); + /** + You must provide a draw callback which will implement your cairo rendering. + This method will permit you to set your cairo callback to \a cb. + */ + void set_draw_cb(cairo_draw_cb cb){draw_cb_=cb;} private: cairo_draw_cb draw_cb_; }; Modified: branches/branch-1.3/FL/Fl_File_Input.H =================================================================== --- branches/branch-1.3/FL/Fl_File_Input.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_File_Input.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -68,8 +68,11 @@ Fl_File_Input(int X, int Y, int W, int H, const char *L=0); virtual int handle(int event); + +protected: virtual void draw(); +public: /** Gets the box type used for the navigation bar. */ Fl_Boxtype down_box() const { return (Fl_Boxtype)down_box_; } /** Sets the box type to use for the navigation bar. */ Modified: branches/branch-1.3/FL/Fl_Gl_Window.H =================================================================== --- branches/branch-1.3/FL/Fl_Gl_Window.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Gl_Window.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -35,7 +35,7 @@ #ifndef GLContext /** - opaque pointer type to hide system specific implementation. + Opaque pointer type to hide system specific implementation. */ typedef void* GLContext; // actually a GLXContext or HGLDC #endif @@ -43,22 +43,24 @@ class Fl_Gl_Choice; // structure to hold result of glXChooseVisual /** - The Fl_Gl_Window widget sets things up so OpenGL works, and - also keeps an OpenGL "context" for that window, so that changes to the + The Fl_Gl_Window widget sets things up so OpenGL works. + + It also keeps an OpenGL "context" for that window, so that changes to the lighting and projection may be reused between redraws. Fl_Gl_Window - also flushes the OpenGL streams and swaps buffers after draw() - returns. - <P>OpenGL hardware typically provides some overlay bit planes, which + also flushes the OpenGL streams and swaps buffers after draw() returns. + + OpenGL hardware typically provides some overlay bit planes, which are very useful for drawing UI controls atop your 3D graphics. If the - overlay hardware is not provided, FLTK tries to simulate the overlay, + overlay hardware is not provided, FLTK tries to simulate the overlay. This works pretty well if your graphics are double buffered, but not - very well for single-buffered. </P> - <P>Please note that the FLTK drawing and clipping functions + very well for single-buffered. + + Please note that the FLTK drawing and clipping functions will not work inside an Fl_Gl_Window. All drawing should be done using OpenGL calls exclusively. Even though Fl_Gl_Window is derived from Fl_Group, it is not useful to add other FLTK Widgets as children, - unless those Widgets are modified to draw using OpenGL calls. + unless those widgets are modified to draw using OpenGL calls. */ class FL_EXPORT Fl_Gl_Window : public Fl_Window { @@ -87,11 +89,10 @@ void resize(int,int,int,int); /** - Is turned off when FLTK creates a new - context for this window or when the window resizes, and is turned on <I> - after</I> draw() is called. You can use this inside your - draw() method to avoid unneccessarily initializing the OpenGL - context. Just do this: + Is turned off when FLTK creates a new context for this window or + when the window resizes, and is turned on \e after draw() is called. + You can use this inside your draw() method to avoid unnecessarily + initializing the OpenGL context. Just do this: \code void mywindow::draw() { if (!valid()) { @@ -130,11 +131,11 @@ */ void context_valid(char v) {if (v) valid_f_ |= 2; else valid_f_ &= 0xfd;} - /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ + /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ static int can_do(int m) {return can_do(m,0);} - /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ + /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ static int can_do(const int *m) {return can_do(0, m);} - /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ + /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ int can_do() {return can_do(mode_,alist);} /** Set or change the OpenGL capabilites of the window. The value can be @@ -188,8 +189,8 @@ */ int can_do_overlay(); /** - This method causes draw_overlay to be called at a later time. - Initially the overlay is clear, if you want the window to display + This method causes draw_overlay() to be called at a later time. + Initially the overlay is clear. If you want the window to display something in the overlay when it first appears, you must call this immediately after you show() your window. */ @@ -219,7 +220,12 @@ Fl_Gl_Window(int X, int Y, int W, int H, const char *l=0) : Fl_Window(X,Y,W,H,l) {init();} - // you *must* override the draw method +protected: + /** + Draws the Fl_Gl_Window. + + You \e \b must override the draw() method. + */ virtual void draw(); }; Modified: branches/branch-1.3/FL/Fl_Input.H =================================================================== --- branches/branch-1.3/FL/Fl_Input.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Input.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -247,8 +247,9 @@ int shift_position(int p); int shift_up_down_position(int p); void handle_mouse(int keepmark=0); +protected: + void draw(); public: - void draw(); int handle(int); Fl_Input(int,int,int,int,const char * = 0); }; Modified: branches/branch-1.3/FL/Fl_Pack.H =================================================================== --- branches/branch-1.3/FL/Fl_Pack.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Pack.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -51,12 +51,17 @@ */ class FL_EXPORT Fl_Pack : public Fl_Group { int spacing_; + public: enum { // values for type(int) VERTICAL = 0, HORIZONTAL = 1 }; + +protected: void draw(); + +public: Fl_Pack(int x,int y,int w ,int h,const char *l = 0); /** Gets the number of extra pixels of blank space that are added Modified: branches/branch-1.3/FL/Fl_Slider.H =================================================================== --- branches/branch-1.3/FL/Fl_Slider.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Slider.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -80,10 +80,10 @@ // these allow subclasses to put the slider in a smaller area: void draw(int, int, int, int); int handle(int, int, int, int, int); + void draw(); public: - void draw(); int handle(int); Fl_Slider(int x,int y,int w,int h, const char *l = 0); Fl_Slider(uchar t,int x,int y,int w,int h, const char *l); Modified: branches/branch-1.3/FL/Fl_Value_Input.H =================================================================== --- branches/branch-1.3/FL/Fl_Value_Input.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Value_Input.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -73,7 +73,9 @@ virtual void value_damage(); // cause damage() due to value() changing public: int handle(int); +protected: void draw(); +public: void resize(int,int,int,int); Fl_Value_Input(int x,int y,int w,int h,const char *l=0); ~Fl_Value_Input(); Modified: branches/branch-1.3/FL/Fl_Value_Output.H =================================================================== --- branches/branch-1.3/FL/Fl_Value_Output.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Value_Output.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -52,9 +52,12 @@ Fl_Fontsize textsize_; uchar soft_; unsigned textcolor_; + +protected: + void draw(); + public: int handle(int); - void draw(); Fl_Value_Output(int x,int y,int w,int h,const char *l=0); /** Modified: branches/branch-1.3/FL/Fl_Value_Slider.H =================================================================== --- branches/branch-1.3/FL/Fl_Value_Slider.H 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/FL/Fl_Value_Slider.H 2009-02-18 09:27:54 UTC (rev 6664) @@ -43,8 +43,9 @@ Fl_Font textfont_; Fl_Fontsize textsize_; unsigned textcolor_; +protected: + void draw(); public: - void draw(); int handle(int); Fl_Value_Slider(int x,int y,int w,int h, const char *l = 0); /** Gets the typeface of the text in the value box. */ Modified: branches/branch-1.3/src/Fl_Value_Input.cxx =================================================================== --- branches/branch-1.3/src/Fl_Value_Input.cxx 2009-02-16 15:36:16 UTC (rev 6663) +++ branches/branch-1.3/src/Fl_Value_Input.cxx 2009-02-18 09:27:54 UTC (rev 6664) @@ -52,7 +52,7 @@ if (damage()&~FL_DAMAGE_CHILD) input.clear_damage(FL_DAMAGE_ALL); input.box(box()); input.color(color(), selection_color()); - input.draw(); + Fl_Widget *i = &input; i->draw(); // calls protected input.draw() input.clear_damage(); } _______________________________________________ fltk-commit mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-commit
