@Override void setFontDescription (long /*int*/ font) { super.setFontDescription (font); layout.setFont (Font.gtk_new (display, font)); }
@Override void setFontDescription (int /*long*/ font) { super.setFontDescription (font); layout.setFont (Font.gtk_new (display, font)); }
@Override void setFontDescription (int /*long*/ font) { super.setFontDescription (font); layout.setFont (Font.gtk_new (display, font)); }
@Override void createWidget (int index) { super.createWidget (index); layout.setFont (getFont ()); text = ""; initAccessible (); }
@Override LRESULT WM_SETFONT (int /*long*/ wParam, int /*long*/ lParam) { layout.setFont (Font.win32_new (display, wParam)); if (lParam != 0) OS.InvalidateRect (handle, null, true); return super.WM_SETFONT (font = wParam, lParam); }
@Override void createWidget (int index) { super.createWidget (index); layout.setFont (getFont ()); text = ""; initAccessible (); }
@Override void createWidget (int index) { super.createWidget (index); layout.setFont (getFont ()); text = ""; initAccessible (); }
private void processColoredLabel(ColoredString richLabel, GC gc, Rectangle textBounds, boolean isSelected, Font font) { String text= richLabel.getString(); fTextLayout.setText(text); fTextLayout.setFont(font); if (!isSelected) { // apply the styled ranges only when element is not selected Display display= (Display) gc.getDevice(); Iterator ranges= richLabel.getRanges(); while (ranges.hasNext()) { ColoredString.StyleRange curr= (ColoredString.StyleRange) ranges.next(); ColoredString.Style style= curr.style; if (style != null) { Color foreground= getColor(style.getForegroundColorName(), display); TextStyle textStyle= new TextStyle(null, foreground, null); fTextLayout.setStyle(textStyle, curr.offset, curr.offset + curr.length - 1); } } } Rectangle bounds= fTextLayout.getBounds(); int x= textBounds.x; int y = textBounds.y + Math.max(0, (textBounds.height - bounds.height) / 2); fTextLayout.draw(gc, x, y); fTextLayout.setText(""); // clear all ranges //$NON-NLS-1$ }
public void measure(Event event, TextLayout textLayout, ResourceManager resourceManager, TextStyle boldStyle) { Table table = ((TableItem) event.item).getParent(); textLayout.setFont(table.getFont()); event.width = 0; switch (event.index) {
private int updateTextLayout(TableItem item, int index, boolean isSelected) { fSharedLayout.setFont(item.getFont(index)); // XXX: needed to clear the style info, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=226090 fSharedLayout.setText(""); //$NON-NLS-1$ fSharedLayout.setText(item.getText(index)); int originalTextWidth= fSharedLayout.getBounds().width; // text width without any styles StyleRange[] ranges= getStyledRanges(item, index); if (ranges != null) { for (int i= 0; i < ranges.length; i++) { StyleRange curr= ranges[i]; if (isSelected) { curr= (StyleRange) curr.clone(); curr.foreground= null; curr.background= null; } fSharedLayout.setStyle(curr, curr.start, curr.start + curr.length - 1); } } return fSharedLayout.getBounds().width - originalTextWidth; }
private int updateTextLayout(TableItem item, int index, boolean isSelected) { fSharedLayout.setFont(item.getFont(index)); // XXX: needed to clear the style info, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=226090 fSharedLayout.setText(""); //$NON-NLS-1$ fSharedLayout.setText(item.getText(index)); int originalTextWidth= fSharedLayout.getBounds().width; // text width without any styles StyleRange[] ranges= getStyledRanges(item, index); if (ranges != null) { for (StyleRange range : ranges) { StyleRange curr= range; if (isSelected) { curr= (StyleRange) curr.clone(); curr.foreground= null; curr.background= null; } fSharedLayout.setStyle(curr, curr.start, curr.start + curr.length - 1); } } return fSharedLayout.getBounds().width - originalTextWidth; }
void setFont(Font font, int tabs) { TextLayout layout = new TextLayout(device); layout.setFont(regularFont); if (font != null) { if (boldFont != null) boldFont.dispose(); regularFont = font; layout.setText(" "); layout.setFont(font); layout.setStyle(new TextStyle(getFont(SWT.NORMAL), null, null), 0, 0); layout.setStyle(new TextStyle(getFont(SWT.BOLD), null, null), 1, 1); layout.setFont(regularFont); StringBuffer tabBuffer = new StringBuffer(tabs); for (int i = 0; i < tabs; i++) {
void setFont(Font font, int tabs) { TextLayout layout = new TextLayout(device); layout.setFont(regularFont); if (font != null) { if (boldFont != null) boldFont.dispose(); regularFont = font; layout.setText(" "); layout.setFont(font); layout.setStyle(new TextStyle(getFont(SWT.NORMAL), null, null), 0, 0); layout.setStyle(new TextStyle(getFont(SWT.BOLD), null, null), 1, 1); layout.setFont(regularFont); StringBuffer tabBuffer = new StringBuffer(tabs); for (int i = 0; i < tabs; i++) {
void setFont(Font font, int tabs) { TextLayout layout = new TextLayout(device); layout.setFont(regularFont); if (font != null) { if (boldFont != null) boldFont.dispose(); regularFont = font; layout.setText(" "); layout.setFont(font); layout.setStyle(new TextStyle(getFont(SWT.NORMAL), null, null), 0, 0); layout.setStyle(new TextStyle(getFont(SWT.BOLD), null, null), 1, 1); layout.setFont(regularFont); StringBuffer tabBuffer = new StringBuffer(tabs); for (int i = 0; i < tabs; i++) {
void setFont(Font font, int tabs) { TextLayout layout = new TextLayout(device); layout.setFont(regularFont); if (font != null) { if (boldFont != null) boldFont.dispose(); regularFont = font; layout.setText(" "); layout.setFont(font); layout.setStyle(new TextStyle(getFont(SWT.NORMAL), null, null), 0, 0); layout.setStyle(new TextStyle(getFont(SWT.BOLD), null, null), 1, 1); layout.setFont(regularFont); StringBuffer tabBuffer = new StringBuffer(tabs); for (int i = 0; i < tabs; i++) {
/** * @param layout * @param cell * @param applyColors * @return the text width delta (0 if the text layout contains no other font) */ private int updateTextLayout(TextLayout layout, ViewerCell cell, boolean applyColors) { layout.setStyle(null, 0, Integer.MAX_VALUE); // clear old styles layout.setText(cell.getText()); layout.setFont(cell.getFont()); // set also if null to clear previous usages int originalTextWidth = layout.getBounds().width; // text width without any styles boolean containsOtherFont= false; StyleRange[] styleRanges = cell.getStyleRanges(); if (styleRanges != null) { // user didn't fill styled ranges for (int i = 0; i < styleRanges.length; i++) { StyleRange curr = prepareStyleRange(styleRanges[i], applyColors); layout.setStyle(curr, curr.start, curr.start + curr.length - 1); if (curr.font != null) { containsOtherFont= true; } } } int textWidthDelta = 0; if (containsOtherFont) { textWidthDelta = layout.getBounds().width - originalTextWidth; } return textWidthDelta; }
void setFont(Font font, int tabs) { TextLayout layout = new TextLayout(device); layout.setFont(regularFont); if (font != null) { if (boldFont != null) boldFont.dispose(); regularFont = font; layout.setText(" "); layout.setFont(font); layout.setStyle(new TextStyle(getFont(SWT.NORMAL), null, null), 0, 0); layout.setStyle(new TextStyle(getFont(SWT.BOLD), null, null), 1, 1); layout.setFont(regularFont); StringBuffer tabBuffer = new StringBuffer(tabs); for (int i = 0; i < tabs; i++) {
/** * @param layout * @param cell * @param applyColors * @return the text width delta (0 if the text layout contains no other font) */ private int updateTextLayout(TextLayout layout, ViewerCell cell, boolean applyColors) { layout.setStyle(null, 0, Integer.MAX_VALUE); // clear old styles layout.setText(cell.getText()); layout.setFont(cell.getFont()); // set also if null to clear previous usages int originalTextWidth = layout.getBounds().width; // text width without any styles boolean containsOtherFont= false; StyleRange[] styleRanges = cell.getStyleRanges(); if (styleRanges != null) { // user didn't fill styled ranges for (StyleRange styleRange : styleRanges) { StyleRange curr = prepareStyleRange(styleRange, applyColors); layout.setStyle(curr, curr.start, curr.start + curr.length - 1); if (curr.font != null) { containsOtherFont= true; } } } int textWidthDelta = 0; if (containsOtherFont) { textWidthDelta = layout.getBounds().width - originalTextWidth; } return textWidthDelta; }
/** * Creates and initializes the text layout used * to compute the size hint. * * @since 3.2 */ private void createTextLayout() { fTextLayout= new TextLayout(fBrowser.getDisplay()); // Initialize fonts String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName; Font font= JFaceResources.getFont(symbolicFontName); fTextLayout.setFont(font); fTextLayout.setWidth(-1); font= JFaceResources.getFontRegistry().getBold(symbolicFontName); fBoldStyle= new TextStyle(font, null, null); // Compute and set tab width fTextLayout.setText(" "); //$NON-NLS-1$ int tabWidth= fTextLayout.getBounds().width; fTextLayout.setTabs(new int[] { tabWidth }); fTextLayout.setText(""); //$NON-NLS-1$ }
/** * Creates and initializes the text layout used * to compute the size hint. * * @since 3.2 */ private void createTextLayout() { fTextLayout= new TextLayout(fBrowser.getDisplay()); // Initialize fonts String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName; Font font= JFaceResources.getFont(symbolicFontName); fTextLayout.setFont(font); fTextLayout.setWidth(-1); font= JFaceResources.getFontRegistry().getBold(symbolicFontName); fBoldStyle= new TextStyle(font, null, null); // Compute and set tab width fTextLayout.setText(" "); //$NON-NLS-1$ int tabWidth= fTextLayout.getBounds().width; fTextLayout.setTabs(new int[] { tabWidth }); fTextLayout.setText(""); //$NON-NLS-1$ }