4354
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
4297
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2019 by Claus Gittinger
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
|
14 |
"{ Package: 'stx:libview2' }"
|
|
15 |
|
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
|
18 |
LayoutFrame subclass:#ConstrainedLayoutFrame
|
|
19 |
instanceVariableNames:'minLeft maxLeft minRight maxRight minTop maxTop minBottom
|
|
20 |
maxBottom'
|
|
21 |
classVariableNames:''
|
|
22 |
poolDictionaries:''
|
|
23 |
category:'Graphics-Geometry'
|
|
24 |
!
|
|
25 |
|
|
26 |
!ConstrainedLayoutFrame class methodsFor:'documentation'!
|
|
27 |
|
|
28 |
copyright
|
|
29 |
"
|
|
30 |
COPYRIGHT (c) 2019 by Claus Gittinger
|
|
31 |
All Rights Reserved
|
|
32 |
|
|
33 |
This software is furnished under a license and may be used
|
|
34 |
only in accordance with the terms of that license and with the
|
|
35 |
inclusion of the above copyright notice. This software may not
|
|
36 |
be provided or otherwise made available to, or used by, any
|
|
37 |
other person. No title to or ownership of the software is
|
|
38 |
hereby transferred.
|
|
39 |
"
|
|
40 |
!
|
|
41 |
|
|
42 |
documentation
|
|
43 |
"
|
|
44 |
Instances of me are like layoutFrames,
|
|
45 |
with additional (optional) limits on the bounds.
|
|
46 |
Useful to arrange for labels in a dialog to never become too large.
|
|
47 |
|
|
48 |
[author:]
|
|
49 |
Claus Gittinger
|
|
50 |
|
|
51 |
[see also:]
|
|
52 |
View
|
|
53 |
LayoutFrame LayoutOrigin AlignmentOrigin Layout
|
|
54 |
Rectangle Point
|
|
55 |
"
|
|
56 |
! !
|
|
57 |
|
|
58 |
!ConstrainedLayoutFrame methodsFor:'accessing'!
|
|
59 |
|
|
60 |
maxBottom
|
|
61 |
^ maxBottom
|
|
62 |
!
|
|
63 |
|
|
64 |
maxBottom:something
|
|
65 |
maxBottom := something.
|
|
66 |
!
|
|
67 |
|
|
68 |
maxLeft
|
|
69 |
^ maxLeft
|
|
70 |
!
|
|
71 |
|
4354
|
72 |
maxLeft:pixels
|
|
73 |
maxLeft := pixels.
|
4297
|
74 |
!
|
|
75 |
|
|
76 |
maxRight
|
|
77 |
^ maxRight
|
|
78 |
!
|
|
79 |
|
4354
|
80 |
maxRight:pixels
|
|
81 |
maxRight := pixels.
|
4297
|
82 |
!
|
|
83 |
|
|
84 |
maxTop
|
|
85 |
^ maxTop
|
|
86 |
!
|
|
87 |
|
4354
|
88 |
maxTop:pixels
|
|
89 |
maxTop := pixels.
|
4297
|
90 |
!
|
|
91 |
|
|
92 |
minBottom
|
|
93 |
^ minBottom
|
|
94 |
!
|
|
95 |
|
4354
|
96 |
minBottom:pixels
|
|
97 |
minBottom := pixels.
|
4297
|
98 |
!
|
|
99 |
|
|
100 |
minLeft
|
|
101 |
^ minLeft
|
|
102 |
!
|
|
103 |
|
4354
|
104 |
minLeft:pixels
|
|
105 |
minLeft := pixels.
|
4297
|
106 |
!
|
|
107 |
|
|
108 |
minRight
|
|
109 |
^ minRight
|
|
110 |
!
|
|
111 |
|
4354
|
112 |
minRight:pixels
|
|
113 |
minRight := pixels.
|
4297
|
114 |
!
|
|
115 |
|
|
116 |
minTop
|
|
117 |
^ minTop
|
|
118 |
!
|
|
119 |
|
4354
|
120 |
minTop:pixels
|
|
121 |
minTop := pixels.
|
4297
|
122 |
! !
|
|
123 |
|
|
124 |
!ConstrainedLayoutFrame methodsFor:'computing'!
|
|
125 |
|
|
126 |
rectangleRelativeTo:superRectangle preferred:prefRectHolder
|
|
127 |
"compute the rectangle represented by the receiver,
|
|
128 |
given the superView's rectangle and the view's preferredExtent."
|
|
129 |
|
|
130 |
|x1 y1 x2 y2 superWidth superHeight|
|
|
131 |
|
|
132 |
x1 := x2 := superRectangle left.
|
|
133 |
y1 := y2 := superRectangle top.
|
|
134 |
|
|
135 |
leftOffset notNil ifTrue:[
|
|
136 |
x1 := x1 + leftOffset value
|
|
137 |
].
|
|
138 |
topOffset notNil ifTrue:[
|
|
139 |
y1 := y1 + topOffset value
|
|
140 |
].
|
|
141 |
rightOffset notNil ifTrue:[
|
|
142 |
x2 := x2 + rightOffset value
|
|
143 |
].
|
|
144 |
bottomOffset notNil ifTrue:[
|
|
145 |
y2 := y2 + bottomOffset value
|
|
146 |
].
|
|
147 |
|
|
148 |
leftFraction notNil ifTrue:[
|
|
149 |
superWidth := superRectangle width.
|
|
150 |
x1 := x1 + (superWidth * leftFraction value)
|
|
151 |
].
|
|
152 |
topFraction notNil ifTrue:[
|
|
153 |
superHeight := superRectangle height.
|
|
154 |
y1 := y1 + (superHeight * topFraction value)
|
|
155 |
].
|
|
156 |
rightFraction notNil ifTrue:[
|
|
157 |
superWidth isNil ifTrue:[superWidth := superRectangle width].
|
|
158 |
x2 := x2 + (superWidth * rightFraction value)
|
|
159 |
].
|
|
160 |
bottomFraction notNil ifTrue:[
|
|
161 |
superHeight isNil ifTrue:[superHeight := superRectangle height].
|
|
162 |
y2 := y2 + (superHeight * bottomFraction value)
|
|
163 |
].
|
|
164 |
(minLeft notNil and:[x1 < minLeft]) ifTrue:[
|
|
165 |
x1 := minLeft.
|
|
166 |
].
|
|
167 |
(maxLeft notNil and:[x1 > maxLeft]) ifTrue:[
|
|
168 |
x1 := maxLeft.
|
|
169 |
].
|
|
170 |
(minTop notNil and:[y1 < minTop]) ifTrue:[
|
|
171 |
y1 := minTop.
|
|
172 |
].
|
|
173 |
(maxTop notNil and:[x1 > maxTop]) ifTrue:[
|
|
174 |
y1 := maxTop.
|
|
175 |
].
|
|
176 |
(minRight notNil and:[x1 < minRight]) ifTrue:[
|
|
177 |
x2 := minRight.
|
|
178 |
].
|
|
179 |
(maxRight notNil and:[x1 > maxRight]) ifTrue:[
|
|
180 |
x2 := maxRight.
|
|
181 |
].
|
|
182 |
(minBottom notNil and:[y1 < minBottom]) ifTrue:[
|
|
183 |
y2 := minBottom.
|
|
184 |
].
|
|
185 |
(maxBottom notNil and:[x1 > maxBottom]) ifTrue:[
|
|
186 |
y2 := maxBottom.
|
|
187 |
].
|
|
188 |
^ Rectangle left:x1 top:y1 right:x2 bottom:y2
|
|
189 |
|
|
190 |
"
|
|
191 |
|superRect1 superRect2 lF|
|
|
192 |
|
|
193 |
superRect1 := 0@0 corner:100@100.
|
|
194 |
superRect2 := 0@0 corner:400@100.
|
|
195 |
lF := (ConstrainedLayoutFrame new).
|
|
196 |
lF leftFraction:0.25 rightFraction:0.75
|
|
197 |
topFraction:0.25 bottomFraction:0.75.
|
|
198 |
lF rectangleRelativeTo:superRect1 preferred:(0@0 corner:30@30).
|
|
199 |
|
|
200 |
lF rectangleRelativeTo:superRect2 preferred:(0@0 corner:30@30).
|
|
201 |
lF maxLeft:70.
|
|
202 |
lF rectangleRelativeTo:superRect2 preferred:(0@0 corner:30@30).
|
|
203 |
"
|
|
204 |
|
|
205 |
"Created: / 17-07-2019 / 10:02:08 / Claus Gittinger"
|
|
206 |
! !
|
|
207 |
|
|
208 |
!ConstrainedLayoutFrame class methodsFor:'documentation'!
|
|
209 |
|
|
210 |
version_CVS
|
|
211 |
^ '$Header$'
|
|
212 |
! !
|
|
213 |
|