Search in sources :

Example 76 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class RowStructuralChangeEvent method getChangedPositionRectangles.

@Override
public Collection<Rectangle> getChangedPositionRectangles() {
    Collection<Rectangle> changedPositionRectangles = new ArrayList<Rectangle>();
    int columnCount = getLayer().getColumnCount();
    int rowCount = getLayer().getRowCount();
    for (Range range : getRowPositionRanges()) {
        changedPositionRectangles.add(new Rectangle(0, range.start, columnCount, rowCount - range.start));
    }
    return changedPositionRectangles;
}
Also used : ArrayList(java.util.ArrayList) Rectangle(org.eclipse.swt.graphics.Rectangle) Range(net.sourceforge.nattable.coordinate.Range)

Example 77 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class BackgroundImagePainter method paintCell.

@Override
public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
    // Save GC settings
    Color originalBackground = gc.getBackground();
    Color originalForeground = gc.getForeground();
    gc.setBackgroundPattern(new Pattern(Display.getCurrent(), bgImage));
    gc.fillRectangle(rectangle);
    gc.setBackgroundPattern(null);
    if (isNotNull(separatorColor)) {
        gc.setForeground(separatorColor);
        gc.drawLine(rectangle.x - 1, rectangle.y, rectangle.x - 1, rectangle.y + rectangle.height);
        gc.drawLine(rectangle.x - 1 + rectangle.width, rectangle.y, rectangle.x - 1 + rectangle.width, rectangle.y + rectangle.height);
    }
    // Restore original GC settings
    gc.setBackground(originalBackground);
    gc.setForeground(originalForeground);
    // Draw interior
    Rectangle interiorBounds = new Rectangle(rectangle.x + 2, rectangle.y + 2, rectangle.width - 4, rectangle.height - 4);
    super.paintCell(cell, gc, interiorBounds, configRegistry);
}
Also used : Pattern(org.eclipse.swt.graphics.Pattern) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 78 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class ImagePainter method paintCell.

@Override
public void paintCell(LayerCell cell, GC gc, Rectangle bounds, IConfigRegistry configRegistry) {
    if (paintBg) {
        super.paintCell(cell, gc, bounds, configRegistry);
    }
    Image image = getImage(cell, configRegistry);
    if (image != null) {
        Rectangle imageBounds = image.getBounds();
        IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
        gc.drawImage(image, bounds.x + CellStyleUtil.getHorizontalAlignmentPadding(cellStyle, bounds, imageBounds.width), bounds.y + CellStyleUtil.getVerticalAlignmentPadding(cellStyle, bounds, imageBounds.height));
    }
}
Also used : IStyle(net.sourceforge.nattable.style.IStyle) Rectangle(org.eclipse.swt.graphics.Rectangle) Image(org.eclipse.swt.graphics.Image)

Example 79 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class BeveledBorderDecorator method paintCell.

public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
    Rectangle interiorBounds = new Rectangle(rectangle.x + 2, rectangle.y + 2, rectangle.width - 4, rectangle.height - 4);
    super.paintCell(cell, gc, interiorBounds, configRegistry);
    // Save GC settings
    Color originalForeground = gc.getForeground();
    //TODO: Need to look at the border style
    // Up
    gc.setForeground(GUIHelper.COLOR_WIDGET_LIGHT_SHADOW);
    gc.drawLine(rectangle.x, rectangle.y, rectangle.x + rectangle.width - 1, rectangle.y);
    gc.drawLine(rectangle.x, rectangle.y, rectangle.x, rectangle.y + rectangle.height - 1);
    gc.setForeground(GUIHelper.COLOR_WIDGET_HIGHLIGHT_SHADOW);
    gc.drawLine(rectangle.x + 1, rectangle.y + 1, rectangle.x + rectangle.width - 1, rectangle.y + 1);
    gc.drawLine(rectangle.x + 1, rectangle.y + 1, rectangle.x + 1, rectangle.y + rectangle.height - 1);
    // Down
    gc.setForeground(GUIHelper.COLOR_WIDGET_DARK_SHADOW);
    gc.drawLine(rectangle.x, rectangle.y + rectangle.height - 1, rectangle.x + rectangle.width - 1, rectangle.y + rectangle.height - 1);
    gc.drawLine(rectangle.x + rectangle.width - 1, rectangle.y, rectangle.x + rectangle.width - 1, rectangle.y + rectangle.height - 1);
    gc.setForeground(GUIHelper.COLOR_WIDGET_NORMAL_SHADOW);
    gc.drawLine(rectangle.x, rectangle.y + rectangle.height - 2, rectangle.x + rectangle.width - 1, rectangle.y + rectangle.height - 2);
    gc.drawLine(rectangle.x + rectangle.width - 2, rectangle.y, rectangle.x + rectangle.width - 2, rectangle.y + rectangle.height - 2);
    // Restore GC settings
    gc.setForeground(originalForeground);
}
Also used : Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 80 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class CellPainterDecorator method paintCell.

public void paintCell(LayerCell cell, GC gc, Rectangle bounds, IConfigRegistry configRegistry) {
    int x = bounds.x + (cellEdge == CellEdgeEnum.LEFT ? decoratorCellPainter.getPreferredWidth(cell, gc, configRegistry) + spacing : 0);
    int y = bounds.y + (cellEdge == CellEdgeEnum.TOP ? decoratorCellPainter.getPreferredHeight(cell, gc, configRegistry) + spacing : 0);
    Rectangle baseCellPainterBounds = new Rectangle(x, y, bounds.width, bounds.height).intersection(bounds);
    baseCellPainter.paintCell(cell, gc, baseCellPainterBounds, configRegistry);
    x = bounds.x + (cellEdge == CellEdgeEnum.RIGHT ? bounds.width - spacing - decoratorCellPainter.getPreferredWidth(cell, gc, configRegistry) : 0);
    y = bounds.y + (cellEdge == CellEdgeEnum.BOTTOM ? bounds.height - spacing - decoratorCellPainter.getPreferredHeight(cell, gc, configRegistry) : 0);
    Rectangle decoratorCellPainterBounds = new Rectangle(x, y, bounds.width, bounds.height).intersection(bounds);
    decoratorCellPainter.paintCell(cell, gc, decoratorCellPainterBounds, configRegistry);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle)

Aggregations

Rectangle (org.eclipse.swt.graphics.Rectangle)651 Point (org.eclipse.swt.graphics.Point)370 Image (org.eclipse.swt.graphics.Image)114 GC (org.eclipse.swt.graphics.GC)104 Test (org.junit.Test)80 Color (org.eclipse.swt.graphics.Color)61 Shell (org.eclipse.swt.widgets.Shell)54 Composite (org.eclipse.swt.widgets.Composite)53 SelectionEvent (org.eclipse.swt.events.SelectionEvent)51 TableItem (org.eclipse.swt.widgets.TableItem)47 GridLayout (org.eclipse.swt.layout.GridLayout)44 Display (org.eclipse.swt.widgets.Display)44 Button (org.eclipse.swt.widgets.Button)42 Menu (org.eclipse.swt.widgets.Menu)40 GridData (org.eclipse.swt.layout.GridData)38 Label (org.eclipse.swt.widgets.Label)37 SWT (org.eclipse.swt.SWT)34 Event (org.eclipse.swt.widgets.Event)34 Font (org.eclipse.swt.graphics.Font)30 Listener (org.eclipse.swt.widgets.Listener)29