Point size = gc.textExtent( leftText + e.text + rightText ); gc.dispose(); size = text.computeSize( size.x, SWT.DEFAULT ); editor.horizontalAlignment = SWT.LEFT; Rectangle itemRect = item.getBounds(),
Point size = gc.textExtent( leftText + e.text + rightText ); gc.dispose(); size = text.computeSize( size.x, SWT.DEFAULT ); editor.horizontalAlignment = SWT.LEFT; Rectangle itemRect = item.getBounds(),
Point size = gc.textExtent( leftText + e.text + rightText ); gc.dispose(); size = text.computeSize( size.x, SWT.DEFAULT ); editor.horizontalAlignment = SWT.LEFT; Rectangle itemRect = item.getBounds(),
FontMetrics fm = gc.getFontMetrics(); int charWidth = fm.getAverageCharWidth(); int fieldWidth = text.computeSize( charWidth * 20, SWT.DEFAULT ).x; gc.dispose();
public void handleEvent( Event event ) { messageLabelHeight = messageLabel.computeSize( SWT.DEFAULT, SWT.DEFAULT ).y; setLayoutsForNormalMessage( verticalSpacing, horizontalSpacing ); determineTitleImageLargest(); layoutForNewMessage( true ); } } );
@Override protected Point computeSize(Composite composite, int hint, int hint2, boolean flushCache) { // height int height = m_resetButton.computeSize(SWT.DEFAULT, hint2).y + 2; for (Text t : m_filterFields.values()) { height = Math.max(height, t.computeSize(SWT.DEFAULT, hint2).y + 2); } return new Point(hint, height); }
public void handleEvent(Event e) { Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT); textSize.x += textSize.y; // Add extra space for new characters. Point parentSize = textEditorParent.getSize(); textEditor.setBounds(2, 1, Math.min(textSize.x, parentSize.x - 4), parentSize.y - 2); textEditorParent.redraw(); } });
@Override public Point computeSize(int wHint, int hHint, boolean changed) { // Text widget, at least on Windows, forces the preferred width // to the width of the text inside of it // Fix this by forcing to LayoutData's minWidth if ( hHint==0 && !isVisible()){ return( new Point( 0, 0 )); } Point pt = super.computeSize(wHint, hHint, changed); if (wHint == SWT.DEFAULT) { Object ld = getLayoutData(); if (ld instanceof GridData) { if (((GridData)ld).grabExcessHorizontalSpace) { pt.x = 10; } } } return pt; } };
@Override public Point computeSize(int wHint, int hHint, boolean changed) { // Text widget, at least on Windows, forces the preferred width // to the width of the text inside of it // Fix this by forcing to LayoutData's minWidth if ( hHint==0 && !isVisible()){ return( new Point( 0, 0 )); } Point pt = super.computeSize(wHint, hHint, changed); if (wHint == SWT.DEFAULT) { Object ld = getLayoutData(); if (ld instanceof GridData) { if (((GridData)ld).grabExcessHorizontalSpace) { pt.x = 10; } } } return pt; } };
public void handleEvent(Event e) { Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT); textSize.x += textSize.y; // Add extra space for new // characters. Point parentSize = textEditorParent.getSize(); textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4), parentSize.y - 2 * inset); textEditorParent.redraw(); } });
@Override public Point computeSize(int wHint, int hHint, boolean changed) { Point point = super.computeSize(wHint, hHint, changed); if (Utils.isGTK3) { Rectangle area = getParent().getClientArea(); //System.out.println("computedSize = " + point + "; parent.h=" + area.height); // Bug in SWT: When there's no border, computed size chops off a few // pixels in height (probably because GTK3 shows a border when focused) point.y += 2; // Bug in SWT: Seems Text widget on GTK3 doesn't obey parent's fixed height if (area.height > 0 && point.y > area.height) { point.y = area.height; } } return point; } };
public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; String[] items = list.getItems (); int textWidth = 0; GC gc = new GC (text); int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ for (int i = 0; i < items.length; i++) { textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); } gc.dispose(); Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); // Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point arrowSize = new Point(16, 16); Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); int borderWidth = getBorderWidth (); height = Math.max (textSize.y, arrowSize.y); width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x); if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; return new Point (width + 2*borderWidth, height + 2*borderWidth); } void createPopup(String[] items, int selectionIndex) {
@Override public void initializePanel(Composite parent) { final FillLayout rl = new FillLayout(); parent.setLayout(rl); final Text t = new Text(parent, SWT.SINGLE | SWT.ICON_CANCEL | SWT.CANCEL); t.setText(startString); final GC gc = new GC(t); final FontMetrics fm = gc.getFontMetrics(); final int width = CHARS * fm.getAverageCharWidth(); final int height = fm.getHeight(); gc.dispose(); t.setSize(t.computeSize(width, height)); t.addListener(SWT.DefaultSelection, this); t.addListener(SWT.Modify, this); vehicles.addAll(roadModel.getObjectsOfType(Vehicle.class)); }
public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; String[] items = list.getItems (); GC gc = new GC (text); int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ int textWidth = gc.stringExtent (text.getText ()).x; for (int i = 0; i < items.length; i++) { textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); } gc.dispose (); Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); int borderWidth = getBorderWidth (); height = Math.max (textSize.y, arrowSize.y); width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x); if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; return new Point (width + 2*borderWidth, height + 2*borderWidth); } /**
@Override public void initializePanel(Composite parent) { final FillLayout rl = new FillLayout(); parent.setLayout(rl); final Text t = new Text(parent, SWT.SINGLE | SWT.ICON_CANCEL | SWT.CANCEL); t.setText(startString); final GC gc = new GC(t); final FontMetrics fm = gc.getFontMetrics(); final int width = CHARS * fm.getAverageCharWidth(); final int height = fm.getHeight(); gc.dispose(); t.setSize(t.computeSize(width, height)); t.addListener(SWT.DefaultSelection, this); t.addListener(SWT.Modify, this); vehicles.addAll(roadModel.getObjectsOfType(Vehicle.class)); }
@Override public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; String[] items = list.getItems (); GC gc = new GC (text); int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ int textWidth = gc.stringExtent (text.getText ()).x; for (int i = 0; i < items.length; i++) { textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); } gc.dispose (); Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); int borderWidth = getBorderWidth (); height = Math.max (textSize.y, arrowSize.y); width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x); if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; return new Point (width + 2*borderWidth, height + 2*borderWidth); } /**
@Override public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; String[] items = list.getItems (); GC gc = new GC (text); int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ int textWidth = gc.stringExtent (text.getText ()).x; for (int i = 0; i < items.length; i++) { textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); } gc.dispose (); Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); int borderWidth = getBorderWidth (); height = Math.max (textSize.y, arrowSize.y); width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x); if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; return new Point (width + 2*borderWidth, height + 2*borderWidth); } /**
@Override public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; String[] items = list.getItems (); GC gc = new GC (text); int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ int textWidth = gc.stringExtent (text.getText ()).x; for (int i = 0; i < items.length; i++) { textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); } gc.dispose (); Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed); int borderWidth = getBorderWidth (); height = Math.max (textSize.y, arrowSize.y); width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x); if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; return new Point (width + 2*borderWidth, height + 2*borderWidth); } /**
@Override public void relocate(CellEditor celleditor) { // Obtain the location IFigure figure = OfficeFloorDirectEditPolicy.this.initialiser .getLocationFigure(); Rectangle rect = figure.getBounds().getCopy(); figure.translateToAbsolute(rect); // Obtain the preferred size Text text = (Text) celleditor.getControl(); Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); // Position the cell editor text box text.setBounds(rect.x, rect.y, pref.x, pref.y); } };
public void relocate(CellEditor celleditor) { Text text = (Text) celleditor.getControl(); Label label = namedEditPart.getNameLabelFigure(); if (text.getBounds().x <= 0) { super.relocate(celleditor); } else { org.eclipse.swt.graphics.Point sel = text.getSelection(); org.eclipse.swt.graphics.Point pref = text.computeSize(-1, -1); Rectangle rect = label.getTextBounds().getCopy(); label.translateToAbsolute(rect); text.setBounds(rect.x, rect.y-1, rect.width, pref.y+1); text.setSelection(0); text.setSelection(sel); } } }