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);
}
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);
}
}
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);
}
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;
}
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));
}
}
}
Aggregations