From 3f7d403612402c75469ea7f9598faa5d88ac120c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 8 Nov 2023 21:24:02 +0000 Subject: improve tkWinGDI.c, using objc/objv in stead of argc/argv --- win/tkWinGDI.c | 464 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 226 insertions(+), 238 deletions(-) diff --git a/win/tkWinGDI.c b/win/tkWinGDI.c index f05bebc..969606b 100644 --- a/win/tkWinGDI.c +++ b/win/tkWinGDI.c @@ -36,30 +36,18 @@ typedef BOOL WINAPI (*DrawFunc) ( #endif /* Real functions. */ -static int GdiArc(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiBitmap(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiCharWidths(ClientData clientData, - Tcl_Interp *interp, int argc, const char **argv); -static int GdiImage(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiPhoto(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiLine(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiOval(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiPolygon(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiRectangle(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiText(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiMap(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); -static int GdiCopyBits(ClientData clientData, Tcl_Interp *interp, - int argc, const char **argv); +static Tcl_ObjCmdProc GdiArc; +static Tcl_ObjCmdProc GdiBitmap; +static Tcl_ObjCmdProc GdiCharWidths; +static Tcl_ObjCmdProc GdiImage; +static Tcl_ObjCmdProc GdiPhoto; +static Tcl_ObjCmdProc GdiLine; +static Tcl_ObjCmdProc GdiOval; +static Tcl_ObjCmdProc GdiPolygon; +static Tcl_ObjCmdProc GdiRectangle; +static Tcl_ObjCmdProc GdiText; +static Tcl_ObjCmdProc GdiMap; +static Tcl_ObjCmdProc GdiCopyBits; /* Local copies of similar routines elsewhere in Tcl/Tk. */ static int GdiGetColor(const char *name, COLORREF *color); @@ -136,7 +124,7 @@ static HDC printDC; static const struct gdi_command { const char *command_string; - Tcl_CmdProc *command; + Tcl_ObjCmdProc *command; } gdi_commands[] = { { "arc", GdiArc }, { "bitmap", GdiBitmap }, @@ -169,7 +157,7 @@ static int GdiArc( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi arc hdc x1 y1 x2 y2 " @@ -202,45 +190,45 @@ static int GdiArc( hDC = printDC; - x1 = atoi(argv[2]); - y1 = atoi(argv[3]); - x2 = atoi(argv[4]); - y2 = atoi(argv[5]); + x1 = atoi(Tcl_GetString(objv[2])); + y1 = atoi(Tcl_GetString(objv[3])); + x2 = atoi(Tcl_GetString(objv[4])); + y2 = atoi(Tcl_GetString(objv[5])); argc -= 6; - argv += 6; + objv += 6; while (argc >= 2) { - if (strcmp(argv[0], "-extent") == 0) { - extent = atof(argv[1]); - } else if (strcmp(argv[0], "-start") == 0) { - start = atof(argv[1]); - } else if (strcmp(argv[0], "-style") == 0) { - if (strcmp(argv[1], "pieslice") == 0) { + if (strcmp(Tcl_GetString(objv[0]), "-extent") == 0) { + extent = atof(Tcl_GetString(objv[1])); + } else if (strcmp(Tcl_GetString(objv[0]), "-start") == 0) { + start = atof(Tcl_GetString(objv[1])); + } else if (strcmp(Tcl_GetString(objv[0]), "-style") == 0) { + if (strcmp(Tcl_GetString(objv[1]), "pieslice") == 0) { drawfunc = Pie; - } else if (strcmp(argv[1], "arc") == 0) { + } else if (strcmp(Tcl_GetString(objv[1]), "arc") == 0) { drawfunc = Arc; - } else if (strcmp(argv[1], "chord") == 0) { + } else if (strcmp(Tcl_GetString(objv[1]), "chord") == 0) { drawfunc = Chord; } - } else if (strcmp(argv[0], "-fill") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-fill") == 0) { /* Handle all args, even if we don't use them yet. */ - if (GdiGetColor(argv[1], &fillcolor)) { + if (GdiGetColor(Tcl_GetString(objv[1]), &fillcolor)) { dofillcolor = 1; } - } else if (strcmp(argv[0], "-outline") == 0) { - if (GdiGetColor(argv[1], &linecolor)) { + } else if (strcmp(Tcl_GetString(objv[0]), "-outline") == 0) { + if (GdiGetColor(Tcl_GetString(objv[1]), &linecolor)) { dolinecolor = 1; } - } else if (strcmp(argv[0], "-outlinestipple") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-outlinestipple") == 0) { /* ignored */ - } else if (strcmp(argv[0], "-stipple") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) { /* ignored */ - } else if (strcmp(argv[0], "-width") == 0) { - width = atoi(argv[1]); - } else if (strcmp(argv[0], "-dash") == 0) { - if (argv[1]) { + } else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) { + width = atoi(Tcl_GetString(objv[1])); + } else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) { + if (Tcl_GetString(objv[1])) { dodash = 1; - dashdata = argv[1]; + dashdata = Tcl_GetString(objv[1]); } } else { /* Don't know that option! */ @@ -248,7 +236,7 @@ static int GdiArc( return TCL_ERROR; } argc -= 2; - argv += 2; + objv += 2; } xr0 = xr1 = (x1 + x2) / 2; yr0 = yr1 = (y1 + y2) / 2; @@ -323,7 +311,7 @@ static int GdiBitmap( TCL_UNUSED(void *), Tcl_Interp *interp, TCL_UNUSED(int), - TCL_UNUSED(const char **)) + TCL_UNUSED(Tcl_Obj *const *)) { static const char usage_message[] = "::tk::print::_gdi bitmap hdc x y " @@ -359,7 +347,7 @@ static int GdiImage( TCL_UNUSED(void *), Tcl_Interp *interp, TCL_UNUSED(int), - TCL_UNUSED(const char **)) + TCL_UNUSED(Tcl_Obj *const *)) { static const char usage_message[] = "::tk::print::_gdi image hdc x y -anchor [center|n|e|s|w] -image name\n" @@ -395,7 +383,7 @@ static int GdiPhoto( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi photo hdc [-destination x y [w [h]]] -photo name\n"; @@ -433,19 +421,19 @@ static int GdiPhoto( if ((GetDeviceCaps(dst, RASTERCAPS) & RC_STRETCHDIB) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "::tk::print::_gdi photo not supported on device context (0x%s)", - argv[1])); + Tcl_GetString(objv[1]))); return TCL_ERROR; } /* Parse the command line arguments. */ for (j = 2; j < argc; j++) { - if (strcmp(argv[j], "-destination") == 0) { + if (strcmp(Tcl_GetString(objv[j]), "-destination") == 0) { double x, y, w, h; int count = 0; char dummy; if (j < argc) { - count = sscanf(argv[++j], "%lf%lf%lf%lf%c", + count = sscanf(Tcl_GetString(objv[++j]), "%lf%lf%lf%lf%c", &x, &y, &w, &h, &dummy); } @@ -466,8 +454,8 @@ static int GdiPhoto( dst_w = (int) w; dst_h = (int) h; } - } else if (strcmp(argv[j], "-photo") == 0) { - photoname = argv[++j]; + } else if (strcmp(Tcl_GetString(objv[j]), "-photo") == 0) { + photoname = Tcl_GetString(objv[++j]); } } @@ -653,7 +641,7 @@ static int GdiLine( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi line hdc x1 y1 ... xn yn " @@ -701,27 +689,27 @@ static int GdiLine( Tcl_AppendResult(interp, "Out of memory in GdiLine", NULL); return TCL_ERROR; } - polypoints[0].x = atol(argv[2]); - polypoints[0].y = atol(argv[3]); - polypoints[1].x = atol(argv[4]); - polypoints[1].y = atol(argv[5]); + polypoints[0].x = atol(Tcl_GetString(objv[2])); + polypoints[0].y = atol(Tcl_GetString(objv[3])); + polypoints[1].x = atol(Tcl_GetString(objv[4])); + polypoints[1].y = atol(Tcl_GetString(objv[5])); argc -= 6; - argv += 6; + objv += 6; npoly = 2; while (argc >= 2) { /* Check for a number. */ - x = strtoul(argv[0], &strend, 0); - if (strend > argv[0]) { + x = strtoul(Tcl_GetString(objv[0]), &strend, 0); + if (strend > Tcl_GetString(objv[0])) { /* One number.... */ - y = strtoul(argv[1], &strend, 0); - if (strend > argv[1]) { + y = strtoul(Tcl_GetString(objv[1]), &strend, 0); + if (strend > Tcl_GetString(objv[1])) { /* TWO numbers!. */ polypoints[npoly].x = x; polypoints[npoly].y = y; npoly++; argc -= 2; - argv += 2; + objv += 2; } else { /* Only one number... Assume a usage error. */ Tcl_Free((void *)polypoints); @@ -729,24 +717,24 @@ static int GdiLine( return TCL_ERROR; } } else { - if (strcmp(*argv, "-arrow") == 0) { - if (strcmp(argv[1], "none") == 0) { + if (strcmp(Tcl_GetString(*objv), "-arrow") == 0) { + if (strcmp(Tcl_GetString(objv[1]), "none") == 0) { doarrow = 0; - } else if (strcmp(argv[1], "both") == 0) { + } else if (strcmp(Tcl_GetString(objv[1]), "both") == 0) { doarrow = 3; - } else if (strcmp(argv[1], "first") == 0) { + } else if (strcmp(Tcl_GetString(objv[1]), "first") == 0) { doarrow = 2; - } else if (strcmp(argv[1], "last") == 0) { + } else if (strcmp(Tcl_GetString(objv[1]), "last") == 0) { doarrow = 1; } - argv += 2; + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-arrowshape") == 0) { + } else if (strcmp(Tcl_GetString(*objv), "-arrowshape") == 0) { /* List of 3 numbers--set arrowshape array. */ int a1, a2, a3; char dummy; - if (sscanf(argv[1], "%d%d%d%c", &a1, &a2, &a3, &dummy) == 3 + if (sscanf(Tcl_GetString(objv[1]), "%d%d%d%c", &a1, &a2, &a3, &dummy) == 3 && a1 > 0 && a2 > 0 && a3 > 0) { arrowshape[0] = a1; arrowshape[1] = a2; @@ -754,24 +742,24 @@ static int GdiLine( } /* Else the argument was bad. */ - argv += 2; + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-capstyle") == 0) { - argv += 2; + } else if (strcmp(Tcl_GetString(*objv), "-capstyle") == 0) { + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-fill") == 0) { - if (GdiGetColor(argv[1], &linecolor)) { + } else if (strcmp(Tcl_GetString(*objv), "-fill") == 0) { + if (GdiGetColor(Tcl_GetString(objv[1]), &linecolor)) { dolinecolor = 1; } - argv += 2; + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-joinstyle") == 0) { - argv += 2; + } else if (strcmp(Tcl_GetString(*objv), "-joinstyle") == 0) { + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-smooth") == 0) { + } else if (strcmp(Tcl_GetString(*objv), "-smooth") == 0) { /* Argument is true/false or 1/0 or bezier. */ - if (argv[1]) { - switch (argv[1][0]) { + if (Tcl_GetString(objv[1])) { + switch (Tcl_GetString(objv[1])[0]) { case 't': case 'T': case '1': case 'b': case 'B': /* bezier. */ @@ -781,33 +769,33 @@ static int GdiLine( dosmooth = 0; break; } - argv += 2; + objv += 2; argc -= 2; } - } else if (strcmp(*argv, "-splinesteps") == 0) { - nStep = atoi(argv[1]); - argv += 2; + } else if (strcmp(Tcl_GetString(*objv), "-splinesteps") == 0) { + nStep = atoi(Tcl_GetString(objv[1])); + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-dash") == 0) { - if (argv[1]) { + } else if (strcmp(Tcl_GetString(*objv), "-dash") == 0) { + if (Tcl_GetString(objv[1])) { dodash = 1; - dashdata = argv[1]; + dashdata = Tcl_GetString(objv[1]); } - argv += 2; + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-dashoffset") == 0) { - argv += 2; + } else if (strcmp(Tcl_GetString(*objv), "-dashoffset") == 0) { + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-stipple") == 0) { - argv += 2; + } else if (strcmp(Tcl_GetString(*objv), "-stipple") == 0) { + objv += 2; argc -= 2; - } else if (strcmp(*argv, "-width") == 0) { - width = atoi(argv[1]); - argv += 2; + } else if (strcmp(Tcl_GetString(*objv), "-width") == 0) { + width = atoi(Tcl_GetString(objv[1])); + objv += 2; argc -= 2; } else { /* It's an unknown argument!. */ argc--; - argv++; + objv++; } /* Check for arguments * Most of the arguments affect the "Pen" @@ -947,7 +935,7 @@ static int GdiOval( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi oval hdc x1 y1 x2 y2 -fill color -outline color " @@ -973,10 +961,10 @@ static int GdiOval( hDC = printDC; - x1 = atol(argv[2]); - y1 = atol(argv[3]); - x2 = atol(argv[4]); - y2 = atol(argv[5]); + x1 = atol(Tcl_GetString(objv[2])); + y1 = atol(Tcl_GetString(objv[3])); + x2 = atol(Tcl_GetString(objv[4])); + y2 = atol(Tcl_GetString(objv[5])); if (x1 > x2) { int x3 = x1; x1 = x2; @@ -988,31 +976,31 @@ static int GdiOval( y2 = y3; } argc -= 6; - argv += 6; + objv += 6; while (argc > 0) { /* Now handle any other arguments that occur. */ - if (strcmp(argv[0], "-fill") == 0) { - if (argv[1] && GdiGetColor(argv[1], &fillcolor)) { + if (strcmp(Tcl_GetString(objv[0]), "-fill") == 0) { + if (Tcl_GetString(objv[1]) && GdiGetColor(Tcl_GetString(objv[1]), &fillcolor)) { dofillcolor = 1; } - } else if (strcmp(argv[0], "-outline") == 0) { - if (argv[1] && GdiGetColor(argv[1], &linecolor)) { + } else if (strcmp(Tcl_GetString(objv[0]), "-outline") == 0) { + if (Tcl_GetString(objv[1]) && GdiGetColor(Tcl_GetString(objv[1]), &linecolor)) { dolinecolor = 1; } - } else if (strcmp(argv[0], "-stipple") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) { /* Not actually implemented */ - } else if (strcmp(argv[0], "-width") == 0) { - if (argv[1]) { - width = atoi(argv[1]); + } else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) { + if (Tcl_GetString(objv[1])) { + width = atoi(Tcl_GetString(objv[1])); } - } else if (strcmp(argv[0], "-dash") == 0) { - if (argv[1]) { + } else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) { + if (Tcl_GetString(objv[1])) { dodash = 1; - dashdata = argv[1]; + dashdata = Tcl_GetString(objv[1]); } } - argv += 2; + objv += 2; argc -= 2; } @@ -1062,7 +1050,7 @@ static int GdiPolygon( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi polygon hdc x1 y1 ... xn yn " @@ -1101,27 +1089,27 @@ static int GdiPolygon( Tcl_AppendResult(interp, "Out of memory in GdiLine", NULL); return TCL_ERROR; } - polypoints[0].x = atol(argv[2]); - polypoints[0].y = atol(argv[3]); - polypoints[1].x = atol(argv[4]); - polypoints[1].y = atol(argv[5]); + polypoints[0].x = atol(Tcl_GetString(objv[2])); + polypoints[0].y = atol(Tcl_GetString(objv[3])); + polypoints[1].x = atol(Tcl_GetString(objv[4])); + polypoints[1].y = atol(Tcl_GetString(objv[5])); argc -= 6; - argv += 6; + objv += 6; npoly = 2; while (argc >= 2) { /* Check for a number */ - x = strtoul(argv[0], &strend, 0); - if (strend > argv[0]) { + x = strtoul(Tcl_GetString(objv[0]), &strend, 0); + if (strend > Tcl_GetString(objv[0])) { /* One number.... */ - y = strtoul(argv[1], &strend, 0); - if (strend > argv[1]) { + y = strtoul(Tcl_GetString(objv[1]), &strend, 0); + if (strend > Tcl_GetString(objv[1])) { /* TWO numbers!. */ polypoints[npoly].x = x; polypoints[npoly].y = y; npoly++; argc -= 2; - argv += 2; + objv += 2; } else { /* Only one number... Assume a usage error. */ Tcl_Free((void *) polypoints); @@ -1133,17 +1121,17 @@ static int GdiPolygon( * Check for arguments. * Most of the arguments affect the "Pen" and "Brush". */ - if (strcmp(argv[0], "-fill") == 0) { - if (argv[1] && GdiGetColor(argv[1], &fillcolor)) { + if (strcmp(Tcl_GetString(objv[0]), "-fill") == 0) { + if (Tcl_GetString(objv[1]) && GdiGetColor(Tcl_GetString(objv[1]), &fillcolor)) { dofillcolor = 1; } - } else if (strcmp(argv[0], "-outline") == 0) { - if (GdiGetColor(argv[1], &linecolor)) { + } else if (strcmp(Tcl_GetString(objv[0]), "-outline") == 0) { + if (GdiGetColor(Tcl_GetString(objv[1]), &linecolor)) { dolinecolor = 0; } - } else if (strcmp(argv[0], "-smooth") == 0) { - if (argv[1]) { - switch (argv[1][0]) { + } else if (strcmp(Tcl_GetString(objv[0]), "-smooth") == 0) { + if (Tcl_GetString(objv[1])) { + switch (Tcl_GetString(objv[1])[0]) { case 't': case 'T': case '1': case 'b': case 'B': /* bezier. */ @@ -1154,24 +1142,24 @@ static int GdiPolygon( break; } } - } else if (strcmp(argv[0], "-splinesteps") == 0) { - if (argv[1]) { - nStep = atoi(argv[1]); + } else if (strcmp(Tcl_GetString(objv[0]), "-splinesteps") == 0) { + if (Tcl_GetString(objv[1])) { + nStep = atoi(Tcl_GetString(objv[1])); } - } else if (strcmp(argv[0], "-stipple") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) { /* Not supported */ - } else if (strcmp(argv[0], "-width") == 0) { - if (argv[1]) { - width = atoi(argv[1]); + } else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) { + if (Tcl_GetString(objv[1])) { + width = atoi(Tcl_GetString(objv[1])); } - } else if (strcmp(argv[0], "-dash") == 0) { - if (argv[1]) { + } else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) { + if (Tcl_GetString(objv[1])) { dodash = 1; - dashdata = argv[1]; + dashdata = Tcl_GetString(objv[1]); } } argc -= 2; - argv += 2; + objv += 2; } } @@ -1232,7 +1220,7 @@ static int GdiRectangle( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi rectangle hdc x1 y1 x2 y2 " @@ -1260,10 +1248,10 @@ static int GdiRectangle( hDC = printDC; - x1 = atol(argv[2]); - y1 = atol(argv[3]); - x2 = atol(argv[4]); - y2 = atol(argv[5]); + x1 = atol(Tcl_GetString(objv[2])); + y1 = atol(Tcl_GetString(objv[3])); + x2 = atol(Tcl_GetString(objv[4])); + y2 = atol(Tcl_GetString(objv[5])); if (x1 > x2) { int x3 = x1; x1 = x2; @@ -1275,33 +1263,33 @@ static int GdiRectangle( y2 = y3; } argc -= 6; - argv += 6; + objv += 6; /* Now handle any other arguments that occur. */ while (argc > 1) { - if (strcmp(argv[0], "-fill") == 0) { - if (argv[1] && GdiGetColor(argv[1], &fillcolor)) { + if (strcmp(Tcl_GetString(objv[0]), "-fill") == 0) { + if (Tcl_GetString(objv[1]) && GdiGetColor(Tcl_GetString(objv[1]), &fillcolor)) { dofillcolor = 1; } - } else if (strcmp(argv[0], "-outline") == 0) { - if (argv[1] && GdiGetColor(argv[1], &linecolor)) { + } else if (strcmp(Tcl_GetString(objv[0]), "-outline") == 0) { + if (Tcl_GetString(objv[1]) && GdiGetColor(Tcl_GetString(objv[1]), &linecolor)) { dolinecolor = 1; } - } else if (strcmp(argv[0], "-stipple") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) { /* Not supported; ignored */ - } else if (strcmp(argv[0], "-width") == 0) { - if (argv[1]) { - width = atoi(argv[1]); + } else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) { + if (Tcl_GetString(objv[1])) { + width = atoi(Tcl_GetString(objv[1])); } - } else if (strcmp(argv[0], "-dash") == 0) { - if (argv[1]) { + } else if (strcmp(Tcl_GetString(objv[0]), "-dash") == 0) { + if (Tcl_GetString(objv[1])) { dodash = 1; - dashdata = argv[1]; + dashdata = Tcl_GetString(objv[1]); } } argc -= 2; - argv += 2; + objv += 2; } /* @@ -1358,7 +1346,7 @@ static int GdiCharWidths( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi characters hdc [-font fontname] [-array ary]"; @@ -1386,27 +1374,27 @@ static int GdiCharWidths( hDC = printDC; argc -= 2; - argv += 2; + objv += 2; while (argc > 0) { - if (strcmp(argv[0], "-font") == 0) { + if (strcmp(Tcl_GetString(objv[0]), "-font") == 0) { argc--; - argv++; - if (GdiMakeLogFont(interp, argv[0], &lf, hDC)) { + objv++; + if (GdiMakeLogFont(interp, Tcl_GetString(objv[0]), &lf, hDC)) { if ((hfont = CreateFontIndirectW(&lf)) != NULL) { made_font = 1; oldfont = SelectObject(hDC, hfont); } } /* Else leave the font alone!. */ - } else if (strcmp(argv[0], "-array") == 0) { - argv++; + } else if (strcmp(Tcl_GetString(objv[0]), "-array") == 0) { + objv++; argc--; if (argc > 0) { - aryvarname = argv[0]; + aryvarname = Tcl_GetString(objv[0]); } } - argv++; + objv++; argc--; } @@ -1472,7 +1460,7 @@ int GdiText( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi text hdc x y -anchor [center|n|e|s|w] " @@ -1508,76 +1496,76 @@ int GdiText( hDC = printDC; - x = atol(argv[2]); - y = atol(argv[3]); + x = atol(Tcl_GetString(objv[2])); + y = atol(Tcl_GetString(objv[3])); argc -= 4; - argv += 4; + objv += 4; sizerect.left = sizerect.right = x; sizerect.top = sizerect.bottom = y; while (argc > 0) { - if (strcmp(argv[0], "-anchor") == 0) { + if (strcmp(Tcl_GetString(objv[0]), "-anchor") == 0) { argc--; - argv++; + objv++; if (argc > 0) { - Tk_GetAnchor(interp, argv[0], &anchor); + Tk_GetAnchor(interp, Tcl_GetString(objv[0]), &anchor); } - } else if (strcmp(argv[0], "-justify") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-justify") == 0) { argc--; - argv++; + objv++; if (argc > 0) { - if (strcmp(argv[0], "left") == 0) { + if (strcmp(Tcl_GetString(objv[0]), "left") == 0) { format_flags |= DT_LEFT; - } else if (strcmp(argv[0], "center") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "center") == 0) { format_flags |= DT_CENTER; - } else if (strcmp(argv[0], "right") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "right") == 0) { format_flags |= DT_RIGHT; } } - } else if (strcmp(argv[0], "-text") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-text") == 0) { argc--; - argv++; + objv++; if (argc > 0) { - string = argv[0]; + string = Tcl_GetString(objv[0]); } - } else if (strcmp(argv[0], "-font") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-font") == 0) { argc--; - argv++; - if (GdiMakeLogFont(interp, argv[0], &lf, hDC)) { + objv++; + if (GdiMakeLogFont(interp, Tcl_GetString(objv[0]), &lf, hDC)) { if ((hfont = CreateFontIndirectW(&lf)) != NULL) { made_font = 1; oldfont = SelectObject(hDC, hfont); } } /* Else leave the font alone! */ - } else if (strcmp(argv[0], "-stipple") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-stipple") == 0) { argc--; - argv++; + objv++; /* Not implemented yet. */ - } else if (strcmp(argv[0], "-fill") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-fill") == 0) { argc--; - argv++; + objv++; /* Get text color. */ - if (GdiGetColor(argv[0], &textcolor)) { + if (GdiGetColor(Tcl_GetString(objv[0]), &textcolor)) { dotextcolor = 1; } - } else if (strcmp(argv[0], "-width") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-width") == 0) { argc--; - argv++; + objv++; if (argc > 0) { - sizerect.right += atol(argv[0]); + sizerect.right += atol(Tcl_GetString(objv[0])); } /* If a width is specified, break at words. */ format_flags |= DT_WORDBREAK; - } else if (strcmp(argv[0], "-single") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-single") == 0) { usesingle = 1; - } else if (strcmp(argv[0], "-backfill") == 0) { + } else if (strcmp(Tcl_GetString(objv[0]), "-backfill") == 0) { dobgmode = 1; } argc--; - argv++; + objv++; } if (string == 0) { @@ -1820,7 +1808,7 @@ static int GdiMap( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { static const char usage_message[] = "::tk::print::_gdi map hdc " @@ -1858,25 +1846,25 @@ static int GdiMap( /* Parse remaining arguments. */ for (argno = 2; argno < argc; argno++) { - if (strcmp(argv[argno], "-default") == 0) { + if (strcmp(Tcl_GetString(objv[argno]), "-default") == 0) { vextent.cx = vextent.cy = wextent.cx = wextent.cy = 1; vorigin.x = vorigin.y = worigin.x = worigin.y = 0; mapmode = MM_TEXT; use_default = 1; - } else if (strcmp(argv[argno], "-mode") == 0) { + } else if (strcmp(Tcl_GetString(objv[argno]), "-mode") == 0) { if (argno + 1 >= argc) { need_usage = 1; } else { - mapmode = GdiNameToMode(argv[argno + 1]); + mapmode = GdiNameToMode(Tcl_GetString(objv[argno + 1])); use_mode = 1; argno++; } - } else if (strcmp(argv[argno], "-offset") == 0) { + } else if (strcmp(Tcl_GetString(objv[argno]), "-offset") == 0) { if (argno + 1 >= argc) { need_usage = 1; } else { /* It would be nice if this parsed units as well.... */ - if (sscanf(argv[argno + 1], "%ld%ld", + if (sscanf(Tcl_GetString(objv[argno + 1]), "%ld%ld", &vorigin.x, &vorigin.y) == 2) { use_offset = 1; } else { @@ -1884,7 +1872,7 @@ static int GdiMap( } argno++; } - } else if (strcmp(argv[argno], "-logical") == 0) { + } else if (strcmp(Tcl_GetString(objv[argno]), "-logical") == 0) { if (argno + 1 >= argc) { need_usage = 1; } else { @@ -1892,7 +1880,7 @@ static int GdiMap( argno++; /* In "real-life", this should parse units as well.. */ - if ((count = sscanf(argv[argno], "%ld%ld", + if ((count = sscanf(Tcl_GetString(objv[argno]), "%ld%ld", &wextent.cx, &wextent.cy)) != 2) { if (count == 1) { mapmode = MM_ISOTROPIC; @@ -1906,7 +1894,7 @@ static int GdiMap( use_logical = 2; } } - } else if (strcmp(argv[argno], "-physical") == 0) { + } else if (strcmp(Tcl_GetString(objv[argno]), "-physical") == 0) { if (argno + 1 >= argc) { need_usage = 1; } else { @@ -1914,7 +1902,7 @@ static int GdiMap( argno++; /* In "real-life", this should parse units as well.. */ - if ((count = sscanf(argv[argno], "%ld%ld", + if ((count = sscanf(Tcl_GetString(objv[argno]), "%ld%ld", &vextent.cx, &vextent.cy)) != 2) { if (count == 1) { mapmode = MM_ISOTROPIC; @@ -2003,7 +1991,7 @@ static int GdiCopyBits( TCL_UNUSED(void *), Tcl_Interp *interp, int argc, - const char **argv) + Tcl_Obj *const *objv) { /* Goal: get the Tk_Window from the top-level * convert it to an HWND @@ -2083,10 +2071,10 @@ static int GdiCopyBits( /* Loop through the remaining arguments. */ for (k=2; k= 100.0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "Unreasonable scale specification %s", argv[k])); + "Unreasonable scale specification %s", Tcl_GetString(objv[k]))); return TCL_ERROR; } do_scale = 1; } - } else if (strcmp(argv[k], "-noprint") == 0 - || strncmp(argv[k], "-calc", 5) == 0) { + } else if (strcmp(Tcl_GetString(objv[k]), "-noprint") == 0 + || strncmp(Tcl_GetString(objv[k]), "-calc", 5) == 0) { /* This option suggested by Pascal Bouvier to get sizes without * printing. */ do_print = 0; @@ -3537,7 +3525,7 @@ int Winprint_Init( char buffer[100]; snprintf(buffer, sizeof(buffer), "%s::%s", gdiName, gdi_commands[i].command_string); - Tcl_CreateCommand(interp, buffer, gdi_commands[i].command, + Tcl_CreateObjCommand(interp, buffer, gdi_commands[i].command, NULL, (Tcl_CmdDeleteProc *) 0); Tcl_Export(interp, namespacePtr, gdi_commands[i].command_string, 0); } -- cgit v0.12