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  * Base class for ccui.CheckBox
 28  * @class
 29  * @extends ccui.Widget
 30  *
 31  * @property {Boolean}  selected    - Indicate whether the check box has been selected
 32  */
 33 ccui.CheckBox = ccui.Widget.extend(/** @lends ccui.CheckBox# */{
 34     _backGroundBoxRenderer: null,
 35     _backGroundSelectedBoxRenderer: null,
 36     _frontCrossRenderer: null,
 37     _backGroundBoxDisabledRenderer: null,
 38     _frontCrossDisabledRenderer: null,
 39     _isSelected: true,
 40     _checkBoxEventListener: null,
 41     _checkBoxEventSelector: null,
 42     _backGroundTexType: ccui.Widget.LOCAL_TEXTURE,
 43     _backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE,
 44     _frontCrossTexType: ccui.Widget.LOCAL_TEXTURE,
 45     _backGroundDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
 46     _frontCrossDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
 47     _backGroundFileName: "",
 48     _backGroundSelectedFileName: "",
 49     _frontCrossFileName: "",
 50     _backGroundDisabledFileName: "",
 51     _frontCrossDisabledFileName: "",
 52     _className: "CheckBox",
 53 
 54     /**
 55      * allocates and initializes a UICheckBox.
 56      * Constructor of ccui.CheckBox
 57      * @example
 58      * // example
 59      * var uiCheckBox = new ccui.CheckBox();
 60      */
 61     ctor: function () {
 62         ccui.Widget.prototype.ctor.call(this);
 63     },
 64     init: function () {
 65         if (ccui.Widget.prototype.init.call(this)) {
 66             this.setTouchEnabled(true);
 67             this.setSelectedState(false);
 68             return true;
 69         }
 70         return false;
 71     },
 72 
 73     initRenderer: function () {
 74         this._backGroundBoxRenderer = cc.Sprite.create();
 75         this._backGroundSelectedBoxRenderer = cc.Sprite.create();
 76         this._frontCrossRenderer = cc.Sprite.create();
 77         this._backGroundBoxDisabledRenderer = cc.Sprite.create();
 78         this._frontCrossDisabledRenderer = cc.Sprite.create();
 79         cc.Node.prototype.addChild.call(this, this._backGroundBoxRenderer, ccui.CheckBox.BOX_RENDERER_ZORDER, -1);
 80         cc.Node.prototype.addChild.call(this, this._backGroundSelectedBoxRenderer, ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER, -1);
 81         cc.Node.prototype.addChild.call(this, this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1);
 82         cc.Node.prototype.addChild.call(this, this._backGroundBoxDisabledRenderer, ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER, -1);
 83         cc.Node.prototype.addChild.call(this, this._frontCrossDisabledRenderer, ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER, -1);
 84     },
 85 
 86     /**
 87      * Load textures for checkbox.
 88      * @param {String} backGround
 89      * @param {String} backGroundSelected
 90      * @param {String} cross
 91      * @param {String} backGroundDisabled
 92      * @param {String} frontCrossDisabled
 93      * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
 94      */
 95     loadTextures: function (backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType) {
 96         this.loadTextureBackGround(backGround, texType);
 97         this.loadTextureBackGroundSelected(backGroundSelected, texType);
 98         this.loadTextureFrontCross(cross, texType);
 99         this.loadTextureBackGroundDisabled(backGroundDisabled, texType);
100         this.loadTextureFrontCrossDisabled(frontCrossDisabled, texType);
101     },
102 
103     /**
104      * Load backGround texture for checkbox.
105      * @param {String} backGround
106      * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
107      */
108     loadTextureBackGround: function (backGround, texType) {
109         if (!backGround) {
110             return;
111         }
112         texType = texType || ccui.Widget.LOCAL_TEXTURE;
113         this._backGroundFileName = backGround;
114         this._backGroundTexType = texType;
115         var bgBoxRenderer = this._backGroundBoxRenderer;
116         switch (this._backGroundTexType) {
117             case ccui.Widget.LOCAL_TEXTURE:
118                 bgBoxRenderer.initWithFile(backGround);
119                 break;
120             case ccui.Widget.PLIST_TEXTURE:
121                 bgBoxRenderer.initWithSpriteFrameName(backGround);
122                 break;
123             default:
124                 break;
125         }
126 
127         this.updateColorToRenderer(bgBoxRenderer);
128         this.updateAnchorPoint();
129         this.updateFlippedX();
130         this.updateFlippedY();
131         if (!bgBoxRenderer.textureLoaded()) {
132             this._backGroundBoxRenderer.setContentSize(this._customSize);
133             bgBoxRenderer.addLoadedEventListener(function () {
134                 this.backGroundTextureScaleChangedWithSize();
135             }, this);
136         }
137         this.backGroundTextureScaleChangedWithSize();
138     },
139     /**
140      * Load backGroundSelected texture for checkbox.
141      * @param {String} backGroundSelected
142      * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
143      */
144     loadTextureBackGroundSelected: function (backGroundSelected, texType) {
145         if (!backGroundSelected) {
146             return;
147         }
148         texType = texType || ccui.Widget.LOCAL_TEXTURE;
149         this._backGroundSelectedFileName = backGroundSelected;
150         this._backGroundSelectedTexType = texType;
151         switch (this._backGroundSelectedTexType) {
152             case ccui.Widget.LOCAL_TEXTURE:
153                 this._backGroundSelectedBoxRenderer.initWithFile(backGroundSelected);
154                 break;
155             case ccui.Widget.PLIST_TEXTURE:
156                 this._backGroundSelectedBoxRenderer.initWithSpriteFrameName(backGroundSelected);
157                 break;
158             default:
159                 break;
160         }
161         this.updateColorToRenderer(this._backGroundSelectedBoxRenderer);
162         this.updateAnchorPoint();
163         this.updateFlippedX();
164         this.updateFlippedY();
165         this.backGroundSelectedTextureScaleChangedWithSize();
166     },
167 
168     /**
169      * Load cross texture for checkbox.
170      * @param {String} cross
171      * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
172      */
173     loadTextureFrontCross: function (cross, texType) {
174         if (!cross) {
175             return;
176         }
177         texType = texType || ccui.Widget.LOCAL_TEXTURE;
178         this._frontCrossFileName = cross;
179         this._frontCrossTexType = texType;
180         switch (this._frontCrossTexType) {
181             case ccui.Widget.LOCAL_TEXTURE:
182                 this._frontCrossRenderer.initWithFile(cross);
183                 break;
184             case ccui.Widget.PLIST_TEXTURE:
185                 this._frontCrossRenderer.initWithSpriteFrameName(cross);
186                 break;
187             default:
188                 break;
189         }
190         this.updateColorToRenderer(this._frontCrossRenderer);
191         this.updateAnchorPoint();
192         this.updateFlippedX();
193         this.updateFlippedY();
194         this.frontCrossTextureScaleChangedWithSize();
195     },
196 
197     /**
198      * Load backGroundDisabled texture for checkbox.
199      * @param {String} backGroundDisabled
200      * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
201      */
202     loadTextureBackGroundDisabled: function (backGroundDisabled, texType) {
203         if (!backGroundDisabled) {
204             return;
205         }
206         texType = texType || ccui.Widget.LOCAL_TEXTURE;
207         this._backGroundDisabledFileName = backGroundDisabled;
208         this._backGroundDisabledTexType = texType;
209         switch (this._backGroundDisabledTexType) {
210             case ccui.Widget.LOCAL_TEXTURE:
211                 this._backGroundBoxDisabledRenderer.initWithFile(backGroundDisabled);
212                 break;
213             case ccui.Widget.PLIST_TEXTURE:
214                 this._backGroundBoxDisabledRenderer.initWithSpriteFrameName(backGroundDisabled);
215                 break;
216             default:
217                 break;
218         }
219         this.updateColorToRenderer(this._backGroundBoxDisabledRenderer);
220         this.updateAnchorPoint();
221         this.updateFlippedX();
222         this.updateFlippedY();
223         this.backGroundDisabledTextureScaleChangedWithSize();
224     },
225 
226     /**
227      * Load frontCrossDisabled texture for checkbox.
228      * @param {String} frontCrossDisabled
229      * @param {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
230      */
231     loadTextureFrontCrossDisabled: function (frontCrossDisabled, texType) {
232         if (!frontCrossDisabled) {
233             return;
234         }
235         texType = texType || ccui.Widget.LOCAL_TEXTURE;
236         this._frontCrossDisabledFileName = frontCrossDisabled;
237         this._frontCrossDisabledTexType = texType;
238         switch (this._frontCrossDisabledTexType) {
239             case ccui.Widget.LOCAL_TEXTURE:
240                 this._frontCrossDisabledRenderer.initWithFile(frontCrossDisabled);
241                 break;
242             case ccui.Widget.PLIST_TEXTURE:
243                 this._frontCrossDisabledRenderer.initWithSpriteFrameName(frontCrossDisabled);
244                 break;
245             default:
246                 break;
247         }
248         this.updateColorToRenderer(this._frontCrossDisabledRenderer);
249         this.updateAnchorPoint();
250         this.updateFlippedX();
251         this.updateFlippedY();
252         this.frontCrossDisabledTextureScaleChangedWithSize();
253     },
254 
255     onTouchEnded: function (touch, event) {
256         var touchPoint = touch.getLocation();
257         this._touchEndPos.x = touchPoint.x;
258         this._touchEndPos.y = touchPoint.y;
259         if (this._focus) {
260             this.releaseUpEvent();
261             if (this._isSelected) {
262                 this.setSelectedState(false);
263                 this.unSelectedEvent();
264             }
265             else {
266                 this.setSelectedState(true);
267                 this.selectedEvent();
268             }
269         }
270         this.setFocused(false);
271         var widgetParent = this.getWidgetParent();
272         if (widgetParent) {
273             widgetParent.checkChildInfo(2, this, touchPoint);
274         }
275     },
276 
277     onPressStateChangedToNormal: function () {
278         this._backGroundBoxRenderer.setVisible(true);
279         this._backGroundSelectedBoxRenderer.setVisible(false);
280         this._backGroundBoxDisabledRenderer.setVisible(false);
281         this._frontCrossDisabledRenderer.setVisible(false);
282     },
283 
284     onPressStateChangedToPressed: function () {
285         this._backGroundBoxRenderer.setVisible(false);
286         this._backGroundSelectedBoxRenderer.setVisible(true);
287         this._backGroundBoxDisabledRenderer.setVisible(false);
288         this._frontCrossDisabledRenderer.setVisible(false);
289     },
290 
291     onPressStateChangedToDisabled: function () {
292         this._backGroundBoxRenderer.setVisible(false);
293         this._backGroundSelectedBoxRenderer.setVisible(false);
294         this._backGroundBoxDisabledRenderer.setVisible(true);
295         this._frontCrossRenderer.setVisible(false);
296         if (this._isSelected) {
297             this._frontCrossDisabledRenderer.setVisible(true);
298         }
299     },
300 
301     setSelectedState: function (selected) {
302         if (selected == this._isSelected) {
303             return;
304         }
305         this._isSelected = selected;
306         this._frontCrossRenderer.setVisible(this._isSelected);
307     },
308 
309     getSelectedState: function () {
310         return this._isSelected;
311     },
312 
313     selectedEvent: function () {
314         if (this._checkBoxEventListener && this._checkBoxEventSelector) {
315             this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_SELECTED);
316         }
317     },
318 
319     unSelectedEvent: function () {
320         if (this._checkBoxEventListener && this._checkBoxEventSelector) {
321             this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_UNSELECTED);
322         }
323     },
324 
325     /**
326      * add event listener
327      * @param {Function} selector
328      * @param {Object} target
329      */
330     addEventListenerCheckBox: function (selector, target) {
331         this._checkBoxEventSelector = selector;
332         this._checkBoxEventListener = target;
333     },
334 
335     updateFlippedX: function () {
336         this._backGroundBoxRenderer.setFlippedX(this._flippedX);
337         this._backGroundSelectedBoxRenderer.setFlippedX(this._flippedX);
338         this._frontCrossRenderer.setFlippedX(this._flippedX);
339         this._backGroundBoxDisabledRenderer.setFlippedX(this._flippedX);
340         this._frontCrossDisabledRenderer.setFlippedX(this._flippedX);
341     },
342 
343     updateFlippedY: function () {
344         this._backGroundBoxRenderer.setFlippedY(this._flippedY);
345         this._backGroundSelectedBoxRenderer.setFlippedY(this._flippedY);
346         this._frontCrossRenderer.setFlippedY(this._flippedY);
347         this._backGroundBoxDisabledRenderer.setFlippedY(this._flippedY);
348         this._frontCrossDisabledRenderer.setFlippedY(this._flippedY);
349     },
350 
351     /**
352      * override "setAnchorPoint" of widget.
353      * @param {cc.Point|Number} point The anchor point of UICheckBox or The anchor point.x of UICheckBox.
354      * @param {Number} [y] The anchor point.y of UICheckBox.
355      */
356     setAnchorPoint: function (point, y) {
357         if (y === undefined) {
358             ccui.Widget.prototype.setAnchorPoint.call(this, point);
359             this._backGroundBoxRenderer.setAnchorPoint(point);
360             this._backGroundSelectedBoxRenderer.setAnchorPoint(point);
361             this._backGroundBoxDisabledRenderer.setAnchorPoint(point);
362             this._frontCrossRenderer.setAnchorPoint(point);
363             this._frontCrossDisabledRenderer.setAnchorPoint(point);
364         } else {
365             ccui.Widget.prototype.setAnchorPoint.call(this, point, y);
366             this._backGroundBoxRenderer.setAnchorPoint(point, y);
367             this._backGroundSelectedBoxRenderer.setAnchorPoint(point, y);
368             this._backGroundBoxDisabledRenderer.setAnchorPoint(point, y);
369             this._frontCrossRenderer.setAnchorPoint(point, y);
370             this._frontCrossDisabledRenderer.setAnchorPoint(point, y);
371         }
372     },
373     _setAnchorX: function (value) {
374         ccui.Widget.prototype._setAnchorX.call(this, value);
375         this._backGroundBoxRenderer._setAnchorX(value);
376         this._backGroundSelectedBoxRenderer._setAnchorX(value);
377         this._backGroundBoxDisabledRenderer._setAnchorX(value);
378         this._frontCrossRenderer._setAnchorX(value);
379         this._frontCrossDisabledRenderer._setAnchorX(value);
380     },
381     _setAnchorY: function (value) {
382         ccui.Widget.prototype._setAnchorY.call(this, value);
383         this._backGroundBoxRenderer._setAnchorY(value);
384         this._backGroundSelectedBoxRenderer._setAnchorY(value);
385         this._backGroundBoxDisabledRenderer._setAnchorY(value);
386         this._frontCrossRenderer._setAnchorY(value);
387         this._frontCrossDisabledRenderer._setAnchorY(value);
388     },
389 
390     onSizeChanged: function () {
391         ccui.Widget.prototype.onSizeChanged.call(this);
392         this.backGroundTextureScaleChangedWithSize();
393         this.backGroundSelectedTextureScaleChangedWithSize();
394         this.frontCrossTextureScaleChangedWithSize();
395         this.backGroundDisabledTextureScaleChangedWithSize();
396         this.frontCrossDisabledTextureScaleChangedWithSize();
397     },
398 
399     /**
400      * override "getContentSize" method of widget.
401      * @returns {cc.Size}
402      */
403     getContentSize: function () {
404         return this._backGroundBoxRenderer.getContentSize();
405     },
406     _getWidth: function () {
407         return this._backGroundBoxRenderer._getWidth();
408     },
409     _getHeight: function () {
410         return this._backGroundBoxRenderer._getHeight();
411     },
412 
413     /**
414      * override "getVirtualRenderer" method of widget.
415      * @returns {cc.Node}
416      */
417     getVirtualRenderer: function () {
418         return this._backGroundBoxRenderer;
419     },
420 
421     backGroundTextureScaleChangedWithSize: function () {
422         if (this._ignoreSize) {
423             this._backGroundBoxRenderer.setScale(1.0);
424             var locBackSize = this._backGroundBoxRenderer.getContentSize();
425             this._size.width = locBackSize.width;
426             this._size.height = locBackSize.height;
427         }
428         else {
429             var textureSize = this._backGroundBoxRenderer.getContentSize();
430             if (textureSize.width <= 0.0 || textureSize.height <= 0.0) {
431                 this._backGroundBoxRenderer.setScale(1.0);
432                 return;
433             }
434             var scaleX = this._size.width / textureSize.width;
435             var scaleY = this._size.height / textureSize.height;
436             this._backGroundBoxRenderer.setScaleX(scaleX);
437             this._backGroundBoxRenderer.setScaleY(scaleY);
438         }
439     },
440 
441     backGroundSelectedTextureScaleChangedWithSize: function () {
442         if (this._ignoreSize) {
443             this._backGroundSelectedBoxRenderer.setScale(1.0);
444         }
445         else {
446             var textureSize = this._backGroundSelectedBoxRenderer.getContentSize();
447             if (textureSize.width <= 0.0 || textureSize.height <= 0.0) {
448                 this._backGroundSelectedBoxRenderer.setScale(1.0);
449                 return;
450             }
451             var scaleX = this._size.width / textureSize.width;
452             var scaleY = this._size.height / textureSize.height;
453             this._backGroundSelectedBoxRenderer.setScaleX(scaleX);
454             this._backGroundSelectedBoxRenderer.setScaleY(scaleY);
455         }
456     },
457 
458     frontCrossTextureScaleChangedWithSize: function () {
459         if (this._ignoreSize) {
460             this._frontCrossRenderer.setScale(1.0);
461         }
462         else {
463             var textureSize = this._frontCrossRenderer.getContentSize();
464             if (textureSize.width <= 0.0 || textureSize.height <= 0.0) {
465                 this._frontCrossRenderer.setScale(1.0);
466                 return;
467             }
468             var scaleX = this._size.width / textureSize.width;
469             var scaleY = this._size.height / textureSize.height;
470             this._frontCrossRenderer.setScaleX(scaleX);
471             this._frontCrossRenderer.setScaleY(scaleY);
472         }
473     },
474 
475     backGroundDisabledTextureScaleChangedWithSize: function () {
476         if (this._ignoreSize) {
477             this._backGroundBoxDisabledRenderer.setScale(1.0);
478         }
479         else {
480             var textureSize = this._backGroundBoxDisabledRenderer.getContentSize();
481             if (textureSize.width <= 0.0 || textureSize.height <= 0.0) {
482                 this._backGroundBoxDisabledRenderer.setScale(1.0);
483                 return;
484             }
485             var scaleX = this._size.width / textureSize.width;
486             var scaleY = this._size.height / textureSize.height;
487             this._backGroundBoxDisabledRenderer.setScaleX(scaleX);
488             this._backGroundBoxDisabledRenderer.setScaleY(scaleY);
489         }
490     },
491 
492     frontCrossDisabledTextureScaleChangedWithSize: function () {
493         if (this._ignoreSize) {
494             this._frontCrossDisabledRenderer.setScale(1.0);
495         }
496         else {
497             var textureSize = this._frontCrossDisabledRenderer.getContentSize();
498             if (textureSize.width <= 0.0 || textureSize.height <= 0.0) {
499                 this._frontCrossDisabledRenderer.setScale(1.0);
500                 return;
501             }
502             var scaleX = this._size.width / textureSize.width;
503             var scaleY = this._size.height / textureSize.height;
504             this._frontCrossDisabledRenderer.setScaleX(scaleX);
505             this._frontCrossDisabledRenderer.setScaleY(scaleY);
506         }
507     },
508 
509     updateTextureColor: function () {
510         this.updateColorToRenderer(this._backGroundBoxRenderer);
511         this.updateColorToRenderer(this._backGroundSelectedBoxRenderer);
512         this.updateColorToRenderer(this._frontCrossRenderer);
513         this.updateColorToRenderer(this._backGroundBoxDisabledRenderer);
514         this.updateColorToRenderer(this._frontCrossDisabledRenderer);
515     },
516 
517     updateTextureOpacity: function () {
518         this.updateOpacityToRenderer(this._backGroundBoxRenderer);
519         this.updateOpacityToRenderer(this._backGroundSelectedBoxRenderer);
520         this.updateOpacityToRenderer(this._frontCrossRenderer);
521         this.updateOpacityToRenderer(this._backGroundBoxDisabledRenderer);
522         this.updateOpacityToRenderer(this._frontCrossDisabledRenderer);
523     },
524 
525     /**
526      * Returns the "class name" of widget.
527      * @returns {string}
528      */
529     getDescription: function () {
530         return "CheckBox";
531     },
532 
533     createCloneInstance: function () {
534         return ccui.CheckBox.create();
535     },
536 
537     copySpecialProperties: function (uiCheckBox) {
538         this.loadTextureBackGround(uiCheckBox._backGroundFileName, uiCheckBox._backGroundTexType);
539         this.loadTextureBackGroundSelected(uiCheckBox._backGroundSelectedFileName, uiCheckBox._backGroundSelectedTexType);
540         this.loadTextureFrontCross(uiCheckBox._frontCrossFileName, uiCheckBox._frontCrossTexType);
541         this.loadTextureBackGroundDisabled(uiCheckBox._backGroundDisabledFileName, uiCheckBox._backGroundDisabledTexType);
542         this.loadTextureFrontCrossDisabled(uiCheckBox._frontCrossDisabledFileName, uiCheckBox._frontCrossDisabledTexType);
543         this.setSelectedState(uiCheckBox._isSelected);
544     }
545 });
546 
547 var _p = ccui.CheckBox.prototype;
548 
549 // Extended properties
550 /** @expose */
551 _p.selected;
552 cc.defineGetterSetter(_p, "selected", _p.getSelectedState, _p.setSelectedState);
553 
554 _p = null;
555 
556 /**
557  * allocates and initializes a UICheckBox.
558  * @constructs
559  * @return {ccui.CheckBox}
560  * @example
561  * // example
562  * var uiCheckBox = ccui.CheckBox.create();
563  */
564 ccui.CheckBox.create = function () {
565     return new ccui.CheckBox();
566 };
567 
568 // Constants
569 //CheckBoxEvent type
570 ccui.CheckBox.EVENT_SELECTED = 0;
571 ccui.CheckBox.EVENT_UNSELECTED = 1;
572 
573 //Render zorder
574 ccui.CheckBox.BOX_RENDERER_ZORDER = -1;
575 ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER = -1;
576 ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER = -1;
577 ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER = -1;
578 ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER = -1;
579