1 /**************************************************************************** 2 Copyright (c) 2011-2012 cocos2d-x.org 3 Copyright (c) 2013-2014 Chukong Technologies Inc. 4 5 http://www.cocos2d-x.org 6 7 Permission is hereby granted, free of charge, to any person obtaining a copy 8 of this software and associated documentation files (the "Software"), to deal 9 in the Software without restriction, including without limitation the rights 10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 copies of the Software, and to permit persons to whom the Software is 12 furnished to do so, subject to the following conditions: 13 14 The above copyright notice and this permission notice shall be included in 15 all copies or substantial portions of the Software. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 THE SOFTWARE. 24 ****************************************************************************/ 25 26 /** 27 * The vertical box of Cocos UI. Its layout type is ccui.Layout.LINEAR_VERTICAL. 28 * @class 29 * @extends ccui.Layout 30 */ 31 ccui.VBox = ccui.Layout.extend(/** @lends ccui.VBox# */{ 32 /** 33 * The constructor of ccui.VBox 34 * @function 35 * @param {cc.Size} size 36 */ 37 ctor: function(size){ 38 ccui.Layout.prototype.ctor.call(this, size); 39 if(size !== undefined) 40 this.initWithSize(size); 41 else 42 this.init(); 43 }, 44 45 /** 46 * Initializes a VBox. please do not call this function by yourself, you should pass the parameters to constructor to initialize it. 47 * @override 48 * @returns {boolean} 49 */ 50 init: function(){ 51 if(ccui.Layout.prototype.init.call(this)){ 52 this.setLayoutType(ccui.Layout.LINEAR_VERTICAL); 53 return true; 54 } 55 return false; 56 }, 57 58 /** 59 * Initializes a VBox with size. 60 * @param {cc.Size} size 61 * @returns {boolean} 62 */ 63 initWithSize: function(size){ 64 if(this.init()){ 65 this.setContentSize(size); 66 return true; 67 } 68 return false; 69 } 70 }); 71 72 /** 73 * Creates a VBox 74 * @param {cc.Size} size 75 * @returns {ccui.VBox} 76 */ 77 ccui.VBox.create = function(size){ 78 return new ccui.VBox(size); 79 };