Search in sources :

Example 6 with UIID

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();
    }
}
Also used : CodenameOneComponentWrapper(com.codename1.ui.resource.util.CodenameOneComponentWrapper) BorderLayout(java.awt.BorderLayout) Border(com.codename1.ui.plaf.Border) JDialog(javax.swing.JDialog)

Example 7 with UIID

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());
    }
}
Also used : EditorTTFFont(com.codename1.ui.EditorTTFFont) File(java.io.File) EditorTTFFont(com.codename1.ui.EditorTTFFont) EditorFont(com.codename1.ui.EditorFont) Font(com.codename1.ui.Font)

Example 8 with UIID

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();
    }
}
Also used : GridLayout(com.codename1.ui.layouts.GridLayout) FlowLayout(com.codename1.ui.layouts.FlowLayout) Border(com.codename1.ui.plaf.Border)

Example 9 with UIID

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();
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Layout(com.codename1.ui.layouts.Layout) BoxLayout(com.codename1.ui.layouts.BoxLayout) LayeredLayout(com.codename1.ui.layouts.LayeredLayout) BorderLayout(com.codename1.ui.layouts.BorderLayout) BoxLayout(com.codename1.ui.layouts.BoxLayout)

Example 10 with UIID

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();
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Layout(com.codename1.ui.layouts.Layout) BoxLayout(com.codename1.ui.layouts.BoxLayout) LayeredLayout(com.codename1.ui.layouts.LayeredLayout) BorderLayout(com.codename1.ui.layouts.BorderLayout) BoxLayout(com.codename1.ui.layouts.BoxLayout)

Aggregations

UIID (com.codename1.rad.attributes.UIID)7 Style (com.codename1.ui.plaf.Style)7 Container (com.codename1.ui.Container)4 BorderLayout (com.codename1.ui.layouts.BorderLayout)4 File (java.io.File)4 Component (com.codename1.ui.Component)3 Label (com.codename1.ui.Label)3 UIManager (com.codename1.ui.plaf.UIManager)3 IOException (java.io.IOException)3 ComponentImage (ca.weblite.shared.components.ComponentImage)2 MultiButton (com.codename1.components.MultiButton)2 BadgeUIID (com.codename1.rad.attributes.BadgeUIID)2 IconUIID (com.codename1.rad.attributes.IconUIID)2 ActionNode (com.codename1.rad.nodes.ActionNode)2 ListNode (com.codename1.rad.nodes.ListNode)2 Node (com.codename1.rad.nodes.Node)2 EntityView (com.codename1.rad.ui.EntityView)2 Button (com.codename1.ui.Button)2 Font (com.codename1.ui.Font)2 Image (com.codename1.ui.Image)2