titled borders. fixes with colors of line and font size at least 11 points.

This commit is contained in:
Evgeny Zakrevsky
2011-09-08 21:04:37 +04:00
parent d0e49d31bf
commit 4cb498906c
2 changed files with 49 additions and 9 deletions
@@ -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() {
@@ -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<Color, BufferedImage> ourAppleDotSamples = new HashMap<Color, BufferedImage>();
@@ -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);