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

goog.provide('org.apache.royale.jewel.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.jewel.Button');
goog.require('org.apache.royale.jewel.beads.controls.spinner.ISpinnerView');
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.4
 * @constructor
 * @implements {org.apache.royale.core.IBeadController}
 */
org.apache.royale.jewel.beads.controllers.SpinnerMouseController = function() {
};


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


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


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


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


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


org.apache.royale.jewel.beads.controllers.SpinnerMouseController.prototype.set__strand = function(value) {
  this.org_apache_royale_jewel_beads_controllers_SpinnerMouseController__strand = value;
  this.org_apache_royale_jewel_beads_controllers_SpinnerMouseController_rangeModel = value.model;
  
  var /** @type {org.apache.royale.jewel.beads.controls.spinner.ISpinnerView} */ spinnerBead = value.getBeadByType(org.apache.royale.jewel.beads.controls.spinner.ISpinnerView);
  var /** @type {org.apache.royale.jewel.Button} */ incrementButton = spinnerBead.increment;
  var /** @type {org.apache.royale.jewel.Button} */ decrementButton = spinnerBead.decrement;
  goog.events.listen(incrementButton.element, goog.events.EventType.CLICK, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_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_jewel_beads_controllers_SpinnerMouseController_decrementClickHandler, this, 'decrementClickHandler'));
};


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


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



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