1 /****************************************************************************
  2  Copyright (c) 2010-2012 cocos2d-x.org
  3 
  4  http://www.cocos2d-x.org
  5 
  6  Permission is hereby granted, free of charge, to any person obtaining a copy
  7  of this software and associated documentation files (the "Software"), to deal
  8  in the Software without restriction, including without limitation the rights
  9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10  copies of the Software, and to permit persons to whom the Software is
 11  furnished to do so, subject to the following conditions:
 12 
 13  The above copyright notice and this permission notice shall be included in
 14  all copies or substantial portions of the Software.
 15 
 16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 22  THE SOFTWARE.
 23  ****************************************************************************/
 24 
 25 //LinearGravity
 26 /**
 27  * @ignore
 28  */
 29 ccui.LINEAR_GRAVITY_NONE = 0;
 30 ccui.LINEAR_GRAVITY_LEFT = 1;
 31 ccui.LINEAR_GRAVITY_TOP = 2;
 32 ccui.LINEAR_GRAVITY_RIGHT = 3;
 33 ccui.LINEAR_GRAVITY_BOTTOM = 4;
 34 ccui.LINEAR_GRAVITY_CENTER_VERTICAL = 5;
 35 ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL = 6;
 36 
 37 //RelativeAlign
 38 ccui.RELATIVE_ALIGN_NONE = 0;
 39 ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT = 1;
 40 ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL = 2;
 41 ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT = 3;
 42 ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL = 4;
 43 ccui.RELATIVE_ALIGN_PARENT_CENTER = 5;
 44 ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL = 6;
 45 ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM = 7;
 46 ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL = 8;
 47 ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM = 9;
 48 
 49 ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT = 10;
 50 ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER = 11;
 51 ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT = 12;
 52 
 53 ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP = 13;
 54 ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER = 14;
 55 ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM = 15;
 56 
 57 ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP = 16;
 58 ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER = 17;
 59 ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM = 18;
 60 
 61 ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP = 19;
 62 ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER = 20;
 63 ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM = 21;
 64 
 65 /**
 66  * Base class for ccui.Margin
 67  * @class
 68  * @extends ccui.Class
 69  */
 70 ccui.Margin = ccui.Class.extend(/** @lends ccui.Margin# */{
 71     left: 0,
 72     top: 0,
 73     right: 0,
 74     bottom: 0,
 75     ctor: function (margin, top, right, bottom) {
 76         if (margin && top === undefined) {
 77             this.left = margin.left;
 78             this.top = margin.top;
 79             this.right = margin.right;
 80             this.bottom = margin.bottom;
 81         }
 82         if (bottom !== undefined) {
 83             this.left = margin;
 84             this.top = top;
 85             this.right = right;
 86             this.bottom = bottom;
 87         }
 88     },
 89     /**
 90      *  set margin
 91      * @param {Number} l
 92      * @param {Number} t
 93      * @param {Number} r
 94      * @param {Number} b
 95      */
 96     setMargin: function (l, t, r, b) {
 97         this.left = l;
 98         this.top = t;
 99         this.right = r;
100         this.bottom = b;
101     },
102     /**
103      *  check is equals
104      * @param {ccui.Margin} target
105      * @returns {boolean}
106      */
107     equals: function (target) {
108         return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom);
109     }
110 });
111 
112 ccui.MarginZero = function(){
113    return new ccui.Margin(0,0,0,0);
114 };