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

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

goog.require('org.apache.royale.core.IDataGridModel');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.core.UIBase');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.html.ButtonBar');
goog.require('org.apache.royale.html.beads.IDataGridView');
goog.require('org.apache.royale.html.beads.layouts.DataGridLayout');
goog.require('org.apache.royale.html.beads.models.ButtonBarModel');
goog.require('org.apache.royale.html.supportClasses.IDataGridColumn');
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.html.beads.layouts.DataGridLayout}
 */
org.apache.royale.html.beads.layouts.DataGridPercentageLayout = function() {
  org.apache.royale.html.beads.layouts.DataGridPercentageLayout.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.layouts.DataGridPercentageLayout, org.apache.royale.html.beads.layouts.DataGridLayout);


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


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.layouts.DataGridPercentageLayout.prototype.org_apache_royale_html_beads_layouts_DataGridPercentageLayout__strand;


/**
 * @copy org.apache.royale.core.IBeadLayout#layout
 * @export
 * @override
 */
org.apache.royale.html.beads.layouts.DataGridPercentageLayout.prototype.layout = function() {
  if (!org.apache.royale.html.beads.layouts.DataGridPercentageLayout.superClass_.layout.apply(this))
    return false;
  var /** @type {org.apache.royale.core.UIBase} */ host = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_layouts_DataGridPercentageLayout__strand, org.apache.royale.core.UIBase);
  var /** @type {org.apache.royale.core.IUIBase} */ header = org.apache.royale.utils.Language.as(host.view, org.apache.royale.html.beads.IDataGridView).header;
  var /** @type {org.apache.royale.core.IDataGridModel} */ sharedModel = org.apache.royale.utils.Language.as(host.model, org.apache.royale.core.IDataGridModel);
  var /** @type {Array} */ columnLists = org.apache.royale.utils.Language.as(host.view, org.apache.royale.html.beads.IDataGridView).columnLists;
  var /** @type {number} */ columnListCount = sharedModel.columns.length;
  var /** @type {Array} */ buttonWidths = [];
  for (var /** @type {number} */ i = 0; i < columnListCount; i++) {
    var /** @type {org.apache.royale.html.supportClasses.IDataGridColumn} */ dgc = org.apache.royale.utils.Language.as(sharedModel.columns[i], org.apache.royale.html.supportClasses.IDataGridColumn);
    var /** @type {number} */ colWidth = dgc.columnWidth;
    buttonWidths.push(colWidth);
    var /** @type {org.apache.royale.core.UIBase} */ list = org.apache.royale.utils.Language.as(columnLists[i], org.apache.royale.core.UIBase);
    if (!isNaN(dgc.columnWidth)) {
      list.width = NaN;
      list.percentWidth = Number(colWidth);
    }
  }
  var /** @type {org.apache.royale.core.IUIBase} */ listArea = org.apache.royale.utils.Language.as(host.view, org.apache.royale.html.beads.IDataGridView).listArea;
  listArea.dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
  var /** @type {org.apache.royale.html.ButtonBar} */ dgButtonBar = org.apache.royale.utils.Language.as(header, org.apache.royale.html.ButtonBar);
  dgButtonBar.buttonWidths = buttonWidths;
  dgButtonBar.widthType = org.apache.royale.html.beads.models.ButtonBarModel.PERCENT_WIDTHS;
  dgButtonBar.dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
  return true;
};


org.apache.royale.html.beads.layouts.DataGridPercentageLayout.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_layouts_DataGridPercentageLayout__strand = value;
  org.apache.royale.html.beads.layouts.DataGridPercentageLayout.superClass_.set__strand.apply(this, [ value] );
};


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


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.layouts.DataGridPercentageLayout.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.DataGridPercentageLayout'}
      };
    },
    methods: function () {
      return {
        'DataGridPercentageLayout': { type: '', declaredBy: 'org.apache.royale.html.beads.layouts.DataGridPercentageLayout'},
        'layout': { type: 'Boolean', declaredBy: 'org.apache.royale.html.beads.layouts.DataGridPercentageLayout'}
      };
    }
  };
};