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

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

goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.core.ValuesManager');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.jewel.beads.layouts.SimpleHorizontalLayout');
goog.require('org.apache.royale.core.layout.ILayoutStyleProperties');



/**
 *  Constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @constructor
 * @extends {org.apache.royale.jewel.beads.layouts.SimpleHorizontalLayout}
 * @implements {org.apache.royale.core.layout.ILayoutStyleProperties}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout = function() {
  org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.base(this, 'constructor');
};
goog.inherits(org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout, org.apache.royale.jewel.beads.layouts.SimpleHorizontalLayout);


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


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


/**
 *  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
 * @override
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.beadsAddedHandler = function(event) {
  event = typeof event !== 'undefined' ? event : null;
  org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.superClass_.beadsAddedHandler.apply(this);
  if (this.hostClassList.contains("centered"))
    this.hostClassList.remove("centered");
  this.hostClassList.add("centered");
  this.applyStyleToLayout(this.hostComponent, "gap");
  this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout_setGap(this._gap);
};


/**
 * @private
 * @type {number}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingTop = 0;


/**
 * @private
 * @type {number}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingRight = 0;


/**
 * @private
 * @type {number}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingBottom = 0;


/**
 * @private
 * @type {number}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingLeft = 0;


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


/**
 *  Get the component layout style and apply 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
 * 
 *  @see org.apache.royale.core.layout.ILayoutStyleProperties#applyStyleToLayout(component:IUIBase, cssProperty:String):void
 * 
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @export
 * @param {org.apache.royale.core.IUIBase} component
 * @param {string} cssProperty
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.applyStyleToLayout = function(component, cssProperty) {
  var /** @type {*} */ cssValue = org.apache.royale.core.ValuesManager["valuesImpl"].getValue(component, cssProperty);
  if (cssValue !== undefined) {
    switch (cssProperty) {
      case "gap":
        if (!this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout_gapInitialized)
          this.gap = Number(cssValue);
        break;
      default:
        break;
    }
  }
};


/**
 * @export
 * @const
 * @type {number}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAPS = 10;


/**
 * @export
 * @const
 * @type {number}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAP_STEP = 3;


/**
 * @protected
 * @type {number}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype._gap = 0;


/**
 * @private
 * @param {number} value
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout_setGap = function(value) {
  if (value >= 0 && value <= org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAPS * org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAP_STEP) {
    if (this.hostClassList.contains("gap-" + this._gap + "x" + org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAP_STEP + "px"))
      this.hostClassList.remove("gap-" + this._gap + "x" + org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAP_STEP + "px");
    if (value != 0)
      this.hostClassList.add("gap-" + value + "x" + org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAP_STEP + "px");
  }
  else
    throw new Error("Gap needs to be between 0 and " + org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAPS * org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.GAP_STEP);
};


/**
 * @copy org.apache.royale.core.IBeadLayout#layout
 * @royaleignorecoercion org.apache.royale.core.ILayoutHost
 * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
 * @royaleignorecoercion org.apache.royale.core.IBorderPaddingMarginValuesImpl
 * @export
 * @override
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.layout = function() {
  
  return true;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingTop = function() {
  return this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingTop;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingTop = function(value) {
  this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingTop = value;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingRight = function() {
  return this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingRight;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingRight = function(value) {
  this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingRight = value;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingBottom = function() {
  return this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingBottom;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingBottom = function(value) {
  this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingBottom = value;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingLeft = function() {
  return this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingLeft;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingLeft = function(value) {
  this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout__paddingLeft = value;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__gap = function() {
  return this._gap;
};


org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__gap = function(value) {
  if (this._gap != value) {
    if (this.hostComponent)
      this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout_setGap(value);
    this._gap = value;
    this.org_apache_royale_jewel_beads_layouts_HorizontalCenteredLayout_gapInitialized = true;
  }
};


Object.defineProperties(org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype, /** @lends {org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype} */ {
/**
  * @export
  * @type {number} */
paddingTop: {
get: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingTop,
set: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingTop},
/**
  * @export
  * @type {number} */
paddingRight: {
get: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingRight,
set: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingRight},
/**
  * @export
  * @type {number} */
paddingBottom: {
get: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingBottom,
set: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingBottom},
/**
  * @export
  * @type {number} */
paddingLeft: {
get: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__paddingLeft,
set: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__paddingLeft},
/**
  * @export
  * @type {number} */
gap: {
get: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.get__gap,
set: org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.set__gap}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'paddingTop': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout'},
        'paddingRight': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout'},
        'paddingBottom': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout'},
        'paddingLeft': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout'},
        'gap': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout'}
      };
    },
    methods: function () {
      return {
        'HorizontalCenteredLayout': { type: '', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout'},
        'beadsAddedHandler': { type: 'void', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout', parameters: function () { return [  { index: 1, type: 'org.apache.royale.events.Event', optional: true } ]; }},
        'applyStyleToLayout': { type: 'void', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout', parameters: function () { return [  { index: 1, type: 'org.apache.royale.core.IUIBase', optional: false },{ index: 2, type: 'String', optional: false } ]; }},
        'layout': { type: 'Boolean', declaredBy: 'org.apache.royale.jewel.beads.layouts.HorizontalCenteredLayout'}
      };
    }
  };
};