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

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

goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('org.apache.royale.core.IRangeModel');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.UIBase');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.events.MouseEvent');
goog.require('org.apache.royale.events.ValueChangeEvent');
goog.require('org.apache.royale.html.beads.ISpinnerView');
goog.require('org.apache.royale.html.supportClasses.SpinnerButton');
goog.require('org.apache.royale.core.IBeadController');
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.IBeadController}
 */
org.apache.royale.html.beads.controllers.SpinnerMouseController = function() {
};


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


/**
 * @private
 * @type {org.apache.royale.core.IRangeModel}
 */
org.apache.royale.html.beads.controllers.SpinnerMouseController.prototype.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel;


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.controllers.SpinnerMouseController.prototype.org_apache_royale_html_beads_controllers_SpinnerMouseController__strand;


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @private
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.beads.controllers.SpinnerMouseController.prototype.org_apache_royale_html_beads_controllers_SpinnerMouseController_decrementClickHandler = function(event) {
  var /** @type {number} */ oldValue = this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value;
  this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value = Math.max(this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.minimum, this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value - this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.stepSize);
  var /** @type {org.apache.royale.events.ValueChangeEvent} */ vce = org.apache.royale.events.ValueChangeEvent.createUpdateEvent(this.org_apache_royale_html_beads_controllers_SpinnerMouseController__strand, "value", oldValue, this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value);
  this.org_apache_royale_html_beads_controllers_SpinnerMouseController__strand.dispatchEvent(vce);
};


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @private
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.beads.controllers.SpinnerMouseController.prototype.org_apache_royale_html_beads_controllers_SpinnerMouseController_incrementClickHandler = function(event) {
  var /** @type {number} */ oldValue = this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value;
  this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value = Math.min(this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.maximum, this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value + this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.stepSize);
  var /** @type {org.apache.royale.events.ValueChangeEvent} */ vce = org.apache.royale.events.ValueChangeEvent.createUpdateEvent(this.org_apache_royale_html_beads_controllers_SpinnerMouseController__strand, "value", oldValue, this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel.value);
  this.org_apache_royale_html_beads_controllers_SpinnerMouseController__strand.dispatchEvent(vce);
};


org.apache.royale.html.beads.controllers.SpinnerMouseController.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_controllers_SpinnerMouseController__strand = value;
  this.org_apache_royale_html_beads_controllers_SpinnerMouseController_rangeModel = value.model;
  
  var /** @type {org.apache.royale.html.beads.ISpinnerView} */ spinnerBead = value.getBeadByType(org.apache.royale.html.beads.ISpinnerView);
  var /** @type {org.apache.royale.html.supportClasses.SpinnerButton} */ incrementButton = spinnerBead.increment;
  var /** @type {org.apache.royale.html.supportClasses.SpinnerButton} */ decrementButton = spinnerBead.decrement;
  goog.events.listen(incrementButton.element, goog.events.EventType.CLICK, org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_controllers_SpinnerMouseController_incrementClickHandler, this, 'incrementClickHandler'));
  goog.events.listen(decrementButton.element, goog.events.EventType.CLICK, org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_controllers_SpinnerMouseController_decrementClickHandler, this, 'decrementClickHandler'));
};


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


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



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