Tk Source Code

Artifact [509d5809]
Login

Artifact 509d58098cb81c042377fab9f1c0aa706cb0bc384c600d86b98a888145aa0fe0:

Attachment "tkWinGDI.diff" to ticket [7716cb2f] added by emiliano 2025-04-27 20:12:27.
Index: win/tkWinGDI.c
==================================================================
--- win/tkWinGDI.c
+++ win/tkWinGDI.c
@@ -55,11 +55,11 @@
 /*
  * Helper functions.
  */
 static int		GdiMakeLogFont(Tcl_Interp *interp, const char *str,
 			    LOGFONTW *lf, HDC hDC);
-static int		GdiMakePen(Tcl_Interp *interp, int width,
+static int		GdiMakePen(Tcl_Interp *interp, double dwidth,
 			    int dashstyle, const char *dashstyledata,
 			    int capstyle, int joinstyle,
 			    int stipplestyle, const char *stippledata,
 			    unsigned long color, HDC hDC, HGDIOBJ *oldPen);
 static int		GdiFreePen(Tcl_Interp *interp, HDC hDC, HGDIOBJ oldPen);
@@ -156,11 +156,11 @@
     double x1, y1, x2, y2;
     int xr0, yr0, xr1, yr1;
     HDC hDC;
     double extent = 0.0, start = 0.0;
     DrawFunc drawfunc;
-    int width = 0;
+    double width = 0.0;
     HPEN hPen;
     COLORREF linecolor = 0, fillcolor = BS_NULL;
     int dolinecolor = 0, dofillcolor = 0;
     HBRUSH hBrush = NULL;
     LOGBRUSH lbrush;
@@ -212,11 +212,11 @@
 	} else if (strcmp(Tcl_GetString(objv[0]), "-outlinestipple") == 0) {
 	    /* ignored */
 	} else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) {
 	    /* ignored */
 	} else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) {
-	    if (Tcl_GetIntFromObj(interp, objv[1], &width)) {
+	    if (Tcl_GetDoubleFromObj(interp, objv[1], &width)) {
 		return TCL_ERROR;
 	    }
 	} else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) {
 	    if (Tcl_GetString(objv[1])) {
 		dodash = 1;
@@ -644,11 +644,11 @@
     HPEN hPen;
 
     LOGBRUSH lbrush;
     HBRUSH hBrush = NULL;
 
-    int width          = 0;
+    double width       = 0.0;
     COLORREF linecolor = 0;
     int dolinecolor    = 0;
     int dosmooth       = 0;
     int doarrow        = 0; /* 0=none; 1=end; 2=start; 3=both. */
     int arrowshape[3];
@@ -784,11 +784,11 @@
 		objc -= 2;
 	    } else if (strcmp(Tcl_GetString(*objv), "-stipple") == 0) {
 		objv += 2;
 		objc -= 2;
 	    } else if (strcmp(Tcl_GetString(*objv), "-width") == 0) {
-		if (Tcl_GetIntFromObj(interp, objv[1], &width) != TCL_OK) {
+		if (Tcl_GetDoubleFromObj(interp, objv[1], &width) != TCL_OK) {
 		    return TCL_ERROR;
 		}
 		objv += 2;
 		objc -= 2;
 	    } else { /* It's an unknown argument!. */
@@ -939,11 +939,11 @@
 	"::tk::print::_gdi oval hdc x1 y1 x2 y2 -fill color -outline color "
 	"-stipple bitmap -width linewid";
     double x1, y1, x2, y2;
     HDC hDC;
     HPEN hPen;
-    int width = 0;
+    double width = 0.0;
     COLORREF linecolor = 0, fillcolor = 0;
     int dolinecolor = 0, dofillcolor = 0;
     HBRUSH hBrush = NULL;
     LOGBRUSH lbrush;
     HGDIOBJ oldobj = NULL;
@@ -990,11 +990,11 @@
 	    }
 	} else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) {
 	    /* Not actually implemented */
 	} else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) {
 	    if (Tcl_GetString(objv[1])) {
-		if (Tcl_GetIntFromObj(interp, objv[1], &width) != TCL_OK) {
+		if (Tcl_GetDoubleFromObj(interp, objv[1], &width) != TCL_OK) {
 		    return TCL_ERROR;
 		}
 	    }
 	} else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) {
 	    if (Tcl_GetString(objv[1])) {
@@ -1065,11 +1065,11 @@
     int dosmooth = 0;
     int nStep = 12;
     int x, y;
     HDC hDC;
     HPEN hPen;
-    int width = 0;
+    double width = 0.0;
     COLORREF linecolor = 0, fillcolor = BS_NULL;
     int dolinecolor = 0, dofillcolor = 0;
     LOGBRUSH lbrush;
     HBRUSH hBrush = NULL;
     HGDIOBJ oldobj = NULL;
@@ -1159,11 +1159,11 @@
 		}
 	    } else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) {
 		/* Not supported */
 	    } else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) {
 		if (Tcl_GetString(objv[1])) {
-		    if (Tcl_GetIntFromObj(interp, objv[1], &width) != TCL_OK) {
+		    if (Tcl_GetDoubleFromObj(interp, objv[1], &width) != TCL_OK) {
 			return TCL_ERROR;
 		    }
 		}
 	    } else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) {
 		if (Tcl_GetString(objv[1])) {
@@ -1241,11 +1241,11 @@
 	"-stipple bitmap -width linewid";
 
     double x1, y1, x2, y2;
     HDC hDC;
     HPEN hPen;
-    int width = 0;
+    double width = 0.0;
     COLORREF linecolor = 0, fillcolor = BS_NULL;
     int dolinecolor = 0, dofillcolor = 0;
     LOGBRUSH lbrush;
     HBRUSH hBrush = NULL;
     HGDIOBJ oldobj = NULL;
@@ -1292,11 +1292,11 @@
 	    }
 	} else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) {
 	    /* Not supported; ignored */
 	} else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) {
 	    if (Tcl_GetString(objv[1])) {
-		if (Tcl_GetIntFromObj(interp, objv[1], &width) != TCL_OK) {
+		if (Tcl_GetDoubleFromObj(interp, objv[1], &width) != TCL_OK) {
 		    return TCL_ERROR;
 		}
 	    }
 	} else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) {
 	    if (Tcl_GetString(objv[1])) {
@@ -2661,11 +2661,11 @@
  *----------------------------------------------------------------------
  */
 
 static int GdiMakePen(
     Tcl_Interp *interp,
-    int width,
+    double dwidth,
     int dashstyle,
     const char *dashstyledata,
     TCL_UNUSED(int),		/* Ignored for now. */
     TCL_UNUSED(int),		/* Ignored for now. */
     TCL_UNUSED(int),
@@ -2686,11 +2686,11 @@
      * it matches the Tk canvas pens much better--but not for Win95, which
      * does not support PS_USERSTYLE. An explicit test (or storage in a static
      * after first failure) may suffice for working around this. The
      * ExtCreatePen is not supported at all under Win32.
      */
-
+    int width = floor(dwidth + 0.5);
     HPEN hPen;
     LOGBRUSH lBrush;
     DWORD pStyle = PS_SOLID;           /* -dash should override*/
     DWORD endStyle = PS_ENDCAP_ROUND;  /* -capstyle should override. */
     DWORD joinStyle = PS_JOIN_ROUND;   /* -joinstyle should override. */