Search in sources :

Example 61 with Style

use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.

the class CommonTransitions method initTransition.

/**
 * {@inheritDoc}
 */
public void initTransition() {
    firstFinished = false;
    if (transitionType == TYPE_EMPTY) {
        return;
    }
    startTime = System.currentTimeMillis();
    Component source = getSource();
    Component destination = getDestination();
    position = 0;
    int w = source.getWidth();
    int h = source.getHeight();
    // improper replace() calls, this may still be valid and shouldn't fail
    if (w <= 0 || h <= 0) {
        return;
    }
    // nothing to prepare in advance  for a shift fade transition
    if (transitionType == TYPE_SLIDE_AND_FADE) {
        if (getSource() instanceof Form && getDestination() instanceof Form) {
            motion = createMotion(100, 200, speed);
            motion2 = createMotion(0, getDestination().getWidth(), speed);
            motion.start();
            motion2.start();
            return;
        }
        transitionType = TYPE_SLIDE;
    }
    if (transitionType == TYPE_PULSATE_DIALOG) {
        if (getDestination() instanceof Dialog) {
            motion = createMotion(600, 1100, 150);
            motion.start();
            motion2 = createMotion(100, 255, 225);
            motion2.start();
            pulseState = 0;
            Component c = getDialogParent(getDestination());
            originalX = c.getX();
            originalY = c.getY();
            originalWidth = c.getWidth();
            originalHeight = c.getHeight();
            Display d = Display.getInstance();
            Dialog dlg = (Dialog) destination;
            // transparent image!
            buffer = Image.createImage(Math.min(d.getDisplayWidth(), getDialogParent(dlg).getWidth()), Math.min(d.getDisplayHeight(), dlg.getContentPane().getParent().getHeight() + getDialogTitleHeight(dlg)), 0);
            Graphics g = buffer.getGraphics();
            Style stl = dlg.getDialogComponent().getStyle();
            byte bgt = stl.getBgTransparency();
            stl.setBgTransparency(0xff);
            drawDialogCmp(buffer.getGraphics(), dlg);
            stl.setBgTransparency(bgt & 0xff, true);
            return;
        }
        transitionType = TYPE_EMPTY;
        motion = createMotion(0, 0, 0);
        pulseState = (byte) 3;
        return;
    }
    if (Display.getInstance().areMutableImagesFast() || transitionType == TYPE_TIMELINE) {
        if (buffer == null) {
            buffer = createMutableImage(w, h);
        } else {
            // this might happen when screen orientation changes
            if (buffer.getWidth() != w || buffer.getHeight() != h) {
                buffer = createMutableImage(w, h);
                rgbBuffer = null;
                // slide motion might need resetting since screen size is different
                motion = null;
            }
        }
    }
    if (transitionType == TYPE_FADE) {
        motion = createMotion(0, 256, speed);
        motion.start();
        if (Display.getInstance().areMutableImagesFast()) {
            Graphics g = buffer.getGraphics();
            g.translate(-source.getAbsoluteX(), -source.getAbsoluteY());
            if (getSource().getParent() != null) {
                getSource().getComponentForm().paintComponent(g);
            }
            getSource().paintBackgrounds(g);
            g.setClip(0, 0, buffer.getWidth() + source.getAbsoluteX(), buffer.getHeight() + source.getAbsoluteY());
            paint(g, getDestination(), 0, 0);
            rgbBuffer = new RGBImage(buffer.getRGBCached(), buffer.getWidth(), buffer.getHeight());
            paint(g, getSource(), 0, 0, true);
            g.translate(source.getAbsoluteX(), source.getAbsoluteY());
        }
        return;
    }
    if (transitionType == TYPE_TIMELINE) {
        Graphics g = buffer.getGraphics();
        g.translate(-source.getAbsoluteX(), -source.getAbsoluteY());
        g.setClip(0, 0, buffer.getWidth() + source.getAbsoluteX(), buffer.getHeight() + source.getAbsoluteY());
        if (timeline.getWidth() != buffer.getWidth() || timeline.getHeight() != buffer.getHeight()) {
            timeline = timeline.scaled(buffer.getWidth(), buffer.getHeight());
        }
        if (timeline instanceof Timeline) {
            ((Timeline) timeline).setTime(0);
            ((Timeline) timeline).setLoop(false);
            ((Timeline) timeline).setAnimationDelay(0);
        }
        paint(g, getDestination(), 0, 0);
        g.translate(source.getAbsoluteX(), source.getAbsoluteY());
        return;
    }
    if (transitionType == TYPE_SLIDE || transitionType == TYPE_FAST_SLIDE || transitionType == TYPE_COVER || transitionType == TYPE_UNCOVER) {
        int dest;
        int startOffset = 0;
        boolean direction = forward;
        // flip the direction only for horizontal slides
        if ((source.getUIManager().getLookAndFeel().isRTL()) && slideType == SLIDE_HORIZONTAL) {
            direction = !direction;
        }
        if (slideType == SLIDE_HORIZONTAL) {
            dest = w;
            if (destination instanceof Dialog) {
                startOffset = w - getDialogParent(destination).getWidth();
                if (direction) {
                    startOffset -= getDialogParent(destination).getStyle().getMarginLeft(destination.isRTL());
                } else {
                    startOffset -= getDialogParent(destination).getStyle().getMarginRight(destination.isRTL());
                }
            } else {
                if (source instanceof Dialog) {
                    dest = getDialogParent(source).getWidth();
                    if (direction) {
                        dest += getDialogParent(source).getStyle().getMarginLeft(source.isRTL());
                    } else {
                        dest += getDialogParent(source).getStyle().getMarginRight(source.isRTL());
                    }
                }
            }
        } else {
            dest = h;
            if (destination instanceof Dialog) {
                startOffset = h - getDialogParent(destination).getHeight() - getDialogTitleHeight((Dialog) destination);
                if (direction) {
                    startOffset -= getDialogParent(destination).getStyle().getMarginBottom();
                } else {
                    startOffset -= getDialogParent(destination).getStyle().getMarginTop();
                    startOffset -= ((Dialog) destination).getTitleStyle().getMarginTop();
                    if (!drawDialogMenu && ((Dialog) destination).getCommandCount() > 0) {
                        Container p = ((Dialog) destination).getSoftButton(0).getParent();
                        if (p != null) {
                            startOffset -= p.getHeight();
                        }
                    }
                }
            } else {
                if (source instanceof Dialog) {
                    dest = getDialogParent(source).getHeight() + getDialogTitleHeight((Dialog) source);
                    if (direction) {
                        dest += getDialogParent(source).getStyle().getMarginBottom();
                    } else {
                        dest += getDialogParent(source).getStyle().getMarginTop();
                        dest += ((Dialog) source).getTitleStyle().getMarginTop();
                        if (((Dialog) source).getCommandCount() > 0) {
                            Container p = ((Dialog) source).getSoftButton(0).getParent();
                            if (p != null) {
                                dest += p.getHeight();
                            }
                        }
                    }
                }
            }
        }
        motion = createMotion(startOffset, dest, speed);
        if (!Display.getInstance().areMutableImagesFast()) {
            motion.start();
            buffer = null;
            return;
        }
        // make sure the destination is painted fully at least once
        // we must use a full buffer otherwise the clipping will take effect
        Graphics g = buffer.getGraphics();
        // tinting is expensive
        if (getSource() instanceof Dialog) {
            paint(g, getDestination(), 0, 0);
            if (transitionType == TYPE_FAST_SLIDE && !(destination instanceof Dialog)) {
                Dialog d = (Dialog) source;
                secondaryBuffer = createMutableImage(getDialogParent(d).getWidth(), getDialogParent(d).getHeight() + getDialogTitleHeight(d));
                drawDialogCmp(secondaryBuffer.getGraphics(), d);
            }
        } else {
            if (getDestination() instanceof Dialog) {
                paint(g, getSource(), 0, 0);
                if (transitionType == TYPE_FAST_SLIDE && !(source instanceof Dialog)) {
                    Dialog d = (Dialog) destination;
                    secondaryBuffer = createMutableImage(getDialogParent(d).getWidth(), d.getContentPane().getParent().getHeight() + getDialogTitleHeight(d));
                    drawDialogCmp(secondaryBuffer.getGraphics(), d);
                }
            } else {
                paint(g, source, -source.getAbsoluteX(), -source.getAbsoluteY(), true);
                if (transitionType == TYPE_FAST_SLIDE) {
                    secondaryBuffer = createMutableImage(destination.getWidth(), destination.getHeight());
                    paint(secondaryBuffer.getGraphics(), destination, -destination.getAbsoluteX(), -destination.getAbsoluteY());
                }
            }
        }
        motion.start();
    }
}
Also used : Graphics(com.codename1.ui.Graphics) Container(com.codename1.ui.Container) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog) Style(com.codename1.ui.plaf.Style) Component(com.codename1.ui.Component) RGBImage(com.codename1.ui.RGBImage) Display(com.codename1.ui.Display)

Example 62 with Style

use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.

the class SideMenuBar method createMenu.

private Form createMenu(final String placement) {
    final Form m = new Form() {

        private boolean pressedInRightPanel;

        private boolean manualMotionLock;

        protected boolean shouldSendPointerReleaseToOtherForm() {
            return true;
        }

        void actionCommandImpl(Command cmd, ActionEvent ev) {
            if (cmd instanceof SideMenuBar.CommandWrapper) {
                cmd = ((SideMenuBar.CommandWrapper) cmd).cmd;
                ev = new ActionEvent(cmd, ActionEvent.Type.Command);
            }
            final Command c = cmd;
            final ActionEvent e = ev;
            Display.getInstance().scheduleBackgroundTask(new Runnable() {

                public void run() {
                    Display.getInstance().invokeAndBlock(new Runnable() {

                        public void run() {
                            while (Display.getInstance().getCurrent() != parent) {
                                try {
                                    Thread.sleep(40);
                                } catch (Exception ex) {
                                }
                            }
                        }
                    });
                    Display.getInstance().callSerially(new Runnable() {

                        public void run() {
                            parent.actionCommandImpl(c, e);
                        }
                    });
                }
            });
        }

        protected void sizeChanged(int w, int h) {
            Style formStyle = getStyle();
            int width = w - (formStyle.getHorizontalMargins());
            parent.sizeChangedInternal(w, h);
            // close the menu
            if (getWidth() != width) {
                closeMenu();
            }
            super.sizeChanged(w, h);
        }

        public void pointerPressed(int x, int y) {
            if (manualMotionLock) {
                return;
            }
            super.pointerPressed(x, y);
            if (rightPanel.contains(x, y)) {
                pressedInRightPanel = true;
            }
        }

        public void pointerDragged(int[] x, int[] y) {
            if (manualMotionLock) {
                return;
            }
            if (!transitionRunning && pressedInRightPanel) {
                dragActivated = true;
                pressedInRightPanel = false;
            }
            if (dragActivated) {
                setMenuGlassPane(menu, placement);
                draggedX = x[0];
                repaint();
                return;
            }
            super.pointerDragged(x, y);
        }

        public void pointerReleased(int x, int y) {
            if (manualMotionLock) {
                return;
            }
            super.pointerReleased(x, y);
            boolean isRTLValue = isRTL();
            if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
                isRTLValue = !isRTLValue;
            }
            int displayWidth = Display.getInstance().getDisplayWidth();
            if (isRTLValue) {
                if (!transitionRunning && dragActivated && x < (displayWidth - rightPanel.getWidth()) / 2) {
                    final Motion motion = Motion.createEaseInOutMotion(draggedX, rightPanel.getWidth(), 200);
                    motion.start();
                    registerAnimated(new Animation() {

                        public boolean animate() {
                            draggedX = motion.getValue();
                            if (motion.isFinished()) {
                                dragActivated = false;
                                Display.getInstance().getCurrent().setGlassPane(null);
                                deregisterAnimated(this);
                            }
                            return true;
                        }

                        public void paint(Graphics g) {
                            repaint();
                        }
                    });
                    return;
                }
            } else {
                if (!transitionRunning && dragActivated && x > (displayWidth - rightPanel.getWidth()) / 2) {
                    final Motion motion = Motion.createEaseInOutMotion(draggedX, Display.getInstance().getDisplayWidth() - rightPanel.getWidth(), 200);
                    motion.start();
                    registerAnimated(new Animation() {

                        public boolean animate() {
                            draggedX = motion.getValue();
                            if (motion.isFinished()) {
                                dragActivated = false;
                                Display.getInstance().getCurrent().setGlassPane(null);
                                deregisterAnimated(this);
                            }
                            return true;
                        }

                        public void paint(Graphics g) {
                            repaint();
                        }
                    });
                    return;
                }
            }
            if (dragActivated || rightPanel.contains(x, y)) {
                setMenuGlassPane(menu, placement);
                draggedX = x;
                int start = x;
                int end = 0;
                if (isRTLValue) {
                    end = getWidth();
                }
                final Motion motion = Motion.createEaseInOutMotion(start, end, getUIManager().getThemeConstant("sideMenuAnimSpeedInt", 300));
                motion.start();
                manualMotionLock = true;
                sideSwipePotential = false;
                rightSideSwipePotential = false;
                topSwipePotential = false;
                registerAnimated(new Animation() {

                    public boolean animate() {
                        draggedX = motion.getValue();
                        if (motion.isFinished()) {
                            dragActivated = false;
                        }
                        return true;
                    }

                    public void paint(Graphics g) {
                        repaint();
                        if (draggedX == motion.getDestinationValue() && motion.isFinished()) {
                            parent.setTransitionInAnimator(CommonTransitions.createEmpty());
                            parent.show();
                            deregisterAnimated(this);
                            Display.getInstance().callSerially(new Runnable() {

                                public void run() {
                                    clean();
                                }
                            });
                        }
                    }
                });
            }
        }

        public void keyReleased(int keyCode) {
            if (keyCode == leftSK) {
                if (transitionRunning) {
                    return;
                }
                closeMenu();
                return;
            }
            super.keyReleased(keyCode);
        }
    };
    m.setScrollable(false);
    m.removeComponentFromForm(m.getTitleArea());
    m.putClientProperty("Menu", "true");
    m.setTransitionInAnimator(CommonTransitions.createEmpty());
    m.setTransitionOutAnimator(CommonTransitions.createEmpty());
    m.setBackCommand(new Command("") {

        public void actionPerformed(ActionEvent evt) {
            if (transitionRunning) {
                return;
            }
            closeMenu();
        }
    });
    m.setLayout(new BorderLayout());
    if (Display.getInstance().areMutableImagesFast()) {
        rightPanel = new Container(new BorderLayout());
    } else {
        rightPanel = new Container(new BorderLayout()) {

            public void paintBackground(Graphics g) {
            }

            public void paintBackgrounds(Graphics g) {
            }

            public void paint(Graphics g) {
                Component c = (Component) rightPanel.getClientProperty("$parent");
                // not sure why its happening: https://code.google.com/p/codenameone/issues/detail?id=1072
                if (c != null) {
                    boolean b = c.isVisible();
                    c.setVisible(true);
                    int x = getAbsoluteX();
                    g.translate(x, 0);
                    Container.sidemenuBarTranslation = x;
                    c.paintComponent(g, true);
                    Container.sidemenuBarTranslation = 0;
                    g.translate(-x, 0);
                    c.setVisible(b);
                }
            }
        };
    }
    if (placement == COMMAND_PLACEMENT_VALUE_TOP) {
        int v = 0;
        if (Display.getInstance().isPortrait()) {
            if (Display.getInstance().isTablet()) {
                v = getUIManager().getThemeConstant("topMenuSizeTabPortraitInt", -1);
                if (v < 0) {
                    v = m.getHeight() * 2 / 3;
                } else {
                    v = m.getHeight() / 100 * v;
                }
            } else {
                v = getUIManager().getThemeConstant("topMenuSizePortraitInt", -1);
                if (v < 0) {
                    v = openButton.getHeight();
                } else {
                    v = m.getHeight() / 100 * v;
                }
            }
        } else {
            if (Display.getInstance().isTablet()) {
                v = getUIManager().getThemeConstant("topMenuSizeTabLandscapeInt", -1);
                if (v < 0) {
                    v = m.getHeight() * 3 / 4;
                } else {
                    v = m.getWidth() / 100 * v;
                }
            } else {
                v = getUIManager().getThemeConstant("topMenuSizeLandscapeInt", -1);
                if (v < 0) {
                    v = m.getHeight() * 4 / 10;
                } else {
                    v = m.getHeight() / 100 * v;
                }
            }
        }
        rightPanel.setPreferredH(v);
    } else {
        if (Display.getInstance().isPortrait()) {
            int v = 0;
            if (Display.getInstance().isTablet()) {
                v = getUIManager().getThemeConstant("sideMenuSizeTabPortraitInt", -1);
                if (v < 0) {
                    v = m.getWidth() * 2 / 3;
                } else {
                    v = m.getWidth() / 100 * v;
                }
            } else {
                v = getUIManager().getThemeConstant("sideMenuSizePortraitInt", -1);
                if (v < 0) {
                    if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
                        if (isRTL()) {
                            v = openButton.getWidth();
                        } else {
                            v = rightSideButton.getWidth();
                        }
                    } else {
                        v = openButton.getWidth();
                    }
                } else {
                    v = m.getWidth() / 100 * v;
                }
            }
            rightPanel.setPreferredW(v);
        } else {
            int v = 0;
            if (Display.getInstance().isTablet()) {
                v = getUIManager().getThemeConstant("sideMenuSizeTabLandscapeInt", -1);
                if (v < 0) {
                    v = m.getWidth() * 3 / 4;
                } else {
                    v = m.getWidth() / 100 * v;
                }
            } else {
                v = getUIManager().getThemeConstant("sideMenuSizeLandscapeInt", -1);
                if (v < 0) {
                    v = m.getWidth() * 4 / 10;
                } else {
                    v = m.getWidth() / 100 * v;
                }
            }
            rightPanel.setPreferredW(v);
        }
    }
    if (sidePanel != null) {
        sidePanel.removeAll();
        sidePanel = null;
    }
    sidePanel = createSideNavigationComponent(getCommands(), placement);
    if (placement == COMMAND_PLACEMENT_VALUE_RIGHT) {
        m.addComponent(BorderLayout.WEST, rightPanel);
        m.addComponent(BorderLayout.CENTER, sidePanel);
    } else {
        if (placement == COMMAND_PLACEMENT_VALUE_TOP) {
            m.addComponent(BorderLayout.NORTH, rightPanel);
            m.addComponent(BorderLayout.CENTER, sidePanel);
            Button button = new Button(" ");
            button.setUIID("Container");
            button.setPreferredH(Display.getInstance().getDisplayHeight() / 10);
            m.addComponent(BorderLayout.SOUTH, button);
            button.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent evt) {
                    closeMenu();
                }
            });
        } else {
            m.addComponent(BorderLayout.EAST, rightPanel);
            m.addComponent(BorderLayout.CENTER, sidePanel);
        }
    }
    m.putClientProperty("cn1$sideMenuParent", this);
    return m;
}
Also used : Motion(com.codename1.ui.animations.Motion) ActionEvent(com.codename1.ui.events.ActionEvent) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) Style(com.codename1.ui.plaf.Style) Animation(com.codename1.ui.animations.Animation)

Example 63 with Style

use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.

the class FlowLayout method layoutContainer.

/**
 * {@inheritDoc}
 */
public void layoutContainer(Container parent) {
    Style s = parent.getStyle();
    int x = s.getPaddingLeft(parent.isRTL());
    int width = parent.getLayoutWidth() - parent.getSideGap() - s.getPaddingLeft(parent.isRTL()) - x;
    boolean rtl = parent.isRTL();
    if (rtl) {
        x += parent.getSideGap();
    }
    int initX = x;
    int y = s.getPaddingTop();
    int rowH = 0;
    int start = 0;
    int rowBaseline = 0;
    int maxComponentWidth = width;
    int numOfcomponents = parent.getComponentCount();
    for (int i = 0; i < numOfcomponents; i++) {
        Component cmp = parent.getComponentAt(i);
        Style style = cmp.getStyle();
        int marginX = style.getMarginLeftNoRTL() + style.getMarginRightNoRTL();
        cmp.setWidth(Math.min(maxComponentWidth - marginX, cmp.getPreferredW()));
        cmp.setHeight(cmp.getPreferredH());
        if ((x == s.getPaddingLeft(rtl)) || (x + cmp.getPreferredW() <= width)) {
            // We take the actual LEFT since drawing is done in reverse
            x += cmp.getStyle().getMarginLeftNoRTL();
            if (rtl) {
                cmp.setX(Math.max(width + initX - (x - initX) - cmp.getPreferredW(), style.getMarginLeftNoRTL()));
            } else {
                cmp.setX(x);
            }
            cmp.setY(y + cmp.getStyle().getMarginTop());
            x += cmp.getWidth() + cmp.getStyle().getMarginRightNoRTL();
            rowH = Math.max(rowH, cmp.getHeight() + cmp.getStyle().getMarginTop() + cmp.getStyle().getMarginBottom());
            if (valign == Component.BASELINE) {
                int cmpPrefH = cmp.getPreferredH();
                int cmpBaseline = cmp.getBaseline(cmp.getPreferredW(), cmpPrefH);
                rowBaseline = Math.max(rowBaseline, cmpBaseline + cmp.getStyle().getMarginTop());
                rowH = Math.max(rowH, rowBaseline + cmp.getStyle().getMarginBottom() + cmpPrefH - cmpBaseline);
            }
        } else {
            moveComponents(parent, s.getPaddingLeft(rtl), y, width - s.getPaddingLeft(rtl) - x, rowH, start, i, rowBaseline);
            if (fillRows) {
                fillRow(parent, width, start, i);
            }
            x = initX + cmp.getStyle().getMarginLeftNoRTL();
            y += rowH;
            rowBaseline = 0;
            if (rtl) {
                cmp.setX(Math.max(width + initX - (x - initX) - cmp.getPreferredW(), style.getMarginLeftNoRTL()));
            } else {
                cmp.setX(x);
            }
            cmp.setY(y + cmp.getStyle().getMarginTop());
            rowH = cmp.getPreferredH() + cmp.getStyle().getMarginTop() + cmp.getStyle().getMarginBottom();
            if (valign == Component.BASELINE) {
                int cmpPrefH = cmp.getPreferredH();
                int cmpBaseline = cmp.getBaseline(cmp.getPreferredW(), cmpPrefH);
                rowBaseline = Math.max(rowBaseline, cmpBaseline + cmp.getStyle().getMarginTop());
                rowH = Math.max(rowH, rowBaseline + cmp.getStyle().getMarginBottom() + cmpPrefH - cmpBaseline);
            }
            x += cmp.getPreferredW() + cmp.getStyle().getMarginRightNoRTL();
            start = i;
        }
    }
    moveComponents(parent, s.getPaddingLeft(rtl), y, width - s.getPaddingLeft(rtl) - x, rowH, start, numOfcomponents, rowBaseline);
    if (fillRows) {
        fillRow(parent, width, start, numOfcomponents);
    }
}
Also used : Style(com.codename1.ui.plaf.Style) Component(com.codename1.ui.Component)

Example 64 with Style

use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.

the class FlowLayout method getPreferredSize.

/**
 * {@inheritDoc}
 */
public Dimension getPreferredSize(Container parent) {
    int parentWidth = parent.getWidth();
    if (parentWidth == 0) {
        parent.invalidate();
    }
    int width = 0;
    int height = 0;
    int w = 0;
    int numOfcomponents = parent.getComponentCount();
    Style parentStyle = parent.getStyle();
    int parentPadding = parentStyle.getHorizontalPadding();
    for (int i = 0; i < numOfcomponents; i++) {
        Component cmp = parent.getComponentAt(i);
        height = Math.max(height, cmp.getPreferredH() + cmp.getStyle().getMarginTop() + cmp.getStyle().getMarginBottom());
        int prefW = cmp.getPreferredW() + cmp.getStyle().getMarginRightNoRTL() + cmp.getStyle().getMarginLeftNoRTL();
        w += prefW;
        // we need to break a line
        if (parentWidth > parentPadding && w > parentWidth && i > 0) {
            height += cmp.getPreferredH() + cmp.getStyle().getMarginTop() + cmp.getStyle().getMarginBottom();
            width = Math.max(w, width);
            w = prefW;
        }
    }
    width = Math.max(w, width);
    dim.setWidth(width + parent.getStyle().getPaddingLeftNoRTL() + parent.getStyle().getPaddingRightNoRTL());
    dim.setHeight(height + parent.getStyle().getPaddingTop() + parent.getStyle().getPaddingBottom());
    return dim;
}
Also used : Style(com.codename1.ui.plaf.Style) Component(com.codename1.ui.Component)

Example 65 with Style

use of com.codename1.charts.compat.Paint.Style in project CodenameOne by codenameone.

the class GridBagLayoutInfo method getPreferredSize.

public Dimension getPreferredSize(Container parent) {
    Style s = parent.getStyle();
    ParentInfo info = lastParentInfo = getParentInfo(parent);
    if (getComponentsNumber(parent) == 0) {
        return new Dimension(s.getHorizontalPadding(), s.getVerticalPadding());
    }
    try {
        validate(parent, info);
    } catch (RuntimeException e) {
        // awt.87=PreferredLayoutSize: {0}
        Log.e(e);
        // $NON-NLS-1$
        throw new IllegalArgumentException("PreferredLayoutSize: " + e.getMessage());
    }
    Dimension d = info.grid.preferredSize();
    d.setWidth(d.getWidth() + s.getHorizontalPadding());
    d.setHeight(d.getHeight() + s.getVerticalPadding());
    return d;
// return addInsets(grid.preferredSize(), parent);
}
Also used : Style(com.codename1.ui.plaf.Style) Dimension(com.codename1.ui.geom.Dimension)

Aggregations

Style (com.codename1.ui.plaf.Style)103 Dimension (com.codename1.ui.geom.Dimension)28 Component (com.codename1.ui.Component)25 Image (com.codename1.ui.Image)20 Rectangle (com.codename1.ui.geom.Rectangle)13 Container (com.codename1.ui.Container)11 Font (com.codename1.ui.Font)11 FontImage (com.codename1.ui.FontImage)11 Border (com.codename1.ui.plaf.Border)8 Form (com.codename1.ui.Form)6 Label (com.codename1.ui.Label)6 ActionEvent (com.codename1.ui.events.ActionEvent)6 IOException (java.io.IOException)6 UIManager (com.codename1.ui.plaf.UIManager)5 Vector (java.util.Vector)5 Dialog (com.codename1.ui.Dialog)4 EncodedImage (com.codename1.ui.EncodedImage)4 Graphics (com.codename1.ui.Graphics)4 TextArea (com.codename1.ui.TextArea)4 SpanButton (com.codename1.components.SpanButton)3