Search in sources :

Example 1 with SynthStyle

use of javax.swing.plaf.synth.SynthStyle in project intellij-community by JetBrains.

the class LafManagerImpl method patchGtkDefaults.

private static void patchGtkDefaults(UIDefaults defaults) {
    if (!UIUtil.isUnderGTKLookAndFeel())
        return;
    Map<String, Icon> map = ContainerUtil.newHashMap(Arrays.asList("OptionPane.errorIcon", "OptionPane.informationIcon", "OptionPane.warningIcon", "OptionPane.questionIcon"), Arrays.asList(AllIcons.General.ErrorDialog, AllIcons.General.InformationDialog, AllIcons.General.WarningDialog, AllIcons.General.QuestionDialog));
    // GTK+ L&F keeps icons hidden in style
    SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
    for (String key : map.keySet()) {
        if (defaults.get(key) != null)
            continue;
        Object icon = style == null ? null : style.get(null, key);
        defaults.put(key, icon instanceof Icon ? icon : map.get(key));
    }
    Color fg = defaults.getColor("Label.foreground");
    Color bg = defaults.getColor("Label.background");
    if (fg != null && bg != null) {
        defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5));
    }
}
Also used : JBColor(com.intellij.ui.JBColor) SynthStyle(javax.swing.plaf.synth.SynthStyle)

Example 2 with SynthStyle

use of javax.swing.plaf.synth.SynthStyle in project intellij-community by JetBrains.

the class LafManagerImpl method fixGtkPopupStyle.

private static void fixGtkPopupStyle() {
    if (!UIUtil.isUnderGTKLookAndFeel())
        return;
    final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();
    SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {

        @Override
        public SynthStyle getStyle(final JComponent c, final Region id) {
            final SynthStyle style = original.getStyle(c, id);
            if (id == Region.POPUP_MENU) {
                final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness");
                if (x != null && x == 0) {
                    // workaround for Sun bug #6636964
                    ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1);
                    ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3);
                }
            }
            return style;
        }
    });
    // invokes updateUI() -> updateStyle()
    new JBPopupMenu();
    SynthLookAndFeel.setStyleFactory(original);
}
Also used : Region(javax.swing.plaf.synth.Region) SynthStyle(javax.swing.plaf.synth.SynthStyle) SynthStyleFactory(javax.swing.plaf.synth.SynthStyleFactory) JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu)

Example 3 with SynthStyle

use of javax.swing.plaf.synth.SynthStyle in project jdk8u_jdk by JetBrains.

the class NimbusLookAndFeel method initialize.

/** Called by UIManager when this look and feel is installed. */
@Override
public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {

        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
Also used : JComponent(javax.swing.JComponent) Region(javax.swing.plaf.synth.Region) SynthStyle(javax.swing.plaf.synth.SynthStyle) SynthStyleFactory(javax.swing.plaf.synth.SynthStyleFactory)

Aggregations

SynthStyle (javax.swing.plaf.synth.SynthStyle)3 Region (javax.swing.plaf.synth.Region)2 SynthStyleFactory (javax.swing.plaf.synth.SynthStyleFactory)2 JBPopupMenu (com.intellij.openapi.ui.JBPopupMenu)1 JBColor (com.intellij.ui.JBColor)1 JComponent (javax.swing.JComponent)1