GridBagLayoutView.st
author Claus Gittinger <cg@exept.de>
Fri, 15 Jun 2018 10:54:35 +0200
changeset 5816 7876c07931a7
parent 5634 9fb149cbc61e
child 5946 454fc5b536b1
permissions -rw-r--r--
#DOCUMENTATION by cg class: ComboListView class comment/format in: #documentation
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
5634
9fb149cbc61e #DOCUMENTATION by mawalch
mawalch
parents: 5303
diff changeset
   220
    "(re)compute position of every child whenever children are added or my size has changed"
721
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
5634
9fb149cbc61e #DOCUMENTATION by mawalch
mawalch
parents: 5303
diff changeset
   224
    "Modified: / 01-02-1998 / 12:52:22 / av"
9fb149cbc61e #DOCUMENTATION by mawalch
mawalch
parents: 5303
diff changeset
   225
    "Modified (comment): / 09-11-2017 / 10:43:16 / mawalch"
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
!GridBagLayoutView methodsFor:'private'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
adjustForGravity:c in:r
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   232
    |insets fill anchor diffx diffy add |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   234
    insets := c insets.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   235
    fill := c fill.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   236
    anchor := c anchor.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   237
    
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   238
    r setLeft: ((r left)   + (insets left)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   239
    r width:   ((r width)  - ((insets left) + (insets right))).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   240
    r setTop:  ((r top)    + (insets top)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   241
    r height:  ((r height) - ((insets top) + (insets bottom))).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    diffx := 0.
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   244
    (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
   245
        diffx := (r width) - add.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   246
        r width:add.
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    diffy := 0.
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   250
    (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
   251
        diffy := (r height) - add.
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   252
        r height:add.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   255
    (anchor == #CENTER) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   256
        r setLeft:((r left) + (diffx / 2)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   257
        r setTop:((r top) + (diffy / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   259
    (anchor == #NORTH) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   260
        r setLeft:((r left) + (diffx / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   262
    (anchor == #NORTHEAST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   263
        r setLeft:((r left) + diffx).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   265
    (anchor == #EAST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   266
        r setLeft:((r left) + diffx).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   267
        r setTop:((r top) + (diffy / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   269
    (anchor == #SOUTHEAST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   270
        r setLeft:((r left) + diffx).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   271
        r setTop:((r top) + diffy).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   273
    (anchor == #SOUTH) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   274
        r setLeft:((r left) + (diffx / 2)).
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   275
        r setTop:((r top) + diffy).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   277
    (anchor == #SOUTHWEST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   278
        r setTop:((r top) + diffy).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   280
    (anchor == #WEST) ifTrue:[
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   281
        r setTop:((r top) + (diffy / 2)).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    ].
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   283
    (anchor == #NORTHWEST) ifTrue:[
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    r setLeft: ((r left)   asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    r setTop:  ((r top)    asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    r width:   ((r width)  asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    r height:  ((r height) asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    ^ r
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    "Modified: / 22.1.1998 / 09:50:01 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
arrangeGrid
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    " Lay out the grid."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    | insets subViews info ext d r c diffw diffh weight |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    insets := Insets new.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    "/ If the parent has no slaves anymore, then don't do anything
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    "/ at all:  just leave the parent's size as-is.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    (((subViews := self subViews) size) == 0) ifTrue:[^ self].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
3245
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   307
"/    self extentChangedFlag ifTrue:[
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   308
"/        ext    := self computeExtent.
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   309
"/        width  := ext x.
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   310
"/        height := ext y.
facdad487e2f changed #arrangeGrid
ca
parents: 2955
diff changeset
   311
"/    ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    "/ Pass #1: scan all the slaves to figure out the total amount
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    "/ of space needed.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    info := self getLayoutInfo:#PREFERRED_SIZE.    
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    d := self getMinSize:info.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    ((width < (d width)) or:[(height < (d height))]) ifTrue:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   320
        info := self getLayoutInfo:#MINIMUM_SIZE.    
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   321
        d := self getMinSize:info.
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    layoutInfo := info.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    r := Rectangle origin:0@0 extent:((d width) @ (d height)).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    "/ If the current dimensions of the window don't match the desired
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    "/ dimensions, then adjust the minWidth and minHeight arrays
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    "/ according to the weights.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
    diffw := width - (r width).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
    (diffw ~~ 0) ifTrue:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   333
        weight := 0.0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   334
        0 to:((info width) - 1) do:[ :i |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   335
            weight := weight + ((info weightX) at:(i + 1)).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   336
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   337
        (weight > 0.0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   338
            0 to:((info width) - 1) do:[ :i |    
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   339
                | dx |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   340
                dx := ((diffw * ((info weightX) at:(i + 1))) / weight) asInteger.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   341
                (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
   342
                r width:((r width) + dx).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   343
                (((info minWidth) at:(i + 1)) < 0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   344
                    r width:((r width) - ((info minWidth) at:(i + 1))).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   345
                    (info minWidth) at:(i + 1) put:0.
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
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   349
        diffw := width - (r width).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    ] ifFalse:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   351
        diffw := 0.
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    diffh := height - (r height).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    (diffh ~~ 0) ifTrue:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   356
        weight := 0.0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   357
        0 to:((info height) - 1) do:[ :i |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   358
            weight := weight + ((info weightY) at:(i + 1)).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   359
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   360
        (weight > 0.0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   361
            0 to:((info height) - 1) do:[ :i |    
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   362
                | dy |
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   363
                dy := ((diffh * ((info weightY) at:(i + 1))) / weight) asInteger.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   364
                (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
   365
                r height:((r height) + dy).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   366
                (((info minHeight) at:(i + 1)) < 0) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   367
                    r height:((r height) - ((info minHeight) at:(i + 1))).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   368
                    (info minHeight) at:(i + 1) put:0.
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
        ].
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   372
        diffh := height - (r height).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    ] ifFalse:[
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   374
        diffh := 0.
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    "/ Now do the actual layout of the slaves using the layout information
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    "/ that has been collected.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    info startX:(((diffw / 2) + (insets left)) asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    info startY:(((diffh / 2) + (insets top)) asInteger).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    subViews do:[ :child |
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   384
        |rW rH minWidth minHeight|
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   386
        c := self constraints:child.
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   387
        minWidth := info minWidth.
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   388
        minHeight := info minHeight.
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   389
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   390
        r setLeft:(info startX).
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   391
        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
   392
        
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   393
        r setTop:(info startY).
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   394
        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
   395
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   396
        r width:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   397
        (c tempX) to:((c tempX) + (c tempWidth) - 1) do:[ :i |
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   398
            r width:((r width) + (minWidth at:(i + 1))).
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   399
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   401
        r height:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   402
        (c tempY) to:((c tempY) + (c tempHeight) - 1) do:[ :i |
2955
57c6b1a672dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2840
diff changeset
   403
            r height:((r height) + (minHeight at:(i + 1))).
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   404
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   406
        self adjustForGravity:c in:r.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   408
        "/ If the window is too small to be interesting then
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   409
        "/ unmap it.  Otherwise configure it and then make sure
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   410
        "/ its mapped.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   411
        rW := r width.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   412
        rH := r height.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
1519
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   414
        ((rW <= 0) or:[rH <= 0]) ifTrue:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   415
            child origin:(0@0) ; width:0 height:0.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   416
        ] ifFalse:[
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   417
            child origin:((r left) @ (r top)).
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   418
            child width:rW.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   419
            child height:rH.
eeb8243a99af checkin from browser
Claus Gittinger <cg@exept.de>
parents: 790
diff changeset
   420
        ].
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    "Modified: / 1.2.1998 / 12:53:37 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
constraints:anObject 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
    " 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
   428
      which don't have any constraints yet."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
    | c |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
    c := anObject objectAttributeAt:#GridBagConstraints.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
    c isNil ifTrue:[
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
	anObject objectAttributeAt:#GridBagConstraints put:(c := GridBagConstraints new)
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
    ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
    ^ c.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
    "Created: / 21.1.1998 / 00:24:34 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    "Modified: / 1.2.1998 / 12:55:23 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
getLayoutInfo:which
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
    "return a good extent, one that makes subviews fit"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
    | 
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   446
        MAX_INT_VAL subViews 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   447
        r i k px py pixelsDiff weightDiff weight nextSize c 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   448
        curX curY curWidth curHeight curRow curCol xMax yMax
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    MAX_INT_VAL := 9999999999.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
    subViews := (self subViews).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    r := GridBagLayoutInfo new.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    r width:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    r height:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
    xMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
    yMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
    curRow := curCol := -1.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    "/ Pass #1
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
    "/ 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
   465
    "/ zero or negative widths and heights).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
    subViews do:[ :child |
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   468
        c := self constraints:child.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   470
        curX := c gridX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   471
        curY := c gridY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   472
        ((curWidth  := c gridWidth)  <= 0) ifTrue:[ curWidth  := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   473
        ((curHeight := c gridHeight) <= 0) ifTrue:[ curHeight := 1. ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   475
        "/ If x or y is negative, then use relative positioning:
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   476
        ((curX < 0) and:[ curY < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   477
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   478
                (curRow >= 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   479
                    ifTrue: [ curY := curRow. ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   480
                    ifFalse:[ (curCol >= 0) ifTrue:[ curX := curCol. ] ifFalse: [ curY := 0. ]].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   481
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   483
        (curX < 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   484
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   485
                px := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   486
                curY to:(curY + curHeight - 1) do: [ :i |
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   487
                    px := px max:(xMax at:(i + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   488
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   489
                ((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   490
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   491
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   492
                (curY < 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   493
                    py := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   494
                    curX to: (curX + curWidth - 1) do: [ :i |
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   495
                        py := py max: (yMax at:(i + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   496
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   497
                    ((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   498
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   499
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
        
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   501
        "/ Adjust the grid width and height
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   502
        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
   503
        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
   504
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   505
        "/ Adjust the xMax and yMax arrays
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   506
        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
   507
        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
   508
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   509
        c minWidth:(child preferredWidth).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   510
        c minHeight:(child preferredHeight).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   512
        "/ 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
   513
        "/ else something is wrong). 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   514
        (((c gridHeight) == 0) and:[ (c gridWidth) == 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   515
            curRow := curCol := -1.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   516
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   518
        "/ Zero width starts a new row
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   519
        (((c gridHeight) == 0) and:[ curRow < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   520
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   521
                curCol := curX + curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   522
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   523
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   524
                ((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   525
                    curRow := curY + curHeight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   526
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   527
            ].
721
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
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
    "/ Apply minimum row/column dimensions
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    ((r width)  < (columnWidths size)) ifTrue:[ r width:(columnWidths size). ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
    ((r height) < (rowHeights size))   ifTrue:[ r height:(rowHeights size). ].
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
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
    "/ Pass #2
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
    "/ Negative values for gridX are filled in with the current x value.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
    "/ Negative values for gridY are filled in with the current y value.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
    "/ Negative or zero values for gridWidth and gridHeight end the current
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
    "/ row or column, respectively.
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    curRow := curCol := -1.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
    xMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
    yMax := IdentityDictionaryWithDefault newWithDefaultValue:0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
    subViews do:[ :child |
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   550
        c := self constraints:child.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   552
        curX      := c gridX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   553
        curY      := c gridY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   554
        curWidth  := c gridWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   555
        curHeight := c gridHeight.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   557
        "/ If x or y is negative, then use relative positioning:
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   558
        ((curX < 0) and:[ curY < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   559
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   560
                (curRow >= 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   561
                    ifTrue: [ curY := curRow. ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   562
                    ifFalse:[ (curCol >= 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   563
                        ifTrue:  [ curX := curCol. ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   564
                        ifFalse: [ curY := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   565
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   566
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   568
        (curX < 0) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   569
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   570
                (curHeight <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   571
                    curHeight := curHeight + (r height) - curY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   572
                    (curHeight < 1) ifTrue:[ curHeight := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   573
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   574
                px := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   575
                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
   576
                ((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   577
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   578
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   579
                (curY < 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   580
                    (curWidth <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   581
                        curWidth := curWidth + (r width) - curX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   582
                        (curWidth < 1) ifTrue:[ curWidth := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   583
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   584
                    py := 0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   585
                    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
   586
                    ((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   587
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   588
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   590
        (curWidth <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   591
            curWidth := curWidth + (r width) - curX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   592
            (curWidth < 1) ifTrue:[ curWidth := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   593
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   595
        (curHeight <= 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   596
            curHeight := curHeight + (r height) - curY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   597
            (curHeight < 1) ifTrue:[ curHeight := 1. ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   598
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   600
        px := curX + curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   601
        py := curY + curHeight.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   603
        "/ Adjust the xMax and yMax arrays
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   604
        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
   605
        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
   606
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   607
        "/ 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
   608
        "/ else something is wrong). 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   609
        ((c gridHeight) == 0 and:[ (c gridWidth) == 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   610
            curRow := curCol := -1.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   611
        ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   613
        "/ Zero width starts a new row
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   614
        ((c gridHeight) == 0 and:[ curRow < 0 ]) 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   615
            ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   616
                curCol := curX + curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   617
            ]
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   618
            ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   619
                ((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   620
                    curRow := curY + curHeight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   621
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   622
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
        
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   624
        "/ Assign the new values to the gridbag slave */
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   625
        c tempX:curX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   626
        c tempY:curY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   627
        c tempWidth:curWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   628
        c tempHeight:curHeight.
721
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
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
    "/ Apply minimum row/column dimensions and weights
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    r minWidth:  (columnWidths copy). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    r minHeight: (rowHeights copy). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    r weightX:   (columnWeights copy). 
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
    r weightY:   (rowWeights copy).  
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
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
    "/ Pass #3
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
    "/ Distribute the minimun widths and weights:
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    "/
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
    nextSize := MAX_INT_VAL.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
    i := 1. [ i ~~ MAX_INT_VAL ] whileTrue:[
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   647
        subViews do:[ :child |
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   648
            c := self constraints:child.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   650
            ((c tempWidth) == i) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   651
                px := (c tempX) + (c tempWidth).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   653
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   654
                "/ 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
   655
                "/ 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
   656
                "/ then discard the weight.  Otherwise split the difference
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   657
                "/ according to the existing weights.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   658
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   659
                weightDiff := (c weightX) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   660
                (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
   661
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   662
                (weightDiff > 0.0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   663
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   664
                    (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
   665
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   666
                    k := c tempX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   667
                    [ (weight > 0.0) and:[k < px] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   668
                        | wt dx |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   670
                        wt := ((r weightX) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   671
                        dx := (wt * weightDiff) / weight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   672
                        wt at:(k + 1) put:(wt + dx).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   673
                        weightDiff := weightDiff - dx.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   674
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   675
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   676
                    (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
   677
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   679
                "/ Calculate the minWidth array values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   680
                "/ First, figure out how wide the current slave needs to be.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   681
                "/ Then, see if it will fit within the current minWidth values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   682
                "/ If it will not fit, add the difference according to the
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   683
                "/ weightX array.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   685
                pixelsDiff := (c minWidth) + (c ipadX) + (c insets left) + (c insets right).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   686
                (c tempX) to:(px - 1) do:[ :k | 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   687
                    pixelsDiff := pixelsDiff - ((r minWidth) at:(k + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   688
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   690
                (pixelsDiff > 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   691
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   692
                    (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
   693
                    k := c tempX.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   694
                    [ (weight > 0.0) and:[k < px] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   695
                        | wt dx |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   697
                        wt := ((r weightX) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   698
                        dx := ((wt * pixelsDiff) / weight) asInteger.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   699
                        (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
   700
                        pixelsDiff := pixelsDiff - dx.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   701
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   702
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   703
                    (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
   704
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   705
            ] ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   706
                (((c tempWidth) > i) and:[ (c tempWidth) < nextSize ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   707
                    nextSize := c tempWidth.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   708
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   709
            ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   711
            "///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   713
            ((c tempHeight) == i) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   714
                py := (c tempY) + (c tempHeight).
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   716
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   717
                "/ 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
   718
                "/ 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
   719
                "/ then discard the weight.  Otherwise split the difference
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   720
                "/ according to the existing weights.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   721
                "/
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   722
                weightDiff := (c weightY) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   723
                (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
   724
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   725
                (weightDiff > 0.0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   726
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   727
                    (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
   728
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   729
                    k := c tempY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   730
                    [ (weight > 0.0) and:[k < py] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   731
                        | wt dy |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   733
                        wt := ((r weightY) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   734
                        dy := (wt * weightDiff) / weight.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   735
                        wt at:(k + 1) put:(wt + dy).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   736
                        weightDiff := weightDiff - dy.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   737
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   738
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   739
                    (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
   740
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   742
                "/ Calculate the minWidth array values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   743
                "/ First, figure out how wide the current slave needs to be.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   744
                "/ Then, see if it will fit within the current minWidth values.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   745
                "/ If it will not fit, add the difference according to the
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   746
                "/ weightX array.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   748
                pixelsDiff := (c minHeight) + (c ipadY) + (c insets top) + (c insets bottom).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   749
                (c tempY) to:(py - 1) do:[ :k | 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   750
                    pixelsDiff := pixelsDiff - ((r minHeight) at:(k + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   751
                ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   753
                (pixelsDiff > 0) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   754
                    weight := 0.0.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   755
                    (c tempY) to:(py - 1) do:[ :k | 
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   756
                        weight := weight + ((r weightY) at:(k + 1)).
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   757
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   758
                    k := c tempY.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   759
                    [ (weight > 0.0) and:[k < py] ] whileTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   760
                        | wt dy |
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
3422
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   762
                        wt := ((r weightY) at:(k + 1)) asFloat.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   763
                        dy := ((wt * pixelsDiff) / weight) asInteger.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   764
                        (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
   765
                        pixelsDiff := pixelsDiff - dy.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   766
                        weight := weight - wt.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   767
                    ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   768
                    (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
   769
                ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   770
            ] ifFalse:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   771
                (((c tempHeight) > i) and:[ (c tempHeight) < nextSize ]) ifTrue:[
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   772
                    nextSize := c tempHeight.
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
        ].
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   776
        i := nextSize.
01087101a82b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
   777
        nextSize := MAX_INT_VAL.
721
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
    ^ r
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
    "Modified: / 29.3.1997 / 11:06:45 / cg"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
    "Created: / 19.1.1998 / 17:24:26 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
    "Modified: / 21.1.1998 / 18:40:38 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
getMinSize:info
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
    "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
   789
     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
   790
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
    | d insets t |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
    insets := Insets new.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
    d := Rectangle origin:0@0 extent:0@0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
    
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
    t := 0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    1 to:(info width) do:[ :i | t := t + ((info minWidth) at:i). ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
    d width:(t + (insets left) + (insets right)).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
    t := 0.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    1 to:(info height) do:[ :i | t := t + ((info minHeight) at:i). ].
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
    d height:(t + (insets top) + (insets bottom)).
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
    ^ d
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
    "Modified: / 1.2.1998 / 12:59:00 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
minimumLayoutSize
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
    "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
   812
     layout size."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
    | info |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
    info := self getLayoutInfo:#MINIMUM_SIZE.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
    ^ self getMinSize:info
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    "Created: / 19.1.1998 / 17:25:01 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
    "Modified: / 1.2.1998 / 12:59:38 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
preferredLayoutSize
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
    "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
   825
    preferred layout size."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
    | info |
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
    info := self getLayoutInfo:#PREFFERED_SIZE.
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    ^ self getMinSize:info
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
    "Created: / 19.1.1998 / 17:23:37 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
    "Modified: / 1.2.1998 / 13:00:04 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
!GridBagLayoutView methodsFor:'queries'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
preferredExtent
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
    "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
   840
    where x and y represents the width and height of the extent."
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
3570
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   842
    "/ If I have an explicit preferredExtent..
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   843
    explicitExtent notNil ifTrue:[
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   844
        ^ explicitExtent
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
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   847
    "/ If I have a cached preferredExtent value..
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   848
    preferredExtent notNil ifTrue:[
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   849
        ^ preferredExtent
a8243f6c0b1f changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3422
diff changeset
   850
    ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
3673
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   852
    self subViews isNil ifTrue:[ 
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   853
        ^ super preferredExtent. 
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   854
    ].
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
3673
31a56ced44b6 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 3570
diff changeset
   856
    ^ self preferredLayoutSize extent.
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
    "Created: / 17.1.1998 / 00:11:46 / av"
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
    "Modified: / 1.2.1998 / 13:01:46 / av"
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
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
!GridBagLayoutView class methodsFor:'documentation'!
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
version
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   865
    ^ '$Header$'
721
c33e43c9fe66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
! !
5303
dc0252c294f5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3673
diff changeset
   867