return; ( (TextLayout) object ).draw( gc, 0, 0 ); return;
/** * Draws the receiver's text using the specified GC at the specified * point. * * @param gc the GC to draw * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the gc is null</li> * </ul> */ public void draw(GC gc, int x, int y) { draw(gc, x, y, -1, -1, null, null); }
/** * Draws the receiver's text using the specified GC at the specified * point. * * @param gc the GC to draw * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn * @param selectionStart the offset where the selections starts, or -1 indicating no selection * @param selectionEnd the offset where the selections ends, or -1 indicating no selection * @param selectionForeground selection foreground, or NULL to use the system default color * @param selectionBackground selection background, or NULL to use the system default color * * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the gc is null</li> * </ul> */ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0); }
drawY = clientArea.y + clientArea.height + segmentHeight; layout.draw(gc, drawX, drawY);
drawY = clientArea.y + clientArea.height + segmentHeight; layout.draw(gc, drawX, drawY);
drawY = clientArea.y + clientArea.height + segmentHeight; layout.draw(gc, drawX, drawY);
void onPaint (Event event) { GC gc = event.gc; int x = BORDER + PADDING; int y = BORDER + PADDING; if ((style & SWT.BALLOON) != 0) { if (spikeAbove) y += TIP_HEIGHT; gc.drawPolygon (borderPolygon); } else { Rectangle rect = tip.getClientArea (); gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height -1); } if (layoutText != null) { int id = style & (SWT.ICON_ERROR | SWT.ICON_INFORMATION | SWT.ICON_WARNING); if ((style & SWT.BALLOON) != 0 && id != 0) { Display display = getDisplay (); Image image = display.getSystemImage (id); Rectangle rect = image.getBounds (); gc.drawImage (image, 0, 0, rect.width, rect.height, x, y, IMAGE_SIZE, IMAGE_SIZE); x += IMAGE_SIZE; } x += INSET; layoutText.draw (gc, x, y); y += 2 * PADDING + Math.max (IMAGE_SIZE, layoutText.getBounds ().height); } if (layoutMessage != null) { x = BORDER + PADDING + INSET; layoutMessage.draw (gc, x, y); } }
void drawBullet(Bullet bullet, GC gc, int paintX, int paintY, int index, int lineAscent, int lineDescent) { StyleRange style = bullet.style; GlyphMetrics metrics = style.metrics; Color color = style.foreground; if (color != null) gc.setForeground(color); Font font = style.font; if (font != null) gc.setFont(font); String string = ""; int type = bullet.type & (ST.BULLET_DOT|ST.BULLET_NUMBER|ST.BULLET_LETTER_LOWER|ST.BULLET_LETTER_UPPER); switch (type) { case ST.BULLET_DOT: string = "\u2022"; break; case ST.BULLET_NUMBER: string = String.valueOf(index + 1); break; case ST.BULLET_LETTER_LOWER: string = String.valueOf((char) (index % 26 + 97)); break; case ST.BULLET_LETTER_UPPER: string = String.valueOf((char) (index % 26 + 65)); break; } if ((bullet.type & ST.BULLET_TEXT) != 0) string += bullet.text; Display display = styledText.getDisplay(); TextLayout layout = new TextLayout(display); layout.setText(string); layout.setAscent(lineAscent); layout.setDescent(lineDescent); style = (StyleRange)style.clone(); style.metrics = null; if (style.font == null) style.font = getFont(style.fontStyle); layout.setStyle(style, 0, string.length()); int x = paintX + Math.max(0, metrics.width - layout.getBounds().width - BULLET_MARGIN); layout.draw(gc, x, paintY); layout.dispose(); } int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground) {
@Override void drawWidget(GC gc) { int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if ((state & DISABLED) != 0) gc.setForeground (disabledColor); layout.draw (gc, 0, 0, selStart, selEnd, null, null); if (hasFocus () && focusIndex != -1) { Rectangle [] rects = getRectanglesInPixels (focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = DPIUtil.autoScaleDown(rects [i]); gc.drawFocus (rect.x, rect.y, rect.width, rect.height); } } }
void drawBullet(Bullet bullet, GC gc, int paintX, int paintY, int index, int lineAscent, int lineDescent) { StyleRange style = bullet.style; GlyphMetrics metrics = style.metrics; Color color = style.foreground; if (color != null) gc.setForeground(color); Font font = style.font; if (font != null) gc.setFont(font); String string = ""; int type = bullet.type & (ST.BULLET_DOT|ST.BULLET_NUMBER|ST.BULLET_LETTER_LOWER|ST.BULLET_LETTER_UPPER); switch (type) { case ST.BULLET_DOT: string = "\u2022"; break; case ST.BULLET_NUMBER: string = String.valueOf(index + 1); break; case ST.BULLET_LETTER_LOWER: string = String.valueOf((char) (index % 26 + 97)); break; case ST.BULLET_LETTER_UPPER: string = String.valueOf((char) (index % 26 + 65)); break; } if ((bullet.type & ST.BULLET_TEXT) != 0) string += bullet.text; Display display = styledText.getDisplay(); TextLayout layout = new TextLayout(display); layout.setText(string); layout.setAscent(lineAscent); layout.setDescent(lineDescent); style = (StyleRange)style.clone(); style.metrics = null; if (style.font == null) style.font = getFont(style.fontStyle); layout.setStyle(style, 0, string.length()); int x = paintX + Math.max(0, metrics.width - layout.getBounds().width - BULLET_MARGIN); layout.draw(gc, x, paintY); layout.dispose(); } int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground) {
void drawBullet(Bullet bullet, GC gc, int paintX, int paintY, int index, int lineAscent, int lineDescent) { StyleRange style = bullet.style; GlyphMetrics metrics = style.metrics; Color color = style.foreground; if (color != null) gc.setForeground(color); Font font = style.font; if (font != null) gc.setFont(font); String string = ""; int type = bullet.type & (ST.BULLET_DOT|ST.BULLET_NUMBER|ST.BULLET_LETTER_LOWER|ST.BULLET_LETTER_UPPER); switch (type) { case ST.BULLET_DOT: string = "\u2022"; break; case ST.BULLET_NUMBER: string = String.valueOf(index + 1); break; case ST.BULLET_LETTER_LOWER: string = String.valueOf((char) (index % 26 + 97)); break; case ST.BULLET_LETTER_UPPER: string = String.valueOf((char) (index % 26 + 65)); break; } if ((bullet.type & ST.BULLET_TEXT) != 0) string += bullet.text; Display display = styledText.getDisplay(); TextLayout layout = new TextLayout(display); layout.setText(string); layout.setAscent(lineAscent); layout.setDescent(lineDescent); style = (StyleRange)style.clone(); style.metrics = null; if (style.font == null) style.font = getFont(style.fontStyle); layout.setStyle(style, 0, string.length()); int x = paintX + Math.max(0, metrics.width - layout.getBounds().width - BULLET_MARGIN); layout.draw(gc, x, paintY); layout.dispose(); } int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground) {
@Override void drawWidget(GC gc) { int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if ((state & DISABLED) != 0) gc.setForeground (disabledColor); layout.draw (gc, 0, 0, selStart, selEnd, null, null); if (hasFocus () && focusIndex != -1) { Rectangle [] rects = getRectanglesInPixels (focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = DPIUtil.autoScaleDown(rects [i]); gc.drawFocus (rect.x, rect.y, rect.width, rect.height); } } }
void drawBullet(Bullet bullet, GC gc, int paintX, int paintY, int index, int lineAscent, int lineDescent) { StyleRange style = bullet.style; GlyphMetrics metrics = style.metrics; Color color = style.foreground; if (color != null) gc.setForeground(color); Font font = style.font; if (font != null) gc.setFont(font); String string = ""; int type = bullet.type & (ST.BULLET_DOT|ST.BULLET_NUMBER|ST.BULLET_LETTER_LOWER|ST.BULLET_LETTER_UPPER); switch (type) { case ST.BULLET_DOT: string = "\u2022"; break; case ST.BULLET_NUMBER: string = String.valueOf(index + 1); break; case ST.BULLET_LETTER_LOWER: string = String.valueOf((char) (index % 26 + 97)); break; case ST.BULLET_LETTER_UPPER: string = String.valueOf((char) (index % 26 + 65)); break; } if ((bullet.type & ST.BULLET_TEXT) != 0) string += bullet.text; Display display = styledText.getDisplay(); TextLayout layout = new TextLayout(display); layout.setText(string); layout.setAscent(lineAscent); layout.setDescent(lineDescent); style = (StyleRange)style.clone(); style.metrics = null; if (style.font == null) style.font = getFont(style.fontStyle); layout.setStyle(style, 0, string.length()); int x = paintX + Math.max(0, metrics.width - layout.getBounds().width - BULLET_MARGIN); layout.draw(gc, x, paintY); layout.dispose(); } int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground) {
@Override void drawWidget(GC gc) { int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if ((state & DISABLED) != 0) gc.setForeground (disabledColor); layout.draw (gc, 0, 0, selStart, selEnd, null, null); if (hasFocus () && focusIndex != -1) { Rectangle [] rects = getRectanglesInPixels (focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = DPIUtil.autoScaleDown(rects [i]); gc.drawFocus (rect.x, rect.y, rect.width, rect.height); } } }
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$ }
void drawWidget (GC gc, RECT rect) { drawBackground (gc.handle, rect); int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if (!OS.IsWindowEnabled (handle)) gc.setForeground (disabledColor); layout.draw (gc, 0, 0, selStart, selEnd, null, null); if (hasFocus () && focusIndex != -1) { Rectangle [] rects = getRectanglesInPixels (focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rectangle = DPIUtil.autoScaleDown(rects [i]); gc.drawFocus (rectangle.x, rectangle.y, rectangle.width, rectangle.height); } } if (hooks (SWT.Paint) || filters (SWT.Paint)) { Event event = new Event (); event.gc = gc; event.setBoundsInPixels(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top)); sendEvent (SWT.Paint, event); event.gc = null; } }