#!/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 {Resizeth -- Resize widgets interactively.

This program is useful for interactively resizing widgets using either keyboard
commands or menus. It resizes widgets by modifying their configuration options.
Of course, you can modify their configuration options with Configureth, but this
program provides a uniform means of expanding or shirnking widgets' horizontal
or vertical dimensions.

This program teaches remote widgets to shrink or expand themselves horizontally
or vertically by a certain number of units. Some widgets use pixels as the
units, and some use characters, and some can use either, depending on their
configuration. You can adjust the units, either characters or pixels that
widgets should use to resize themselves. Some widgets cannot be adjusted in
either or both dimensions; resizeth knows how to resize each widget, and only
provides bindings for the options each widget permits.

} $TH_Bindings_Help {

Widgets of Resizeth

The Increment Scales

These four scales adjust the increment values for resizing commands. For
example, if you shrink an Entry widget horizontally, that widget gets shrunk by
a certain number of characters, which is shown on the 'Horizontal Characters'
scale. If you teach an Entry widget how to resize, it will learn the value of
the Horizontal Character scale for when it gets interactively resized. You can
specify the initial values of the scales as command-line parameters.

} $TH_Teach_Bind_Help {

Resizeth changes widget sizes by changing configuration options in each widget.
This may be one of: length, width, height. If the widget's actual size is not
determined by the size specified by its configuration option, it will not be
visibly changed. For example, a widget that is expanded to fill the entire
horizontal width of a window will not appear to be affected by horizontal
resizing commands, until the -width configuration option becomes greater than
its actual size, in which case the window will expand to accomodate the larger
widget.

Using your window manager to interactively resize the toplevel window may
eliminate resizeth's effect on that window's widgets.

Many widgets have special behavior when given a horizontal or vertical size of
0. For example, labels, buttons, and entries when given a width or height of 0
allocate just enough width or height to store the text or bitmap they may
contain. So if you expand a label that looks the 'right' size, it may actually
shrink the first time, and if you then shrink that label, it will pop back to
it's regular size.

Although frame and toplevel widgets have width and height options to them,
resizeth cannot change their shape; use your window manager's interactive
resizing facility to change their size.}


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

# For a widget, returns the appropriate bindings. (They will depend on the
# class of the widget, and maybe some configuration options.)
proc widget_bindings {} {
  global Bindings Inc
  set bindings $Bindings(Resize)
  foreach pair [list "%ICX $Inc(Horizontal,Chars)" "%ICY $Inc(Vertical,Chars)" "%IPX $Inc(Horizontal,Pixels)" "%IPY $Inc(Vertical,Pixels)"] {
    set bindings [regexp_replace $bindings [lindex $pair 0] [lindex $pair 1]]
  }
  return $bindings
}


label .l -text "Increment Values" ; pack .l -fill x -side top
foreach frame {.inch .incv} {
  frame $frame ; pack $frame -side left -fill x -expand yes
  if {$frame == ".inch"} {set type "Horizontal"} else {set type "Vertical"}
  label $frame.l -text $type ; pack $frame.l -side top -fill x
  create_form_scale $frame.sc "Characters" Inc($type,Chars) 1 -from 1 -to 25
  create_form_scale $frame.sp "Pixels" Inc($type,Pixels) 20 -from 1 -to 250
}
