author | tm |
Tue, 07 Sep 1999 11:14:16 +0200 | |
changeset 2006 | c0c1cc3c5a70 |
parent 1959 | e7b3df3c952f |
child 2034 | 2efa727de60f |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
60 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
119 | 13 |
SimpleView subclass:#PanelView |
585 | 14 |
instanceVariableNames:'hLayout vLayout verticalSpace horizontalSpace mustRearrange |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
15 |
elementsChangeSize ignoreInvisibleComponents' |
585 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Layout' |
|
0 | 19 |
! |
20 |
||
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
21 |
!PanelView class methodsFor:'documentation'! |
0 | 22 |
|
38 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
60 | 26 |
All Rights Reserved |
0 | 27 |
|
38 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
0 | 36 |
|
38 | 37 |
documentation |
38 |
" |
|
127 | 39 |
this is a view for holding subviews. (layout-widget ?) |
38 | 40 |
|
41 |
Instances of PanelView try to get all their subviews into them, |
|
42 |
arranging subviews left-to-right, top-to-bottom. |
|
43 |
||
44 |
If you dont like its layout, define a new subclass or use one of |
|
45 |
the existing subclasses: HorizontalPanelView and VerticalPanelView. |
|
60 | 46 |
|
127 | 47 |
The panel assumes, that the elements do not resize themselfes, after it |
48 |
became visible. This is not true for all widgets (buttons or labels may |
|
49 |
like to change). If you have changing elements, tell this to the panel |
|
50 |
with 'aPanel elementsChangeSize:true'. In that case, the panel will react |
|
51 |
to size changes, and reorganize things. |
|
52 |
||
63 | 53 |
PanelViews normally delay the actual positioning/sizing of their elements, |
60 | 54 |
until actually displayed. This is useful, if more elements are to |
55 |
be added, to avoid repeated configuration of the elements. |
|
56 |
||
57 |
If you want to query for the relative position of an element BEFORE |
|
58 |
the view is visible, you have to send #setChildPositionsIfChanged before |
|
63 | 59 |
doing so (otherwise, you may get invalid origins from the subviews). As |
60 |
an example, the modalBoxes do so before showing themselfes to ask for the |
|
61 |
position of the ok-button relative to the top-left box-origin, in order to |
|
62 |
position the ok-button under the mouse-pointer. |
|
63 |
||
585 | 64 |
[Instance variables:] |
63 | 65 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
66 |
hLayout <Symbol> controls horizontal layout; ignored in this |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
67 |
class, but used in Horizontal- and |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
68 |
VerticalPanelViews. See more info there. |
63 | 69 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
70 |
vLayout <Symbol> controls vertical layout; ignored in this |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
71 |
class, but used in Horizontal- and |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
72 |
VerticalPanelViews. See more info there. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
73 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
74 |
horizontalSpace <Integer> number of pixels to use as space between elements |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
75 |
defaults to ViewSpacing, which is 1mm |
63 | 76 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
77 |
verticalSpace <Integer> number of pixels to use as space between elements |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
78 |
defaults to ViewSpacing, which is 1mm |
63 | 79 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
80 |
mustRearrange <Boolean> internal flag, if rearrangement is needed |
63 | 81 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
82 |
elementsChangeSize |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
83 |
<Boolean> if true, the panel takes care of this situation. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
84 |
By default, this is false. |
125 | 85 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
86 |
ignoreInvisibleComponents |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
87 |
<Boolean> if true, invisible (i.e. hidden) views |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
88 |
are not considered in the layout computation. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
89 |
If false, they will lead to additional space |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
90 |
between visible components. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
91 |
The default is false. |
585 | 92 |
|
93 |
[author:] |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
94 |
Claus Gittinger |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
95 |
" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
96 |
! |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
97 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
98 |
examples |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
99 |
" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
100 |
The generic panelView simply tries to get its |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
101 |
components arranged for fitting them all into |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
102 |
its area. No special layout is done, except for |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
103 |
horizontal/vertical spacings. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
104 |
The view is filled top-left to bottom-right |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
105 |
with subcomponents. Subcomponents are not resized. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
106 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
107 |
example: |
1604 | 108 |
[exBegin] |
109 |
|v p b1 b2 b3| |
|
110 |
||
111 |
v := StandardSystemView new. |
|
112 |
v label:'panel'. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
113 |
|
1604 | 114 |
p := PanelView in:v. |
115 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
116 |
b1 := Button label:'button1' in:p. |
|
117 |
b2 := Button label:'button2' in:p. |
|
118 |
b3 := Button label:'button3' in:p. |
|
119 |
v extent:300 @ 100. |
|
120 |
v open |
|
121 |
[exEnd] |
|
122 |
||
123 |
||
124 |
invisible component not considered in layout: |
|
125 |
[exBegin] |
|
126 |
|v p b1 b2 b3| |
|
127 |
||
128 |
v := StandardSystemView new. |
|
129 |
v label:'panel'. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
130 |
|
1604 | 131 |
p := PanelView in:v. |
132 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
133 |
b1 := Button label:'button1' in:p. |
|
134 |
b2 := Button label:'button2' in:p. |
|
135 |
b2 beInvisible. |
|
136 |
b3 := Button label:'button3' in:p. |
|
137 |
v extent:300 @ 100. |
|
138 |
v open |
|
139 |
[exEnd] |
|
140 |
||
141 |
invisible component considered in layout: |
|
142 |
[exBegin] |
|
143 |
|v p b1 b2 b3| |
|
144 |
||
145 |
v := StandardSystemView new. |
|
146 |
v label:'panel'. |
|
147 |
||
148 |
p := PanelView in:v. |
|
149 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
150 |
p ignoreInvisibleComponents:false. |
|
151 |
b1 := Button label:'button1' in:p. |
|
152 |
b2 := Button label:'button2' in:p. |
|
153 |
b2 beInvisible. |
|
154 |
b3 := Button label:'button3' in:p. |
|
155 |
v extent:300 @ 100. |
|
156 |
v open |
|
157 |
[exEnd] |
|
38 | 158 |
" |
787
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
159 |
! ! |
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
160 |
|
202 | 161 |
!PanelView methodsFor:'accessing'! |
162 |
||
1959 | 163 |
elementsChangeSize |
164 |
"tell the panel if elements are to change their size by themselfes |
|
165 |
(for example, Labels or Buttons may do so if their contents changes). |
|
166 |
Setting this flag will make the panel reorganize the elements whenever |
|
167 |
any element changes its size." |
|
168 |
||
169 |
^ elementsChangeSize |
|
170 |
! |
|
171 |
||
202 | 172 |
elementsChangeSize:aBoolean |
173 |
"tell the panel if elements are to change their size by themselfes |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
174 |
(for example, Labels or Buttons may do so if their contents changes). |
202 | 175 |
Setting this flag will make the panel reorganize the elements whenever |
176 |
any element changes its size." |
|
177 |
||
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
178 |
|subViews| |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
179 |
|
202 | 180 |
elementsChangeSize := aBoolean. |
181 |
aBoolean ifTrue:[ |
|
2006 | 182 |
self makeMyselfDependentOnSubviews. |
202 | 183 |
] |
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
184 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
185 |
"Modified: / 17.1.1998 / 00:19:14 / cg" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
186 |
! |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
187 |
|
1036 | 188 |
horizontalLayout |
189 |
"not supported by this view" |
|
190 |
||
191 |
^ nil |
|
192 |
! |
|
193 |
||
194 |
horizontalLayout:aLayoutSymbol |
|
195 |
"not supported by this view" |
|
196 |
||
197 |
! |
|
198 |
||
1072 | 199 |
horizontalSpace |
200 |
"return the horizontal space between elements on pixels (default is 1mm)" |
|
201 |
||
202 |
^ horizontalSpace |
|
203 |
! |
|
204 |
||
202 | 205 |
horizontalSpace:numberOfPixels |
206 |
"set the horizontal space between elements on pixels (default is 1mm)" |
|
207 |
||
208 |
horizontalSpace ~= numberOfPixels ifTrue:[ |
|
209 |
horizontalSpace := numberOfPixels. |
|
210 |
self layoutChanged |
|
211 |
] |
|
212 |
! |
|
213 |
||
1423 | 214 |
ignoreInvisibleComponents |
215 |
"return the flag which controls if invisible (unrealized) |
|
216 |
components should be ignored in the layout computation. |
|
217 |
By default, it is false, which means that invisible components will |
|
218 |
lead to a visible space between visible components" |
|
219 |
||
220 |
^ ignoreInvisibleComponents |
|
221 |
! |
|
222 |
||
223 |
ignoreInvisibleComponents:aBoolean |
|
224 |
"set/clears the flag which controls if invisible (unrealized) |
|
225 |
components should be ignored in the layout computation. |
|
226 |
By default, it is false, which means that invisible components will |
|
2006 | 227 |
lead to a visible space between visible components." |
1423 | 228 |
|
1605
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
229 |
(ignoreInvisibleComponents ~~ aBoolean) ifTrue:[ |
2006 | 230 |
aBoolean ifTrue:[ |
231 |
self makeMyselfDependentOnSubviews. |
|
232 |
]. |
|
1605
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
233 |
ignoreInvisibleComponents := aBoolean. |
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
234 |
self layoutChanged |
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
235 |
] |
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
236 |
|
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
237 |
"Modified: / 20.7.1998 / 14:12:38 / cg" |
1423 | 238 |
! |
239 |
||
202 | 240 |
space:numberOfPixels |
241 |
"set the space between elements in pixels (default is 1mm) for both directions" |
|
242 |
||
243 |
(verticalSpace ~= numberOfPixels |
|
244 |
or:[horizontalSpace ~= numberOfPixels]) ifTrue:[ |
|
245 |
horizontalSpace := numberOfPixels. |
|
246 |
verticalSpace := numberOfPixels. |
|
247 |
self layoutChanged |
|
248 |
] |
|
249 |
! |
|
250 |
||
1036 | 251 |
verticalLayout |
252 |
"not supported by this view" |
|
253 |
||
254 |
^ nil |
|
255 |
! |
|
256 |
||
257 |
verticalLayout:aLayoutSymbol |
|
258 |
"not supported by this view" |
|
259 |
||
260 |
! |
|
261 |
||
1072 | 262 |
verticalSpace |
263 |
"return the vertical space between elements on pixels (default is 1mm)" |
|
264 |
||
265 |
^ verticalSpace |
|
266 |
! |
|
267 |
||
202 | 268 |
verticalSpace:numberOfPixels |
269 |
"set the vertical space between elements (in pixels). |
|
270 |
The default is computed for 1mm spacing." |
|
271 |
||
272 |
verticalSpace ~= numberOfPixels ifTrue:[ |
|
273 |
verticalSpace := numberOfPixels. |
|
274 |
self layoutChanged |
|
275 |
] |
|
276 |
! ! |
|
277 |
||
278 |
!PanelView methodsFor:'adding & removing subviews'! |
|
279 |
||
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
280 |
addComponent:aComponent |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
281 |
"redefined to recompute layout when a component is added" |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
282 |
|
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
283 |
super addComponent:aComponent. |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
284 |
self addedView:aComponent |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
285 |
|
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
286 |
"Created: 28.1.1997 / 17:44:18 / cg" |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
287 |
! |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
288 |
|
202 | 289 |
addSubView:aView |
290 |
"redefined to recompute layout when a subview is added" |
|
291 |
||
292 |
super addSubView:aView. |
|
293 |
self addedView:aView |
|
294 |
! |
|
295 |
||
296 |
addSubView:newView after:aView |
|
297 |
"redefined to recompute layout when a subview is added" |
|
298 |
||
299 |
super addSubView:newView after:aView. |
|
787
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
300 |
self addedView:newView |
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
301 |
|
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
302 |
"Modified: 15.7.1996 / 10:15:04 / cg" |
202 | 303 |
! |
304 |
||
305 |
addSubView:newView before:aView |
|
306 |
"redefined to recompute layout when a subview is added" |
|
307 |
||
308 |
super addSubView:newView before:aView. |
|
787
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
309 |
self addedView:newView |
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
310 |
|
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
311 |
"Modified: 15.7.1996 / 10:14:39 / cg" |
202 | 312 |
! |
313 |
||
314 |
removeSubView:aView |
|
315 |
"redefined to recompute layout when a subview is removed" |
|
316 |
||
317 |
super removeSubView:aView. |
|
318 |
aView removeDependent:self. |
|
319 |
self layoutChanged |
|
38 | 320 |
! ! |
0 | 321 |
|
1159 | 322 |
!PanelView methodsFor:'enumerating subviews'! |
323 |
||
324 |
changeSequenceOrderFor:aSubView to:anIndex |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
325 |
"change a subview's position in the subviews collection |
1159 | 326 |
" |
327 |
|success| |
|
328 |
||
329 |
success := super changeSequenceOrderFor:aSubView to:anIndex. |
|
330 |
||
331 |
success ifTrue:[ |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
332 |
self layoutChanged. |
1159 | 333 |
]. |
334 |
^ success |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
335 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
336 |
" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
337 |
|panel comp1 comp2 comp3| |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
338 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
339 |
panel := HorizontalPanelView new. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
340 |
comp1 := Label label:'one' in:panel. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
341 |
comp2 := Label label:'two' in:panel. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
342 |
comp3 := Label label:'three' in:panel. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
343 |
panel open. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
344 |
Delay waitForSeconds:3. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
345 |
panel changeSequenceOrderFor:comp2 to:3. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
346 |
Delay waitForSeconds:3. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
347 |
panel changeSequenceOrderFor:comp2 to:1. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
348 |
" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
349 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
350 |
"Modified: / 17.1.1998 / 00:13:43 / cg" |
1159 | 351 |
! ! |
352 |
||
0 | 353 |
!PanelView methodsFor:'event processing'! |
354 |
||
355 |
sizeChanged:how |
|
119 | 356 |
"my size has changed - must rearrange elements" |
357 |
||
0 | 358 |
super sizeChanged:how. |
60 | 359 |
self layoutChanged |
125 | 360 |
! |
361 |
||
362 |
update:something with:aParameter from:changedObject |
|
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
363 |
"an element changed its size" |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
364 |
|
125 | 365 |
something == #sizeOfView ifTrue:[ |
2006 | 366 |
self layoutChanged. |
367 |
^ self |
|
368 |
]. |
|
369 |
something == #visibility ifTrue:[ |
|
370 |
self layoutChanged. |
|
371 |
^ self |
|
125 | 372 |
]. |
373 |
^ super update:something with:aParameter from:changedObject |
|
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
374 |
|
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
375 |
"Modified: 28.1.1997 / 17:52:44 / cg" |
0 | 376 |
! ! |
377 |
||
1821
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
378 |
!PanelView methodsFor:'focus handling'! |
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
379 |
|
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
380 |
wantsFocusWithButtonPress |
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
381 |
"no, do not catch the keyboard focus on button click" |
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
382 |
|
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
383 |
^ false |
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
384 |
|
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
385 |
|
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
386 |
! ! |
b57cc9dc2c08
changed request-focus-with-Button press
Claus Gittinger <cg@exept.de>
parents:
1605
diff
changeset
|
387 |
|
202 | 388 |
!PanelView methodsFor:'initialization'! |
389 |
||
390 |
initialize |
|
391 |
super initialize. |
|
392 |
||
393 |
hLayout := vLayout := #center. "/ notice, this is ignored in this class |
|
394 |
"/ used by subclasses only |
|
395 |
verticalSpace := ViewSpacing. |
|
396 |
horizontalSpace := ViewSpacing. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
397 |
mustRearrange := elementsChangeSize := false. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
398 |
ignoreInvisibleComponents := true. |
202 | 399 |
! |
400 |
||
401 |
realize |
|
402 |
mustRearrange ifTrue:[ |
|
403 |
self setChildPositions |
|
404 |
]. |
|
405 |
super realize |
|
406 |
! |
|
407 |
||
1216
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
408 |
resize |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
409 |
super resize. |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
410 |
mustRearrange ifTrue:[ |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
411 |
self setChildPositions |
1216
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
412 |
]. |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
413 |
! |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
414 |
|
202 | 415 |
setChildPositionsIfChanged |
416 |
"set all of my child positions - this is usually delayed, |
|
417 |
until the panel is actually shown (since we dont know, if more |
|
418 |
elements are to be added) thus avoiding repositioning the elements |
|
419 |
over and over. However, sometimes it is nescessary, to force positioning |
|
420 |
the elements, for example, before querying the relative position of |
|
421 |
an element (modalBoxes do so, to position the ok-button under the mouse |
|
422 |
pointer)." |
|
423 |
||
424 |
mustRearrange ifTrue:[ |
|
425 |
self setChildPositions |
|
426 |
]. |
|
427 |
||
428 |
! ! |
|
429 |
||
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
430 |
!PanelView methodsFor:'layout'! |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
431 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
432 |
setChildPositions |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
433 |
"(re)compute position of every child. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
434 |
This method is redefined for different layout characteristics - you may |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
435 |
even create subclasses with completely different geometry management." |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
436 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
437 |
|first xpos ypos maxHeightInRow thisRow subViews ext| |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
438 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
439 |
subViews := self subViewsToConsider. |
1423 | 440 |
subViews size == 0 ifTrue:[^ self]. |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
441 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
442 |
extentChanged ifTrue:[ |
1423 | 443 |
ext := self computeExtent. |
444 |
width := ext x. |
|
445 |
height := ext y. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
446 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
447 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
448 |
xpos := horizontalSpace. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
449 |
ypos := verticalSpace. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
450 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
451 |
maxHeightInRow := 0. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
452 |
first := true. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
453 |
thisRow := OrderedCollection new. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
454 |
subViews do:[:child | |
1423 | 455 |
"go to next row, if this subview won't fit" |
456 |
first ifFalse: [ |
|
457 |
(xpos + child widthIncludingBorder + horizontalSpace) > width |
|
458 |
ifTrue: [ |
|
459 |
thisRow notEmpty ifTrue:[ |
|
460 |
thisRow do:[:rowElement | |
|
461 |
rowElement heightIncludingBorder < maxHeightInRow ifTrue:[ |
|
462 |
rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder)) |
|
463 |
] |
|
464 |
] |
|
465 |
]. |
|
466 |
ypos := ypos + verticalSpace + maxHeightInRow. |
|
467 |
xpos := horizontalSpace. |
|
468 |
maxHeightInRow := 0. |
|
469 |
thisRow := OrderedCollection new. |
|
470 |
] |
|
471 |
]. |
|
472 |
thisRow add:child. |
|
473 |
child origin:(xpos@ypos). |
|
474 |
xpos := xpos + (child widthIncludingBorder) + horizontalSpace. |
|
475 |
(maxHeightInRow < (child heightIncludingBorder)) ifTrue:[ |
|
476 |
maxHeightInRow := child heightIncludingBorder |
|
477 |
]. |
|
478 |
first := false |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
479 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
480 |
thisRow notEmpty ifTrue:[ |
1423 | 481 |
thisRow do:[:rowElement | |
482 |
rowElement heightIncludingBorder < maxHeightInRow ifTrue:[ |
|
483 |
rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder)) |
|
484 |
] |
|
485 |
] |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
486 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
487 |
mustRearrange := false |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
488 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
489 |
"Modified: / 17.1.1998 / 00:17:19 / cg" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
490 |
! ! |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
491 |
|
0 | 492 |
!PanelView methodsFor:'private'! |
493 |
||
202 | 494 |
addedView:aView |
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
495 |
"added a new element - rearrange components" |
202 | 496 |
|
2006 | 497 |
(elementsChangeSize or:[ignoreInvisibleComponents]) ifTrue:[ |
498 |
aView addDependent:self |
|
787
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
499 |
]. |
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
500 |
aView resize. |
788
653fd742b5b0
extent handling when adding views
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
501 |
"/ explicitExtent ~~ true ifTrue:[ |
653fd742b5b0
extent handling when adding views
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
502 |
"/ self resize |
653fd742b5b0
extent handling when adding views
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
503 |
"/ ]. |
202 | 504 |
self layoutChanged |
787
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
505 |
|
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
506 |
"Modified: 28.1.1997 / 17:45:10 / cg" |
202 | 507 |
! |
508 |
||
0 | 509 |
layoutChanged |
119 | 510 |
"called whenever repositioning is required. If the panel view is |
511 |
already visible, reposition elements right now. Otherwise, remember |
|
512 |
that a repositioning is needed to do so when the view eventually becomes |
|
513 |
visible." |
|
514 |
||
15 | 515 |
shown ifTrue:[ |
60 | 516 |
self setChildPositions |
0 | 517 |
] ifFalse:[ |
60 | 518 |
mustRearrange := true |
0 | 519 |
] |
520 |
! |
|
521 |
||
2006 | 522 |
makeMyselfDependentOnSubviews |
523 |
(subViews := self subViews) notNil ifTrue:[ |
|
524 |
subViews do:[:aView | |
|
525 |
aView addDependent:self |
|
526 |
] |
|
527 |
] |
|
528 |
||
529 |
||
530 |
! |
|
531 |
||
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
532 |
subViewsToConsider |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
533 |
"return a collection of subviews which are to be considered in |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
534 |
the layout. If ignoreInvisibleComponents is true, only visible |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
535 |
components are considered; otherwise, all are considered." |
0 | 536 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
537 |
|subViews| |
1042 | 538 |
|
539 |
subViews := self subViews. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
540 |
subViews size ~~ 0 ifTrue:[ |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
541 |
ignoreInvisibleComponents ifTrue:[ |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
542 |
subViews := subViews |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
543 |
select:[:v | realized |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
544 |
ifTrue:[v realized] |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
545 |
ifFalse:[v isHiddenOnRealize not] |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
546 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
547 |
]. |
1042 | 548 |
]. |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
549 |
^ subViews |
1042 | 550 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
551 |
"Created: / 17.1.1998 / 00:17:05 / cg" |
0 | 552 |
! ! |
125 | 553 |
|
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
554 |
!PanelView class methodsFor:'documentation'! |
205 | 555 |
|
556 |
version |
|
2006 | 557 |
^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.31 1999-09-07 09:14:16 tm Exp $' |
205 | 558 |
! ! |