1 /**
  2  * @author Gillis Haasnoot <gillis.haasnoot@gmail.com>
  3  * @package Banana.Controls
  4  * @summary HBox control  
  5  */
  6 
  7 goog.provide('Banana.Controls.VBox');
  8 
  9 goog.require('Banana.Controls.Panel');
 10 
 11 /** @namespace Banana.Controls.Layout.VBox */
 12 namespace('Banana.Controls').VBox = Banana.Controls.Panel.extend(
 13 /** @lends Banana.Controls.VBox.prototype */
 14 {
 15 	/**
 16 	 * Creates a HBox in which all added controls are aligned vertically.
 17 	 * @constructs
 18 	 * @extends Banana.Controls.Panel
 19 	 */
 20 	init : function()
 21 	{
 22 		this._super();
 23 		this.spacing = 0;
 24 	},
 25 
 26 	/**
 27 	 * sets space between controls
 28 	 * @param {int} s 
 29 	 */
 30 	setSpacing : function(s)
 31 	{
 32 		this.spacing = s;
 33 		return this;
 34 	},
 35 
 36 	/**
 37 	 * @override
 38 	 * @ignore
 39 	 */
 40 	updateDisplay : function()
 41 	{
 42 		this._super();
 43 
 44 		for (var i = 0, len = this.controls.length; i < len; i++)
 45 		{
 46 			var c = this.controls[i];
 47 			if (!(c instanceof Banana.Control))
 48 			{
 49 				continue;
 50 			}
 51 
 52 			if (c.getStyleProperty('float') == 'none')
 53 			{
 54 				c.setCss({'clear':'both','float':'','width':'100%'});
 55 			}
 56 			else
 57 			{
 58 				c.setCss({'clear':'both','float':''});
 59 			}
 60 			
 61 
 62 			if (i < this.controls.length)
 63 			{
 64 				c.setCss({'margin-bottom':this.spacing+'px'});
 65 			}
 66 		}
 67 	}
 68 });