Skip to content

Commit

Permalink
Modified all public widget draw methods to be protected.
Browse files Browse the repository at this point in the history
ToDo: Documentation updates.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6664 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Albrecht Schlosser committed Feb 18, 2009
1 parent e83060f commit 5e9a5f3
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 43 deletions.
39 changes: 22 additions & 17 deletions FL/Fl_Cairo_Window.H
Expand Up @@ -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,
Expand All @@ -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) {}

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:
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;}
/** 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_;
};
Expand Down
3 changes: 3 additions & 0 deletions FL/Fl_File_Input.H
Expand Up @@ -68,8 +68,11 @@ public:
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. */
Expand Down
48 changes: 27 additions & 21 deletions FL/Fl_Gl_Window.H
Expand Up @@ -35,30 +35,32 @@

#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

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 {

Expand Down Expand Up @@ -87,11 +89,10 @@ public:
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()) {
Expand Down Expand Up @@ -130,11 +131,11 @@ public:
*/
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
Expand Down Expand Up @@ -188,8 +189,8 @@ public:
*/
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.
*/
Expand Down Expand Up @@ -219,7 +220,12 @@ public:
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();
};

Expand Down
3 changes: 2 additions & 1 deletion FL/Fl_Input.H
Expand Up @@ -247,8 +247,9 @@ class FL_EXPORT Fl_Input : public Fl_Input_ {
int shift_position(int p);
int shift_up_down_position(int p);
void handle_mouse(int keepmark=0);
public:
protected:
void draw();
public:
int handle(int);
Fl_Input(int,int,int,int,const char * = 0);
};
Expand Down
5 changes: 5 additions & 0 deletions FL/Fl_Pack.H
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion FL/Fl_Slider.H
Expand Up @@ -80,10 +80,10 @@ protected:
// 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);
Expand Down
2 changes: 2 additions & 0 deletions FL/Fl_Value_Input.H
Expand Up @@ -73,7 +73,9 @@ private:
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();
Expand Down
5 changes: 4 additions & 1 deletion FL/Fl_Value_Output.H
Expand Up @@ -52,9 +52,12 @@ class FL_EXPORT Fl_Value_Output : public Fl_Valuator {
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);

/**
Expand Down
3 changes: 2 additions & 1 deletion FL/Fl_Value_Slider.H
Expand Up @@ -43,8 +43,9 @@ class FL_EXPORT Fl_Value_Slider : public Fl_Slider {
Fl_Font textfont_;
Fl_Fontsize textsize_;
unsigned textcolor_;
public:
protected:
void draw();
public:
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. */
Expand Down
2 changes: 1 addition & 1 deletion src/Fl_Value_Input.cxx
Expand Up @@ -52,7 +52,7 @@ void Fl_Value_Input::draw() {
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();
}

Expand Down

0 comments on commit 5e9a5f3

Please sign in to comment.