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 {
catch {[$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
}
proc setDimensions {file_name width_px height_px} {
set filename [$file_name getCurrentValue]
set buffer [GuidoExecServer GetImageDimensions [subst {filename = "$filename"}]]
set width [GuidoGetParamBufferValue $buffer width]
if {$width > 0} {
$width_px setCurrentValue $width
} else {
$width_px setCurrentValue ""
}
set height [GuidoGetParamBufferValue $buffer width]
if {$height > 0} {
$height_px setCurrentValue $height
} else {
$height_px setCurrentValue ""
}
}
GuidoForm frm00872 {
-default_buttons
-label "Image Element Properties"
-tip 00868_TIP
GuidoField xpos {
-decimals 2
-default 0
-display_length 6
-format double
-label "X position (lower left)"
-max_length 10
-null false
-tip 00868_TIP_1
-translate upper
}
GuidoField ypos {
-decimals 2
-default 0
-display_length 6
-format double
-label "Y position (lower left)"
-max_length 10
-null false
-tip 00868_TIP_2
-translate upper
}
GuidoFiller frm00704_8 {
-height 1
}
GuidoFiller frm00704_9 {
-height 1
}
GuidoField width {
-decimals 2
-default 0
-display_length 6
-format double
-label "Width (mm)"
-max_length 10
-null false
-tip 00868_TIP_3
-translate upper
}
GuidoField height {
-decimals 2
-default 0
-display_length 6
-format double
-label "Height (mm)"
-max_length 10
-null false
-tip 00868_TIP_4
-translate upper
}
GuidoLabel ratio_label {
-label "Aspect ratio:"
}
GuidoLabel ratio {
}
GuidoFiller frm00704_8 {
-height 1
}
GuidoFiller frm00704_9 {
-height 1
}
GuidoCheckBox maintain {
-label "Maintain aspect ratio:"
-default false
}
GuidoFileBrowserField file_name {
-absolutePath true
-display_length 12
-file_mask "*.gif *.jpg *.jpeg *.tif *.bmp *.png"
-format none
-label "Image file"
-max_length 256
-null false
-tip IMAGE_SELECT_TIP
-translate none
}
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]}
}
GuidoFiller frm00704_8 {
-height 1
}
GuidoFiller frm00704_9 {
-height 1
}
GuidoField priority {
-default 1
-display_length 5
-format integer
-high_bound 125
-label Priority
-low_bound 0
-max_length 10
-null false
-tip 00868_TIP_5
-translate none
}
$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]}
$file_name setActionCallback initial {[setDimensions $file_name $width_px $height_px]}
$file_name setActionCallback valueChanged {[setDimensions $file_name $width_px $height_px]}
$file_name setActionCallback valueChanged {[setRatio $maintain $ratio_px $width_px $height_px $ratio_px 0]}
}
