Tk Source Code

Changes On Branch bug-bb5c3d0ecc
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-bb5c3d0ecc Excluding Merge-Ins

This is equivalent to a diff from 6e560259 to 4a06dff1

2025-04-26
11:47
Fix [bb5c3d0ecc]: tk print command fails on windows. With complementary patches by Emiliano Gavilan. check-in: 5c5daa6c user: fvogel tags: trunk, main
07:42
Correctly indent continuation lines. Closed-Leaf check-in: 4a06dff1 user: fvogel tags: bug-bb5c3d0ecc
2025-04-25
19:15
Further patch from Emiliano Gavilan. check-in: c4c9d256 user: fvogel tags: bug-bb5c3d0ecc
2025-04-24
21:01
Fix [bb5c3d0ecc]: tk print command fails on windows check-in: 8fd0f283 user: fvogel tags: bug-bb5c3d0ecc
11:59
Fix [855ec435ef]: Aqua sometimes fails to set TkEventTarget when a new keyWindow is assigned - breaks BWidget DND. check-in: 87e85a52 user: jan.nijtmans tags: core-9-0-branch
11:52
Merge 9.0 check-in: 43dd3043 user: jan.nijtmans tags: trunk, main
2025-04-23
09:42
Attempt to fix [d2eac285d9]: tk print command fails with canvas widget Closed-Leaf check-in: fada46f6 user: jan.nijtmans tags: bug-d2eac285d9
2025-04-22
22:56
Merge trunk, resolve conflicts in winDialog.test check-in: b5831181 user: erikleunissen tags: tk_collect_test_utils, FINAL_REVIEW
2025-04-18
02:52
Merge trunk check-in: 1b5bbef9 user: kevin_walzer tags: tka11y
2025-04-14
14:01
merge main Leaf check-in: 49cf5954 user: oehhar tags: tip-714-alt
13:56
merge main, minimize diff Leaf check-in: a68b9232 user: oehhar tags: tip-714-image-driver-info
2025-04-11
17:33
Fix [855ec435ef]: Aqua sometimes fails to set TkEventTarget when a new keyWindow is assigned - breaks BWidget DND. check-in: 6e560259 user: culler tags: trunk, main
15:57
Move the call to [NSApp setTkEventTarget:] into the windowActivation callback method of NSApp. Closed-Leaf check-in: 82221f8b user: culler tags: bug-855ec435ef
2025-04-10
19:32
WidgetDemo: Minor improvements in knightstour.tcl. check-in: 696a8519 user: csaba tags: trunk, main

Changes to library/print.tcl.
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

	    #First, we select the printer.
	    _selectprinter

	    #Next, set values. Some are taken from the printer,
	    #some are sane defaults.

	if {[info exists printer_name] && $printer_name ne ""} {
	    set printargs(hDC) $printer_name
	    set printargs(pw) $paper_width
	    set printargs(pl) $paper_height
	    set printargs(lm) 1000
	    set printargs(tm) 1000
	    set printargs(rm) 1000
	    set printargs(bm) 1000
	    set printargs(resx) $dpi_x
	    set printargs(resy) $dpi_y
	    set printargs(copies) $copies
	    set printargs(resolution) [list $dpi_x $dpi_y]
		}
	}

	# _print_data
	# This function prints multiple-page files, using a line-oriented
	# function, taking advantage of knowing the character widths.
	# Arguments:
	# data -       Text data for printing







|
|
|
|
|
|
|
|
|
|
|
|
|







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

	    #First, we select the printer.
	    _selectprinter

	    #Next, set values. Some are taken from the printer,
	    #some are sane defaults.

	    if {[info exists printer_name] && $printer_name ne ""} {
		set printargs(hDC) $printer_name
		set printargs(pw) $paper_width
		set printargs(pl) $paper_height
		set printargs(lm) 1000
		set printargs(tm) 1000
		set printargs(rm) 1000
		set printargs(bm) 1000
		set printargs(resx) $dpi_x
		set printargs(resy) $dpi_y
		set printargs(copies) $copies
		set printargs(resolution) [list $dpi_x $dpi_y]
	    }
	}

	# _print_data
	# This function prints multiple-page files, using a line-oriented
	# function, taking advantage of knowing the character widths.
	# Arguments:
	# data -       Text data for printing
Changes to win/tkWinGDI.c.
3630
3631
3632
3633
3634
3635
3636


















3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647



3648
3649
3650
3651
3652
3653
3654

3655
3656

3657
3658

3659
3660

3661
3662

3663
3664


3665
3666
3667
3668
3669
3670
3671
	    paper_width = (int) localDevmode->dmPaperWidth / 0.254;
	    copies = pd.nCopies;
	    /* Set device context here for all GDI printing operations. */
	    printDC = CreateDCW(L"WINSPOOL", printerName, NULL, localDevmode);
	} else {
	    localDevmode = NULL;
	}


















    }

    if (pd.hDevMode != NULL) {
	GlobalFree(pd.hDevMode);
    }

    /*
     * Store print properties and link variables so they can be accessed from
     * script level.
     */
    if (localPrinterName != NULL) {



	char* varlink1 = (char*)ckalloc(100 * sizeof(char));
	char** varlink2 = (char**)ckalloc(sizeof(char*));
	*varlink2 = varlink1;
	WideCharToMultiByte(CP_UTF8, 0, localPrinterName, -1, varlink1, 0, NULL, NULL);

	Tcl_LinkVar(interp, "::tk::print::printer_name", varlink2,
	    TCL_LINK_STRING | TCL_LINK_READ_ONLY);

	Tcl_LinkVar(interp, "::tk::print::copies", &copies,
	    TCL_LINK_INT | TCL_LINK_READ_ONLY);

	Tcl_LinkVar(interp, "::tk::print::dpi_x", &dpi_x,
	    TCL_LINK_INT | TCL_LINK_READ_ONLY);

	Tcl_LinkVar(interp, "::tk::print::dpi_y", &dpi_y,
	    TCL_LINK_INT | TCL_LINK_READ_ONLY);

	Tcl_LinkVar(interp, "::tk::print::paper_width", &paper_width,
	    TCL_LINK_INT | TCL_LINK_READ_ONLY);

	Tcl_LinkVar(interp, "::tk::print::paper_height", &paper_height,
	    TCL_LINK_INT | TCL_LINK_READ_ONLY);


    }

    return TCL_OK;
}

/*
 * --------------------------------------------------------------------------







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|



>
>
>
|
|
<
|
|
|
<
>
|
<
>
|
<
>
|
<
>
|
<
>
|
<
>
>







3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670

3671
3672
3673

3674
3675

3676
3677

3678
3679

3680
3681

3682
3683

3684
3685
3686
3687
3688
3689
3690
3691
3692
	    paper_width = (int) localDevmode->dmPaperWidth / 0.254;
	    copies = pd.nCopies;
	    /* Set device context here for all GDI printing operations. */
	    printDC = CreateDCW(L"WINSPOOL", printerName, NULL, localDevmode);
	} else {
	    localDevmode = NULL;
	}
    } else {
	unsigned int errorcode = CommDlgExtendedError();

	/*
	 * The user cancelled, or there was an error
	 * The code on the Tcl side checks if the variable
	 * ::tk::print::printer_name is defined to determine
	 * that a valid selection was made.
	 * So we better unset this here, unconditionally.
	 */
	Tcl_UnsetVar(interp, "::tk::print::printer_name", 0);
	if (errorcode != 0) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf("print failed: error %04x",
		    errorcode));
	    Tcl_SetErrorCode(interp, "TK", "PRINT", "DIALOG", (char*)NULL);
	    return TCL_ERROR;
	}
	return TCL_OK;
    }

    if (pd.hDevMode != NULL) {
	GlobalFree(pd.hDevMode);
    }

    /*
     * Store print properties in variables so they can be accessed from
     * script level.
     */
    if (localPrinterName != NULL) {
	char *prname;
	int size_needed = WideCharToMultiByte(CP_UTF8, 0, localPrinterName,
		-1, NULL, 0, NULL, NULL);

	prname = (char*)ckalloc(size_needed);

	WideCharToMultiByte(CP_UTF8, 0, localPrinterName, -1, prname,
		size_needed, NULL, NULL);
	Tcl_SetVar2Ex(interp, "::tk::print::printer_name", NULL,

		Tcl_NewStringObj(prname, size_needed - 1), 0);
	Tcl_SetVar2Ex(interp, "::tk::print::copies", NULL,

		Tcl_NewIntObj(copies), 0);
	Tcl_SetVar2Ex(interp, "::tk::print::dpi_x", NULL,

		Tcl_NewIntObj(dpi_x), 0);
	Tcl_SetVar2Ex(interp, "::tk::print::dpi_y", NULL,

		Tcl_NewIntObj(dpi_y), 0);
	Tcl_SetVar2Ex(interp, "::tk::print::paper_width", NULL,

		Tcl_NewIntObj(paper_width), 0);
	Tcl_SetVar2Ex(interp, "::tk::print::paper_height", NULL,

		Tcl_NewIntObj(paper_height), 0);
	ckfree(prname);
    }

    return TCL_OK;
}

/*
 * --------------------------------------------------------------------------