diff options
author | hobbs <hobbs@noemail.net> | 1999-12-14 06:53:54 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 1999-12-14 06:53:54 (GMT) |
commit | 5812c540849a8c493ec3c9b834a5f10e61ba6b5e (patch) | |
tree | ebecb7e15ad76bd36fed4bfce9bac5c8b8cb9f7c /win | |
parent | 63c624d25da1e7e67c5379673ba0d3d9d71cdeae (diff) | |
download | tk-5812c540849a8c493ec3c9b834a5f10e61ba6b5e.zip tk-5812c540849a8c493ec3c9b834a5f10e61ba6b5e.tar.gz tk-5812c540849a8c493ec3c9b834a5f10e61ba6b5e.tar.bz2 |
* win/tkWinDraw.c:
* win/tkWinPointer.c: added support for pointer warping and
platform specific support for dash patch items
FossilOrigin-Name: 182e9eb9199a03d0b4a6634ebe00d9871ecbadb2
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinDraw.c | 133 | ||||
-rw-r--r-- | win/tkWinPointer.c | 38 |
2 files changed, 131 insertions, 40 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 diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index d503417..6e62e31 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinPointer.c,v 1.6 1999/04/16 01:51:53 stanton Exp $ + * RCS: @(#) $Id: tkWinPointer.c,v 1.7 1999/12/14 06:53:54 hobbs Exp $ */ #include "tkWinInt.h" @@ -331,6 +331,42 @@ XQueryPointer(display, w, root_return, child_return, root_x_return, *mask_return = TkWinGetModifierState(); return True; } + +/* + *---------------------------------------------------------------------- + * + * XWarpPointer -- + * + * Move pointer to new location. This is not a complete + * implementation of this function. + * + * Results: + * None. + * + * Side effects: + * Mouse pointer changes position on screen. + * + *---------------------------------------------------------------------- + */ + +void +XWarpPointer(display, src_w, dest_w, src_x, src_y, src_width, + src_height, dest_x, dest_y) + Display* display; + Window src_w; + Window dest_w; + int src_x; + int src_y; + unsigned int src_width; + unsigned int src_height; + int dest_x; + int dest_y; +{ + RECT r; + + GetWindowRect(Tk_GetHWND(dest_w), &r); + SetCursorPos(r.left+dest_x, r.top+dest_y); +} /* *---------------------------------------------------------------------- |