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