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