Java Code Examples for org.eclipse.swt.SWT#ITALIC

The following examples show how to use org.eclipse.swt.SWT#ITALIC . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private boolean applyCSSPropertyStyle(final Object element, final Control widget, final CSSValue value) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		boolean modified = false;
		if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.ITALIC);
			}
		} else {
			modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.ITALIC);
			}
		}
		if (modified) {
			applyFont(widget, fd);
		}

	}
	return true;
}
 
Example 2
/**
 * Adds style information to the given text presentation.
 *
 * @param presentation the text presentation to be extended
 * @param offset the offset of the range to be styled
 * @param length the length of the range to be styled
 * @param attr the attribute describing the style of the range to be styled
 */
protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
    if (attr != null) {
        int style = attr.getStyle();
        int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
        StyleRange styleRange = new StyleRange(offset, length, attr.getForeground(), attr.getBackground(),
                fontStyle);
        styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
        styleRange.underline = (style & TextAttribute.UNDERLINE) != 0;
        styleRange.font = attr.getFont();
        presentation.addStyleRange(styleRange);
    }
}
 
Example 3
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 4
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 5
Source Project: xds-ide   File: XStyledString.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private StyleRange mkSRange(String s, Color fgColor, int style) {
    //NOTE: new used attributes in StyleRange must be reconcoled in convertToStyledString()
    StyleRange sr = new StyleRange();
    sr.start = sb.length();
    sr.length = s.length();
    sr.foreground = fgColor;
    sr.fontStyle = (style & (SWT.BOLD | SWT.ITALIC));
    sr.underline = (style & TextAttribute.UNDERLINE) != 0;
    sr.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0;
    usedStyles |= style;
    return sr;
}
 
Example 6
Source Project: nebula   File: PWFontChooser.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @return a string that contains data about the choosen font
 */
protected String buildFontInformation() {
	final StringBuilder sb = new StringBuilder();
	if (fontData != null) {
		sb.append(fontData.getName()).append(",").append(fontData.getHeight()).append(" pt");
		if ((fontData.getStyle() & SWT.BOLD) == SWT.BOLD) {
			sb.append(", ").append(ResourceManager.getLabel(ResourceManager.BOLD));
		}
		if ((fontData.getStyle() & SWT.ITALIC) == SWT.ITALIC) {
			sb.append(", ").append(ResourceManager.getLabel(ResourceManager.ITALIC));
		}
	}
	return sb.toString();
}
 
Example 7
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 8
public static TextAttribute getTextAttribute(LogToolRuleDesc ruleDesc) {		
	if (ruleDesc != null) {
		int style = SWT.NORMAL;
		if (ruleDesc.isItalic())
			style |= SWT.ITALIC;
		if (ruleDesc.isBold())
			style |= SWT.BOLD;
		if (ruleDesc.isStrikethrough())
			style |= TextAttribute.STRIKETHROUGH;
		if (ruleDesc.isUnderline())
			style |= TextAttribute.UNDERLINE;			
		return new TextAttribute(new Color(Display.getDefault(),ruleDesc.getForegroundColor()),new Color(Display.getDefault(),ruleDesc.getBackgroundColor()), style);	
	}
	return null;
}
 
Example 9
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 10
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 11
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 12
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 13
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 14
Source Project: scava   File: SinkNameEditPart.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 15
private Font getFont(int style) {
	Device device = Display.getDefault();
	switch (style) {
	case SWT.BOLD:
		return new Font(device, getFontData(style));
	case SWT.ITALIC:
		return new Font(device, getFontData(style));
	case SWT.BOLD | SWT.ITALIC:
		return new Font(device, getFontData(style));
	default:
		return font;
	}

}
 
Example 16
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 17
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 18
/**
* @generated
*/
protected void refreshFont() {
	FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
	if (style != null) {
		FontData fontData = new FontData(style.getFontName(), style.getFontHeight(),
				(style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
		setFont(fontData);
	}
}
 
Example 19
/**
 * A Java Properties file serialization of this theme.
 * 
 * @return
 */
public Properties toProps()
{
	Properties props = new OrderedProperties();
	props.put(THEME_NAME_PROP_KEY, getName());
	props.put(SELECTION_PROP_KEY, toHex(getSelection()));
	props.put(LINE_HIGHLIGHT_PROP_KEY, toHex(getLineHighlight()));
	props.put(FOREGROUND_PROP_KEY, toHex(getForeground()));
	props.put(BACKGROUND_PROP_KEY, toHex(getBackground()));
	props.put(CARET_PROP_KEY, toHex(caret));
	for (ThemeRule rule : coloringRules)
	{
		if (rule == null)
		{
			continue;
		}
		StringBuilder value = new StringBuilder();
		DelayedTextAttribute attr = rule.getTextAttribute();
		RGBa color = attr.foreground;
		if (color != null)
		{
			value.append(toHex(color)).append(DELIMETER);
		}
		color = attr.background;
		if (color != null)
		{
			value.append(toHex(color)).append(DELIMETER);
		}
		int style = attr.style;
		if ((style & SWT.ITALIC) != 0)
		{
			value.append(ITALIC).append(DELIMETER);
		}
		if ((style & TextAttribute.UNDERLINE) != 0)
		{
			value.append(UNDERLINE).append(DELIMETER);
		}
		if ((style & SWT.BOLD) != 0)
		{
			value.append(BOLD).append(DELIMETER);
		}
		if (value.length() > 0)
		{
			value.deleteCharAt(value.length() - 1);
		}
		// Append the scope selector
		value.append(SELECTOR_DELIMITER);
		value.append(rule.getScopeSelector().toString());
		props.put(rule.getName(), value.toString());
	}
	return props;
}
 
Example 20
Source Project: gef   File: JFaceFontsExample.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Font getFont(Object element) {
	return new Font(Display.getCurrent(), "Helvetica",
			element.toString().startsWith("F") ? 12 : 24,
			element.toString().startsWith("S") ? SWT.BOLD : SWT.ITALIC);
}