#!/afs/ece/usr/tcl/bin/wish -f
# The next line is executed by most shells, but not Tcl \
wish $0 $*


set Bind_Keyword [file tail [info script]]
source "[file dirname [info script]]/../aux/teach_bind.tcl"


# Help text.
set Help "" ; append Help {Windowth -- Move and resize windows through keyboard and menus

This program is useful for interactively resizing windows using either keyboard
commands or menus. It can resize or move windows by modifying their 'wm
geometry' options. It can also iconify or raise a window. If the window is
gridded, it automatically resizes it by increments of 1 grid unit, otherwise,
the window is resized by a user-defined increment value, measured in pixels.

} $TH_Bindings_Help {

Widgets of Windowth

The Increment Scales

These scales adjust the increment values for resizing and moving commands. Both
values are in units of pixels.

} $TH_Teach_Bind_Help {

The window resize bindings taught here clash with the resize bindings taught by
resizeth. This means that a widget cannot have both window resizing and widget
resizing as menu options, and it cannot have both as keybinding options. (You
can always change the bindings if you want both windowth and resizeth options on
one particular widget.) This falls somewhere in that void between 'bug' and
'feature'. If a widget remains unaffected by the widget resize commands, you can
teach it window resize commands which will resize the widget (along with the
other widgets in the window). If you want a widget to learn window movement,
iconify, raise along with widget resize, teach it windowth's code before
resizeth's code. This way resizeth's widget resize bindings overwrite windowth's
window resize bindings.}


# Gives app all the code necessary to do our functions.
proc teach_code {} {include_files {window.tcl th_geometry_change}}

# For a widget, returns the appropriate bindings. (They will depend on the
# toplevel window.)
proc widget_bindings {} {
  global App Widget 
  set tl [send $App winfo toplevel $Widget]
  global Bindings Inc_X Inc_Y
  set bindings [regexp_replace $Bindings(Window) %IMX $Inc_X]
  set bindings [regexp_replace $bindings %IMY $Inc_Y]
  if {[send $App wm grid $tl] != ""} {set ix 1 ; set iy 1
  } else {set ix $Inc_X ; set iy $Inc_Y}
  set bindings [regexp_replace $bindings %IRX $ix]
  set bindings [regexp_replace $bindings %IRY $iy]
  return $bindings
}


label .winl -text "Increment Pixel Values" ; pack .winl -fill x
create_form_scale .winsx "Horizontal" Inc_X 20 -from 1 -to 250
create_form_scale .winsy "Vertical" Inc_Y 20 -from 1 -to 250
foreach w {.winsx .winsy} {pack $w -side left -expand yes}
