function SpeedSelector() 
{
    /**
     * get the current default speed
     * @return the current default speed
     * @type int
     */
    this.getDefaultSpeed = function() {
	return this.fDefaultSpeed;
    }

    /**
     * get the current speed
     * @return the current speed
     * @type int
     */
    this.getCurrentSpeed = function() {
	return this.fSpeed;
    }

    /**
     * get the current gati
     * @return the current gati
     * @type GATI
     */
    this.getCurrentGati = function() {
	return this.fGati;
    }

    /**
     * get the current swara label
     * @return the current swara label
     * @type String
     */
    this.getCurrentSwaraLabel = function() {
	return this.fSwaraLabel;
    }

    /**
     * called when a certain speed is selected (used in testing also)
     * @private
     */
    this.onSpeed = function(speed) {
	this.fSpeed = speed;
	this.fLabelView.nodeValue = this._getMathraiString();
	EventManager.postEvent(EventManager.EVENT_SWARATOOLBAR_SPEEDCHANGED, this, speed);
    }

    /**
     * {@link EventListener} interface implementation
     */
    this.onEvent = function(evt, src, data) {
	if( evt == EventManager.EVENT_SWARA_SELECTED || evt == EventManager.EVENT_NEWSWARASPACER_SELECTED ) {
	    this.fGati         = src.rowView().getGati(src.getCellIndex());
	    this.fDefaultSpeed = src.rowView().pageView().songView().getModel().getDefaultSpeed();
	    this.fSpeed        = data.getSpeed();
	    this.fSwaraLabel   = data.getLabel();
	    this.fLabelView.nodeValue = this._getMathraiString();
	    return;
	}
	else if( evt == EventManager.EVENT_MENU_CLOSED )
	    this.setSelected(false);
    }

    /**
     * {@link ActionHandler} interface implementation
     */
    this.doAction = function(src, actionID) {
	if( src == this ) {
	    var obj = src.getContent();
	    var x = LookAndFeel.findPosX(obj);
	    var y = LookAndFeel.findPosY(obj) + obj.offsetHeight;
	    this.fWholeMenuItem.update();
	    this.fHalfMenuItem.update();
	    this.fQtrMenuItem.update();
	    this.fEighthMenuItem.update();
	    this.fSpeedMenu.show(x,y);
	}
	else {
	    // speed menu item is selected
	    this.onSpeed(actionID);
	}
    }

    /**
     * override of base class method to provide real content
     */
    this.provideContent = function() {
	var div = document.createElement("div");
	div.style.fontSize = "85%";	// need to to this to match toolbar font
	div.style.fontWeight = "bold";	// need to to this to match toolbar font
	div.style.width = "100%";
	if( !Utils.isIE() )		// IE doesnt support table
	    div.style.display  = "table";	// very important for firefox so that arrow
					// div below has a chance to occupy same
					// height as others (and draw at the bottom)
	div.style.height   = "1.5em";	// give some height
	div.style.width    = "3em";

	var div2 = document.createElement("div");
	div2.style.cssFloat = "left";
	div2.style.display  = "inline";
	div2.style.height = "100%";
	div2.style.width  = "1.5em";
	this.fLabelView = document.createTextNode(this._getMathraiString());
	div2.appendChild(this.fLabelView);
	div.appendChild(div2);

	var arrow = document.createElement("div");
	arrow.style.width = "1.5em";
	arrow.style.height = "100%";
	arrow.style.background = LookAndFeel.url("but_arrow.png") + " center right no-repeat";	
	arrow.style.cssFloat = "right";
	arrow.style.display  = "inline";
	div.appendChild(arrow);

	return div;
    }

    /**
     * internal method to get the duration of the current speed as a string
     * @return get the duration as a string
     * @type String
     */
    this._getMathraiString = function() {
	// a bit tricky. We are allocating aksharas for double-speed 
	// This means a quadruple-speed swara occupies 1 akshara,
	// a double-speed swara occupies 2 aksharas, but a whole-note
	// occupies but 2*gati aksharas
	var denom;
	if( this.fSpeed == 0 ) denom = 1;
	else if( this.fSpeed == 1 ) denom = this.fGati;
	else if( this.fSpeed == 2 ) denom = 2*this.fGati;
	else if( this.fSpeed == 3 ) denom = 4*this.fGati;

	return "1/" + denom;
    }

    /**
     * the speed menu that is popped up when the selector is clicked on
     * @type Menu
     * @private
     */
    this.fSpeedMenu = new Menu();
    this.fSpeedMenu.initMenu();

    /**
     * the fourth speed (=> 8 mathrais per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */
    this.fEighthMenuItem = new SpeedMenuItem(3, this);
    this.fSpeedMenu.addItem( this.fEighthMenuItem, this, 3 );

    /**
     * the third speed (=> 4 mathrais per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */
    this.fQtrMenuItem = new SpeedMenuItem(2, this);
    this.fSpeedMenu.addItem( this.fQtrMenuItem, this, 2 );

    /**
     * the second speed (<=> 2 mathrais per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */
    this.fHalfMenuItem = new SpeedMenuItem(1, this);
    this.fSpeedMenu.addItem( this.fHalfMenuItem, this, 1);

    /**
     * the first speed ( <=> 1 mathrai per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */
    this.fWholeMenuItem = new SpeedMenuItem(0, this);
    this.fSpeedMenu.addItem( this.fWholeMenuItem, this, 0);


    /**
     * the current speed
     * @type int
     * @private
     */
    this.fSpeed        = 1;

    /**
     * the current default speed
     * @type int
     * @private
     */
    this.fDefaultSpeed = 1;

    /**
     * the current gati
     * @type GATI
     * @private
     */
    this.fGati         = GATI_CATUSRA;

    /**
     * the current swara label
     * @type String
     * @private
     */
    this.fSwaraLabel   = "S";

    this.initButton(this, null);
    EventManager.addListener(EventManager.EVENT_SWARA_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_NEWSWARASPACER_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_MENU_CLOSED, this);

}
/**
 * @class
 * speed selector - which is part of the swara tool bar - it also
 * implements the @{link EventListener} and @{link ActionHandler} interfaces
 */
@class
speed selector - which is part of the swara tool bar - it also
implements the @{link EventListener} and @{link ActionHandler} interfaces
@class speed selector - which is part of the swara tool bar - it also implements the @ { link EventListener } and @ { link ActionHandler } interfaces
function SpeedSelector() 
{
    this.getDefaultSpeed = function() {
	return this.fDefaultSpeed;
    }
    this.getCurrentSpeed = function() {
	return this.fSpeed;
    }
    this.getCurrentGati = function() {
	return this.fGati;
    }
    this.getCurrentSwaraLabel = function() {
	return this.fSwaraLabel;
    }
    this.onSpeed = function(speed) {
	this.fSpeed = speed;
	this.fLabelView.nodeValue = this._getMathraiString();
	EventManager.postEvent(EventManager.EVENT_SWARATOOLBAR_SPEEDCHANGED, this, speed);
    }
    this.onEvent = function(evt, src, data) {
	if( evt == EventManager.EVENT_SWARA_SELECTED || evt == EventManager.EVENT_NEWSWARASPACER_SELECTED ) {
	    this.fGati         = src.rowView().getGati(src.getCellIndex());
	    this.fDefaultSpeed = src.rowView().pageView().songView().getModel().getDefaultSpeed();
	    this.fSpeed        = data.getSpeed();
	    this.fSwaraLabel   = data.getLabel();
	    this.fLabelView.nodeValue = this._getMathraiString();
	    return;
	}
	else if( evt == EventManager.EVENT_MENU_CLOSED )
	    this.setSelected(false);
    }
    this.doAction = function(src, actionID) {
	if( src == this ) {
	    var obj = src.getContent();
	    var x = LookAndFeel.findPosX(obj);
	    var y = LookAndFeel.findPosY(obj) + obj.offsetHeight;
	    this.fWholeMenuItem.update();
	    this.fHalfMenuItem.update();
	    this.fQtrMenuItem.update();
	    this.fEighthMenuItem.update();
	    this.fSpeedMenu.show(x,y);
	}
	else {
	    this.onSpeed(actionID);
	}
    }
    this.provideContent = function() {
	var div = document.createElement("div");
	div.style.fontSize = "85%";	
	div.style.fontWeight = "bold";	
	div.style.width = "100%";
	if( !Utils.isIE() )		
	    div.style.display  = "table";	
	div.style.height   = "1.5em";	
	div.style.width    = "3em";
	var div2 = document.createElement("div");
	div2.style.cssFloat = "left";
	div2.style.display  = "inline";
	div2.style.height = "100%";
	div2.style.width  = "1.5em";
	this.fLabelView = document.createTextNode(this._getMathraiString());
	div2.appendChild(this.fLabelView);
	div.appendChild(div2);
	var arrow = document.createElement("div");
	arrow.style.width = "1.5em";
	arrow.style.height = "100%";
	arrow.style.background = LookAndFeel.url("but_arrow.png") + " center right no-repeat";	
	arrow.style.cssFloat = "right";
	arrow.style.display  = "inline";
	div.appendChild(arrow);
	return div;
    }
    this._getMathraiString = function() {
	var denom;
	if( this.fSpeed == 0 ) denom = 1;
	else if( this.fSpeed == 1 ) denom = this.fGati;
	else if( this.fSpeed == 2 ) denom = 2*this.fGati;
	else if( this.fSpeed == 3 ) denom = 4*this.fGati;
	return "1/" + denom;
    }
    this.fSpeedMenu = new Menu();
    this.fSpeedMenu.initMenu();
    this.fEighthMenuItem = new SpeedMenuItem(3, this);
    this.fSpeedMenu.addItem( this.fEighthMenuItem, this, 3 );
    this.fQtrMenuItem = new SpeedMenuItem(2, this);
    this.fSpeedMenu.addItem( this.fQtrMenuItem, this, 2 );
    this.fHalfMenuItem = new SpeedMenuItem(1, this);
    this.fSpeedMenu.addItem( this.fHalfMenuItem, this, 1);
    this.fWholeMenuItem = new SpeedMenuItem(0, this);
    this.fSpeedMenu.addItem( this.fWholeMenuItem, this, 0);
    this.fSpeed        = 1;
    this.fDefaultSpeed = 1;
    this.fGati         = GATI_CATUSRA;
    this.fSwaraLabel   = "S";
    this.initButton(this, null);
    EventManager.addListener(EventManager.EVENT_SWARA_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_NEWSWARASPACER_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_MENU_CLOSED, this);
}
function SpeedSelector ( ) { this . getDefaultSpeed = function ( ) { return this . fDefaultSpeed ; } this . getCurrentSpeed = function ( ) { return this . fSpeed ; } this . getCurrentGati = function ( ) { return this . fGati ; } this . getCurrentSwaraLabel = function ( ) { return this . fSwaraLabel ; } this . onSpeed = function ( speed ) { this . fSpeed = speed ; this . fLabelView . nodeValue = this . _getMathraiString ( ) ; EventManager . postEvent ( EventManager . EVENT_SWARATOOLBAR_SPEEDCHANGED , this , speed ) ; } this . onEvent = function ( evt , src , data ) { if ( evt == EventManager . EVENT_SWARA_SELECTED || evt == EventManager . EVENT_NEWSWARASPACER_SELECTED ) { this . fGati = src . rowView ( ) . getGati ( src . getCellIndex ( ) ) ; this . fDefaultSpeed = src . rowView ( ) . pageView ( ) . songView ( ) . getModel ( ) . getDefaultSpeed ( ) ; this . fSpeed = data . getSpeed ( ) ; this . fSwaraLabel = data . getLabel ( ) ; this . fLabelView . nodeValue = this . _getMathraiString ( ) ; return ; } else if ( evt == EventManager . EVENT_MENU_CLOSED ) this . setSelected ( false ) ; } this . doAction = function ( src , actionID ) { if ( src == this ) { var obj = src . getContent ( ) ; var x = LookAndFeel . findPosX ( obj ) ; var y = LookAndFeel . findPosY ( obj ) + obj . offsetHeight ; this . fWholeMenuItem . update ( ) ; this . fHalfMenuItem . update ( ) ; this . fQtrMenuItem . update ( ) ; this . fEighthMenuItem . update ( ) ; this . fSpeedMenu . show ( x , y ) ; } else { this . onSpeed ( actionID ) ; } } this . provideContent = function ( ) { var div = document . createElement ( "div" ) ; div . style . fontSize = "85%" ; div . style . fontWeight = "bold" ; div . style . width = "100%" ; if ( ! Utils . isIE ( ) ) div . style . display = "table" ; div . style . height = "1.5em" ; div . style . width = "3em" ; var div2 = document . createElement ( "div" ) ; div2 . style . cssFloat = "left" ; div2 . style . display = "inline" ; div2 . style . height = "100%" ; div2 . style . width = "1.5em" ; this . fLabelView = document . createTextNode ( this . _getMathraiString ( ) ) ; div2 . appendChild ( this . fLabelView ) ; div . appendChild ( div2 ) ; var arrow = document . createElement ( "div" ) ; arrow . style . width = "1.5em" ; arrow . style . height = "100%" ; arrow . style . background = LookAndFeel . url ( "but_arrow.png" ) + " center right no-repeat" ; arrow . style . cssFloat = "right" ; arrow . style . display = "inline" ; div . appendChild ( arrow ) ; return div ; } this . _getMathraiString = function ( ) { var denom ; if ( this . fSpeed == 0 ) denom = 1 ; else if ( this . fSpeed == 1 ) denom = this . fGati ; else if ( this . fSpeed == 2 ) denom = 2 * this . fGati ; else if ( this . fSpeed == 3 ) denom = 4 * this . fGati ; return "1/" + denom ; } this . fSpeedMenu = new Menu ( ) ; this . fSpeedMenu . initMenu ( ) ; this . fEighthMenuItem = new SpeedMenuItem ( 3 , this ) ; this . fSpeedMenu . addItem ( this . fEighthMenuItem , this , 3 ) ; this . fQtrMenuItem = new SpeedMenuItem ( 2 , this ) ; this . fSpeedMenu . addItem ( this . fQtrMenuItem , this , 2 ) ; this . fHalfMenuItem = new SpeedMenuItem ( 1 , this ) ; this . fSpeedMenu . addItem ( this . fHalfMenuItem , this , 1 ) ; this . fWholeMenuItem = new SpeedMenuItem ( 0 , this ) ; this . fSpeedMenu . addItem ( this . fWholeMenuItem , this , 0 ) ; this . fSpeed = 1 ; this . fDefaultSpeed = 1 ; this . fGati = GATI_CATUSRA ; this . fSwaraLabel = "S" ; this . initButton ( this , null ) ; EventManager . addListener ( EventManager . EVENT_SWARA_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_NEWSWARASPACER_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_MENU_CLOSED , this ) ; }
@class
 speed selector - which is part of the swara tool bar - it also
 implements the @{link EventListener} and @{link ActionHandler} interfaces
@class speed selector - which is part of the swara tool bar - it also implements the @ { link EventListener } and @ { link ActionHandler } interfaces
/**
     * get the current default speed
     * @return the current default speed
     * @type int
     */ /**
     * get the current speed
     * @return the current speed
     * @type int
     */ /**
     * get the current gati
     * @return the current gati
     * @type GATI
     */ /**
     * get the current swara label
     * @return the current swara label
     * @type String
     */ /**
     * called when a certain speed is selected (used in testing also)
     * @private
     */ /**
     * {@link EventListener} interface implementation
     */ /**
     * {@link ActionHandler} interface implementation
     */ // speed menu item is selected
 /**
     * override of base class method to provide real content
     */ // need to to this to match toolbar font
 // need to to this to match toolbar font
 // IE doesnt support table
 // very important for firefox so that arrow
 // div below has a chance to occupy same
 // height as others (and draw at the bottom)
 // give some height
 /**
     * internal method to get the duration of the current speed as a string
     * @return get the duration as a string
     * @type String
     */ // a bit tricky. We are allocating aksharas for double-speed 
 // This means a quadruple-speed swara occupies 1 akshara,
 // a double-speed swara occupies 2 aksharas, but a whole-note
 // occupies but 2*gati aksharas
 /**
     * the speed menu that is popped up when the selector is clicked on
     * @type Menu
     * @private
     */ /**
     * the fourth speed (=> 8 mathrais per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */ /**
     * the third speed (=> 4 mathrais per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */ /**
     * the second speed (<=> 2 mathrais per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */ /**
     * the first speed ( <=> 1 mathrai per akshara in catusra gati) duration menu item
     * @type MenuItem
     * @private
     */ /**
     * the current speed
     * @type int
     * @private
     */ /**
     * the current default speed
     * @type int
     * @private
     */ /**
     * the current gati
     * @type GATI
     * @private
     */ /**
     * the current swara label
     * @type String
     * @private
     */