int h = expressionEditor.getLineHeight( offset ); Point l = GUIResource.calculateControlPosition( expressionEditor );
private int getHeightOfAllLines(StyledText styledText) { int height= 0; int lineCount= styledText.getLineCount(); for (int i= 0; i < lineCount; i++) height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i)); return height; }
/** * Returns the number of the currently visible lines. * * @return the number of the currently visible lines */ private int computeNumberOfVisibleLines() { StyledText textWidget= fSourceViewer.getTextWidget(); int lineHeight= textWidget.getLineHeight(); int clientAreaHeight= textWidget.getClientArea().height; return clientAreaHeight / lineHeight; }
@Override public int getLineHeight() { if (fContentAssistSubjectControl != null) return fContentAssistSubjectControl.getLineHeight(); return fViewer.getTextWidget().getLineHeight(getCaretOffset()); }
public int getViewportLines() { StyledText te= getTextWidget(); Rectangle clArea= te.getClientArea(); if (!clArea.isEmpty()) return clArea.height / te.getLineHeight(); return 0; }
@Override public int getLineHeight() { if (fContentAssistSubjectControl != null) return fContentAssistSubjectControl.getLineHeight(); return fViewer.getTextWidget().getLineHeight(getCaretOffset()); }
@Override public void lineGetStyle(LineStyleEvent event) { StyleRange range = new StyleRange(); range.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); int maxNumLine = styledText.getLineCount(); int bulletLength = Integer.toString(maxNumLine).length(); // right padding int widthBullet = ((bulletLength + 1) * styledText.getLineHeight()) / 2; range.metrics = new GlyphMetrics(0, 0, widthBullet); event.bullet = new Bullet(ST.BULLET_TEXT, range); event.bullet.text = String.format("%" + bulletLength + "s", styledText.getLineAtOffset(event.lineOffset) + 1); }
@Override public Point computeSizeConstraints(int widthInChars, int heightInChars) { GC gc= new GC(fText); gc.setFont(fTextFont); int width= gc.getFontMetrics().getAverageCharWidth(); int height= fText.getLineHeight(); //https://bugs.eclipse.org/bugs/show_bug.cgi?id=377109 gc.dispose(); return new Point(widthInChars * width, heightInChars * height); } }
@Override public Point computeSizeConstraints(int widthInChars, int heightInChars) { GC gc= new GC(fText); gc.setFont(fTextFont); double width= gc.getFontMetrics().getAverageCharacterWidth(); int height= fText.getLineHeight(); gc.dispose(); return new Point((int) (widthInChars * width), heightInChars * height); } }
@Override public Point computeSizeConstraints(int widthInChars, int heightInChars) { GC gc= new GC(fText); gc.setFont(fTextFont); int width= gc.getFontMetrics().getAverageCharWidth(); int height= fText.getLineHeight(); //https://bugs.eclipse.org/bugs/show_bug.cgi?id=377109 gc.dispose(); return new Point(widthInChars * width, heightInChars * height); } }
@Override public Point computeSizeConstraints(int widthInChars, int heightInChars) { GC gc= new GC(fText); gc.setFont(fTextFont); int width= gc.getFontMetrics().getAverageCharWidth(); int height= fText.getLineHeight(); gc.dispose(); return new Point (widthInChars * width, heightInChars * height); } }
private Caret createInsertCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(getCaretWidthPreference(), styledText.getLineHeight()); caret.setFont(styledText.getFont()); return caret; }
@Override public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
@Override public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
@Override public Rectangle getInsertionBounds(Control control) { StyledText text = (StyledText) control; Point caretOrigin = text.getCaret().getLocation(); return new Rectangle(caretOrigin.x + text.getClientArea().x, caretOrigin.y + text.getClientArea().y + 3, 1, text.getLineHeight()); }
private Caret createInsertCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(getCaretWidthPreference(), styledText.getLineHeight()); caret.setFont(styledText.getFont()); return caret; }
@Override public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
private Caret createOverwriteCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); GC gc= new GC(styledText); // XXX this overwrite box is not proportional-font aware // take 'a' as a medium sized character Point charSize= gc.stringExtent("a"); //$NON-NLS-1$ // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(charSize.x, styledText.getLineHeight()); caret.setFont(styledText.getFont()); gc.dispose(); return caret; }
private Caret createOverwriteCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); GC gc= new GC(styledText); // XXX: this overwrite box is not proportional-font aware // take 'a' as a medium sized character Point charSize= gc.stringExtent("a"); //$NON-NLS-1$ // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(charSize.x, styledText.getLineHeight()); caret.setFont(styledText.getFont()); gc.dispose(); return caret; }
private Caret createOverwriteCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); GC gc= new GC(styledText); // XXX: this overwrite box is not proportional-font aware // take 'a' as a medium sized character Point charSize= gc.stringExtent("a"); //$NON-NLS-1$ // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(charSize.x, styledText.getLineHeight()); caret.setFont(styledText.getFont()); gc.dispose(); return caret; }