Search in sources :

Example 6 with Painter

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);
}
Also used : Painter(com.codename1.ui.Painter) Component(com.codename1.ui.Component)

Example 7 with Painter

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();
        }
    }
}
Also used : Painter(com.codename1.ui.Painter) Vector(java.util.Vector)

Example 8 with Painter

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);
    }
}
Also used : Painter(com.codename1.ui.Painter)

Example 9 with Painter

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);
}
Also used : Painter(com.codename1.ui.Painter) Component(com.codename1.ui.Component)

Example 10 with Painter

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);
}
Also used : Dialog(com.codename1.ui.Dialog) Painter(com.codename1.ui.Painter) Component(com.codename1.ui.Component)

Aggregations

Painter (com.codename1.ui.Painter)8 Rectangle (com.codename1.ui.geom.Rectangle)4 Component (com.codename1.ui.Component)3 Dialog (com.codename1.ui.Dialog)2 Graphics (com.codename1.ui.Graphics)2 Motion (com.codename1.ui.animations.Motion)2 Point (com.codename1.ui.geom.Point)2 Border (com.codename1.ui.plaf.Border)2 Style (com.codename1.ui.plaf.Style)2 Form (com.codename1.ui.Form)1 Image (com.codename1.ui.Image)1 RGBImage (com.codename1.ui.RGBImage)1 Animation (com.codename1.ui.animations.Animation)1 CommonTransitions (com.codename1.ui.animations.CommonTransitions)1 ComponentAnimation (com.codename1.ui.animations.ComponentAnimation)1 Transition (com.codename1.ui.animations.Transition)1 UIManager (com.codename1.ui.plaf.UIManager)1 Vector (java.util.Vector)1