home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Komunikace
/
Comanche
/
comanche.exe
/
lib
/
iwidgets3.0.0
/
scripts
/
canvasprintdialog.itk
< prev
next >
Wrap
Text File
|
1999-02-24
|
6KB
|
156 lines
#
# 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" widgetDefault
option add *Canvasprintdialog.hPageCnt 1 widgetDefault
option add *Canvasprintdialog.orient landscape widgetDefault
option add *Canvasprintdialog.output printer widgetDefault
option add *Canvasprintdialog.pageSize A4 widgetDefault
option add *Canvasprintdialog.posterize 0 widgetDefault
option add *Canvasprintdialog.printCmd lpr widgetDefault
option add *Canvasprintdialog.printRegion "" widgetDefault
option add *Canvasprintdialog.vPageCnt 1 widgetDefault
option add *Canvasprintdialog.title "Canvas Print Dialog" widgetDefault
option add *Canvasprintdialog.master "." widgetDefault
#
# Usual options.
#
itk::usual Canvasprintdialog {
keep -background -cursor -foreground -modality
}
# ------------------------------------------------------------------
# CANVASPRINTDIALOG
# ------------------------------------------------------------------
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.
# ------------------------------------------------------------------
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 [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.
# ------------------------------------------------------------------
body iwidgets::Canvasprintdialog::deactivate {args} {
$itk_component(cpb) stop
return [eval Shell::deactivate $args]
}
# ------------------------------------------------------------------
# METHOD: getoutput
#
# Thinwrapped method of canvas print box class.
# ------------------------------------------------------------------
body iwidgets::Canvasprintdialog::getoutput {} {
return [$itk_component(cpb) getoutput]
}
# ------------------------------------------------------------------
# METHOD: setcanvas
#
# Thinwrapped method of canvas print box class.
# ------------------------------------------------------------------
body iwidgets::Canvasprintdialog::setcanvas {canv} {
return [$itk_component(cpb) setcanvas $canv]
}
# ------------------------------------------------------------------
# METHOD: refresh
#
# Thinwrapped method of canvas print box class.
# ------------------------------------------------------------------
body iwidgets::Canvasprintdialog::refresh {} {
return [$itk_component(cpb) refresh]
}
# ------------------------------------------------------------------
# METHOD: print
#
# Thinwrapped method of canvas print box class.
# ------------------------------------------------------------------
body iwidgets::Canvasprintdialog::print {} {
return [$itk_component(cpb) print]
}