mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
additional information about font in the combo box
This commit is contained in:
@@ -19,8 +19,6 @@ package com.intellij.application.options.colors;
|
||||
import com.intellij.application.options.EditorFontsConstants;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeTooltipManager;
|
||||
import com.intellij.ide.ui.AntialiasingType;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
@@ -51,8 +49,8 @@ import java.util.Set;
|
||||
public class FontOptions extends JPanel implements OptionsPanel{
|
||||
private static final FontInfoRenderer RENDERER = new FontInfoRenderer() {
|
||||
@Override
|
||||
protected AntialiasingType getAntialiasingType() {
|
||||
return UISettings.getShadowInstance().EDITOR_AA_TYPE;
|
||||
protected boolean isEditorFont() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.util.ui.FontInfo;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -40,6 +41,10 @@ public final class FontComboBox extends ComboBox {
|
||||
|
||||
public FontComboBox(boolean withAllStyles) {
|
||||
super(new Model(withAllStyles));
|
||||
Dimension size = getPreferredSize();
|
||||
size.width = size.height * 8;
|
||||
setPreferredSize(size);
|
||||
setSwingPopup(true);
|
||||
setRenderer(RENDERER);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.ui.AntialiasingType;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.util.ui.FontInfo;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -27,35 +25,35 @@ import java.awt.*;
|
||||
/**
|
||||
* @author Sergey.Malenkov
|
||||
*/
|
||||
public class FontInfoRenderer extends ListCellRendererWrapper {
|
||||
public class FontInfoRenderer extends ColoredListCellRenderer<Object> {
|
||||
@Override
|
||||
public void customize(JList list, Object value, int index, boolean selected, boolean focused) {
|
||||
protected void customizeCellRenderer(@NotNull JList<?> list, Object value, int index, boolean selected, boolean focused) {
|
||||
Font font = list.getFont();
|
||||
String text = value == null ? "" : value.toString();
|
||||
setText(text);
|
||||
append(text);
|
||||
if (value instanceof FontInfo) {
|
||||
FontInfo info = (FontInfo)value;
|
||||
Integer size = getFontSize();
|
||||
Font f = info.getFont(size != null ? size : font.getSize());
|
||||
if (f.canDisplayUpTo(text) == -1) {
|
||||
font = f;
|
||||
setFont(f);
|
||||
}
|
||||
else {
|
||||
append(" Non-latin", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
setFont(font);
|
||||
setForeground(list.isEnabled()
|
||||
? UIUtil.getListForeground(selected)
|
||||
: UIUtil.getLabelDisabledForeground());
|
||||
}
|
||||
|
||||
AntialiasingType type = getAntialiasingType();
|
||||
if (type == null) type = AntialiasingType.GREYSCALE;
|
||||
setClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, type.getTextInfo());
|
||||
@Override
|
||||
protected void applyAdditionalHints(@NotNull Graphics2D g) {
|
||||
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AntialiasingType.getKeyForCurrentScope(isEditorFont()));
|
||||
}
|
||||
|
||||
protected Integer getFontSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected AntialiasingType getAntialiasingType() {
|
||||
return UISettings.getShadowInstance().IDE_AA_TYPE;
|
||||
protected boolean isEditorFont() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user