⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 canvasprintbox.itk

📁 windows下的GDB insight前端
💻 ITK
📖 第 1 页 / 共 3 页
字号:
itcl::body iwidgets::Canvasprintbox::_update_canvas {{when later}} {	if {$win == "" || $canvas == "" || [$canvas find all] == ""} {		return	}	if {$when == "later"} {		if {$_reposition == ""} {			set _reposition [after idle [itcl::code $this _update_canvas now]]		}		return	}	_update_attr now	#	# Make a copy of the "source" canvas to the "stamp".	#	if {$_globVar($this,hpc) == [llength $vlines] &&	    $_globVar($this,vpc) == [llength $hlines]} {		stop		return	}		$canvw delete all	set width  [winfo width $canvw]	set height [winfo height $canvw]	set ps [_calc_poster_size]	#	# Calculate the scaling factor that would be needed to fit the	# whole "source" into the "stamp". This takes into account the	# total amount of "paper" that would be needed to print the	# contents of the "source".	#	set xsf [expr {$width/[lindex $ps 0]}]	set ysf [expr {$height/[lindex $ps 1]}]	set sf [expr {$xsf < $ysf ? $xsf : $ysf}]	set w [expr {[lindex $ps 0]*$sf}]	set h [expr {[lindex $ps 1]*$sf}]	set x1 [expr {($width-$w)/2}]	set y1 [expr {($height-$h)/2}]	set x2 [expr {$x1+$w}]	set y2 [expr {$y1+$h}]	set cx [expr {($x2+$x1)/ 2}]	set cy [expr {($y2+$y1)/ 2}]	set printreg [_calc_print_region]	set prx1 [lindex $printreg 0]	set pry1 [lindex $printreg 1]	set prx2 [lindex $printreg 2]	set pry2 [lindex $printreg 3]	set prcx [expr {($prx2+$prx1)/2}]	set prcy [expr {($pry2+$pry1)/2}]	set psf [_calc_print_scale]	#	# Copy all items from the "real" canvas to the canvas	# showing what we'll send to the printer. Bitmaps and	# texts are not copied because they can't be scaled,	# a rectangle will be created instead.	#	set tsf [expr {$sf * $psf}]	set dx [expr {$cx-($prcx*$tsf)}]	set dy [expr {$cy-($prcy*$tsf)}]	$canvw create rectangle \		[expr {$x1+0}] \		[expr {$y1+0}] \		[expr {$x2-0}] \		[expr {$y2-0}] -fill white	set items [eval "$canvas find overlapping $printreg"]	set itemCount [llength $items]	for {set cnt 0} {$cnt < $itemCount} {incr cnt} {		#		# Determine the item's type and coordinates		#		set i [lindex $items $cnt]		set t [$canvas type $i]		set crds [$canvas coords $i]		#		# Ask for the item's configuration settings and strip		# it to leave only a list of option names and values.		#		set cfg [$canvas itemconfigure $i]		set cfg2 ""		foreach c $cfg {			if {[llength $c] == 5} {				lappend cfg2 [lindex $c 0] [lindex $c 4]			}		}		#		# Handle texts and bitmaps differently: they will		# be represented as rectangles.		#		if {$t == "text" || $t == "bitmap" || $t == "window"} {			set t "rectangle"			set crds [$canvas bbox $i]			set cfg2 "-outline {} -fill gray"		}		#		# Remove the arrows from a line item when the scale		# factor drops below 1/3rd of the original size.		# This to prevent the arrowheads from dominating the		# display.		#		if {$t == "line" && $tsf < 0.33} {			lappend cfg2 -arrow none		}				#		# Create a copy of the item on the "printing" canvas.		#		set i2 [eval "$canvw create $t $crds $cfg2"]		$canvw scale $i2 0 0 $tsf $tsf		$canvw move $i2 $dx $dy		if {($cnt%25) == 0} {			update		}		if {$_reposition == ""} {			return		}	}	set p $x1	set i 1	set vlines {}	while {$i < $_globVar($this,hpc)} {		set p [expr {$p + ($w/$_globVar($this,hpc))}]		set l [$canvw create line $p $y1 $p $y2]		lappend vlines $l		incr i	}	set p $y1	set i 1	set vlines {}	while {$i < $_globVar($this,vpc)} {		set p [expr {$p + ($h/$_globVar($this,vpc))}]		set l [$canvw create line $x1 $p $x2 $p]		lappend vlines $l		incr i	}	set _reposition ""}## Update the attributes to reflect changes made in the user-# interface.## In:	itk_option (attrib) - the attributes to update#	itk_component (attrib) - the widgets#	_globVar (common) - the global var holding the state#		of all radiobuttons and checkboxes.# Out:	-#itcl::body iwidgets::Canvasprintbox::_update_attr {{when "later"}} {	if {$when != "now"} {		if {$_update_attr_id == ""} {			set _update_attr_id [after idle [itcl::code $this _update_attr now]]		}		return	}        set itk_option(-printcmd)  $_globVar($this,printeref)        set itk_option(-filename)  $_globVar($this,fileef)        set itk_option(-output)    $_globVar($this,output)	set itk_option(-pagesize)  [string tolower [$itk_component(paperom) get]]	set itk_option(-stretch)   $_globVar($this,stretchcb)	set itk_option(-posterize) $_globVar($this,postercb)	set itk_option(-vpagecnt)  $_globVar($this,vpc)	set itk_option(-hpagecnt)  $_globVar($this,hpc)	set itk_option(-orient)    [$itk_component(orientom) get]	set rotate                 [expr {$itk_option(-orient) == "landscape"}]	if {$_globVar($this,output) == "file"} {		$itk_component(fileef) configure \			-state normal -foreground $itk_option(-foreground)		$itk_component(printeref) configure \			-state disabled -foreground $itk_option(-disabledforeground)	} else {		$itk_component(fileef) configure \			-state disabled -foreground $itk_option(-disabledforeground)		$itk_component(printeref) configure \			-state normal -foreground $itk_option(-foreground)	}	set fg [expr {$_globVar($this,postercb) \		? $itk_option(-foreground) : $itk_option(-disabledforeground)}]	$itk_component(vpcnt) configure -foreground $fg	$itk_component(hpcnt) configure -foreground $fg	$itk_component(pages) configure -foreground $fg	#	# Update dependencies among widgets. (For example: disabling	# an entry-widget when its associated checkbox-button is used	# to turn of the option (the entry's value is not needed	# anymore and this should be reflected in the fact that it	# isn't possible to change it anymore).	#	# former method:_update_widgets/_update_UI	#	set state [expr {$itk_option(-posterize) ? "normal" : "disabled"}]	$itk_component(vpcnt) configure -state $state	$itk_component(hpcnt) configure -state $state	$itk_component(paperom) select "*[string range $itk_option(-pagesize) 1 end]"	set _update_attr_id ""}## Gets called when the CanvasPrintBox-widget gets mapped.#itcl::body iwidgets::Canvasprintbox::_mapEventHandler {} {	set win $itk_interior	set canvw $itk_component(canvas)	if {$canvas != ""} {		setcanvas $canvas	}	_update_attr}## Destroy this object and its associated widgets.#itcl::body iwidgets::Canvasprintbox::destructor {} {	stop}## Hold the information about common paper sizes. A bit of a hack, but it# should be possible to add your own if you take a look at it.#itcl::body iwidgets::Canvasprintbox::ezPaperInfo {size {attr ""} \	{orient "portrait"} {window ""}} {    	set size [string tolower $size]	set attr [string tolower $attr]	set orient [string tolower $orient]		case $size in {		types {			return "A5 A4 A3 A2 A1 Legal Letter"		}		a5 {			set paper(x1) "1.0c"			set paper(y1) "1.0c"			set paper(x2) "13.85c"			set paper(y2) "20.0c"			set paper(pheight) "19.0c"			set paper(pwidth) "12.85c"			set paper(height) "21.0c"			set paper(width) "14.85c"			set paper(centerx) "7.425c"			set paper(centery) "10.5c"		}		a4 {			set paper(x1) "1.0c"			set paper(y1) "1.0c"			set paper(x2) "20.0c"			set paper(y2) "28.7c"			set paper(pheight) "27.7c"			set paper(pwidth) "19.0c"			set paper(height) "29.7c"			set paper(width) "21.0c"			set paper(centerx) "10.5c"			set paper(centery) "14.85c"		}		a3 {			set paper(x1) "1.0c"			set paper(y1) "1.0c"			set paper(x2) "28.7c"			set paper(y2) "41.0c"			set paper(pheight) "40.0c"			set paper(pwidth) "27.7c"			set paper(height) "42.0c"			set paper(width) "29.7c"			set paper(centerx) "14.85c"			set paper(centery)  "21.0c"		}		a2 {			set paper(x1) "1.0c"			set paper(y1) "1.0c"			set paper(x2) "41.0c"			set paper(y2) "58.4c"			set paper(pheight) "57.4c"			set paper(pwidth) "40.0c"			set paper(height) "59.4c"			set paper(width) "42.0c"			set paper(centerx) "21.0c"			set paper(centery)  "29.7c"		}		a1 {			set paper(x1) "1.0c"			set paper(y1) "1.0c"			set paper(x2) "58.4c"			set paper(y2) "83.0c"			set paper(pheight) "82.0c"			set paper(pwidth) "57.4c"			set paper(height) "84.0c"			set paper(width) "59.4c"			set paper(centerx) "29.7c"			set paper(centery)  "42.0c"		}		legal {			set paper(x1) "0.2i"			set paper(y1) "0.2i"			set paper(x2) "8.3i"			set paper(y2) "13.8i"			set paper(pheight) "13.6i"			set paper(pwidth) "8.1i"			set paper(height) "14.0i"			set paper(width) "8.5i"			set paper(centerx) "4.25i"			set paper(centery) "7.0i"		}		letter {			set paper(x1) "0.2i"			set paper(y1) "0.2i"			set paper(x2) "8.3i"			set paper(y2) "10.8i"			set paper(pheight) "10.6i"			set paper(pwidth) "8.1i"			set paper(height) "11.0i"			set paper(width) "8.5i"			set paper(centerx) "4.25i"			set paper(centery) "5.5i"		}		default {			error "ezPaperInfo: Unknown paper type ($type)"		}	}		set inv(x1) "y1"	set inv(x2) "y2"	set inv(y1) "x1"	set inv(y2) "x2"	set inv(pwidth) "pheight"	set inv(pheight) "pwidth"	set inv(width) "height"	set inv(height) "width"	set inv(centerx) "centery"	set inv(centery) "centerx"		case $orient in {		landscape {			set res $paper($inv($attr))		}		portrait {			set res $paper($attr)		}		default {			error "ezPaperInfo: orientation should be\				portrait or landscape (not $orient)"		}	}		if {$window != ""} {		set res [winfo fpixels $window $res]	}		return $res} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -