use of com.codename1.util.Wrapper in project CodenameOne by codenameone.
the class DateTimeSpinner3D method addComponents.
void addComponents() {
if (date != null) {
// setLayout(new LayeredLayout());
setLayout(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
add(BorderLayout.CENTER, wrapper);
wrapper.addComponent(date);
wrapper.addComponent(time);
// LayeredLayout ll = (LayeredLayout)getLayout();
// ll.setInsets(date, "0 auto 0 0")
// .setInsets(time, "0 auto 0 0")
// .setReferenceComponentLeft(time, date, 1f);
}
}
use of com.codename1.util.Wrapper in project CodenameOne by codenameone.
the class DurationSpinner3D method init.
private void init() {
setLayout(new BorderLayout());
Container wrapper = new Container(new LayeredLayout());
Container box = new Container(BoxLayout.x());
UIManager uim = UIManager.getInstance();
Style s = null;
if (includeDays) {
days = Spinner3D.create(0, 1000, 0, 1);
days.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
s = Style.createProxyStyle(days.getRowStyle(), days.getSelectedRowStyle());
s.setAlignment(Component.RIGHT);
box.add(days);
box.add(new Label(uim.localize("day", "day")));
}
if (includeHours) {
hours = Spinner3D.create(0, includeDays ? 24 : 1000, 0, 1);
hours.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
s = Style.createProxyStyle(hours.getRowStyle(), hours.getSelectedRowStyle());
s.setAlignment(Component.RIGHT);
box.add(hours);
box.add(new Label(uim.localize("hour", "hour")));
}
if (includeMinutes) {
minutes = Spinner3D.create(0, includeHours ? 59 : 1000, 0, 1);
minutes.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
s = Style.createProxyStyle(minutes.getRowStyle(), minutes.getSelectedRowStyle());
s.setAlignment(Component.RIGHT);
box.add(minutes);
box.add(new Label(uim.localize("min", "min")));
}
if (includeSeconds) {
seconds = Spinner3D.create(0, includeMinutes ? 59 : 1000, 0, 1);
seconds.setPreferredW(new Label("0000", "Spinner3DRow").getPreferredW());
s = Style.createProxyStyle(seconds.getRowStyle(), seconds.getSelectedRowStyle());
s.setAlignment(Component.RIGHT);
box.add(seconds);
box.add(new Label(uim.localize("sec", "sec")));
}
if (includeMilliseconds) {
milliseconds = Spinner3D.create(0, 1000, 0, 1);
milliseconds.setPreferredW(new Label("0000", "Spinner3DRow").getPreferredW());
s = Style.createProxyStyle(milliseconds.getRowStyle(), milliseconds.getSelectedRowStyle());
s.setAlignment(Component.RIGHT);
box.add(milliseconds);
box.add(new Label("ms", "ms"));
}
wrapper.add(box);
LayeredLayout ll = (LayeredLayout) wrapper.getLayout();
ll.setInsets(box, "0 auto 0 auto");
add(BorderLayout.CENTER, wrapper);
}
use of com.codename1.util.Wrapper in project CodenameOne by codenameone.
the class FadeOutTransitionSample method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", new BorderLayout());
Button button1 = new Button("Button 1");
$(button1).selectAllStyles().setBgColor(0xff0000);
Button button2 = new Button("Button 2");
$(button2).selectAllStyles().setBgColor(0x00ff00);
Button doFade = new Button("Toggle");
doFade.addActionListener(evt -> {
Container contentPane = hi.getContentPane();
if (contentPane.contains(button1)) {
button2.remove();
Container wrapper = BorderLayout.center(button2);
contentPane.replace(button1.getParent(), wrapper, CommonTransitions.createFade(500));
} else if (contentPane.contains(button2)) {
Container empty = new Container();
$(empty).selectAllStyles().setBgColor(0xeaeaea).setBgTransparency(0xff);
contentPane.replace(button2.getParent(), empty, CommonTransitions.createFade(500));
// contentPane.removeComponent(empty);
} else {
Container empty = new Container();
button1.remove();
contentPane.add(CENTER, empty);
contentPane.revalidateWithAnimationSafety();
contentPane.replace(empty, BorderLayout.center(button1), CommonTransitions.createFade(500));
}
});
hi.add(NORTH, doFade);
hi.show();
}
use of com.codename1.util.Wrapper in project CodenameOne by codenameone.
the class TestComponent method getComponentAt_int_int_nested.
private void getComponentAt_int_int_nested() {
log("Testing getComponentAt(x, y) with layered nesting");
int w = Display.getInstance().getDisplayWidth();
int h = Display.getInstance().getDisplayHeight();
Form f = new Form("My Form", new BorderLayout());
Container bottom = new Container() {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(w, h);
}
};
bottom.setGrabsPointerEvents(true);
bottom.setName("Bottom");
Container top = new Container(BoxLayout.y());
// top.setScrollableY(true);
top.setScrollableY(true);
top.setGrabsPointerEvents(true);
Component content = new Component() {
@Override
protected Dimension calcPreferredSize() {
return new Dimension(w, h * 2);
}
};
content.setFocusable(false);
content.setGrabsPointerEvents(false);
content.setName("Content");
top.add(content);
top.setName("Top");
Container wrapper = new Container(new LayeredLayout());
wrapper.add(bottom).add(top);
f.add(BorderLayout.CENTER, wrapper);
f.show();
TestUtils.waitForFormTitle("My Form", 2000);
Component middleComponent = f.getComponentAt(w / 2, h / 2);
assertEqual(content, middleComponent, "Found wrong component");
}
use of com.codename1.util.Wrapper in project CodeRAD by shannah.
the class EntityListView method requiresUpdate.
/**
* Checks to see if the model has changed since last update, and requires update.
* Update is required only if rows are added or removed.
* @return
*/
private boolean requiresUpdate() {
List<Entity> viewSet = new ArrayList<Entity>();
EntityList<?> modelSet = getEntity();
int modelSize = modelSet.size();
int index = 0;
for (Component child : wrapper) {
if (child instanceof EntityView) {
EntityView rowView = (EntityView) child;
if (index >= modelSize && modelSet.get(index) != rowView) {
return true;
}
index++;
}
}
return index != modelSize;
}
Aggregations