home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)printoptio.tcl /main/hindenburg/3
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)printoptio.tcl /main/hindenburg/3 14 Nov 1996 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
- # End user added include file section
-
-
- Class PrintOptionsDialog : {TemplateDialog} {
- constructor
- method destructor
- method popUp
- method printOptions
- method handleOk
- method handleCancel
- method autoScaleChanged
- method scaleValue
- method scaleModified
- method numPages
- method pagesModified
- attribute diagram
- attribute readOnly
- attribute title
- attribute orientation
- attribute doPrintBox
- attribute autoScale
- attribute horNumPages
- attribute verNumPages
- attribute scale
- attribute horPagesPrev
- attribute verPagesPrev
- attribute scalePrev
- attribute props
- }
-
- constructor PrintOptionsDialog {class this name} {
- set this [TemplateDialog::constructor $class $this $name]
- $this readOnly 0
- # Start constructor user section
- $this TemplateDialog::title "Print Options"
- interface DlgColumn $this.c {
- Label titleLabel {
- text "Title:"
- }
- SingleLineText title {}
- CheckButton landscape {
- label "Landscape"
- }
- CheckButton printBox {
- label "Print Box"
- }
- NamedGroup scaleStrategy {
- label "Scale Strategy"
- DlgColumn c {
- CheckButton autoScale {
- label "Auto Scale"
- }
- Label scaleLabel {
- text "Scale Factor"
- }
- FloatField scale {}
- Label horLabel {
- text "Horizontal Number Of Pages"
- }
- IntField horPages {}
- Label verLabel {
- text "Vertical Number Of Pages"
- }
- IntField verPages {}
- }
- }
- NamedGroup saved {
- label "Options To Be Saved With Diagram"
- DlgColumn c {
- CheckButton title {
- label Title
- }
- CheckButton orientation {
- label Orientation
- }
- CheckButton scaleStrategy {
- label "Scale Strategy"
- }
- }
- }
- }
- $this.c.scaleStrategy.c.autoScale stateChanged "$this autoScaleChanged"
- $this.c.scaleStrategy.c.scale textModified "$this scaleModified"
- $this.c.scaleStrategy.c.horPages textModified "$this pagesModified hor"
- $this.c.scaleStrategy.c.verPages textModified "$this pagesModified ver"
- $this config \
- -modal yes \
- -autoPopDown no \
- -okPressed {%this handleOk} \
- -cancelPressed {%this handleCancel} \
- -helpPressed {.main helpOnName printOptions}
- # End constructor user section
- return $this
- }
-
- method PrintOptionsDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method PrintOptionsDialog::popUp {this} {
- set props [$this props]
- set diag [$this diagram]
- set saved $this.c.saved.c
- if [$this readOnly] {
- $saved.title sensitive 0
- $saved.orientation sensitive 0
- $saved.scaleStrategy sensitive 0
- } else {
- $saved.title sensitive 1
- $saved.orientation sensitive 1
- $saved.scaleStrategy sensitive 1
- }
-
- set scStr [expr {[$props findProperty M4_ps_auto_scale] != ""}]
- $saved.title state [expr {[$props findProperty M4_ps_title] != ""}]
- $saved.orientation state [expr {[$props findProperty M4_ps_mode] != ""}]
- $saved.scaleStrategy state $scStr
-
- set objs [list m4_var $props]
- set cmds [list get getProperty]
- set oTtl [lindex $objs [$saved.title state]]
- set gTtl [lindex $cmds [$saved.title state]]
- $this.c.title text [$oTtl $gTtl M4_ps_title]
-
- set oMod [lindex $objs [$saved.orientation state]]
- set gMod [lindex $cmds [$saved.orientation state]]
- $this.c.landscape state [expr {[$oMod $gMod M4_ps_mode] == "landscape"}]
-
- set oASc [lindex $objs $scStr]
- set gASc [lindex $cmds $scStr]
- set aScSt [$oASc $gASc M4_ps_auto_scale]
- $this.c.scaleStrategy.c.autoScale state $aScSt
-
- set pgs [expr $scStr && $aScSt]
- set oPgs [lindex $objs $pgs]
- set gPgs [lindex $cmds $pgs]
- $this numPages hor [$oPgs $gPgs M4_ps_columns]
- $this numPages ver [$oPgs $gPgs M4_ps_rows]
-
- set scl [expr $scStr && ! $aScSt]
- set oScl [lindex $objs $scl]
- set gScl [lindex $cmds $scl]
- $this scaleValue [$oScl $gScl M4_ps_scale]
- $this.c.printBox state [m4_var get M4_print_box]
- $this autoScaleChanged
-
- $this TemplateDialog::popUp
- }
-
- method PrintOptionsDialog::printOptions {this} {
- set result ""
- foreach var {title orientation doPrintBox autoScale horNumPages
- verNumPages scale} {
- if {[$this $var] != ""} {
- lappend result -$var [$this $var]
- }
- }
- return $result
- }
-
- method PrintOptionsDialog::handleOk {this} {
- $this title [$this.c.title text]
- set state [$this.c.landscape state]
- if $state {
- $this orientation "landscape"
- } else {
- $this orientation "portrait"
- }
- $this doPrintBox [$this.c.printBox state]
- $this autoScale [$this.c.scaleStrategy.c.autoScale state]
- set label ""
- if [$this autoScale] {
- $this horNumPages [$this numPages hor]
- $this verNumPages [$this numPages ver]
- $this scale ""
- if {[$this horNumPages] <= 0} {
- set label hor
- } elseif {[$this verNumPages] <= 0} {
- set label ver
- }
- } else {
- $this horNumPages ""
- $this verNumPages ""
- $this scale [$this scaleValue]
- if {[$this scale] <= 0} {
- set label scale
- }
- }
- if {"$label" != ""} {
- set fieldName [$this.c.scaleStrategy.c.${label}Label text]
- wmtkerror "$fieldName must be a positive value"
- return
- }
-
- if {"[m4_var get M4_ps_title]" != "[$this title]"} {
- m4_var set M4_ps_title [$this title]
- }
- if {"[m4_var get M4_ps_mode]" != "[$this orientation]"} {
- m4_var set M4_ps_mode [$this orientation]
- }
- if {"[m4_var get M4_print_box]" != "[$this doPrintBox]"} {
- m4_var set M4_print_box [$this doPrintBox]
- }
- if [$this autoScale] {
- if {[m4_var get M4_ps_auto_scale] != 1} {
- m4_var set M4_ps_auto_scale 1
- }
- if {"[m4_var get M4_ps_columns]" != "[$this horNumPages]"} {
- m4_var set M4_ps_columns [$this horNumPages]
- }
- if {"[m4_var get M4_ps_rows]" != "[$this verNumPages]"} {
- m4_var set M4_ps_rows [$this verNumPages]
- }
- } else {
- if {[m4_var get M4_ps_auto_scale] != 0} {
- m4_var set M4_ps_auto_scale 0
- }
- if {"[m4_var get M4_ps_scale]" != "[$this scale]"} {
- m4_var set M4_ps_scale [$this scale]
- }
- }
-
- set props [$this props]
- if [$this readOnly] {
- $props quit
- } else {
- if [$this.c.saved.c.title state] {
- $props changeProperty M4_ps_title [$this title]
- } else {
- $props removeProperty M4_ps_title
- }
- if [$this.c.saved.c.orientation state] {
- $props changeProperty M4_ps_mode [$this orientation]
- } else {
- $props removeProperty M4_ps_mode
- }
- if [$this.c.saved.c.scaleStrategy state] {
- if [$this autoScale] {
- $props changeProperty M4_ps_auto_scale 1
- $props changeProperty M4_ps_columns \
- [$this horNumPages]
- $props changeProperty M4_ps_rows \
- [$this verNumPages]
- $props removeProperty M4_ps_scale
- } else {
- $props changeProperty M4_ps_auto_scale 0
- $props changeProperty M4_ps_scale [$this scale]
- $props removeProperty M4_ps_columns
- $props removeProperty M4_ps_rows
- }
- } else {
- $props removeProperty M4_ps_auto_scale
- $props removeProperty M4_ps_columns
- $props removeProperty M4_ps_scale
- $props removeProperty M4_ps_rows
- }
- }
-
- $this popDown
- }
-
- method PrintOptionsDialog::handleCancel {this} {
- }
-
- method PrintOptionsDialog::autoScaleChanged {this} {
- if [$this.c.scaleStrategy.c.autoScale state] {
- $this.c.scaleStrategy.c.horPages sensitive 1
- $this.c.scaleStrategy.c.verPages sensitive 1
- $this.c.scaleStrategy.c.scale sensitive 0
- } else {
- $this.c.scaleStrategy.c.horPages sensitive 0
- $this.c.scaleStrategy.c.verPages sensitive 0
- $this.c.scaleStrategy.c.scale sensitive 1
- }
- }
-
- method PrintOptionsDialog::scaleValue {this {scale ,}} {
- if {$scale == ","} {
- return [$this.c.scaleStrategy.c.scale floatValue]
- }
- $this.c.scaleStrategy.c.scale floatValue $scale
- $this scalePrev $scale
- }
-
- method PrintOptionsDialog::scaleModified {this} {
- if {[$this scaleValue] >= 0} {
- $this scalePrev [$this.c.scaleStrategy.c.scale text]
- } else {
- set cIdx [$this.c.scaleStrategy.c.scale cursorIndex]
- $this.c.scaleStrategy.c.scale text [$this scalePrev]
- $this.c.scaleStrategy.c.scale cursorIndex [expr $cIdx - 1]
- }
- }
-
- method PrintOptionsDialog::numPages {this dim {num ,}} {
- if {$num == ","} {
- return [$this.c.scaleStrategy.c.${dim}Pages intValue]
- }
- $this.c.scaleStrategy.c.${dim}Pages intValue $num
- $this ${dim}PagesPrev $num
- }
-
- method PrintOptionsDialog::pagesModified {this dim} {
- if {[$this numPages $dim] >= 0} {
- $this ${dim}PagesPrev [$this.c.scaleStrategy.c.${dim}Pages text]
- } else {
- set cIdx [$this.c.scaleStrategy.c.${dim}Pages cursorIndex]
- $this.c.scaleStrategy.c.${dim}Pages text [$this ${dim}PagesPrev]
- $this.c.scaleStrategy.c.${dim}Pages cursorIndex [expr $cIdx - 1]
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-