DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2400
Version: 1.3-feature
Here is a patch to apply to FLTK 1.3 svn trunk that makes clip and matrix
stack and related functions members of class Fl_Graphics_Driver.
I tested it first on my own fltk working version, applied the diffs to my
fltk 1.3 svn trunk compiled and tested (I mean everything compiled and
linked fine and run some of the test programs and they seem to work as
expected).
All test was made on a win32 machine.
Link: http://www.fltk.org/str.php?L2400
Version: 1.3-feature
Index: FL/Fl_Device.H
===================================================================
--- FL/Fl_Device.H (revision 7677)
+++ FL/Fl_Device.H (working copy)
@@ -65,6 +65,27 @@
*/
typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
+#define REGION_STACK_SIZE 10
+#define REGION_STACK_MAX (REGION_STACK_SIZE - 1)
+
+#define MATRIX_STACK_SIZE 32
+#define MATRIX_STACK_MAX (MATRIX_STACK_SIZE - 1)
+struct matrix {double a, b, c, d, x, y;};
+
+// typedef what the x,y fields in a point are:
+#ifdef WIN32
+typedef int COORD_T;
+# define XPOINT XPoint
+#elif defined(__APPLE_QUARTZ__)
+typedef float COORD_T;
+typedef struct { float x; float y; } QPoint;
+# define XPOINT QPoint
+extern float fl_quartz_line_width_;
+#else
+typedef short COORD_T;
+# define XPOINT XPoint
+#endif
+
/**
\brief All graphical output devices and all graphics systems.
*/
@@ -171,7 +192,7 @@
friend FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data,
int X,int Y,int W,int H, int D);
/** \brief The constructor. */
- Fl_Graphics_Driver() {};
+ Fl_Graphics_Driver();
/** \brief see fl_rect(int x, int y, int w, int h). */
virtual void rect(int x, int y, int w, int h);
/** \brief see fl_rectf(int x, int y, int w, int h). */
@@ -262,6 +283,28 @@
virtual void push_no_clip();
/** \brief see fl_pop_clip(). */
virtual void pop_clip();
+
+ virtual void fl_transformed_vertex0(COORD_T x, COORD_T y);
+ void fixloop();
+
+ public:
+ virtual void fl_push_matrix();
+ virtual void fl_pop_matrix();
+ virtual void fl_scale(double x, double y);
+ virtual void fl_scale(double x);
+ virtual void fl_translate(double x, double y);
+ virtual void fl_rotate(double d);
+ virtual void fl_mult_matrix(double a, double b, double c, double d, double
x, double y);
+ virtual double fl_transform_x(double x, double y);
+ virtual double fl_transform_y(double x, double y);
+ virtual double fl_transform_dx(double x, double y);
+ virtual double fl_transform_dy(double x, double y);
+
+ virtual Fl_Region fl_clip_region();
+ virtual void fl_clip_region(Fl_Region r);
+ virtual void fl_restore_clip();
+
+ protected:
// Images
/** \brief see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int
D, int L). */
virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int
D=3, int L=0);
@@ -293,6 +336,27 @@
public:
static const char *device_type;
+ matrix stack[MATRIX_STACK_SIZE];
+ int sptr;
+ matrix * fl_matrix;
+ matrix m;
+
+ XPOINT *p;
+ int p_size;
+ int n;
+ int what;
+ enum {LINE, LOOP, POLYGON, POINT_};
+
+ int gap_;
+#if defined(WIN32)
+ int counts[20];
+ int numcount;
+#endif
+
+ Fl_Region rstack[REGION_STACK_SIZE];
+ int rstackptr;
+ int fl_clip_state_number;
+
/** \brief The destructor */
virtual ~Fl_Graphics_Driver() {};
};
Index: FL/fl_draw.H
===================================================================
--- FL/fl_draw.H (revision 7677)
+++ FL/fl_draw.H (working copy)
@@ -132,18 +132,18 @@
inline int fl_clip_box(int x , int y, int w, int h, int& X, int& Y, int& W,
int& H)
{return fl_graphics_driver->clip_box(x,y,w,h,X,Y,W,H); };
/** Undoes any clobbering of clip done by your program */
-extern void fl_restore_clip();
+inline void fl_restore_clip() { fl_graphics_driver->fl_restore_clip(); };
/**
Replaces the top of the clipping stack with a clipping region of any shape.
Fl_Region is an operating system specific type.
\param[in] r clipping region
*/
-FL_EXPORT void fl_clip_region(Fl_Region r);
+inline void fl_clip_region(Fl_Region r) {
fl_graphics_driver->fl_clip_region(r); };
/**
returns the current clipping region.
*/
-extern Fl_Region fl_clip_region();
+inline Fl_Region fl_clip_region() { return
fl_graphics_driver->fl_clip_region(); };
// points:
@@ -325,13 +325,14 @@
FL_EXPORT void fl_chord(int x, int y, int w, int h, double a1, double a2); //
nyi
// scalable drawing code (code in fl_vertex.C and fl_arc.C):
-FL_EXPORT void fl_push_matrix();
-FL_EXPORT void fl_pop_matrix();
-FL_EXPORT void fl_scale(double x, double y);
-FL_EXPORT void fl_scale(double x);
-FL_EXPORT void fl_translate(double x, double y);
-FL_EXPORT void fl_rotate(double d);
-FL_EXPORT void fl_mult_matrix(double a, double b, double c, double d, double
x,double y);
+inline void fl_push_matrix() { fl_graphics_driver->fl_push_matrix(); };
+inline void fl_pop_matrix() { fl_graphics_driver->fl_pop_matrix(); };
+inline void fl_scale(double x, double y) { fl_graphics_driver->fl_scale(x, y);
};
+inline void fl_scale(double x) { fl_graphics_driver->fl_scale(x); };
+inline void fl_translate(double x, double y) {
fl_graphics_driver->fl_translate(x, y); };
+inline void fl_rotate(double d) { fl_graphics_driver->fl_rotate(d); };
+inline void fl_mult_matrix(double a, double b, double c, double d, double
x,double y)
+ { fl_graphics_driver->fl_mult_matrix(a, b, c, d, x, y); };
/**
Starts drawing a list of points. Points are added to the list with fl_vertex()
*/
@@ -423,10 +424,10 @@
*/
inline void fl_end_complex_polygon()
{fl_graphics_driver->end_complex_polygon(); };
// get and use transformed positions:
-FL_EXPORT double fl_transform_x(double x, double y);
-FL_EXPORT double fl_transform_y(double x, double y);
-FL_EXPORT double fl_transform_dx(double x, double y);
-FL_EXPORT double fl_transform_dy(double x, double y);
+inline double fl_transform_x(double x, double y) {return
fl_graphics_driver->fl_transform_x(x, y); };
+inline double fl_transform_y(double x, double y) {return
fl_graphics_driver->fl_transform_y(x, y); };
+inline double fl_transform_dx(double x, double y) {return
fl_graphics_driver->fl_transform_dx(x, y); };
+inline double fl_transform_dy(double x, double y) {return
fl_graphics_driver->fl_transform_dy(x, y); };
/**
Adds coordinate pair to the vertex list without further transformations.
\param[in] xf,yf transformed coordinate
Index: FL/win32.H
===================================================================
--- FL/win32.H (revision 7677)
+++ FL/win32.H (working copy)
@@ -45,13 +45,16 @@
#define VK_APPS 0x5D
#endif
+typedef HRGN Fl_Region;
+typedef POINT XPoint;
+
#include <FL/Fl_Device.H>
// some random X equivalents
typedef HWND Window;
-typedef POINT XPoint;
+
struct XRectangle {int x, y, width, height;};
-typedef HRGN Fl_Region;
+
FL_EXPORT void fl_clip_region(Fl_Region);
extern Fl_Region XRectangleRegion(int x, int y, int w, int h);
inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
Index: src/Fl_Device.cxx
===================================================================
--- src/Fl_Device.cxx (revision 7677)
+++ src/Fl_Device.cxx (working copy)
@@ -51,6 +51,10 @@
fl_surface = this;
}
+Fl_Graphics_Driver::Fl_Graphics_Driver() {
+ sptr=0; rstackptr=0; fl_clip_state_number=0;
+ m= {1, 0, 0, 1, 0, 0}; fl_matrix = &m; p = (XPOINT *)0;};
+
//
// End of "$Id$".
//
Index: src/Fl_GDI_Printer.cxx
===================================================================
--- src/Fl_GDI_Printer.cxx (revision 7677)
+++ src/Fl_GDI_Printer.cxx (working copy)
@@ -72,7 +72,7 @@
abortPrint = FALSE;
memset (&pd, 0, sizeof (PRINTDLG));
pd.lStructSize = sizeof (PRINTDLG);
- pd.hwndOwner = GetForegroundWindow();
+ //pd.hwndOwner = GetForegroundWindow();
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE | PD_NOSELECTION;
pd.nMinPage = 1;
pd.nMaxPage = pagecount;
Index: src/Fl_PostScript.cxx
===================================================================
--- src/Fl_PostScript.cxx (revision 7677)
+++ src/Fl_PostScript.cxx (working copy)
@@ -977,9 +977,6 @@
fprintf(output, ") %g %g show_pos_width\n", x, y);
}
-struct matrix {double a, b, c, d, x, y;};
-extern matrix * fl_matrix;
-
void Fl_PostScript_Graphics_Driver::concat(){
fprintf(output,"[%g %g %g %g %g %g] CT\n", fl_matrix->a , fl_matrix->b ,
fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
}
Index: src/fl_rect.cxx
===================================================================
--- src/fl_rect.cxx (revision 7677)
+++ src/fl_rect.cxx (working copy)
@@ -394,12 +394,6 @@
////////////////////////////////////////////////////////////////
-#define STACK_SIZE 10
-#define STACK_MAX (STACK_SIZE - 1)
-static Fl_Region rstack[STACK_SIZE];
-static int rstackptr=0;
-int fl_clip_state_number=0; // used by gl_begin.cxx to update GL clip
-
#if !defined(WIN32) && !defined(__APPLE__)
// Missing X call: (is this the fastest way to init a 1-rectangle region?)
// MSWindows equivalent exists, implemented inline in win32.H
@@ -412,7 +406,7 @@
}
#endif
-void fl_restore_clip() {
+void Fl_Graphics_Driver::fl_restore_clip() {
fl_clip_state_number++;
Fl_Region r = rstack[rstackptr];
#if defined(USE_X11)
@@ -440,14 +434,14 @@
#endif
}
-void fl_clip_region(Fl_Region r) {
+void Fl_Graphics_Driver::fl_clip_region(Fl_Region r) {
Fl_Region oldr = rstack[rstackptr];
if (oldr) XDestroyRegion(oldr);
rstack[rstackptr] = r;
fl_restore_clip();
}
-Fl_Region fl_clip_region() {
+Fl_Region Fl_Graphics_Driver::fl_clip_region() {
return rstack[rstackptr];
}
@@ -482,14 +476,14 @@
# error unsupported platform
#endif
}
- if (rstackptr < STACK_MAX) rstack[++rstackptr] = r;
+ if (rstackptr < REGION_STACK_MAX) rstack[++rstackptr] = r;
else Fl::warning("fl_push_clip: clip stack overflow!\n");
fl_restore_clip();
}
// make there be no clip (used by fl_begin_offscreen() only!)
void Fl_Graphics_Driver::push_no_clip() {
- if (rstackptr < STACK_MAX) rstack[++rstackptr] = 0;
+ if (rstackptr < REGION_STACK_MAX) rstack[++rstackptr] = 0;
else Fl::warning("fl_push_no_clip: clip stack overflow!\n");
fl_restore_clip();
}
Index: src/fl_vertex.cxx
===================================================================
--- src/fl_vertex.cxx (revision 7677)
+++ src/fl_vertex.cxx (working copy)
@@ -44,20 +44,12 @@
#include <FL/math.h>
#include <stdlib.h>
-struct matrix {double a, b, c, d, x, y;};
-
-static matrix m = {1, 0, 0, 1, 0, 0};
-
-static matrix stack[32];
-matrix * fl_matrix = &m;
-static int sptr = 0;
-
/**
Saves the current transformation matrix on the stack.
The maximum depth of the stack is 4.
*/
-void fl_push_matrix() {
- if (sptr==32)
+void Fl_Graphics_Driver::fl_push_matrix() {
+ if (sptr==MATRIX_STACK_SIZE)
Fl::error("fl_push_matrix(): matrix stack overflow.");
else
stack[sptr++] = m;
@@ -66,7 +58,7 @@
/**
Restores the current transformation matrix from the stack.
*/
-void fl_pop_matrix() {
+void Fl_Graphics_Driver::fl_pop_matrix() {
if (sptr==0)
Fl::error("fl_pop_matrix(): matrix stack underflow.");
else
@@ -79,7 +71,7 @@
\param[in] a,b,c,d,x,y transformation matrix elements such that
<tt> X' = aX + cY + x </tt> and <tt> Y' = bX +dY + y </tt>
*/
-void fl_mult_matrix(double a, double b, double c, double d, double x, double
y) {
+void Fl_Graphics_Driver::fl_mult_matrix(double a, double b, double c, double
d, double x, double y) {
matrix o;
o.a = a*m.a + b*m.c;
o.b = a*m.b + b*m.d;
@@ -94,25 +86,25 @@
Concatenates scaling transformation onto the current one.
\param[in] x,y scale factors in x-direction and y-direction
*/
-void fl_scale(double x,double y) {fl_mult_matrix(x,0,0,y,0,0);}
+void Fl_Graphics_Driver::fl_scale(double x,double y)
{fl_mult_matrix(x,0,0,y,0,0);}
/**
Concatenates scaling transformation onto the current one.
\param[in] x scale factor in both x-direction and y-direction
*/
-void fl_scale(double x) {fl_mult_matrix(x,0,0,x,0,0);}
+void Fl_Graphics_Driver::fl_scale(double x) {fl_mult_matrix(x,0,0,x,0,0);}
/**
Concatenates translation transformation onto the current one.
\param[in] x,y translation factor in x-direction and y-direction
*/
-void fl_translate(double x,double y) {fl_mult_matrix(1,0,0,1,x,y);}
+void Fl_Graphics_Driver::fl_translate(double x,double y)
{fl_mult_matrix(1,0,0,1,x,y);}
/**
Concatenates rotation transformation onto the current one.
\param[in] d - rotation angle, counter-clockwise in degrees (not radians)
*/
-void fl_rotate(double d) {
+void Fl_Graphics_Driver::fl_rotate(double d) {
if (d) {
double s, c;
if (d == 0) {s = 0; c = 1;}
@@ -124,27 +116,6 @@
}
}
-// typedef what the x,y fields in a point are:
-#ifdef WIN32
-typedef int COORD_T;
-# define XPOINT XPoint
-#elif defined(__APPLE_QUARTZ__)
-typedef float COORD_T;
-typedef struct { float x; float y; } QPoint;
-# define XPOINT QPoint
-extern float fl_quartz_line_width_;
-#else
-typedef short COORD_T;
-# define XPOINT XPoint
-#endif
-
-static XPOINT *p = (XPOINT *)0;
-
-static int p_size;
-static int n;
-static int what;
-enum {LINE, LOOP, POLYGON, POINT_};
-
void Fl_Graphics_Driver::begin_points() {n = 0; what = POINT_;}
void Fl_Graphics_Driver::begin_line() {n = 0; what = LINE;}
@@ -157,27 +128,27 @@
Transforms coordinate using the current transformation matrix.
\param[in] x,y coordinate
*/
-double fl_transform_x(double x, double y) {return x*m.a + y*m.c + m.x;}
+double Fl_Graphics_Driver::fl_transform_x(double x, double y) {return x*m.a +
y*m.c + m.x;}
/**
Transform coordinate using the current transformation matrix.
\param[in] x,y coordinate
*/
-double fl_transform_y(double x, double y) {return x*m.b + y*m.d + m.y;}
+double Fl_Graphics_Driver::fl_transform_y(double x, double y) {return x*m.b +
y*m.d + m.y;}
/**
Transforms distance using current transformation matrix.
\param[in] x,y coordinate
*/
-double fl_transform_dx(double x, double y) {return x*m.a + y*m.c;}
+double Fl_Graphics_Driver::fl_transform_dx(double x, double y) {return x*m.a +
y*m.c;}
/**
Transforms distance using current transformation matrix.
\param[in] x,y coordinate
*/
-double fl_transform_dy(double x, double y) {return x*m.b + y*m.d;}
+double Fl_Graphics_Driver::fl_transform_dy(double x, double y) {return x*m.b +
y*m.d;}
-static void fl_transformed_vertex(COORD_T x, COORD_T y) {
+void Fl_Graphics_Driver::fl_transformed_vertex0(COORD_T x, COORD_T y) {
if (!n || x != p[n-1].x || y != p[n-1].y) {
if (n >= p_size) {
p_size = p ? 2*p_size : 16;
@@ -191,14 +162,14 @@
void Fl_Graphics_Driver::transformed_vertex(double xf, double yf) {
#ifdef __APPLE_QUARTZ__
- fl_transformed_vertex(COORD_T(xf), COORD_T(yf));
+ fl_transformed_vertex0(COORD_T(xf), COORD_T(yf));
#else
- fl_transformed_vertex(COORD_T(rint(xf)), COORD_T(rint(yf)));
+ fl_transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf)));
#endif
}
void Fl_Graphics_Driver::vertex(double x,double y) {
- fl_transformed_vertex(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y);
+ fl_transformed_vertex0(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y);
}
void Fl_Graphics_Driver::end_points() {
@@ -241,7 +212,7 @@
#endif
}
-static void fixloop() { // remove equal points from closed path
+void Fl_Graphics_Driver::fixloop() { // remove equal points from closed path
while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--;
}
@@ -278,12 +249,6 @@
#endif
}
-static int gap_;
-#if defined(WIN32)
-static int counts[20];
-static int numcount;
-#endif
-
void Fl_Graphics_Driver::begin_complex_polygon() {
fl_begin_polygon();
gap_ = 0;
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev