home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / tcl / 2311 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  2.9 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!news-is-not-mail
  2. From: capo@cs.utexas.edu (Charles Read)
  3. Newsgroups: comp.lang.tcl
  4. Subject: tricky problem with "place" command
  5. Date: 7 Jan 1993 11:26:23 -0600
  6. Organization: CS Dept, University of Texas at Austin
  7. Lines: 83
  8. Message-ID: <1ihp3vINNis9@im4u.cs.utexas.edu>
  9. NNTP-Posting-Host: im4u.cs.utexas.edu
  10. Keywords: placer, geometry manager
  11.  
  12.   The code below packs two frames (vertically) inside
  13. a toplevel window. The top frame contains a menu.
  14. The bottom frame contains a pair of scrollbars.
  15.   When the toplevel window is resized, the scrollbars
  16. should be proportionately resized. That's why I use
  17. the "place" command. The problem is that the bottom
  18. frame always tries to fill the whole toplevel window
  19. when it should really fill just the whole area BELOW
  20. the menubar.
  21.   If you have clues how to fix this, please let me know.
  22. -c
  23. ---------------------------cut here-------------------------
  24. #!/usr/local/bin/wish -f
  25. proc sdmCreateMenu {w} {
  26.   # Create and pack the menu.
  27.   frame $w.menu -relief flat -borderwidth 1
  28.   pack append $w $w.menu {top fillx}
  29.  
  30.   # File menu.
  31.   menubutton $w.menu.file -text "File" -menu $w.menu.file.m
  32.   menu $w.menu.file.m
  33.   $w.menu.file.m add command -label "Quit" -command exit
  34.   
  35.   # Props menu.
  36.   menubutton $w.menu.props -text "Props" -menu $w.menu.props.m
  37.   menu $w.menu.props.m
  38.   $w.menu.props.m add command -label "Test1" -command "echo Test1"
  39.   $w.menu.props.m add command -label "Test2" -command "echo Test2"
  40.  
  41.   # Styles menu.
  42.   menubutton $w.menu.styles -text "Styles" -menu $w.menu.styles.m
  43.   menu $w.menu.styles.m
  44.   $w.menu.styles.m add command -label "Points" -command "echo Unsupported"
  45.   $w.menu.styles.m add command -label "Lines" -command "echo Unsupported"
  46.  
  47.   # Pack all the menus
  48.   pack append $w.menu \
  49.     $w.menu.file left \
  50.     $w.menu.props left \
  51.     $w.menu.styles left
  52. }
  53.  
  54. wm withdraw .
  55.  
  56. set bx 32
  57. set by 32
  58. set bh 286
  59. set bw 186
  60. set w .zot
  61. set cwidth 350
  62. set cheight 250
  63. toplevel $w
  64.  
  65. # Create and pack the menu.
  66. frame $w.menu -relief flat -borderwidth 1
  67. pack append $w $w.menu {top fillx}
  68. sdmCreateMenu $w.menu
  69.  
  70. # this specifies a minimum size AND allows for resizing.
  71. wm minsize $w $cwidth $cheight
  72.     
  73. # Make a frame and canvas for the new window.
  74. frame $w.frame -relief flat -bd 2
  75. pack append $w $w.frame {top expand}
  76. canvas $w.frame.c -relief flat -width $cwidth -height $cheight
  77.  
  78. # Let the "placer" handle size-tracking for the canvas and scrollbars.
  79. place $w.frame -relwidth 1.0 -relheight 1.0
  80. # place $w.frame -in $w.menu -relx 0.0 -rely 0.0 -anchor nw
  81.  
  82. scrollbar $w.frame.hscroll -orient horiz -relief sunken \
  83.   -width 12
  84. $w.frame.hscroll set $bw $bw 0 [expr $bw-1]
  85. pack append $w.frame $w.frame.hscroll {bottom fillx}
  86.  
  87. scrollbar $w.frame.vscroll -orient vert -relief sunken \
  88.   -width 12
  89. $w.frame.vscroll set $bh $bh 0 [expr $bh-1]
  90. pack append $w.frame $w.frame.vscroll {right filly}
  91.  
  92. # pack canvas
  93. pack append $w.frame $w.frame.c {expand fill}
  94.  
  95.