Search in sources :

Example 21 with Label

use of com.codename1.rad.models.Property.Label 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 22 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class TextComponent method constructUI.

void constructUI() {
    if (getComponentCount() == 0) {
        if (isOnTopMode() && isFocusAnimation()) {
            getLabel().setUIID("FloatingHint");
            setLayout(new LayeredLayout());
            Container tfContainer;
            if (action != null) {
                tfContainer = BorderLayout.center(LayeredLayout.encloseIn(field, FlowLayout.encloseRightMiddle(action)));
            } else {
                tfContainer = BorderLayout.center(field);
            }
            tfContainer.add(BorderLayout.NORTH, getLabel()).add(BorderLayout.SOUTH, LayeredLayout.encloseIn(getErrorMessage(), getDescriptionMessage()));
            add(tfContainer);
            Label errorMessageFiller = new Label();
            Component.setSameSize(errorMessageFiller, getErrorMessage());
            animationLayer = BorderLayout.south(errorMessageFiller);
            add(animationLayer);
            updateLabel();
        } else {
            super.constructUI();
        }
    }
}
Also used : LayeredLayout(com.codename1.ui.layouts.LayeredLayout)

Example 23 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class List method calcPreferredSize.

/**
 * {@inheritDoc}
 */
protected Dimension calcPreferredSize() {
    if (shouldShowHint()) {
        Label l = getHintLabelImpl();
        if (l != null) {
            Dimension d1 = getUIManager().getLookAndFeel().getListPreferredSize(this);
            Dimension d2 = l.getPreferredSize();
            return new Dimension(d1.getWidth() + d2.getWidth(), d1.getHeight() + d2.getHeight());
        }
    }
    Dimension d = getUIManager().getLookAndFeel().getListPreferredSize(this);
    if (spinnerOverlay != null) {
        if (spinnerOverlay.getBorder() != null) {
            d.setWidth(Math.max(spinnerOverlay.getBorder().getMinimumWidth(), d.getWidth()));
            d.setHeight(Math.max(spinnerOverlay.getBorder().getMinimumHeight(), d.getHeight()));
        }
    }
    return d;
}
Also used : Dimension(com.codename1.ui.geom.Dimension)

Example 24 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class AutoCapitalizationTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.add(new Label("Hi World"));
    TextField myTextField = new TextField();
    myTextField.setSingleLineTextArea(false);
    myTextField.setConstraint(TextArea.INITIAL_CAPS_SENTENCE);
    myTextField.setGrowLimit(-1);
    myTextField.setMaxSize(1600);
    myTextField.setHint("Type Something...");
    hi.add(myTextField);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) TextField(com.codename1.ui.TextField)

Example 25 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class FingerprintScannerSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    TextField keyName = new TextField();
    TextField keyValue = new TextField();
    Button addItem = new Button("Add Item");
    Button getItem = new Button("Get Item");
    Button deleteItem = new Button("Delete Item");
    Button checkAvailable = new Button("Check Available");
    checkAvailable.addActionListener(evt -> {
        Container cnt = BoxLayout.encloseY(new Label("TouchID: " + Fingerprint.isTouchIDAvailable()), new Label("FaceID: " + Fingerprint.isFaceIDAvailable()));
        Dialog.show("Capabilities", cnt, new Command("OK"));
    });
    addItem.addActionListener(evt -> {
        if (!Fingerprint.isAvailable()) {
            ToastBar.showErrorMessage("Fingerprint not avaiable on this platform");
            return;
        }
        Fingerprint.addPassword("Adding secure item to keystore", keyName.getText(), keyValue.getText()).onResult((res, err) -> {
            if (err != null) {
                if (AsyncResource.isCancelled(err)) {
                    Log.p("addPassword request was cancelled");
                    return;
                }
                Log.e(err);
                ToastBar.showErrorMessage(err.getMessage());
            } else {
                ToastBar.showInfoMessage("Result: " + res);
            }
        });
    });
    getItem.addActionListener(evt -> {
        Fingerprint.getPassword("Getting secure item", keyName.getText()).onResult((res, err) -> {
            if (err != null) {
                if (AsyncResource.isCancelled(err)) {
                    Log.p("getPassword request was cancelled");
                    return;
                }
                Log.e(err);
                if (err instanceof KeyRevokedException) {
                    ToastBar.showErrorMessage("Your key has been invalidated, likely due to adding new fingerprints");
                } else {
                    ToastBar.showErrorMessage(err.getMessage());
                }
            } else {
                keyValue.setText(res);
                hi.revalidateWithAnimationSafety();
            }
        });
    });
    deleteItem.addActionListener(evt -> {
        Fingerprint.deletePassword("Getting secure item", keyName.getText()).onResult((res, err) -> {
            if (err != null) {
                if (AsyncResource.isCancelled(err)) {
                    Log.p("deletePassword request was cancelled");
                }
                Log.e(err);
                ToastBar.showErrorMessage(err.getMessage());
            } else {
                keyValue.setText("");
                hi.revalidateWithAnimationSafety();
            }
        });
    });
    Button checkHardware = new Button("Check Hardware");
    checkHardware.addActionListener(evt -> {
        Fingerprint.isAvailable();
        Dialog.show("Hardware", CN.getProperty("Fingerprint.types", "None"), "OK", null);
    });
    hi.addAll(checkHardware, new Label("Key:"), keyName, new Label("Value: "), keyValue, addItem, getItem, deleteItem, checkAvailable);
    hi.show();
}
Also used : Container(com.codename1.ui.Container) KeyRevokedException(com.codename1.fingerprint.KeyRevokedException) Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Command(com.codename1.ui.Command) Label(com.codename1.ui.Label) TextField(com.codename1.ui.TextField)

Aggregations

Label (com.codename1.ui.Label)129 Form (com.codename1.ui.Form)95 Button (com.codename1.ui.Button)50 BorderLayout (com.codename1.ui.layouts.BorderLayout)50 Container (com.codename1.ui.Container)49 Component (com.codename1.ui.Component)27 SpanLabel (com.codename1.components.SpanLabel)26 Style (com.codename1.ui.plaf.Style)24 BoxLayout (com.codename1.ui.layouts.BoxLayout)19 TextArea (com.codename1.ui.TextArea)18 ActionEvent (com.codename1.ui.events.ActionEvent)18 IOException (java.io.IOException)18 Image (com.codename1.ui.Image)17 Dimension (com.codename1.ui.geom.Dimension)16 TextField (com.codename1.ui.TextField)15 ActionListener (com.codename1.ui.events.ActionListener)15 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)15 Toolbar (com.codename1.ui.Toolbar)13 FlowLayout (com.codename1.ui.layouts.FlowLayout)12 EncodedImage (com.codename1.ui.EncodedImage)11