use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class Border method getMinimumWidth.
/**
* Returns the minimum size required to properly display this border, normally this
* is 0 but a border might deem itself undisplayable with too small a size e.g. for
* the case of an image border the minimum height would be top + bottom and the minimum
* width would be left+right
*
* @return 0 if not applicable or a dimension if it is.
*/
public int getMinimumWidth() {
if (images != null) {
if (images.length < 4) {
if (type == TYPE_IMAGE_HORIZONTAL) {
return images[0].getWidth() + images[1].getWidth();
} else {
return images[0].getWidth();
}
}
Image topLeft = images[4];
Image topRight = images[5];
return topLeft.getWidth() + topRight.getWidth();
}
return 0;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class Border method getMinimumHeight.
/**
* Returns the minimum size required to properly display this border, normally this
* is 0 but a border might deem itself undisplayable with too small a size e.g. for
* the case of an image border the minimum height would be top + bottom and the minimum
* width would be left+right
*
* @return 0 if not applicable or a dimension if it is.
*/
public int getMinimumHeight() {
if (images != null) {
if (images.length < 4) {
if (type == TYPE_IMAGE_HORIZONTAL) {
return images[0].getHeight();
} else {
return images[0].getHeight() + images[1].getHeight();
}
}
Image topLeft = images[4];
Image bottomRight = images[7];
return topLeft.getHeight() + bottomRight.getHeight();
}
return 0;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class DefaultLookAndFeel method getTextAreaSize.
/**
* {@inheritDoc}
*/
public Dimension getTextAreaSize(TextArea ta, boolean pref) {
int prefW = 0;
int prefH = 0;
Style style = ta.getStyle();
Font f = style.getFont();
// if this is a text field the preferred size should be the text width
if (ta.getRows() == 1) {
prefW = f.stringWidth(ta.getText());
} else {
prefW = f.charWidth(TextArea.getWidestChar()) * ta.getColumns();
}
int rows;
if (pref) {
rows = ta.getActualRows();
} else {
rows = ta.getLines();
}
prefH = (f.getHeight() + ta.getRowsGap()) * rows;
if (!ta.isActAsLabel()) {
int columns = ta.getColumns();
String str = "";
for (int iter = 0; iter < columns; iter++) {
str += TextArea.getWidestChar();
}
if (columns > 0) {
prefW = Math.max(prefW, f.stringWidth(str));
}
}
prefH = Math.max(prefH, rows * f.getHeight());
prefW += style.getPaddingRightNoRTL() + style.getPaddingLeftNoRTL();
prefH += style.getPaddingTop() + style.getPaddingBottom();
if (style.getBorder() != null) {
prefW = Math.max(style.getBorder().getMinimumWidth(), prefW);
prefH = Math.max(style.getBorder().getMinimumHeight(), prefH);
}
if (isBackgroundImageDetermineSize() && style.getBgImage() != null) {
prefW = Math.max(style.getBgImage().getWidth(), prefW);
prefH = Math.max(style.getBgImage().getHeight(), prefH);
}
return new Dimension(prefW, prefH);
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class DefaultLookAndFeel method getListPreferredSize.
/**
* {@inheritDoc}
*/
public Dimension getListPreferredSize(List l) {
Dimension d = getListPreferredSizeImpl(l);
Style style = l.getStyle();
if (style.getBorder() != null) {
d.setWidth(Math.max(style.getBorder().getMinimumWidth(), d.getWidth()));
d.setHeight(Math.max(style.getBorder().getMinimumHeight(), d.getHeight()));
}
return d;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class DefaultLookAndFeel method getRadioButtonPreferredSize.
/**
* {@inheritDoc}
*/
public Dimension getRadioButtonPreferredSize(Button rb) {
if (rb.isToggle()) {
return getButtonPreferredSize(rb);
}
threeImageCache[0] = rb.getMaskedIcon();
threeImageCache[1] = rb.getRolloverIcon();
threeImageCache[2] = rb.getPressedIcon();
if (rButtonImages != null) {
return getPreferredSize(rb, threeImageCache, rButtonImages[0]);
}
Dimension d = getPreferredSize(rb, threeImageCache, null);
// radio button radius needs to be of the size of the font height even
// when no text is in the radio button this is a good indication of phone DPI
int height = rb.getStyle().getFont().getHeight();
// allow for radio buttons without a string within them
d.setHeight(Math.max(height, d.getHeight()));
if (rButtonImages != null && rButtonImages.length > 0) {
d.setWidth(rButtonImages[0].getWidth() + d.getWidth() + rb.getGap());
} else {
d.setWidth(d.getWidth() + height + rb.getGap());
}
return d;
}
Aggregations