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 horizontal box of Cocos UI. Its layout type is ccui.Layout.LINEAR_HORIZONTAL.
 28  * @class
 29  * @extends ccui.Layout
 30  */
 31 ccui.HBox = ccui.Layout.extend(/** @lends ccui.HBox# */{
 32     /**
 33      * The constructor of ccui.HBox
 34      * @function
 35      * @param {cc.Size} [size]
 36      */
 37     ctor: function(size){
 38         if(size)
 39             this.initWithSize(size);
 40         else
 41            this.init();
 42     },
 43 
 44     /**
 45      * Initialize a HBox. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
 46      * @override
 47      * @returns {boolean}
 48      */
 49     init: function(){
 50         if(ccui.Layout.prototype.init.call(this)){
 51             this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL);
 52             return true;
 53         }
 54         return false;
 55     },
 56 
 57     /**
 58      * Initializes a HBox with size.
 59      * @param size
 60      * @returns {boolean}
 61      */
 62     initWithSize: function(size){
 63         if(this.init()){
 64             this.setContentSize(size);
 65             return true;
 66         }
 67         return false;
 68     }
 69 });
 70 
 71 /**
 72  * Creates a HBox object
 73  * @deprecated since v3.0, please use new ccui.HBox(size) instead.
 74  * @param {cc.Size} size
 75  * @returns {ccui.HBox}
 76  */
 77 ccui.HBox.create = function(size){
 78     return new ccui.HBox(size);
 79 };