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

goog.provide('org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout');

goog.require('org.apache.royale.core.ILayoutChild');
goog.require('org.apache.royale.core.ILayoutView');
goog.require('org.apache.royale.core.UIBase');
goog.require('org.apache.royale.core.ValuesManager');
goog.require('org.apache.royale.html.beads.layouts.HorizontalLayout');
goog.require('org.apache.royale.core.IDocument');
goog.require('org.apache.royale.html.beads.layouts.IOneFlexibleChildLayout');



/**
 *  Constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @constructor
 * @extends {org.apache.royale.html.beads.layouts.HorizontalLayout}
 * @implements {org.apache.royale.html.beads.layouts.IOneFlexibleChildLayout}
 * @implements {org.apache.royale.core.IDocument}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout = function() {
  org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout, org.apache.royale.html.beads.layouts.HorizontalLayout);


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


/**
 * @private
 * @type {string}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__flexibleChild;


/**
 * @protected
 * @type {org.apache.royale.core.ILayoutChild}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.actualChild;


/**
 * @private
 * @type {Object}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout_document;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__maxWidth;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__maxHeight;


/**
 * @copy org.apache.royale.core.IBeadLayout#layout
 * @royaleignorecoercion org.apache.royale.core.UIBase
 * @export
 * @override
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.layout = function() {
  if (this.flexibleChild == null)
    return false;
  var /** @type {org.apache.royale.core.ILayoutView} */ contentView = this.layoutView;
  this.actualChild = this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout_document[this.flexibleChild];
  contentView.setDisplayStyleForLayout("flex");
  contentView.element.style["flex-flow"] = "row";
  var /** @type {string} */ align = org.apache.royale.utils.Language.string(org.apache.royale.core.ValuesManager["valuesImpl"].getValue(this.host, "alignItems"));
  if (align == "center")
    contentView.element.style["align-items"] = "center";
  var /** @type {number} */ n = contentView.numElements;
  if (n == 0)
    return false;
  for (var /** @type {number} */ i = 0; i < n; i++) {
    var /** @type {Object} */ child = contentView.getElementAt(i);
    child.element.style["flex-grow"] = (child == this.actualChild) ? "1" : "0";
    child.element.style["flex-shrink"] = "0";
    if (!isNaN(child.percentWidth))
      child.element.style["flex-basis"] = child.percentWidth.toString() + "%";
  }
  return true;
};


/**
 * @export
 * @param {Object} document
 * @param {string=} id
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.setDocument = function(document, id) {
  id = typeof id !== 'undefined' ? id : null;
  this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout_document = document;
};


org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.get__flexibleChild = function() {
  return this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__flexibleChild;
};


org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.set__flexibleChild = function(value) {
  this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__flexibleChild = value;
};


org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.get__maxWidth = function() {
  return this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__maxWidth;
};


org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.set__maxWidth = function(value) {
  this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__maxWidth = value;
};


org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.get__maxHeight = function() {
  return this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__maxHeight;
};


org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.set__maxHeight = function(value) {
  this.org_apache_royale_html_beads_layouts_OneFlexibleChildHorizontalLayout__maxHeight = value;
};


Object.defineProperties(org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype, /** @lends {org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype} */ {
/**
  * @export
  * @type {string} */
flexibleChild: {
get: org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.get__flexibleChild,
set: org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.set__flexibleChild},
/**
  * @export
  * @type {number} */
maxWidth: {
get: org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.get__maxWidth,
set: org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.set__maxWidth},
/**
  * @export
  * @type {number} */
maxHeight: {
get: org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.get__maxHeight,
set: org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.set__maxHeight}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'flexibleChild': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout'},
        'maxWidth': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout'},
        'maxHeight': { type: 'Number', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout'}
      };
    },
    methods: function () {
      return {
        'OneFlexibleChildHorizontalLayout': { type: '', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout'},
        'layout': { type: 'Boolean', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout'},
        'setDocument': { type: 'void', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildHorizontalLayout', parameters: function () { return [  { index: 1, type: 'Object', optional: false },{ index: 2, type: 'String', optional: true } ]; }}
      };
    }
  };
};