proc setRatio {maintain correct_ratio width height ratio change_height} {
if {[$maintain getCurrentValue]} {
if {$change_height} {
catch {[$height setCurrentValue [expr [$width getCurrentValue] / [$correct_ratio getCurrentValue]]]}
} else {
$width setCurrentValue [expr [$height getCurrentValue] * [$correct_ratio getCurrentValue]]
}
}
set value "-"
catch {[set value "[format %.5f [expr 1.0 * [$width getCurrentValue] / [$height getCurrentValue]]]"]}
$ratio setCurrentValue $value
}
GuidoForm frm00704 {
-default_buttons
-label "Change the Size and Position of an Image"
-tip IMAGE_ENTITY_EDIT_TIP
GuidoField x {
-display_length 6
-format double
-label "X offset from lower left corner (mm)"
-max_length 9
-null false
-translate upper
}
GuidoField y {
-display_length 6
-format double
-label "Y offset from lower left corner (mm)"
-max_length 9
-null false
-translate upper
}
GuidoFiller frm00704_8 {
-height 1
}
GuidoFiller frm00704_9 {
-height 1
}
GuidoField width {
-display_length 6
-format double
-label "Width (mm)"
-max_length 9
-null false
-translate upper
-low_bound 1
-decimals 3
}
GuidoField height {
-display_length 6
-format double
-label "Height (mm)"
-max_length 9
-null false
-translate upper
-low_bound 1
-decimals 3
}
GuidoLabel ratio_label {
-label "Aspect ratio:"
}
GuidoLabel ratio {
}
GuidoFiller frm00704_10 {
-height 1
}
GuidoFiller frm00704_11 {
-height 1
}
GuidoCheckBox maintain {
-label "Maintain aspect ratio:"
-default false
}
GuidoField width_px {
-display_length 6
-format integer
-input false
-label "Width (pixels)"
-max_length 6
-translate upper
}
GuidoField height_px {
-display_length 6
-format integer
-input false
-label "Height (pixels)"
-max_length 6
-translate upper
}
GuidoLabel ratio_label {
-label "Aspect ratio:"
}
GuidoLabel ratio_px {
-action initial {[setRatio $maintain $ratio_px $width_px $height_px $ratio_px 0]}
}
$width setActionCallback keyPressed   {[setRatio $maintain $ratio_px $width $height $ratio 1]}
$width setActionCallback valueChanged {[setRatio $maintain $ratio_px $width $height $ratio 1]}
$width setActionCallback keyReleased  {[setRatio $maintain $ratio_px $width $height $ratio 1]}
$width setActionCallback keyTyped     {[setRatio $maintain $ratio_px $width $height $ratio 1]}
$width setActionCallback focusLost    {[setRatio $maintain $ratio_px $width $height $ratio 1]}
$height setActionCallback keyPressed   {[setRatio $maintain $ratio_px $width $height $ratio 0]}
$height setActionCallback valueChanged {[setRatio $maintain $ratio_px $width $height $ratio 0]}
$height setActionCallback keyReleased  {[setRatio $maintain $ratio_px $width $height $ratio 0]}
$height setActionCallback keyTyped     {[setRatio $maintain $ratio_px $width $height $ratio 0]}
$height setActionCallback focusLost    {[setRatio $maintain $ratio_px $width $height $ratio 0]}
$ratio  setActionCallback initial {[setRatio $maintain $ratio_px $width $height $ratio 0]}
$maintain setActionCallback valueChanged {[setRatio $maintain $ratio_px $width $height $ratio 1]}
}
