public int getViewportHeight() { StyledText te= getTextWidget(); Rectangle clArea= te.getClientArea(); if (!clArea.isEmpty()) return clArea.height; return 0; }
/** * Returns the number of lines that can fully fit into the viewport. This is computed by * dividing the widget's client area height by the widget's line height. The result is only * accurate if the widget does not use variable line heights - for that reason, clients should * not use this method any longer and use the client area height of the text widget to find out * how much content fits into it. * * @return the view port height in lines * @deprecated as of 3.2 */ @Deprecated protected int getVisibleLinesInViewport() { if (fTextWidget != null) { Rectangle clArea= fTextWidget.getClientArea(); if (!clArea.isEmpty()) return clArea.height / fTextWidget.getLineHeight(); } return -1; }
/** * Returns the number of lines that can fully fit into the viewport. This is computed by * dividing the widget's client area height by the widget's line height. The result is only * accurate if the widget does not use variable line heights - for that reason, clients should * not use this method any longer and use the client area height of the text widget to find out * how much content fits into it. * * @return the view port height in lines * @deprecated as of 3.2 */ @Deprecated protected int getVisibleLinesInViewport() { if (fTextWidget != null) { Rectangle clArea= fTextWidget.getClientArea(); if (!clArea.isEmpty()) return clArea.height / fTextWidget.getLineHeight(); } return -1; }
/** * Returns <code>true</code> if any text in the widget is selected, * and <code>false</code> otherwise. * * @return the text selection state * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.103 */ public boolean isTextSelected() { checkWidget(); if (blockSelection && blockXLocation != -1) { Rectangle rect = getBlockSelectionPosition(); return !rect.isEmpty(); } return selection.y != selection.x; } /**
/** * Returns <code>true</code> if any text in the widget is selected, * and <code>false</code> otherwise. * * @return the text selection state * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.103 */ public boolean isTextSelected() { checkWidget(); if (blockSelection && blockXLocation != -1) { Rectangle rect = getBlockSelectionPosition(); return !rect.isEmpty(); } return selection.y != selection.x; } /**
/** * Returns <code>true</code> if any text in the widget is selected, * and <code>false</code> otherwise. * * @return the text selection state * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.103 */ public boolean isTextSelected() { checkWidget(); if (blockSelection && blockXLocation != -1) { Rectangle rect = getBlockSelectionPosition(); return !rect.isEmpty(); } return selection.y != selection.x; } /**
/** * Returns <code>true</code> if any text in the widget is selected, * and <code>false</code> otherwise. * * @return the text selection state * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.103 */ public boolean isTextSelected() { checkWidget(); if (blockSelection && blockXLocation != -1) { Rectangle rect = getBlockSelectionPosition(); return !rect.isEmpty(); } return selection.y != selection.x; } /**
public int getViewportLines() { StyledText te= getTextWidget(); Rectangle clArea= te.getClientArea(); if (!clArea.isEmpty()) return clArea.height / te.getLineHeight(); return 0; }
private static void reveal(MergeSourceViewer v, Position p) { if (v != null && p != null) { StyledText st= v.getTextWidget(); if (st != null) { Rectangle r= st.getClientArea(); if (!r.isEmpty()) // workaround for #7320: Next diff scrolls when going into current diff v.revealRange(p.offset, p.length); } } }
public int getViewportHeight() { StyledText te= getSourceViewer().getTextWidget(); Rectangle clArea= te.getClientArea(); if (!clArea.isEmpty()) return clArea.height; return 0; }
/** * 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 */ @Deprecated 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; }
/** * 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 */ @Deprecated 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; }
public int getViewportLines() { StyledText te= getSourceViewer().getTextWidget(); Rectangle clArea= te.getClientArea(); if (!clArea.isEmpty()) return clArea.height / te.getLineHeight(); return 0; }
private static void reveal(MergeSourceViewer v, Position p) { if (v != null && p != null) { StyledText st= v.getSourceViewer().getTextWidget(); if (st != null) { Rectangle r= st.getClientArea(); if (!r.isEmpty()) // workaround for #7320: Next diff scrolls when going into current diff v.getSourceViewer().revealRange(p.offset, p.length); } } }
public void invokeSWTPaintListeners(GC gc) { if (getBounds().isEmpty()) { return; } if (tableColumn != null) { Object[] swtPaintListeners = tableColumn.getCellOtherListeners("SWTPaint"); if (swtPaintListeners != null) { for (int i = 0; i < swtPaintListeners.length; i++) { try { TableCellSWTPaintListener l = (TableCellSWTPaintListener) swtPaintListeners[i]; l.cellPaint(gc, this); } catch (Throwable e) { Debug.printStackTrace(e); } } } } if (cellSWTPaintListeners == null) { return; } for (int i = 0; i < cellSWTPaintListeners.size(); i++) { try { TableCellSWTPaintListener l = (TableCellSWTPaintListener) (cellSWTPaintListeners.get(i)); l.cellPaint(gc, this); } catch (Throwable e) { Debug.printStackTrace(e); } } }
@Override protected void computeInformation() { IRegion region= fHover.getHoverRegion(fTextViewer, -1); if (region == null) { setInformation(null, null); return; } Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); if (area == null || area.isEmpty()) { setInformation(null, null); return; } Object information= fHover.getHoverInfo2(fTextViewer, region); setCustomInformationControlCreator(fHover.getHoverControlCreator()); setInformation(information, area); }
@Override protected void computeInformation() { IRegion region= fHover.getHoverRegion(fTextViewer, -1); if (region == null) { setInformation(null, null); return; } Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); if (area == null || area.isEmpty()) { setInformation(null, null); return; } Object information= fHover.getHoverInfo2(fTextViewer, region); setCustomInformationControlCreator(fHover.getHoverControlCreator()); setInformation(information, area); }
@Override public Image getBackgroundImage() { if (bounds == null || bounds.isEmpty()) { return null; } Image image = new Image(Display.getDefault(), bounds.width - (marginWidth * 2), bounds.height - (marginHeight * 2)); GC gc = new GC(image); gc.setForeground(getBackgroundSWT()); gc.setBackground(getBackgroundSWT()); gc.fillRectangle(0, 0, bounds.width, bounds.height); gc.dispose(); return image; }
/** * @param image * @param bounds * @param text */ public static void obfuscateArea(Image image, Rectangle bounds, String text) { if (bounds.isEmpty()) return; if (text == null || text.length() == 0) { obfuscateArea(image, bounds); return; } GC gc = new GC(image); try { Device device = image.getDevice(); gc.setBackground(Colors.getSystemColor(device, SWT.COLOR_WHITE)); gc.setForeground(Colors.getSystemColor(device, SWT.COLOR_RED)); gc.fillRectangle(bounds); gc.drawRectangle(bounds); Utils.setClipping(gc, bounds); gc.drawText(text, bounds.x + 2, bounds.y + 1); } finally { gc.dispose(); } }
result[0] = 0; Rectangle rect = browser.getClientArea (); if (rect.isEmpty ()) { rect.width = 1; rect.height = 1;