Search in sources :

Example 46 with Rectangle

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

the class Grid method handleRowResizerDragging.

/**
     * Sets the new height of the item of the row being resized and fires the appropriate
     * listeners.
     *
     * @param x mouse x
     */
private void handleRowResizerDragging(int y) {
    int newHeight = resizingRowStartHeight + (y - resizingStartY);
    if (newHeight < MIN_ROW_HEADER_HEIGHT) {
        newHeight = MIN_ROW_HEADER_HEIGHT;
    }
    if (newHeight > getClientArea().height) {
        newHeight = getClientArea().height;
    }
    if (newHeight == rowBeingResized.getHeight()) {
        return;
    }
    Event e = new Event();
    e.item = rowBeingResized;
    e.widget = this;
    e.detail = newHeight;
    rowBeingResized.notifyListeners(SWT.Resize, e);
    if (e.doit == false)
        return;
    newHeight = e.detail;
    if (newHeight < MIN_ROW_HEADER_HEIGHT) {
        newHeight = MIN_ROW_HEADER_HEIGHT;
    }
    if (newHeight > getClientArea().height) {
        newHeight = getClientArea().height;
    }
    rowBeingResized.setHeight(newHeight);
    scrollValuesObsolete = true;
    Rectangle clientArea = getClientArea();
    redraw(clientArea.x, clientArea.y, clientArea.width, clientArea.height, false);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) FocusEvent(org.eclipse.swt.events.FocusEvent) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Event(org.eclipse.swt.widgets.Event) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point)

Example 47 with Rectangle

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

the class TableCombo method internalLayout.

/**
	 * This method is invoked when a resize event occurs.
	 * @param changed
	 */
private void internalLayout(boolean changed) {
    if (isDropped())
        dropDown(false);
    Rectangle rect = getClientArea();
    int width = rect.width;
    int height = rect.height;
    Point arrowSize = arrow.computeSize(SWT.DEFAULT, height, changed);
    // calculate text vertical alignment.
    int textYPos = 0;
    Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    if (textSize.y < height) {
        textYPos = (height - textSize.y) / 2;
    }
    // does the selected entry have a image associated with it?
    if (selectedImage.getImage() == null) {
        // set image, text, and arrow boundaries
        selectedImage.setBounds(0, 0, 0, 0);
        text.setBounds(0, textYPos, width - arrowSize.x, textSize.y);
        arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
    } else {
        // calculate the amount of width left in the control after taking
        // into account the arrow selector
        int remainingWidth = width - arrowSize.x;
        Point imageSize = selectedImage.computeSize(SWT.DEFAULT, height, changed);
        int imageWidth = imageSize.x + 2;
        // space in the control.
        if (imageWidth > remainingWidth) {
            imageWidth = remainingWidth;
            remainingWidth = 0;
        } else {
            remainingWidth = remainingWidth - imageWidth;
        }
        // set the width of the text.
        int textWidth = remainingWidth;
        // set image, text, and arrow boundaries
        selectedImage.setBounds(0, 0, imageWidth, imageSize.y);
        text.setBounds(imageWidth, textYPos, textWidth, textSize.y);
        arrow.setBounds(imageWidth + textWidth, 0, arrowSize.x, arrowSize.y);
    }
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 48 with Rectangle

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

the class GridCellSpanManager method addCellSpanInfo.

protected void addCellSpanInfo(int colIndex, int rowIndex, int colSpan, int rowSpan) {
    Rectangle rect = new Rectangle(colIndex, rowIndex, colSpan + 1, rowSpan + 1);
    this.listOfCellSpanRectangles.add(rect);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 49 with Rectangle

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

the class GridColumn method getBounds.

/**
	 * Returns the bounds of this column's header.
	 *
	 * @return bounds of the column header
	 */
Rectangle getBounds() {
    Rectangle bounds = new Rectangle(0, 0, 0, 0);
    if (!isVisible()) {
        return bounds;
    }
    Point loc = parent.getOrigin(this, null);
    bounds.x = loc.x;
    bounds.y = loc.y;
    bounds.width = getWidth();
    bounds.height = parent.getHeaderHeight();
    if (getColumnGroup() != null) {
        bounds.height -= parent.getGroupHeaderHeight();
    }
    return bounds;
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point)

Example 50 with Rectangle

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

the class AttributeTextCellRenderer method draw.

public void draw(GC gc, JaretTable jaretTable, ICellStyle cellStyle, Rectangle drawingArea, IRow row, IColumn column, boolean drawFocus, boolean selected, boolean printing) {
    super.draw(gc, jaretTable, cellStyle, drawingArea, row, column, drawFocus, selected, printing);
    // Color bg = gc.getBackground();
    // Color fg = gc.getForeground();
    Rectangle drect = drawBorder(gc, cellStyle, drawingArea, printing);
    Rectangle rect = applyInsets(drect);
    String s = convertValue(row, column);
    if (s != null && mapStyle != null && mapStyle.containsKey(row)) {
        if (selected && !printing) {
            Color color = ColorManager.getColorManager(Display.getCurrent()).getColor(new RGB(218, 218, 218));
            gc.setBackground(color);
        } else {
            gc.setBackground(getBackgroundColor(cellStyle, printing));
        }
        if (textLayout == null) {
            textLayout = new TextLayout(gc.getDevice());
            jaretTable.getParent().addDisposeListener(new DisposeListener() {

                public void widgetDisposed(DisposeEvent e) {
                    textLayout.dispose();
                }
            });
        }
        textLayout.setOrientation(jaretTable.getOrientation());
        textLayout.setText(s);
        textLayout.setFont(gc.getFont());
        textLayout.setWidth(rect.width);
        ArrayList<int[]> lstIndex = mapStyle.get(row);
        if (lstIndex != null) {
            for (int[] arrIndex : lstIndex) {
                if (arrIndex != null && arrIndex.length == 2) {
                    textLayout.setStyle(style, arrIndex[0], arrIndex[1] - 1);
                }
            }
            gc.fillRectangle(rect);
            textLayout.draw(gc, rect.x, rect.y);
            gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle) RGB(org.eclipse.swt.graphics.RGB) DisposeEvent(org.eclipse.swt.events.DisposeEvent) TextLayout(org.eclipse.swt.graphics.TextLayout)

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