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

goog.provide('org.apache.royale.jewel.beads.layouts.StyledLayoutBase');

goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.core.LayoutBase');
goog.require('org.apache.royale.core.UIBase');
goog.require('org.apache.royale.core.ValuesManager');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
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.LayoutBase}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase = function() {
  org.apache.royale.jewel.beads.layouts.StyledLayoutBase.base(this, 'constructor');
};
goog.inherits(org.apache.royale.jewel.beads.layouts.StyledLayoutBase, org.apache.royale.core.LayoutBase);


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


/**
 * @export
 * @const
 * @type {string}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.LAYOUT_TYPE_NAMES = "";


/**
 * @protected
 * @type {org.apache.royale.core.UIBase}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.hostComponent;


/**
 * @protected
 * @type {DOMTokenList}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.hostClassList;


/**
 *  Add class selectors when the component is addedToParent
 *  Otherwise component will not get the class selectors when 
 *  perform "removeElement" and then "addElement"
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @export
 * @param {org.apache.royale.events.Event=} event
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.beadsAddedHandler = function(event) {
  event = typeof event !== 'undefined' ? event : null;
  this.initStyleToLayout(this.hostComponent, "itemsExpand");
  this.setHostClassList("itemsExpand", this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsExpand ? "itemsExpand" : "");
  this.initStyleToLayout(this.hostComponent, "itemsHorizontalAlign");
  this.setHostClassList(this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsHorizontalAlign, this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsHorizontalAlign);
  this.initStyleToLayout(this.hostComponent, "itemsVerticalAlign");
  this.setHostClassList(this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsVerticalAlign, this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsVerticalAlign);
};


/**
 *  Get the component layout style and init to if exists
 * 
 *  @asparam component the IUIBase component that host this layout
 *  @asparam cssProperty the style property in css set for the component to retrieve
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @protected
 * @param {org.apache.royale.core.IUIBase} component
 * @param {string} cssProperty
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.initStyleToLayout = function(component, cssProperty) {
  var /** @type {*} */ cssValue = org.apache.royale.core.ValuesManager["valuesImpl"].getValue(component, cssProperty);
  if (cssValue !== undefined) {
    switch (cssProperty) {
      case "itemsExpand":
        if (!this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase_itemsExpandInitialized)
          this.itemsExpand = "true" == cssValue;
        break;
      case "itemsHorizontalAlign":
        if (!this.itemsHorizontalAlign)
          this.itemsHorizontalAlign = String(cssValue);
        break;
      case "itemsVerticalAlign":
        if (!this.itemsVerticalAlign)
          this.itemsVerticalAlign = String(cssValue);
        break;
      default:
        break;
    }
  }
};


/**
 * @protected
 * @type {boolean}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.itemsHorizontalAlignInitialized;


/**
 * @private
 * @type {string}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsHorizontalAlign;


/**
 * @protected
 * @type {boolean}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.itemsVerticalAlignInitialized;


/**
 * @private
 * @type {string}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsVerticalAlign;


/**
 * @private
 * @type {boolean}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.org_apache_royale_jewel_beads_layouts_StyledLayoutBase_itemsExpandInitialized;


/**
 * @private
 * @type {boolean}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsExpand = false;


/**
 * @protected
 * @param {string} oldValue
 * @param {string} newValue
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.setHostClassList = function(oldValue, newValue) {
  if (!this.hostComponent)
    return;
  if (oldValue && this.hostClassList.contains(oldValue)) {
    if (oldValue == newValue)
      return;
    this.hostClassList.remove(oldValue);
  }
  if (newValue)
    this.hostClassList.add(newValue);
};


org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__strand = function(value) {
  org.apache.royale.jewel.beads.layouts.StyledLayoutBase.superClass_.set__strand.apply(this, [ value] );
  this.hostComponent = org.apache.royale.utils.Language.as(this.host, org.apache.royale.core.UIBase);
  this.hostClassList = this.hostComponent.positioner.classList;
  org.apache.royale.utils.Language.as(value, org.apache.royale.events.IEventDispatcher, true).addEventListener("beadsAdded", org.apache.royale.utils.Language.closure(this.beadsAddedHandler, this, 'beadsAddedHandler'));
  this.beadsAddedHandler();
};


org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.get__itemsHorizontalAlign = function() {
  return this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsHorizontalAlign;
};


org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__itemsHorizontalAlign = function(value) {
  if (this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsHorizontalAlign != value) {
    this.setHostClassList(this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsHorizontalAlign, value);
    this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsHorizontalAlign = value;
    this.itemsHorizontalAlignInitialized = true;
  }
};


org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.get__itemsVerticalAlign = function() {
  return this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsVerticalAlign;
};


org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__itemsVerticalAlign = function(value) {
  if (this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsVerticalAlign != value) {
    this.setHostClassList(this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsVerticalAlign, value);
    this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsVerticalAlign = value;
    this.itemsVerticalAlignInitialized = true;
  }
};


org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.get__itemsExpand = function() {
  return this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsExpand;
};


org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__itemsExpand = function(value) {
  if (this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsExpand != value) {
    this.setHostClassList("itemsExpand", value ? "itemsExpand" : "");
    this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase__itemsExpand = value;
    this.org_apache_royale_jewel_beads_layouts_StyledLayoutBase_itemsExpandInitialized = true;
  }
};


Object.defineProperties(org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype, /** @lends {org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__strand},
/**
  * @export
  * @type {string} */
itemsHorizontalAlign: {
get: org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.get__itemsHorizontalAlign,
set: org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__itemsHorizontalAlign},
/**
  * @export
  * @type {string} */
itemsVerticalAlign: {
get: org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.get__itemsVerticalAlign,
set: org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__itemsVerticalAlign},
/**
  * @export
  * @type {boolean} */
itemsExpand: {
get: org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.get__itemsExpand,
set: org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.set__itemsExpand}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.layouts.StyledLayoutBase.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.layouts.StyledLayoutBase'},
        'itemsHorizontalAlign': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.StyledLayoutBase'},
        'itemsVerticalAlign': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.StyledLayoutBase'},
        'itemsExpand': { type: 'Boolean', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.StyledLayoutBase'}
      };
    },
    methods: function () {
      return {
        'StyledLayoutBase': { type: '', declaredBy: 'org.apache.royale.jewel.beads.layouts.StyledLayoutBase'},
        'beadsAddedHandler': { type: 'void', declaredBy: 'org.apache.royale.jewel.beads.layouts.StyledLayoutBase', parameters: function () { return [  { index: 1, type: 'org.apache.royale.events.Event', optional: true } ]; }}
      };
    }
  };
};