summaryrefslogtreecommitdiffstats
path: root/win/tkWinDraw.c
diff options
context:
space:
mode:
authorhobbs <hobbs>1999-12-14 06:53:54 (GMT)
committerhobbs <hobbs>1999-12-14 06:53:54 (GMT)
commitf2d4a0a8a6313d0104083cd328797b447fd6e51e (patch)
treeebecb7e15ad76bd36fed4bfce9bac5c8b8cb9f7c /win/tkWinDraw.c
parent0e681b41b7f68d1a46ab1c64693044ca8005a166 (diff)
downloadtk-f2d4a0a8a6313d0104083cd328797b447fd6e51e.zip
tk-f2d4a0a8a6313d0104083cd328797b447fd6e51e.tar.gz
tk-f2d4a0a8a6313d0104083cd328797b447fd6e51e.tar.bz2
* win/tkWinDraw.c:
* win/tkWinPointer.c: added support for pointer warping and platform specific support for dash patch items
Diffstat (limited to 'win/tkWinDraw.c')
-rw-r--r--win/tkWinDraw.c133
1 files changed, 94 insertions, 39 deletions
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index 5c89989..a32c45d 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDraw.c,v 1.6 1999/09/02 17:03:26 hobbs Exp $
+ * RCS: @(#) $Id: tkWinDraw.c,v 1.7 1999/12/14 06:53:54 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -125,6 +125,7 @@ static void DrawOrFillArc _ANSI_ARGS_((Display *display,
static void RenderObject _ANSI_ARGS_((HDC dc, GC gc,
XPoint* points, int npoints, int mode, HPEN pen,
WinDrawFunc func));
+static HPEN SetUpGraphicsPort _ANSI_ARGS_((GC gc));
/*
*----------------------------------------------------------------------
@@ -888,42 +889,7 @@ XDrawLines(display, d, gc, points, npoints, mode)
dc = TkWinGetDrawableDC(display, d, &state);
- if (!tkpIsWin32s && (gc->line_width > 1)) {
- LOGBRUSH lb;
- DWORD style;
-
- lb.lbStyle = BS_SOLID;
- lb.lbColor = gc->foreground;
- lb.lbHatch = 0;
-
- style = PS_GEOMETRIC|PS_COSMETIC;
- switch (gc->cap_style) {
- case CapNotLast:
- case CapButt:
- style |= PS_ENDCAP_FLAT;
- break;
- case CapRound:
- style |= PS_ENDCAP_ROUND;
- break;
- default:
- style |= PS_ENDCAP_SQUARE;
- break;
- }
- switch (gc->join_style) {
- case JoinMiter:
- style |= PS_JOIN_MITER;
- break;
- case JoinRound:
- style |= PS_JOIN_ROUND;
- break;
- default:
- style |= PS_JOIN_BEVEL;
- break;
- }
- pen = ExtCreatePen(style, gc->line_width, &lb, 0, NULL);
- } else {
- pen = CreatePen(PS_SOLID, gc->line_width, gc->foreground);
- }
+ pen = SetUpGraphicsPort(gc);
RenderObject(dc, gc, points, npoints, mode, pen, Polyline);
DeleteObject(pen);
@@ -1009,7 +975,7 @@ XDrawRectangle(display, d, gc, x, y, width, height)
dc = TkWinGetDrawableDC(display, d, &state);
- pen = CreatePen(PS_SOLID, gc->line_width, gc->foreground);
+ pen = SetUpGraphicsPort(gc);
oldPen = SelectObject(dc, pen);
oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));
SetROP2(dc, tkpWinRopModes[gc->function]);
@@ -1171,7 +1137,7 @@ DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill)
* difference in pixel definitions between X and Windows.
*/
- pen = CreatePen(PS_SOLID, gc->line_width, gc->foreground);
+ pen = SetUpGraphicsPort(gc);
oldPen = SelectObject(dc, pen);
if (!fill) {
/*
@@ -1198,6 +1164,95 @@ DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill)
/*
*----------------------------------------------------------------------
*
+ * SetUpGraphicsPort --
+ *
+ * Set up the graphics port from the given GC.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The current port is adjusted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static HPEN
+SetUpGraphicsPort(gc)
+ GC gc;
+{
+ DWORD style;
+
+ if (gc->line_style == LineOnOffDash) {
+ unsigned char *p = (unsigned char *) &(gc->dashes);
+ /* pointer to the dash-list */
+
+ /*
+ * Below is a simple translation of serveral dash patterns
+ * to valid windows pen types. Far from complete,
+ * but I don't know how to do it better.
+ * Any ideas: <mailto:j.nijtmans@chello.nl>
+ */
+
+ if (p[1] && p[2]) {
+ if (!p[3] || p[4]) {
+ style = PS_DASHDOTDOT; /* -.. */
+ } else {
+ style = PS_DASHDOT; /* -. */
+ }
+ } else {
+ if (p[0] > (4 * gc->line_width)) {
+ style = PS_DASH; /* - */
+ } else {
+ style = PS_DOT; /* . */
+ }
+ }
+ } else {
+ style = PS_SOLID;
+ }
+ if (tkpIsWin32s || (gc->line_width < 2)) {
+ if (gc->line_width > 1) {
+ style = PS_SOLID;
+ }
+ return CreatePen(style, gc->line_width, gc->foreground);
+ } else {
+ LOGBRUSH lb;
+
+ lb.lbStyle = BS_SOLID;
+ lb.lbColor = gc->foreground;
+ lb.lbHatch = 0;
+
+ style |= PS_GEOMETRIC;
+ switch (gc->cap_style) {
+ case CapNotLast:
+ case CapButt:
+ style |= PS_ENDCAP_FLAT;
+ break;
+ case CapRound:
+ style |= PS_ENDCAP_ROUND;
+ break;
+ default:
+ style |= PS_ENDCAP_SQUARE;
+ break;
+ }
+ switch (gc->join_style) {
+ case JoinMiter:
+ style |= PS_JOIN_MITER;
+ break;
+ case JoinRound:
+ style |= PS_JOIN_ROUND;
+ break;
+ default:
+ style |= PS_JOIN_BEVEL;
+ break;
+ }
+ return ExtCreatePen(style, gc->line_width, &lb, 0, NULL);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkScrollWindow --
*
* Scroll a rectangle of the specified window and accumulate