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

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

goog.require('org.apache.royale.core.IBeadModel');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.SimpleCSSStylesWithFlex');
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.html.Group');
goog.require('org.apache.royale.html.List');
goog.require('org.apache.royale.html.beads.GroupView');
goog.require('org.apache.royale.html.beads.layouts.HorizontalFlexLayout');
goog.require('org.apache.royale.html.beads.models.DateChooserModel');
goog.require('org.apache.royale.html.supportClasses.DateChooserHeader');
goog.require('org.apache.royale.html.supportClasses.DateChooserList');
goog.require('org.apache.royale.html.supportClasses.DateHeaderButton');
goog.require('org.apache.royale.utils.loadBeadFromValuesManager');
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.0
 * @constructor
 * @extends {org.apache.royale.html.beads.GroupView}
 * @implements {org.apache.royale.core.IBeadView}
 */
org.apache.royale.html.beads.DateChooserView = function() {
  org.apache.royale.html.beads.DateChooserView.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.DateChooserView, org.apache.royale.html.beads.GroupView);


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


/**
 * @private
 * @type {org.apache.royale.html.beads.models.DateChooserModel}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_model;


/**
 * @private
 * @type {org.apache.royale.html.supportClasses.DateHeaderButton}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView__prevMonthButton;


/**
 * @private
 * @type {org.apache.royale.html.supportClasses.DateHeaderButton}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView__nextMonthButton;


/**
 * @private
 * @type {org.apache.royale.html.supportClasses.DateHeaderButton}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_monthLabel;


/**
 * @private
 * @type {org.apache.royale.html.Group}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer;


/**
 * @private
 * @type {org.apache.royale.html.supportClasses.DateChooserHeader}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_dayNamesContainer;


/**
 * @private
 * @type {org.apache.royale.html.supportClasses.DateChooserList}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_daysContainer;


/**
 * @royaleignorecoercion org.apache.royale.core.UIBase
 * @private
 * @return {Object}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_getHost = function() {
  return this._strand;
};


/**
 * @private
 * @const
 * @type {number}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_controlHeight = 26;


/**
 * @private
 * @const
 * @type {number}
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_commonButtonWidth = 40;


/**
 * @asprivate
 * @private
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_createChildren = function() {
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer = new org.apache.royale.html.Group();
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.addBead(new org.apache.royale.html.beads.layouts.HorizontalFlexLayout());
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.height = this.org_apache_royale_html_beads_DateChooserView_controlHeight;
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.id = "dateChooserMonthButtons";
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.style = new org.apache.royale.core.SimpleCSSStylesWithFlex();
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.style.flexGrow = 0;
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.element.style["flex-grow"] = "0";
  this.org_apache_royale_html_beads_DateChooserView__prevMonthButton = new org.apache.royale.html.supportClasses.DateHeaderButton();
  this.org_apache_royale_html_beads_DateChooserView__prevMonthButton.width = this.org_apache_royale_html_beads_DateChooserView_commonButtonWidth;
  this.org_apache_royale_html_beads_DateChooserView__prevMonthButton.text = "<";
  if (this.org_apache_royale_html_beads_DateChooserView__prevMonthButton.style == null) {
    this.org_apache_royale_html_beads_DateChooserView__prevMonthButton.style = new org.apache.royale.core.SimpleCSSStylesWithFlex();
  }
  this.org_apache_royale_html_beads_DateChooserView__prevMonthButton.style.flexGrow = 0;
  this.org_apache_royale_html_beads_DateChooserView__prevMonthButton.element.style["flex-grow"] = "0";
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.addElement(this.org_apache_royale_html_beads_DateChooserView__prevMonthButton);
  this.org_apache_royale_html_beads_DateChooserView_monthLabel = new org.apache.royale.html.supportClasses.DateHeaderButton();
  this.org_apache_royale_html_beads_DateChooserView_monthLabel.text = "Month Here";
  if (this.org_apache_royale_html_beads_DateChooserView_monthLabel.style == null) {
    this.org_apache_royale_html_beads_DateChooserView_monthLabel.style = new org.apache.royale.core.SimpleCSSStylesWithFlex();
  }
  this.org_apache_royale_html_beads_DateChooserView_monthLabel.style.flexGrow = 1;
  this.org_apache_royale_html_beads_DateChooserView_monthLabel.element.style["flex-grow"] = "1";
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.addElement(this.org_apache_royale_html_beads_DateChooserView_monthLabel);
  this.org_apache_royale_html_beads_DateChooserView__nextMonthButton = new org.apache.royale.html.supportClasses.DateHeaderButton();
  this.org_apache_royale_html_beads_DateChooserView__nextMonthButton.width = this.org_apache_royale_html_beads_DateChooserView_commonButtonWidth;
  this.org_apache_royale_html_beads_DateChooserView__nextMonthButton.text = ">";
  if (this.org_apache_royale_html_beads_DateChooserView__nextMonthButton.style == null) {
    this.org_apache_royale_html_beads_DateChooserView__nextMonthButton.style = new org.apache.royale.core.SimpleCSSStylesWithFlex();
  }
  this.org_apache_royale_html_beads_DateChooserView__nextMonthButton.element.style["flex-grow"] = "0";
  this.org_apache_royale_html_beads_DateChooserView__nextMonthButton.style.flexGrow = 0;
  this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer.addElement(this.org_apache_royale_html_beads_DateChooserView__nextMonthButton);
  this.org_apache_royale_html_beads_DateChooserView_getHost().addElement(this.org_apache_royale_html_beads_DateChooserView_monthButtonsContainer, false);
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer = new org.apache.royale.html.supportClasses.DateChooserHeader();
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.id = "dateChooserDayNames";
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.className = "DateChooserHeader";
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.height = this.org_apache_royale_html_beads_DateChooserView_controlHeight;
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.style = new org.apache.royale.core.SimpleCSSStylesWithFlex();
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.style.flexGrow = 0;
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.element.style["flex-grow"] = "0";
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.element.style["align-items"] = "center";
  
  this.org_apache_royale_html_beads_DateChooserView_getHost().addElement(this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer, false);
  this.org_apache_royale_html_beads_DateChooserView_daysContainer = new org.apache.royale.html.supportClasses.DateChooserList();
  this.org_apache_royale_html_beads_DateChooserView_daysContainer.className = "DateChooserList";
  this.org_apache_royale_html_beads_DateChooserView_daysContainer.id = "dateChooserList";
  this.org_apache_royale_html_beads_DateChooserView_daysContainer.style = new org.apache.royale.core.SimpleCSSStylesWithFlex();
  this.org_apache_royale_html_beads_DateChooserView_daysContainer.style.flexGrow = 1;
  this.org_apache_royale_html_beads_DateChooserView_daysContainer.element.style["flex-grow"] = "1";
  
  this.org_apache_royale_html_beads_DateChooserView_getHost().addElement(this.org_apache_royale_html_beads_DateChooserView_daysContainer, false);
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_DateChooserView_daysContainer, org.apache.royale.events.IEventDispatcher, true).dispatchEvent(new org.apache.royale.events.Event("itemsCreated"));
  this.org_apache_royale_html_beads_DateChooserView_model.addEventListener("selectedDateChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DateChooserView_selectionChangeHandler, this, 'selectionChangeHandler'));
};


/**
 * @asprivate
 * @private
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_updateDisplay = function() {
  this.org_apache_royale_html_beads_DateChooserView_monthLabel.text = this.org_apache_royale_html_beads_DateChooserView_model.monthNames[this.org_apache_royale_html_beads_DateChooserView_model.displayedMonth] + " " + String(this.org_apache_royale_html_beads_DateChooserView_model.displayedYear);
  this.org_apache_royale_html_beads_DateChooserView_dayNamesContainer.dataProvider = this.org_apache_royale_html_beads_DateChooserView_model.dayNames;
  this.org_apache_royale_html_beads_DateChooserView_daysContainer.dataProvider = this.org_apache_royale_html_beads_DateChooserView_model.days;
  this.org_apache_royale_html_beads_DateChooserView_daysContainer.selectedIndex = this.org_apache_royale_html_beads_DateChooserView_model.getIndexForSelectedDate();
};


/**
 * @asprivate
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_selectionChangeHandler = function(event) {
  this.org_apache_royale_html_beads_DateChooserView_updateDisplay();
  this.org_apache_royale_html_beads_DateChooserView_getHost().dispatchEvent(new org.apache.royale.events.Event("selectedDateChanged"));
  this.org_apache_royale_html_beads_DateChooserView_getHost().dispatchEvent(new org.apache.royale.events.Event("change"));
};


/**
 * @asprivate
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.DateChooserView.prototype.org_apache_royale_html_beads_DateChooserView_handleModelChange = function(event) {
  this.org_apache_royale_html_beads_DateChooserView_updateDisplay();
};


org.apache.royale.html.beads.DateChooserView.prototype.set__strand = function(value) {
  org.apache.royale.html.beads.DateChooserView.superClass_.set__strand.apply(this, [ value] );
  this.org_apache_royale_html_beads_DateChooserView_model = org.apache.royale.utils.Language.as(org.apache.royale.utils.loadBeadFromValuesManager(org.apache.royale.core.IBeadModel, "iBeadModel", this._strand), org.apache.royale.html.beads.models.DateChooserModel);
  this.org_apache_royale_html_beads_DateChooserView_model.addEventListener("displayedMonthChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DateChooserView_handleModelChange, this, 'handleModelChange'));
  this.org_apache_royale_html_beads_DateChooserView_model.addEventListener("displayedYearChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DateChooserView_handleModelChange, this, 'handleModelChange'));
  this.org_apache_royale_html_beads_DateChooserView_createChildren();
  this.org_apache_royale_html_beads_DateChooserView_updateDisplay();
};


org.apache.royale.html.beads.DateChooserView.prototype.get__prevMonthButton = function() {
  return this.org_apache_royale_html_beads_DateChooserView__prevMonthButton;
};


org.apache.royale.html.beads.DateChooserView.prototype.get__nextMonthButton = function() {
  return this.org_apache_royale_html_beads_DateChooserView__nextMonthButton;
};


org.apache.royale.html.beads.DateChooserView.prototype.get__dayList = function() {
  return this.org_apache_royale_html_beads_DateChooserView_daysContainer;
};


Object.defineProperties(org.apache.royale.html.beads.DateChooserView.prototype, /** @lends {org.apache.royale.html.beads.DateChooserView.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.DateChooserView.prototype.set__strand},
/**
  * @export
  * @type {org.apache.royale.html.supportClasses.DateHeaderButton} */
prevMonthButton: {
get: org.apache.royale.html.beads.DateChooserView.prototype.get__prevMonthButton},
/**
  * @export
  * @type {org.apache.royale.html.supportClasses.DateHeaderButton} */
nextMonthButton: {
get: org.apache.royale.html.beads.DateChooserView.prototype.get__nextMonthButton},
/**
  * @export
  * @type {org.apache.royale.html.List} */
dayList: {
get: org.apache.royale.html.beads.DateChooserView.prototype.get__dayList}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.DateChooserView.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.DateChooserView'},
        'prevMonthButton': { type: 'org.apache.royale.html.supportClasses.DateHeaderButton', access: 'readonly', declaredBy: 'org.apache.royale.html.beads.DateChooserView'},
        'nextMonthButton': { type: 'org.apache.royale.html.supportClasses.DateHeaderButton', access: 'readonly', declaredBy: 'org.apache.royale.html.beads.DateChooserView'},
        'dayList': { type: 'org.apache.royale.html.List', access: 'readonly', declaredBy: 'org.apache.royale.html.beads.DateChooserView'}
      };
    },
    methods: function () {
      return {
        'DateChooserView': { type: '', declaredBy: 'org.apache.royale.html.beads.DateChooserView'}
      };
    }
  };
};