Search in sources :

Example 6 with UIManager

use of com.codename1.ui.plaf.UIManager in project CodenameOne by codenameone.

the class FontImage method setMaterialIcon.

/**
 * <p>Applies a material design icon (one of the MATERIAL_* icon constants) to the given command using the
 * given UIID. Notice that the pressed/selected &amp; disabled states will be set appropriately.</p>
 *
 * @param c a command
 * @param icon one of the MATERIAL_* icons
 * @param uiid the UIID for the command (e.g. TitleCommand)
 * @param size the size of the icon in millimeters
 */
public static void setMaterialIcon(Command c, char icon, String uiid, float size) {
    if (Font.isTrueTypeFileSupported()) {
        UIManager uim = UIManager.getInstance();
        Style s = uim.getComponentStyle(uiid);
        s.setFont(getMaterialDesignFont().derive(rightSize(s, size), Font.STYLE_PLAIN));
        c.setIcon(FontImage.create("" + icon, s));
        Style sel = uim.getComponentSelectedStyle(uiid);
        Style pre = uim.getComponentCustomStyle(uiid, "press");
        Style dis = uim.getComponentCustomStyle(uiid, "dis");
        ;
        if (sel.getFgColor() != s.getFgColor() || (sel.getBgColor() != s.getBgColor()) || (sel.getBgTransparency() != s.getBgTransparency())) {
            sel = new Style(sel);
            sel.setFont(getMaterialDesignFont().derive(rightSize(sel, size), Font.STYLE_PLAIN));
            c.setRolloverIcon(FontImage.create("" + icon, sel));
        }
        if (pre.getFgColor() != s.getFgColor() || (pre.getBgColor() != s.getBgColor()) || (pre.getBgTransparency() != s.getBgTransparency())) {
            pre = new Style(pre);
            pre.setFont(getMaterialDesignFont().derive(rightSize(pre, size), Font.STYLE_PLAIN));
            c.setPressedIcon(FontImage.create("" + icon, pre));
        }
        if (dis.getFgColor() != s.getFgColor() || (dis.getBgColor() != s.getBgColor()) || (dis.getBgTransparency() != s.getBgTransparency())) {
            dis = new Style(dis);
            dis.setFont(getMaterialDesignFont().derive(rightSize(dis, size), Font.STYLE_PLAIN));
            c.setDisabledIcon(FontImage.create("" + icon, dis));
        }
    }
}
Also used : UIManager(com.codename1.ui.plaf.UIManager) Style(com.codename1.ui.plaf.Style)

Example 7 with UIManager

use of com.codename1.ui.plaf.UIManager in project CodenameOne by codenameone.

the class MenuBar method createMenuCancelCommand.

/**
 * Factory method that returns the Form Menu cancel Command.
 * This method can be overridden to customize the Command on the Form.
 *
 * @return Command
 */
protected Command createMenuCancelCommand() {
    UIManager manager = parent.getUIManager();
    LookAndFeel lf = manager.getLookAndFeel();
    return new Command(manager.localize("cancel", "Cancel"), lf.getMenuIcons()[1]);
}
Also used : UIManager(com.codename1.ui.plaf.UIManager) LookAndFeel(com.codename1.ui.plaf.LookAndFeel)

Example 8 with UIManager

use of com.codename1.ui.plaf.UIManager in project CodenameOne by codenameone.

the class MenuBar method refreshTheme.

/**
 * {@inheritDoc}
 */
public void refreshTheme(boolean merge) {
    super.refreshTheme(merge);
    UIManager manager = parent.getUIManager();
    if (menuStyle.isModified() && merge) {
        menuStyle.merge(manager.getComponentStyle("Menu"));
    } else {
        menuStyle = manager.getComponentStyle("Menu");
    }
    if (menuCellRenderer != null) {
        List tmp = new List();
        tmp.setListCellRenderer(menuCellRenderer);
        tmp.refreshTheme(merge);
    }
    for (int iter = 0; iter < soft.length; iter++) {
        updateSoftButtonStyle(soft[iter]);
    }
    revalidate();
}
Also used : UIManager(com.codename1.ui.plaf.UIManager)

Example 9 with UIManager

use of com.codename1.ui.plaf.UIManager in project CodenameOne by codenameone.

the class MenuBar method createMenuSelectCommand.

/**
 * Factory method that returns the Form Menu select Command.
 * This method can be overridden to customize the Command on the Form.
 *
 * @return Command
 */
protected Command createMenuSelectCommand() {
    UIManager manager = parent.getUIManager();
    LookAndFeel lf = manager.getLookAndFeel();
    return new Command(manager.localize("select", "Select"), lf.getMenuIcons()[0]);
}
Also used : UIManager(com.codename1.ui.plaf.UIManager) LookAndFeel(com.codename1.ui.plaf.LookAndFeel)

Example 10 with UIManager

use of com.codename1.ui.plaf.UIManager in project CodenameOne by codenameone.

the class TextField method paint.

/**
 * {@inheritDoc}
 */
public void paint(Graphics g) {
    // the native input will show the string.
    if (useNativeTextInput && Display.getInstance().isNativeEditorVisible(this)) {
        return;
    }
    UIManager manager = getUIManager();
    manager.getLookAndFeel().drawTextField(g, this);
    if (drawCursor && hasFocus() && isEditable()) {
        manager.getLookAndFeel().drawTextFieldCursor(g, this);
    }
    paintHint(g);
}
Also used : UIManager(com.codename1.ui.plaf.UIManager)

Aggregations

UIManager (com.codename1.ui.plaf.UIManager)21 LookAndFeel (com.codename1.ui.plaf.LookAndFeel)9 Style (com.codename1.ui.plaf.Style)5 Image (com.codename1.ui.Image)4 BorderLayout (com.codename1.ui.layouts.BorderLayout)4 FontImage (com.codename1.ui.FontImage)3 ActionEvent (com.codename1.ui.events.ActionEvent)2 ActionListener (com.codename1.ui.events.ActionListener)2 Dimension (com.codename1.ui.geom.Dimension)2 GridLayout (com.codename1.ui.layouts.GridLayout)2 Border (com.codename1.ui.plaf.Border)2 Component (com.codename1.ui.Component)1 Form (com.codename1.ui.Form)1 Label (com.codename1.ui.Label)1 BubbleTransition (com.codename1.ui.animations.BubbleTransition)1 Transition (com.codename1.ui.animations.Transition)1 Rectangle (com.codename1.ui.geom.Rectangle)1 FlowLayout (com.codename1.ui.layouts.FlowLayout)1 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)1 DefaultLookAndFeel (com.codename1.ui.plaf.DefaultLookAndFeel)1