author | Claus Gittinger <cg@exept.de> |
Mon, 15 Feb 1999 13:39:53 +0100 | |
changeset 1739 | 3cb6e85d42c0 |
parent 1605 | 6ddd87c04fd5 |
child 1821 | b57cc9dc2c08 |
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 |
||
163 |
elementsChangeSize:aBoolean |
|
164 |
"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
|
165 |
(for example, Labels or Buttons may do so if their contents changes). |
202 | 166 |
Setting this flag will make the panel reorganize the elements whenever |
167 |
any element changes its size." |
|
168 |
||
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
169 |
|subViews| |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
170 |
|
202 | 171 |
elementsChangeSize := aBoolean. |
172 |
aBoolean ifTrue:[ |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
173 |
(subViews := self subViews) notNil ifTrue:[ |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
174 |
subViews do:[:aView | |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
175 |
aView addDependent:self |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
176 |
] |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
177 |
] |
202 | 178 |
] |
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
179 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
180 |
"Modified: / 17.1.1998 / 00:19:14 / cg" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
181 |
! |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
182 |
|
1036 | 183 |
horizontalLayout |
184 |
"not supported by this view" |
|
185 |
||
186 |
^ nil |
|
187 |
! |
|
188 |
||
189 |
horizontalLayout:aLayoutSymbol |
|
190 |
"not supported by this view" |
|
191 |
||
192 |
! |
|
193 |
||
1072 | 194 |
horizontalSpace |
195 |
"return the horizontal space between elements on pixels (default is 1mm)" |
|
196 |
||
197 |
^ horizontalSpace |
|
198 |
! |
|
199 |
||
202 | 200 |
horizontalSpace:numberOfPixels |
201 |
"set the horizontal space between elements on pixels (default is 1mm)" |
|
202 |
||
203 |
horizontalSpace ~= numberOfPixels ifTrue:[ |
|
204 |
horizontalSpace := numberOfPixels. |
|
205 |
self layoutChanged |
|
206 |
] |
|
207 |
! |
|
208 |
||
1423 | 209 |
ignoreInvisibleComponents |
210 |
"return the flag which controls if invisible (unrealized) |
|
211 |
components should be ignored in the layout computation. |
|
212 |
By default, it is false, which means that invisible components will |
|
213 |
lead to a visible space between visible components" |
|
214 |
||
215 |
^ ignoreInvisibleComponents |
|
216 |
! |
|
217 |
||
218 |
ignoreInvisibleComponents:aBoolean |
|
219 |
"set/clears the flag which controls if invisible (unrealized) |
|
220 |
components should be ignored in the layout computation. |
|
221 |
By default, it is false, which means that invisible components will |
|
222 |
lead to a visible space between visible components" |
|
223 |
||
1605
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
224 |
(ignoreInvisibleComponents ~~ aBoolean) ifTrue:[ |
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
225 |
ignoreInvisibleComponents := aBoolean. |
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
226 |
self layoutChanged |
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
227 |
] |
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
228 |
|
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
229 |
"Modified: / 20.7.1998 / 14:12:38 / cg" |
1423 | 230 |
! |
231 |
||
202 | 232 |
space:numberOfPixels |
233 |
"set the space between elements in pixels (default is 1mm) for both directions" |
|
234 |
||
235 |
(verticalSpace ~= numberOfPixels |
|
236 |
or:[horizontalSpace ~= numberOfPixels]) ifTrue:[ |
|
237 |
horizontalSpace := numberOfPixels. |
|
238 |
verticalSpace := numberOfPixels. |
|
239 |
self layoutChanged |
|
240 |
] |
|
241 |
! |
|
242 |
||
1036 | 243 |
verticalLayout |
244 |
"not supported by this view" |
|
245 |
||
246 |
^ nil |
|
247 |
! |
|
248 |
||
249 |
verticalLayout:aLayoutSymbol |
|
250 |
"not supported by this view" |
|
251 |
||
252 |
! |
|
253 |
||
1072 | 254 |
verticalSpace |
255 |
"return the vertical space between elements on pixels (default is 1mm)" |
|
256 |
||
257 |
^ verticalSpace |
|
258 |
! |
|
259 |
||
202 | 260 |
verticalSpace:numberOfPixels |
261 |
"set the vertical space between elements (in pixels). |
|
262 |
The default is computed for 1mm spacing." |
|
263 |
||
264 |
verticalSpace ~= numberOfPixels ifTrue:[ |
|
265 |
verticalSpace := numberOfPixels. |
|
266 |
self layoutChanged |
|
267 |
] |
|
268 |
! ! |
|
269 |
||
270 |
!PanelView methodsFor:'adding & removing subviews'! |
|
271 |
||
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
272 |
addComponent:aComponent |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
273 |
"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
|
274 |
|
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
275 |
super addComponent:aComponent. |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
276 |
self addedView:aComponent |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
277 |
|
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
278 |
"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
|
279 |
! |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
280 |
|
202 | 281 |
addSubView:aView |
282 |
"redefined to recompute layout when a subview is added" |
|
283 |
||
284 |
super addSubView:aView. |
|
285 |
self addedView:aView |
|
286 |
! |
|
287 |
||
288 |
addSubView:newView after:aView |
|
289 |
"redefined to recompute layout when a subview is added" |
|
290 |
||
291 |
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
|
292 |
self addedView:newView |
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
293 |
|
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
294 |
"Modified: 15.7.1996 / 10:15:04 / cg" |
202 | 295 |
! |
296 |
||
297 |
addSubView:newView before:aView |
|
298 |
"redefined to recompute layout when a subview is added" |
|
299 |
||
300 |
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
|
301 |
self addedView:newView |
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
302 |
|
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
303 |
"Modified: 15.7.1996 / 10:14:39 / cg" |
202 | 304 |
! |
305 |
||
306 |
removeSubView:aView |
|
307 |
"redefined to recompute layout when a subview is removed" |
|
308 |
||
309 |
super removeSubView:aView. |
|
310 |
aView removeDependent:self. |
|
311 |
self layoutChanged |
|
38 | 312 |
! ! |
0 | 313 |
|
1159 | 314 |
!PanelView methodsFor:'enumerating subviews'! |
315 |
||
316 |
changeSequenceOrderFor:aSubView to:anIndex |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
317 |
"change a subview's position in the subviews collection |
1159 | 318 |
" |
319 |
|success| |
|
320 |
||
321 |
success := super changeSequenceOrderFor:aSubView to:anIndex. |
|
322 |
||
323 |
success ifTrue:[ |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
324 |
self layoutChanged. |
1159 | 325 |
]. |
326 |
^ success |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
327 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
328 |
" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
329 |
|panel comp1 comp2 comp3| |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
330 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
331 |
panel := HorizontalPanelView new. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
332 |
comp1 := Label label:'one' in:panel. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
333 |
comp2 := Label label:'two' in:panel. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
334 |
comp3 := Label label:'three' in:panel. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
335 |
panel open. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
336 |
Delay waitForSeconds:3. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
337 |
panel changeSequenceOrderFor:comp2 to:3. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
338 |
Delay waitForSeconds:3. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
339 |
panel changeSequenceOrderFor:comp2 to:1. |
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 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
342 |
"Modified: / 17.1.1998 / 00:13:43 / cg" |
1159 | 343 |
! ! |
344 |
||
0 | 345 |
!PanelView methodsFor:'event processing'! |
346 |
||
347 |
sizeChanged:how |
|
119 | 348 |
"my size has changed - must rearrange elements" |
349 |
||
0 | 350 |
super sizeChanged:how. |
60 | 351 |
self layoutChanged |
125 | 352 |
! |
353 |
||
354 |
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
|
355 |
"an element changed its size" |
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
356 |
|
125 | 357 |
something == #sizeOfView ifTrue:[ |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
358 |
self layoutChanged. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
359 |
^ self |
125 | 360 |
]. |
361 |
^ 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
|
362 |
|
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
363 |
"Modified: 28.1.1997 / 17:52:44 / cg" |
0 | 364 |
! ! |
365 |
||
202 | 366 |
!PanelView methodsFor:'initialization'! |
367 |
||
368 |
initialize |
|
369 |
super initialize. |
|
370 |
||
371 |
hLayout := vLayout := #center. "/ notice, this is ignored in this class |
|
372 |
"/ used by subclasses only |
|
373 |
verticalSpace := ViewSpacing. |
|
374 |
horizontalSpace := ViewSpacing. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
375 |
mustRearrange := elementsChangeSize := false. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
376 |
ignoreInvisibleComponents := true. |
202 | 377 |
! |
378 |
||
379 |
realize |
|
380 |
mustRearrange ifTrue:[ |
|
381 |
self setChildPositions |
|
382 |
]. |
|
383 |
super realize |
|
384 |
! |
|
385 |
||
1216
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
386 |
resize |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
387 |
super resize. |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
388 |
mustRearrange ifTrue:[ |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
389 |
self setChildPositions |
1216
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
390 |
]. |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
391 |
! |
3506a6474c42
setChildPos if extent is set in create->resize->prefExtent
ca
parents:
1159
diff
changeset
|
392 |
|
202 | 393 |
setChildPositionsIfChanged |
394 |
"set all of my child positions - this is usually delayed, |
|
395 |
until the panel is actually shown (since we dont know, if more |
|
396 |
elements are to be added) thus avoiding repositioning the elements |
|
397 |
over and over. However, sometimes it is nescessary, to force positioning |
|
398 |
the elements, for example, before querying the relative position of |
|
399 |
an element (modalBoxes do so, to position the ok-button under the mouse |
|
400 |
pointer)." |
|
401 |
||
402 |
mustRearrange ifTrue:[ |
|
403 |
self setChildPositions |
|
404 |
]. |
|
405 |
||
406 |
! ! |
|
407 |
||
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
408 |
!PanelView methodsFor:'layout'! |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
409 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
410 |
setChildPositions |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
411 |
"(re)compute position of every child. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
412 |
This method is redefined for different layout characteristics - you may |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
413 |
even create subclasses with completely different geometry management." |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
414 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
415 |
|first xpos ypos maxHeightInRow thisRow subViews ext| |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
416 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
417 |
subViews := self subViewsToConsider. |
1423 | 418 |
subViews size == 0 ifTrue:[^ self]. |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
419 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
420 |
extentChanged ifTrue:[ |
1423 | 421 |
ext := self computeExtent. |
422 |
width := ext x. |
|
423 |
height := ext y. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
424 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
425 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
426 |
xpos := horizontalSpace. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
427 |
ypos := verticalSpace. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
428 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
429 |
maxHeightInRow := 0. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
430 |
first := true. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
431 |
thisRow := OrderedCollection new. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
432 |
subViews do:[:child | |
1423 | 433 |
"go to next row, if this subview won't fit" |
434 |
first ifFalse: [ |
|
435 |
(xpos + child widthIncludingBorder + horizontalSpace) > width |
|
436 |
ifTrue: [ |
|
437 |
thisRow notEmpty ifTrue:[ |
|
438 |
thisRow do:[:rowElement | |
|
439 |
rowElement heightIncludingBorder < maxHeightInRow ifTrue:[ |
|
440 |
rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder)) |
|
441 |
] |
|
442 |
] |
|
443 |
]. |
|
444 |
ypos := ypos + verticalSpace + maxHeightInRow. |
|
445 |
xpos := horizontalSpace. |
|
446 |
maxHeightInRow := 0. |
|
447 |
thisRow := OrderedCollection new. |
|
448 |
] |
|
449 |
]. |
|
450 |
thisRow add:child. |
|
451 |
child origin:(xpos@ypos). |
|
452 |
xpos := xpos + (child widthIncludingBorder) + horizontalSpace. |
|
453 |
(maxHeightInRow < (child heightIncludingBorder)) ifTrue:[ |
|
454 |
maxHeightInRow := child heightIncludingBorder |
|
455 |
]. |
|
456 |
first := false |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
457 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
458 |
thisRow notEmpty ifTrue:[ |
1423 | 459 |
thisRow do:[:rowElement | |
460 |
rowElement heightIncludingBorder < maxHeightInRow ifTrue:[ |
|
461 |
rowElement top:(rowElement top + (maxHeightInRow - rowElement heightIncludingBorder)) |
|
462 |
] |
|
463 |
] |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
464 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
465 |
mustRearrange := false |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
466 |
|
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
467 |
"Modified: / 17.1.1998 / 00:17:19 / cg" |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
468 |
! ! |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
469 |
|
0 | 470 |
!PanelView methodsFor:'private'! |
471 |
||
202 | 472 |
addedView:aView |
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
473 |
"added a new element - rearrange components" |
202 | 474 |
|
475 |
elementsChangeSize ifTrue:[ |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
476 |
aView addDependent:self |
787
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
477 |
]. |
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
478 |
aView resize. |
788
653fd742b5b0
extent handling when adding views
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
479 |
"/ explicitExtent ~~ true ifTrue:[ |
653fd742b5b0
extent handling when adding views
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
480 |
"/ self resize |
653fd742b5b0
extent handling when adding views
Claus Gittinger <cg@exept.de>
parents:
787
diff
changeset
|
481 |
"/ ]. |
202 | 482 |
self layoutChanged |
787
c568dfd06f11
recompute & resize to the preferredExtent when views are added
Claus Gittinger <cg@exept.de>
parents:
593
diff
changeset
|
483 |
|
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
484 |
"Modified: 28.1.1997 / 17:45:10 / cg" |
202 | 485 |
! |
486 |
||
0 | 487 |
layoutChanged |
119 | 488 |
"called whenever repositioning is required. If the panel view is |
489 |
already visible, reposition elements right now. Otherwise, remember |
|
490 |
that a repositioning is needed to do so when the view eventually becomes |
|
491 |
visible." |
|
492 |
||
15 | 493 |
shown ifTrue:[ |
60 | 494 |
self setChildPositions |
0 | 495 |
] ifFalse:[ |
60 | 496 |
mustRearrange := true |
0 | 497 |
] |
498 |
! |
|
499 |
||
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
500 |
subViewsToConsider |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
501 |
"return a collection of subviews which are to be considered in |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
502 |
the layout. If ignoreInvisibleComponents is true, only visible |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
503 |
components are considered; otherwise, all are considered." |
0 | 504 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
505 |
|subViews| |
1042 | 506 |
|
507 |
subViews := self subViews. |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
508 |
subViews size ~~ 0 ifTrue:[ |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
509 |
ignoreInvisibleComponents ifTrue:[ |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
510 |
subViews := subViews |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
511 |
select:[:v | realized |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
512 |
ifTrue:[v realized] |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
513 |
ifFalse:[v isHiddenOnRealize not] |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
514 |
]. |
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
515 |
]. |
1042 | 516 |
]. |
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
517 |
^ subViews |
1042 | 518 |
|
1418
3397ec6b8419
added ignoreInvisibleComponents stuff
Claus Gittinger <cg@exept.de>
parents:
1216
diff
changeset
|
519 |
"Created: / 17.1.1998 / 00:17:05 / cg" |
0 | 520 |
! ! |
125 | 521 |
|
980
6079922a5519
eliminated references to subViews instance variable (will vanish)
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
522 |
!PanelView class methodsFor:'documentation'! |
205 | 523 |
|
524 |
version |
|
1605
6ddd87c04fd5
recompute layout when ignoreInvisible* is changed.
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
525 |
^ '$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.28 1998-07-20 12:13:36 cg Exp $' |
205 | 526 |
! ! |