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

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

goog.require('org.apache.royale.core.IBeadLayout');
goog.require('org.apache.royale.core.IChild');
goog.require('org.apache.royale.core.IContainerBaseStrandChildrenHost');
goog.require('org.apache.royale.core.ILayoutView');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IViewport');
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.TitleBar');
goog.require('org.apache.royale.html.beads.GroupView');
goog.require('org.apache.royale.html.beads.layouts.VerticalFlexLayout');
goog.require('org.apache.royale.html.supportClasses.PanelLayoutProxy');
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
 * @extends {org.apache.royale.html.beads.GroupView}
 * @implements {org.apache.royale.core.IBeadView}
 */
org.apache.royale.html.beads.PanelView = function() {
  org.apache.royale.html.beads.PanelView.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.PanelView, org.apache.royale.html.beads.GroupView);


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


/**
 * @private
 * @type {org.apache.royale.core.UIBase}
 */
org.apache.royale.html.beads.PanelView.prototype.org_apache_royale_html_beads_PanelView__titleBar;


/**
 * @private
 * @type {org.apache.royale.core.UIBase}
 */
org.apache.royale.html.beads.PanelView.prototype.org_apache_royale_html_beads_PanelView__contentArea;


/**
 * @protected
 */
org.apache.royale.html.beads.PanelView.prototype.setupContentAreaLayout = function() {
};


/**
 * @protected
 */
org.apache.royale.html.beads.PanelView.prototype.setupLayout = function() {
  this.org_apache_royale_html_beads_PanelView__titleBar.element.style["flex-grow"] = "0";
  this.org_apache_royale_html_beads_PanelView__titleBar.element.style["order"] = "1";
  
  
  this.org_apache_royale_html_beads_PanelView__contentArea.element.style["flex-grow"] = "1";
  this.org_apache_royale_html_beads_PanelView__contentArea.element.style["order"] = "2";
  this.org_apache_royale_html_beads_PanelView__contentArea.element.style["overflow"] = "auto";
  var /** @type {org.apache.royale.core.IBeadLayout} */ layoutBead = new org.apache.royale.html.beads.layouts.VerticalFlexLayout();
  this._strand.addBead(layoutBead);
};


/**
 * @private
 * @type {org.apache.royale.html.supportClasses.PanelLayoutProxy}
 */
org.apache.royale.html.beads.PanelView.prototype.org_apache_royale_html_beads_PanelView__panelLayoutProxy;


/**
 * @protected
 * @override
 */
org.apache.royale.html.beads.PanelView.prototype.completeSetup = function() {
  org.apache.royale.html.beads.PanelView.superClass_.completeSetup.apply(this);
  this.performLayout(null);
};


/**
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.PanelView.prototype.handleSizeChange = function(event) {
  this.org_apache_royale_html_beads_PanelView__titleBar.percentWidth = 100;
  this.org_apache_royale_html_beads_PanelView__contentArea.percentWidth = 100;
  this.performLayout(event);
};


/**
 * @private
 * @type {boolean}
 */
org.apache.royale.html.beads.PanelView.prototype.org_apache_royale_html_beads_PanelView_sawInitComplete;


/**
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.PanelView.prototype.org_apache_royale_html_beads_PanelView_handleChildrenAdded = function(event) {
  var /** @type {org.apache.royale.core.UIBase} */ host = org.apache.royale.utils.Language.as(this._strand, org.apache.royale.core.UIBase);
  if (this.org_apache_royale_html_beads_PanelView_sawInitComplete || ((host.isHeightSizedToContent() || !isNaN(host.explicitHeight)) && (host.isWidthSizedToContent() || !isNaN(host.explicitWidth)))) {
    this.org_apache_royale_html_beads_PanelView__contentArea.dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
    this.performLayout(event);
  }
};


/**
 * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.PanelView.prototype.org_apache_royale_html_beads_PanelView_handleClose = function(event) {
  this._strand.dispatchEvent(new org.apache.royale.events.Event("close"));
};


org.apache.royale.html.beads.PanelView.prototype.get__titleBar = function() {
  return this.org_apache_royale_html_beads_PanelView__titleBar;
};


org.apache.royale.html.beads.PanelView.prototype.set__titleBar = function(value) {
  this.org_apache_royale_html_beads_PanelView__titleBar = value;
};


org.apache.royale.html.beads.PanelView.prototype.get__contentArea = function() {
  return this.org_apache_royale_html_beads_PanelView__contentArea;
};


org.apache.royale.html.beads.PanelView.prototype.set__contentArea = function(value) {
  this.org_apache_royale_html_beads_PanelView__contentArea = value;
};


org.apache.royale.html.beads.PanelView.prototype.set__strand = function(value) {
  org.apache.royale.html.beads.PanelView.superClass_.set__strand.apply(this, [ value] );
  var /** @type {org.apache.royale.core.UIBase} */ host = value;
  var /** @type {Array} */ beads = host.beads;
  var /** @type {org.apache.royale.core.IBeadLayout} */ transferLayoutBead;
  var /** @type {org.apache.royale.core.IViewport} */ transferViewportBead;
  if (host.beads != null) {
    for (var /** @type {number} */ i = host.beads.length - 1; i >= 0; i--) {
      if (org.apache.royale.utils.Language.is(host.beads[i], org.apache.royale.core.IBeadLayout)) {
        transferLayoutBead = host.beads[i];
        host.beads.splice(i, 1);
      } else if (org.apache.royale.utils.Language.is(host.beads[i], org.apache.royale.core.IViewport)) {
        transferViewportBead = host.beads[i];
        host.beads.splice(i, 1);
      }
    }
  }
  if (!this.org_apache_royale_html_beads_PanelView__titleBar) {
    this.org_apache_royale_html_beads_PanelView__titleBar = new org.apache.royale.html.TitleBar();
  }
  this.org_apache_royale_html_beads_PanelView__titleBar.id = "panelTitleBar";
  this.org_apache_royale_html_beads_PanelView__titleBar.addEventListener("close", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_PanelView_handleClose, this, 'handleClose'));
  this.titleBar.model = host.model;
  if (this.titleBar.parent == null) {
    this._strand.$addElement(this.titleBar);
  }
  if (!this.org_apache_royale_html_beads_PanelView__contentArea) {
    var /** @type {Object} */ cls = org.apache.royale.core.ValuesManager["valuesImpl"].getValue(this._strand, "iPanelContentArea");
    this.org_apache_royale_html_beads_PanelView__contentArea = new cls();
    this.org_apache_royale_html_beads_PanelView__contentArea.id = "panelContent";
    this.org_apache_royale_html_beads_PanelView__contentArea.typeNames = "PanelContent";
    if (transferLayoutBead)
      this.org_apache_royale_html_beads_PanelView__contentArea.addBead(transferLayoutBead);
    else
      this.setupContentAreaLayout();
    if (transferViewportBead)
      this.org_apache_royale_html_beads_PanelView__contentArea.addBead(transferViewportBead);
  }
  
  org.apache.royale.html.beads.PanelView.superClass_.set__strand.apply(this, [ value] );
  if (this.contentArea.parent == null) {
    this._strand.$addElement(this.contentArea);
  }
  this.setupLayout();
};


org.apache.royale.html.beads.PanelView.prototype.get__contentView = function() {
  if (this.org_apache_royale_html_beads_PanelView__panelLayoutProxy == null) {
    this.org_apache_royale_html_beads_PanelView__panelLayoutProxy = new org.apache.royale.html.supportClasses.PanelLayoutProxy(this._strand);
  }
  return this.org_apache_royale_html_beads_PanelView__panelLayoutProxy;
};


Object.defineProperties(org.apache.royale.html.beads.PanelView.prototype, /** @lends {org.apache.royale.html.beads.PanelView.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.UIBase} */
titleBar: {
get: org.apache.royale.html.beads.PanelView.prototype.get__titleBar,
set: org.apache.royale.html.beads.PanelView.prototype.set__titleBar},
/**
  * @export
  * @type {org.apache.royale.core.UIBase} */
contentArea: {
get: org.apache.royale.html.beads.PanelView.prototype.get__contentArea,
set: org.apache.royale.html.beads.PanelView.prototype.set__contentArea},
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.PanelView.prototype.set__strand},
/**
  * @export
  * @type {org.apache.royale.core.ILayoutView} */
contentView: {
get: org.apache.royale.html.beads.PanelView.prototype.get__contentView}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.PanelView.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'titleBar': { type: 'org.apache.royale.core.UIBase', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.PanelView'},
        'contentArea': { type: 'org.apache.royale.core.UIBase', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.PanelView'},
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.html.beads.PanelView'},
        'contentView': { type: 'org.apache.royale.core.ILayoutView', access: 'readonly', declaredBy: 'org.apache.royale.html.beads.PanelView'}
      };
    },
    methods: function () {
      return {
        'PanelView': { type: '', declaredBy: 'org.apache.royale.html.beads.PanelView'}
      };
    }
  };
};