1 | <html> |
---|
2 | <head> |
---|
3 | <title>VBox Layout</title> |
---|
4 | <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css"/> |
---|
5 | |
---|
6 | <!-- GC --> |
---|
7 | <!-- LIBS --> |
---|
8 | <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script> |
---|
9 | <!-- ENDLIBS --> |
---|
10 | |
---|
11 | <script type="text/javascript" src="../../ext-all.js"></script> |
---|
12 | |
---|
13 | <style type="text/css"> |
---|
14 | html, body { |
---|
15 | font: normal 12px verdana; |
---|
16 | margin: 0; |
---|
17 | padding: 0; |
---|
18 | border: 0 none; |
---|
19 | } |
---|
20 | </style> |
---|
21 | <script type="text/javascript"> |
---|
22 | |
---|
23 | Ext.onReady(function() { |
---|
24 | |
---|
25 | var replace = function(config){ |
---|
26 | var btns = Ext.getCmp('btns'); |
---|
27 | btns.remove(0); |
---|
28 | btns.add(config); |
---|
29 | |
---|
30 | btns.doLayout(); |
---|
31 | } |
---|
32 | |
---|
33 | |
---|
34 | var viewport = new Ext.Viewport({ |
---|
35 | layout:'border', |
---|
36 | |
---|
37 | items: [{ |
---|
38 | id:'btns', |
---|
39 | region:'west', |
---|
40 | baseCls:'x-plain', |
---|
41 | split:true, |
---|
42 | width:150, |
---|
43 | minWidth: 100, |
---|
44 | maxWidth: 250, |
---|
45 | layout:'fit', |
---|
46 | margins: '5 0 5 5', |
---|
47 | items: { |
---|
48 | baseCls: 'x-plain', |
---|
49 | html: '<p style="padding:10px;color:#556677;font-size:11px;">Select a configuration to the right »</p>' |
---|
50 | } |
---|
51 | }, { |
---|
52 | region:'center', |
---|
53 | margins: '5 5 5 0', |
---|
54 | layout:{ |
---|
55 | type:'vbox', |
---|
56 | align:'stretch' |
---|
57 | }, |
---|
58 | items:[{ |
---|
59 | baseCls:'x-plain', |
---|
60 | layout: { |
---|
61 | type:'hbox', |
---|
62 | padding: 10 |
---|
63 | }, |
---|
64 | defaults:{ |
---|
65 | margins:'0 5 0 0', |
---|
66 | pressed: false, |
---|
67 | toggleGroup:'btns', |
---|
68 | allowDepress: false |
---|
69 | }, |
---|
70 | items: [{ |
---|
71 | xtype:'button', |
---|
72 | text: 'Spaced', |
---|
73 | handler: function(){ |
---|
74 | replace({ |
---|
75 | layout: { |
---|
76 | type:'vbox', |
---|
77 | padding:'5', |
---|
78 | align:'left' |
---|
79 | }, |
---|
80 | defaults:{margins:'0 0 5 0'}, |
---|
81 | items:[{ |
---|
82 | xtype:'button', |
---|
83 | text: 'Button 1' |
---|
84 | },{ |
---|
85 | xtype:'spacer', |
---|
86 | flex:1 |
---|
87 | },{ |
---|
88 | xtype:'button', |
---|
89 | text: 'Button 2' |
---|
90 | },{ |
---|
91 | xtype:'button', |
---|
92 | text: 'Button 3' |
---|
93 | },{ |
---|
94 | xtype:'button', |
---|
95 | text: 'Button 4', |
---|
96 | margins:'0' |
---|
97 | }] |
---|
98 | }); |
---|
99 | } |
---|
100 | },{ |
---|
101 | xtype:'button', |
---|
102 | text: 'Multi-Spaced', |
---|
103 | handler: function(){ |
---|
104 | replace({ |
---|
105 | layout: { |
---|
106 | type:'vbox', |
---|
107 | padding:'5', |
---|
108 | align:'left' |
---|
109 | }, |
---|
110 | defaults:{margins:'0 0 5 0'}, |
---|
111 | items:[{ |
---|
112 | xtype:'button', |
---|
113 | text: 'Button 1' |
---|
114 | },{ |
---|
115 | xtype:'spacer', |
---|
116 | flex:1 |
---|
117 | },{ |
---|
118 | xtype:'button', |
---|
119 | text: 'Button 2' |
---|
120 | },{ |
---|
121 | xtype:'spacer', |
---|
122 | flex:1 |
---|
123 | },{ |
---|
124 | xtype:'button', |
---|
125 | text: 'Button 3' |
---|
126 | },{ |
---|
127 | xtype:'spacer', |
---|
128 | flex:1 |
---|
129 | },{ |
---|
130 | xtype:'button', |
---|
131 | text: 'Button 4', |
---|
132 | margins:'0' |
---|
133 | }] |
---|
134 | }); |
---|
135 | } |
---|
136 | },{ |
---|
137 | xtype:'button', |
---|
138 | text: 'Align: top', |
---|
139 | handler: function(){ |
---|
140 | replace({ |
---|
141 | layout: { |
---|
142 | type:'vbox', |
---|
143 | padding:'5', |
---|
144 | align:'left' |
---|
145 | }, |
---|
146 | defaults:{margins:'0 0 5 0'}, |
---|
147 | items:[{ |
---|
148 | xtype:'button', |
---|
149 | text: 'Button 1' |
---|
150 | },{ |
---|
151 | xtype:'button', |
---|
152 | text: 'Button 2' |
---|
153 | },{ |
---|
154 | xtype:'button', |
---|
155 | text: 'Button 3' |
---|
156 | },{ |
---|
157 | xtype:'button', |
---|
158 | text: 'Button 4' |
---|
159 | }] |
---|
160 | }); |
---|
161 | } |
---|
162 | },{ |
---|
163 | xtype:'button', |
---|
164 | text: 'Align: middle', |
---|
165 | handler: function(){ |
---|
166 | replace({ |
---|
167 | layout: { |
---|
168 | type:'vbox', |
---|
169 | padding:'5', |
---|
170 | align:'center' |
---|
171 | }, |
---|
172 | defaults:{margins:'0 0 5 0'}, |
---|
173 | items:[{ |
---|
174 | xtype:'button', |
---|
175 | text: 'Button 1' |
---|
176 | },{ |
---|
177 | xtype:'button', |
---|
178 | text: 'Button 2' |
---|
179 | },{ |
---|
180 | xtype:'button', |
---|
181 | text: 'Button 3' |
---|
182 | },{ |
---|
183 | xtype:'button', |
---|
184 | text: 'Button 4' |
---|
185 | }] |
---|
186 | }); |
---|
187 | } |
---|
188 | },{ |
---|
189 | xtype:'button', |
---|
190 | text: 'Align: stretch', |
---|
191 | handler: function(){ |
---|
192 | replace({ |
---|
193 | layout: { |
---|
194 | type:'vbox', |
---|
195 | padding:'5', |
---|
196 | align:'stretch' |
---|
197 | }, |
---|
198 | defaults:{margins:'0 0 5 0'}, |
---|
199 | items:[{ |
---|
200 | xtype:'button', |
---|
201 | text: 'Button 1' |
---|
202 | },{ |
---|
203 | xtype:'button', |
---|
204 | text: 'Button 2' |
---|
205 | },{ |
---|
206 | xtype:'button', |
---|
207 | text: 'Button 3' |
---|
208 | },{ |
---|
209 | xtype:'button', |
---|
210 | text: 'Button 4' |
---|
211 | }] |
---|
212 | }); |
---|
213 | } |
---|
214 | },{ |
---|
215 | xtype:'button', |
---|
216 | text: 'Align: stretchmax', |
---|
217 | handler: function(){ |
---|
218 | replace({ |
---|
219 | layout: { |
---|
220 | type:'vbox', |
---|
221 | padding:'5', |
---|
222 | align:'stretchmax' |
---|
223 | }, |
---|
224 | defaults:{margins:'0 0 5 0'}, |
---|
225 | items:[{ |
---|
226 | xtype:'button', |
---|
227 | text: 'Button 1' |
---|
228 | },{ |
---|
229 | xtype:'button', |
---|
230 | text: 'Button 2' |
---|
231 | },{ |
---|
232 | xtype:'button', |
---|
233 | text: 'Button 3' |
---|
234 | },{ |
---|
235 | xtype:'button', |
---|
236 | text: 'Button 4' |
---|
237 | }] |
---|
238 | }); |
---|
239 | } |
---|
240 | }] |
---|
241 | },{ |
---|
242 | baseCls:'x-plain', |
---|
243 | layout: { |
---|
244 | type:'hbox', |
---|
245 | padding: '0 10 10' |
---|
246 | }, |
---|
247 | defaults:{ |
---|
248 | margins:'0 5 0 0', |
---|
249 | pressed: false, |
---|
250 | toggleGroup:'btns', |
---|
251 | allowDepress: false |
---|
252 | }, |
---|
253 | items: [{ |
---|
254 | xtype:'button', |
---|
255 | text: 'Flex: All even', |
---|
256 | handler: function(){ |
---|
257 | replace({ |
---|
258 | layout: { |
---|
259 | type:'vbox', |
---|
260 | padding:'5', |
---|
261 | align:'center' |
---|
262 | }, |
---|
263 | defaults:{margins:'0 0 5 0'}, |
---|
264 | items:[{ |
---|
265 | xtype:'button', |
---|
266 | text: 'Button 1', |
---|
267 | flex:1 |
---|
268 | },{ |
---|
269 | xtype:'button', |
---|
270 | text: 'Button 2', |
---|
271 | flex:1 |
---|
272 | },{ |
---|
273 | xtype:'button', |
---|
274 | text: 'Button 3', |
---|
275 | flex:1 |
---|
276 | },{ |
---|
277 | xtype:'button', |
---|
278 | text: 'Button 4', |
---|
279 | flex:1, |
---|
280 | margins:'0' |
---|
281 | }] |
---|
282 | }); |
---|
283 | } |
---|
284 | },{ |
---|
285 | xtype:'button', |
---|
286 | text: 'Flex: Ratio', |
---|
287 | handler: function(){ |
---|
288 | replace({ |
---|
289 | layout: { |
---|
290 | type:'vbox', |
---|
291 | padding:'5', |
---|
292 | align:'center' |
---|
293 | }, |
---|
294 | defaults:{margins:'0 0 5 0'}, |
---|
295 | items:[{ |
---|
296 | xtype:'button', |
---|
297 | text: 'Button 1', |
---|
298 | flex:1 |
---|
299 | },{ |
---|
300 | xtype:'button', |
---|
301 | text: 'Button 2', |
---|
302 | flex:1 |
---|
303 | },{ |
---|
304 | xtype:'button', |
---|
305 | text: 'Button 3', |
---|
306 | flex:1 |
---|
307 | },{ |
---|
308 | xtype:'button', |
---|
309 | text: 'Button 4', |
---|
310 | flex:3, |
---|
311 | margins:'0' |
---|
312 | }] |
---|
313 | }); |
---|
314 | } |
---|
315 | },{ |
---|
316 | xtype:'button', |
---|
317 | text: 'Flex + Stretch', |
---|
318 | handler: function(){ |
---|
319 | replace({ |
---|
320 | layout: { |
---|
321 | type:'vbox', |
---|
322 | padding:'5', |
---|
323 | align:'stretch' |
---|
324 | }, |
---|
325 | defaults:{margins:'0 0 5 0'}, |
---|
326 | items:[{ |
---|
327 | xtype:'button', |
---|
328 | text: 'Button 1', |
---|
329 | flex:1 |
---|
330 | },{ |
---|
331 | xtype:'button', |
---|
332 | text: 'Button 2', |
---|
333 | flex:1 |
---|
334 | },{ |
---|
335 | xtype:'button', |
---|
336 | text: 'Button 3', |
---|
337 | flex:1 |
---|
338 | },{ |
---|
339 | xtype:'button', |
---|
340 | text: 'Button 4', |
---|
341 | flex:3, |
---|
342 | margins:'0' |
---|
343 | }] |
---|
344 | }); |
---|
345 | } |
---|
346 | },{ |
---|
347 | xtype:'button', |
---|
348 | text: 'Pack: start', |
---|
349 | handler: function(){ |
---|
350 | replace({ |
---|
351 | layout: { |
---|
352 | type:'vbox', |
---|
353 | padding:'5', |
---|
354 | pack:'start', |
---|
355 | align:'center' |
---|
356 | }, |
---|
357 | defaults:{margins:'0 0 5 0'}, |
---|
358 | items:[{ |
---|
359 | xtype:'button', |
---|
360 | text: 'Button 1' |
---|
361 | },{ |
---|
362 | xtype:'button', |
---|
363 | text: 'Button 2' |
---|
364 | },{ |
---|
365 | xtype:'button', |
---|
366 | text: 'Button 3' |
---|
367 | },{ |
---|
368 | xtype:'button', |
---|
369 | text: 'Button 4' |
---|
370 | }] |
---|
371 | }); |
---|
372 | } |
---|
373 | },{ |
---|
374 | xtype:'button', |
---|
375 | text: 'Pack: center', |
---|
376 | handler: function(){ |
---|
377 | replace({ |
---|
378 | layout: { |
---|
379 | type:'vbox', |
---|
380 | padding:'5', |
---|
381 | pack:'center', |
---|
382 | align:'center' |
---|
383 | }, |
---|
384 | defaults:{margins:'0 0 5 0'}, |
---|
385 | items:[{ |
---|
386 | xtype:'button', |
---|
387 | text: 'Button 1' |
---|
388 | },{ |
---|
389 | xtype:'button', |
---|
390 | text: 'Button 2' |
---|
391 | },{ |
---|
392 | xtype:'button', |
---|
393 | text: 'Button 3' |
---|
394 | },{ |
---|
395 | xtype:'button', |
---|
396 | text: 'Button 4', |
---|
397 | margins:'0' |
---|
398 | }] |
---|
399 | }); |
---|
400 | } |
---|
401 | },{ |
---|
402 | xtype:'button', |
---|
403 | text: 'Pack: end', |
---|
404 | handler: function(){ |
---|
405 | replace({ |
---|
406 | layout: { |
---|
407 | type:'vbox', |
---|
408 | padding:'5', |
---|
409 | pack:'end', |
---|
410 | align:'center' |
---|
411 | }, |
---|
412 | defaults:{margins:'0 0 5 0'}, |
---|
413 | items:[{ |
---|
414 | xtype:'button', |
---|
415 | text: 'Button 1' |
---|
416 | },{ |
---|
417 | xtype:'button', |
---|
418 | text: 'Button 2' |
---|
419 | },{ |
---|
420 | xtype:'button', |
---|
421 | text: 'Button 3' |
---|
422 | },{ |
---|
423 | xtype:'button', |
---|
424 | text: 'Button 4', |
---|
425 | margins:'0' |
---|
426 | }] |
---|
427 | }); |
---|
428 | } |
---|
429 | }] |
---|
430 | }] |
---|
431 | }] |
---|
432 | }); |
---|
433 | }); |
---|
434 | </script> |
---|
435 | </head> |
---|
436 | <body> |
---|
437 | </body> |
---|
438 | </html> |
---|