GridBagLayoutView.st
author Claus Gittinger <cg@exept.de>
Wed, 02 Nov 2016 14:41:11 +0100
changeset 5303 dc0252c294f5
parent 3673 31a56ced44b6
child 5634 9fb149cbc61e
permissions -rw-r--r--
#REFACTORING by cg class: GridBagLayoutView changed: #adjustForGravity:in:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
790
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     1
"
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     2
 COPYRIGHT (c) 1998 by Andreas Vogel / eXept Software AG
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     3
              All Rights Reserved
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     4
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     5
 This software is furnished under a license and may be used
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     6
 only in accordance with the terms of that license and with the
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     8
 be provided or otherwise made available to, or used by, any
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
     9
 other person.  No title to or ownership of the software is
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    10
 hereby transferred.
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    11
"
1877
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1519
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
3b415fa4710f only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents: 1519
diff changeset
    13
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
    14
"{ NameSpace: Smalltalk }"
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
    15
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
PanelView subclass:#GridBagLayoutView
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'columnWidths rowHeights columnWeights rowWeights layoutInfo'
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Views-Layout'
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!GridBagLayoutView class methodsFor:'documentation'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
790
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    25
copyright
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    26
"
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    27
 COPYRIGHT (c) 1998 by Andreas Vogel / eXept Software AG
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    28
              All Rights Reserved
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    29
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    30
 This software is furnished under a license and may be used
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    31
 only in accordance with the terms of that license and with the
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    33
 be provided or otherwise made available to, or used by, any
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    34
 other person.  No title to or ownership of the software is
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    35
 hereby transferred.
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    36
"
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    37
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    38
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    39
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    40
!
da146a1929ae added copyright
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    41
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
documentation
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
GridBagLayout is a flexible layout manager that aligns components vertically and horizontally,
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
without requiring that the components be the same size. Each GridBagLayout uses a dynamic rectangular 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
grid of cells, with each component occupying one or more cells (called its display area).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
Each component managed by a GridBagLayout is associated with a GridBagConstraints instance that 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
specifies how the component is laid out within its display area. How a GridBagLayout places a set of 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
components depends on each component's GridBagConstraints and minimum size, as well as the preferred 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
size of the components' container.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
To use a GridBagLayout effectively, you must customize one or more of its components' GridBagConstraints.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
You customize a GridBagConstraints object by setting one or more of its instance variables:
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    gridX
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    gridY
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
		Specifies the cell at the upper left of the component's display area, where the 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
		upper-left-most cell has address gridX=0, gridY=0. Use #RELATIVE (the default value)
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
		to specify that the component be just placed just to the right of (for gridX)
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
		or just below (for gridY) the component that was added to the container just before 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
		this component was added.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    gridWidth
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    gridHeight
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
		Specifies the number of cells in a row (for gridWidth) or column (for gridHeight)
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
		in the component's display area. The default value is 1. Use #REMAINDER to specify
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
		that the component be the last one in its row (for gridWidth) or column (for gridHeight).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
		Use #RELATIVE to specify that the component be the next to last one in its row 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
		(for gridWidth) or column (for gridHeight).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    fill
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
		Used when the component's display area is larger than the component's requested size
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
		to determine whether (and how) to resize the component.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
		Valid values are
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
		    #NONE
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
			(the default),
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
		    #HORIZONTAL
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
			(make the component wide enough to fill its display area
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
			horizontally, but don't change its height),
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
		    #VERTICAL
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
			(make the component tall enough to fill its display area
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
			vertically, but don't change its width), and
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
		    #BOTH       
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
			(make the component fill its display area entirely).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    ipadX
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    ipadY
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
		Specifies the internal padding: how much to add to the minimum size of the component.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
		The width of the component will be at least its minimum width plus ipadX*2 pixels
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
		(since the padding applies to both sides of the component). Similarly, the height of 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
		the component will be at least the minimum height plus ipadY*2 pixels.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    insets
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
		Specifies the external padding of the component -- the minimum amount of space between 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
		the component and the edges of its display area.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    anchor
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
		Used when the component is smaller than its display area to determine where (within the area) 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
		to place the component.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
		Valid values are
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
			#CENTER (the default),
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
			#NORTH,
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
			#NORTHEAST,
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
			#EAST,
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
			#SOUTHEAST,
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
			#SOUTH,
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
			#SOUTHWEST,
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
			#WEST, 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
			#NORTHWEST.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    weightX
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    weightY
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
		Used to determine how to distribute space; this is important for specifying resizing 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
		behavior. Unless you specify a weight for at least one component in a row (weightX)
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
		and column (weightY), all the components clump together in the center of their container.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
		This is because when the weight is zero (the default), the GridBagLayout puts any extra 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
		space between its grid of cells and the edges of the container.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    [see also:]
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
	GridBagConstraints
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
	GridBagLayoutInfo
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
	Insets
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    [author:]
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
	Andreas Vogel
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
examples
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    This example is taken from the java source and should produce the same layout. Check the file
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    Grid*.gif in the java distribution.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
									[exBegin]
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
	| v p c |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
	c := #(
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
	    #( fill: #BOTH weightX: 1.0 )                         
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
	    #( fill: #BOTH weightX: 1.0 )                         
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
	    #( fill: #BOTH weightX: 1.0 )                         
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
	    #( fill: #BOTH weightX: 1.0 gridWidth: #REMAINDER ) 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
	    #( fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
	    #( fill: #BOTH gridWidth: #RELATIVE )                 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
	    #( fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
	    #( fill: #BOTH weightY: 1.0 gridHeight: 2 )
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
	    #( fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
	    #( fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
	).           
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
	v := StandardSystemView new. v label:'GridBagLayoutView: Example 1'.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
	p := GridBagLayoutView in:v. p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
	1 to: c size do:[ :i | | b |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
	    b := Button label:('Button ',(i displayString)) in:p. 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
	    b objectAttributeAt:#GridBagConstraints put:((#(GridBagConstraints) , (c at:i)) decodeAsLiteralArray). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
	].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
	v extent:(p preferredExtent). v open.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
									[exEnd]
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
									[exBegin]
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
	| v p c |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
	c := #(
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 )                         
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 )                         
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 )                         
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 gridWidth: #REMAINDER ) 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #RELATIVE )                 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH weightY: 1.0 gridHeight: 2 )
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
	    #( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER )                
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
	).           
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
	v := StandardSystemView new. v label:'GridBagLayoutView: Example 2'.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
	p := GridBagLayoutView in:v. p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
	1 to: c size do:[ :i | | b |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
	    b := Button label:('Button ',(i displayString)) in:p. 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
	    b objectAttributeAt:#GridBagConstraints put:((#(GridBagConstraints) , (c at:i)) decodeAsLiteralArray). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
	].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
	v extent:(p preferredExtent). v open.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
									[exEnd]
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
! !
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
!GridBagLayoutView class methodsFor:'instance creation'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
new
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
    "Create a new instance of my class and do explizit initialization of it."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
2840
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   192
    ^ self basicNew initialize
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "Created: / 19.1.1998 / 13:53:11 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    "Modified: / 1.2.1998 / 13:02:59 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
! !
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
2840
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   198
!GridBagLayoutView methodsFor:'initialization'!
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   199
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   200
initialize
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   201
    "Initialize the instance. Mainly set our instance variables to required values."
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   202
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   203
    super initialize.
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   204
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   205
    columnWidths  := IdentityDictionaryWithDefault newWithDefaultValue:0.
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   206
    rowHeights    := IdentityDictionaryWithDefault newWithDefaultValue:0.
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   207
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   208
    columnWeights := IdentityDictionaryWithDefault newWithDefaultValue:0.0.
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   209
    rowWeights    := IdentityDictionaryWithDefault newWithDefaultValue:0.0.
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   210
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   211
    layoutInfo    := nil.
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   212
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   213
    "Created: / 19.1.1998 / 13:53:59 / av"
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   214
    "Modified: / 1.2.1998 / 12:57:05 / av"
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   215
! !
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1877
diff changeset
   216
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
!GridBagLayoutView methodsFor:'layout'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
setChildPositions
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    "(re)compute position of every child whenever childs are added or my size has changed"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    self arrangeGrid.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    "Modified: / 1.2.1998 / 12:52:22 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
! !
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
!GridBagLayoutView methodsFor:'private'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
adjustForGravity:c in:r
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   231
    |insets fill anchor diffx diffy add |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   233
    insets := c insets.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   234
    fill := c fill.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   235
    anchor := c anchor.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   236
    
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   237
    r setLeft: ((r left)   + (insets left)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   238
    r width:   ((r width)  - ((insets left) + (insets right))).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   239
    r setTop:  ((r top)    + (insets top)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   240
    r height:  ((r height) - ((insets top) + (insets bottom))).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    diffx := 0.
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   243
    (fill ~~ #HORIZONTAL and:[(fill ~~ #BOTH) and:[(r width) > (add := (c minWidth) + (c ipadX))]]) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   244
        diffx := (r width) - add.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   245
        r width:add.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    diffy := 0.
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   249
    (fill ~~ #VERTICAL and:[(fill ~~ #BOTH) and:[(r height) > (add := (c minHeight) + (c ipadY))]]) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   250
        diffy := (r height) - add.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   251
        r height:add.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   254
    (anchor == #CENTER) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   255
        r setLeft:((r left) + (diffx / 2)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   256
        r setTop:((r top) + (diffy / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   258
    (anchor == #NORTH) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   259
        r setLeft:((r left) + (diffx / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   261
    (anchor == #NORTHEAST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   262
        r setLeft:((r left) + diffx).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   264
    (anchor == #EAST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   265
        r setLeft:((r left) + diffx).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   266
        r setTop:((r top) + (diffy / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   268
    (anchor == #SOUTHEAST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   269
        r setLeft:((r left) + diffx).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   270
        r setTop:((r top) + diffy).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   272
    (anchor == #SOUTH) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   273
        r setLeft:((r left) + (diffx / 2)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   274
        r setTop:((r top) + diffy).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   276
    (anchor == #SOUTHWEST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   277
        r setTop:((r top) + diffy).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   279
    (anchor == #WEST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   280
        r setTop:((r top) + (diffy / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   282
    (anchor == #NORTHWEST) ifTrue:[
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    r setLeft: ((r left)   asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    r setTop:  ((r top)    asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    r width:   ((r width)  asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    r height:  ((r height) asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    ^ r
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    "Modified: / 22.1.1998 / 09:50:01 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
arrangeGrid
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    " Lay out the grid."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
    | insets subViews info ext d r c diffw diffh weight |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
    insets := Insets new.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    "/ If the parent has no slaves anymore, then don't do anything
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    "/ at all:  just leave the parent's size as-is.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    (((subViews := self subViews) size) == 0) ifTrue:[^ self].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
3245
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   306
"/    self extentChangedFlag ifTrue:[
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   307
"/        ext    := self computeExtent.
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   308
"/        width  := ext x.
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   309
"/        height := ext y.
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   310
"/    ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    "/ Pass #1: scan all the slaves to figure out the total amount
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    "/ of space needed.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    info := self getLayoutInfo:#PREFERRED_SIZE.    
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    d := self getMinSize:info.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    ((width < (d width)) or:[(height < (d height))]) ifTrue:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   319
        info := self getLayoutInfo:#MINIMUM_SIZE.    
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   320
        d := self getMinSize:info.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    layoutInfo := info.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    r := Rectangle origin:0@0 extent:((d width) @ (d height)).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    "/ If the current dimensions of the window don't match the desired
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    "/ dimensions, then adjust the minWidth and minHeight arrays
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    "/ according to the weights.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    diffw := width - (r width).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
    (diffw ~~ 0) ifTrue:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   332
        weight := 0.0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   333
        0 to:((info width) - 1) do:[ :i |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   334
            weight := weight + ((info weightX) at:(i + 1)).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   335
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   336
        (weight > 0.0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   337
            0 to:((info width) - 1) do:[ :i |    
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   338
                | dx |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   339
                dx := ((diffw * ((info weightX) at:(i + 1))) / weight) asInteger.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   340
                (info minWidth) at:(i + 1) put:(((info minWidth) at:(i + 1)) + dx).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   341
                r width:((r width) + dx).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   342
                (((info minWidth) at:(i + 1)) < 0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   343
                    r width:((r width) - ((info minWidth) at:(i + 1))).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   344
                    (info minWidth) at:(i + 1) put:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   345
                ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   346
            ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   347
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   348
        diffw := width - (r width).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    ] ifFalse:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   350
        diffw := 0.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
    diffh := height - (r height).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    (diffh ~~ 0) ifTrue:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   355
        weight := 0.0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   356
        0 to:((info height) - 1) do:[ :i |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   357
            weight := weight + ((info weightY) at:(i + 1)).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   358
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   359
        (weight > 0.0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   360
            0 to:((info height) - 1) do:[ :i |    
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   361
                | dy |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   362
                dy := ((diffh * ((info weightY) at:(i + 1))) / weight) asInteger.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   363
                (info minHeight) at:(i + 1) put:(((info minHeight) at:(i + 1)) + dy).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   364
                r height:((r height) + dy).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   365
                (((info minHeight) at:(i + 1)) < 0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   366
                    r height:((r height) - ((info minHeight) at:(i + 1))).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   367
                    (info minHeight) at:(i + 1) put:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   368
                ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   369
            ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   370
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   371
        diffh := height - (r height).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    ] ifFalse:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   373
        diffh := 0.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
    "/ Now do the actual layout of the slaves using the layout information
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    "/ that has been collected.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    info startX:(((diffw / 2) + (insets left)) asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    info startY:(((diffh / 2) + (insets top)) asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    subViews do:[ :child |
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   383
        |rW rH minWidth minHeight|
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   385
        c := self constraints:child.
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   386
        minWidth := info minWidth.
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   387
        minHeight := info minHeight.
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   388
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   389
        r setLeft:(info startX).
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   390
        0 to:((c tempX) - 1) do:[ :i | r setLeft:((r left) + (minWidth at:(i + 1))). ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
        
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   392
        r setTop:(info startY).
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   393
        0 to:((c tempY) - 1) do:[ :i | r setTop:((r top) + (minHeight at:(i + 1))). ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   395
        r width:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   396
        (c tempX) to:((c tempX) + (c tempWidth) - 1) do:[ :i |
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   397
            r width:((r width) + (minWidth at:(i + 1))).
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   398
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   400
        r height:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   401
        (c tempY) to:((c tempY) + (c tempHeight) - 1) do:[ :i |
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   402
            r height:((r height) + (minHeight at:(i + 1))).
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   403
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   405
        self adjustForGravity:c in:r.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   407
        "/ If the window is too small to be interesting then
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   408
        "/ unmap it.  Otherwise configure it and then make sure
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   409
        "/ its mapped.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   410
        rW := r width.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   411
        rH := r height.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   413
        ((rW <= 0) or:[rH <= 0]) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   414
            child origin:(0@0) ; width:0 height:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   415
        ] ifFalse:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   416
            child origin:((r left) @ (r top)).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   417
            child width:rW.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   418
            child height:rH.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   419
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
    "Modified: / 1.2.1998 / 12:53:37 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
constraints:anObject 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
    " Get the GridBag constraints for an object. As a fallback create new constraints for objects
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
      which don't have any constraints yet."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
    | c |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
    c := anObject objectAttributeAt:#GridBagConstraints.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
    c isNil ifTrue:[
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
	anObject objectAttributeAt:#GridBagConstraints put:(c := GridBagConstraints new)
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
    ^ c.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
    "Created: / 21.1.1998 / 00:24:34 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
    "Modified: / 1.2.1998 / 12:55:23 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
getLayoutInfo:which
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    "return a good extent, one that makes subviews fit"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
    | 
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   445
        MAX_INT_VAL subViews 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   446
        r i k px py pixelsDiff weightDiff weight nextSize c 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   447
        curX curY curWidth curHeight curRow curCol xMax yMax
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
    |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
    MAX_INT_VAL := 9999999999.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    subViews := (self subViews).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
    r := GridBagLayoutInfo new.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    r width:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    r height:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
    xMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
    yMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
    curRow := curCol := -1.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
    "/ Pass #1
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    "/ Figure out the dimensions of the layout grid (use a value of 1 for
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
    "/ zero or negative widths and heights).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    subViews do:[ :child |
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   467
        c := self constraints:child.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   469
        curX := c gridX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   470
        curY := c gridY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   471
        ((curWidth  := c gridWidth)  <= 0) ifTrue:[ curWidth  := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   472
        ((curHeight := c gridHeight) <= 0) ifTrue:[ curHeight := 1. ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   474
        "/ If x or y is negative, then use relative positioning:
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   475
        ((curX < 0) and:[ curY < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   476
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   477
                (curRow >= 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   478
                    ifTrue: [ curY := curRow. ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   479
                    ifFalse:[ (curCol >= 0) ifTrue:[ curX := curCol. ] ifFalse: [ curY := 0. ]].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   480
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   482
        (curX < 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   483
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   484
                px := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   485
                curY to:(curY + curHeight - 1) do: [ :i |
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   486
                    px := px max:(xMax at:(i + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   487
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   488
                ((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   489
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   490
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   491
                (curY < 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   492
                    py := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   493
                    curX to: (curX + curWidth - 1) do: [ :i |
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   494
                        py := py max: (yMax at:(i + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   495
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   496
                    ((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   497
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   498
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
        
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   500
        "/ Adjust the grid width and height
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   501
        px := curX + curWidth.  [ (r width)  < px ] whileTrue:[ r width:((r width) + 1). ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   502
        py := curY + curHeight. [ (r height) < py ] whileTrue:[ r height:((r height) + 1). ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   504
        "/ Adjust the xMax and yMax arrays
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   505
        curX to:(curX + curWidth  - 1) do:[ :i | yMax at:(i + 1) put:py. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   506
        curY to:(curY + curHeight - 1) do:[ :i | xMax at:(i + 1) put:px. ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   508
        c minWidth:(child preferredWidth).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   509
        c minHeight:(child preferredHeight).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   511
        "/ Zero width and height must mean that this is the last item (or
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   512
        "/ else something is wrong). 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   513
        (((c gridHeight) == 0) and:[ (c gridWidth) == 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   514
            curRow := curCol := -1.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   515
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   517
        "/ Zero width starts a new row
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   518
        (((c gridHeight) == 0) and:[ curRow < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   519
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   520
                curCol := curX + curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   521
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   522
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   523
                ((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   524
                    curRow := curY + curHeight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   525
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   526
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
    ].    
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
    "/ Apply minimum row/column dimensions
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
    ((r width)  < (columnWidths size)) ifTrue:[ r width:(columnWidths size). ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    ((r height) < (rowHeights size))   ifTrue:[ r height:(rowHeights size). ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
    "/ Pass #2
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
    "/ Negative values for gridX are filled in with the current x value.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
    "/ Negative values for gridY are filled in with the current y value.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
    "/ Negative or zero values for gridWidth and gridHeight end the current
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    "/ row or column, respectively.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    curRow := curCol := -1.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    xMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
    yMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
    subViews do:[ :child |
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   549
        c := self constraints:child.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   551
        curX      := c gridX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   552
        curY      := c gridY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   553
        curWidth  := c gridWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   554
        curHeight := c gridHeight.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   556
        "/ If x or y is negative, then use relative positioning:
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   557
        ((curX < 0) and:[ curY < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   558
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   559
                (curRow >= 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   560
                    ifTrue: [ curY := curRow. ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   561
                    ifFalse:[ (curCol >= 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   562
                        ifTrue:  [ curX := curCol. ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   563
                        ifFalse: [ curY := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   564
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   565
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   567
        (curX < 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   568
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   569
                (curHeight <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   570
                    curHeight := curHeight + (r height) - curY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   571
                    (curHeight < 1) ifTrue:[ curHeight := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   572
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   573
                px := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   574
                curY to:(curY + curHeight - 1) do: [ :i | px := px max:(xMax at:(i + 1)). ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   575
                ((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   576
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   577
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   578
                (curY < 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   579
                    (curWidth <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   580
                        curWidth := curWidth + (r width) - curX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   581
                        (curWidth < 1) ifTrue:[ curWidth := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   582
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   583
                    py := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   584
                    curX to:(curX + curWidth - 1) do: [ :i | py := py max:(yMax at:(i + 1)). ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   585
                    ((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   586
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   587
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   589
        (curWidth <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   590
            curWidth := curWidth + (r width) - curX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   591
            (curWidth < 1) ifTrue:[ curWidth := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   592
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   594
        (curHeight <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   595
            curHeight := curHeight + (r height) - curY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   596
            (curHeight < 1) ifTrue:[ curHeight := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   597
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   599
        px := curX + curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   600
        py := curY + curHeight.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   602
        "/ Adjust the xMax and yMax arrays
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   603
        curX to: (curX + curWidth  - 1) do:[ :i | yMax at:(i + 1) put:py. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   604
        curY to: (curY + curHeight - 1) do:[ :i | xMax at:(i + 1) put:px. ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   606
        "/ Zero width and height must mean that this is the last item (or
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   607
        "/ else something is wrong). 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   608
        ((c gridHeight) == 0 and:[ (c gridWidth) == 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   609
            curRow := curCol := -1.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   610
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   612
        "/ Zero width starts a new row
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   613
        ((c gridHeight) == 0 and:[ curRow < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   614
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   615
                curCol := curX + curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   616
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   617
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   618
                ((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   619
                    curRow := curY + curHeight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   620
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   621
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
        
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   623
        "/ Assign the new values to the gridbag slave */
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   624
        c tempX:curX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   625
        c tempY:curY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   626
        c tempWidth:curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   627
        c tempHeight:curHeight.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    "/ Apply minimum row/column dimensions and weights
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    r minWidth:  (columnWidths copy). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    r minHeight: (rowHeights copy). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    r weightX:   (columnWeights copy). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    r weightY:   (rowWeights copy).  
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
    "/ Pass #3
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
    "/ Distribute the minimun widths and weights:
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    nextSize := MAX_INT_VAL.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
    i := 1. [ i ~~ MAX_INT_VAL ] whileTrue:[
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   646
        subViews do:[ :child |
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   647
            c := self constraints:child.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   649
            ((c tempWidth) == i) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   650
                px := (c tempX) + (c tempWidth).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   652
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   653
                "/ Figure out if we should use this slaves weight.  If the weight
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   654
                "/ is less than the total weight spanned by the width of the cell,
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   655
                "/ then discard the weight.  Otherwise split the difference
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   656
                "/ according to the existing weights.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   657
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   658
                weightDiff := (c weightX) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   659
                (c tempX) to:(px - 1) do:[ :k | weightDiff := weightDiff - ((r weightX) at:(k + 1)) ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   661
                (weightDiff > 0.0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   662
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   663
                    (c tempX) to:(px - 1) do:[ :k | weight := weight + ((r weightX) at:(k + 1)). ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   665
                    k := c tempX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   666
                    [ (weight > 0.0) and:[k < px] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   667
                        | wt dx |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   669
                        wt := ((r weightX) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   670
                        dx := (wt * weightDiff) / weight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   671
                        wt at:(k + 1) put:(wt + dx).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   672
                        weightDiff := weightDiff - dx.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   673
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   674
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   675
                    (r weightX) at:(px - 1 + 1) put:(((r weightX) at:(px - 1 + 1)) + weightDiff).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   676
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   678
                "/ Calculate the minWidth array values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   679
                "/ First, figure out how wide the current slave needs to be.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   680
                "/ Then, see if it will fit within the current minWidth values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   681
                "/ If it will not fit, add the difference according to the
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   682
                "/ weightX array.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   684
                pixelsDiff := (c minWidth) + (c ipadX) + (c insets left) + (c insets right).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   685
                (c tempX) to:(px - 1) do:[ :k | 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   686
                    pixelsDiff := pixelsDiff - ((r minWidth) at:(k + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   687
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   689
                (pixelsDiff > 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   690
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   691
                    (c tempX) to:(px - 1) do:[ :k | weight := weight + ((r weightX) at:(k + 1)). ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   692
                    k := c tempX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   693
                    [ (weight > 0.0) and:[k < px] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   694
                        | wt dx |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   696
                        wt := ((r weightX) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   697
                        dx := ((wt * pixelsDiff) / weight) asInteger.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   698
                        (r minWidth) at:(k + 1) put:(((r minWidth) at:(k + 1)) + dx).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   699
                        pixelsDiff := pixelsDiff - dx.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   700
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   701
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   702
                    (r minWidth) at:(px - 1 + 1) put:(((r minWidth) at:(px - 1 + 1)) + pixelsDiff).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   703
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   704
            ] ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   705
                (((c tempWidth) > i) and:[ (c tempWidth) < nextSize ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   706
                    nextSize := c tempWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   707
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   708
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   710
            "///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   712
            ((c tempHeight) == i) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   713
                py := (c tempY) + (c tempHeight).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   715
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   716
                "/ Figure out if we should use this slaves weight.  If the weight
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   717
                "/ is less than the total weight spanned by the width of the cell,
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   718
                "/ then discard the weight.  Otherwise split the difference
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   719
                "/ according to the existing weights.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   720
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   721
                weightDiff := (c weightY) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   722
                (c tempY) to:(py - 1) do:[ :k | weightDiff := weightDiff - ((r weightY) at:(k + 1)) ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   724
                (weightDiff > 0.0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   725
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   726
                    (c tempY) to:(py - 1) do:[ :k | weight := weight + ((r weightY) at:(k + 1)). ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   728
                    k := c tempY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   729
                    [ (weight > 0.0) and:[k < py] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   730
                        | wt dy |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   732
                        wt := ((r weightY) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   733
                        dy := (wt * weightDiff) / weight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   734
                        wt at:(k + 1) put:(wt + dy).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   735
                        weightDiff := weightDiff - dy.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   736
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   737
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   738
                    (r weightY) at:(py - 1 + 1) put:(((r weightY) at:(py - 1 + 1)) + weightDiff).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   739
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   741
                "/ Calculate the minWidth array values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   742
                "/ First, figure out how wide the current slave needs to be.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   743
                "/ Then, see if it will fit within the current minWidth values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   744
                "/ If it will not fit, add the difference according to the
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   745
                "/ weightX array.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   747
                pixelsDiff := (c minHeight) + (c ipadY) + (c insets top) + (c insets bottom).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   748
                (c tempY) to:(py - 1) do:[ :k | 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   749
                    pixelsDiff := pixelsDiff - ((r minHeight) at:(k + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   750
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   752
                (pixelsDiff > 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   753
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   754
                    (c tempY) to:(py - 1) do:[ :k | 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   755
                        weight := weight + ((r weightY) at:(k + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   756
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   757
                    k := c tempY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   758
                    [ (weight > 0.0) and:[k < py] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   759
                        | wt dy |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   761
                        wt := ((r weightY) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   762
                        dy := ((wt * pixelsDiff) / weight) asInteger.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   763
                        (r minHeight) at:(k + 1) put:(((r minHeight) at:(k + 1)) + dy).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   764
                        pixelsDiff := pixelsDiff - dy.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   765
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   766
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   767
                    (r minHeight) at:(py - 1 + 1) put:(((r minHeight) at:(py - 1 + 1)) + pixelsDiff).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   768
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   769
            ] ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   770
                (((c tempHeight) > i) and:[ (c tempHeight) < nextSize ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   771
                    nextSize := c tempHeight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   772
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   773
            ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   774
        ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   775
        i := nextSize.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   776
        nextSize := MAX_INT_VAL.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
    ^ r
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
    "Modified: / 29.3.1997 / 11:06:45 / cg"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
    "Created: / 19.1.1998 / 17:24:26 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
    "Modified: / 21.1.1998 / 18:40:38 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
getMinSize:info
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
    "Figure out the minimum size of the master based on the information from getLayoutInfo. The
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
     result will be returned as a rectangle with width and height set to the minimum size."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
    | d insets t |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
    insets := Insets new.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
    d := Rectangle origin:0@0 extent:0@0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
    
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
    t := 0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
    1 to:(info width) do:[ :i | t := t + ((info minWidth) at:i). ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    d width:(t + (insets left) + (insets right)).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
    t := 0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
    1 to:(info height) do:[ :i | t := t + ((info minHeight) at:i). ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    d height:(t + (insets top) + (insets bottom)).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
    ^ d
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
    "Modified: / 1.2.1998 / 12:59:00 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
minimumLayoutSize
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
    "Return our minimum layout size. The width and height of the returned rectangle gives the minimum
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
     layout size."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
    | info |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
    info := self getLayoutInfo:#MINIMUM_SIZE.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
    ^ self getMinSize:info
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
    "Created: / 19.1.1998 / 17:25:01 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    "Modified: / 1.2.1998 / 12:59:38 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
preferredLayoutSize
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
    "Return our preffered layout size. The width and height of the returned rectangle gives the
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
    preferred layout size."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
    | info |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
    info := self getLayoutInfo:#PREFFERED_SIZE.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
    ^ self getMinSize:info
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
    "Created: / 19.1.1998 / 17:23:37 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
    "Modified: / 1.2.1998 / 13:00:04 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
! !
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
!GridBagLayoutView methodsFor:'queries'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
preferredExtent
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    "Return a good extent, one that makes subviews fit. Return the the preferred extent as a point
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
    where x and y represents the width and height of the extent."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
3570
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   841
    "/ If I have an explicit preferredExtent..
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   842
    explicitExtent notNil ifTrue:[
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   843
        ^ explicitExtent
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   844
    ].
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   845
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   846
    "/ If I have a cached preferredExtent value..
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   847
    preferredExtent notNil ifTrue:[
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   848
        ^ preferredExtent
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   849
    ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
3673
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   851
    self subViews isNil ifTrue:[ 
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   852
        ^ super preferredExtent. 
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   853
    ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
3673
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   855
    ^ self preferredLayoutSize extent.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
    "Created: / 17.1.1998 / 00:11:46 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
    "Modified: / 1.2.1998 / 13:01:46 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
! !
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
!GridBagLayoutView class methodsFor:'documentation'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
version
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   864
    ^ '$Header$'
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
! !
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   866