use of com.codename1.ui.Painter in project CodenameOne by codenameone.
the class BubbleTransition method drawDialogCmp.
private void drawDialogCmp(Graphics g, Dialog dlg) {
Painter p = dlg.getStyle().getBgPainter();
dlg.getStyle().setBgPainter(null);
g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
g.translate(-getDialogParent(dlg).getX(), -getDialogParent(dlg).getY());
getDialogParent(dlg).paintComponent(g, false);
if (dlg.getCommandCount() > 0) {
Component menuBar = dlg.getSoftButton(0).getParent();
if (menuBar != null) {
g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
menuBar.paintComponent(g, false);
}
}
dlg.getStyle().setBgPainter(p);
}
use of com.codename1.ui.Painter in project CodenameOne by codenameone.
the class PainterChain method removeGlassPane.
/**
* Removes a glass pane from the given form, this is the opposite operation for the
* install glass pane
*
* @param f form from which to remove the chain
* @param p painter to remove
*/
public static void removeGlassPane(Form f, Painter p) {
Painter existing = f.getGlassPane();
if (existing == null) {
return;
}
if (existing == p) {
f.setGlassPane(null);
return;
}
if (existing instanceof PainterChain) {
PainterChain pc = (PainterChain) existing;
if (pc.chain.length == 1) {
f.setGlassPane(null);
} else {
Vector v = new Vector();
int plen = pc.chain.length;
for (int iter = 0; iter < plen; iter++) {
if (pc.chain[iter] != p) {
v.addElement(pc.chain[iter]);
}
}
if (v.size() == 0) {
f.setGlassPane(null);
return;
}
Painter[] newChain = new Painter[v.size()];
int clen = newChain.length;
for (int iter = 0; iter < clen; iter++) {
newChain[iter] = (Painter) v.elementAt(iter);
}
pc.chain = newChain;
// Since setGlassPane was not called and still the painter changed, we need to call repaint
f.repaint();
}
}
}
use of com.codename1.ui.Painter in project CodenameOne by codenameone.
the class PainterChain method installGlassPane.
/**
* Installs a glass pane on the given form making sure to make it a painter
* chain only if required by existing painter
*
* @param f form on which to install the chain
* @param p painter to install
*/
public static void installGlassPane(Form f, Painter p) {
Painter existing = f.getGlassPane();
if (existing == null) {
f.setGlassPane(p);
return;
}
if (existing instanceof PainterChain) {
f.setGlassPane(((PainterChain) existing).addPainter(p));
} else {
PainterChain pc = new PainterChain(new Painter[] { existing, p });
f.setGlassPane(pc);
}
}
use of com.codename1.ui.Painter in project CodenameOne by codenameone.
the class CommonTransitions method drawDialogCmp.
private void drawDialogCmp(Graphics g, Dialog dlg) {
Painter p = dlg.getStyle().getBgPainter();
dlg.getStyle().setBgPainter(null);
g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
g.translate(-getDialogParent(dlg).getX(), -getDialogParent(dlg).getY() + getDialogTitleHeight(dlg));
getDialogParent(dlg).paintComponent(g, false);
if (drawDialogMenu && dlg.getCommandCount() > 0) {
Component menuBar = dlg.getSoftButton(0).getParent();
if (menuBar != null) {
g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
menuBar.paintComponent(g, false);
}
}
dlg.getStyle().setBgPainter(p);
}
use of com.codename1.ui.Painter in project CodenameOne by codenameone.
the class CommonTransitions method paint.
private void paint(Graphics g, Component cmp, int x, int y, boolean background) {
boolean b = cmp.isVisible();
cmp.setVisible(true);
int cx = g.getClipX();
int cy = g.getClipY();
int cw = g.getClipWidth();
int ch = g.getClipHeight();
if (cmp instanceof Dialog) {
if (transitionType == TYPE_FADE && Display.getInstance().areMutableImagesFast()) {
cmp.paintComponent(g, background);
return;
}
if (!(getSource() instanceof Dialog && getDestination() instanceof Dialog && cmp == getDestination())) {
Painter p = cmp.getStyle().getBgPainter();
cmp.getStyle().setBgPainter(null);
g.translate(x, y);
Dialog dlg = (Dialog) cmp;
g.setClip(0, 0, cmp.getWidth(), cmp.getHeight());
getDialogParent(dlg).paintComponent(g, false);
g.translate(-x, -y);
if (drawDialogMenu && dlg.getCommandCount() > 0) {
Component menuBar = dlg.getSoftButton(0).getParent();
if (menuBar != null) {
g.setClip(0, 0, cmp.getWidth(), cmp.getHeight());
menuBar.paintComponent(g, false);
}
}
g.setClip(cx, cy, cw, ch);
cmp.getStyle().setBgPainter(p);
} else {
cmp.paintComponent(g, background);
}
return;
}
// g.clipRect(cmp.getAbsoluteX(), cmp.getAbsoluteY(), cmp.getWidth(), cmp.getHeight());
g.translate(x, y);
// g.clipRect(cmp.getAbsoluteX(), cmp.getAbsoluteY(), cmp.getWidth(), cmp.getHeight());
cmp.paintComponent(g, background);
g.translate(-x, -y);
g.setClip(cx, cy, cw, ch);
cmp.setVisible(b);
}
Aggregations