/** * This does the work of laying out our controls. * * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean) */ protected void layout(Composite composite, boolean flushCache) { getControls(composite); Rectangle rect = composite.getClientArea(); int left = rect.x, right = rect.width, top = rect.y, bottom = rect.height; if (north != null) { Point pt = getSize(north, flushCache); north.setBounds(left, top, rect.width, pt.y); top += pt.y; } if (south != null) { Point pt = getSize(south, flushCache); south.setBounds(left, rect.height - pt.y, rect.width, pt.y); bottom -= pt.y; } if (east != null) { Point pt = getSize(east, flushCache); east.setBounds(rect.width - pt.x, top, pt.x, (bottom - top)); right -= pt.x; } if (west != null) { Point pt = getSize(west, flushCache); west.setBounds(left, top, pt.x, (bottom - top)); left += pt.x; } if (center != null) { center.setBounds(left, top, (right - left), (bottom - top)); } }
/** * Force the repainting of the control (the only way found to accomplish this, is to reset its * bounds, and set again its original ones) * * @param control the control to be repainted */ public static void forceRepaint(Control control) { // Locals Rectangle bounds = control.getBounds(); control.setBounds(0, 0, 0, 0); control.setBounds(bounds); }
// javadoc inherited. protected void layout(Composite composite, boolean flushCache) { Control[] children = composite.getChildren(); if (flushCache || sizes == null || sizes.length != children.length) { initialize(children); } int x = marginWidth; int y = marginHeight; // Get the maximum width of the composite's client area (used to allow // the control in the last column to fill the rest of the space). final int width = getWidth(composite, SWT.DEFAULT); for (int i = 0; i < children.length; i++) { final Control child = children[i]; if (child.getVisible()) { int labelVOffset = 0; boolean span = getColumnSpan(child) > 1; int col = getColumnIndex(child, span); if (child instanceof Label) { // Non-label control should be next in the sizes array. int index = i >= sizes.length ? i : i + 1; labelVOffset = (sizes[index].y - sizes[i].y) / 2; } // Determine if we need to move to the next row, handle spanning // and fill in space for the last column. if (col == (numberOfColumns - 1)) { int fillWidth = width - getOtherColumnsWidth(numberOfColumns - 1); fillWidth = fillWidth < 0 ? columnWidth[col] : fillWidth; child.setBounds(x, y + labelVOffset, fillWidth, sizes[i].y); // Bump up the row offset and reset the column offset. y += getControlHeight(child, sizes[i].y); x = marginWidth; } else { // If we span then this control takes up all the rest of the // columns horizontal real estate. int otherColumnsWidth = getOtherColumnsWidth(col - 1); int colWidth = span ? width - otherColumnsWidth : columnWidth[col]; child.setBounds(x, y + labelVOffset, colWidth, sizes[i].y); if (span) { y += getControlHeight(child, sizes[i].y); } else { x += colWidth; } } } } }
/** * Sets the component's bounds using the given component and cell bounds. * * @param c the component to set bounds * @param layout the FormLayout instance that computes the bounds * @param cellBounds the cell's bounds * @param minWidthMeasure measures the minimum width * @param minHeightMeasure measures the minimum height * @param prefWidthMeasure measures the preferred width * @param prefHeightMeasure measures the preferred height */ void setBounds( Control c, FormLayout layout, Rectangle cellBounds, FormLayout.Measure minWidthMeasure, FormLayout.Measure minHeightMeasure, FormLayout.Measure prefWidthMeasure, FormLayout.Measure prefHeightMeasure) { ColumnSpec colSpec = gridWidth == 1 ? layout.getColumnSpec(gridX) : null; RowSpec rowSpec = gridHeight == 1 ? layout.getRowSpec(gridY) : null; Alignment concreteHAlign = concreteAlignment(this.hAlign, colSpec); Alignment concreteVAlign = concreteAlignment(this.vAlign, rowSpec); Insets concreteInsets = this.insets != null ? this.insets : EMPTY_INSETS; int cellX = cellBounds.x + concreteInsets.getLeft(); int cellY = cellBounds.y + concreteInsets.getTop(); int cellW = cellBounds.width - concreteInsets.getLeft() - concreteInsets.getRight(); int cellH = cellBounds.height - concreteInsets.getTop() - concreteInsets.getBottom(); int compW = componentSize(c, colSpec, cellW, minWidthMeasure, prefWidthMeasure); int compH = componentSize(c, rowSpec, cellH, minHeightMeasure, prefHeightMeasure); int x = origin(concreteHAlign, cellX, cellW, compW); int y = origin(concreteVAlign, cellY, cellH, compH); int w = extent(concreteHAlign, cellW, compW); int h = extent(concreteVAlign, cellH, compH); c.setBounds(x, y, w, h); }
private void layoutControls() { Rectangle r = canvas.getBounds(); int hw = Math.max(0, (r.width - MARGIN_H) / 2 - MARGIN_H); nameLayout.setWidth(Math.max(hw, 1)); valueLayout.setWidth(Math.max(hw, 1)); if (editor != null) { Control ec = editor.getControl(); int eh = r.height - MARGIN_V - MARGIN_V; ec.setBounds(r.width - MARGIN_H - hw, (r.height - eh) / 2, hw, eh); } // if (border != null) { // border.dispose(); // border = null; // } // border = new Path(Display.getCurrent()); // float left = 0, top = 0, right = r.width, bottom = r.height; // border.moveTo(right - RADIUS, top); // border.cubicTo(right - RADIUS_BEND, top, right, top + RADIUS_BEND, // right, top + RADIUS); // border.lineTo(right, bottom - RADIUS); // border.cubicTo(right, bottom - RADIUS_BEND, right - RADIUS_BEND, // bottom, right - RADIUS, bottom); // border.lineTo(left + RADIUS, bottom); // border.cubicTo(left + RADIUS_BEND, bottom, left, bottom - RADIUS_BEND, // left, bottom - RADIUS); // border.lineTo(left, top + RADIUS); // border.cubicTo(left, top + RADIUS_BEND, left + RADIUS_BEND, top, left // + RADIUS, top); // border.close(); }
@Override protected void layout(Composite composite, boolean flushCache) { Control[] children = composite.getChildren(); if (sizes == null || flushCache || sizes.length != children.length) init(composite); int y = 0; int x = getMaximized() ? 0 : 1; // border width for (int i = 0; i < children.length; i++) { Control child = children[i]; if (child instanceof RibbonTabFolder) child.setBounds(new Rectangle(x, y, mShell.getBounds().width - 2, sizes[i].y)); else child.setBounds(new Rectangle(x, y, sizes[i].x - 2, sizes[i].y)); y += sizes[i].y; } }
@Override public void setBounds(Rectangle rect) { super.setBounds(rect); rect = rect.getCopy(); translateToAbsolute(rect); control.setBounds(rect.x, rect.y, rect.width, rect.height); System.out.println("Set Bounds " + rect); super.setBounds(rect); }
protected void layout(Composite composite, boolean flushCache) { CTabFolder folder = (CTabFolder) composite; // resize content if (folder.selectedIndex != -1) { Control control = folder.items[folder.selectedIndex].getControl(); if (control != null && !control.isDisposed()) { control.setBounds(folder.getClientArea()); } } }
/* * @see Layout#layout(Composite, boolean) */ protected void layout(Composite composite, boolean flushCache) { Rectangle clArea = composite.getClientArea(); Rectangle trim = getTextWidget().computeTrim(0, 0, 0, 0); int topTrim = -trim.y; int scrollbarHeight = trim.height - topTrim; // scrollbar is only under the client area int x = clArea.x; int width = clArea.width; if (fOverviewRuler != null && fIsOverviewRulerVisible) { int overviewRulerWidth = fOverviewRuler.getWidth(); fOverviewRuler .getControl() .setBounds( clArea.x + clArea.width - overviewRulerWidth - 1, clArea.y + scrollbarHeight, overviewRulerWidth, clArea.height - 3 * scrollbarHeight); fOverviewRuler .getHeaderControl() .setBounds( clArea.x + clArea.width - overviewRulerWidth - 1, clArea.y, overviewRulerWidth, scrollbarHeight); width -= overviewRulerWidth + fGap; } if (fVerticalRuler != null && fIsVerticalRulerVisible) { int verticalRulerWidth = fVerticalRuler.getWidth(); final Control verticalRulerControl = fVerticalRuler.getControl(); int oldWidth = verticalRulerControl.getBounds().width; verticalRulerControl.setBounds( clArea.x, clArea.y + topTrim, verticalRulerWidth, clArea.height - scrollbarHeight - topTrim); if (flushCache && getVisualAnnotationModel() != null && oldWidth == verticalRulerWidth) verticalRulerControl.redraw(); x += verticalRulerWidth + fGap; width -= verticalRulerWidth + fGap; } getTextWidget().setBounds(x, clArea.y, width, clArea.height); }
private void setInput(Control c) { if (klickedCell == null) { return; } XViewerColumn xCol = xv.getXViewerFactory() .getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId()); if (xCol instanceof ExtendedViewerColumn) { ExtendedViewerColumn extendedCol = (ExtendedViewerColumn) xCol; CellEditDescriptor ced = extendedCol.getCellEditDescriptorMap().get(klickedCell.getElement().getClass()); if (ced == null || ced.getControl() == null) { return; } converter.setInput(c, ced, klickedCell.getElement()); } c.setBounds(klickedCell.getBounds()); }
protected PresentationTestbed createPresentation( AbstractPresentationFactory factory, int type, int numParts) { TestPresentablePart selection = null; PresentationTestbed testBed = new PresentationTestbed(theShell, factory, type); for (int partCount = 0; partCount < numParts; partCount++) { TestPresentablePart part = new TestPresentablePart(theShell, img); part.setName("Some part"); part.setContentDescription("Description"); part.setTitle("Some title"); part.setDirty(partCount % 2 == 0); part.setTooltip("This is a tooltip"); testBed.add(part); selection = part; } testBed.setSelection(selection); Control ctrl = testBed.getControl(); ctrl.setBounds(theShell.getClientArea()); return testBed; }
public void layout(GC gc, int width, Locator loc, Hashtable resourceTable, boolean selected) { super.layout(gc, width, loc, resourceTable, selected); Control control = getControl(resourceTable); if (control != null) control.setBounds(getBounds()); }
// From Nebula EditController (with minor tweaks) protected ExecutionStatusKind editCell( ILayerCell cell, Composite parent, Object initialCanonicalValue, IConfigRegistry configRegistry) { ExecutionStatusKind result = ExecutionStatusKind.FAIL_ROLLBACK; try { Rectangle cellBounds = cell.getBounds(); ILayer layer = cell.getLayer(); int columnPosition = cell.getColumnPosition(); int rowPosition = cell.getRowPosition(); List<String> configLabels = cell.getConfigLabels().getLabels(); ICellEditor cellEditor = (ICellEditor) configRegistry.getConfigAttribute( EditConfigAttributes.CELL_EDITOR, DisplayMode.EDIT, configLabels); // Try to open an in-line editor before falling back to a dialog if (cellEditor.openInline(configRegistry, configLabels)) { MyInlineEditHandler editHandler = new MyInlineEditHandler(layer, columnPosition, rowPosition); Rectangle editorBounds = layer .getLayerPainter() .adjustCellBounds( columnPosition, rowPosition, new Rectangle(cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height)); cellEditor.activateCell( parent, initialCanonicalValue, EditModeEnum.INLINE, editHandler, cell, configRegistry); Control editorControl = cellEditor.getEditorControl(); if ((editorControl != null) && (!(editorControl.isDisposed()))) { editorControl.setBounds(editorBounds); cellEditor.addEditorControlListeners(); ActiveCellEditorRegistry.registerActiveCellEditor(cellEditor); } // Command succeeded but should not appear on the undo stack because we haven't completed an // edit (only activated the cell editor), // unless the cell editor is like the CheckBoxCellEditor that commits upon activation result = editHandler.isCommitted() ? ExecutionStatusKind.OK_COMPLETE : ExecutionStatusKind.OK_ROLLBACK; } else { // The dialog case List<ILayerCell> cells = new ArrayList<ILayerCell>(1); cells.add(cell); result = editCells(cells, parent, initialCanonicalValue, configRegistry); } } catch (OperationCanceledException e) { // OK. The user cancelled a dialog or some such result = ExecutionStatusKind.FAIL_ROLLBACK; } catch (Exception e) { Activator.log.error("Uncaught exception in table cell editor activation.", e); // $NON-NLS-1$ } return result; }