use of org.eclipse.swt.graphics.Font in project eclipse.platform.swt by eclipse.
the class TableTab method resetColorsAndFonts.
/**
* Sets the foreground color, background color, and font
* of the "Example" widgets to their default settings.
* Also sets foreground and background color of TableItem [0]
* to default settings.
*/
@Override
void resetColorsAndFonts() {
super.resetColorsAndFonts();
Color oldColor = itemForegroundColor;
itemForegroundColor = null;
setItemForeground();
if (oldColor != null)
oldColor.dispose();
oldColor = itemBackgroundColor;
itemBackgroundColor = null;
setItemBackground();
if (oldColor != null)
oldColor.dispose();
Font oldFont = font;
itemFont = null;
setItemFont();
if (oldFont != null)
oldFont.dispose();
oldColor = cellForegroundColor;
cellForegroundColor = null;
setCellForeground();
if (oldColor != null)
oldColor.dispose();
oldColor = cellBackgroundColor;
cellBackgroundColor = null;
setCellBackground();
if (oldColor != null)
oldColor.dispose();
oldFont = font;
cellFont = null;
setCellFont();
if (oldFont != null)
oldFont.dispose();
oldColor = headerBackgroundColor;
headerBackgroundColor = null;
setHeaderBackground();
if (oldColor != null)
oldColor.dispose();
oldColor = headerForegroundColor;
headerForegroundColor = null;
setHeaderForeground();
if (oldColor != null)
oldColor.dispose();
}
use of org.eclipse.swt.graphics.Font in project eclipse.platform.swt by eclipse.
the class TreeTab method setItemFont.
/**
* Sets the font of the Node 1 TreeItems.
*/
void setItemFont() {
if (!instance.startup) {
textNode1.setFont(itemFont);
imageNode1.setFont(itemFont);
}
/* Set the font item's image to match the font of the item. */
Font ft = itemFont;
if (ft == null)
ft = textNode1.getFont();
TableItem item = colorAndFontTable.getItem(ITEM_FONT);
Image oldImage = item.getImage();
if (oldImage != null)
oldImage.dispose();
item.setImage(fontImage(ft));
item.setFont(ft);
colorAndFontTable.layout();
}
use of org.eclipse.swt.graphics.Font in project eclipse.platform.swt by eclipse.
the class TreeTab method setCellFont.
/**
* Sets the font of the Node 1 TreeItems in column 1.
*/
void setCellFont() {
if (!instance.startup) {
textNode1.setFont(1, cellFont);
imageNode1.setFont(1, cellFont);
}
/* Set the font item's image to match the font of the item. */
Font ft = cellFont;
if (ft == null)
ft = textNode1.getFont(1);
TableItem item = colorAndFontTable.getItem(CELL_FONT);
Image oldImage = item.getImage();
if (oldImage != null)
oldImage.dispose();
item.setImage(fontImage(ft));
item.setFont(ft);
colorAndFontTable.layout();
}
use of org.eclipse.swt.graphics.Font in project eclipse.platform.swt by eclipse.
the class TreeTab method resetColorsAndFonts.
/**
* Sets the foreground color, background color, and font
* of the "Example" widgets to their default settings.
* Also sets foreground and background color of the Node 1
* TreeItems to default settings.
*/
@Override
void resetColorsAndFonts() {
super.resetColorsAndFonts();
Color oldColor = itemForegroundColor;
itemForegroundColor = null;
setItemForeground();
if (oldColor != null)
oldColor.dispose();
oldColor = itemBackgroundColor;
itemBackgroundColor = null;
setItemBackground();
if (oldColor != null)
oldColor.dispose();
Font oldFont = font;
itemFont = null;
setItemFont();
if (oldFont != null)
oldFont.dispose();
oldColor = cellForegroundColor;
cellForegroundColor = null;
setCellForeground();
if (oldColor != null)
oldColor.dispose();
oldColor = cellBackgroundColor;
cellBackgroundColor = null;
setCellBackground();
if (oldColor != null)
oldColor.dispose();
oldFont = font;
cellFont = null;
setCellFont();
if (oldFont != null)
oldFont.dispose();
oldColor = headerBackgroundColor;
headerBackgroundColor = null;
setHeaderBackground();
if (oldColor != null)
oldColor.dispose();
oldColor = headerForegroundColor;
headerForegroundColor = null;
setHeaderForeground();
if (oldColor != null)
oldColor.dispose();
}
use of org.eclipse.swt.graphics.Font in project eclipse.platform.swt by eclipse.
the class CurvesSWTTab method paint.
@Override
public void paint(GC gc, int width, int height) {
if (!example.checkAdvancedGraphics())
return;
Device device = gc.getDevice();
Font font = new Font(device, getPlatformFont(), 16, SWT.ITALIC);
gc.setFont(font);
gc.setLineWidth(2);
Transform transform;
// ----- letter s -----
sXPos = 4 * width / 16;
sYPos = (height - 150) / 2;
transform = new Transform(device);
transform.translate(sXPos, sYPos);
gc.setTransform(transform);
transform.dispose();
gc.setForeground(device.getSystemColor(SWT.COLOR_DARK_BLUE));
gc.drawString(GraphicsExample.getResourceString("Cubic"), 0, 175, true);
Path path = new Path(device);
path.cubicTo(-200 + sDiffX1, 50 + sDiffY1, 200 + sDiffX2, 100 + sDiffY2, 0, 150);
gc.drawPath(path);
path.dispose();
// draw the spline points
gc.setTransform(null);
gc.drawRectangle(sRect1.x + (int) sXPos, sRect1.y + (int) sYPos, sRect1.width, sRect1.height);
gc.drawRectangle(sRect2.x + (int) sXPos, sRect2.y + (int) sYPos, sRect2.width, sRect2.height);
// ----- letter w -----
wXPos = 6 * width / 16;
wYPos = (height - 150) / 2;
transform = new Transform(device);
transform.translate(wXPos, wYPos);
gc.setTransform(transform);
transform.dispose();
gc.setForeground(device.getSystemColor(SWT.COLOR_GRAY));
gc.drawString(GraphicsExample.getResourceString("Quadratic"), 0, -50, true);
gc.drawString(GraphicsExample.getResourceString("Quadratic"), 110, -50, true);
path = new Path(device);
path.quadTo(100 + wDiffX1, 300 + wDiffY1, 100, 0);
path.quadTo(100 + wDiffX2, 300 + wDiffY2, 200, 0);
gc.drawPath(path);
path.dispose();
gc.setTransform(null);
gc.drawRectangle(wRect1.x + (int) wXPos, wRect1.y + (int) wYPos, wRect1.width, wRect1.height);
gc.drawRectangle(wRect2.x + (int) wXPos, wRect2.y + (int) wYPos, wRect2.width, wRect2.height);
// ----- top of letter t -----
topTXPos = 11 * width / 16;
topTYPos = (height - 150) / 2;
transform = new Transform(device);
transform.translate(topTXPos, topTYPos);
gc.setTransform(transform);
transform.dispose();
gc.setForeground(device.getSystemColor(SWT.COLOR_YELLOW));
gc.drawString(GraphicsExample.getResourceString("Cubic"), 25, -50, true);
path = new Path(device);
path.cubicTo(33 + tTopDiffX1, -20 + tTopDiffY1, 66 + tTopDiffX2, 20 + tTopDiffY2, 100, 0);
gc.drawPath(path);
path.dispose();
gc.setTransform(null);
gc.drawRectangle(tTopRect1.x + (int) topTXPos, tTopRect1.y + (int) topTYPos, tTopRect1.width, tTopRect1.height);
gc.drawRectangle(tTopRect2.x + (int) topTXPos, tTopRect2.y + (int) topTYPos, tTopRect2.width, tTopRect2.height);
// ----- vertical bar of letter t -----
botTXPos = 12 * width / 16;
botTYPos = (height - 150) / 2;
transform = new Transform(device);
transform.translate(botTXPos, botTYPos);
gc.setTransform(transform);
transform.dispose();
gc.setForeground(device.getSystemColor(SWT.COLOR_RED));
gc.drawString(GraphicsExample.getResourceString("Cubic"), 0, 175, true);
path = new Path(device);
path.cubicTo(-33 + tBotDiffX1, 50 + tBotDiffY1, 33 + tBotDiffX2, 100 + tBotDiffY2, 0, 150);
gc.drawPath(path);
path.dispose();
gc.setTransform(null);
gc.drawRectangle(tBottomRect1.x + (int) botTXPos, tBottomRect1.y + (int) botTYPos, tBottomRect1.width, tBottomRect1.height);
gc.drawRectangle(tBottomRect2.x + (int) botTXPos, tBottomRect2.y + (int) botTYPos, tBottomRect2.width, tBottomRect2.height);
font.dispose();
}
Aggregations