Java Code Examples for org.eclipse.swt.graphics.Rectangle#isEmpty()
The following examples show how to use
org.eclipse.swt.graphics.Rectangle#isEmpty() .
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: CDateTime.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void layout(VPanel panel, boolean flushCache) { Rectangle cRect = panel.getClientArea(); if (cRect.isEmpty()) { return; } Point tSize = text.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT); tSize.y += textMarginHeight; spinner.setBounds(cRect.x, cRect.y, cRect.width, tSize.y); Rectangle sRect = spinner.getControl().computeTrim(0, 0, 0, 0); int sWidth = sRect.x + sRect.width - 2 * spinner.getControl().getBorderWidth() + 1; if (gtk && sWidth == 0) { sWidth = 67; } tSize.x = cRect.width - sWidth; text.setBounds(cRect.x, cRect.y + getBorderWidth(), tSize.x, tSize.y); }
Example 2
Source File: TimeGraphViewer.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Resize the controls */ public void resizeControls() { Rectangle r = fTimeAlignedComposite.getClientArea(); if (r.isEmpty()) { return; } if (fWeights != null) { setWeights(fWeights); fWeights = null; } int width = r.width; if (fNameWidth > width - fMinNameWidth) { fNameWidth = width - fMinNameWidth; } if (fNameWidth < fMinNameWidth) { fNameWidth = fMinNameWidth; } GridData gd = (GridData) fTree.getLayoutData(); gd.widthHint = fNameWidth; if (fTree.getColumnCount() == 1) { fTree.getColumn(0).setWidth(fNameWidth); } adjustHorizontalScrollBar(); adjustVerticalScrollBar(); }
Example 3
Source File: TimeGraphBaseControl.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override public void paintControl(PaintEvent e) { if (e.widget != this) { return; } // we will use advanced graphics, set now for consistent output e.gc.setAdvanced(true); fFontHeight = e.gc.getFontMetrics().getHeight(); Rectangle bound = getClientArea(); if (!bound.isEmpty()) { Color colBackup = e.gc.getBackground(); paint(bound, e); e.gc.setBackground(colBackup); } }
Example 4
Source File: CTreeLayout.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected void layout(Composite composite, boolean flushCache) { Rectangle area = composite.getClientArea(); if(area.isEmpty()) return; if(flushCache) computeSize(composite, -1, -1, flushCache); ctree.getHeader().setBounds( area.x, area.y, area.width, headerSize.y ); Point origin = ctree.getScrollPosition(); int height = area.height-headerSize.y; ctree.body.setBounds( area.x-origin.x, area.y+headerSize.y-origin.y, (gtk ? Math.max(area.width, headerSize.x) : area.width), (gtk ? Math.max(height, contentHeight) : height) ); layoutHeader(); layoutContent(); updateScrollBars(); }
Example 5
Source File: CTreeLayout.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Recalculate the correct state of the scrollbars and set their visibility accordingly. */ private void updateScrollBars() { Rectangle area = ctree.getClientArea(); if(area.isEmpty()) return; if(ctree.hBar != null) { if(area.width < size.x) { ctree.hBar.setMaximum(size.x); ctree.hBar.setThumb(area.width); if(!ctree.hBar.getVisible()) { ctree.hBar.setVisible(true); } } else { ctree.hBar.setMaximum(1); if(ctree.hBar.getVisible()) { ctree.hBar.setVisible(false); } } } if(ctree.vBar != null) { if(area.height < size.y) { ctree.vBar.setMaximum(size.y); ctree.vBar.setThumb(area.height); if(!ctree.vBar.getVisible()) { ctree.vBar.setVisible(true); } } else { ctree.vBar.setMaximum(1); if(ctree.vBar.getVisible()) { ctree.vBar.setVisible(false); } } } }
Example 6
Source File: CTree.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected void paintItems(GC gc, Rectangle ebounds) { if(isEmpty()) { if (emptyMessage.length() > 0) { Point bSize = getSize(); Point tSize = gc.textExtent(emptyMessage); gc.setForeground(colors.getItemForegroundNormal()); gc.drawText(emptyMessage, (bSize.x - tSize.x) / 2 - ebounds.x, 4 - ebounds.y); } } else { Image image = new Image(gc.getDevice(), ebounds); GC gc2 = new GC(image); for (Iterator iter = paintedItems.iterator(); iter.hasNext();) { CTreeItem item = (CTreeItem) iter.next(); for(int i = 0; i < item.cells.length; i++) { CTreeCell cell = item.cells[i]; cell.paint(gc, ebounds); Rectangle cb = cell.getClientArea(); gc2.setBackground(getDisplay().getSystemColor(SWT.COLOR_CYAN)); gc2.fillRectangle(ebounds); if(!cb.isEmpty() && cell.paintClientArea(gc2, new Rectangle(0,0,cb.width,cb.height))) { gc.drawImage(image, 0,0,Math.min(ebounds.width, cb.width),Math.min(ebounds.height, cb.height), cb.x-ebounds.x,cb.y-ebounds.y,cb.width,cb.height ); } } } gc2.dispose(); image.dispose(); } }
Example 7
Source File: BookmarkRulerColumn.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private int getVisibleLinesInViewport() { if (fCachedTextWidget != null) { Rectangle clArea= fCachedTextWidget.getClientArea(); if (!clArea.isEmpty()) { int firstPixel= 0; // what about margins? don't take trims as they include scrollbars: int lastPixel= clArea.height - 1; int first= JFaceTextUtil.getLineIndex(fCachedTextWidget, firstPixel); int last= JFaceTextUtil.getLineIndex(fCachedTextWidget, lastPixel); return last - first; } } return -1; }
Example 8
Source File: CommonLineNumberRulerColumn.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Returns the number of lines in the view port. * * @param textWidget the styled text widget * @return the number of lines visible in the view port <code>-1</code> if there's no client * area * @deprecated this method should not be used - it relies on the widget using a uniform line * height */ static int getVisibleLinesInViewport(StyledText textWidget) { if (textWidget != null) { Rectangle clArea= textWidget.getClientArea(); if (!clArea.isEmpty()) { int firstPixel= 0; int lastPixel= clArea.height - 1; // XXX: what about margins? don't take trims as they include scrollbars int first= JFaceTextUtil.getLineIndex(textWidget, firstPixel); int last= JFaceTextUtil.getLineIndex(textWidget, lastPixel); return last - first; } } return -1; }
Example 9
Source File: TimeGraphMarkerAxis.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Handle a mouseDown event. * * @param e * the mouse event * @param bounds * the bounds of the marker axis in the mouse event's coordinates * @param nameSpace * the width of the marker name area */ public void mouseDown(MouseEvent e, Rectangle bounds, int nameSpace) { if (bounds.isEmpty()) { return; } if (fCollapsed || (e.x < bounds.x + Math.min(nameSpace, EXPANDED.getBounds().width))) { fCollapsed = !fCollapsed; getParent().layout(); redraw(); return; } if (e.x < bounds.x + nameSpace) { String category = getHiddenCategoryForEvent(e, bounds); if (category != null) { for (IMarkerAxisListener listener : fListeners) { listener.setMarkerCategoryVisible(category, false); } } return; } IMarkerEvent marker = getMarkerForEvent(e); if (marker != null) { if ((e.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) { /* Extend current selection */ long selectionBegin = fTimeProvider.getSelectionBegin(); long selectionEnd = fTimeProvider.getSelectionEnd(); long markerBegin = marker.getTime(); long markerEnd = marker.getTime() + marker.getDuration(); /* If marker end is outside selection, extend closest boundary */ if (((markerEnd - selectionBegin) > 0) == ((markerEnd - selectionEnd) > 0)) { if (Math.abs(markerEnd - selectionBegin) < Math.abs(markerEnd - selectionEnd)) { selectionBegin = markerEnd; } else { selectionEnd = markerEnd; } } /* If marker begin is outside selection, extend closest boundary */ if (((markerBegin - selectionBegin) > 0) == ((markerBegin - selectionEnd) > 0)) { if (Math.abs(markerBegin - selectionBegin) < Math.abs(markerBegin - selectionEnd)) { selectionBegin = markerBegin; } else { selectionEnd = markerBegin; } } fTimeProvider.setSelectionRangeNotify(selectionBegin, selectionEnd, false); } else { /* Replace current selection */ fTimeProvider.setSelectionRangeNotify(marker.getTime(), marker.getTime() + marker.getDuration(), false); } } }