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