Search in sources :

Example 26 with UIManager

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

the class SideMenuBar method validateCommandPlacement.

private void validateCommandPlacement(String placement) {
    if (placement == COMMAND_PLACEMENT_VALUE_TOP) {
        ((BorderLayout) getTitleAreaContainer().getLayout()).setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_SCALE);
        if (!(getTitleComponent() instanceof Button)) {
            Button b = new Button(parent.getTitle());
            b.setUIID("Title");
            parent.setTitleComponent(b);
            b.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    openMenu(COMMAND_PLACEMENT_VALUE_TOP);
                }
            });
        }
        return;
    }
    if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
        if (rightSideButton != null && rightSideButton.getParent() != null) {
            return;
        }
        rightSideButton = new Button();
        rightSideButton.setUIID("MenuButtonRight");
        UIManager uim = parent.getUIManager();
        Image i = (Image) uim.getThemeImageConstant("rightSideMenuImage");
        if (i != null) {
            rightSideButton.setIcon(i);
        } else {
            FontImage.setMaterialIcon(rightSideButton, FontImage.MATERIAL_MENU);
        }
        Image p = (Image) uim.getThemeImageConstant("rightSideMenuPressImage");
        if (p != null) {
            rightSideButton.setPressedIcon(p);
        }
        rightSideButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                openMenu(COMMAND_PLACEMENT_VALUE_RIGHT);
            }
        });
        Container ta = getTitleAreaContainer();
        ta.addComponent(BorderLayout.EAST, rightSideButton);
        ta.revalidate();
        return;
    }
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) ActionEvent(com.codename1.ui.events.ActionEvent) UIManager(com.codename1.ui.plaf.UIManager)

Example 27 with UIManager

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

the class SideMenuBar method createOpenButton.

/**
 * Creates the Side Menu open button.
 * @return a Button instance to place on the TitleArea
 */
protected Button createOpenButton() {
    Button ob = new Button();
    ob.setUIID("MenuButton");
    UIManager uim = parent.getUIManager();
    Image i = (Image) uim.getThemeImageConstant("sideMenuImage");
    if (i != null) {
        ob.setIcon(i);
    } else {
        float size = 4.5f;
        try {
            size = Float.parseFloat(uim.getThemeConstant("menuImageSize", "4.5"));
        } catch (Throwable t) {
            Log.e(t);
        }
        FontImage.setMaterialIcon(ob, FontImage.MATERIAL_MENU, size);
    }
    Image p = (Image) uim.getThemeImageConstant("sideMenuPressImage");
    if (p != null) {
        ob.setPressedIcon(p);
    }
    return ob;
}
Also used : UIManager(com.codename1.ui.plaf.UIManager)

Example 28 with UIManager

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

the class Component method initLaf.

/**
 * This method initializes the Component defaults constants
 */
protected void initLaf(UIManager uim) {
    if (uim == getUIManager() && isInitialized()) {
        return;
    }
    selectText = uim.localize("select", "Select");
    LookAndFeel laf = uim.getLookAndFeel();
    animationSpeed = laf.getDefaultSmoothScrollingSpeed();
    rtl = laf.isRTL();
    tactileTouch = isFocusable();
    tensileDragEnabled = laf.isDefaultTensileDrag();
    snapToGrid = laf.isDefaultSnapToGrid();
    alwaysTensile = laf.isDefaultAlwaysTensile();
    tensileHighlightEnabled = laf.isDefaultTensileHighlight();
    scrollOpacityChangeSpeed = laf.getFadeScrollBarSpeed();
    isScrollVisible = laf.isScrollVisible();
    if (tensileHighlightEnabled) {
        tensileLength = 3;
    } else {
        tensileLength = -1;
    }
}
Also used : LookAndFeel(com.codename1.ui.plaf.LookAndFeel)

Example 29 with UIManager

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

the class GameCanvasImplementation method editString.

/**
 * @inheritDoc
 */
public void editString(Component cmp, int maxSize, int constraint, String text, int keyCode) {
    UIManager m = UIManager.getInstance();
    CONFIRM_COMMAND = new Command(m.localize("ok", "OK"), Command.OK, 1);
    CANCEL_COMMAND = new Command(m.localize("cancel", "Cancel"), Command.CANCEL, 2);
    if (mid.getAppProperty("forceBackCommand") != null) {
        canvas.addCommand(MIDP_BACK_COMMAND);
    }
    currentTextBox = new TextBox("", "", maxSize, TextArea.ANY);
    currentTextBox.setCommandListener((CommandListener) canvas);
    currentTextBox.addCommand(CONFIRM_COMMAND);
    currentTextBox.addCommand(CANCEL_COMMAND);
    currentTextComponent = cmp;
    currentTextBox.setMaxSize(maxSize);
    currentTextBox.setString(text);
    currentTextBox.setConstraints(constraint);
    display.setCurrent(currentTextBox);
    ((C) canvas).setDone(false);
    Display.getInstance().invokeAndBlock(((C) canvas));
}
Also used : Command(javax.microedition.lcdui.Command) UIManager(com.codename1.ui.plaf.UIManager) TextBox(javax.microedition.lcdui.TextBox)

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