Search in sources :

Example 11 with UIManager

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

the class SideMenuBar method createSideNavigationPanel.

Container createSideNavigationPanel(Vector commands, String placement) {
    Container menu = constructSideNavigationComponent();
    if (getUIManager().isThemeConstant("paintsTitleBarBool", false)) {
        Container bar = new Container();
        bar.setUIID("StatusBarSideMenu");
        addComponentToSideMenu(menu, bar);
    }
    if (!getUIManager().isThemeConstant("sideMenuTensileDragBool", true)) {
        menu.setTensileDragEnabled(false);
    }
    for (int iter = commands.size() - 1; iter > -1; iter--) {
        Command c = (Command) commands.elementAt(iter);
        if (c.getClientProperty(COMMAND_PLACEMENT_KEY) != placement) {
            continue;
        }
        Component cmp = (Component) c.getClientProperty(COMMAND_SIDE_COMPONENT);
        if (cmp != null) {
            if (cmp.getParent() != null) {
                cmp.getParent().removeAll();
            }
            if (c.getClientProperty(COMMAND_ACTIONABLE) != null && c.getClientProperty(COMMAND_ACTIONABLE).equals(Boolean.TRUE)) {
                Container cnt = new Container(new BorderLayout());
                cnt.addComponent(BorderLayout.CENTER, cmp);
                Button btn = createTouchCommandButton(c);
                btn.setParent(cnt);
                cnt.setLeadComponent(btn);
                addComponentToSideMenu(menu, cnt);
            } else {
                addComponentToSideMenu(menu, cmp);
            }
            initTitleBarStatus();
        } else {
            // special case: hide back button that doesn't have text, icon or a side component entry
            if (parent.getBackCommand() == c && (c.getCommandName() == null || c.getCommandName().length() == 0) && c.getIcon() == null) {
                continue;
            }
            addComponentToSideMenu(menu, createTouchCommandButton(c));
        }
    }
    boolean isRTLValue = isRTL();
    if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
        isRTLValue = !isRTLValue;
    }
    UIManager uim = menu.getUIManager();
    boolean shadowEnabled = uim.isThemeConstant("sideMenuShadowBool", true);
    Image sh = (Image) uim.getThemeImageConstant("sideMenuShadowImage");
    if (sh == null && shadowEnabled) {
        sh = Resources.getSystemResource().getImage("sidemenu-shadow.png");
    }
    if (isRTLValue && sh != null) {
        sh = sh.flipHorizontally(true);
    }
    final Image shadow = sh;
    if (shadow == null) {
        return menu;
    } else {
        Container main = new Container(new LayeredLayout());
        Label shadowLabel = new Label();
        shadowLabel.getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER);
        shadowLabel.getStyle().setBgImage(shadow);
        shadowLabel.getStyle().setPadding(0, 0, 0, 0);
        shadowLabel.getStyle().setMargin(0, 0, 0, 0);
        shadowLabel.getStyle().setBgTransparency(0);
        Container c = new Container(new BorderLayout());
        if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
            shadowLabel.setPreferredW(shadow.getWidth());
            c.addComponent(BorderLayout.WEST, shadowLabel);
            shadowLabel.getStyle().setBgImage(shadow.rotate180Degrees(true));
        } else {
            if (placement == COMMAND_PLACEMENT_VALUE_TOP) {
            // shadowLabel.setPreferredH(shadow.getHeight());
            // c.addComponent(BorderLayout.SOUTH, shadowLabel);
            // shadowLabel.getStyle().setBgImage(shadow.rotate90Degrees(true));
            } else {
                shadowLabel.setPreferredW(shadow.getWidth());
                c.addComponent(BorderLayout.EAST, shadowLabel);
            }
        }
        main.addComponent(menu);
        main.addComponent(c);
        return main;
    }
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) UIManager(com.codename1.ui.plaf.UIManager) LayeredLayout(com.codename1.ui.layouts.LayeredLayout)

Example 12 with UIManager

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

the class Tabs method initLaf.

/**
 * {@inheritDoc}
 */
protected void initLaf(UIManager manager) {
    super.initLaf(manager);
    int tabPlace = manager.getThemeConstant("tabPlacementInt", -1);
    tabsFillRows = manager.isThemeConstant("tabsFillRowsBool", false);
    tabsGridLayout = manager.isThemeConstant("tabsGridBool", false);
    changeTabOnFocus = manager.isThemeConstant("changeTabOnFocusBool", false);
    BorderLayout bd = (BorderLayout) super.getLayout();
    if (bd != null) {
        if (manager.isThemeConstant("tabsOnTopBool", false)) {
            if (bd.getCenterBehavior() != BorderLayout.CENTER_BEHAVIOR_TOTAL_BELOW) {
                bd.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_TOTAL_BELOW);
                checkTabsCanBeSeen();
            }
        } else {
            bd.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_SCALE);
        }
    }
    changeTabContainerStyleOnFocus = manager.isThemeConstant("changeTabContainerStyleOnFocusBool", false);
    if (tabPlace != -1) {
        tabPlacement = tabPlace;
    }
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout)

Example 13 with UIManager

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

the class TextArea method initLaf.

/**
 * {@inheritDoc}
 */
protected void initLaf(UIManager uim) {
    super.initLaf(uim);
    setSelectCommandText(uim.localize("edit", "Edit"));
    LookAndFeel laf = uim.getLookAndFeel();
    setSmoothScrolling(laf.isDefaultSmoothScrolling());
}
Also used : LookAndFeel(com.codename1.ui.plaf.LookAndFeel)

Example 14 with UIManager

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

the class DefaultLookAndFeel method updateCheckBoxConstants.

private void updateCheckBoxConstants(UIManager m, boolean focus, String append) {
    Image checkSel = m.getThemeImageConstant("checkBoxChecked" + append + "Image");
    if (checkSel != null) {
        Image checkUnsel = m.getThemeImageConstant("checkBoxUnchecked" + append + "Image");
        if (checkUnsel != null) {
            Image disUnsel = m.getThemeImageConstant("checkBoxUncheckDis" + append + "Image");
            Image disSel = m.getThemeImageConstant("checkBoxCheckDis" + append + "Image");
            if (disSel == null) {
                disSel = checkSel;
            }
            if (disUnsel == null) {
                disUnsel = checkUnsel;
            }
            if (focus) {
                setCheckBoxFocusImages(checkSel, checkUnsel, disSel, disUnsel);
            } else {
                setCheckBoxImages(checkSel, checkUnsel, disSel, disUnsel);
            }
        }
        if (checkUnsel != null) {
            if (focus) {
                setCheckBoxFocusImages(checkSel, checkUnsel, checkSel, checkUnsel);
            } else {
                setCheckBoxImages(checkSel, checkUnsel);
            }
        }
    } else {
        if (!Font.isTrueTypeFileSupported()) {
            return;
        }
        UIManager uim = UIManager.getInstance();
        Style unsel = uim.createStyle("CheckBox.", "", false);
        Style sel = uim.createStyle("CheckBox.", "sel#", true);
        Style dis = uim.createStyle("CheckBox.", "dis#", false);
        FontImage checkedDis = FontImage.createMaterial(FontImage.MATERIAL_CHECK_BOX, dis);
        FontImage uncheckedDis = FontImage.createMaterial(FontImage.MATERIAL_CHECK_BOX_OUTLINE_BLANK, sel);
        if (focus) {
            FontImage checkedSelected = FontImage.createMaterial(FontImage.MATERIAL_CHECK_BOX, sel);
            FontImage uncheckedSelected = FontImage.createMaterial(FontImage.MATERIAL_CHECK_BOX_OUTLINE_BLANK, sel);
            setCheckBoxFocusImages(checkedSelected, uncheckedSelected, checkedDis, uncheckedDis);
        } else {
            FontImage checkedUnselected = FontImage.createMaterial(FontImage.MATERIAL_CHECK_BOX, unsel);
            FontImage uncheckedUnselected = FontImage.createMaterial(FontImage.MATERIAL_CHECK_BOX_OUTLINE_BLANK, unsel);
            setCheckBoxImages(checkedUnselected, uncheckedUnselected, checkedDis, uncheckedDis);
        }
    }
}
Also used : Image(com.codename1.ui.Image) FontImage(com.codename1.ui.FontImage) FontImage(com.codename1.ui.FontImage)

Example 15 with UIManager

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

the class DefaultLookAndFeel method refreshTheme.

/**
 * {@inheritDoc}
 */
public void refreshTheme(boolean b) {
    chkBoxImages = null;
    comboImage = null;
    rButtonImages = null;
    chkBoxImagesFocus = null;
    rButtonImagesFocus = null;
    super.refreshTheme(b);
    UIManager m = getUIManager();
    Image combo = m.getThemeImageConstant("comboImage");
    if (combo != null) {
        setComboBoxImage(combo);
    } else {
        if (Font.isNativeFontSchemeSupported()) {
            Style c = UIManager.getInstance().createStyle("ComboBox.", "", false);
            combo = FontImage.createMaterial(FontImage.MATERIAL_ARROW_DROP_DOWN, c);
            setComboBoxImage(combo);
        }
    }
    updateCheckBoxConstants(m, false, "");
    updateCheckBoxConstants(m, true, "Focus");
    updateRadioButtonConstants(m, false, "");
    updateRadioButtonConstants(m, true, "Focus");
}
Also used : Image(com.codename1.ui.Image) FontImage(com.codename1.ui.FontImage)

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