/* Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license */ package com.yahoo.astra.fl.containers { import com.yahoo.astra.fl.containers.layoutClasses.AdvancedLayoutPane; import com.yahoo.astra.layout.modes.BorderLayout; import fl.core.InvalidationType; /** * A container that arranges its children similar to a non-scrolling document * page. Top and bottom constraints define headers and footers. Left and * right constraints define sidebars, and a center constraint stetches the * main contents to fill the remaining space. * *

This layout container supports advanced options specified through the * configuration property.

* *

Available Configuration Options

*
*
target : DisplayObject
*
A display object to be configured.
*
constraint : String
*
The BorderConstraints value to be used on the target by the layout algorithm. The default * value is BorderConstraints.CENTER.
*
maintainAspectRatio : Boolean
*
If true, the aspect ratio of the target will be maintained if it is resized.
*
horizontalAlign : String
*
The horizontal alignment used when positioning the target. Used in combination with * maintainAspectRatio.
*
verticalAlign : String
*
The vertical alignment used when positioning the target. Used in combination with * maintainAspectRatio.
*
aspectRatio : Number
*
The desired aspect ratio to use with maintainAspectRatio. This value is optional. * If no aspect ratio is provided, it will be determined based on the target's original width and height.
*
includeInLayout : Boolean
*
If false, the target will not be included in layout calculations. The default value is true.
*
* * @example The following code sets the configuration options for a BorderPane * * pane.configuration = [ * { target: headerSprite, constraint: BorderContstraints.TOP }, * { target: contentSprite, constraint: BorderConstraints.CENTER, * maintainAspectRatio: true, horizontalAlign: "center", * verticalAlign: "middle" } * ]; * * * @see com.yahoo.astra.layout.BorderConstraints * @see com.yahoo.astra.layout.HorizontalAlignment * @see com.yahoo.astra.layout.VerticalAlignment * * @author Josh Tynjala */ public class BorderPane extends AdvancedLayoutPane { //-------------------------------------- // Constructor //-------------------------------------- /** * Constructor. * * @param configuration An Array of optional configurations for the layout container's children. */ public function BorderPane(configuration:Array = null) { super(new BorderLayout(), configuration); } //-------------------------------------- // Properties //-------------------------------------- /** * @private * Storage for the verticalGap property. */ private var _verticalGap:Number = 0; /** * The number of vertical pixels between each item displayed by this * container. */ public function get verticalGap():Number { return this._verticalGap; } /** * @private */ public function set verticalGap(value:Number):void { this._verticalGap = value; this.invalidate(INVALIDATION_TYPE_LAYOUT); } /** * @private * Storage for the horizontalGap property. */ private var _horizontalGap:Number = 0; /** * The number of horizontal pixels between each item displayed by this * container. */ public function get horizontalGap():Number { return this._horizontalGap; } /** * @private */ public function set horizontalGap(value:Number):void { this._horizontalGap = value; this.invalidate(INVALIDATION_TYPE_LAYOUT); } //-------------------------------------- // Protected Methods //-------------------------------------- /** * @private */ override protected function draw():void { var borderLayout:BorderLayout = this.layoutMode as BorderLayout; if(borderLayout) { borderLayout.horizontalGap = this.horizontalGap; borderLayout.verticalGap = this.verticalGap; } super.draw(); } } }