/**
 * Generated by Apache Royale Compiler from org\apache\royale\jewel\CheckBox.as
 * org.apache.royale.jewel.CheckBox
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.jewel.CheckBox');

goog.require('org.apache.royale.core.StyledUIBase');
goog.require('org.apache.royale.core.WrappedHTMLElement');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.html.util.addElementToWrapper');
goog.require('org.apache.royale.jewel.supportClasses.checkbox.CheckBoxIcon');
goog.require('org.apache.royale.utils.Language');



/**
 *  Constructor.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @constructor
 * @extends {org.apache.royale.core.StyledUIBase}
 */
org.apache.royale.jewel.CheckBox = function() {
  org.apache.royale.jewel.CheckBox.base(this, 'constructor');
  this.typeNames = "jewel checkbox";
};
goog.inherits(org.apache.royale.jewel.CheckBox, org.apache.royale.core.StyledUIBase);


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.jewel.CheckBox', org.apache.royale.jewel.CheckBox);


/**
 * @private
 * @type {org.apache.royale.core.WrappedHTMLElement}
 */
org.apache.royale.jewel.CheckBox.prototype.org_apache_royale_jewel_CheckBox__label;


/**
 * @private
 * @type {org.apache.royale.jewel.supportClasses.checkbox.CheckBoxIcon}
 */
org.apache.royale.jewel.CheckBox.prototype.org_apache_royale_jewel_CheckBox__icon;


/**
 * @private
 * @type {number}
 */
org.apache.royale.jewel.CheckBox.org_apache_royale_jewel_CheckBox__checkNumber = 0;


/**
 * @protected
 * @type {HTMLInputElement}
 */
org.apache.royale.jewel.CheckBox.prototype.input;


/**
 * @protected
 * @type {HTMLSpanElement}
 */
org.apache.royale.jewel.CheckBox.prototype.checkbox;


/**
 * @protected
 * @type {HTMLLabelElement}
 */
org.apache.royale.jewel.CheckBox.prototype.label;


/**
 * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
 * @royaleignorecoercion HTMLLabelElement
 * @royaleignorecoercion HTMLInputElement
 * @royaleignorecoercion HTMLSpanElement
 * @royaleignorecoercion Text
 * @protected
 * @override
 */
org.apache.royale.jewel.CheckBox.prototype.createElement = function() {
  var /** @type {HTMLLabelElement} */ label = document.createElement('label');
  this.input = org.apache.royale.html.util.addElementToWrapper(this, 'input');
  this.input.type = 'checkbox';
  label.appendChild(this.input);
  this.checkbox = document.createElement('span');
  label.appendChild(this.checkbox);
  this.positioner = label;
  this.positioner.royale_wrapper = this;
  return this.element;
};


/**
 * @protected
 * @type {Text}
 */
org.apache.royale.jewel.CheckBox.prototype.textNode;


org.apache.royale.jewel.CheckBox.prototype.get__text = function() {
  
  return this.textNode ? this.textNode.nodeValue : "";
};


org.apache.royale.jewel.CheckBox.prototype.set__text = function(value) {
  
  if (!this.textNode) {
    this.textNode = org.apache.royale.utils.Language.as(document.createTextNode(''), Text);
    this.checkbox.appendChild(this.textNode);
  }
  this.textNode.nodeValue = value;
};


org.apache.royale.jewel.CheckBox.prototype.get__value = function() {
  
  return this.input.value;
};


org.apache.royale.jewel.CheckBox.prototype.set__value = function(newValue) {
  
  this.input.value = newValue;
};


org.apache.royale.jewel.CheckBox.prototype.get__selected = function() {
  
  return this.input.checked;
};


org.apache.royale.jewel.CheckBox.prototype.set__selected = function(value) {
  
  if (this.input.checked == value)
    return;
  var /** @type {Object} */ instance = this.element['JewelCheckbox'];
  if (instance) {
    if (value)
      instance["check"]();
    else
      instance["uncheck"]();
  }
  else
    this.input.checked = value;
  this.dispatchEvent(new org.apache.royale.events.Event(org.apache.royale.events.Event.CHANGE));
};


Object.defineProperties(org.apache.royale.jewel.CheckBox.prototype, /** @lends {org.apache.royale.jewel.CheckBox.prototype} */ {
/**
  * @export
  * @type {string} */
text: {
get: org.apache.royale.jewel.CheckBox.prototype.get__text,
set: org.apache.royale.jewel.CheckBox.prototype.set__text},
/**
  * @export
  * @type {string} */
value: {
get: org.apache.royale.jewel.CheckBox.prototype.get__value,
set: org.apache.royale.jewel.CheckBox.prototype.set__value},
/**
  * @export
  * @type {boolean} */
selected: {
get: org.apache.royale.jewel.CheckBox.prototype.get__selected,
set: org.apache.royale.jewel.CheckBox.prototype.set__selected}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.jewel.CheckBox.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'CheckBox', qName: 'org.apache.royale.jewel.CheckBox', kind: 'class' }] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.CheckBox.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'text': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.CheckBox'},
        'value': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.CheckBox'},
        'selected': { type: 'Boolean', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.CheckBox', metadata: function () { return [ { name: 'Bindable', args: [ { key: '', value: 'change' } ] } ]; }}
      };
    },
    methods: function () {
      return {
        'CheckBox': { type: '', declaredBy: 'org.apache.royale.jewel.CheckBox'}
      };
    },
    metadata: function () { return [  ]; }
  };
};