Annotation of capa/capa51/GUITools/utils.tcl, revision 1.1.1.1

1.1       albertel    1: #Utilities for Grader. Used for a fileselect dialogue 
                      2: #stolen from TkNet.
                      3: 
                      4: ###############################################################
                      5: # TkNet - Utilities Module
                      6: # Charlie KEMPSON - charlie@siren.demon.co.uk
                      7: # http://public.logica.com/~kempsonc/tknet.htm
                      8: # Version 1.1
                      9: ###############################################################
                     10: 
                     11: ###############################################################
                     12: #
                     13: #    Copyright (c) 1995-1996 Charlie Kempson
                     14: #
                     15: #    This program is free software; you can redistribute it 
                     16: #    and/or modify it under the terms of the GNU General 
                     17: #    Public License as published by the Free Software 
                     18: #    Foundation (version 2 of the License).
                     19: #
                     20: #    This program is distributed in the hope that it will 
                     21: #    be useful, but WITHOUT ANY WARRANTY; without even the 
                     22: #    implied warranty of MERCHANTABILITY or FITNESS FOR A 
                     23: #    PARTICULAR PURPOSE.  See the GNU General Public License 
                     24: #    for more details.
                     25: #
                     26: #    For a copy of the GNU General Public License, write to the 
                     27: #    Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
                     28: #    MA 02139, USA.
                     29: ###############################################################
                     30: ###############################################################
                     31: # Centre a window on the screen (or parent)
                     32: proc Centre_Dialog {window {position ""} {parent ""}} {
                     33: 
                     34:    # Withdraw dialog and update all windows
                     35:    wm withdraw $window
                     36:    update idletasks
                     37:    set win_width [winfo reqwidth $window]
                     38:    set win_height [winfo reqheight $window]
                     39: 
                     40:    # Read the positioning argument (pointer, widget, default)
                     41:    switch -glob -- $position {
                     42:       p* {
                     43:          # place at POINTER (centered is $a == center)
                     44:          wm geometry $window +[expr \
                     45:             [winfo pointerx $window]-$win_width \
                     46:             /2]+[expr [winfo pointery $window]-\
                     47:             $win_height/2]
                     48:       }
                     49:       w* {
                     50:          # center about WIDGET $parent
                     51:          wm geometry $window +[expr [winfo rootx $parent]+ \
                     52:             ([winfo width $parent]-$win_width)/2]+[expr \
                     53:             [winfo rooty $parent]+([winfo height \
                     54:             $parent]-$win_height)/2]
                     55:       }
                     56:       default {
                     57:          wm geometry $window +[expr ([winfo screenwidth \
                     58:             $window]-$win_width) / 2]+[expr ([winfo screenheight \
                     59:             $window]- $win_height) / 2]
                     60:       }
                     61:    }
                     62: 
                     63:    # Now show the window
                     64:    wm deiconify $window
                     65: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>