1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4  
     5  import org.aswing.Component;
     6  import org.aswing.Container;
     7  import org.aswing.JPanel;
     8  import org.aswing.SoftBoxLayout;
     9  
    10  /**
    11   * @author iiley
    12   */
    13  class org.aswing.SoftBox extends JPanel {
    14  	
    15  	/**
    16  	 * SoftBox(axis:Number, gap:Number)<br>
    17  	 * SoftBox(axis:Number) default gap to 0.
    18  	 * Creates a panel with a SoftBoxLayout.
    19  	 * @param axis the axis of layout.
    20  	 *  {@link org.aswing.SoftBoxLayout#X_AXIS} or {@link org.aswing.SoftBoxLayout#Y_AXIS}
    21       * @param gap the gap between each component, default 0
    22  	 * @see org.aswing.SoftBoxLayout
    23  	 */
    24  	public function SoftBox(axis:Number, gap:Number){
    25  		super();
    26  		setName("Box");
    27  		setLayout(new SoftBoxLayout(axis, gap));
    28  	}
    29  	
    30  	/**
    31  	 * Creates and return a Horizontal SoftBox.
    32       * @param gap the gap between each component, default 0
    33       * @return a horizontal SoftBox.
    34  	 */
    35  	public static function createHorizontalBox(gap:Number):SoftBox{
    36  		return new SoftBox(SoftBoxLayout.X_AXIS, gap);
    37  	}
    38  	
    39  	/**
    40  	 * Creates and return a Vertical SoftBox.
    41       * @param gap the gap between each component, default 0
    42       * @return a vertical SoftBox.
    43  	 */
    44  	public static function createVerticalBox(gap:Number):SoftBox{
    45  		return new SoftBox(SoftBoxLayout.Y_AXIS, gap);
    46  	}
    47  	
    48  	public static function createHorizontalGlue(width:Number):Component{
    49  		var glue:Container = new JPanel();
    50  		glue.setOpaque(false);
    51  		glue.setMinimumSize(0, 0);
    52  		glue.setPreferredSize(width, 0);
    53  		glue.setMaximumSize(width, Number.MAX_VALUE);
    54  		return glue;
    55  	}
    56  	
    57  	public static function createVerticalGlue(height:Number):Component{
    58  		var glue:Container = new JPanel();
    59  		glue.setOpaque(false);
    60  		glue.setMinimumSize(0, 0);
    61  		glue.setPreferredSize(0, height);
    62  		glue.setMaximumSize(Number.MAX_VALUE, height);
    63  		return glue;
    64  	}
    65  
    66  }
    67