use of com.codename1.ui.layouts.BoxLayout in project CodenameOne by codenameone.
the class RSSReader method createRendererContainer.
private Container createRendererContainer() {
Container entries = new Container(new BoxLayout(BoxLayout.Y_AXIS));
entries.setUIID("RSSEntry");
Label title = new Label();
title.setName("title");
title.setUIID("RSSTitle");
entries.addComponent(title);
TextArea description = new TextArea(2, 30);
description.setGrowByContent(false);
description.setName("details");
description.setUIID("RSSDescription");
description.setScrollVisible(false);
entries.addComponent(description);
if (iconPlaceholder != null) {
Container wrap = new Container(new BorderLayout());
wrap.addComponent(BorderLayout.CENTER, entries);
Label icon = new Label();
icon.setIcon(iconPlaceholder);
icon.setUIID("RSSIcon");
icon.setName("icon");
wrap.addComponent(BorderLayout.WEST, icon);
entries = wrap;
}
return entries;
}
use of com.codename1.ui.layouts.BoxLayout in project CodenameOne by codenameone.
the class Container method calculateLastPaintableOffset.
/**
* Gets the index of the "last" child component that intersects the given rectangle. This is
* only helpful if the components are sorted (e.g. with BoxLayout.Y_AXIS). If they aren't
* sorted then this will just return components.size()-1.
* @param pos The starting position to search. It is assumed that this starting
* position is in the visible region.
* @param clipX1 The left bounds of the region to search. (0,0) is the top left corner of the container.
* @param clipY1 The top bounds of the region to search. (0,0) is the top left corner of the container.
* @param clipX2 The right bounds of the region to search. (0,0) is the top left corner of the container.
* @param clipY2 The bottom bounds of the region to search. (0,0) is the top left corner of the container.
* @return The index of the last visible component in this container - or components.size()-1
*/
private int calculateLastPaintableOffset(int pos, int clipX1, int clipY1, int clipX2, int clipY2) {
final int len = components.size();
if (pos >= len - 1) {
// Let's return one less than pos to indicate this
return len - 1;
}
final Layout l = getLayout();
if (l.getClass() == BoxLayout.class) {
if (((BoxLayout) l).getAxis() == BoxLayout.Y_AXIS) {
// Use a binary search to find the first visible
// Component c = components.get(++pos);
Component c = null;
int cy1 = -1;
final int end = len - 1;
// This should still be a valid index because
pos++;
// we previously checked to see if it was >= len-1
do {
c = components.get(pos);
cy1 = c.getBounds().getY();
} while (++pos <= end && cy1 <= clipY2);
return pos - 1;
}
}
return len - 1;
}
use of com.codename1.ui.layouts.BoxLayout in project CodenameOne by codenameone.
the class MenuBar method adaptTitleLayoutBackCommandStructure.
void adaptTitleLayoutBackCommandStructure() {
Container t = getTitleAreaContainer();
if (t.getComponentCount() - componentCountOffset(t) == 3) {
return;
}
BorderLayout titleLayout = (BorderLayout) t.getLayout();
if (Display.COMMAND_BEHAVIOR_ICS == getCommandBehavior()) {
titleLayout.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_SCALE);
getTitleComponent().getUnselectedStyle().setAlignment(Component.LEFT, true);
} else {
titleLayout.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
}
t.removeAll();
t.addComponent(BorderLayout.CENTER, getTitleComponent());
Container leftContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));
Container rightContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));
t.addComponent(BorderLayout.EAST, rightContainer);
t.addComponent(BorderLayout.WEST, leftContainer);
initTitleBarStatus();
}
use of com.codename1.ui.layouts.BoxLayout in project CodenameOne by codenameone.
the class DefaultCrashReporter method exception.
/**
* {@inheritDoc}
*/
public void exception(Throwable t) {
Preferences.set("$CN1_pendingCrash", true);
if (promptUser) {
Dialog error = new Dialog("Error");
error.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
TextArea txt = new TextArea(errorText);
txt.setEditable(false);
txt.setUIID("DialogBody");
error.addComponent(txt);
CheckBox cb = new CheckBox(checkboxText);
cb.setUIID("DialogBody");
error.addComponent(cb);
Container grid = new Container(new GridLayout(1, 2));
error.addComponent(grid);
Command ok = new Command(sendButtonText);
Command dont = new Command(dontSendButtonText);
Button send = new Button(ok);
Button dontSend = new Button(dont);
grid.addComponent(send);
grid.addComponent(dontSend);
Command result = error.showPacked(BorderLayout.CENTER, true);
if (result == dont) {
if (cb.isSelected()) {
Preferences.set("$CN1_crashBlocked", true);
}
Preferences.set("$CN1_pendingCrash", false);
return;
} else {
if (cb.isSelected()) {
Preferences.set("$CN1_prompt", false);
}
}
}
Log.sendLog();
Preferences.set("$CN1_pendingCrash", false);
}
use of com.codename1.ui.layouts.BoxLayout in project CodenameOne by codenameone.
the class SignIn method start.
public void start() {
// new SignInFormGB(theme).show();
// if (true) return;
loginForm = new Form("Sign in Demo");
loginForm.setLayout(new BorderLayout());
Container center = new Container(new BoxLayout(BoxLayout.Y_AXIS));
center.setUIID("ContainerWithPadding");
Image logo = theme.getImage("CodenameOne.png");
Label l = new Label(logo);
Container flow = new Container(new FlowLayout(Component.CENTER));
flow.addComponent(l);
center.addComponent(flow);
final TextField username = new TextField();
username.setHint("Username");
final TextField pass = new TextField();
pass.setHint("Password");
pass.setConstraint(TextField.PASSWORD);
center.addComponent(username);
center.addComponent(pass);
Button signIn = new Button("Sign In");
signIn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (username.getText().length() == 0 || pass.getText().length() == 0) {
return;
}
UserForm userForm = new UserForm(username.getText(), (EncodedImage) theme.getImage("user.png"), null);
userForm.show();
}
});
center.addComponent(signIn);
loginForm.addComponent(BorderLayout.CENTER, center);
Container bottom = new Container(new BoxLayout(BoxLayout.Y_AXIS));
Button loginWFace = new Button(theme.getImage("signin_facebook.png"));
loginWFace.setUIID("LoginButton");
loginWFace.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// create your own app identity on facebook follow the guide here:
// facebook-login.html
String clientId = "1171134366245722";
String redirectURI = "http://www.codenameone.com/";
String clientSecret = "";
if (clientSecret.length() == 0) {
System.err.println("create your own facebook app follow the guide here:");
System.err.println("http://www.codenameone.com/facebook-login.html");
return;
}
Login fb = FacebookConnect.getInstance();
fb.setClientId(clientId);
fb.setRedirectURI(redirectURI);
fb.setClientSecret(clientSecret);
login = fb;
fb.setCallback(new LoginListener(LoginListener.FACEBOOK));
if (!fb.isUserLoggedIn()) {
fb.doLogin();
} else {
showFacebookUser(fb.getAccessToken().getToken());
}
}
});
Button loginWG = new Button(theme.getImage("signin_google.png"));
loginWG.setUIID("LoginButton");
loginWG.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
SignIn.this.doFirebase();
// create your own google project follow the guide here:
// http://www.codenameone.com/google-login.html
String clientId = "555462747934-iujpd5saj4pjpibo7c6r9tbjfef22rh1.apps.googleusercontent.com";
String redirectURI = "https://www.codenameone.com/oauth2callback";
String clientSecret = "650YqplrnAI0KXb9LMUnVNnx";
if (clientSecret.length() == 0) {
System.err.println("create your own google project follow the guide here:");
System.err.println("http://www.codenameone.com/google-login.html");
return;
}
Login gc = GoogleConnect.getInstance();
gc.setClientId(clientId);
gc.setRedirectURI(redirectURI);
gc.setClientSecret(clientSecret);
gc.setScope("https://www.googleapis.com/auth/plus.profile.emails.read https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file");
login = gc;
gc.setCallback(new LoginListener(LoginListener.GOOGLE));
if (!gc.isUserLoggedIn()) {
gc.doLogin();
} else {
showGoogleUser(gc.getAccessToken().getToken());
}
}
});
bottom.addComponent(loginWFace);
bottom.addComponent(loginWG);
loginForm.addComponent(BorderLayout.SOUTH, bottom);
loginForm.show();
}
Aggregations