use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.
the class SelectRowCommandHandler method selectRowWithCtrlKey.
private Range selectRowWithCtrlKey(int columnPosition, int rowPosition) {
Rectangle selectedRowRectangle = new Rectangle(0, rowPosition, selectionLayer.getColumnCount(), 1);
if (selectionLayer.isRowFullySelected(rowPosition)) {
selectionLayer.clearSelection(selectedRowRectangle);
if (selectionLayer.lastSelectedRegion != null && selectionLayer.lastSelectedRegion.equals(selectedRowRectangle)) {
selectionLayer.lastSelectedRegion = null;
}
} else {
// Preserve last selected region
if (selectionLayer.lastSelectedRegion != null) {
selectionLayer.selectionModel.addSelection(new Rectangle(selectionLayer.lastSelectedRegion.x, selectionLayer.lastSelectedRegion.y, selectionLayer.lastSelectedRegion.width, selectionLayer.lastSelectedRegion.height));
}
selectionLayer.selectRegion(0, rowPosition, selectionLayer.getColumnCount(), 1);
selectionLayer.moveSelectionAnchor(columnPosition, rowPosition);
}
return new Range(rowPosition, rowPosition + 1);
}
use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.
the class SelectionLayer method clear.
// Clear features
public void clear() {
selectionModel.clearSelection();
lastSelectedCell.columnPosition = -1;
lastSelectedCell.rowPosition = -1;
lastSelectedRegion = new Rectangle(0, 0, 0, 0);
selectionAnchor.columnPosition = -1;
selectionAnchor.rowPosition = -1;
}
use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.
the class SelectionLayer method hideMultipleColumnPositions.
/**
* Any selected columns will be hidden. A column is considered selected even if a cell is selected.
*/
protected boolean hideMultipleColumnPositions(MultiColumnHideCommand command) {
for (int columnPosition : command.getColumnPositions()) {
if (isColumnFullySelected(columnPosition)) {
Rectangle selection = new Rectangle(columnPosition, 0, 1, getRowCount());
clearSelection(selection);
}
}
return super.doCommand(command);
}
use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.
the class CellEdgeDetectUtil method getHorizontalCellEdge.
/**
* Figure out if the click point is closer to the left/right edge of the cell.
* @param cellBounds of the table cell containing the click
* @param clickPt
* @param distanceFromEdge distance from the edge to qualify as <i>close</i> to the cell edge
*/
public static CellEdgeEnum getHorizontalCellEdge(Rectangle cellBounds, Point clickPt, int distanceFromEdge) {
if (distanceFromEdge < 0) {
distanceFromEdge = cellBounds.width / 2;
}
Rectangle left = new Rectangle(cellBounds.x, cellBounds.y, distanceFromEdge, cellBounds.height);
Rectangle right = new Rectangle(cellBounds.x + cellBounds.width - distanceFromEdge, cellBounds.y, distanceFromEdge, cellBounds.height);
if (left.contains(clickPt)) {
return LEFT;
} else if (right.contains(clickPt)) {
return RIGHT;
} else {
return NONE;
}
}
use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.
the class NatCombo method createTextControl.
private void createTextControl() {
text = new Text(this, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
text.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
text.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
text.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(gridData);
text.forceFocus();
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP) {
showDropdownControl();
int selectionIndex = dropdownList.getSelectionIndex();
selectionIndex += event.keyCode == SWT.ARROW_DOWN ? 1 : -1;
if (selectionIndex < 0) {
selectionIndex = 0;
}
dropdownList.select(selectionIndex);
text.setText(dropdownList.getSelection()[0]);
}
}
});
iconImage = GUIHelper.getImage("down_2");
final Canvas iconCanvas = new Canvas(this, SWT.NONE) {
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
Rectangle iconImageBounds = iconImage.getBounds();
return new Point(iconImageBounds.width + 2, iconImageBounds.height + 2);
}
};
gridData = new GridData(GridData.BEGINNING, SWT.FILL, false, true);
iconCanvas.setLayoutData(gridData);
iconCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
GC gc = event.gc;
Rectangle iconCanvasBounds = iconCanvas.getBounds();
Rectangle iconImageBounds = iconImage.getBounds();
int horizontalAlignmentPadding = CellStyleUtil.getHorizontalAlignmentPadding(HorizontalAlignmentEnum.CENTER, iconCanvasBounds, iconImageBounds.width);
int verticalAlignmentPadding = CellStyleUtil.getVerticalAlignmentPadding(VerticalAlignmentEnum.MIDDLE, iconCanvasBounds, iconImageBounds.height);
gc.drawImage(iconImage, horizontalAlignmentPadding, verticalAlignmentPadding);
Color originalFg = gc.getForeground();
gc.setForeground(GUIHelper.COLOR_WIDGET_BORDER);
gc.drawRectangle(0, 0, iconCanvasBounds.width - 1, iconCanvasBounds.height - 1);
gc.setForeground(originalFg);
}
});
iconCanvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
showDropdownControl();
}
});
}
Aggregations