#!/bin/sh
# \
	exec itkwish "$0" ${1+"$@"}

#
# Use: TestCanvasPrintDialog [<printcommand> [<pagesize>]]
#
option add *textBackground white

set pc "lpr"
set ps "A4"
if {$argc > 0} {
	set pc [lindex $argv 0]
	if {$argc > 1} {
		set ps [lindex $argv 1]
	}
}

Canvasprintdialog .pcd -printcmd $pc -modality application -pagesize $ps

set sz "A4"
set or "landscape"
set x1 [iwidgets::Canvasprintbox::ezPaperInfo $sz x1 $or]
set x2 [iwidgets::Canvasprintbox::ezPaperInfo $sz x2 $or]
set y1 [iwidgets::Canvasprintbox::ezPaperInfo $sz y1 $or]
set y2 [iwidgets::Canvasprintbox::ezPaperInfo $sz y2 $or]
set cx [iwidgets::Canvasprintbox::ezPaperInfo $sz centerx $or]
set cy [iwidgets::Canvasprintbox::ezPaperInfo $sz centery $or]

canvas .c
pack .c -expand 1 -fill both
.c create rectangle $x1 $y1 $x2 $y2

set y 150
set j 0
while {$j < 3} {
	set i 0
	set x 150
	while {$i < 15} {
		set item [.c create oval -50 -50 50 50 -fill red]
		.c move $item $x $y
		set item [.c create rectangle -10 0 70 100 -fill blue]
		.c move $item $x $y
		set item [.c create text 10 130 -text TEST!!!!]
		.c move $item $x $y
		set item [.c create bitmap 20 150 -bitmap hourglass]
		.c move $item $x $y
		incr x 50
		incr i
	}
	incr y 200
	incr j
}

update

.pcd setcanvas .c
if {[.pcd activate]} {
	puts "Printing.... NOT ;)"
	puts "(Remove the comment in the source to get real printing)"

#
# REMOVE THE COMMENT IN THE FOLLOWING LINE TO GET "REAL" PRINTING.
#
#	.pcd print
#
}

exit
