use of com.codename1.rad.attributes.UIID in project CodenameOne by codenameone.
the class AddThemeEntry method imageBorderWizardActionPerformed.
// GEN-LAST:event_deriveTextDecorationActionPerformed
private void imageBorderWizardActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_imageBorderWizardActionPerformed
deriveBorder.setSelected(false);
ImageBorderWizardTabbedPane iw = new ImageBorderWizardTabbedPane(resources, themeName);
String name = (String) componentName.getSelectedItem();
String uiid;
if (prefix == null || prefix.length() == 0) {
uiid = name + ".border";
} else {
uiid = name + "." + prefix + "border";
}
iw.addToAppliesToList(uiid);
JDialog dlg = new JDialog(SwingUtilities.windowForComponent(this));
dlg.setLayout(new java.awt.BorderLayout());
dlg.add(java.awt.BorderLayout.CENTER, iw);
dlg.pack();
dlg.setLocationRelativeTo(this);
dlg.setModal(true);
dlg.setVisible(true);
Border b = (Border) resources.getTheme(themeName).get(uiid);
if (b != null) {
currentBorder = b;
((CodenameOneComponentWrapper) borderLabel).getCodenameOneComponent().getStyle().setBorder(b);
borderLabel.repaint();
}
}
use of com.codename1.rad.attributes.UIID in project CodenameOne by codenameone.
the class AddThemeEntry method updateThemeHashtable.
/**
* Updates the theme hash with the values from this editor
*/
public void updateThemeHashtable(Hashtable themeRes) {
if (disableRefresh) {
return;
}
String uiid = prefix;
String item = (String) componentName.getSelectedItem();
if (item != null && item.length() > 0) {
uiid = item + "." + prefix;
}
removeKeys(themeRes, uiid);
if (!defineAttribute.isSelected()) {
String val = (String) baseStyle.getSelectedItem();
if (val != null && val.length() > 0) {
switch(baseStyleType.getSelectedIndex()) {
case 0:
themeRes.put(uiid + "derive", val);
break;
case 1:
themeRes.put(uiid + "derive", val + ".sel");
break;
case 2:
themeRes.put(uiid + "derive", val + ".press");
break;
case 3:
themeRes.put(uiid + "derive", val + ".dis");
break;
}
}
}
if (!deriveAlignment.isSelected()) {
switch(alignmentCombo.getSelectedIndex()) {
case 0:
themeRes.put(uiid + "align", new Integer(com.codename1.ui.Component.LEFT));
break;
case 1:
themeRes.put(uiid + "align", new Integer(com.codename1.ui.Component.RIGHT));
break;
default:
themeRes.put(uiid + "align", new Integer(com.codename1.ui.Component.CENTER));
break;
}
}
if (!deriveBackground.isSelected()) {
int index = backgroundType.getSelectedIndex();
themeRes.put(uiid + "bgType", new Byte(BACKGROUND_VALUES[index]));
if (backgroundType.getSelectedIndex() >= BACKGROUND_VALUES_GRADIENT_ARRAY_OFFSET) {
// this is a gradient related type
themeRes.put(uiid + "bgGradient", new Object[] { Integer.valueOf(gradientStartColor.getText(), 16), Integer.valueOf(gradientEndColor.getText(), 16), new Float(((Number) gradientX.getValue()).floatValue()), new Float(((Number) gradientY.getValue()).floatValue()), new Float(((Number) gradientSize.getValue()).floatValue()) });
} else {
// this is an image related type
if (imagesCombo.getSelectedItem() != null && imagesCombo.getSelectedItem().toString().length() > 0) {
themeRes.put(uiid + "bgImage", resources.getImage((String) imagesCombo.getSelectedItem()));
} else {
brokenImage = true;
themeRes.put(uiid + "bgImage", com.codename1.ui.Image.createImage(5, 5));
}
}
}
if (!deriveBackgroundColor.isSelected()) {
themeRes.put(uiid + "bgColor", colorValueBG.getText());
}
if (!deriveBorder.isSelected()) {
if (currentBorder == null) {
themeRes.remove(uiid + "border");
} else {
themeRes.put(uiid + "border", currentBorder);
}
}
if (!deriveFont.isSelected()) {
Object v;
if (bitmapFont.isSelected()) {
String val = (String) bitmapFontValue.getSelectedItem();
if (val != null) {
v = resources.getFont(val);
} else {
v = Font.getDefaultFont();
}
} else {
if (trueTypeFont.getSelectedIndex() > 0) {
Font sys = Font.createSystemFont(FONT_FACE_VALUES[fontFace.getSelectedIndex()], FONT_STYLE_VALUES[fontStyle.getSelectedIndex()], FONT_SIZE_VALUES[fontSize.getSelectedIndex()]);
String selectedItem = (String) trueTypeFont.getSelectedItem();
if (selectedItem.startsWith("native:")) {
v = new EditorTTFFont(selectedItem, trueTypeFontSizeOption.getSelectedIndex(), ((Number) trueTypeFontSizeValue.getValue()).floatValue(), sys);
} else {
v = new EditorTTFFont(new File(ResourceEditorView.getLoadedFile().getParentFile(), selectedItem), trueTypeFontSizeOption.getSelectedIndex(), ((Number) trueTypeFontSizeValue.getValue()).floatValue(), sys);
}
} else {
v = Font.createSystemFont(FONT_FACE_VALUES[fontFace.getSelectedIndex()], FONT_STYLE_VALUES[fontStyle.getSelectedIndex()], FONT_SIZE_VALUES[fontSize.getSelectedIndex()]);
}
}
themeRes.put(uiid + "font", v);
}
if (!deriveForegroundColor.isSelected()) {
themeRes.put(uiid + "fgColor", colorValueFG.getText());
}
if (!deriveMargin.isSelected()) {
themeRes.put(uiid + "margin", marginTop.getValue() + "," + marginBottom.getValue() + "," + marginLeft.getValue() + "," + marginRight.getValue());
byte[] padUnit = new byte[4];
padUnit[com.codename1.ui.Component.BOTTOM] = (byte) marginBottomUnit.getSelectedIndex();
padUnit[com.codename1.ui.Component.TOP] = (byte) marginTopUnit.getSelectedIndex();
padUnit[com.codename1.ui.Component.LEFT] = (byte) marginLeftUnit.getSelectedIndex();
padUnit[com.codename1.ui.Component.RIGHT] = (byte) marginRightUnit.getSelectedIndex();
updateThemeRes(padUnit, themeRes, uiid + "marUnit");
}
if (!derivePadding.isSelected()) {
themeRes.put(uiid + "padding", paddingTop.getValue() + "," + paddingBottom.getValue() + "," + paddingLeft.getValue() + "," + paddingRight.getValue());
byte[] padUnit = new byte[4];
padUnit[com.codename1.ui.Component.BOTTOM] = (byte) paddingBottomUnit.getSelectedIndex();
padUnit[com.codename1.ui.Component.TOP] = (byte) paddingTopUnit.getSelectedIndex();
padUnit[com.codename1.ui.Component.LEFT] = (byte) paddingLeftUnit.getSelectedIndex();
padUnit[com.codename1.ui.Component.RIGHT] = (byte) paddingRightUnit.getSelectedIndex();
updateThemeRes(padUnit, themeRes, uiid + "padUnit");
}
if (!deriveTextDecoration.isSelected()) {
Object v;
switch(textDecorationCombo.getSelectedIndex()) {
case 1:
v = new Integer(com.codename1.ui.plaf.Style.TEXT_DECORATION_UNDERLINE);
break;
case 2:
v = new Integer(com.codename1.ui.plaf.Style.TEXT_DECORATION_STRIKETHRU);
break;
case 3:
v = new Integer(com.codename1.ui.plaf.Style.TEXT_DECORATION_3D);
break;
case 4:
v = new Integer(com.codename1.ui.plaf.Style.TEXT_DECORATION_3D_LOWERED);
break;
case 5:
v = new Integer(com.codename1.ui.plaf.Style.TEXT_DECORATION_3D_SHADOW_NORTH);
break;
default:
v = new Integer(0);
break;
}
themeRes.put(uiid + "textDecoration", v);
}
if (!deriveTransparency.isSelected()) {
themeRes.put(uiid + "transparency", "" + transparencyValue.getValue());
}
}
use of com.codename1.rad.attributes.UIID in project CodenameOne by codenameone.
the class Dialog method placeButtonCommands.
/**
* Places the given commands in the dialog command area, this is very useful for touch devices.
*
* @param cmds the commands to place
* @deprecated this method shouldn't be invoked externally, it should have been private
*/
public void placeButtonCommands(Command[] cmds) {
buttonCommands = cmds;
Container buttonArea;
if (getUIManager().isThemeConstant("dlgCommandGridBool", false)) {
buttonArea = new Container(new GridLayout(1, cmds.length));
} else {
buttonArea = new Container(new FlowLayout(CENTER));
}
buttonArea.setUIID("DialogCommandArea");
String uiid = getUIManager().getThemeConstant("dlgButtonCommandUIID", null);
addButtonBar(buttonArea);
if (cmds.length > 0) {
String lineColor = getUIManager().getThemeConstant("dlgInvisibleButtons", null);
if (cmds.length > 3) {
lineColor = null;
}
int largest = Integer.parseInt(getUIManager().getThemeConstant("dlgCommandButtonSizeInt", "0"));
for (int iter = 0; iter < cmds.length; iter++) {
Button b = new Button(cmds[iter]);
if (uiid != null) {
b.setUIID(uiid);
}
// special case for dialog butons uppercase on Android
if (Button.isCapsTextDefault()) {
b.setCapsText(true);
}
largest = Math.max(b.getPreferredW(), largest);
if (lineColor != null && lineColor.length() > 0) {
int color = Integer.parseInt(lineColor, 16);
Border brd = null;
if (iter < cmds.length - 1) {
brd = Border.createCompoundBorder(Border.createLineBorder(1, color), null, null, Border.createLineBorder(1, color));
} else {
brd = Border.createCompoundBorder(Border.createLineBorder(1, color), null, null, null);
}
b.getUnselectedStyle().setBorder(brd);
b.getSelectedStyle().setBorder(brd);
b.getPressedStyle().setBorder(brd);
}
buttonArea.addComponent(b);
}
for (int iter = 0; iter < cmds.length; iter++) {
buttonArea.getComponentAt(iter).setPreferredW(largest);
}
buttonArea.getComponentAt(0).requestFocus();
}
}
use of com.codename1.rad.attributes.UIID in project CodenameOne by codenameone.
the class SideMenuBar method installLeftCommands.
void installLeftCommands() {
if (leftCommands != null) {
for (int i = 0; i < leftCommands.size(); i++) {
Command leftCommand = (Command) leftCommands.get(leftCommands.size() - 1 - i);
String uiid = (String) leftCommand.getClientProperty("uiid");
String landscapeUiid = (String) leftCommand.getClientProperty("luiid");
if (uiid == null) {
uiid = "TitleCommand";
if (landscapeUiid == null && UIManager.getInstance().isThemeConstant("landscapeTitleUiidBool", false)) {
landscapeUiid = uiid + "Landscape";
}
}
int txtPosition = Component.RIGHT;
Integer pos = (Integer) leftCommand.getClientProperty("textPosition");
if (pos != null) {
txtPosition = pos.intValue();
}
Layout l = getTitleAreaContainer().getLayout();
if (l instanceof BorderLayout) {
Button b = new Button(leftCommand);
b.setUIID(uiid, landscapeUiid);
b.putClientProperty("TitleCommand", Boolean.TRUE);
b.setTextPosition(txtPosition);
BorderLayout bl = (BorderLayout) l;
Component west = bl.getWest();
if (west == null) {
getTitleAreaContainer().addComponent(BorderLayout.WEST, b);
} else {
if (west instanceof Container) {
Container cnt = (Container) west;
// check if this command is already added
boolean shouldAdd = true;
for (int j = 0; j < cnt.getComponentCount(); j++) {
Component c = cnt.getComponentAt(j);
if (c instanceof Button) {
Command cc = ((Button) c).getCommand();
if (cc != null && cc.equals(b.getCommand())) {
shouldAdd = false;
break;
}
}
}
if (shouldAdd) {
cnt.addComponent(b);
}
} else {
if (west instanceof Button) {
Command cc = ((Button) west).getCommand();
if (cc != null && cc.equals(b.getCommand())) {
continue;
}
}
west.getParent().removeComponent(west);
Container buttons = new Container(new BoxLayout(BoxLayout.X_AXIS));
buttons.addComponent(west);
buttons.addComponent(b);
getTitleAreaContainer().addComponent(BorderLayout.WEST, buttons);
}
}
}
}
}
initTitleBarStatus();
}
use of com.codename1.rad.attributes.UIID in project CodenameOne by codenameone.
the class SideMenuBar method installRightCommands.
void installRightCommands() {
if (rightCommands != null) {
for (int i = 0; i < rightCommands.size(); i++) {
Command rightCommand = (Command) rightCommands.get(rightCommands.size() - 1 - i);
String uiid = (String) rightCommand.getClientProperty("uiid");
String landscapeUiid = (String) rightCommand.getClientProperty("luiid");
if (uiid == null) {
uiid = "TitleCommand";
if (landscapeUiid == null && UIManager.getInstance().isThemeConstant("landscapeTitleUiidBool", false)) {
landscapeUiid = uiid + "Landscape";
}
}
int txtPosition = Component.RIGHT;
Integer pos = (Integer) rightCommand.getClientProperty("textPosition");
if (pos != null) {
txtPosition = pos.intValue();
}
Layout l = getTitleAreaContainer().getLayout();
if (l instanceof BorderLayout) {
final Button b = new Button(rightCommand);
b.setUIID(uiid, landscapeUiid);
b.putClientProperty("TitleCommand", Boolean.TRUE);
b.setTextPosition(txtPosition);
BorderLayout bl = (BorderLayout) l;
final Component east = bl.getEast();
if (east == null) {
getTitleAreaContainer().addComponent(BorderLayout.EAST, b);
} else {
if (east instanceof Container) {
Container cnt = (Container) east;
// check if this command is already added
boolean shouldAdd = true;
for (int j = 0; j < cnt.getComponentCount(); j++) {
Component c = cnt.getComponentAt(j);
if (c instanceof Button) {
Command cc = ((Button) c).getCommand();
if (cc != null && cc.equals(b.getCommand())) {
shouldAdd = false;
break;
}
}
}
if (shouldAdd) {
cnt.addComponent(b);
}
} else {
if (east instanceof Button) {
Command cc = ((Button) east).getCommand();
if (cc != null && cc.equals(b.getCommand())) {
continue;
}
}
east.getParent().removeComponent(east);
Container buttons = new Container(new BoxLayout(BoxLayout.X_AXIS));
buttons.addComponent(east);
buttons.addComponent(b);
getTitleAreaContainer().addComponent(BorderLayout.EAST, buttons);
}
}
}
}
}
initTitleBarStatus();
}
Aggregations