OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [libgui/] [library/] [bbox.tcl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# bbox.tcl - Function for handling button box.
2
# Copyright (C) 1997 Cygnus Solutions.
3
# Written by Tom Tromey <tromey@cygnus.com>.
4
 
5
# Pass this proc a frame whose children are all buttons.  It will put
6
# the children into the frame so that they look right on the current
7
# platform.  On Windows this means that they are all the same width
8
# and have a uniform separation.  (And currently on Unix it means this
9
# same thing, though that might change.)
10
proc standard_button_box {frame {horizontal 1}} {
11
  # This is half the separation we want between the buttons.  This
12
  # number comes from the Windows UI "standards" manual.
13
  set half_gap 2
14
 
15
  set width 0
16
  foreach button [winfo children $frame] {
17
    set bw [winfo reqwidth $button]
18
    if {$bw > $width} then {
19
      set width $bw
20
    }
21
  }
22
 
23
  incr width $half_gap
24
  incr width $half_gap
25
 
26
  if {$horizontal} then {
27
    set i 1
28
  } else {
29
    set i 0
30
  }
31
  foreach button [winfo children $frame] {
32
    if {$horizontal} then {
33
      # We set the size via the grid, and not -width on the button.
34
      # Why?  Because in Tk -width has different units depending on the
35
      # contents of the button.  And worse, the font units don't really
36
      # make sense when dealing with a proportional font.
37
      grid $button -row 0 -column $i -sticky ew \
38
        -padx $half_gap -pady $half_gap
39
      grid columnconfigure $frame $i -weight 0 -minsize $width
40
    } else {
41
      grid $button -column 0 -row $i -sticky new \
42
        -padx $half_gap -pady $half_gap
43
      grid rowconfigure $frame $i -weight 0
44
    }
45
    incr i
46
  }
47
 
48
  if {$horizontal} then {
49
    # Make the empty column 0 suck up all the space.
50
    grid columnconfigure $frame 0 -weight 1
51
  } else {
52
    grid columnconfigure $frame 0 -minsize $width
53
    # Make the last row suck up all the space.
54
    incr i -1
55
    grid rowconfigure $frame $i -weight 1
56
  }
57
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.