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

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

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.core.ValuesManager');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.html.beads.models.DividedContainerModel');
goog.require('org.apache.royale.html.supportClasses.IDividedContainerDivider');
goog.require('org.apache.royale.core.IBeadView');
goog.require('org.apache.royale.utils.Language');



/**
 * Constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @constructor
 * @implements {org.apache.royale.core.IBeadView}
 */
org.apache.royale.html.beads.DividedContainerView = function() {
};


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


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.DividedContainerView.prototype.org_apache_royale_html_beads_DividedContainerView__strand;


/**
 * Handles the "childrenAdded" event and generates the separators between them
 * based on the direction of the box.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.DividedContainerView.prototype.handleChildrenAdded = function(event) {
  var /** @type {number} */ n = org.apache.royale.utils.Language.as(this.host, org.apache.royale.core.UIBase).numElements;
  var /** @type {Array} */ seps = [];
  var /** @type {Array} */ adjustments = [];
  if (n > 1) {
    for (var /** @type {number} */ i = 0; i < (n - 1); i++) {
      var /** @type {org.apache.royale.html.supportClasses.IDividedContainerDivider} */ sep = org.apache.royale.utils.Language.as(org.apache.royale.core.ValuesManager["valuesImpl"].newInstance(this.org_apache_royale_html_beads_DividedContainerView__strand, "iDividerFactory"), org.apache.royale.html.supportClasses.IDividedContainerDivider);
      org.apache.royale.utils.Language.as(this.host, org.apache.royale.core.UIBase).addElement(sep);
      seps.push(sep);
      adjustments.push(0);
      sep.model = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_DividedContainerView__strand, org.apache.royale.core.UIBase).model;
      sep.pairIndex = i;
    }
  }
  org.apache.royale.utils.Language.as(org.apache.royale.utils.Language.as(this.host, org.apache.royale.core.UIBase).model, org.apache.royale.html.beads.models.DividedContainerModel).pairAdjustments = adjustments;
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_DividedContainerView__strand, org.apache.royale.events.IEventDispatcher).dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
};


/**
 * @asprivate
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.DividedContainerView.prototype.org_apache_royale_html_beads_DividedContainerView_handlePairAdjustmentChanged = function(event) {
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_DividedContainerView__strand, org.apache.royale.events.IEventDispatcher).dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
};


org.apache.royale.html.beads.DividedContainerView.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_DividedContainerView__strand = value;
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_DividedContainerView__strand, org.apache.royale.events.IEventDispatcher).addEventListener("childrenAdded", org.apache.royale.utils.Language.closure(this.handleChildrenAdded, this, 'handleChildrenAdded'));
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_DividedContainerView__strand, org.apache.royale.core.UIBase).model.addEventListener("pairAdjustmentChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DividedContainerView_handlePairAdjustmentChanged, this, 'handlePairAdjustmentChanged'));
};


org.apache.royale.html.beads.DividedContainerView.prototype.get__host = function() {
  return org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_DividedContainerView__strand, org.apache.royale.core.IUIBase);
};


Object.defineProperties(org.apache.royale.html.beads.DividedContainerView.prototype, /** @lends {org.apache.royale.html.beads.DividedContainerView.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.DividedContainerView.prototype.set__strand},
/**
  * @export
  * @type {org.apache.royale.core.IUIBase} */
host: {
get: org.apache.royale.html.beads.DividedContainerView.prototype.get__host}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.DividedContainerView.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.DividedContainerView'},
        'host': { type: 'org.apache.royale.core.IUIBase', access: 'readonly', declaredBy: 'org.apache.royale.html.beads.DividedContainerView'}
      };
    },
    methods: function () {
      return {
        'DividedContainerView': { type: '', declaredBy: 'org.apache.royale.html.beads.DividedContainerView'}
      };
    }
  };
};