function SwaraLyricLabelBox(isSwara)
{
    /**
     * called by base-class when escape key is pressed
     */
    this.onEscape = function() {
	// ESC key - restore to current swara's label and NOT what text box would do
	if( this.fView )  {
	    this.getTextBox().value = this.fOrigContents;
	    this.fView.setLabel(this.fOrigContents);
	}
    }

    /**
     * called to let derived classes handle event
     */
    this.handleEvent = function(evt, src, data) {
    }


    /**
     * {@link EventListener} interface implementation
     */
    this.onEvent = function(evt, src, data) {
	this.handleEvent(evt,src,data);
    }

    this.onDelete = function()  {
	if( this.fisSwaraBox && this.fView ) {
	    if( this.fView.partType() == ROWVIEWPART_SWARA ) {
	      EventManager.postEvent(EventManager.EVENT_SWARATOOLBAR_DELETESWARA, null, null);
	      return true;
	    }
	}
	return false;
    }

    this.onINS = function() 
    {
	if( this.fisSwaraBox && this.fView ) {
	    if( this.fView.partType() == ROWVIEWPART_SWARA ) {
		NotationEditModeController.setInsertMode(!NotationEditModeController.insertMode());
		EventManager.postEvent(EventManager.EVENT_NOTATION_INSERTMODE, null, null);
	    }
	}
    }

    /**
     * called by base-class when key sequence for "next" is pressed
     */
    this.onNext = function() {
	if( !this.fView ) return;
	var s = this.fView.nextSelectable();
	if( !s ) return;
	this.fView.rowView().pageView().songView().selectObject(s);
    }

    /**
     * called by base-class called when key sequence for "prev" is pressed
     */
    this.onPrev = function() {
	if( !this.fView ) return;
	var s = this.fView.prevSelectable();
	if( !s ) return;
	this.fView.rowView().pageView().songView().selectObject(s);
    }


    /**
     * (protected) called when key sequence for "home" is pressed
     * @private
     */
    this.onHome = function() {
	if( this.fView ) {
	    var rowView = this.fView.rowView();
	    var songView = rowView.pageView().songView();
	    var s = rowView.firstSelectable();
	    if( s )
		songView.selectObject(s);
	}
    }

    /**
     * (protected) called when key sequence for "end" is pressed
     * @private
     */
    this.onEnd = function() {
	if( this.fView ) {
	    var rowView = this.fView.rowView();
	    var songView = rowView.pageView().songView();
	    var s = rowView.lastSelectable();
	    if( s )
		songView.selectObject(s);
	}
    }
    
    /**
     * (private) handles up/down navigation
     * @param {boolean}	up	true=> up, false=>down
     * @private
     */
    this.onUpDown = function(up) {
	if( !this.fView ) return;
	var rowView = this.fView.rowView();
	var songView = rowView.pageView().songView();
	var row = ((up) ? songView.getPrevSelectableRow(rowView):songView.getNextSelectableRow(rowView));
	if( !row ) return;
	if( row.isSelectable() ) {
	    songView.selectObject(row);
	    return;
	}

	/*
	 * we want to ideally select the part in the row that
	 * spans the current selected object's column (NOT cell)
	 * index; If such a part is not selectable, we select
	 * the first selectable part that follows it, else
	 * we select the last selectable part
	 */
	var colIndex = rowView.getColumnIndex(this.fView.getCellIndex());
	var p = row.fFirstPart;
	var col = 0;
	var selObj = null;
	var selNext = false;
	while(p != null) {
	    var ncol = col + p.colspan();
	    // if we are to select the next selectable obj, select it
	    if( selNext && p.isSelectable() ) {
		selObj = p;
		break
	    }
	    else if( colIndex >= col && colIndex < ncol )  {
		// if the span of this part includes our column, select it
		if(p.isSelectable()) {
		    selObj = p;
		    break;
		}
		else
		    selNext = true;	// select the next obj
	    }
	    p = p.next;
	    col = ncol;
	}
	if( selObj == null ) selObj = row.lastSelectable();
	if( selObj != null ) 
	    songView.selectObject(selObj);
    }

    /**
     * (protected) called when key sequence for "beginning of next line" is pressed
     * @private
     */
    this.onNextLine = function() {
    }


    /**
     * (protected) called when key sequence for up-arrow is pressed
     * @private
     */
    this.onUp = function() { this.onUpDown(true); }

    /**
     * (protected) called when key sequence for down-arrow is pressed
     * @private
     */
    this.onDown = function() { this.onUpDown(false); }

    /**
     * (protected) called when key sequence for down-arrow is pressed
     * @private
     */
    this.onChange = function() {
    }


    /**
     * (protectwd) derived-classes must call this to initialize us
     */
    this.initSwaraLyricLabelBox = function() {
	this.initLabelBox(!this.fisSwaraBox);
	EventManager.addListener(EventManager.EVENT_SWARA_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_NOTHING_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_NEWSWARASPACER_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_LYRIC_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_HEADING_SELECTED, this);
    }

    /**
     * are we a swara/lyric label box?
     * @type boolean
     * @private
     */
    this.fisSwaraBox = isSwara;

    /**
     * (protected) original contents of a swara/lyric when it is selected
     * @type String
     * @private
     */
    this.fOrigContents = "";
}
/**
 * @class
 * represents base-class for a swara/lyric label edit box. It implements the {@link EventListener}
 * interface.
 *
 * @constructor
 * @param {boolean} isSwara  is this a swara or a lyric label box?
 */
@class
represents base-class for a swara/lyric label edit box. It implements the  EventListener
interface.


@class represents base - class for a swara / lyric label edit box . It implements the EventListener interface .
function SwaraLyricLabelBox(isSwara)
{
    this.onEscape = function() {
	if( this.fView )  {
	    this.getTextBox().value = this.fOrigContents;
	    this.fView.setLabel(this.fOrigContents);
	}
    }
    this.handleEvent = function(evt, src, data) {
    }
    this.onEvent = function(evt, src, data) {
	this.handleEvent(evt,src,data);
    }
    this.onDelete = function()  {
	if( this.fisSwaraBox && this.fView ) {
	    if( this.fView.partType() == ROWVIEWPART_SWARA ) {
	      EventManager.postEvent(EventManager.EVENT_SWARATOOLBAR_DELETESWARA, null, null);
	      return true;
	    }
	}
	return false;
    }
    this.onINS = function() 
    {
	if( this.fisSwaraBox && this.fView ) {
	    if( this.fView.partType() == ROWVIEWPART_SWARA ) {
		NotationEditModeController.setInsertMode(!NotationEditModeController.insertMode());
		EventManager.postEvent(EventManager.EVENT_NOTATION_INSERTMODE, null, null);
	    }
	}
    }
    this.onNext = function() {
	if( !this.fView ) return;
	var s = this.fView.nextSelectable();
	if( !s ) return;
	this.fView.rowView().pageView().songView().selectObject(s);
    }
    this.onPrev = function() {
	if( !this.fView ) return;
	var s = this.fView.prevSelectable();
	if( !s ) return;
	this.fView.rowView().pageView().songView().selectObject(s);
    }
    this.onHome = function() {
	if( this.fView ) {
	    var rowView = this.fView.rowView();
	    var songView = rowView.pageView().songView();
	    var s = rowView.firstSelectable();
	    if( s )
		songView.selectObject(s);
	}
    }
    this.onEnd = function() {
	if( this.fView ) {
	    var rowView = this.fView.rowView();
	    var songView = rowView.pageView().songView();
	    var s = rowView.lastSelectable();
	    if( s )
		songView.selectObject(s);
	}
    }
    this.onUpDown = function(up) {
	if( !this.fView ) return;
	var rowView = this.fView.rowView();
	var songView = rowView.pageView().songView();
	var row = ((up) ? songView.getPrevSelectableRow(rowView):songView.getNextSelectableRow(rowView));
	if( !row ) return;
	if( row.isSelectable() ) {
	    songView.selectObject(row);
	    return;
	}
	var colIndex = rowView.getColumnIndex(this.fView.getCellIndex());
	var p = row.fFirstPart;
	var col = 0;
	var selObj = null;
	var selNext = false;
	while(p != null) {
	    var ncol = col + p.colspan();
	    if( selNext && p.isSelectable() ) {
		selObj = p;
		break
	    }
	    else if( colIndex >= col && colIndex < ncol )  {
		if(p.isSelectable()) {
		    selObj = p;
		    break;
		}
		else
		    selNext = true;	
	    }
	    p = p.next;
	    col = ncol;
	}
	if( selObj == null ) selObj = row.lastSelectable();
	if( selObj != null ) 
	    songView.selectObject(selObj);
    }
    this.onNextLine = function() {
    }
    this.onUp = function() { this.onUpDown(true); }
    this.onDown = function() { this.onUpDown(false); }
    this.onChange = function() {
    }
    this.initSwaraLyricLabelBox = function() {
	this.initLabelBox(!this.fisSwaraBox);
	EventManager.addListener(EventManager.EVENT_SWARA_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_NOTHING_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_NEWSWARASPACER_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_LYRIC_SELECTED, this);
	EventManager.addListener(EventManager.EVENT_HEADING_SELECTED, this);
    }
    this.fisSwaraBox = isSwara;
    this.fOrigContents = "";
}
function SwaraLyricLabelBox ( isSwara ) { this . onEscape = function ( ) { if ( this . fView ) { this . getTextBox ( ) . value = this . fOrigContents ; this . fView . setLabel ( this . fOrigContents ) ; } } this . handleEvent = function ( evt , src , data ) { } this . onEvent = function ( evt , src , data ) { this . handleEvent ( evt , src , data ) ; } this . onDelete = function ( ) { if ( this . fisSwaraBox && this . fView ) { if ( this . fView . partType ( ) == ROWVIEWPART_SWARA ) { EventManager . postEvent ( EventManager . EVENT_SWARATOOLBAR_DELETESWARA , null , null ) ; return true ; } } return false ; } this . onINS = function ( ) { if ( this . fisSwaraBox && this . fView ) { if ( this . fView . partType ( ) == ROWVIEWPART_SWARA ) { NotationEditModeController . setInsertMode ( ! NotationEditModeController . insertMode ( ) ) ; EventManager . postEvent ( EventManager . EVENT_NOTATION_INSERTMODE , null , null ) ; } } } this . onNext = function ( ) { if ( ! this . fView ) return ; var s = this . fView . nextSelectable ( ) ; if ( ! s ) return ; this . fView . rowView ( ) . pageView ( ) . songView ( ) . selectObject ( s ) ; } this . onPrev = function ( ) { if ( ! this . fView ) return ; var s = this . fView . prevSelectable ( ) ; if ( ! s ) return ; this . fView . rowView ( ) . pageView ( ) . songView ( ) . selectObject ( s ) ; } this . onHome = function ( ) { if ( this . fView ) { var rowView = this . fView . rowView ( ) ; var songView = rowView . pageView ( ) . songView ( ) ; var s = rowView . firstSelectable ( ) ; if ( s ) songView . selectObject ( s ) ; } } this . onEnd = function ( ) { if ( this . fView ) { var rowView = this . fView . rowView ( ) ; var songView = rowView . pageView ( ) . songView ( ) ; var s = rowView . lastSelectable ( ) ; if ( s ) songView . selectObject ( s ) ; } } this . onUpDown = function ( up ) { if ( ! this . fView ) return ; var rowView = this . fView . rowView ( ) ; var songView = rowView . pageView ( ) . songView ( ) ; var row = ( ( up ) ? songView . getPrevSelectableRow ( rowView ) : songView . getNextSelectableRow ( rowView ) ) ; if ( ! row ) return ; if ( row . isSelectable ( ) ) { songView . selectObject ( row ) ; return ; } var colIndex = rowView . getColumnIndex ( this . fView . getCellIndex ( ) ) ; var p = row . fFirstPart ; var col = 0 ; var selObj = null ; var selNext = false ; while ( p != null ) { var ncol = col + p . colspan ( ) ; if ( selNext && p . isSelectable ( ) ) { selObj = p ; break } else if ( colIndex >= col && colIndex < ncol ) { if ( p . isSelectable ( ) ) { selObj = p ; break ; } else selNext = true ; } p = p . next ; col = ncol ; } if ( selObj == null ) selObj = row . lastSelectable ( ) ; if ( selObj != null ) songView . selectObject ( selObj ) ; } this . onNextLine = function ( ) { } this . onUp = function ( ) { this . onUpDown ( true ) ; } this . onDown = function ( ) { this . onUpDown ( false ) ; } this . onChange = function ( ) { } this . initSwaraLyricLabelBox = function ( ) { this . initLabelBox ( ! this . fisSwaraBox ) ; EventManager . addListener ( EventManager . EVENT_SWARA_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_NOTHING_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_NEWSWARASPACER_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_LYRIC_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_HEADING_SELECTED , this ) ; } this . fisSwaraBox = isSwara ; this . fOrigContents = "" ; }
@class
 represents base-class for a swara/lyric label edit box.
@class represents base - class for a swara / lyric label edit box .
/**
     * called by base-class when escape key is pressed
     */ // ESC key - restore to current swara's label and NOT what text box would do
 /**
     * called to let derived classes handle event
     */ /**
     * {@link EventListener} interface implementation
     */ /**
     * called by base-class when key sequence for "next" is pressed
     */ /**
     * called by base-class called when key sequence for "prev" is pressed
     */ /**
     * (protected) called when key sequence for "home" is pressed
     * @private
     */ /**
     * (protected) called when key sequence for "end" is pressed
     * @private
     */ /**
     * (private) handles up/down navigation
     * @param {boolean}	up	true=> up, false=>down
     * @private
     */ /*
	 * we want to ideally select the part in the row that
	 * spans the current selected object's column (NOT cell)
	 * index; If such a part is not selectable, we select
	 * the first selectable part that follows it, else
	 * we select the last selectable part
	 */ // if we are to select the next selectable obj, select it
 // if the span of this part includes our column, select it
 // select the next obj
 /**
     * (protected) called when key sequence for "beginning of next line" is pressed
     * @private
     */ /**
     * (protected) called when key sequence for up-arrow is pressed
     * @private
     */ /**
     * (protected) called when key sequence for down-arrow is pressed
     * @private
     */ /**
     * (protected) called when key sequence for down-arrow is pressed
     * @private
     */ /**
     * (protectwd) derived-classes must call this to initialize us
     */ /**
     * are we a swara/lyric label box?
     * @type boolean
     * @private
     */ /**
     * (protected) original contents of a swara/lyric when it is selected
     * @type String
     * @private
     */