/*
 * Copyright (c) 2006-2008 MiniMe. Code released under The MIT/X Window System
 * License. Full license text can be found in license.txt
 */
package minime;

/**
 * Creates a default font for each component, for example BUTTON_FONT is for
 * buton.
 * 
 * @author yishu
 * 
 */
public class FontManager
{
    // The Component defualt Font tpye
    /**
     * Font for Button, the font attributes are SYSTEM_FONT, BOLD_STYLE and
     * MEDIUM_FONT
     */
    public final static int BUTTON_FONT = 0;

    /**
     * Font for Icon, the font attributes are SYSTEM_FONT, BOLD_STYLE and
     * MEDIUM_FONT
     */
    public final static int ICON_FONT = 1;

    /**
     * Font for MenuItemComposite, the font attributes are MONOSPACE_FONT,
     * BOLD_STYLE and SMALL_FONT
     */
    public final static int MENUITEMCOMP_FONT = 2;

    /**
     * Font for MenuItem, the font attributes are MONOSPACE_FONT, BOLD_STYLE and
     * MEDIUM_FONT
     */
    public final static int MENUITEM_FONT = 3;

    /**
     * Font for TextPanel, the font attributes are MONOSPACE_FONT, PLAIN_STYLE
     * and MEDIUM_FONT
     */
    public final static int TEXTPANEL_FONT = 4;

    /**
     * Font for EditField, the font attributes are MONOSPACE_FONT, PLAIN_STYLE
     * and MEDIUM_FONT
     */
    public final static int EDITFIELD_FONT = 5;

    /**
     * Font for Label, the font attributes are SYSTEM_FONT, BOLD_STYLE and
     * MEDIUM_FONT
     */
    public final static int LABEL_FONT = 6;

    /**
     * Large Font for Label, the font attributes are SYSTEM_FONT, BOLD_STYLE and
     * LARGE_FONT
     */
    public final static int LABEL_LARGE_FONT = 7;

    /**
     * Font for Pop, the font attributes are MONOSPACE_FONT, BOLD_STYLE and
     * MEDIUM_FONT
     */
    public final static int POPUP_FONT = 8;

    private static Font buttonFont = null;
    private static Font iconFont = null;
    private static Font menuItemCompFont = null;
    private static Font menuItemFont = null;
    private static Font textPanelFont = null;
    private static Font editFieldFont = null;
    private static Font labelFont = null;
    private static Font labelItalicFont = null;
    private static Font popupFont = null;

    /**
     * Get the default font, each component has its own default font.If the type
     * is not in FontManager, return the default font, the attributes are
     * SYSTEM_FONT, PLAIN_STYLE and MEDIUM_FONT.
     * 
     * @param type
     *            component default font type
     * @return component default font
     */
    public static Font getFont(int type)
    {
        switch (type)
        {
            case BUTTON_FONT:
                if (buttonFont == null)
                    buttonFont = new Font(Portability.SYSTEM_FONT, Portability.BOLD_STYLE, Portability.MEDIUM_FONT);
                return buttonFont;
            case ICON_FONT:
                if (iconFont == null)
                    iconFont = new Font(Portability.SYSTEM_FONT, Portability.BOLD_STYLE, Portability.MEDIUM_FONT);
                return iconFont;
            case MENUITEMCOMP_FONT:
                if (menuItemCompFont == null)
                    menuItemCompFont = new Font(Portability.MONOSPACE_FONT, Portability.BOLD_STYLE,
                            Portability.SMALL_FONT);
                return menuItemCompFont;
            case MENUITEM_FONT:
                if (menuItemFont == null)
                    menuItemFont = new Font(Portability.MONOSPACE_FONT, Portability.BOLD_STYLE, Portability.MEDIUM_FONT);
                return menuItemFont;
            case TEXTPANEL_FONT:
                if (textPanelFont == null)
                    textPanelFont = new Font(Portability.MONOSPACE_FONT, Portability.PLAIN_STYLE,
                            Portability.MEDIUM_FONT);
                return textPanelFont;
            case EDITFIELD_FONT:
                if (editFieldFont == null)
                    editFieldFont = new Font(Portability.MONOSPACE_FONT, Portability.PLAIN_STYLE,
                            Portability.MEDIUM_FONT);
                return editFieldFont;
            case LABEL_FONT:
                if (labelFont == null)
                    labelFont = new Font(Portability.SYSTEM_FONT, Portability.BOLD_STYLE, Portability.MEDIUM_FONT);
                return labelFont;
            case LABEL_LARGE_FONT:
                if (labelItalicFont == null)
                    labelItalicFont = new Font(Portability.SYSTEM_FONT, Portability.BOLD_STYLE, Portability.LARGE_FONT);
                return labelItalicFont;
            case POPUP_FONT:
                if (popupFont == null)
                    popupFont = new Font(Portability.MONOSPACE_FONT, Portability.BOLD_STYLE, Portability.MEDIUM_FONT);
                return popupFont;
            default:
                return (new Font(Portability.SYSTEM_FONT, Portability.PLAIN_STYLE, Portability.MEDIUM_FONT));
        }
    }

}
