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

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

goog.require('org.apache.royale.core.ILayoutChild');
goog.require('org.apache.royale.core.ILayoutView');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.LayoutBase');
goog.require('org.apache.royale.core.UIBase');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.core.IDocument');
goog.require('org.apache.royale.html.beads.layouts.IOneFlexibleChildLayout');
goog.require('org.apache.royale.utils.Language');



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


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


/**
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype.org_apache_royale_html_beads_layouts_OneFlexibleChildVerticalLayoutForOverflow_parentSizeChangedHandler = function(event) {
  this.performLayout();
};


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


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


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


/**
 * @copy org.apache.royale.core.IBeadLayout#layout
 * @export
 * @override
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.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_OneFlexibleChildVerticalLayoutForOverflow_document[this.flexibleChild];
  var /** @type {number} */ n = contentView.numElements;
  if (n == 0)
    return false;
  for (var /** @type {number} */ i = 0; i < n; i++) {
    var /** @type {org.apache.royale.core.UIBase} */ child = org.apache.royale.utils.Language.as(contentView.getElementAt(i), org.apache.royale.core.UIBase);
    var /** @type {string} */ display = org.apache.royale.utils.Language.string(getComputedStyle(child.element)["display"]);
    if (display != "flex" && display != "none")
      child.element.style["display"] = "block";
  }
  var /** @type {number} */ h = this.host.height - 1;
  for (i = 0; i < n; i++) {
    child = org.apache.royale.utils.Language.as(contentView.getElementAt(i), org.apache.royale.core.UIBase);
    if (child != this.actualChild)
      h -= child.height;
  }
  this.actualChild.height = h;
  return true;
};


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


org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype.set__strand = function(value) {
  org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.superClass_.set__strand.apply(this, [ value] );
  org.apache.royale.utils.Language.as(this.host.parent, org.apache.royale.events.IEventDispatcher).addEventListener("sizeChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_layouts_OneFlexibleChildVerticalLayoutForOverflow_parentSizeChangedHandler, this, 'parentSizeChangedHandler'));
};


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


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


Object.defineProperties(org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype, /** @lends {org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype.set__strand},
/**
  * @export
  * @type {string} */
flexibleChild: {
get: org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype.get__flexibleChild,
set: org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype.set__flexibleChild}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'OneFlexibleChildVerticalLayoutForOverflow', qName: 'org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow', 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.OneFlexibleChildVerticalLayoutForOverflow.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.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow'},
        'flexibleChild': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow'}
      };
    },
    methods: function () {
      return {
        'OneFlexibleChildVerticalLayoutForOverflow': { type: '', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow'},
        'layout': { type: 'Boolean', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow'},
        'setDocument': { type: 'void', declaredBy: 'org.apache.royale.html.beads.layouts.OneFlexibleChildVerticalLayoutForOverflow', parameters: function () { return [  { index: 1, type: 'Object', optional: false },{ index: 2, type: 'String', optional: true } ]; }}
      };
    }
  };
};