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