📄 canvasprintdialog.itk
字号:
## CanvasPrintDialog v1.5# ----------------------------------------------------------------------# Implements a print dialog for printing the contents of a canvas widget# to a printer or a file. It is possible to specify page orientation, the# number of pages to print the image on and if the output should be# stretched to fit the page. The CanvasPrintDialog is derived from the# Dialog class and is composed of a CanvasPrintBox with attributes set to# manipulate the dialog buttons.# # ----------------------------------------------------------------------# AUTHOR: Tako Schotanus EMAIL: Tako.Schotanus@bouw.tno.nl# ----------------------------------------------------------------------# Copyright (c) 1995 Tako Schotanus# ======================================================================# Permission is hereby granted, without written agreement and without# license or royalty fees, to use, copy, modify, and distribute this# software and its documentation for any purpose, provided that the# above copyright notice and the following two paragraphs appear in# all copies of this software.# # IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN # IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE.## THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND # FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS# ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.# ======================================================================## Option database default resources:#option add *Canvasprintdialog.filename "canvas.ps" widgetDefaultoption add *Canvasprintdialog.hPageCnt 1 widgetDefaultoption add *Canvasprintdialog.orient landscape widgetDefaultoption add *Canvasprintdialog.output printer widgetDefaultoption add *Canvasprintdialog.pageSize A4 widgetDefaultoption add *Canvasprintdialog.posterize 0 widgetDefaultoption add *Canvasprintdialog.printCmd lpr widgetDefaultoption add *Canvasprintdialog.printRegion "" widgetDefaultoption add *Canvasprintdialog.vPageCnt 1 widgetDefaultoption add *Canvasprintdialog.title "Canvas Print Dialog" widgetDefaultoption add *Canvasprintdialog.master "." widgetDefault## Usual options.#itk::usual Canvasprintdialog { keep -background -cursor -foreground -modality }# ------------------------------------------------------------------# CANVASPRINTDIALOG# ------------------------------------------------------------------itcl::class iwidgets::Canvasprintdialog { inherit iwidgets::Dialog constructor {args} {} destructor {} method deactivate {args} {} method getoutput {} {} method setcanvas {canv} {} method refresh {} {} method print {} {}}## Provide a lowercased access method for the Canvasprintdialog class.# proc ::iwidgets::canvasprintdialog {args} { uplevel ::iwidgets::Canvasprintdialog $args}# ------------------------------------------------------------------# CONSTRUCTOR ## Create new file selection dialog.# ------------------------------------------------------------------itcl::body iwidgets::Canvasprintdialog::constructor {args} { component hull configure -borderwidth 0 # # Instantiate a file selection box widget. # itk_component add cpb { iwidgets::Canvasprintbox $itk_interior.cpb } { usual keep -printregion -output -printcmd -filename -pagesize \ -orient -stretch -posterize -hpagecnt -vpagecnt } pack $itk_component(cpb) -fill both -expand yes # # Hide the apply and help buttons. # buttonconfigure OK -text Print buttonconfigure Apply -command [itcl::code $this refresh] -text Refresh hide Help eval itk_initialize $args} # ------------------------------------------------------------------# METHOD: deactivate## Redefines method of dialog shell class. Stops the drawing of the# thumbnail (when busy) upon deactivation of the dialog.# ------------------------------------------------------------------itcl::body iwidgets::Canvasprintdialog::deactivate {args} { $itk_component(cpb) stop return [eval Shell::deactivate $args]}# ------------------------------------------------------------------# METHOD: getoutput## Thinwrapped method of canvas print box class.# ------------------------------------------------------------------itcl::body iwidgets::Canvasprintdialog::getoutput {} { return [$itk_component(cpb) getoutput]}# ------------------------------------------------------------------# METHOD: setcanvas## Thinwrapped method of canvas print box class.# ------------------------------------------------------------------itcl::body iwidgets::Canvasprintdialog::setcanvas {canv} { return [$itk_component(cpb) setcanvas $canv]}# ------------------------------------------------------------------# METHOD: refresh## Thinwrapped method of canvas print box class.# ------------------------------------------------------------------itcl::body iwidgets::Canvasprintdialog::refresh {} { return [$itk_component(cpb) refresh]}# ------------------------------------------------------------------# METHOD: print## Thinwrapped method of canvas print box class.# ------------------------------------------------------------------itcl::body iwidgets::Canvasprintdialog::print {} { return [$itk_component(cpb) print]}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -