# Dialogshell # ---------------------------------------------------------------------- # This class is implements a dialog shell which is a top level widget # composed of a button box, separator, and child site area. The class # also has methods to control button construction. # # ---------------------------------------------------------------------- # AUTHOR: Mark L. Ulferts EMAIL: mulferts@spd.dsccc.com # # @(#) $Id: dialogshell.itk,v 1.3 2006/09/11 20:35:54 irby Exp $ # ---------------------------------------------------------------------- # Copyright (c) 1995 DSC Technologies Corporation # ====================================================================== # Permission to use, copy, modify, distribute and license this software # and its documentation for any purpose, and without fee or written # agreement with DSC, is hereby granted, provided that the above copyright # notice appears in all copies and that both the copyright notice and # warranty disclaimer below appear in supporting documentation, and that # the names of DSC Technologies Corporation or DSC Communications # Corporation not be used in advertising or publicity pertaining to the # software without specific, written prior permission. # # DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON- # INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE # AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL # DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR # ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE. # ====================================================================== # # Default resources, # option add *Dialogshell.thickness 3 widgetDefault option add *Dialogshell.buttonBoxPos s widgetDefault option add *Dialogshell.modality none widgetDefault option add *Dialogshell.separator on widgetDefault option add *Dialogshell.padX 10 widgetDefault option add *Dialogshell.padY 10 widgetDefault option add *Dialogshell.master "." widgetDefault # # Usual options. # itk::usual Dialogshell { keep -background -cursor -foreground -modality } # ------------------------------------------------------------------ # DIALOGSHELL # ------------------------------------------------------------------ class iwidgets::Dialogshell { inherit iwidgets::Shell constructor {args} {} itk_option define -thickness thickness Thickness 3 itk_option define -buttonboxpos buttonBoxPos Position s itk_option define -separator separator Separator on itk_option define -padx padX Pad 10 itk_option define -pady padY Pad 10 public method childsite {} public method index {args} public method add {args} public method insert {args} public method delete {args} public method hide {args} public method show {args} public method default {args} public method invoke {args} public method buttonconfigure {args} } # # Provide a lowercased access method for the Dialogshell class. # proc ::iwidgets::dialogshell {pathName args} { uplevel ::iwidgets::Dialogshell $pathName $args } # ------------------------------------------------------------------ # CONSTRUCTOR # ------------------------------------------------------------------ body iwidgets::Dialogshell::constructor {args} { itk_option remove iwidgets::Shell::padx iwidgets::Shell::pady # # Create the user child site, separator, and button box, # itk_component add dschildsite { frame $itk_interior.dschildsite } { keep -background -cursor } pack $itk_component(dschildsite) -fill both -expand yes itk_component add separator { frame $itk_interior.separator -relief sunken } { keep -background -cursor } pack $itk_component(separator) -expand no itk_component add bbox { iwidgets::Buttonbox $itk_interior.bbox } { keep -background -cursor -foreground rename -padx -buttonboxpadx buttonBoxPadX Pad rename -pady -buttonboxpady buttonBoxPadY Pad } pack $itk_component(bbox) -expand no # # Set the itk_interior variable to be the childsite for derived # classes. # set itk_interior $itk_component(dschildsite) # # Set up the default button so that if is pressed in # any widget, it will invoke the default button. # bind $itk_component(hull) [code $this invoke] # # Explicitly handle configs that may have been ignored earlier. # eval itk_initialize $args } # ------------------------------------------------------------------ # OPTIONS # ------------------------------------------------------------------ # ------------------------------------------------------------------ # OPTION: -thickness # # Specifies the thickness of the separator. It sets the width and # height of the separator to the thickness value and the borderwidth # to half the thickness. # ------------------------------------------------------------------ configbody iwidgets::Dialogshell::thickness { $itk_component(separator) config -height $itk_option(-thickness) $itk_component(separator) config -width $itk_option(-thickness) $itk_component(separator) config \ -borderwidth [expr $itk_option(-thickness) / 2] } # ------------------------------------------------------------------ # OPTION: -buttonboxpos # # Specifies the position of the button box relative to the child site. # The separator appears between the child site and button box. # ------------------------------------------------------------------ configbody iwidgets::Dialogshell::buttonboxpos { switch $itk_option(-buttonboxpos) { n { pack config $itk_component(dschildsite) -side top pack config $itk_component(separator) -side top \ -before $itk_component(dschildsite) -fill x $itk_component(bbox) configure -orient horizontal pack config $itk_component(bbox) -side top \ -before $itk_component(separator) -fill x } s { pack config $itk_component(dschildsite) -side top pack config $itk_component(separator) -side top \ -after $itk_component(dschildsite) -fill x $itk_component(bbox) configure -orient horizontal pack config $itk_component(bbox) -side top \ -after $itk_component(separator) -fill x } w { pack config $itk_component(dschildsite) -side left pack config $itk_component(separator) -side left \ -before $itk_component(dschildsite) -fill y $itk_component(bbox) configure -orient vertical pack config $itk_component(bbox) -side left \ -before $itk_component(separator) -fill y } e { pack config $itk_component(dschildsite) -side left pack config $itk_component(separator) -side left \ -after $itk_component(dschildsite) -fill y $itk_component(bbox) configure -orient vertical pack config $itk_component(bbox) -side left \ -after $itk_component(separator) -fill y } default { error "bad buttonboxpos option\ \"$itk_option(-buttonboxpos)\": should be n,\ s, e, or w" } } } # ------------------------------------------------------------------ # OPTION: -separator # # Boolean option indicating wheather to display the separator. # ------------------------------------------------------------------ configbody iwidgets::Dialogshell::separator { if {$itk_option(-separator)} { $itk_component(separator) configure -relief sunken } else { $itk_component(separator) configure -relief flat } } # ------------------------------------------------------------------ # OPTION: -padx # # Specifies a padding distance for the childsite in the X-direction. # ------------------------------------------------------------------ configbody iwidgets::Dialogshell::padx { pack config $itk_component(dschildsite) -padx $itk_option(-padx) } # ------------------------------------------------------------------ # OPTION: -pady # # Specifies a padding distance for the childsite in the Y-direction. # ------------------------------------------------------------------ configbody iwidgets::Dialogshell::pady { pack config $itk_component(dschildsite) -pady $itk_option(-pady) } # ------------------------------------------------------------------ # METHODS # ------------------------------------------------------------------ # ------------------------------------------------------------------ # METHOD: childsite # # Return the pathname of the user accessible area. # ------------------------------------------------------------------ body iwidgets::Dialogshell::childsite {} { return $itk_component(dschildsite) } # ------------------------------------------------------------------ # METHOD: index index # # Thin wrapper of Buttonbox's index method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::index {args} { uplevel $itk_component(bbox) index $args } # ------------------------------------------------------------------ # METHOD: add tag ?option value ...? # # Thin wrapper of Buttonbox's add method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::add {args} { uplevel $itk_component(bbox) add $args } # ------------------------------------------------------------------ # METHOD: insert index tag ?option value ...? # # Thin wrapper of Buttonbox's insert method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::insert {args} { uplevel $itk_component(bbox) insert $args } # ------------------------------------------------------------------ # METHOD: delete tag # # Thin wrapper of Buttonbox's delete method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::delete {args} { uplevel $itk_component(bbox) delete $args } # ------------------------------------------------------------------ # METHOD: hide index # # Thin wrapper of Buttonbox's hide method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::hide {args} { uplevel $itk_component(bbox) hide $args } # ------------------------------------------------------------------ # METHOD: show index # # Thin wrapper of Buttonbox's show method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::show {args} { uplevel $itk_component(bbox) show $args } # ------------------------------------------------------------------ # METHOD: default index # # Thin wrapper of Buttonbox's default method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::default {args} { uplevel $itk_component(bbox) default $args } # ------------------------------------------------------------------ # METHOD: invoke ?index? # # Thin wrapper of Buttonbox's invoke method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::invoke {args} { uplevel $itk_component(bbox) invoke $args } # ------------------------------------------------------------------ # METHOD: buttonconfigure index ?option? ?value option value ...? # # Thin wrapper of Buttonbox's buttonconfigure method. # ------------------------------------------------------------------ body iwidgets::Dialogshell::buttonconfigure {args} { uplevel $itk_component(bbox) buttonconfigure $args }