From 4257131f8d2a6284beaee8ae3fd8923ad37ff03b Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 6 Oct 2011 19:31:52 +0200 Subject: [PATCH] Fix message box background for GTK+ L&F --- .../ConfigurationErrorsComponent.java | 4 +-- .../src/com/intellij/openapi/ui/Messages.java | 6 ++--- .../ui/components/panels/NonOpaquePanel.java | 9 +++---- .../impl/NotificationsManagerImpl.java | 4 +-- .../impl/IdeaActionButtonLook.java | 27 +------------------ .../com/intellij/openapi/util/IconLoader.java | 6 ++--- .../util/src/com/intellij/util/ui/UIUtil.java | 9 ++++--- 7 files changed, 19 insertions(+), 46 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java index 341ca35c2761..feb105110cf9 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -407,7 +407,7 @@ public class ConfigurationErrorsComponent extends JPanel implements Disposable, myFakeTextPane.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); myText.setOpaque(false); if (UIUtil.isUnderNimbusLookAndFeel()) { - myText.setBackground(new Color(0, 0, 0, 0)); + myText.setBackground(UIUtil.TRANSPARENT_COLOR); } myText.setEditable(false); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index 6e6c5d60fb6b..34db66371455 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1013,9 +1013,9 @@ public class Messages { messageComponent.setCaretPosition(0); } - if (UIUtil.isUnderNimbusLookAndFeel()) { + if (UIUtil.isUnderNimbusLookAndFeel() || UIUtil.isUnderGTKLookAndFeel()) { messageComponent.setOpaque(false); - messageComponent.setBackground(new Color(0, 0, 0, 0)); + messageComponent.setBackground(UIUtil.TRANSPARENT_COLOR); } else { messageComponent.setBackground(UIUtil.getOptionPaneBackground()); diff --git a/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java b/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java index 1c53923022f9..a0f0f82019ef 100644 --- a/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java +++ b/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,6 @@ import javax.swing.*; import java.awt.*; public class NonOpaquePanel extends Wrapper { - - private static final Color TRANSPARENT = new Color(0, 0, 0, 0); - public NonOpaquePanel() { setOpaque(false); } @@ -59,7 +56,7 @@ public class NonOpaquePanel extends Wrapper { if (!isOpaque && UIUtil.isUnderNimbusLookAndFeel()) { if (UIUtil.isUnderNimbusLookAndFeel()) { - setBackground(TRANSPARENT); + setBackground(UIUtil.TRANSPARENT_COLOR); } } } @@ -67,7 +64,7 @@ public class NonOpaquePanel extends Wrapper { public static void setTransparent(JComponent c) { c.setOpaque(false); if (UIUtil.isUnderNimbusLookAndFeel()) { - c.setBackground(TRANSPARENT); + c.setBackground(UIUtil.TRANSPARENT_COLOR); } } } diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java index 16e9ca980b02..420b26a9f6d7 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -241,7 +241,7 @@ public class NotificationsManagerImpl extends NotificationsManager implements No text.setOpaque(false); if (UIUtil.isUnderNimbusLookAndFeel()) { - text.setBackground(new Color(0, 0, 0, 0)); + text.setBackground(UIUtil.TRANSPARENT_COLOR); } text.setBorder(null); diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java index ff49f8779104..960e1abd8364 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,6 @@ public class IdeaActionButtonLook extends ActionButtonLook { } } else if (state == ActionButtonComponent.POPPED) { ((Graphics2D)g).setPaint(new GradientPaint(0, 0, new Color(235, 235, 235), 0, dimension.height, new Color(200, 200, 200))); - //g.setColor(new Color(190, 190, 190)); g.fillRect(1, 1, dimension.width - 3, dimension.height - 3); } } @@ -55,26 +54,6 @@ public class IdeaActionButtonLook extends ActionButtonLook { g.setColor(new Color(0, 0, 0, 30)); g.drawRect(1, 1, dimension.width - 3, dimension.height - 3); - - /* - final Graphics2D g2d = (Graphics2D)g; - - final int x = 1; - - g2d.setPaint(new LinearGradientPaint(0, 0, 0, dimension.height, new float[] {0f, 0.5f, 1.0f}, - new Color[] {new Color(0, 0, 0, 0), new Color(0, 0, 0, 40), new Color(0, 0, 0, 0)})); - g2d.fillRect(x, 0, dimension.width - 2, dimension.height); - - g2d.setPaint(new LinearGradientPaint(0, 0, 0, dimension.height, new float[] {0f, 0.5f, 1.0f}, - new Color[] {new Color(0, 0, 0, 40), new Color(0, 0, 0, 150), new Color(0, 0, 0, 40)})); - g2d.drawLine(x, 0, x, dimension.height); - g2d.drawLine(dimension.width - 2, 0, dimension.width - 2, dimension.height); - - g2d.setPaint(new LinearGradientPaint(0, 0, 0, dimension.height, new float[] {0f, 0.5f, 1.0f}, - new Color[] {new Color(0, 0, 0, 0), new Color(0, 0, 0, 60), new Color(0, 0, 0, 0)})); - g2d.drawLine(x + 1, 0, x + 1, dimension.height); - g2d.drawLine(dimension.width - 3, 0, dimension.width - 3, dimension.height); - */ } else { g.setColor(new Color(130, 146, 185)); @@ -91,10 +70,6 @@ public class IdeaActionButtonLook extends ActionButtonLook { if (state == ActionButtonComponent.POPPED) { g.setColor(new Color(0, 0, 0, 30)); g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4); - - //g.setColor(new Color(0, 0, 0, 30)); - //g.drawLine(1, r.height - 2, r.width - 3, r.height - 2); - //g.drawLine(r.width - 2, 1, r.width - 2, r.height - 3); } } else { Color color = new Color(8, 36, 107); diff --git a/platform/util/src/com/intellij/openapi/util/IconLoader.java b/platform/util/src/com/intellij/openapi/util/IconLoader.java index 1a9a903e6276..a02813340427 100644 --- a/platform/util/src/com/intellij/openapi/util/IconLoader.java +++ b/platform/util/src/com/intellij/openapi/util/IconLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.intellij.reference.SoftReference; import com.intellij.util.ImageLoader; import com.intellij.util.containers.ConcurrentHashMap; import com.intellij.util.containers.WeakHashMap; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,7 +36,6 @@ import java.util.*; public final class IconLoader { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.IconLoader"); - private static final Color ourTransparentColor = new Color(0, 0, 0, 0); @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private static final ConcurrentHashMap ourIconsCache = new ConcurrentHashMap(100, 0.9f,2); @@ -190,7 +190,7 @@ public final class IconLoader { final BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); final Graphics2D graphics = image.createGraphics(); - graphics.setColor(ourTransparentColor); + graphics.setColor(UIUtil.TRANSPARENT_COLOR); graphics.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); icon.paintIcon(ourFakeComponent, graphics, 0, 0); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index aba1bb41c10a..f54d8cdf68bc 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -94,11 +94,10 @@ public class UIUtil { MacUIUtil.getInvertedTextCursor(): Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR); } - public enum FontSize { NORMAL, TREE, SMALL, MINI } + public enum FontSize {NORMAL, TREE, SMALL, MINI} public enum ComponentStyle {REGULAR, SMALL, MINI} public enum FontColor {NORMAL, BRIGHTER} - public static final char MNEMONIC = 0x1B; @NonNls public static final String HTML_MIME = "text/html"; @NonNls public static final String JSLIDER_ISFILLED = "JSlider.isFilled"; @@ -119,8 +118,10 @@ public class UIUtil { private static final Color ACTIVE_HEADER_COLOR = new Color(160, 186, 213); private static final Color INACTIVE_HEADER_COLOR = new Color(128, 128, 128); private static final Color BORDER_COLOR = Color.LIGHT_GRAY; - public static Color AQUA_SEPARATOR_FOREGROUND_COLOR = new Color(190, 190, 190); - public static Color AQUA_SEPARATOR_BACKGROUND_COLOR = new Color(240, 240, 240); + + public static final Color AQUA_SEPARATOR_FOREGROUND_COLOR = new Color(190, 190, 190); + public static final Color AQUA_SEPARATOR_BACKGROUND_COLOR = new Color(240, 240, 240); + public static final Color TRANSPARENT_COLOR = new Color(0, 0, 0, 0); public static final int DEFAULT_HGAP = 10; public static final int DEFAULT_VGAP = 5;