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 & 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));
}
}
}
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]);
}
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();
}
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]);
}
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);
}
Aggregations