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();
}
}
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);
}
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;
}
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;
}
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);
}
Aggregations