Java Code Examples for org.eclipse.swt.graphics.FontData#setStyle()
The following examples show how to use
org.eclipse.swt.graphics.FontData#setStyle() .
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
Source File: Utils.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Takes a font and gives it a bold typeface. * * @param font Font to modify * @return Font with bold typeface */ public static Font applyBoldFont(final Font font) { if (font == null) { return null; } final FontData[] fontDataArray = font.getFontData(); if (fontDataArray == null) { return null; } for (int index = 0; index < fontDataArray.length; index++) { final FontData fData = fontDataArray[index]; fData.setStyle(SWT.BOLD); } return new Font(Display.getDefault(), fontDataArray); }
Example 2
Source File: XLIFFEditorImplWithNatTable.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 配置标签列的显示效果 * @param configRegistry * 配置注册表 */ private void addFlagLableToColumn(IConfigRegistry configRegistry) { // Edit by Leakey 实现状态图片的动态显示 StatusPainter painter = new StatusPainter(bodyDataProvider); // CellPainterDecorator flagPainter = new CellPainterDecorator(new BackgroundPainter(), CellEdgeEnum.RIGHT, // painter); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, DisplayMode.NORMAL, FLAG_CELL_LABEL); // Set the color of the cell. This is picked up by the button painter to style the button Style style = new Style(); FontData fd = GUIHelper.DEFAULT_FONT.getFontData()[0]; fd.setStyle(SWT.BOLD); style.setAttributeValue(CellStyleAttributes.FONT, GUIHelper.getFont(fd)); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, FLAG_CELL_LABEL); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.SELECT, FLAG_CELL_LABEL); }
Example 3
Source File: ConcordanceSearchDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 构造方法 * @param parentShell * @param file * 当前文件 * @param strSrcLang * 当前文件的源语言 * @param strTgtLang * 当前文件的目标语言 * @param strSearchText * 搜索文本 */ public ConcordanceSearchDialog(Shell parentShell, IFile file, String strSrcLang, String strTgtLang, String strSearchText) { super(parentShell); FontData fontData = JFaceResources.getDefaultFont().getFontData()[0]; fontData.setStyle(fontData.getStyle() | SWT.BOLD); font = new Font(Display.getDefault(), fontData); style = new TextStyle(font, null, null); this.strSrcLang = strSrcLang; this.strTgtLang = strTgtLang; this.strSearchText = strSearchText; ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject()); lstDatabase = projectConfig.getAllTmDbs(); filterUnAvaliableDatabase(); setHelpAvailable(true); setBlockOnOpen(false); lstSearchHistory = new ArrayList<String>(HISTORY_SIZE - 1); lstFilterHistory = new ArrayList<String>(HISTORY_SIZE - 1); if (!Util.isLinux()) { totalWidth = 910; } }
Example 4
Source File: DiscreteEntryComposite.java From ice with Eclipse Public License 1.0 | 6 votes |
/** * This operation will post a message to the message manager (if one exists) * if the Entry has no value, but requires a value from a discrete set. */ private void throwMissingValuesError() { if (messageManager != null) { // Get the message String errorMessage = "There are no allowed values, can't create DiscreteEntryComposite.";// entry.getErrorMessage(); // Post it if it exists if (errorMessage != null) { // Display the error at the top of the screen if (messageManager != null) { messageManager.addMessage(messageName, errorMessage, null, IMessageProvider.ERROR); } // Highlight the text if it is in a text box if (widget != null) { Color color = new Color(Display.getCurrent(), 200, 0, 0); widget.setForeground(color); FontData fontData = new FontData(); fontData.setStyle(SWT.BOLD); Font font = new Font(getDisplay(), fontData); widget.setFont(font); } } } return; }
Example 5
Source File: ConcordanceSearchDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 构造方法 * @param parentShell * @param file * 当前文件 * @param strSrcLang * 当前文件的源语言 * @param strTgtLang * 当前文件的目标语言 * @param strSearchText * 搜索文本 */ public ConcordanceSearchDialog(Shell parentShell, IFile file, String strSrcLang, String strTgtLang, String strSearchText) { super(parentShell); FontData fontData = JFaceResources.getDefaultFont().getFontData()[0]; fontData.setStyle(fontData.getStyle() | SWT.BOLD); font = new Font(Display.getDefault(), fontData); style = new TextStyle(font, null, null); this.strSrcLang = strSrcLang; this.strTgtLang = strTgtLang; this.strSearchText = strSearchText; ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject()); lstDatabase = projectConfig.getAllTmDbs(); filterUnAvaliableDatabase(); setHelpAvailable(true); setBlockOnOpen(false); lstSearchHistory = new ArrayList<String>(HISTORY_SIZE - 1); lstFilterHistory = new ArrayList<String>(HISTORY_SIZE - 1); if (!Util.isLinux()) { totalWidth = 910; } }
Example 6
Source File: Utils.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Takes a font and gives it the typeface of the given style. * * @param font Font to modify * @param style the new style for the given font (e.g. SWT.BOLD|SWT.ITALIC) * @param size New font size * @return Font with the given typeface and size */ public static Font applyFontData(final Font font, int style, int size) { if (font == null) { return null; } final FontData[] fontDataArray = font.getFontData(); if (fontDataArray == null) { return null; } for (int index = 0; index < fontDataArray.length; index++) { final FontData fData = fontDataArray[index]; fData.setStyle(style); fData.setHeight(size); } return new Font(Display.getDefault(), fontDataArray); }
Example 7
Source File: XLIFFEditorImplWithNatTable.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 配置标签列的显示效果 * @param configRegistry * 配置注册表 */ private void addFlagLableToColumn(IConfigRegistry configRegistry) { // Edit by Leakey 实现状态图片的动态显示 StatusPainter painter = new StatusPainter(bodyDataProvider); // CellPainterDecorator flagPainter = new CellPainterDecorator(new BackgroundPainter(), CellEdgeEnum.RIGHT, // painter); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, DisplayMode.NORMAL, FLAG_CELL_LABEL); // Set the color of the cell. This is picked up by the button painter to style the button Style style = new Style(); FontData fd = GUIHelper.DEFAULT_FONT.getFontData()[0]; fd.setStyle(SWT.BOLD); style.setAttributeValue(CellStyleAttributes.FONT, GUIHelper.getFont(fd)); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, FLAG_CELL_LABEL); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.SELECT, FLAG_CELL_LABEL); }
Example 8
Source File: TableComboPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyWeight(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 ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | SWT.BOLD); } } else { modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.BOLD); } } if (modified) { applyFont(widget, fd); } } return true; }
Example 9
Source File: TableComboPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
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 10
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyWeight(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(grid); boolean modified = false; if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | SWT.BOLD); } } else { modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.BOLD); } } if (modified) { applyFont(grid, fd, target); } } return true; }
Example 11
Source File: CommentBlocksPreferences.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private void setLabelFont(Composite composite, Label label) { try { FontData labelFontData = FontUtils.getFontData(IFontUsage.WIDGET, true); labelFontData.setStyle(SWT.BOLD); label.setFont(new Font(composite.getDisplay(), labelFontData)); } catch (Throwable e) { //ignore } }
Example 12
Source File: GanttToolTip.java From nebula with Eclipse Public License 2.0 | 5 votes |
private static Font applyBoldFont(final Font font) { if (font == null) { return null; } final FontData[] fontDataArray = font.getFontData(); if (fontDataArray == null) { return null; } for (int index = 0; index < fontDataArray.length; index++) { final FontData fData = fontDataArray[index]; fData.setStyle(SWT.BOLD); } return new Font(Display.getDefault(), fontDataArray); }
Example 13
Source File: SnippetGalleryViewerTester.java From nebula with Eclipse Public License 2.0 | 5 votes |
public Font getFont(Object element) { String label = (String) element; if (Integer.parseInt(label.substring(label.indexOf(' ') + 1)) % 2 > 0) { return null; } else { FontData sysFontData = Display.getCurrent().getSystemFont().getFontData()[0]; sysFontData.setStyle(SWT.BOLD | SWT.ITALIC); return new Font(Display.getCurrent(), sysFontData); } }
Example 14
Source File: ResourceHelper.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static Font getItalicFont(Font currentFont) { FontData[] original = currentFont.getFontData(); FontData[] fontData = Arrays.copyOf(original, original.length); for (FontData data : fontData) { data.setStyle(data.getStyle() | SWT.ITALIC); } return getFont(fontData); }
Example 15
Source File: ResourceHelper.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static Font getBoldFont(Font currentFont) { FontData[] original = currentFont.getFontData(); FontData[] fontData = Arrays.copyOf(original, original.length); for (FontData data : fontData) { data.setStyle(data.getStyle() | SWT.BOLD); } return getFont(fontData); }
Example 16
Source File: StylerFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void applyStyles(TextStyle textStyle) { textStyle.strikeout = (xtextTextStyle.getStyle() & TextAttribute.STRIKETHROUGH) != 0; textStyle.underline = (xtextTextStyle.getStyle() & TextAttribute.UNDERLINE) != 0; if (xtextTextStyle.getFontData() == null && xtextTextStyle.getStyle() != org.eclipse.xtext.ui.editor.utils.TextStyle.DEFAULT_FONT_STYLE) { FontData fontData = new FontData(); fontData.setStyle(xtextTextStyle.getStyle()); xtextTextStyle.setFontData(fontData); } textStyle.font = fontFromFontData(xtextTextStyle.getFontData()); if (xtextTextStyle.getBackgroundColor() != null) textStyle.background = colorFromRGB(xtextTextStyle.getBackgroundColor()); textStyle.foreground = colorFromRGB(xtextTextStyle.getColor()); }
Example 17
Source File: SWTUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Styles a font. * * @param font * @return styled font data */ public static FontData[] styleFont(Font font, int fontStyle) { FontData[] datas = font.getFontData(); for (FontData data : datas) { data.setStyle(data.getStyle() | fontStyle); } return datas; }
Example 18
Source File: ConcordanceSearchDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private TextStyle createResultsStyle() { background = new Color(Display.getCurrent(), 0x19, 0x19, 0x70); foreground = new Color(Display.getCurrent(), 0xff, 0xff, 0xff); FontData fontData = JFaceResources.getDefaultFont().getFontData()[0]; fontData.setStyle(fontData.getStyle()); rsFont = new Font(Display.getDefault(), fontData); TextStyle style = new TextStyle(rsFont, foreground, background); return style; }
Example 19
Source File: SWTSkinObjectExpandBar.java From BiglyBT with GNU General Public License v2.0 | 4 votes |
private void createExpandBar() { Composite createOn; if (parent == null) { createOn = skin.getShell(); } else { createOn = (Composite) parent.getControl(); } int style = SWT.NONE; if (properties.getIntValue(sConfigID + ".border", 0) == 1) { style = SWT.BORDER; } expandBar = new ExpandBar(createOn, style); // | SWT.V_SCROLL); // ensure no layout for expandbar (children don't setlayoutdata because they are expanditems) expandBar.setLayout(null); expandBar.setSpacing(1); // This fixes the bandHeight which is only auto calculated if Font on ExpandBar is set if (!Utils.isGTK3) { expandBar.setFont(createOn.getFont()); } else { FontData[] fontData = createOn.getFont().getFontData(); for (FontData fd : fontData) { fd.setStyle(SWT.BOLD); float height = FontUtils.getHeight(fontData) * 1.2f; FontUtils.setFontDataHeight(fontData, height); } final Font font = new Font(createOn.getDisplay(), fontData); expandBar.setFont(font); expandBar.setSpacing(3); expandBar.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { Utils.disposeSWTObjects(new Object[] { font }); } }); } expandBar.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(final Event event) { handleResize(null); } }); triggerListeners(SWTSkinObjectListener.EVENT_CREATED); setControl(expandBar); }
Example 20
Source File: UiUtils.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
public static FontData modifyFont(FontData fd, int flags) { FontData newFd = new FontData(fd.toString()); newFd.setStyle(newFd.getStyle() | flags); return newFd; }