Search in sources :

Example 6 with RadAbstractGridLayoutManager

use of com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager in project intellij-community by JetBrains.

the class GridInsertLocation method getInsertFeedbackPosition.

public static Rectangle getInsertFeedbackPosition(final GridInsertMode mode, final RadContainer container, final Rectangle cellRect, final Rectangle feedbackRect) {
    final RadAbstractGridLayoutManager manager = container.getGridLayoutManager();
    int[] vGridLines = manager.getVerticalGridLines(container);
    int[] hGridLines = manager.getHorizontalGridLines(container);
    Rectangle rc = feedbackRect;
    int w = 4;
    switch(mode) {
        case ColumnBefore:
            rc = new Rectangle(vGridLines[cellRect.x] - w, feedbackRect.y - INSERT_ARROW_SIZE, 2 * w, feedbackRect.height + 2 * INSERT_ARROW_SIZE);
            if (cellRect.x > 0 && manager.isGapCell(container, false, cellRect.x - 1)) {
                rc.translate(-(vGridLines[cellRect.x] - vGridLines[cellRect.x - 1]) / 2, 0);
            }
            break;
        case ColumnAfter:
            rc = new Rectangle(vGridLines[cellRect.x + cellRect.width + 1] - w, feedbackRect.y - INSERT_ARROW_SIZE, 2 * w, feedbackRect.height + 2 * INSERT_ARROW_SIZE);
            if (cellRect.x < manager.getGridColumnCount(container) - 1 && manager.isGapCell(container, false, cellRect.x + 1)) {
                rc.translate((vGridLines[cellRect.x + 2] - vGridLines[cellRect.x + 1]) / 2, 0);
            }
            break;
        case RowBefore:
            rc = new Rectangle(feedbackRect.x - INSERT_ARROW_SIZE, hGridLines[cellRect.y] - w, feedbackRect.width + 2 * INSERT_ARROW_SIZE, 2 * w);
            if (cellRect.y > 0 && manager.isGapCell(container, true, cellRect.y - 1)) {
                rc.translate(0, -(hGridLines[cellRect.y] - hGridLines[cellRect.y - 1]) / 2);
            }
            break;
        case RowAfter:
            rc = new Rectangle(feedbackRect.x - INSERT_ARROW_SIZE, hGridLines[cellRect.y + cellRect.height + 1] - w, feedbackRect.width + 2 * INSERT_ARROW_SIZE, 2 * w);
            if (cellRect.y < manager.getGridRowCount(container) - 1 && manager.isGapCell(container, true, cellRect.y + 1)) {
                rc.translate(0, (hGridLines[cellRect.y + 2] - hGridLines[cellRect.y + 1]) / 2);
            }
            break;
    }
    return rc;
}
Also used : RadAbstractGridLayoutManager(com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager)

Example 7 with RadAbstractGridLayoutManager

use of com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager in project intellij-community by JetBrains.

the class GridChangeUtil method insertRowOrColumn.

/**
   * @param cellIndex column or row index, depending on isRow parameter; must be in the range 0..grid.get{Row|Column}Count()-1
   * @param isRow if true, row inserted, otherwise column
   * @param isBefore if true, row/column will be inserted before row/column with given index, otherwise after
   */
public static void insertRowOrColumn(final RadContainer grid, final int cellIndex, final boolean isRow, final boolean isBefore) {
    check(grid, isRow, cellIndex);
    final RadAbstractGridLayoutManager oldLayout = grid.getGridLayoutManager();
    int beforeIndex = cellIndex;
    if (!isBefore) {
        // beforeIndex can actually be equal to get{Row|Column}Count an case we add row after the last row/column
        beforeIndex++;
    }
    final LayoutManager newLayout = oldLayout.copyLayout(grid.getLayout(), isRow ? 1 : 0, isRow ? 0 : 1);
    GridConstraints[] oldConstraints = copyConstraints(grid);
    for (int i = grid.getComponentCount() - 1; i >= 0; i--) {
        final GridConstraints constraints = grid.getComponent(i).getConstraints();
        adjustConstraintsOnInsert(constraints, isRow, beforeIndex, 1);
    }
    grid.setLayout(newLayout);
    fireAllConstraintsChanged(grid, oldConstraints);
}
Also used : RadAbstractGridLayoutManager(com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager) RadAbstractGridLayoutManager(com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager) GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 8 with RadAbstractGridLayoutManager

use of com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager in project intellij-community by JetBrains.

the class GridCaptionPanel method paintComponent.

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    final Rectangle bounds = getBounds();
    final int paintedSize = 8;
    final int paintOffset = 7;
    RadContainer container = getSelectedGridContainer();
    if (container == null) {
        return;
    }
    RadAbstractGridLayoutManager layout = container.getGridLayoutManager();
    int[] coords = layout.getGridCellCoords(container, myIsRow);
    int[] sizes = layout.getGridCellSizes(container, myIsRow);
    int count = myIsRow ? layout.getGridRowCount(container) : layout.getGridColumnCount(container);
    for (int i = 0; i < count; i++) {
        int x = myIsRow ? 0 : coords[i];
        int y = myIsRow ? coords[i] : 0;
        Point pnt = SwingUtilities.convertPoint(container.getDelegee(), x, y, this);
        Rectangle rc = myIsRow ? new Rectangle(bounds.x + paintOffset, pnt.y, paintedSize, sizes[i]) : new Rectangle(pnt.x, bounds.y + paintOffset, sizes[i], paintedSize);
        g.setColor(getCaptionColor(i));
        g.fillRect(rc.x, rc.y, rc.width, rc.height);
        Rectangle rcDecoration = myIsRow ? new Rectangle(bounds.x, pnt.y, bounds.width, sizes[i]) : new Rectangle(pnt.x, bounds.y, sizes[i], bounds.height);
        layout.paintCaptionDecoration(container, myIsRow, i, g2d, rcDecoration);
        Stroke oldStroke = g2d.getStroke();
        int deltaX = 0;
        int deltaY = 0;
        if (isFocusOwner() && i == mySelectionModel.getLeadSelectionIndex()) {
            g.setColor(Color.BLACK);
            g2d.setStroke(new BasicStroke(2.0f));
            deltaX = myIsRow ? 1 : 0;
            deltaY = myIsRow ? 0 : 1;
        } else {
            g.setColor(Color.DARK_GRAY);
        }
        g.drawRect(rc.x + deltaX, rc.y + deltaY, rc.width - deltaX, rc.height - deltaY);
        g2d.setStroke(oldStroke);
    }
    g.setColor(Color.DARK_GRAY);
    if (myIsRow) {
        g.drawLine(paintOffset + paintedSize, 0, paintOffset + paintedSize, bounds.height);
    } else {
        g.drawLine(0, paintOffset + paintedSize, bounds.width, paintOffset + paintedSize);
    }
    if (myDropInsertLine >= 0) {
        int[] lines = myIsRow ? layout.getHorizontalGridLines(container) : layout.getVerticalGridLines(container);
        int coord = lines[myDropInsertLine];
        if (myIsRow) {
            coord = SwingUtilities.convertPoint(container.getDelegee(), 0, coord, this).y;
        } else {
            coord = SwingUtilities.convertPoint(container.getDelegee(), coord, 0, this).x;
        }
        Stroke oldStroke = g2d.getStroke();
        g2d.setStroke(new BasicStroke(2.0f));
        g.setColor(PlatformColors.BLUE);
        if (myIsRow) {
            g.drawLine(bounds.x + 1, coord, bounds.x + bounds.width - 1, coord);
        } else {
            g.drawLine(coord, bounds.y + 1, coord, bounds.y + bounds.height - 1);
        }
        g2d.setStroke(oldStroke);
    }
}
Also used : RadAbstractGridLayoutManager(com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Aggregations

RadAbstractGridLayoutManager (com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager)8 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)2 HSpacer (com.intellij.uiDesigner.HSpacer)1 VSpacer (com.intellij.uiDesigner.VSpacer)1 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)1 Palette (com.intellij.uiDesigner.palette.Palette)1 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)1 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)1 ColumnSpec (com.jgoodies.forms.layout.ColumnSpec)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 RowSpec (com.jgoodies.forms.layout.RowSpec)1