private static void setFont(Widget widget, Font font) { if (widget instanceof CTabItem) { ((CTabItem) widget).setFont(font); } else if (widget instanceof Control) { ((Control) widget).setFont(font); } }
static void addHighlight(MPart part, CTabItem cti, boolean cssEngineActive) { part.getTags().add(CSSConstants.CSS_HIGHLIGHTED_CLASS); if (!cssEngineActive) { cti.setFont(JFaceResources.getFontRegistry().getBold(TAB_FONT_KEY)); } }
static void removeHighlight(MPart part, CTabItem cti, boolean cssEngineActive) { part.getTags().remove(CSSConstants.CSS_HIGHLIGHTED_CLASS); if (!cssEngineActive) { cti.setFont(JFaceResources.getFontRegistry().get(TAB_FONT_KEY)); } }
@Override public void reset() { CTabItem item = getItem(); CSSSWTImageHelper.restoreDefaultImage(item); item.setFont(null); // in such case the parent's font will be taken super.reset(); } }
/** * Updates the visual for busy state of the part tab in case CSS engine is * not active */ static void updateBusyStateNoCss(CTabItem cti, Object newValue, Object oldValue) { Font updatedFont = null; if (CSSConstants.CSS_BUSY_CLASS.equals(newValue)) { updatedFont = JFaceResources.getFontRegistry().getItalic(TAB_FONT_KEY); } else if (CSSConstants.CSS_BUSY_CLASS.equals(oldValue)) { updatedFont = JFaceResources.getFontRegistry().get(TAB_FONT_KEY); } if (updatedFont != null) { cti.setFont(updatedFont); } } }
/** Helper function to avoid setting fonts unnecessarily */ public static void setFont(CTabItem item, Font font) { if (!equals(item.getFont(), font)) { storeDefaultFont(item); item.setFont(font); } }
public static void restoreDefaultFont(CTabItem item) { Font defaultFont = (Font) item.getData(DEFAULT_FONT); if (defaultFont != null) { if (defaultFont.isDisposed()) { defaultFont = item.getDisplay().getSystemFont(); } if (!equals(defaultFont, item.getFont())) { item.setFont(defaultFont); } } }
public static void applyCTabItem(ActionContext actionContext){ Thing self = (Thing) actionContext.get("self"); CTabItem control = (CTabItem) actionContext.get("widget"); //图 Image image = (Image) createResource(self.getString("image"), "xworker.swt.graphics.Image", "imageFile", actionContext); if(image != null){ control.setImage(image); } //字体 Font font = (Font) createResource(self.getString("font"), "xworker.swt.graphics.Font", "fontData", actionContext); if(font != null){ control.setFont(font); } }
/** * Sets the font of CTabItem 0. */ void setItemFont () { if (!instance.startup) { tabFolder1.getItem (0).setFont (itemFont); setExampleWidgetSize(); } /* Set the font item's image to match the font of the item. */ Font ft = itemFont; if (ft == null) ft = tabFolder1.getItem (0).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 (); } }