use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.
the class TextArea method keyPressed.
/**
* {@inheritDoc}
*/
public void keyPressed(int keyCode) {
super.keyPressed(keyCode);
int action = com.codename1.ui.Display.getInstance().getGameAction(keyCode);
// this works around a bug where fire is also a softkey on devices such as newer Nokia
// series 40's (e.g. the Nokia emulator). It closes its native text box on fire then
// as a result of a Nokia bug we get the key released of that closing and assume the
// users wants to edit the text... When means the only way to exit the native text box
// is via the cancel option (after pressing OK once).
triggerClose = action == Display.GAME_FIRE;
// scroll the TextArea
Rectangle rect = new Rectangle(getScrollX(), getScrollY(), getWidth(), getHeight());
Font textFont = getStyle().getFont();
if (action == Display.GAME_DOWN) {
if ((getScrollY() + getHeight()) < (rowsGap + getStyle().getFont().getHeight()) * getLines()) {
rect.setY(rect.getY() + (textFont.getHeight() + rowsGap) * linesToScroll);
scrollRectToVisible(rect, this);
} else {
setHandlesInput(false);
}
} else {
if (action == Display.GAME_UP) {
if (getScrollY() > 0) {
rect.setY(Math.max(0, rect.getY() - (textFont.getHeight() + rowsGap) * linesToScroll));
scrollRectToVisible(rect, this);
} else {
setHandlesInput(false);
}
}
}
if (action == Display.GAME_RIGHT || action == Display.GAME_LEFT) {
setHandlesInput(false);
}
}
use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.
the class GridBagLayoutInfo method calculateComponentBounds.
private void calculateComponentBounds(ComponentSide horSide, ComponentSide vertSide, Rectangle r, Grid grid) {
Rectangle dispArea = grid.componentDisplayArea(horSide, vertSide);
r.setWidth(fillDisplaySide(dispArea.getWidth(), horSide));
r.setHeight(fillDisplaySide(dispArea.getHeight(), vertSide));
r.setX(anchorComponentSide(dispArea.getX(), dispArea.getWidth(), horSide, r.getWidth()));
r.setY(anchorComponentSide(dispArea.getY(), dispArea.getHeight(), vertSide, r.getHeight()));
}
use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.
the class GridBagLayoutInfo method AdjustForGravity.
/*protected GridBagLayoutInfo getLayoutInfo(Container parent, int sizeflag) {
return GetLayoutInfo(parent, sizeflag);
}
protected Dimension getMinSize(Container parent, GridBagLayoutInfo info) {
toolkit.lockAWT();
try {
return GetMinSize(parent, info);
} finally {
toolkit.unlockAWT();
}
}*/
protected void AdjustForGravity(GridBagConstraints constraints, Rectangle r) {
// Don't get parent as param, so have to use older info if exists
if (layoutInfo == null) {
r.setBounds(0, 0, 0, 0);
return;
}
GridBagConstraints consClone = (GridBagConstraints) constraints.clone();
consClone.fill = GridBagConstraints.BOTH;
ComponentSide horSide = new ComponentSide();
ComponentSide vertSide = new ComponentSide();
Dimension dummySize = new Dimension(0, 0);
initHorCompSide(horSide, consClone, dummySize, dummySize, lastParentInfo);
initVertCompSide(vertSide, consClone, dummySize, dummySize, lastParentInfo);
calculateComponentBounds(horSide, vertSide, r, lastParentInfo.grid);
}
use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.
the class GridBagLayoutInfo method setComponentsBounds.
private void setComponentsBounds(ParentInfo info) {
for (int i = 0; i < info.components.length; i++) {
Rectangle r = new Rectangle();
calculateComponentBounds(info.horCompSides[i], info.vertCompSides[i], r, info.grid);
info.components[i].setX(r.getX());
info.components[i].setY(r.getY());
info.components[i].setWidth(r.getSize().getWidth());
info.components[i].setHeight(r.getSize().getHeight());
}
}
use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.
the class GridBagLayoutInfo method arrangeGridImpl.
private void arrangeGridImpl(Container parent, ParentInfo info) {
validate(parent, info);
// Do not check clientRect for emptiness. Grid must be updated anyway
Rectangle clientRect = new Rectangle(0, 0, parent.getWidth(), parent.getHeight());
info.grid.fit2Client(clientRect);
}
Aggregations