function FontMenu() 
{
    /**
     * implementation of {@link EventHandler} interface
     */
    this.onEvent = function(evt, src, data) {
	if( evt == EventManager.EVENT_FONT_ADDED ) {
	    var font = src;
	    /*
	     * if we get this event, then that means that a new font
	     * was specified by user (and he has selected it). So we 
	     * add it to our menu item but we also tell our action 
	     * handler that the user has selected the new font
	     */
	    var svFontMenuItems = this.fFontMenuItems;
	    var newFontMenuItems = new Array();
	    var nFonts = svFontMenuItems.length;
	    var i;
	    var added = false;
	    for(i = 0; i < nFonts; i++ ) {
		if( svFontMenuItems[i].font == font )  {
		    return;
		}
		else if ( !added && svFontMenuItems[i].font > font ) {
		    var midx = newFontMenuItems.length;

		    newFontMenuItems[midx] = new Object();
		    newFontMenuItems[midx].font =  font;
		    var m = new FontMenuItem(font);
		    newFontMenuItems[midx].item =  m;
		    // insert a menu item making us as the action handler (we will
		    // handle the "Other..." if necessary before pass on action to
		    // the real action handler
		    this.insertItem(m, svFontMenuItems[i].item, this, font);

		    newFontMenuItems[newFontMenuItems.length]=  svFontMenuItems[i];
		    added = true;
		}
		else
		    newFontMenuItems[newFontMenuItems.length] =  svFontMenuItems[i];
	    }
	    this.fFontMenuItems = newFontMenuItems;
	    if( this.fActionHandler ) {
		this.fActionHandler.doAction(this, font);
	    }
	}
    }

    /**
     * implementation of {@link ActionHandler} interface - called when
     * a font menu item is selected
     */
    this.doAction = function(src, actionID) {
	var font = actionID;
	if( font == "" ) {
	    /*
	     * user selected "Other ...", put up AddFont form. When
	     * user specifies a font there, it will trigger a FONT_ADDED
	     * event which we will catch in our event handler (and
	     * we will pass it on to fActionHandler
	     */
	    var form = new AddFontForm();
	    form.initForm(document.body);
	    var obj = document.body;
	    var x = LookAndFeel.findPosX(obj);
	    var y = LookAndFeel.findPosY(obj);
	    form.show(x,y);
	    return;
	}

	if( font == "Default")
	    font = "";

	if( this.fActionHandler ) {
	    this.fActionHandler.doAction(this, font);
	}
    }

    /**
     * implementation of {@link FontStateProgress} interface
     * @private
     */
    this.onProgress = function(pct) {
	    if(pct == "100") 
		this.onFontsEnumerated();
    }

    /**
     * called when all fonts have been enumerated
     * @private
     */
    this.onFontsEnumerated = function() {
    	var fontList = FontManager.getFonts();
	var nFonts = fontList.length;
	var lfontList = new Array();
	var i;
	for(i = 0; i < nFonts; i++ )
	{
	    var font = fontList[i];
	    if( font.fInstalled == font.INSTALLED_YES )
	    	lfontList[lfontList.length] = font.fName;
	}
	lfontList.sort();

	nFonts = lfontList.length;

	this.fFontMenuItems  = new Array();

	/*
	 * insert menu items making us as the action handler (we will
	 * handle the "Other..." if necessary before pass on action to
	 * the real action handler
	 */
	this.addItem(new  FontMenuItem("Default"), this, "Default");
	var midx;
	for(var i = 0; i < nFonts; i++ ) {
	    midx = this.fFontMenuItems.length;

	    this.fFontMenuItems[midx] = new Object();
	    this.fFontMenuItems[midx].font = lfontList[i];
	    var m = new FontMenuItem(lfontList[i]);

	    this.addItem(m, this, lfontList[i]);
	    this.fFontMenuItems[midx].item = m;
	}
	this.addItem(new  FontMenuItem("Other ..."), this, "");
    }

    /**
     * initialize the menu - menu is usable only after this is called.
     * <p>
     * Note that this is different from {@link Menu#initMenu} which initialized
     * the menu display. This method updates the font states and makes the
     * menu item reflect that. This method must be called <b>after</b>
     * {@link Menu#initMenu} is called.
     *
     * @param {ActionHandler} actionHandler	the action handler which will 
     *						be called when a font is
     *						selected (actionID is the font
     *						name, "" implies user selected
     *						default font)
     */
    this.init = function(actionHandler) {
	this.fActionHandler = actionHandler;
	if( !this.fEnumerated ) {
	    this.fEnumerated = true;
	    FontManager.updateFontStates(this.getContent(), FontManager.getFonts(), this);
	}
	else
	    this.onFontsEnumerated();
    }

    /**
     * have we enumerated all the existing fonts to determine their
     * font states?
     * @type boolean
     * @private
     */
    this.fEnumerated = false;

    EventManager.addListener(EventManager.EVENT_FONT_ADDED, this);

    /**
     * An array representing font menu items {@link FontMenuItem}
     * @type Array
     * @private
     */
    this.fFontMenuItems = null;

    /**
     * the action handler called when font is selected
     */
    this.fActionHandler = null;
}
/**
 * @class
 * represents a menu of selectable fonts. 
 * <p>
 * The menu is usable only after {@link FontMenu#init} is called, to which an 
 * {@link ActionHandler} must be provided. This action handler will be called
 * when a font is selected The actionID is the font name, but if it is "", it
 * implies user selected default font.
 */
@class
represents a menu of selectable fonts.

The menu is usable only after  FontMenu#init is called, to which an
ActionHandler must be provided. This action handler will be called
when a font is selected The actionID is the font name, but if it is "", it
implies user selected default font.
@class represents a menu of selectable fonts . The menu is usable only after FontMenu#init is called to which an ActionHandler must be provided . This action handler will be called when a font is selected The actionID is the font name but if it is " " it implies user selected default font .
function FontMenu() 
{
    this.onEvent = function(evt, src, data) {
	if( evt == EventManager.EVENT_FONT_ADDED ) {
	    var font = src;
	    var svFontMenuItems = this.fFontMenuItems;
	    var newFontMenuItems = new Array();
	    var nFonts = svFontMenuItems.length;
	    var i;
	    var added = false;
	    for(i = 0; i < nFonts; i++ ) {
		if( svFontMenuItems[i].font == font )  {
		    return;
		}
		else if ( !added && svFontMenuItems[i].font > font ) {
		    var midx = newFontMenuItems.length;
		    newFontMenuItems[midx] = new Object();
		    newFontMenuItems[midx].font =  font;
		    var m = new FontMenuItem(font);
		    newFontMenuItems[midx].item =  m;
		    this.insertItem(m, svFontMenuItems[i].item, this, font);
		    newFontMenuItems[newFontMenuItems.length]=  svFontMenuItems[i];
		    added = true;
		}
		else
		    newFontMenuItems[newFontMenuItems.length] =  svFontMenuItems[i];
	    }
	    this.fFontMenuItems = newFontMenuItems;
	    if( this.fActionHandler ) {
		this.fActionHandler.doAction(this, font);
	    }
	}
    }
    this.doAction = function(src, actionID) {
	var font = actionID;
	if( font == "" ) {
	    var form = new AddFontForm();
	    form.initForm(document.body);
	    var obj = document.body;
	    var x = LookAndFeel.findPosX(obj);
	    var y = LookAndFeel.findPosY(obj);
	    form.show(x,y);
	    return;
	}
	if( font == "Default")
	    font = "";
	if( this.fActionHandler ) {
	    this.fActionHandler.doAction(this, font);
	}
    }
    this.onProgress = function(pct) {
	    if(pct == "100") 
		this.onFontsEnumerated();
    }
    this.onFontsEnumerated = function() {
    	var fontList = FontManager.getFonts();
	var nFonts = fontList.length;
	var lfontList = new Array();
	var i;
	for(i = 0; i < nFonts; i++ )
	{
	    var font = fontList[i];
	    if( font.fInstalled == font.INSTALLED_YES )
	    	lfontList[lfontList.length] = font.fName;
	}
	lfontList.sort();
	nFonts = lfontList.length;
	this.fFontMenuItems  = new Array();
	this.addItem(new  FontMenuItem("Default"), this, "Default");
	var midx;
	for(var i = 0; i < nFonts; i++ ) {
	    midx = this.fFontMenuItems.length;
	    this.fFontMenuItems[midx] = new Object();
	    this.fFontMenuItems[midx].font = lfontList[i];
	    var m = new FontMenuItem(lfontList[i]);
	    this.addItem(m, this, lfontList[i]);
	    this.fFontMenuItems[midx].item = m;
	}
	this.addItem(new  FontMenuItem("Other ..."), this, "");
    }
    this.init = function(actionHandler) {
	this.fActionHandler = actionHandler;
	if( !this.fEnumerated ) {
	    this.fEnumerated = true;
	    FontManager.updateFontStates(this.getContent(), FontManager.getFonts(), this);
	}
	else
	    this.onFontsEnumerated();
    }
    this.fEnumerated = false;
    EventManager.addListener(EventManager.EVENT_FONT_ADDED, this);
    this.fFontMenuItems = null;
    this.fActionHandler = null;
}
function FontMenu ( ) { this . onEvent = function ( evt , src , data ) { if ( evt == EventManager . EVENT_FONT_ADDED ) { var font = src ; var svFontMenuItems = this . fFontMenuItems ; var newFontMenuItems = new Array ( ) ; var nFonts = svFontMenuItems . length ; var i ; var added = false ; for ( i = 0 ; i < nFonts ; i ++ ) { if ( svFontMenuItems [ i ] . font == font ) { return ; } else if ( ! added && svFontMenuItems [ i ] . font > font ) { var midx = newFontMenuItems . length ; newFontMenuItems [ midx ] = new Object ( ) ; newFontMenuItems [ midx ] . font = font ; var m = new FontMenuItem ( font ) ; newFontMenuItems [ midx ] . item = m ; this . insertItem ( m , svFontMenuItems [ i ] . item , this , font ) ; newFontMenuItems [ newFontMenuItems . length ] = svFontMenuItems [ i ] ; added = true ; } else newFontMenuItems [ newFontMenuItems . length ] = svFontMenuItems [ i ] ; } this . fFontMenuItems = newFontMenuItems ; if ( this . fActionHandler ) { this . fActionHandler . doAction ( this , font ) ; } } } this . doAction = function ( src , actionID ) { var font = actionID ; if ( font == "" ) { var form = new AddFontForm ( ) ; form . initForm ( document . body ) ; var obj = document . body ; var x = LookAndFeel . findPosX ( obj ) ; var y = LookAndFeel . findPosY ( obj ) ; form . show ( x , y ) ; return ; } if ( font == "Default" ) font = "" ; if ( this . fActionHandler ) { this . fActionHandler . doAction ( this , font ) ; } } this . onProgress = function ( pct ) { if ( pct == "100" ) this . onFontsEnumerated ( ) ; } this . onFontsEnumerated = function ( ) { var fontList = FontManager . getFonts ( ) ; var nFonts = fontList . length ; var lfontList = new Array ( ) ; var i ; for ( i = 0 ; i < nFonts ; i ++ ) { var font = fontList [ i ] ; if ( font . fInstalled == font . INSTALLED_YES ) lfontList [ lfontList . length ] = font . fName ; } lfontList . sort ( ) ; nFonts = lfontList . length ; this . fFontMenuItems = new Array ( ) ; this . addItem ( new FontMenuItem ( "Default" ) , this , "Default" ) ; var midx ; for ( var i = 0 ; i < nFonts ; i ++ ) { midx = this . fFontMenuItems . length ; this . fFontMenuItems [ midx ] = new Object ( ) ; this . fFontMenuItems [ midx ] . font = lfontList [ i ] ; var m = new FontMenuItem ( lfontList [ i ] ) ; this . addItem ( m , this , lfontList [ i ] ) ; this . fFontMenuItems [ midx ] . item = m ; } this . addItem ( new FontMenuItem ( "Other ..." ) , this , "" ) ; } this . init = function ( actionHandler ) { this . fActionHandler = actionHandler ; if ( ! this . fEnumerated ) { this . fEnumerated = true ; FontManager . updateFontStates ( this . getContent ( ) , FontManager . getFonts ( ) , this ) ; } else this . onFontsEnumerated ( ) ; } this . fEnumerated = false ; EventManager . addListener ( EventManager . EVENT_FONT_ADDED , this ) ; this . fFontMenuItems = null ; this . fActionHandler = null ; }
@class
 represents a menu of selectable fonts.
@class represents a menu of selectable fonts .
/**
     * implementation of {@link EventHandler} interface
     */ /*
	     * if we get this event, then that means that a new font
	     * was specified by user (and he has selected it). So we 
	     * add it to our menu item but we also tell our action 
	     * handler that the user has selected the new font
	     */ // insert a menu item making us as the action handler (we will
 // handle the "Other..." if necessary before pass on action to
 // the real action handler
 /**
     * implementation of {@link ActionHandler} interface - called when
     * a font menu item is selected
     */ /*
	     * user selected "Other ...", put up AddFont form. When
	     * user specifies a font there, it will trigger a FONT_ADDED
	     * event which we will catch in our event handler (and
	     * we will pass it on to fActionHandler
	     */ /**
     * implementation of {@link FontStateProgress} interface
     * @private
     */ /**
     * called when all fonts have been enumerated
     * @private
     */ /*
	 * insert menu items making us as the action handler (we will
	 * handle the "Other..." if necessary before pass on action to
	 * the real action handler
	 */ /**
     * initialize the menu - menu is usable only after this is called.
     * <p>
     * Note that this is different from {@link Menu#initMenu} which initialized
     * the menu display. This method updates the font states and makes the
     * menu item reflect that. This method must be called <b>after</b>
     * {@link Menu#initMenu} is called.
     *
     * @param {ActionHandler} actionHandler	the action handler which will 
     *						be called when a font is
     *						selected (actionID is the font
     *						name, "" implies user selected
     *						default font)
     */ /**
     * have we enumerated all the existing fonts to determine their
     * font states?
     * @type boolean
     * @private
     */ /**
     * An array representing font menu items {@link FontMenuItem}
     * @type Array
     * @private
     */ /**
     * the action handler called when font is selected
     */