Search in sources :

Example 26 with Rectangle

use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.

the class TextArea method keyPressed.

/**
 * {@inheritDoc}
 */
public void keyPressed(int keyCode) {
    super.keyPressed(keyCode);
    int action = com.codename1.ui.Display.getInstance().getGameAction(keyCode);
    // this works around a bug where fire is also a softkey on devices such as newer Nokia
    // series 40's (e.g. the Nokia emulator). It closes its native text box on fire then
    // as a result of a Nokia bug we get the key released of that closing and assume the
    // users wants to edit the text... When means the only way to exit the native text box
    // is via the cancel option (after pressing OK once).
    triggerClose = action == Display.GAME_FIRE;
    // scroll the TextArea
    Rectangle rect = new Rectangle(getScrollX(), getScrollY(), getWidth(), getHeight());
    Font textFont = getStyle().getFont();
    if (action == Display.GAME_DOWN) {
        if ((getScrollY() + getHeight()) < (rowsGap + getStyle().getFont().getHeight()) * getLines()) {
            rect.setY(rect.getY() + (textFont.getHeight() + rowsGap) * linesToScroll);
            scrollRectToVisible(rect, this);
        } else {
            setHandlesInput(false);
        }
    } else {
        if (action == Display.GAME_UP) {
            if (getScrollY() > 0) {
                rect.setY(Math.max(0, rect.getY() - (textFont.getHeight() + rowsGap) * linesToScroll));
                scrollRectToVisible(rect, this);
            } else {
                setHandlesInput(false);
            }
        }
    }
    if (action == Display.GAME_RIGHT || action == Display.GAME_LEFT) {
        setHandlesInput(false);
    }
}
Also used : Rectangle(com.codename1.ui.geom.Rectangle)

Example 27 with Rectangle

use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.

the class GridBagLayoutInfo method calculateComponentBounds.

private void calculateComponentBounds(ComponentSide horSide, ComponentSide vertSide, Rectangle r, Grid grid) {
    Rectangle dispArea = grid.componentDisplayArea(horSide, vertSide);
    r.setWidth(fillDisplaySide(dispArea.getWidth(), horSide));
    r.setHeight(fillDisplaySide(dispArea.getHeight(), vertSide));
    r.setX(anchorComponentSide(dispArea.getX(), dispArea.getWidth(), horSide, r.getWidth()));
    r.setY(anchorComponentSide(dispArea.getY(), dispArea.getHeight(), vertSide, r.getHeight()));
}
Also used : Rectangle(com.codename1.ui.geom.Rectangle)

Example 28 with Rectangle

use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.

the class GridBagLayoutInfo method AdjustForGravity.

/*protected GridBagLayoutInfo getLayoutInfo(Container parent, int sizeflag) {
        return GetLayoutInfo(parent, sizeflag);
    }

    protected Dimension getMinSize(Container parent, GridBagLayoutInfo info) {
        toolkit.lockAWT();
        try {
            return GetMinSize(parent, info);
        } finally {
            toolkit.unlockAWT();
        }
    }*/
protected void AdjustForGravity(GridBagConstraints constraints, Rectangle r) {
    // Don't get parent as param, so have to use older info if exists
    if (layoutInfo == null) {
        r.setBounds(0, 0, 0, 0);
        return;
    }
    GridBagConstraints consClone = (GridBagConstraints) constraints.clone();
    consClone.fill = GridBagConstraints.BOTH;
    ComponentSide horSide = new ComponentSide();
    ComponentSide vertSide = new ComponentSide();
    Dimension dummySize = new Dimension(0, 0);
    initHorCompSide(horSide, consClone, dummySize, dummySize, lastParentInfo);
    initVertCompSide(vertSide, consClone, dummySize, dummySize, lastParentInfo);
    calculateComponentBounds(horSide, vertSide, r, lastParentInfo.grid);
}
Also used : Dimension(com.codename1.ui.geom.Dimension)

Example 29 with Rectangle

use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.

the class GridBagLayoutInfo method setComponentsBounds.

private void setComponentsBounds(ParentInfo info) {
    for (int i = 0; i < info.components.length; i++) {
        Rectangle r = new Rectangle();
        calculateComponentBounds(info.horCompSides[i], info.vertCompSides[i], r, info.grid);
        info.components[i].setX(r.getX());
        info.components[i].setY(r.getY());
        info.components[i].setWidth(r.getSize().getWidth());
        info.components[i].setHeight(r.getSize().getHeight());
    }
}
Also used : Rectangle(com.codename1.ui.geom.Rectangle)

Example 30 with Rectangle

use of com.codename1.ui.geom.Rectangle in project CodenameOne by codenameone.

the class GridBagLayoutInfo method arrangeGridImpl.

private void arrangeGridImpl(Container parent, ParentInfo info) {
    validate(parent, info);
    // Do not check clientRect for emptiness. Grid must be updated anyway
    Rectangle clientRect = new Rectangle(0, 0, parent.getWidth(), parent.getHeight());
    info.grid.fit2Client(clientRect);
}
Also used : Rectangle(com.codename1.ui.geom.Rectangle)

Aggregations

Rectangle (com.codename1.ui.geom.Rectangle)41 Dimension (com.codename1.ui.geom.Dimension)16 Style (com.codename1.ui.plaf.Style)13 Image (com.codename1.ui.Image)10 ActionEvent (com.codename1.ui.events.ActionEvent)5 Border (com.codename1.ui.plaf.Border)5 Component (com.codename1.ui.Component)4 Graphics (com.codename1.ui.Graphics)4 UIManager (com.codename1.ui.plaf.UIManager)4 Form (com.codename1.ui.Form)3 Label (com.codename1.ui.Label)3 GeneralPath (com.codename1.ui.geom.GeneralPath)3 Point (com.codename1.ui.geom.Point)3 BorderLayout (com.codename1.ui.layouts.BorderLayout)3 Paint (com.codename1.charts.compat.Paint)2 Button (com.codename1.ui.Button)2 EncodedImage (com.codename1.ui.EncodedImage)2 Painter (com.codename1.ui.Painter)2 ActionListener (com.codename1.ui.events.ActionListener)2 RoundBorder (com.codename1.ui.plaf.RoundBorder)2