Search in sources :

Example 21 with Display

use of com.codename1.ui.Display in project CodenameOne by codenameone.

the class FloatingActionButton method released.

@Override
public void released(int x, int y) {
    super.released(x, y);
    if (current != null) {
        current.dispose();
        current = null;
    }
    // if this fab has sub fab's display them
    if (subMenu != null) {
        final Container con = createPopupContent(subMenu);
        Dialog d = new Dialog();
        d.setDialogUIID("Container");
        d.getContentPane().setUIID("Container");
        d.setLayout(new BorderLayout());
        d.add(BorderLayout.CENTER, con);
        for (FloatingActionButton next : subMenu) {
            next.current = d;
        }
        d.setTransitionInAnimator(CommonTransitions.createEmpty());
        d.setTransitionOutAnimator(CommonTransitions.createEmpty());
        for (Component c : con) {
            c.setVisible(false);
        }
        Form f = getComponentForm();
        int oldTint = f.getTintColor();
        f.setTintColor(0);
        d.setBlurBackgroundRadius(-1);
        d.addShowListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                for (Component c : con) {
                    c.setY(con.getHeight());
                    c.setVisible(true);
                }
                con.animateLayout(200);
            }
        });
        showPopupDialog(d);
        f.setTintColor(oldTint);
        for (FloatingActionButton next : subMenu) {
            next.remove();
        }
        con.removeAll();
    }
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog) ActionEvent(com.codename1.ui.events.ActionEvent) Component(com.codename1.ui.Component)

Example 22 with Display

use of com.codename1.ui.Display in project CodenameOne by codenameone.

the class FaceBookAccess method createOAuth.

public Oauth2 createOAuth() {
    String scope = "";
    if (permissions != null && permissions.length > 0) {
        int plen = permissions.length;
        for (int i = 0; i < plen; i++) {
            String permission = permissions[i];
            scope += permission + ",";
        }
        scope = scope.substring(0, scope.length() - 1);
    }
    Hashtable additionalParams = new Hashtable();
    String p = Display.getInstance().getPlatformName();
    // on simulator BB and J2ME use the popup display (no need for javascript)
    if (Display.getInstance().getProperty("OS", "SE").equals("SE") || p.equals("rim") || p.equals("me")) {
        additionalParams.put("display", "popup");
    } else {
        additionalParams.put("display", "touch");
    }
    return new Oauth2("https://www.facebook.com/dialog/oauth", clientId, redirectURI, scope, "https://graph.facebook.com/oauth/access_token", clientSecret, additionalParams);
}
Also used : Hashtable(java.util.Hashtable) Oauth2(com.codename1.io.Oauth2)

Example 23 with Display

use of com.codename1.ui.Display in project CodenameOne by codenameone.

the class DefaultLookAndFeel method getTextFieldCursorX.

/**
 * Calculates the position of the text field cursor within the string
 */
private int getTextFieldCursorX(TextArea ta) {
    Style style = ta.getStyle();
    Font f = style.getFont();
    // display ******** if it is a password field
    String displayText = getTextFieldString(ta);
    String inputMode = ta.getInputMode();
    int inputModeWidth = f.stringWidth(inputMode);
    // QWERTY devices don't quite have an input mode hide it also when we have a VK
    if (ta.isQwertyInput() || Display.getInstance().isVirtualKeyboardShowing()) {
        inputMode = "";
        inputModeWidth = 0;
    }
    int xPos = 0;
    int cursorCharPosition = ta.getCursorX();
    int cursorX = 0;
    int x = 0;
    if (reverseAlignForBidi(ta) == Component.RIGHT) {
        if (Display.getInstance().isBidiAlgorithm()) {
            // char[] dest = displayText.toCharArray();
            cursorCharPosition = Display.getInstance().getCharLocation(displayText, cursorCharPosition - 1);
            if (cursorCharPosition == -1) {
                xPos = f.stringWidth(displayText);
            } else {
                displayText = Display.getInstance().convertBidiLogicalToVisual(displayText);
                if (!isRTLOrWhitespace((displayText.charAt(cursorCharPosition)))) {
                    cursorCharPosition++;
                }
                xPos = f.stringWidth(displayText.substring(0, cursorCharPosition));
            }
        }
        int displayX = ta.getX() + ta.getWidth() - style.getPaddingLeft(ta.isRTL()) - f.stringWidth(displayText);
        cursorX = displayX + xPos;
        x = 0;
    } else {
        if (cursorCharPosition > 0) {
            cursorCharPosition = Math.min(displayText.length(), cursorCharPosition);
            xPos = f.stringWidth(displayText.substring(0, cursorCharPosition));
        }
        cursorX = ta.getX() + style.getPaddingLeft(ta.isRTL()) + xPos;
        if (ta.isSingleLineTextArea() && ta.getWidth() > (f.getHeight() * 2) && cursorX >= ta.getWidth() - inputModeWidth - style.getPaddingLeft(ta.isRTL())) {
            if (x + xPos >= ta.getWidth() - inputModeWidth - style.getPaddingLeftNoRTL() - style.getPaddingRightNoRTL()) {
                x = ta.getWidth() - inputModeWidth - style.getPaddingLeftNoRTL() - style.getPaddingRightNoRTL() - xPos - 1;
            }
        }
    }
    return cursorX + x;
}
Also used : Font(com.codename1.ui.Font)

Example 24 with Display

use of com.codename1.ui.Display in project CodenameOne by codenameone.

the class Tree method createNodeComponent.

/**
 * Creates a node within the tree, this method is protected allowing tree to be
 * subclassed to replace the rendering logic of individual tree buttons.
 *
 * @param node the node object from the model to display on the button
 * @param depth the depth within the tree (normally represented by indenting the entry)
 * @return a button representing the node within the tree
 * @deprecated replaced with createNode, bindNodeListener and setNodeIcon
 */
protected Button createNodeComponent(Object node, int depth) {
    Button cmp = new Button(childToDisplayLabel(node));
    cmp.setUIID("TreeNode");
    if (model.isLeaf(node)) {
        if (nodeImage == null) {
            FontImage.setMaterialIcon(cmp, FontImage.MATERIAL_DESCRIPTION, 3);
        } else {
            cmp.setIcon(nodeImage);
        }
    } else {
        if (folder == null) {
            FontImage.setMaterialIcon(cmp, FontImage.MATERIAL_FOLDER, 3);
        } else {
            cmp.setIcon(folder);
        }
    }
    updateNodeComponentStyle(cmp.getSelectedStyle(), depth);
    updateNodeComponentStyle(cmp.getUnselectedStyle(), depth);
    updateNodeComponentStyle(cmp.getPressedStyle(), depth);
    return cmp;
}
Also used : SpanButton(com.codename1.components.SpanButton) Button(com.codename1.ui.Button)

Example 25 with Display

use of com.codename1.ui.Display in project CodenameOne by codenameone.

the class Tree method createNode.

/**
 * Creates a node within the tree, this method is protected allowing tree to be
 * subclassed to replace the rendering logic of individual tree buttons.
 *
 * @param node the node object from the model to display on the button
 * @param depth the depth within the tree (normally represented by indenting the entry)
 * @return a button representing the node within the tree
 */
protected Component createNode(Object node, int depth) {
    if (multilineMode) {
        SpanButton cmp = new SpanButton(childToDisplayLabel(node));
        cmp.setUIID("TreeNode");
        cmp.setTextUIID("TreeNode");
        if (model.isLeaf(node)) {
            cmp.setIcon(nodeImage);
        } else {
            cmp.setIcon(folder);
        }
        updateNodeComponentStyle(cmp.getSelectedStyle(), depth);
        updateNodeComponentStyle(cmp.getUnselectedStyle(), depth);
        updateNodeComponentStyle(cmp.getPressedStyle(), depth);
        return cmp;
    }
    return createNodeComponent(node, depth);
}
Also used : SpanButton(com.codename1.components.SpanButton)

Aggregations

Display (com.codename1.ui.Display)10 Component (com.codename1.ui.Component)7 BorderLayout (com.codename1.ui.layouts.BorderLayout)6 Container (com.codename1.ui.Container)4 Dialog (com.codename1.ui.Dialog)4 Form (com.codename1.ui.Form)4 IOException (java.io.IOException)4 RGBImage (com.codename1.ui.RGBImage)3 InputStream (java.io.InputStream)3 ParseException (java.text.ParseException)3 Hashtable (java.util.Hashtable)3 Cursor (android.database.Cursor)2 Paint (android.graphics.Paint)2 Paint (com.codename1.charts.compat.Paint)2 Point (com.codename1.charts.models.Point)2 SpanButton (com.codename1.components.SpanButton)2 Address (com.codename1.contacts.Address)2 Contact (com.codename1.contacts.Contact)2 Button (com.codename1.ui.Button)2 Font (com.codename1.ui.Font)2