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

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

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.IStyleableObject');
goog.require('org.apache.royale.html.beads.layouts.HorizontalFlexLayout');
goog.require('org.apache.royale.html.beads.models.ButtonBarModel');
goog.require('org.apache.royale.core.IBeadLayout');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @constructor
 * @extends {org.apache.royale.html.beads.layouts.HorizontalFlexLayout}
 * @implements {org.apache.royale.core.IBeadLayout}
 */
org.apache.royale.html.beads.layouts.ButtonBarLayout = function() {
  
  this.org_apache_royale_html_beads_layouts_ButtonBarLayout__widthType = org.apache.royale.html.beads.models.ButtonBarModel.PIXEL_WIDTHS;
  org.apache.royale.html.beads.layouts.ButtonBarLayout.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.layouts.ButtonBarLayout, org.apache.royale.html.beads.layouts.HorizontalFlexLayout);


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


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


/**
 * @private
 * @type {Array}
 */
org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype.org_apache_royale_html_beads_layouts_ButtonBarLayout__buttonWidths = null;


/**
 * @copy org.apache.royale.core.IBeadLayout#layout
 * @royaleignorecoercion org.apache.royale.core.ILayoutChild
 * @royaleignorecoercion org.apache.royale.core.IStrand
 * @royaleignorecoercion org.apache.royale.html.beads.models.ButtonBarModel
 * @export
 * @override
 */
org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype.layout = function() {
  var /** @type {org.apache.royale.core.ILayoutView} */ contentView = this.layoutView;
  var /** @type {Object} */ model = this.host.getBeadByType(org.apache.royale.html.beads.models.ButtonBarModel);
  if (model) {
    this.buttonWidths = model.buttonWidths;
    this.org_apache_royale_html_beads_layouts_ButtonBarLayout__widthType = model.widthType;
  }
  var /** @type {number} */ n = contentView.numElements;
  if (n <= 0)
    return false;
  for (var /** @type {number} */ i = 0; i < n; i++) {
    var /** @type {Object} */ ilc = contentView.getElementAt(i);
    if (ilc == null || !ilc.visible)
      continue;
    if (!org.apache.royale.utils.Language.is(ilc, org.apache.royale.core.IStyleableObject))
      continue;
    
    if (this.buttonWidths) {
      var /** @type {*} */ widthValue = this.buttonWidths[i];
      if (this.org_apache_royale_html_beads_layouts_ButtonBarLayout__widthType == org.apache.royale.html.beads.models.ButtonBarModel.PIXEL_WIDTHS) {
        if (widthValue != null)
          ilc.width = Number(widthValue);
      } else if (this.org_apache_royale_html_beads_layouts_ButtonBarLayout__widthType == org.apache.royale.html.beads.models.ButtonBarModel.PROPORTIONAL_WIDTHS) {
        if (widthValue != null)
          ilc.element.style["flex-grow"] = String(widthValue);
      } else if (this.org_apache_royale_html_beads_layouts_ButtonBarLayout__widthType == org.apache.royale.html.beads.models.ButtonBarModel.PERCENT_WIDTHS) {
        if (widthValue != null)
          ilc.percentWidth = Number(widthValue);
      }
    } else if (!this.org_apache_royale_html_beads_layouts_ButtonBarLayout__widthType == org.apache.royale.html.beads.models.ButtonBarModel.NATURAL_WIDTHS) {
      ilc.element.style["flex-grow"] = "1";
    }
    if (!this.host.isHeightSizedToContent())
      ilc.height = contentView.height;
  }
  return org.apache.royale.html.beads.layouts.ButtonBarLayout.superClass_.layout.apply(this);
};


org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype.get__buttonWidths = function() {
  return this.org_apache_royale_html_beads_layouts_ButtonBarLayout__buttonWidths;
};


org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype.set__buttonWidths = function(value) {
  this.org_apache_royale_html_beads_layouts_ButtonBarLayout__buttonWidths = value;
};


Object.defineProperties(org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype, /** @lends {org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype} */ {
/**
  * @export
  * @type {Array} */
buttonWidths: {
get: org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype.get__buttonWidths,
set: org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype.set__buttonWidths}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.layouts.ButtonBarLayout.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'buttonWidths': { type: 'Array', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.layouts.ButtonBarLayout'}
      };
    },
    methods: function () {
      return {
        'ButtonBarLayout': { type: '', declaredBy: 'org.apache.royale.html.beads.layouts.ButtonBarLayout'},
        'layout': { type: 'Boolean', declaredBy: 'org.apache.royale.html.beads.layouts.ButtonBarLayout'}
      };
    }
  };
};