Java Code Examples for org.eclipse.swt.SWT#DEFAULT
The following examples show how to use
org.eclipse.swt.SWT#DEFAULT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Oscilloscope.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget(); int width; int height; if (wHint != SWT.DEFAULT) { width = wHint; } else { width = DEFAULT_WIDTH; } if (hHint != SWT.DEFAULT) { height = hHint; } else { height = DEFAULT_HEIGHT; } return new Point(width + 2, height + 2); }
Example 2
Source File: ExpressionValueCellEditor.java From birt with Eclipse Public License 1.0 | 6 votes |
public Point computeSize( Composite editor, int wHint, int hHint, boolean force ) { if ( wHint != SWT.DEFAULT && hHint != SWT.DEFAULT ) return new Point( wHint, hHint ); Point contentsSize = expressionText.computeSize( SWT.DEFAULT, SWT.DEFAULT, force ); Point buttonSize = btnPopup.computeSize( SWT.DEFAULT, SWT.DEFAULT, force ); // Just return the button width to ensure the button is not clipped // if the label is long. // The label will just use whatever extra width there is Point result = new Point( buttonSize.x, Math.max( contentsSize.y, buttonSize.y ) ); return result; }
Example 3
Source File: ExpressionValueCellEditor.java From birt with Eclipse Public License 1.0 | 6 votes |
public Point computeSize( Composite editor, int wHint, int hHint, boolean force ) { if ( wHint != SWT.DEFAULT && hHint != SWT.DEFAULT ) return new Point( wHint, hHint ); Point contentsSize = expressionText.computeSize( SWT.DEFAULT, SWT.DEFAULT, force ); Point buttonSize = btnPopup.computeSize( SWT.DEFAULT, SWT.DEFAULT, force ); // Just return the button width to ensure the button is not clipped // if the label is long. // The label will just use whatever extra width there is Point result = new Point( buttonSize.x, Math.max( contentsSize.y, buttonSize.y ) ); return result; }
Example 4
Source File: Style.java From RepDev with GNU General Public License v3.0 | 6 votes |
public int getStyle(String item){ int swtStyle = SWT.DEFAULT; String styleText = ""; for( int i=0; i<style.getChildNodes().getLength(); i++ ) { Node cur = style.getChildNodes().item(i); if( cur.getNodeName().equals(item) ) { for( int j=0; j<cur.getAttributes().getLength(); j++ ) { if( cur.getAttributes().item(j).getNodeName().equals("style") ) { styleText = cur.getAttributes().item(j).getNodeValue(); } } } } if( styleText.equalsIgnoreCase("bold") ) swtStyle = SWT.BOLD; if( styleText.equalsIgnoreCase("italic") ) swtStyle = SWT.ITALIC; return swtStyle; }
Example 5
Source File: TimeGraphEntry.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void updateEntryBounds(ITimeEvent event) { if (event instanceof NullTimeEvent) { /* A NullTimeEvent should not affect the entry bounds */ return; } long start = event.getTime(); long newStart = getStartTime() == SWT.DEFAULT ? start : Long.min(start, getStartTime()); long end = start + event.getDuration(); long newEnd = getEndTime() == SWT.DEFAULT ? end : Long.max(end, getEndTime()); /* * Model is immutable, this is the only way to do this, consider not updating * bounds in the future? */ fStartTime = newStart; fEndTime = newEnd; }
Example 6
Source File: UIHelper.java From tlaplus with MIT License | 6 votes |
/** * This appropriately scales the non-zero spatial values contained in the * <code>TableWrapData</code> instance to observe display scaling. * * @param tableWrapData the <code>TableWrapData</code> which should be altered */ public static void appropriatelyScaleTableWrapData(final TableWrapData tableWrapData) { // Windows and Mac appear to do the correct thing if (Platform.getOS().equals(Platform.OS_LINUX)) { final double scale = getDisplayScaleFactor(); tableWrapData.indent = (int)((double)tableWrapData.indent * scale); if (tableWrapData.maxWidth != SWT.DEFAULT) { tableWrapData.maxWidth = (int)((double)tableWrapData.maxWidth * scale); } if (tableWrapData.maxHeight != SWT.DEFAULT) { tableWrapData.maxHeight = (int)((double)tableWrapData.maxHeight * scale); } if (tableWrapData.heightHint != SWT.DEFAULT) { tableWrapData.heightHint = (int)((double)tableWrapData.heightHint * scale); } } }
Example 7
Source File: TimeGraphEntryTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Test method addZoomedEvent with duplicates. */ @Test public void testaddZoomedEventDuplicate() { TimeGraphEntry entry = new TimeGraphEntry(NAME, SWT.DEFAULT, SWT.DEFAULT); ITimeEvent event1 = new TimeEvent(entry, 0, 10, 1); ITimeEvent event2 = new TimeEvent(entry, 10, 10, 2); ITimeEvent event3 = new TimeEvent(entry, 20, 10, 3); entry.addZoomedEvent(event1); entry.addZoomedEvent(event2); // duplicate events are not added twice entry.addZoomedEvent(event1); entry.addZoomedEvent(event2); entry.addZoomedEvent(event3); assertEquals(0, entry.getStartTime()); assertEquals(30, entry.getEndTime()); assertIteratorsEqual(Iterators.forArray(event1, event2, event3), entry.getTimeEventsIterator()); }
Example 8
Source File: TestProgressBar.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public Point computeSize(int wHint, int hHint, boolean changed) { if (hHint == SWT.DEFAULT) { return super.computeSize(wHint, preferredHeight, changed); } return super.computeSize(wHint, hHint, changed); }
Example 9
Source File: LEDSeparator.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean) */ @Override public Point computeSize(int wHint, int hHint, boolean changed) { int x = (wHint == SWT.DEFAULT) ? BaseLED.THIN_DEFAULT_WIDTH : wHint; int y = (hHint == SWT.DEFAULT) ? BaseLED.DEFAULT_HEIGHT : hHint; return new Point(x, y); }
Example 10
Source File: LineCanvas.java From birt with Eclipse Public License 1.0 | 5 votes |
public Point computeSize( int wHint, int hHint, boolean changed ) { Point size = new Point( 100, 20 ); if ( wHint != SWT.DEFAULT ) size.x = wHint; if ( hHint != SWT.DEFAULT ) size.y = hHint; Rectangle trim = computeTrim( 0, 0, size.x, size.y ); return new Point( trim.width, trim.height ); }
Example 11
Source File: TimeGraphEntryTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Test method addChild to same parent. */ @Test public void testAddChildSameParent() { TimeGraphEntry parent = new TimeGraphEntry("parent", SWT.DEFAULT, SWT.DEFAULT); TimeGraphEntry child = new TimeGraphEntry("child", SWT.DEFAULT, SWT.DEFAULT); parent.addChild(child); parent.addChild(child); assertEquals(null, parent.getParent()); assertEquals(Arrays.asList(child), parent.getChildren()); assertEquals(parent, child.getParent()); assertEquals(Arrays.asList(), child.getChildren()); }
Example 12
Source File: TimeGraphEntryTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Test method removeChild. */ @Test public void testRemoveChild() { TimeGraphEntry parent = new TimeGraphEntry("parent", SWT.DEFAULT, SWT.DEFAULT); TimeGraphEntry child = new TimeGraphEntry("child", SWT.DEFAULT, SWT.DEFAULT); parent.addChild(child); parent.removeChild(child); assertEquals(null, parent.getParent()); assertEquals(Arrays.asList(), parent.getChildren()); assertEquals(null, child.getParent()); assertEquals(Arrays.asList(), child.getChildren()); }
Example 13
Source File: AlignPrint.java From nebula with Eclipse Public License 2.0 | 5 votes |
private static int checkHAlign(int hAlign) { if (hAlign == SWT.LEFT || hAlign == SWT.CENTER || hAlign == SWT.RIGHT) return hAlign; if (hAlign == SWT.DEFAULT) return DEFAULT_HORIZONTAL_ALIGN; PaperClips.error(SWT.ERROR_INVALID_ARGUMENT, "hAlign must be one of SWT.LEFT, SWT.CENTER or SWT.RIGHT"); //$NON-NLS-1$ return hAlign; }
Example 14
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private IAction createShowColumnAction(final TableColumn column) { final IAction columnMenuAction = new Action(column.getText(), IAction.AS_CHECK_BOX) { @Override public void run() { boolean isChecked = isChecked(); int index = (int) column.getData(Key.INDEX); if (isChecked) { int width = (int) column.getData(Key.WIDTH); column.setResizable(true); if (width <= 0) { fPacking = true; column.pack(); fPacking = false; column.setData(Key.WIDTH, SWT.DEFAULT); fColumnSize[index] = SWT.DEFAULT; } else { column.setWidth(width); } } else { column.setResizable(false); column.setWidth(0); } fColumnResizable[index] = isChecked; fTable.refresh(); } }; columnMenuAction.setChecked(column.getResizable()); return columnMenuAction; }
Example 15
Source File: WorkspaceWizardPage.java From eclipse with Apache License 2.0 | 5 votes |
private Button createButton(String text, Consumer<SelectionEvent> handler) { Button result = new Button(container, SWT.DEFAULT); result.setText(text); result.addSelectionListener(createSelectionListener(handler)); result.setEnabled(false); return result; }
Example 16
Source File: RoundedCheckbox.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean) */ @Override public Point computeSize(int wHint, int hHint, boolean changed) { wHint = wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint) : wHint; hHint = hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint) : hHint; return DPIUtil.autoScaleDown(computeSizePixels(wHint, hHint, changed)); }
Example 17
Source File: LED.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean) */ @Override public Point computeSize(int wHint, int hHint, boolean changed) { int x = (wHint == SWT.DEFAULT) ? DEFAULT_WIDTH : wHint; if (hasDot) { x += (int) (1.5f * DOT_DIAMETER); } int y = (hHint == SWT.DEFAULT) ? DEFAULT_HEIGHT : hHint; return new Point(x, y); }
Example 18
Source File: IllustratedComposite.java From saros with GNU General Public License v2.0 | 4 votes |
@Override public Rectangle getClientArea() { Rectangle clientArea = super.getClientArea(); int extraLeftMargin = getExtraLeftMargin(); /* * Check whether preferred client size fits into the available size; if * not re-compute client size with available size. */ Point newClientSize = this.computeSize(SWT.DEFAULT, SWT.DEFAULT); int wHint = SWT.DEFAULT, hHint = SWT.DEFAULT; if (newClientSize.x > clientArea.width) { /* * Because newClientSize contains the trim, we have to subtract the * trim for wHint. */ wHint = Math.max(clientArea.width - extraLeftMargin, getMinWidth()); } if (newClientSize.y > clientArea.height) { /* * Because newClientSize contains the trim, we have to subtract the * trim for hHint. */ hHint = Math.max(clientArea.height, getMinHeight()); } newClientSize = this.computeSizeTrimless(wHint, hHint); /* * Center the unit of image and child composites. */ clientArea.x += extraLeftMargin; clientArea.y += Math.max((clientArea.height - newClientSize.y) / 2, 0); clientArea.width = newClientSize.x; clientArea.height = newClientSize.y; this.cachedClientArea = clientArea; return clientArea; }
Example 19
Source File: TableCombo.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget(); int overallWidth = 0; int overallHeight = 0; int borderWidth = getBorderWidth(); // use user defined values if they are specified. if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) { overallWidth = wHint; overallHeight = hHint; } else { TableItem[] tableItems = table.getItems(); GC gc = new GC(text); int spacer = gc.stringExtent(" ").x; //$NON-NLS-1$ int maxTextWidth = gc.stringExtent(text.getText()).x; int colIndex = getDisplayColumnIndex(); int maxImageHeight = 0; int currTextWidth = 0; // calculate the maximum text width and image height. for (int i = 0; i < tableItems.length; i++) { currTextWidth = gc.stringExtent(tableItems[i].getText(colIndex)).x; // take image into account if there is one for the tableitem. if (tableItems[i].getImage() != null) { currTextWidth += tableItems[i].getImage().getBounds().width; maxImageHeight = Math.max(tableItems[i].getImage().getBounds().height, maxImageHeight); } maxTextWidth = Math.max(currTextWidth, maxTextWidth); } gc.dispose(); Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); Point tableSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); overallHeight = Math.max(textSize.y, arrowSize.y); overallHeight = Math.max(maxImageHeight, overallHeight); overallWidth = Math.max(maxTextWidth + 2 * spacer + arrowSize.x + 2 * borderWidth, tableSize.x); // use user specified if they were entered. if (wHint != SWT.DEFAULT) overallWidth = wHint; if (hHint != SWT.DEFAULT) overallHeight = hHint; } return new Point(overallWidth + 2 * borderWidth, overallHeight + 2 * borderWidth); }