Author: manolo
Date: 2012-03-07 04:16:19 -0800 (Wed, 07 Mar 2012)
New Revision: 9268
Log:
Completed device virtualization.
Modified:
branches/branch-3.0/include/fltk3/Device.h
branches/branch-3.0/src/fltk3/line_style.cxx
branches/branch-3.0/src/fltk3/vertex.cxx
Modified: branches/branch-3.0/include/fltk3/Device.h
===================================================================
--- branches/branch-3.0/include/fltk3/Device.h 2012-03-07 12:14:44 UTC (rev
9267)
+++ branches/branch-3.0/include/fltk3/Device.h 2012-03-07 12:16:19 UTC (rev
9268)
@@ -129,25 +129,21 @@
enum { matrix_stack_size = MATRIX_STACK_SIZE };
matrix stack[MATRIX_STACK_SIZE];
matrix m;
- int n, p_size, gap_;
- XPOINT *p;
int rstackptr;
enum { region_stack_max = REGION_STACK_SIZE - 1 };
fltk3::Region rstack[REGION_STACK_SIZE];
Fl_Font_Descriptor *font_descriptor_;
- void transformed_vertex0(COORD_T x, COORD_T y);
protected:
#ifndef FLTK3_DOXYGEN
+ int n, p_size, gap_;
+ XPOINT *p;
enum {LINE, LOOP, POLYGON, POINT_};
int what;
int fl_clip_state_number;
-#ifdef WIN32
- int numcount;
- int counts[20];
-#endif
void prepare_circle(double x, double y, double r, int& llx, int& lly, int&
w, int& h, double& xt, double& yt);
void fixloop();
void region_stack_push(fltk3::Region r);
+ void transformed_vertex0(COORD_T x, COORD_T y);
#endif
public:
@@ -169,7 +165,7 @@
/** \brief see fltk3::rectf(int x, int y, int w, int h). */
virtual void rectf(int x, int y, int w, int h) {}
/** \brief see fltk3::line_style(int style, int width, char* dashes). */
- virtual void line_style(int style, int width=0, char* dashes=0);
+ virtual void line_style(int style, int width=0, char* dashes=0) {}
/** \brief see fltk3::xyline(int x, int y, int x1). */
virtual void xyline(int x, int y, int x1) {}
/** \brief see fltk3::xyline(int x, int y, int x1, int y2). */
@@ -230,7 +226,7 @@
/** \brief see fltk3::pie(int x, int y, int w, int h, double a1, double
a2). */
virtual void pie(int x, int y, int w, int h, double a1, double a2) {}
/** \brief see fltk3::end_points(). */
- virtual void end_points() {}
+ virtual void end_points();
/** \brief see fltk3::end_line(). */
virtual void end_line() {}
/** \brief see fltk3::end_loop(). */
@@ -399,6 +395,8 @@
void push_clip(int x, int y, int w, int h);
int not_clipped(int x, int y, int w, int h);
int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
+ void line_style(int style, int width=0, char* dashes=0);
+ void transformed_vertex(double xf, double yf);
};
#endif
@@ -409,6 +407,8 @@
This class is implemented only on the MSWindows platform.
*/
class FLTK3_EXPORT GDIGraphicsDriver : public fltk3::GraphicsDriver {
+ int numcount;
+ int counts[20];
public:
static const char *class_id;
const char *class_name() {return class_id;};
@@ -433,6 +433,8 @@
void end_points();
void end_line();
void end_polygon();
+ void begin_complex_polygon();
+ void gap();
void end_complex_polygon();
void circle(double x, double y, double r);
void arc(int x,int y,int w,int h,double a1,double a2);
@@ -456,6 +458,7 @@
void push_clip(int x, int y, int w, int h);
int not_clipped(int x, int y, int w, int h);
int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
+ void line_style(int style, int width=0, char* dashes=0);
};
#endif
@@ -513,6 +516,7 @@
void push_clip(int x, int y, int w, int h);
int not_clipped(int x, int y, int w, int h);
int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
+ void line_style(int style, int width=0, char* dashes=0);
};
#endif
Modified: branches/branch-3.0/src/fltk3/line_style.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/line_style.cxx 2012-03-07 12:14:44 UTC
(rev 9267)
+++ branches/branch-3.0/src/fltk3/line_style.cxx 2012-03-07 12:16:19 UTC
(rev 9268)
@@ -56,69 +56,11 @@
}
#endif
-void fltk3::GraphicsDriver::line_style(int style, int width, char* dashes) {
-
+#ifdef __APPLE__
+void fltk3::QuartzGraphicsDriver::line_style(int style, int width, char*
dashes) {
// save line width in global variable for X11 clipping
if (width == 0) fl_line_width_ = 1;
else fl_line_width_ = width>0 ? width : -width;
-
-#if defined(USE_X11)
- int ndashes = dashes ? strlen(dashes) : 0;
- // emulate the WIN32 dash patterns on X
- char buf[7];
- if (!ndashes && (style&0xff)) {
- int w = width ? width : 1;
- char dash, dot, gap;
- // adjust lengths to account for cap:
- if (style & 0x200) {
- dash = char(2*w);
- dot = 1; // unfortunately 0 does not work
- gap = char(2*w-1);
- } else {
- dash = char(3*w);
- dot = gap = char(w);
- }
- char* p = dashes = buf;
- switch (style & 0xff) {
- case fltk3::DASH: *p++ = dash; *p++ = gap; break;
- case fltk3::DOT: *p++ = dot; *p++ = gap; break;
- case fltk3::DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ =
gap; break;
- case fltk3::DASHDOTDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap;
*p++ = dot; *p++ = gap; break;
- }
- ndashes = p-buf;
- }
- static int Cap[4] = {CapButt, CapButt, CapRound, CapProjecting};
- static int Join[4] = {JoinMiter, JoinMiter, JoinRound, JoinBevel};
- XSetLineAttributes(fl_display, fl_gc, width,
- ndashes ? LineOnOffDash : LineSolid,
- Cap[(style>>8)&3], Join[(style>>12)&3]);
- if (ndashes) XSetDashes(fl_display, fl_gc, 0, dashes, ndashes);
-#elif defined(WIN32)
- // According to Bill, the "default" cap and join should be the
- // "fastest" mode supported for the platform. I don't know why
- // they should be different (same graphics cards, etc., right?) MRS
- static DWORD Cap[4]= {PS_ENDCAP_FLAT, PS_ENDCAP_FLAT, PS_ENDCAP_ROUND,
PS_ENDCAP_SQUARE};
- static DWORD Join[4]={PS_JOIN_ROUND, PS_JOIN_MITER, PS_JOIN_ROUND,
PS_JOIN_BEVEL};
- int s1 = PS_GEOMETRIC | Cap[(style>>8)&3] | Join[(style>>12)&3];
- DWORD a[16]; int n = 0;
- if (dashes && dashes[0]) {
- s1 |= PS_USERSTYLE;
- for (n = 0; n < 16 && *dashes; n++) a[n] = *dashes++;
- } else {
- s1 |= style & 0xff; // allow them to pass any low 8 bits for style
- }
- if ((style || n) && !width) width = 1; // fix cards that do nothing for 0?
- LOGBRUSH penbrush = {BS_SOLID,fl_RGB(),0}; // can this be fl_brush()?
- HPEN newpen = ExtCreatePen(s1, width, &penbrush, n, n ? a : 0);
- if (!newpen) {
- fltk3::error("fltk3::line_style(): Could not create GDI pen object.");
- return;
- }
- HPEN oldpen = (HPEN)SelectObject(fl_gc, newpen);
- DeleteObject(oldpen);
- DeleteObject(fl_current_xmap->pen);
- fl_current_xmap->pen = newpen;
-#elif defined(__APPLE_QUARTZ__)
static enum CGLineCap Cap[4] = { kCGLineCapButt, kCGLineCapButt,
kCGLineCapRound, kCGLineCapSquare };
static enum CGLineJoin Join[4] = { kCGLineJoinMiter, kCGLineJoinMiter,
@@ -163,12 +105,75 @@
fl_quartz_line_pattern_size = 0;
}
fl_quartz_restore_line_style_();
+}
+#elif defined(WIN32)
+void fltk3::GDIGraphicsDriver::line_style(int style, int width, char* dashes) {
+ // save line width in global variable for X11 clipping
+ if (width == 0) fl_line_width_ = 1;
+ else fl_line_width_ = width>0 ? width : -width;
+ // According to Bill, the "default" cap and join should be the
+ // "fastest" mode supported for the platform. I don't know why
+ // they should be different (same graphics cards, etc., right?) MRS
+ static DWORD Cap[4]= {PS_ENDCAP_FLAT, PS_ENDCAP_FLAT, PS_ENDCAP_ROUND,
PS_ENDCAP_SQUARE};
+ static DWORD Join[4]={PS_JOIN_ROUND, PS_JOIN_MITER, PS_JOIN_ROUND,
PS_JOIN_BEVEL};
+ int s1 = PS_GEOMETRIC | Cap[(style>>8)&3] | Join[(style>>12)&3];
+ DWORD a[16]; int n = 0;
+ if (dashes && dashes[0]) {
+ s1 |= PS_USERSTYLE;
+ for (n = 0; n < 16 && *dashes; n++) a[n] = *dashes++;
+ } else {
+ s1 |= style & 0xff; // allow them to pass any low 8 bits for style
+ }
+ if ((style || n) && !width) width = 1; // fix cards that do nothing for 0?
+ LOGBRUSH penbrush = {BS_SOLID,fl_RGB(),0}; // can this be fl_brush()?
+ HPEN newpen = ExtCreatePen(s1, width, &penbrush, n, n ? a : 0);
+ if (!newpen) {
+ fltk3::error("fltk3::line_style(): Could not create GDI pen object.");
+ return;
+ }
+ HPEN oldpen = (HPEN)SelectObject(fl_gc, newpen);
+ DeleteObject(oldpen);
+ DeleteObject(fl_current_xmap->pen);
+ fl_current_xmap->pen = newpen;
+}
#else
-# error unsupported platform
+void fltk3::XlibGraphicsDriver::line_style(int style, int width, char* dashes)
{
+ // save line width in global variable for X11 clipping
+ if (width == 0) fl_line_width_ = 1;
+ else fl_line_width_ = width>0 ? width : -width;
+ int ndashes = dashes ? strlen(dashes) : 0;
+ // emulate the WIN32 dash patterns on X
+ char buf[7];
+ if (!ndashes && (style&0xff)) {
+ int w = width ? width : 1;
+ char dash, dot, gap;
+ // adjust lengths to account for cap:
+ if (style & 0x200) {
+ dash = char(2*w);
+ dot = 1; // unfortunately 0 does not work
+ gap = char(2*w-1);
+ } else {
+ dash = char(3*w);
+ dot = gap = char(w);
+ }
+ char* p = dashes = buf;
+ switch (style & 0xff) {
+ case fltk3::DASH: *p++ = dash; *p++ = gap; break;
+ case fltk3::DOT: *p++ = dot; *p++ = gap; break;
+ case fltk3::DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ =
gap; break;
+ case fltk3::DASHDOTDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap;
*p++ = dot; *p++ = gap; break;
+ }
+ ndashes = p-buf;
+ }
+ static int Cap[4] = {CapButt, CapButt, CapRound, CapProjecting};
+ static int Join[4] = {JoinMiter, JoinMiter, JoinRound, JoinBevel};
+ XSetLineAttributes(fl_display, fl_gc, width,
+ ndashes ? LineOnOffDash : LineSolid,
+ Cap[(style>>8)&3], Join[(style>>12)&3]);
+ if (ndashes) XSetDashes(fl_display, fl_gc, 0, dashes, ndashes);
+}
#endif
-}
-
//
// End of "$Id$".
//
Modified: branches/branch-3.0/src/fltk3/vertex.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/vertex.cxx 2012-03-07 12:14:44 UTC (rev
9267)
+++ branches/branch-3.0/src/fltk3/vertex.cxx 2012-03-07 12:16:19 UTC (rev
9268)
@@ -110,17 +110,23 @@
}
void fltk3::GraphicsDriver::transformed_vertex(double xf, double yf) {
-#ifdef __APPLE_QUARTZ__
+ transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf)));
+}
+#ifdef __APPLE__
+void fltk3::QuartzGraphicsDriver::transformed_vertex(double xf, double yf) {
transformed_vertex0(COORD_T(xf), COORD_T(yf));
-#else
- transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf)));
+}
#endif
-}
void fltk3::GraphicsDriver::vertex(double x,double y) {
transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d +
m.y));
}
+void fltk3::GraphicsDriver::end_points() {
+ int n = vertex_no();
+ XPOINT *p = vertices();
+ for (int i=0; i<n; i++) point(p[i].x, p[i].y);
+}
#ifdef WIN32
void fltk3::GDIGraphicsDriver::end_points() {
int n = vertex_no();
@@ -243,23 +249,36 @@
void fltk3::GraphicsDriver::begin_complex_polygon() {
begin_polygon();
gap_ = 0;
+}
#if defined(WIN32)
+void fltk3::GDIGraphicsDriver::begin_complex_polygon() {
+ fltk3::GraphicsDriver::begin_complex_polygon();
numcount = 0;
+}
#endif
-}
+
void fltk3::GraphicsDriver::gap() {
while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--;
if (n > gap_+2) {
transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y);
+ gap_ = n;
+ } else {
+ n = gap_;
+ }
+}
#if defined(WIN32)
+void fltk3::GDIGraphicsDriver::gap() {
+ while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--;
+ if (n > gap_+2) {
+ transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y);
counts[numcount++] = n-gap_;
-#endif
gap_ = n;
} else {
n = gap_;
}
}
+#endif
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::end_complex_polygon() {
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit