use of com.codename1.ui.layouts.mig.Grid 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);
}
use of com.codename1.ui.layouts.mig.Grid in project CodenameOne by codenameone.
the class MenuBar method calculateTouchCommandGridColumns.
/**
* Calculates the amount of columns to give to the touch commands within the
* grid
*
* @param grid container that will be arranged in the grid containing the
* components
* @return an integer representing the touch command grid size
*/
protected int calculateTouchCommandGridColumns(Container grid) {
int count = grid.getComponentCount();
int maxWidth = 10;
for (int iter = 0; iter < count; iter++) {
Component c = grid.getComponentAt(iter);
Style s = c.getUnselectedStyle();
// bidi doesn't matter since this is just a summary of width
maxWidth = Math.max(maxWidth, c.getPreferredW() + s.getHorizontalMargins());
}
return Math.max(2, Display.getInstance().getDisplayWidth() / maxWidth);
}
Aggregations