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.
- #
- # main program for SpecTcl UI builder (sau 12/94)
- # Updated ui using SpecTcl generated panel (10/95)
- # Same, but with new ui
-
- # check for proper versions of TK and blt_table
-
-
- catch {blt_table} ;# force autoloading
- if {[info commands blt_table] == ""} {
- tk_dialog .exit "Version Error" \
- "SpecTcl requires the \"blt_table\" geometry manager" \
- error 0 OK
- exit
- }
-
- # check for SpecTcl's blt_extension
-
- frame .1
- frame .1.2
- blt_table .1 .1.2 0,0
- if {[catch {blt_table row .1 location 0}]} {
- tk_dialog .exit "Version Error" \
- "This version of blt_table is too old, and does ot have the \
- \"location\" extension" \
- error 0 OK
- exit 0
- }
- destroy .1
-
- # set some configuration parameters
-
- if {[info exists env(SPECTCL_DIR)]} {
- set Base_dir $env(SPECTCL_DIR)
- } else {
- set Base_dir [file dir $argv0]
- }
- if {[info exists env(SPECTCL_HELP)]} {
- set Help_dir $env(SPECTCL_HELP)
- } else {
- set Help_dir $Base_dir/help
- }
-
- if {![info exists P]} {
- source $Base_dir/preferences.tk
- }
-
- wm geometry . {}
- wm minsize . 50 50
- tk appname SpecTcl
- wm iconbitmap . @$Base_dir/icon.xbm
- wm iconmask . @$Base_dir/icon.xbm
-
- # debugging - make sure we can resource everything
- eval "destroy [winfo children .]"
- catch "unset [info globals sample_*] [info globals *#*] [info globals geom:*]"
- foreach i [array names Widgets] {
- global $i; catch {unset $i}
- }
- foreach i {f Adjust Current Widgets Update_Scheduled Frames Undo_log} {
- catch {unset $i}
- }
- proc ? {} {global errorInfo; puts $errorInfo}
- if {$P(debug)} {
- proc debug {args} {
- global debug
- set debug [concat $args]
- }
- } else {
- proc debug {args} {
- }
- }
-
- # load in all of the procedures
-
- source $Base_dir/trace.tcl ;# simple variable tracing facility
- source $Base_dir/init.tk ;# global variable initialization
- source $Base_dir/configure.tk ;# TK generic widget configuration information
- source $Base_dir/forms.tk ;# option entry management
- source $Base_dir/filters.tk ;# data filters for option values
- source $Base_dir/extract.tk ;# widget option extraction and validation
- source $Base_dir/grid.tk ;# The grid manipulation stuff
- source $Base_dir/subs.tk ;# misc stuff that will end up elsewhere
- source $Base_dir/button_bind.tk ;# generic button binding stuff
- source $Base_dir/button.tk ;# specific binding behavior
- source $Base_dir/highlight.tk ;# handle highlighting
- source $Base_dir/table_subs.tk ;# manage table info
- source $Base_dir/outline.tk ;# manage widget outlines
- source $Base_dir/arrow.tk ;# manage the row and column indicators "arrows"
- source $Base_dir/save.tk ;# save/load project from disk
- source $Base_dir/help.tk ;# preliminary help stuff
- source $Base_dir/anchor.tk ;# anchor selection
- source $Base_dir/fill.tk ;# fill selection
- source $Base_dir/just.tk ;# justify selection
- source $Base_dir/colors.tk ;# color selection placeholder
- source $Base_dir/relief.tk ;# relief management
- source $Base_dir/font_size.tk ;# font size selection
- source $Base_dir/toolbar.tk ;# toobar management routines
- source $Base_dir/resize.tk ;# row and column resize behavior
- source $Base_dir/undo.tk ;# The undo system (not operational)
- source $Base_dir/compile.tk ;# temporary script compiler
- source $Base_dir/scroll.tk ;# auto scrollbar attachment code
- source $Base_dir/menu.tk ;# code to support menu bar
- source $Base_dir/html_lib.tcl ;# html help library
- source $Base_dir/html.tcl ;# html help library helpers
- source $Base_dir/about_xbm.tcl ;# About box bitmaps
- source $Base_dir/about.tk ;# About box animation
-
- # These are generated automatically by SpecTcl
-
- source $Base_dir/spectcl.ui.tcl ;# main ui
- source $Base_dir/open.ui.tcl ;# "open" dialog box
- source $Base_dir/save.ui.tcl ;# "save" dialog box"
- source $Base_dir/edit.ui.tcl ;# "edit code" widget
- source $Base_dir/colors.ui.tcl ;# color editor
- source $Base_dir/help.ui.tcl ;# html help system
-
- # This is generated automatically by the menu edittor
-
- source $Base_dir/menubar.menu.tcl ;# menu bar from menu editor
-
- # read in the "rc" file, if any
-
- catch {source $env(HOME)/.SpecTclrc}
-
- # create the top-level interface
- spectcl_ui .
- menubar_menu .menu
-
- # The menu editor doesn't support this directly
- [menubar_getmenuname .menu "Show grid"] entryconfigure "Show grid" \
- -onvalue $P(grid_size)
- set Grid 3
- test_help $P(help) ;# turn on simple field help
-
- # build the widget scaffolding
-
- set parent .can.f ;# all widgets are children of this guy
- frame $parent -bg $P(frame_bg) ;# window to pack widgets into
- .can create window 0 0 -anchor nw -window $parent
- frame $parent.marker ;# stacking order marker - below all buttons
- set Current(frame) $parent
- set Current(project) $P(project)
- set Current(dirty) ""
- set_title $Current(project)
-
- # draw the grid lines, they go in ODD numbered rows and columns
-
- grid_create $parent $P(maxrows) $P(maxcols) $P(grid_size) $P(grid_color)
-
- # make the row and column arrows
-
- set Frames($parent) 1
- table_setup $parent
- current_frame $parent
- arrow_create .can_row row $parent all
- arrow_create .can_column column $parent all
- arrow_activate .can $parent $P(grid_color)
-
- # initialize the toolbar
-
- create_toolbar .toolbar
- blt_table column .toolbar configure all -resize none
- blt_table column .toolbar configure 20 -resize both
-
- # setup the generic and widget option forms
-
- build_option_form .generic
- build_option_form .widget
-
- # initialize the button binding dispatcher
-
- button_setup . palette_action palette $P(button) $P(gravity)
- button_setup . widget widget $P(button) $P(gravity)
- button_setup . resize resize $P(button) $P(gravity)
- button_setup . sub_widget widget $P(button) $P(gravity) {[winfo parent %W] %X %Y}
-
- # build the widget palette and sample widgets
-
- set _Message "Gathering configuration information"
- set widgets [configure_widget_data Widget_data ._check_ widget_progress]
- set row 0
- foreach widget [lsort $widgets] {
- label .palette.$widget -text $widget \
- -anchor w -relief raised -bd 2 -pady 1 -padx 2 ;# -bg #FDE
- bindtags .palette.$widget {palette palette_action all}
- blt_table .palette .palette.$widget $row,0 -fill x
-
- # make a "sample" widget for configuration
-
- $widget .sample_$widget
- catch {.sample_$widget configure -text $widget}
- catch {.sample_$widget configure -label $widget}
- set Next_widget($widget) 0
- incr row
- }
- blt_table row .palette configure all -pady 1 -resize none
- blt_table column .palette configure all -padx 1
- blt_table row .palette configure $row -resize both
-
- # some more data setup
-
- configure_geometry_data Widget_data ._check_
- install_filters ;# associate data filters with widget items
- install_renames ;# rename some of the tk options
- install_advanced ;# these are the "advanced" options
- ignore_items ;# set "hidden" field names for forms
- scrollregion_update $parent
- update_table $parent Init
-
- # special case stuff for "top level" that is automatic for other frames
- widget_extract .can.f
- set_master .can.f .can.f
- set f(type) frame
-
- source $Base_dir/bind.tk ;# global bindings
-
- # see if project is specified on the command line
-
- set _Message "Key \"Help\" for SpecTcl help"
- if {$argc > 0} {
- set project [lindex $argv 0]
- if {![string match *.$P(file_suffix) $project]} {
- append project .$P(file_suffix)
- }
- load_project $project
- }
-