From 4cb498906ca24e4662a237a54b1afa58f2d83c99 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Thu, 8 Sep 2011 21:04:37 +0400 Subject: [PATCH] titled borders. fixes with colors of line and font size at least 11 points. --- .../intellij/ui/border/IdeaTitledBorder.java | 26 +++++++++++++-- .../util/src/com/intellij/util/ui/UIUtil.java | 32 +++++++++++++++---- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/border/IdeaTitledBorder.java b/platform/platform-api/src/com/intellij/ui/border/IdeaTitledBorder.java index 6d05489e723b..a8df3e82c8b9 100644 --- a/platform/platform-api/src/com/intellij/ui/border/IdeaTitledBorder.java +++ b/platform/platform-api/src/com/intellij/ui/border/IdeaTitledBorder.java @@ -1,6 +1,7 @@ package com.intellij.ui.border; import com.intellij.util.ui.UIUtil; +import com.sun.java.swing.plaf.gtk.GTKLookAndFeel; import sun.swing.SwingUtilities2; import javax.swing.*; @@ -44,12 +45,31 @@ public class IdeaTitledBorder extends TitledBorder { } private void updateUI() { + this.titleFont = UIUtil.getBorderFont(smallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, boldFont); this.titleColor = UIUtil.getTitledBorderTitleColor(); + + Color foregroundColor = UIUtil.getSeparatorForeground(); + Color backgroundColor = UIUtil.getSeparatorBackground(); + if (UIUtil.isUnderAlloyLookAndFeel()) { + foregroundColor = UIUtil.getSeparatorShadow(); + backgroundColor = UIUtil.getSeparatorHighlight(); + } + if (UIUtil.isUnderNimbusLookAndFeel()) { + foregroundColor = null; + backgroundColor = UIUtil.getSeparatorColorUnderNimbus(); + } + //under GTK+ L&F colors setted hard + if (UIUtil.isUnderGTKLookAndFeel()) { + foregroundColor = new Color(215, 215, 215); + backgroundColor = new Color(250, 250, 250); + } + + Border lineBorder = BorderFactory.createCompoundBorder( + BorderFactory.createMatteBorder(1, 0, 0, 0, foregroundColor), + BorderFactory.createMatteBorder(1, 0, 0, 0, backgroundColor)); this.border = BorderFactory.createCompoundBorder(new EmptyBorder(outsideInsets), - BorderFactory.createCompoundBorder( - BorderFactory.createMatteBorder(1, 0, 0, 0, UIUtil.getTitledBorderLineColor()), - new EmptyBorder(insideInsets))); + BorderFactory.createCompoundBorder(lineBorder, new EmptyBorder(insideInsets))); } private void calculateInsets() { diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index fd8ac22daf65..929d76c9ea9f 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -114,6 +114,14 @@ public class UIUtil { private static final Color INACTIVE_HEADER_COLOR = new Color(128, 128, 128); private static final Color BORDER_COLOR = Color.LIGHT_GRAY; + public static final int DEFAULT_HGAP = 10; + public static final int DEFAULT_VGAP = 5; + public static final int LARGE_HGAP = 30; + public static final int LARGE_VGAP = 20; + + public static final Insets PANEL_REGULAR_INSETS = new Insets(8, 12, 8, 12); + public static final Insets PANEL_SMALL_INSETS = new Insets(5, 8, 5, 8); + // accessed only from EDT private static final HashMap ourAppleDotSamples = new HashMap(); @@ -596,18 +604,30 @@ public class UIUtil { return UIManager.getFont("OptionPane.messageFont"); } - public static Color getSeparatorShadow() { - return UIManager.getColor("Separator.shadow"); - } - public static Font getMenuFont() { return UIManager.getFont("Menu.font"); } + public static Color getSeparatorForeground() { + return UIManager.getColor("Separator.foreground"); + } + + public static Color getSeparatorBackground() { + return UIManager.getColor("Separator.background"); + } + + public static Color getSeparatorShadow() { + return UIManager.getColor("Separator.shadow"); + } + public static Color getSeparatorHighlight() { return UIManager.getColor("Separator.highlight"); } + public static Color getSeparatorColorUnderNimbus() { + return UIManager.getColor("nimbusBlueGrey"); + } + public static Border getTableFocusCellHighlightBorder() { return UIManager.getBorder("Table.focusCellHighlightBorder"); } @@ -1462,10 +1482,10 @@ public class UIUtil { public static Font getBorderFont(@NotNull FontSize size, boolean isBold) { Font defFont = getTitledBorderFont(); if (size == FontSize.SMALL) { - defFont = defFont.deriveFont(defFont.getSize() - 2f); + defFont = defFont.deriveFont(Math.max(defFont.getSize() - 2f, 11f)); } if (size == FontSize.MINI) { - defFont = defFont.deriveFont(defFont.getSize() - 4f); + defFont = defFont.deriveFont(Math.max(defFont.getSize() - 4f, 9f)); } if (isBold) { defFont = defFont.deriveFont(Font.BOLD);