home *** CD-ROM | disk | FTP | other *** search
- # SpecTcl, by S. A. Uhler
- # Copyright (c) 1994-1995 Sun Microsystems, Inc.
- #
- # See the file "license.txt" for information on usage and redistribution
- # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- #
- # system wide bindings
-
- # palette bindings for "look" - the're almost buttons
- bind palette <Enter> "%W configure -bg #ececec"
- bind palette <Leave> "%W configure -bg #d9d9d9"
- bind palette <ButtonRelease-1> "%W configure -relief raised"
-
- # set binding to propagate geometry changes
- # There are far too many configure events, so this is too slow
- # Instead, I should go back to the *old way*, and kick off the updates
- # when I know they are needed
-
- set Down 0
- bind widget <Configure> {
- if {$Arrow_move} continue
- if {$Down} continue
- dputs "widget %W configure"
- check_update %W
- }
-
- # new palette behaviour - open option sheet only on double click
-
- bind palette <Double-$P(button)> {
- activate_generic [%W cget -text]
- }
- proc activate_generic {widget} {
- global _Message Geometry Current
- set _Message "fetching generic $widget options ..."
- update idletasks
- wm title .generic "Generic $widget"
- .generic.msg configure -text "- $widget configuration -" \
- -textvariable sample_${widget}(error) -fg red
- widget_extract .sample_$widget sample_$widget
- form_build .generic.form sample_$widget
- if {![winfo ismapped .generic]} {
- parray Geometry
- wm deiconify .generic
- catch {wm geometry .generic $Geometry(generic)}
- }
- raise .generic
- set Current(sample) .palette.$widget
- set _Message ""
- }
-
- # new option sheet behaviour - double click on a widget to bring up
-
- bind widget <Double-$P(button)> {
- activate_option %W
- }
- proc activate_option {win} {
- global Current _Message Geometry
- set class [winfo class $win]
- set name [winfo name $win]
- upvar #0 $name data
- set _Message "fetching $class $data(item_name) options ..."
- update idletasks
- wm title .widget "$class options"
- .widget.msg configure -text "- $class configuration -" \
- -textvariable ${name}(error) -fg red
- form_build .widget.form $name
- if {![winfo ismapped .widget]} {
- catch {wm geometry .widget $Geometry(widget)}
- wm deiconify .widget
- }
- set Current(form) $win
- set _Message ""
- raise .widget
- }
-
- # "deselect" when button press outside active region
-
- bind .can <$P(button)> {
- unselect_widget
- current_frame .can.f
- arrow_unhighlight row
- arrow_unhighlight column
- }
-
- # select row&col when clicking in an empty grid
-
- bind .can.f <$P(button)> {current_frame %W;select_rowcol %x %y}
-
- # given an x,y position on the current grid, select the row/column
-
- proc select_rowcol {x y} {
- global Current
-
- unselect_widget
- arrow_unhighlight row
- arrow_unhighlight column
- set row [blt_table row $Current(frame) location $y]
- set col [blt_table column $Current(frame) location $x]
- arrow_highlight row $Current(frame) $row red
- arrow_highlight column $Current(frame) $col red
- }
-
- # Insert a new row/column for button press on a grid line
-
- bind grid <$P(button)> {grid_insert %W}
-
- # highlight a grid line, for easier identification
-
- bind grid <Enter> {
- set Save_grid_color [%W cget -bg]
- %W configure -bg $P(grid_highlight)
- }
- bind grid <Leave> {
- %W configure -bg $Save_grid_color
- }
-
- # when a frame background changes color, make sure its grid
- # changes too (This still needs work)
-
- bind frame <Configure> {
- # if {$Arrow_move} continue
- if {$Down} continue
- dputs "frame %W configure"
- set color [%W cget -bg]
- if {"%W" == $Current(frame)} {
- set color [Contrast_color $color]
- }
- if {[grid_color %W $color]} {
- # puts "need to change outline colors for %W"
- outline_color %W
- }
- }
-
- # The "delete" key deletes the current what-ever
-
- bind . <Delete> {delete_selected}
-
- # short cut for repeating toolbar action for current widget
- # (moved to menu bar)
- set Current(repeat) ""
-
- # Short cut for selecting containing frame
-
- bind . <KeyPress-Up> Key_up
- proc Key_up {} {
- global Current
-
- if {[set widget $Current(widget)] != ""} {
- upvar #0 [winfo name $widget] data
- set master .can.f$data(master)
- if {$master != ".can.f"} {
- unselect_widget
- select_widget $master
- }
- }
- }
-
- # short cut for going "inside of a frame" (gulp)
-
- bind . <KeyPress-Down> Key_down
- proc Key_down {} {
- global Current _Message Frames
-
- if {[info exists Frames($Current(widget))]} {
- current_frame $Current(widget)
- set _Message "Entering sub frame"
- set widgets [blt_table slaves $Current(widget) -exclude "*@*"]
- if {[llength $widgets] > 0} {
- unselect_widget
- select_widget [lindex [lsort -command sort_widgets $widgets] 0]
- }
- }
- }
-
- # temporary short cut for inserting row or column onto the current frame
-
- proc grid_add {master what {index 2}} {
- table_insert $master $what $index
- grid_process $master $what 1
- update_table $master "insert $what $index"
- }
-
- # short cut for option forms
- bind all <Alt-KeyPress> {
- if {![access_field %A]} {
- tkTraverseToMenu %W %A
- }
- }
-
- # Try to clean up on window manager destroy
- # The app will automatically exit at the next idle time
- # rename "update" to make sure everything is clean up before then
-
- wm protocol . WM_DELETE_WINDOW {
- proc update {args} {}
- quit 0
- exit
- }
-
- bind . <Control-R> {grid_add $Current(frame) row}
- bind . <Control-C> {grid_add $Current(frame) column}
-
-