use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.
the class DefaultLookAndFeel method drawRadioButton.
/**
* {@inheritDoc}
*/
public void drawRadioButton(Graphics g, Button rb) {
if (rButtonImages != null) {
Image x;
if (rButtonImagesFocus != null && rButtonImagesFocus[0] != null && rb.hasFocus() && Display.getInstance().shouldRenderSelection(rb)) {
if (rb.isEnabled()) {
x = rButtonImagesFocus[rb.isSelected() ? 1 : 0];
} else {
x = rButtonImagesFocus[rb.isSelected() ? 3 : 2];
}
} else {
if (rb.isEnabled()) {
x = rButtonImages[rb.isSelected() ? 1 : 0];
} else {
x = rButtonImages[rb.isSelected() ? 3 : 2];
}
}
drawComponent(g, rb, rb.getIconFromState(), x, 0);
} else {
Style style = rb.getStyle();
// 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();
drawComponent(g, rb, rb.getIconFromState(), null, height + rb.getGap());
g.setColor(style.getFgColor());
int x = rb.getX();
if (rb.isRTL()) {
x = x + rb.getWidth() - style.getPaddingLeft(rb.isRTL()) - height;
} else {
x += style.getPaddingLeft(rb.isRTL());
}
int y = rb.getY();
// center the RadioButton
y += Math.max(0, rb.getHeight() / 2 - height / 2);
g.drawArc(x, y, height, height, 0, 360);
if (rb.isSelected()) {
int color = g.getColor();
int destColor = findDestColor(color);
g.fillRadialGradient(color, destColor, x + 3, y + 3, height - 5, height - 5);
}
}
}
use of com.codename1.charts.compat.Paint.Style 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.charts.compat.Paint.Style in project CodenameOne by codenameone.
the class DefaultLookAndFeel method drawCheckBox.
/**
* {@inheritDoc}
*/
public void drawCheckBox(Graphics g, Button cb) {
if (chkBoxImages != null) {
Image x;
if (chkBoxImagesFocus != null && chkBoxImagesFocus[0] != null && cb.hasFocus() && Display.getInstance().shouldRenderSelection(cb)) {
if (cb.isEnabled()) {
x = chkBoxImagesFocus[cb.isSelected() ? 1 : 0];
} else {
x = chkBoxImagesFocus[cb.isSelected() ? 3 : 2];
}
} else {
if (cb.isEnabled()) {
x = chkBoxImages[cb.isSelected() ? 1 : 0];
} else {
x = chkBoxImages[cb.isSelected() ? 3 : 2];
}
}
drawComponent(g, cb, cb.getIconFromState(), x, 0);
} else {
Style style = cb.getStyle();
// checkbox square needs to be the height and width of the font height even
// when no text is in the check box this is a good indication of phone DPI
int height = cb.getStyle().getFont().getHeight();
drawComponent(g, cb, cb.getIconFromState(), null, height);
int gradientColor;
g.setColor(style.getFgColor());
gradientColor = style.getBgColor();
int width = height;
int rectWidth = scaleCoordinate(12f, 16, width);
int tX = cb.getX();
if (cb.isRTL()) {
tX = tX + cb.getWidth() - style.getPaddingLeft(cb.isRTL()) - rectWidth;
} else {
tX += style.getPaddingLeft(cb.isRTL());
}
int tY = cb.getY() + style.getPaddingTop() + (cb.getHeight() - style.getPaddingTop() - style.getPaddingBottom()) / 2 - height / 2;
g.translate(tX, tY);
int x = scaleCoordinate(1.04f, 16, width);
int y = scaleCoordinate(4.0f, 16, height);
int rectHeight = scaleCoordinate(12f, 16, height);
// brighten or darken the color slightly
int destColor = findDestColor(gradientColor);
g.fillLinearGradient(gradientColor, destColor, x + 1, y + 1, rectWidth - 2, rectHeight - 1, false);
g.drawRoundRect(x, y, rectWidth, rectHeight, 5, 5);
if (cb.isSelected()) {
int color = g.getColor();
g.setColor(0x111111);
g.translate(0, 1);
fillCheckbox(g, width, height);
g.setColor(color);
g.translate(0, -1);
fillCheckbox(g, width, height);
}
g.translate(-tX, -tY);
}
}
use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.
the class Spinner method paint.
/**
* {@inheritDoc}
*/
public void paint(Graphics g) {
super.paint(g);
if (spinnerHandle != null) {
Style s = getStyle();
g.drawImage(spinnerHandle, getX() + getWidth() - spinnerHandle.getWidth() - s.getHorizontalPadding(), getY() + s.getPaddingTop());
}
if (System.currentTimeMillis() - inputSkipDelay < lastKeyInteraction || quickType.isPendingCommit()) {
quickType.setWidth(Math.min(getWidth(), quickType.getPreferredW()));
quickType.setHeight(Math.min(getHeight(), quickType.getPreferredH()));
Style s = quickType.getStyle();
quickType.setY(getScrollY() + getY());
// positioning based on date/time
if (getRenderer() instanceof DateTimeRenderer) {
switch(currentInputAlign) {
case LEFT:
quickType.setX(getX());
break;
case RIGHT:
quickType.setX(getX() + quickType.getStyle().getFont().charWidth(TextArea.getWidestChar()) * 4 + s.getMarginRightNoRTL());
break;
default:
quickType.setX(getX() + quickType.getStyle().getFont().charWidth(TextArea.getWidestChar()) * 2 + s.getMarginLeftNoRTL());
break;
}
} else {
quickType.setX(getX());
}
quickType.paintComponent(g, true);
}
}
use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.
the class TableLayout method getRowHeightPixels.
private int getRowHeightPixels(int row, int percentageOf, int available) {
int current = 0;
for (int iter = 0; iter < columns; iter++) {
Constraint c = tablePositions[row * columns + iter];
if (c == null || c == H_SPAN_CONSTRAINT || c == V_SPAN_CONSTRAINT || c == VH_SPAN_CONSTRAINT || c.spanVertical > 1) {
continue;
}
// height in percentage of the parent container
if (c.height > 0) {
current = Math.max(current, c.height * percentageOf / 100);
} else {
Style s = c.parent.getStyle();
current = Math.max(current, c.parent.getPreferredH() + s.getMarginTop() + s.getMarginBottom());
}
if (available > -1) {
current = Math.min(available, current);
}
}
return current;
}
Aggregations