diff options
Diffstat (limited to 'src/fl_line_style.cxx')
| -rw-r--r-- | src/fl_line_style.cxx | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/src/fl_line_style.cxx b/src/fl_line_style.cxx index 908685aa9..222ba8a68 100644 --- a/src/fl_line_style.cxx +++ b/src/fl_line_style.cxx @@ -46,7 +46,39 @@ void fl_quartz_restore_line_style_() { #endif void fl_line_style(int style, int width, char* dashes) { -#ifdef WIN32 + +#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 FL_DASH: *p++ = dash; *p++ = gap; break; + case FL_DOT: *p++ = dot; *p++ = gap; break; + case FL_DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; break; + case FL_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 @@ -71,20 +103,6 @@ void fl_line_style(int style, int width, char* dashes) { DeleteObject(oldpen); DeleteObject(fl_current_xmap->pen); fl_current_xmap->pen = newpen; -#elif defined(__APPLE_QD__) - // QuickDraw supports pen size and pattern, but no arbitrary line styles. - static Pattern styles[] = { - { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }, // FL_SOLID - { { 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f } }, // FL_DASH - { { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 } } // FL_DOT - }; - - if (!width) width = 1; - PenSize(width, width); - - style &= 0xff; - if (style > 2) style = 2; - PenPat(styles + style); #elif defined(__APPLE_QUARTZ__) static enum CGLineCap Cap[4] = { kCGLineCapButt, kCGLineCapButt, kCGLineCapRound, kCGLineCapSquare }; @@ -126,36 +144,7 @@ void fl_line_style(int style, int width, char* dashes) { } fl_quartz_restore_line_style_(); #else - 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 FL_DASH: *p++ = dash; *p++ = gap; break; - case FL_DOT: *p++ = dot; *p++ = gap; break; - case FL_DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; break; - case FL_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); +# error unsupported platform #endif } |
