1////////////////////////////////////////////////////////////////////////////////
2//
3//  ADOBE SYSTEMS INCORPORATED
4//  Copyright 2008 Adobe Systems Incorporated
5//  All Rights Reserved.
6//
7//  NOTICE: Adobe permits you to use, modify, and distribute this file
8//  in accordance with the terms of the license agreement accompanying it.
9//
10////////////////////////////////////////////////////////////////////////////////
11
12package spark.components
13{
14import flash.events.Event;
15import spark.layouts.TileLayout;
16import spark.layouts.supportClasses.LayoutBase;
17
18[IconFile("TileGroup.png")]
19
20[Exclude(name="layout", kind="property")]
21
22/**
23 *  The TileGroup container is an instance of the Group container
24 *  that uses the TileLayout class.
25 *  Do not modify the <code>layout</code> property.
26 *  Instead, use the properties of the TileGroup class to modify the
27 *  characteristics of the TileLayout class.
28 *
29 *  <p>The TileGroup container has the following default characteristics:</p>
30 *  <table class="innertable">
31 *     <tr><th>Characteristic</th><th>Description</th></tr>
32 *     <tr><td>Default size</td><td>Large enough to display its children</td></tr>
33 *     <tr><td>Minimum size</td><td>0 pixels</td></tr>
34 *     <tr><td>Maximum size</td><td>10000 pixels wide and 10000 pixels high</td></tr>
35 *  </table>
36 *
37 *  @mxml
38 *
39 *  <p>The <code>&lt;s:TileGroup&gt;</code> tag inherits all of the tag
40 *  attributes of its superclass and adds the following tag attributes:</p>
41 *
42 *  <pre>
43 *  &lt;s:TileGroup
44 *    <strong>Properties</strong>
45 *    columnAlign="left"
46 *    columnCount="-1"
47 *    columnWidth="0"
48 *    horizontalAlign="justify"
49 *    horizontalGap="6"
50 *    orientation="rows"
51 *    paddingBottom="0"
52 *    paddingLeft="0"
53 *    paddingRight="0"
54 *    paddingTop="0"
55 *    requestedColumnCount"-1"
56 *    requestedRowCount="-1"
57 *    rowAlign="top"
58 *    rowCount="-1"
59 *    rowHeight="0"
60 *    verticalAlign="justify"
61 *    verticalGap="6"
62 *  /&gt;
63 *  </pre>
64 *
65 *  @see spark.layouts.TileLayout
66 *  @includeExample examples/TileGroupExample.mxml
67 *
68 *  @langversion 3.0
69 *  @playerversion Flash 10
70 *  @playerversion AIR 1.5
71 *  @productversion Flex 4
72 */
73public class TileGroup extends Group
74{
75    include "../core/Version.as";
76
77    /**
78     *  Constructor.
79     *  Initializes the <code>layout</code> property to an instance of
80     *  the TileLayout class.
81     *
82     *  @see spark.layouts.TileLayout
83     *  @see spark.components.HGroup
84     *  @see spark.components.VGroup
85     *
86     *  @langversion 3.0
87     *  @playerversion Flash 10
88     *  @playerversion AIR 1.5
89     *  @productversion Flex 4
90     */
91    public function TileGroup():void
92    {
93        super();
94        super.layout = new TileLayout();
95    }
96
97    private function get tileLayout():TileLayout
98    {
99        return TileLayout(layout);
100    }
101
102    //--------------------------------------------------------------------------
103    //
104    //  Properties
105    //
106    //--------------------------------------------------------------------------
107
108    //----------------------------------
109    //  columnAlign
110    //----------------------------------
111
112    [Inspectable(category="General", enumeration="left,justifyUsingGap,justifyUsingWidth", defaultValue="left")]
113
114    /**
115     *  @copy spark.layouts.TileLayout#columnAlign
116     *
117     *  @default "left"
118     *
119     *  @langversion 3.0
120     *  @playerversion Flash 10
121     *  @playerversion AIR 1.5
122     *  @productversion Flex 4
123     */
124    public function get columnAlign():String
125    {
126        return tileLayout.columnAlign;
127    }
128
129    /**
130     *  @private
131     */
132    public function set columnAlign(value:String):void
133    {
134        tileLayout.columnAlign = value;
135    }
136
137    //----------------------------------
138    //  columnCount
139    //----------------------------------
140
141    [Bindable("propertyChange")]
142    [Inspectable(category="General")]
143
144    /**
145     *  @copy spark.layouts.TileLayout#columnCount
146     *
147     *  @default -1
148     *
149     *  @langversion 3.0
150     *  @playerversion Flash 10
151     *  @playerversion AIR 1.5
152     *  @productversion Flex 4
153     */
154    public function get columnCount():int
155    {
156        return tileLayout.columnCount;
157    }
158
159    //----------------------------------
160    //  columnWidth
161    //----------------------------------
162
163    [Bindable("propertyChange")]
164    [Inspectable(category="General", minValue="0.0")]
165
166    /**
167     *  @copy spark.layouts.TileLayout#columnWidth
168     *
169     *  @default 0
170     *
171     *  @langversion 3.0
172     *  @playerversion Flash 10
173     *  @playerversion AIR 1.5
174     *  @productversion Flex 4
175     */
176    public function get columnWidth():int
177    {
178        return tileLayout.columnWidth;
179    }
180
181    /**
182     *  @private
183     */
184    public function set columnWidth(value:int):void
185    {
186        tileLayout.columnWidth = value;
187    }
188
189    //----------------------------------
190    //  horizontalAlign
191    //----------------------------------
192
193    [Inspectable(category="General", enumeration="left,right,center,justify", defaultValue="justify")]
194
195    /**
196     *  @copy spark.layouts.TileLayout#horizontalAlign
197     *
198     *  @default "justify"
199     *
200     *  @langversion 3.0
201     *  @playerversion Flash 10
202     *  @playerversion AIR 1.5
203     *  @productversion Flex 4
204     */
205    public function get horizontalAlign():String
206    {
207        return tileLayout.horizontalAlign;
208    }
209
210    /**
211     *  @private
212     */
213    public function set horizontalAlign(value:String):void
214    {
215        tileLayout.horizontalAlign = value;
216    }
217
218    //----------------------------------
219    //  horizontalGap
220    //----------------------------------
221
222    [Bindable("propertyChange")]
223    [Inspectable(category="General", defaultValue="6")]
224
225    /**
226     *  @copy spark.layouts.TileLayout#horizontalGap
227     *
228     *  @default 6
229     *
230     *  @langversion 3.0
231     *  @playerversion Flash 10
232     *  @playerversion AIR 1.5
233     *  @productversion Flex 4
234     */
235    public function get horizontalGap():int
236    {
237        return tileLayout.horizontalGap;
238    }
239
240    /**
241     *  @private
242     */
243    public function set horizontalGap(value:int):void
244    {
245        tileLayout.horizontalGap = value;
246    }
247
248    //----------------------------------
249    //  orientation
250    //----------------------------------
251
252    [Inspectable(category="General", enumeration="rows,columns", defaultValue="rows")]
253
254    /**
255     *  @copy spark.layouts.TileLayout#orientation
256     *
257     *  @default "rows"
258     *
259     *  @langversion 3.0
260     *  @playerversion Flash 10
261     *  @playerversion AIR 1.5
262     *  @productversion Flex 4
263     */
264    public function get orientation():String
265    {
266        return tileLayout.orientation;
267    }
268
269    /**
270     *  @private
271     */
272    public function set orientation(value:String):void
273    {
274        tileLayout.orientation = value;
275    }
276
277    //----------------------------------
278    //  paddingLeft
279    //----------------------------------
280
281    [Inspectable(category="General", defaultValue="0.0")]
282
283    /**
284     *  @copy spark.layouts.TileLayout#paddingLeft
285     *
286     *  @default 0
287     *
288     *  @langversion 3.0
289     *  @playerversion Flash 10
290     *  @playerversion AIR 1.5
291     *  @productversion Flex 4
292     */
293    public function get paddingLeft():Number
294    {
295        return tileLayout.paddingLeft;
296    }
297
298    /**
299     *  @private
300     */
301    public function set paddingLeft(value:Number):void
302    {
303        tileLayout.paddingLeft = value;
304    }
305
306    //----------------------------------
307    //  paddingRight
308    //----------------------------------
309
310    [Inspectable(category="General", defaultValue="0.0")]
311
312    /**
313     *  @copy spark.layouts.TileLayout#paddingRight
314     *
315     *  @default 0
316     *
317     *  @langversion 3.0
318     *  @playerversion Flash 10
319     *  @playerversion AIR 1.5
320     *  @productversion Flex 4
321     */
322    public function get paddingRight():Number
323    {
324        return tileLayout.paddingRight;
325    }
326
327    /**
328     *  @private
329     */
330    public function set paddingRight(value:Number):void
331    {
332        tileLayout.paddingRight = value;
333    }
334
335    //----------------------------------
336    //  paddingTop
337    //----------------------------------
338
339    [Inspectable(category="General", defaultValue="0.0")]
340
341    /**
342     *  @copy spark.layouts.TileLayout#paddingTop
343     *
344     *  @default 0
345     *
346     *  @langversion 3.0
347     *  @playerversion Flash 10
348     *  @playerversion AIR 1.5
349     *  @productversion Flex 4
350     */
351    public function get paddingTop():Number
352    {
353        return tileLayout.paddingTop;
354    }
355
356    /**
357     *  @private
358     */
359    public function set paddingTop(value:Number):void
360    {
361        tileLayout.paddingTop = value;
362    }
363
364    //----------------------------------
365    //  paddingBottom
366    //----------------------------------
367
368    [Inspectable(category="General", defaultValue="0.0")]
369
370    /**
371     *  @copy spark.layouts.TileLayout#paddingBottom
372     *
373     *  @default 0
374     *
375     *  @langversion 3.0
376     *  @playerversion Flash 10
377     *  @playerversion AIR 1.5
378     *  @productversion Flex 4
379     */
380    public function get paddingBottom():Number
381    {
382        return tileLayout.paddingBottom;
383    }
384
385    /**
386     *  @private
387     */
388    public function set paddingBottom(value:Number):void
389    {
390        tileLayout.paddingBottom = value;
391    }
392
393    //----------------------------------
394    //  requestedColumnCount
395    //----------------------------------
396
397    [Inspectable(category="General", minValue="-1")]
398
399    /**
400     *  @copy spark.layouts.TileLayout#requestedColumnCount
401     *
402     *  @default -1
403     *
404     *  @langversion 3.0
405     *  @playerversion Flash 10
406     *  @playerversion AIR 1.5
407     *  @productversion Flex 4
408     */
409    public function get requestedColumnCount():int
410    {
411        return tileLayout.requestedColumnCount;
412    }
413
414    /**
415     *  @private
416     */
417    public function set requestedColumnCount(value:int):void
418    {
419        tileLayout.requestedColumnCount = value;
420    }
421
422    //----------------------------------
423    //  requestedRowCount
424    //----------------------------------
425
426    [Inspectable(category="General", minValue="-1")]
427
428    /**
429     *  @copy spark.layouts.TileLayout#requestedRowCount
430     *
431     *  @default -1
432     *
433     *  @langversion 3.0
434     *  @playerversion Flash 10
435     *  @playerversion AIR 1.5
436     *  @productversion Flex 4
437     */
438    public function get requestedRowCount():int
439    {
440        return tileLayout.requestedRowCount;
441    }
442
443    /**
444     *  @private
445     */
446    public function set requestedRowCount(value:int):void
447    {
448        tileLayout.requestedRowCount = value;
449    }
450
451    //----------------------------------
452    //  rowAlign
453    //----------------------------------
454
455    [Inspectable(category="General", enumeration="top,justifyUsingGap,justifyUsingHeight", defaultValue="top")]
456
457    /**
458     *  @copy spark.layouts.TileLayout#rowAlign
459     *
460     *  @default "top"
461     *
462     *  @langversion 3.0
463     *  @playerversion Flash 10
464     *  @playerversion AIR 1.5
465     *  @productversion Flex 4
466     */
467    public function get rowAlign():String
468    {
469        return tileLayout.rowAlign;
470    }
471
472    /**
473     *  @private
474     */
475    public function set rowAlign(value:String):void
476    {
477        tileLayout.rowAlign = value;
478    }
479
480    //----------------------------------
481    //  rowCount
482    //----------------------------------
483
484    [Bindable("propertyChange")]
485    [Inspectable(category="General")]
486
487    /**
488     *  @copy spark.layouts.TileLayout#rowCount
489     *
490     *  @default -1
491     *
492     *  @langversion 3.0
493     *  @playerversion Flash 10
494     *  @playerversion AIR 1.5
495     *  @productversion Flex 4
496     */
497    public function get rowCount():int
498    {
499        return tileLayout.rowCount;
500    }
501
502    //----------------------------------
503    //  rowHeight
504    //----------------------------------
505
506    [Bindable("propertyChange")]
507    [Inspectable(category="General", minValue="0.0")]
508
509    /**
510     *  @copy spark.layouts.TileLayout#rowHeight
511     *
512     *  @default 0
513     *
514     *  @langversion 3.0
515     *  @playerversion Flash 10
516     *  @playerversion AIR 1.5
517     *  @productversion Flex 4
518     */
519    public function get rowHeight():int
520    {
521        return tileLayout.rowHeight;
522    }
523
524    /**
525     *  @private
526     */
527    public function set rowHeight(value:int):void
528    {
529        tileLayout.rowHeight = value;
530    }
531
532    //----------------------------------
533    //  verticalAlign
534    //----------------------------------
535
536    [Inspectable(category="General", enumeration="top,bottom,middle,justify", defaultValue="justify")]
537
538    /**
539     *  @copy spark.layouts.TileLayout#verticalAlign
540     *
541     *  @default "justify"
542     *
543     *  @langversion 3.0
544     *  @playerversion Flash 10
545     *  @playerversion AIR 1.5
546     *  @productversion Flex 4
547     */
548    public function get verticalAlign():String
549    {
550        return tileLayout.verticalAlign;
551    }
552
553    /**
554     *  @private
555     */
556    public function set verticalAlign(value:String):void
557    {
558        tileLayout.verticalAlign = value;
559    }
560
561    //----------------------------------
562    //  verticalGap
563    //----------------------------------
564
565    [Bindable("propertyChange")]
566    [Inspectable(category="General", defaultValue="6")]
567
568    /**
569     *  @copy spark.layouts.TileLayout#verticalGap
570     *
571     *  @default 6
572     *
573     *  @langversion 3.0
574     *  @playerversion Flash 10
575     *  @playerversion AIR 1.5
576     *  @productversion Flex 4
577     */
578    public function get verticalGap():int
579    {
580        return tileLayout.verticalGap;
581    }
582
583    /**
584     *  @private
585     */
586    public function set verticalGap(value:int):void
587    {
588        tileLayout.verticalGap = value;
589    }
590
591    //--------------------------------------------------------------------------
592    //
593    //  Overridden Properties
594    //
595    //--------------------------------------------------------------------------
596
597    //----------------------------------
598    //  layout
599    //----------------------------------
600
601    /**
602     *  @private
603     */
604    override public function set layout(value:LayoutBase):void
605    {
606        throw(new Error(resourceManager.getString("components", "layoutReadOnly")));
607    }
608
609    //--------------------------------------------------------------------------
610    //
611    //  Event Handlers
612    //
613    //--------------------------------------------------------------------------
614
615    /**
616     * @private
617     */
618    override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
619    {
620        if (type == "propertyChange")
621        {
622            if (!hasEventListener(type))
623                tileLayout.addEventListener(type, redispatchHandler);
624        }
625        super.addEventListener(type, listener, useCapture, priority, useWeakReference)
626    }
627
628    /**
629     * @private
630     */
631    override public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
632    {
633        super.removeEventListener(type, listener, useCapture);
634        if (type == "propertyChange")
635        {
636            if (!hasEventListener(type))
637                tileLayout.removeEventListener(type, redispatchHandler);
638        }
639    }
640
641    private function redispatchHandler(event:Event):void
642    {
643        dispatchEvent(event);
644    }
645
646}
647}
648