summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2021-05-06 03:48:08 (GMT)
committerKevin Walzer <kw@codebykevin.com>2021-05-06 03:48:08 (GMT)
commit1e7d79df7dfdb25ac911ca112fc891e4f6bb68d9 (patch)
tree45d96e8e465cce78d4a4e559c815e2b450fe884e
parentdf19bd86f4307eebad863249fdff6ce451fc909b (diff)
downloadtk-1e7d79df7dfdb25ac911ca112fc891e4f6bb68d9.zip
tk-1e7d79df7dfdb25ac911ca112fc891e4f6bb68d9.tar.gz
tk-1e7d79df7dfdb25ac911ca112fc891e4f6bb68d9.tar.bz2
More work on gdi needed to expose commands
-rw-r--r--library/print.tcl52
-rw-r--r--win/tkWinGDI.c36
2 files changed, 43 insertions, 45 deletions
diff --git a/library/print.tcl b/library/print.tcl
index 4a08231..54d775d 100644
--- a/library/print.tcl
+++ b/library/print.tcl
@@ -25,7 +25,7 @@ namespace eval ::tk::print {
variable ::tk::print::margin_left
variable ::tk::print::margin_top
variable printargs
- set printargs ""
+ array set printargs {}
# Multiple utility procedures for printing text based on the C printer
# primitives.
@@ -33,10 +33,9 @@ namespace eval ::tk::print {
# _page_args:
# Parse common arguments for text processing in the other commands.
#
- # Arguments:
- # array - name of an array in which to store the various pieces needed for text processing.
- proc _page_args { array } {
- upvar #0 $array ary
+ #
+ proc _page_args {} {
+ variable printargs
#First, we select the printer.
::tk::print::_selectprinter
@@ -47,20 +46,22 @@ namespace eval ::tk::print {
}
#Next, set values.
- set ary(hDC) $::tk::print::printer_name
- set ary(pw) $::tk::print::paper_width
- set ary(pl) $::tk::print::paper_height
- set ary(lm) $::tk::print::margin_left
- set ary(tm) $::tk::print::margin_top
- set ary(rm) [list expr $ary(pw) - $ary(lm)]
- set ary(bm) [list expr $ary(pl) - $ary(tm)]
- set ary(resx) $::tk::print::dpi_x
- set ary(resy) $::tk::print::dpi_y
- set ary(copies) $::tk::print::copies
-
- if { ( [ info exist ary(hDC) ] == 0 ) || ($ary(hDC) == 0x0) } {
+ set printargs(hDC) $::tk::print::printer_name
+ set printargs(pw) $::tk::print::paper_width
+ set printargs(pl) $::tk::print::paper_height
+ set printargs(lm) 100 ;#$::tk::print::margin_left
+ set printargs(tm) 100 ;#$::tk::print::margin_top
+ set printargs(rm) [expr $printargs(pw) - $printargs(lm)]
+ set printargs(bm) [expr $printargs(pl) - $printargs(tm)]
+ set printargs(resx) $::tk::print::dpi_x
+ set printargs(resy) $::tk::print::dpi_y
+ set printargs(copies) $::tk::print::copies
+
+ if { ( [ info exist printargs(hDC) ] == 0 ) || ($printargs(hDC) == 0x0) } {
error "Can't get printer attributes"
}
+
+ return printargs
}
# _ print_page_data
@@ -75,7 +76,8 @@ namespace eval ::tk::print {
proc _print_page_data { data {fontargs {}} } {
variable printargs
- _page_args printargs
+
+ _page_args
set tm [ expr $printargs(tm) * $printargs(resy) / 1000 ]
set lm [ expr $printargs(lm) * $printargs(resx) / 1000 ]
@@ -122,7 +124,7 @@ namespace eval ::tk::print {
proc _print_data { data {breaklines 1 } {font {}} } {
variable printargs
- _page_args printargs
+ _page_args
if { [string length $font] == 0 } {
eval ::tk::print::_gdi characters $printargs(hDC) -array printcharwid
@@ -278,10 +280,8 @@ namespace eval ::tk::print {
# name - App name to pass to printer.
proc _print_widget { wid {printer default} {name "Tk Print Job"} } {
-
- variable p
- set p(0) 0 ; unset p(0)
- _page_args p
+
+ _page_args
::tk::print::_opendoc
::tk::print::_openpage
@@ -568,10 +568,8 @@ namespace eval ::tk::print {
proc _print_canvas.text {hdc cw id} {
variable vtgPrint
- variable p
-
- set p(0) 1 ; unset p(0)
- _page_args p
+
+ _page_args
set color [_print_canvas.TransColor [$cw itemcget $id -fill]]
# if {[string match white [string tolower $color]]} {return}
diff --git a/win/tkWinGDI.c b/win/tkWinGDI.c
index aae31f5..4bd205c 100644
--- a/win/tkWinGDI.c
+++ b/win/tkWinGDI.c
@@ -26,25 +26,25 @@
#include "tkWinHDC.h"
/* Main dispatcher for commands. */
-static int TkWinGDI (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
+static int TkWinGDI (ClientData clientData, Tcl_Interp *interp, int argc, const char **argv);
/* Main dispatcher for subcommands. */
-static int TkWinGDISubcmd (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
+static int TkWinGDISubcmd (ClientData clientData, Tcl_Interp *interp, int argc, const char **argv);
/* Real functions. */
-static int GdiArc (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiBitmap (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiCharWidths (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiImage (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiPhoto (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiLine (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiOval (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiPolygon (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiRectangle(ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiText (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiMap (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
-static int GdiCopyBits (ClientData unused, Tcl_Interp *interp, int argc, const char **argv);
+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);
/* Local copies of similar routines elsewhere in Tcl/Tk. */
static int GdiParseColor (const char *name, unsigned long *color);
@@ -107,13 +107,13 @@ static HDC get_dc(Tcl_Interp *interp, const char *name);
*----------------------------------------------------------------------
*/
-static int TkWinGDI (ClientData unused, Tcl_Interp *interp, int argc, const char **argv)
+static int TkWinGDI (ClientData clientData, Tcl_Interp *interp, int argc, const char **argv)
{
if ( argc > 1 && strcmp(*argv, "::tk::print::_gdi") == 0 )
{
argc--;
argv++;
- return TkWinGDISubcmd(unused, interp, argc, argv);
+ return TkWinGDISubcmd(clientData, interp, argc, argv);
}
Tcl_AppendResult(interp, gdi_usage_message, NULL);
@@ -160,13 +160,13 @@ struct gdi_command
*----------------------------------------------------------------------
*/
-static int TkWinGDISubcmd (ClientData unused, Tcl_Interp *interp, int argc, const char **argv)
+static int TkWinGDISubcmd (ClientData clientData, Tcl_Interp *interp, int argc, const char **argv)
{
size_t i;
for (i=0; i<sizeof(gdi_commands) / sizeof(struct gdi_command); i++)
if ( strcmp (*argv, gdi_commands[i].command_string) == 0 )
- return (*gdi_commands[i].command)(unused, interp, argc-1, argv+1);
+ return (*gdi_commands[i].command)(clientData, interp, argc-1, argv+1);
Tcl_AppendResult (interp, gdi_usage_message, NULL);
return TCL_ERROR;