Search in sources :

Example 71 with Font

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();
}
Also used : Color(org.eclipse.swt.graphics.Color) Font(org.eclipse.swt.graphics.Font)

Example 72 with Font

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();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Image(org.eclipse.swt.graphics.Image) Font(org.eclipse.swt.graphics.Font)

Example 73 with Font

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();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Image(org.eclipse.swt.graphics.Image) Font(org.eclipse.swt.graphics.Font)

Example 74 with Font

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();
}
Also used : Color(org.eclipse.swt.graphics.Color) Font(org.eclipse.swt.graphics.Font)

Example 75 with Font

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();
}
Also used : Path(org.eclipse.swt.graphics.Path) Device(org.eclipse.swt.graphics.Device) Transform(org.eclipse.swt.graphics.Transform) Font(org.eclipse.swt.graphics.Font)

Aggregations

Font (org.eclipse.swt.graphics.Font)235 FontData (org.eclipse.swt.graphics.FontData)93 GridData (org.eclipse.swt.layout.GridData)52 Point (org.eclipse.swt.graphics.Point)51 Composite (org.eclipse.swt.widgets.Composite)50 GridLayout (org.eclipse.swt.layout.GridLayout)47 Color (org.eclipse.swt.graphics.Color)45 Label (org.eclipse.swt.widgets.Label)38 Test (org.junit.Test)26 GC (org.eclipse.swt.graphics.GC)22 Image (org.eclipse.swt.graphics.Image)22 Rectangle (org.eclipse.swt.graphics.Rectangle)22 Button (org.eclipse.swt.widgets.Button)19 Display (org.eclipse.swt.widgets.Display)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 Text (org.eclipse.swt.widgets.Text)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)15 StyledText (org.eclipse.swt.custom.StyledText)13 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)12 StyleRange (org.eclipse.swt.custom.StyleRange)11