makeConstraintDialog

$canvaseditor makeConstraintDialog
creates dialog window for constraint of selected object.

These constraints are realized:

noprint
suppress printing of object if used for internal purposes only
size
suppress scaling
orient
suppress rotating
shear
suppress shearing horizontal, vertical, but not diagonal
fillcolor
fix color of fill objects
linecolor
fix color of line objects
linewidth
fix width of line objects
gravity
preferring objecs for some purposes

obj method canvaseditor makeConstraintDialog {} {
  set elements [my selection]
  if {[llength $elements] != 1} then {
    return -code error {Select exactly one element, please.}
  }
  lassign $elements obj
  set var [namespace current]::constraint
  catch {unset $var}
  catch {array unset $var}
  #
  destroy [my canvas].constraint
  set dialog [toplevel [my canvas].constraint]
  wm transient $dialog [my canvas]
  wm resizable $dialog no no
  #
  $self basicBindings no
  #
  foreach constraint {
    noprint size orient shear gravity fillcolor linecolor linewidth
  } {
    set [set var]($constraint) [$obj constraint $constraint]
    ::pack [checkbutton $dialog.$constraint\
      -text [string totitle $constraint]\
      -variable [set var]($constraint)\
      -command "$obj constraint $constraint toggle"\
      -width 18 -anchor nw -onvalue yes -offvalue no]
  }
  set before [list $obj configure -constraint [$obj cget -constraint]]
  frame $dialog.finish
  bind $dialog.finish <Destroy> [subst -nocommand {
      $self basicBindings
      $self initUndoRedo [list $before]\
        "$obj configure -constraint [list [$obj cget -constraint]]"
  }]
}

© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z