Browse Source

mass update

master
Konstantin Bulenkov 11 years ago
parent
commit
10f0834bf7
  1. 0
      .idea/.name
  2. 0
      .idea/codeStyleSettings.xml
  3. 0
      .idea/compiler.xml
  4. 4
      .idea/copyright/profiles_settings.xml
  5. 6
      .idea/dictionaries/kb.xml
  6. 0
      .idea/encodings.xml
  7. 12
      .idea/inspectionProfiles/Project_Default.xml
  8. 7
      .idea/inspectionProfiles/profiles_settings.xml
  9. 9
      .idea/libraries/IconLoader.xml
  10. 0
      .idea/misc.xml
  11. 0
      .idea/modules.xml
  12. 2
      .idea/runConfigurations/SwingSet2.xml
  13. 0
      .idea/scopes/scope_settings.xml
  14. 0
      .idea/uiDesigner.xml
  15. 0
      .idea/vcs.xml
  16. 1
      Darcula.iml
  17. BIN
      lib/SwingSet2.jar
  18. BIN
      lib/iconloader.jar
  19. 2
      src/com/bulenkov/darcula/DarculaDefaultTableHeaderRenderer.java
  20. 38
      src/com/bulenkov/darcula/DarculaLaf.java
  21. 15
      src/com/bulenkov/darcula/DarculaLookAndFeelInfo.java
  22. 2
      src/com/bulenkov/darcula/DarculaTableHeaderBorder.java
  23. 6
      src/com/bulenkov/darcula/DarculaTableHeaderUI.java
  24. 240
      src/com/bulenkov/darcula/DarculaUIUtil.java
  25. 10
      src/com/bulenkov/darcula/darcula.css
  26. 62
      src/com/bulenkov/darcula/darcula.properties
  27. 0
      src/com/bulenkov/darcula/darcula_linux.properties
  28. 0
      src/com/bulenkov/darcula/darcula_mac.properties
  29. 10
      src/com/bulenkov/darcula/darcula_windows.properties
  30. 19
      src/com/bulenkov/darcula/ui/DarculaButtonPainter.java
  31. 83
      src/com/bulenkov/darcula/ui/DarculaButtonUI.java
  32. 4
      src/com/bulenkov/darcula/ui/DarculaCheckBoxBorder.java
  33. 83
      src/com/bulenkov/darcula/ui/DarculaCheckBoxUI.java
  34. 268
      src/com/bulenkov/darcula/ui/DarculaComboBoxUI.java
  35. 0
      src/com/bulenkov/darcula/ui/DarculaEditorPaneUI.java
  36. 42
      src/com/bulenkov/darcula/ui/DarculaInternalBorder.java
  37. 55
      src/com/bulenkov/darcula/ui/DarculaInternalFrameUI.java
  38. 9
      src/com/bulenkov/darcula/ui/DarculaMenuBarBorder.java
  39. 0
      src/com/bulenkov/darcula/ui/DarculaMenuItemBorder.java
  40. 0
      src/com/bulenkov/darcula/ui/DarculaPanelUI.java
  41. 2
      src/com/bulenkov/darcula/ui/DarculaPasswordFieldUI.java
  42. 0
      src/com/bulenkov/darcula/ui/DarculaPopupMenuBorder.java
  43. 0
      src/com/bulenkov/darcula/ui/DarculaProgressBarBorder.java
  44. 28
      src/com/bulenkov/darcula/ui/DarculaProgressBarUI.java
  45. 47
      src/com/bulenkov/darcula/ui/DarculaRadioButtonUI.java
  46. 1023
      src/com/bulenkov/darcula/ui/DarculaRootPaneUI.java
  47. 57
      src/com/bulenkov/darcula/ui/DarculaScrollBarUI.java
  48. 36
      src/com/bulenkov/darcula/ui/DarculaSpinnerBorder.java
  49. 16
      src/com/bulenkov/darcula/ui/DarculaSpinnerUI.java
  50. 0
      src/com/bulenkov/darcula/ui/DarculaTabbedPaneUI.java
  51. 607
      src/com/bulenkov/darcula/ui/DarculaTest.form
  52. 20
      src/com/bulenkov/darcula/ui/DarculaTextBorder.java
  53. 153
      src/com/bulenkov/darcula/ui/DarculaTextFieldUI.java
  54. 729
      src/com/bulenkov/darcula/ui/DarculaTitlePane.java
  55. 423
      src/com/bulenkov/darcula/ui/DarculaTreeUI.java
  56. 0
      src/com/bulenkov/darcula/ui/win/DarculaWindowsInternalFrameUI.java
  57. 0
      src/com/bulenkov/darcula/util/Animator.java
  58. 11
      src/com/bulenkov/darcula/util/DarculaColors.java
  59. 142
      src/com/bulenkov/darcula/util/StringUtil.java
  60. 39
      src/com/bulenkov/darcula/util/UIUtil.java
  61. 0
      swingset2/AquaTheme.java
  62. 0
      swingset2/BezierAnimationPanel.java
  63. 0
      swingset2/ButtonDemo.java
  64. 0
      swingset2/CharcoalTheme.java
  65. 0
      swingset2/CodeViewer.java
  66. 0
      swingset2/ColorChooserDemo.java
  67. 0
      swingset2/ComboBoxDemo.java
  68. 0
      swingset2/ContrastTheme.java
  69. 0
      swingset2/DemoModule.java
  70. 0
      swingset2/DirectionPanel.java
  71. 0
      swingset2/EmeraldTheme.java
  72. 0
      swingset2/ExampleFileFilter.java
  73. 0
      swingset2/ExampleFileView.java
  74. 0
      swingset2/FileChooserDemo.java
  75. 0
      swingset2/HtmlDemo.java
  76. 0
      swingset2/InternalFrameDemo.java
  77. 0
      swingset2/LayoutControlPanel.java
  78. 0
      swingset2/ListDemo.java
  79. 0
      swingset2/OptionPaneDemo.java
  80. 0
      swingset2/Permuter.java
  81. 0
      swingset2/ProgressBarDemo.java
  82. 0
      swingset2/RubyTheme.java
  83. 0
      swingset2/ScrollPaneDemo.java
  84. 0
      swingset2/SliderDemo.java
  85. 0
      swingset2/SplitPaneDemo.java
  86. 22
      swingset2/SwingSet2.java
  87. 0
      swingset2/SwingSet2Applet.java
  88. 0
      swingset2/TabbedPaneDemo.java
  89. 0
      swingset2/TableDemo.java
  90. 15
      swingset2/ToolTipDemo.java
  91. 0
      swingset2/TreeDemo.java
  92. 0
      swingset2/resources/ant.html
  93. 0
      swingset2/resources/bug.html
  94. 0
      swingset2/resources/images/About.jpg
  95. 0
      swingset2/resources/images/ImageClub/COPYRIGHT
  96. 0
      swingset2/resources/images/ImageClub/food/apple.jpg
  97. 0
      swingset2/resources/images/ImageClub/food/asparagus.jpg
  98. 0
      swingset2/resources/images/ImageClub/food/banana.jpg
  99. 0
      swingset2/resources/images/ImageClub/food/broccoli.jpg
  100. 0
      swingset2/resources/images/ImageClub/food/cantaloupe.jpg
  101. Some files were not shown because too many files have changed in this diff Show More

0
.idea/.name

0
.idea/codeStyleSettings.xml

0
.idea/compiler.xml

4
.idea/copyright/profiles_settings.xml

@ -1,5 +1,3 @@
<component name="CopyrightManager"> <component name="CopyrightManager">
<settings default=""> <settings default="" />
<module2copyright />
</settings>
</component> </component>

6
.idea/dictionaries/kb.xml

@ -1,3 +1,7 @@
<component name="ProjectDictionaryState"> <component name="ProjectDictionaryState">
<dictionary name="kb" /> <dictionary name="kb">
<words>
<w>darcula</w>
</words>
</dictionary>
</component> </component>

0
.idea/encodings.xml

12
.idea/inspectionProfiles/Project_Default.xml

@ -0,0 +1,12 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
<option name="myLocal" value="false" />
<inspection_tool class="UnusedDeclaration" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ADD_MAINS_TO_ENTRIES" value="true" />
<option name="ADD_APPLET_TO_ENTRIES" value="true" />
<option name="ADD_SERVLET_TO_ENTRIES" value="true" />
<option name="ADD_NONJAVA_TO_ENTRIES" value="true" />
</inspection_tool>
</profile>
</component>

7
.idea/inspectionProfiles/profiles_settings.xml

@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>

9
.idea/libraries/IconLoader.xml

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="IconLoader">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/iconloader.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

0
.idea/misc.xml

0
.idea/modules.xml

2
.idea/runConfigurations/SwingSet2.xml

@ -17,7 +17,9 @@
<option name="TRANSPORT" value="0" /> <option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" /> <option name="LOCAL" value="true" />
</RunnerSettings> </RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" /> <ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method /> <method />
</configuration> </configuration>
</component> </component>

0
.idea/scopes/scope_settings.xml

0
.idea/uiDesigner.xml

0
.idea/vcs.xml

1
Darcula.iml

@ -8,6 +8,7 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="IconLoader" level="project" />
</component> </component>
</module> </module>

BIN
lib/SwingSet2.jar

Binary file not shown.

BIN
lib/iconloader.jar

Binary file not shown.

2
src/com/bulenkov/darcula/DarculaDefaultTableHeaderRenderer.java

@ -1,4 +1,4 @@
package com.intellij.ide.ui.laf.darcula; package com.bulenkov.darcula;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;

38
src/com/bulenkov/darcula/DarculaLaf.java

@ -1,23 +1,8 @@
/*
* Copyright 2000-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bulenkov.darcula; package com.bulenkov.darcula;
import com.bulenkov.darcula.util.ColorUtil; import com.bulenkov.iconloader.util.ColorUtil;
import com.bulenkov.darcula.util.StringUtil; import com.bulenkov.iconloader.util.StringUtil;
import com.bulenkov.darcula.util.UIManagerUtil; import com.bulenkov.iconloader.util.SystemInfo;
import sun.awt.AppContext; import sun.awt.AppContext;
import javax.swing.*; import javax.swing.*;
@ -30,8 +15,6 @@ import javax.swing.text.DefaultEditorKit;
import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet; import javax.swing.text.html.StyleSheet;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.*; import java.io.*;
@ -75,21 +58,11 @@ public final class DarculaLaf extends BasicLookAndFeel {
@SuppressWarnings("UnusedParameters") @SuppressWarnings("UnusedParameters")
private static void log(Exception e) { private static void log(Exception e) {
//everything is gonna be alright //everything is gonna be alright
e.printStackTrace(); //e.printStackTrace();
} }
@Override @Override
public UIDefaults getDefaults() { public UIDefaults getDefaults() {
final Timer[] timer = new Timer[1];
timer[0] = new Timer(2000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UIManagerUtil.showInfo();
timer[0].stop();
}
});
timer[0].start();
try { try {
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
superMethod.setAccessible(true); superMethod.setAccessible(true);
@ -390,7 +363,4 @@ public final class DarculaLaf extends BasicLookAndFeel {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), pasteActionKey); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), pasteActionKey);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), DefaultEditorKit.cutAction); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK), DefaultEditorKit.cutAction);
} }
} }

15
src/com/bulenkov/darcula/DarculaLookAndFeelInfo.java

@ -1,18 +1,3 @@
/*
* Copyright 2000-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bulenkov.darcula; package com.bulenkov.darcula;
import javax.swing.*; import javax.swing.*;

2
src/com/bulenkov/darcula/DarculaTableHeaderBorder.java

@ -15,7 +15,7 @@ public class DarculaTableHeaderBorder implements Border, UIResource {
@Override @Override
public Insets getBorderInsets(Component c) { public Insets getBorderInsets(Component c) {
return new Insets(0, 0, 0, 0); return new Insets(0,0,0,0);
} }
@Override @Override

6
src/com/bulenkov/darcula/DarculaTableHeaderUI.java

@ -15,9 +15,9 @@
*/ */
package com.bulenkov.darcula; package com.bulenkov.darcula;
import com.bulenkov.darcula.util.ColorUtil; import com.bulenkov.iconloader.util.ColorUtil;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.Gray;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;

240
src/com/bulenkov/darcula/DarculaUIUtil.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,40 +15,41 @@
*/ */
package com.bulenkov.darcula; package com.bulenkov.darcula;
import com.bulenkov.darcula.util.ColorUtil; import com.bulenkov.iconloader.util.ColorUtil;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.DoubleColor;
import com.bulenkov.iconloader.util.SystemInfo;
import com.bulenkov.iconloader.util.UIUtil;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
import java.awt.geom.GeneralPath;
/** /**
* @author Konstantin Bulenkov * @author Konstantin Bulenkov
*/ */
public class DarculaUIUtil { public class DarculaUIUtil {
public static final Color GLOW_COLOR = new Color(96, 175, 255); public static final Color GLOW_COLOR = new DoubleColor(new Color(96, 132, 212), new Color(96, 175, 255));
public static final boolean USE_QUARTZ = "true".equals(System.getProperty("apple.awt.graphics.UseQuartz"));
public static final String MAC_FILL_BORDER = "MAC_FILL_BORDER";
public static final int MAC_COMBO_BORDER_V_OFFSET = SystemInfo.isMacOSLion ? 1 : 0;
private static Cursor INVERTED_TEXT_CURSOR;
public static void paintFocusRing(Graphics g, int x, int y, int width, int height) { public static void paintFocusRing(Graphics g, int x, int y, int width, int height) {
paintFocusRing((Graphics2D)g, GLOW_COLOR, new Rectangle(x, y, width, height)); paintFocusRing((Graphics2D) g, getGlow(), new Rectangle(x, y, width, height));
} }
public static void paintFocusOval(Graphics g, int x, int y, int width, int height) { public static void paintFocusOval(Graphics g, int x, int y, int width, int height) {
paintFocusRing((Graphics2D)g, GLOW_COLOR, new Rectangle(x, y, width, height), true); paintFocusRing((Graphics2D) g, getGlow(), new Rectangle(x, y, width, height), true);
} }
public static final boolean USE_QUARTZ = "true".equals(System.getProperty("apple.awt.graphics.UseQuartz")); private static Color getGlow() {
public static final String MAC_FILL_BORDER = "MAC_FILL_BORDER"; return new DoubleColor(new Color(35, 121, 212), new Color(96, 175, 255));
public static final int MAC_COMBO_BORDER_V_OFFSET = SystemInfo.isMacOSLion ? 1 : 0; }
private static Cursor INVERTED_TEXT_CURSOR;
public static void paintFocusRing(Graphics2D g2d, Color ringColor, Rectangle bounds) { public static void paintFocusRing(Graphics2D g2d, Color ringColor, Rectangle bounds) {
paintFocusRing(g2d, ringColor, bounds, false); paintFocusRing(g2d, ringColor, bounds, false);
} }
public static void paintFocusRing(Graphics2D g, Color ringColor, Rectangle bounds, boolean oval) { public static void paintFocusRing(Graphics2D g, Color ringColor, Rectangle bounds, boolean oval) {
int correction = 50; int correction = UIUtil.isUnderDarcula() ? 50 : 0;
final Color[] colors = new Color[]{ final Color[] colors = new Color[]{
ColorUtil.toAlpha(ringColor, 180 - correction), ColorUtil.toAlpha(ringColor, 180 - correction),
ColorUtil.toAlpha(ringColor, 120 - correction), ColorUtil.toAlpha(ringColor, 120 - correction),
@ -99,202 +100,45 @@ public class DarculaUIUtil {
} }
} }
public static void drawToolbarDecoratorBackground(Graphics g2, int width, int height) { public static void paintSearchFocusRing(Graphics2D g, Rectangle bounds) {
final Graphics2D g = (Graphics2D)g2; int correction = UIUtil.isUnderDarcula() ? 50 : 0;
final int h1 = height / 2; final Color[] colors = new Color[]{
g.setPaint(new GradientPaint(0,0, Gray._247, 0, h1, Gray._240)); ColorUtil.toAlpha(getGlow(), 180 - correction),
g.fillRect(0, 0, width, h1); ColorUtil.toAlpha(getGlow(), 120 - correction),
g.setPaint(new GradientPaint(0,h1, Gray._229, 0, height, Gray._234)); ColorUtil.toAlpha(getGlow(), 70 - correction),
g.fillRect(0, h1, width, height); ColorUtil.toAlpha(getGlow(), 100 - correction),
} ColorUtil.toAlpha(getGlow(), 50 - correction)
};
public static class EditorTextFieldBorder implements Border {
private JComponent myEnabledComponent;
public EditorTextFieldBorder(final JComponent enabledComponent) {
myEnabledComponent = enabledComponent;
}
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
final int x1 = x + 3;
final int y1 = y + 3;
final int width1 = width - 8;
final int height1 = height - 6;
if (c.isOpaque() || (c instanceof JComponent && ((JComponent)c).getClientProperty(MAC_FILL_BORDER) == Boolean.TRUE)) {
g.setColor(UIManager.getColor("Panel.background"));
g.fillRect(x, y, width, height);
}
g.setColor(c.getBackground());
g.fillRect(x1, y1, width1, height1);
if (!myEnabledComponent.isEnabled()) {
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
}
g.setColor(new Color(100, 100, 100, 200));
g.drawLine(x1, y1, x1 + width1 - 1, y1);
g.setColor(new Color(212, 212, 212, 200));
g.drawLine(x1, y1 + 1, x1 + width1 - 1, y1 + 1);
g.setColor(Gray._225);
g.drawLine(x1 + 1, y1 + height1 - 1, x1 + width1 - 2, y1 + height1 - 1);
g.setColor(new Color(30, 30, 30, 70));
g.drawLine(x1, y1, x1, y1 + height1 - 1);
g.drawLine(x1 + width1 - 1, y1, x1 + width1 - 1, y1 + height1 - 1);
g.setColor(new Color(30, 30, 30, 10));
g.drawLine(x1 + 1, y1, x1 + 1, y1 + height1 - 1);
g.drawLine(x1 + width1 - 2, y1, x1 + width1 - 2, y1 + height1 - 1);
if (myEnabledComponent.isEnabled() && myEnabledComponent.isVisible() && hasFocus(myEnabledComponent)) {
paintTextFieldFocusRing((Graphics2D) g, new Rectangle(x1, y1, width1, height1));
}
}
private static boolean hasFocus(final Component toCheck) {
if (toCheck.hasFocus()) return true;
if (toCheck instanceof JComponent) {
final JComponent c = (JComponent)toCheck;
for (int i = 0; i < c.getComponentCount(); i++) {
final boolean b = hasFocus(c.getComponent(i));
if (b) return true;
}
}
return false;
}
final Object oldAntialiasingValue = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
final Object oldStrokeControlValue = g.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
@Override g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
public Insets getBorderInsets(Component c) { g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
return new Insets(6, 7, 6, 7);
}
@Override
public boolean isBorderOpaque() {
return true;
}
}
public static Color getFocusRingColor() { final Rectangle r = new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 6, bounds.height + 6);
final Object o = UIManager.get("Focus.color");
if (o instanceof Color) {
return (Color)o;
}
return new Color(64, 113, 167); g.setColor(colors[0]);
} g.drawRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, r.height - 5, r.height - 5);
public static void paintTextFieldFocusRing(final Graphics2D g2d, final Rectangle bounds) { g.setColor(colors[1]);
paintFocusRing(g2d, getFocusRingColor(), bounds); g.drawRoundRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3, r.height - 3, r.height - 3);
}
public static void paintComboboxFocusRing(final Graphics2D g2d, final Rectangle bounds) { g.setColor(colors[2]);
final Color color = getFocusRingColor(); g.drawRoundRect(r.x, r.y, r.width - 1, r.height - 1, r.height - 1, r.height - 1);
final Color[] colors = new Color[]{
ColorUtil.toAlpha(color, 180),
ColorUtil.toAlpha(color, 130),
ColorUtil.toAlpha(color, 80),
ColorUtil.toAlpha(color, 80)
};
final Object oldAntialiasingValue = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
final Object oldStrokeControlValue = g2d.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(colors[3]);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, g.drawRoundRect(r.x+3, r.y+3, r.width - 7, r.height - 7, r.height - 7, r.height - 7);
USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
int _y = MAC_COMBO_BORDER_V_OFFSET; g.setColor(colors[4]);
g.drawRoundRect(r.x+4, r.y+4, r.width - 9, r.height - 9, r.height - 9, r.height - 9);
final GeneralPath path1 = new GeneralPath();
path1.moveTo(2, _y + 4);
path1.quadTo(2, +_y + 2, 4, _y + 2);
path1.lineTo(bounds.width - 7, _y + 2);
path1.quadTo(bounds.width - 5, _y + 3, bounds.width - 4, _y + 5);
path1.lineTo(bounds.width - 4, bounds.height - 7 + _y);
path1.quadTo(bounds.width - 5, bounds.height - 5 + _y, bounds.width - 7, bounds.height - 4 + _y);
path1.lineTo(4, bounds.height - 4 + _y);
path1.quadTo(2, bounds.height - 4 + _y, 2, bounds.height - 6 + _y);
path1.closePath();
g2d.setColor(colors[0]);
g2d.draw(path1);
final GeneralPath path2 = new GeneralPath();
path2.moveTo(1, 5 + _y);
path2.quadTo(1, 1 + _y, 5, 1 + _y);
path2.lineTo(bounds.width - 8, 1 + _y);
path2.quadTo(bounds.width - 4, 2 + _y, bounds.width - 3, 6 + _y);
path2.lineTo(bounds.width - 3, bounds.height - 7 + _y);
path2.quadTo(bounds.width - 4, bounds.height - 4 + _y, bounds.width - 8, bounds.height - 3 + _y);
path2.lineTo(4, bounds.height - 3 + _y);
path2.quadTo(1, bounds.height - 3 + _y, 1, bounds.height - 6 + _y);
path2.closePath();
g2d.setColor(colors[1]);
g2d.draw(path2);
final GeneralPath path3 = new GeneralPath();
path3.moveTo(0, 4 + _y);
path3.quadTo(0, _y, 7, _y);
path3.lineTo(bounds.width - 9, _y);
path3.quadTo(bounds.width - 2, 1 + _y, bounds.width - 2, 7 + _y);
path3.lineTo(bounds.width - 2, bounds.height - 8 + _y);
path3.quadTo(bounds.width - 3, bounds.height - 1 + _y, bounds.width - 12, bounds.height - 2 + _y);
path3.lineTo(7, bounds.height - 2 + _y);
path3.quadTo(0, bounds.height - 1 + _y, 0, bounds.height - 7 + _y);
path3.closePath();
g2d.setColor(colors[2]);
g2d.draw(path3);
// restore rendering hints // restore rendering hints
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
} }
// public static void drawComboboxFocusRing(final JComboBox combobox, final Graphics g) {
// if (SystemInfo.isMac && combobox.isEnabled() && combobox.isEditable() && UIUtil.isUnderAquaLookAndFeel()) {
// final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
// if (focusOwner != null) {
// final Container ancestor = SwingUtilities.getAncestorOfClass(JComboBox.class, focusOwner);
// if (ancestor == combobox) {
// paintComboboxFocusRing((Graphics2D)g, combobox.getBounds());
// }
// }
// }
// }
// public static void doNotFillBackground(final JTree tree, final DefaultTreeCellRenderer renderer) {
// TreeUI ui = tree.getUI();
// if (ui instanceof WideSelectionTreeUI) {
// if (((WideSelectionTreeUI)ui).isWideSelection()) {
// renderer.setOpaque(false);
// try {
// final Field fillBackground = DefaultTreeCellRenderer.class.getDeclaredField("fillBackground");
// fillBackground.setAccessible(true);
// fillBackground.set(renderer, false);
// }
// catch (Exception e) {
// // nothing
// }
// }
// }
// }
// public static Cursor getInvertedTextCursor() {
// if (INVERTED_TEXT_CURSOR == null) {
// final Toolkit toolkit = Toolkit.getDefaultToolkit();
// Image cursorImage = toolkit.createImage(MacUIUtil.class.getClassLoader().getResource("/mac/text.gif"));
// INVERTED_TEXT_CURSOR = toolkit.createCustomCursor(cursorImage, new Point(15, 13), "InvertedTextCursor");
// }
// return INVERTED_TEXT_CURSOR;
// }
} }

10
src/com/bulenkov/darcula/darcula.css

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -354,6 +354,14 @@ caption {
text-align: center text-align: center
} }
table {
border: none;
}
td {
border: none;
}
nobr { nobr {
white-space: nowrap white-space: nowrap
} }

62
src/com/bulenkov/darcula/darcula.properties

@ -5,23 +5,18 @@ darcula.foreground=bbbbbb
darcula.textForeground=bbbbbb darcula.textForeground=bbbbbb
darcula.caretForeground=bbbbbb darcula.caretForeground=bbbbbb
darcula.inactiveBackground=3C3F41 darcula.inactiveBackground=3C3F41
darcula.highlight=3C3F41 darcula.selectionForeground=ffffff
darcula.light=3C3F41 darcula.selectionBackgroundInactive=0D293E
darcula.selectionInactiveBackground=0D293E
darcula.selectionForegroundInactive=bbbbbb
darcula.selectionInactiveForeground=bbbbbb
window=3c3f41 window=3c3f41
info=3c3f41
controlLtHighlight=3c3f41
controlHighlight=3c3f41
menu=3c3f41
desktop=3c3f41
text=bbbbbb text=bbbbbb
textText=bbbbbb textText=bbbbbb
infoText=bbbbbb infoText=bbbbbb
activeCaption=3c3f41
OptionPane.messageForeground=bbbbbb OptionPane.messageForeground=bbbbbb
TitledBorder.titleColor=bbbbbb
Menu.maxGutterIconWidth=18 Menu.maxGutterIconWidth=18
MenuItem.maxGutterIconWidth=18 MenuItem.maxGutterIconWidth=18
MenuItem.acceleratorDelimiter=- MenuItem.acceleratorDelimiter=-
@ -44,14 +39,18 @@ Table.descendingSortIcon=AllIcons.General.SplitDown
#just to suppress border painters #just to suppress border painters
TableHeader.cellBorder=com.bulenkov.darcula.DarculaTableHeaderBorder TableHeader.cellBorder=com.bulenkov.darcula.DarculaTableHeaderBorder
TitledBorder.titleColor=bbbbbb
MenuBar.disabledBackground=3c3f41 MenuBar.disabledBackground=3c3f41
MenuBar.shadow=3c3f41 MenuBar.shadow=3c3f41
MenuBar.darcula.borderColor=555555
MenuBar.darcula.borderShadowColor=282828
TabbedPaneUI=com.bulenkov.darcula.ui.DarculaTabbedPaneUI TabbedPaneUI=com.bulenkov.darcula.ui.DarculaTabbedPaneUI
TabbedPane.tabInsets=0,4,0,4 TabbedPane.tabInsets=0,4,0,4
TabbedPane.highlight=292b2d TabbedPane.highlight=292b2d
TabbedPane.light=444444 TabbedPane.light=444444
TabbedPane.selected=626262 TabbedPane.selected=41516D
TabbedPane.selectHighlight=3c3f41 TabbedPane.selectHighlight=3c3f41
TabbedPane.contentBorderInsets=3,1,1,1 TabbedPane.contentBorderInsets=3,1,1,1
TabbedPane.darkShadow=292b2d TabbedPane.darkShadow=292b2d
@ -64,6 +63,11 @@ Focus.color=ff0000
TextField.background=45494A TextField.background=45494A
TextFieldUI=com.bulenkov.darcula.ui.DarculaTextFieldUI TextFieldUI=com.bulenkov.darcula.ui.DarculaTextFieldUI
TextField.border=com.bulenkov.darcula.ui.DarculaTextBorder TextField.border=com.bulenkov.darcula.ui.DarculaTextBorder
TextField.darcula.search.icon=/com/intellij/ide/ui/laf/darcula/icons/search.png
TextField.darcula.searchWithHistory.icon=/com/intellij/ide/ui/laf/darcula/icons/searchWithHistory.png
TextField.darcula.clear.icon=/com/intellij/ide/ui/laf/darcula/icons/clear.png
TextArea.selectionForeground=bbbbbb
PasswordField.background=45494A PasswordField.background=45494A
PasswordFieldUI=com.bulenkov.darcula.ui.DarculaPasswordFieldUI PasswordFieldUI=com.bulenkov.darcula.ui.DarculaPasswordFieldUI
PasswordField.border=com.bulenkov.darcula.ui.DarculaTextBorder PasswordField.border=com.bulenkov.darcula.ui.DarculaTextBorder
@ -78,12 +82,31 @@ TextArea.background=45494A
CheckBoxUI=com.bulenkov.darcula.ui.DarculaCheckBoxUI CheckBoxUI=com.bulenkov.darcula.ui.DarculaCheckBoxUI
CheckBox.border=com.bulenkov.darcula.ui.DarculaCheckBoxBorder CheckBox.border=com.bulenkov.darcula.ui.DarculaCheckBoxBorder
CheckBox.darcula.inactiveFillColor=282828b4
CheckBox.darcula.borderColor1=7878785a
CheckBox.darcula.borderColor2=78787869
CheckBox.darcula.disabledBorderColor1=7878785a
CheckBox.darcula.disabledBorderColor2=78787869
CheckBox.darcula.backgroundColor1=6e6e6e
CheckBox.darcula.backgroundColor2=5f5f5f
CheckBox.darcula.checkSignColor=aaaaaa
CheckBox.darcula.checkSignColorDisabled=787878
CheckBox.darcula.shadowColor=1e1e1e
CheckBox.darcula.shadowColorDisabled=3c3c3c
CheckBox.darcula.focusedArmed.backgroundColor1=646464
CheckBox.darcula.focusedArmed.backgroundColor2=373737
CheckBox.darcula.focused.backgroundColor1=787878
CheckBox.darcula.focused.backgroundColor2=4b4b4b
ComboBoxUI=com.bulenkov.darcula.ui.DarculaComboBoxUI ComboBoxUI=com.bulenkov.darcula.ui.DarculaComboBoxUI
ComboBox.disabledBackground=3c3f41 ComboBox.disabledBackground=3c3f41
ComboBox.squareButton=false ComboBox.squareButton=false
RadioButtonUI=com.bulenkov.darcula.ui.DarculaRadioButtonUI RadioButtonUI=com.bulenkov.darcula.ui.DarculaRadioButtonUI
RadioButton.darcula.selectionEnabledColor=aaaaaa
RadioButton.darcula.selectionDisabledColor=787878
RadioButton.darcula.selectionEnabledShadowColor=1e1e1e
RadioButton.darcula.selectionDisabledShadowColor=3c3c3c
StatusBar.topColor=2c2c2c StatusBar.topColor=2c2c2c
StatusBar.top2Color=2c2c2c StatusBar.top2Color=2c2c2c
@ -91,6 +114,13 @@ StatusBar.bottomColor=2c2c2c
Button.border=com.bulenkov.darcula.ui.DarculaButtonPainter Button.border=com.bulenkov.darcula.ui.DarculaButtonPainter
ButtonUI=com.bulenkov.darcula.ui.DarculaButtonUI ButtonUI=com.bulenkov.darcula.ui.DarculaButtonUI
Button.disabledText=777777
Button.darcula.color1=555a5c
Button.darcula.color2=414648
Button.darcula.selection.color1=384f6b
Button.darcula.selection.color2=233143
Button.darcula.selectedButtonForeground=bbbbbb
Button.darcula.disabledText.shadow=00000000
MenuItem.acceleratorForeground=eeeeee MenuItem.acceleratorForeground=eeeeee
PopupMenu.translucentBackground=3c3f41 PopupMenu.translucentBackground=3c3f41
@ -103,7 +133,17 @@ Spinner.background=3c3f41
Spinner.arrowButtonInsets=1,1,1,1 Spinner.arrowButtonInsets=1,1,1,1
Spinner.editorBorderPainted=false Spinner.editorBorderPainted=false
SplitPane.highlight=3c3f41
TreeUI=com.bulenkov.darcula.ui.DarculaTreeUI
Hyperlink.linkColor=589df6 Hyperlink.linkColor=589df6
#List.background=45494A
#Table.background=45494A
#Tree.background=45494A
Tree.collapsedIcon=AllIcons.Mac.Tree_white_right_arrow Tree.collapsedIcon=AllIcons.Mac.Tree_white_right_arrow
Tree.expandedIcon=AllIcons.Mac.Tree_white_down_arrow Tree.expandedIcon=AllIcons.Mac.Tree_white_down_arrow
FileView.fileIcon=AllIcons.FileTypes.Unknown

0
src/com/bulenkov/darcula/darcula_linux.properties

0
src/com/bulenkov/darcula/darcula_mac.properties

10
src/com/bulenkov/darcula/darcula_windows.properties

@ -1,14 +1,10 @@
# suppress inspection "UnusedProperty" for whole file # suppress inspection "UnusedProperty" for whole file
darcula.selectionBackground=4B6EAF darcula.selectionBackground=4B6EAF
darcula.selectionForeground=bbbbbb darcula.selectionForeground=bbbbbb
darcula.select=0D293E
PopupMenu.border=com.bulenkov.darcula.ui.DarculaPopupMenuBorder PopupMenu.border=com.bulenkov.darcula.ui.DarculaPopupMenuBorder
MenuBarUI=com.bulenkov.darcula.ui.DarculaMenuBarUI
MenuBar.border=com.bulenkov.darcula.ui.DarculaMenuBarBorder MenuBar.border=com.bulenkov.darcula.ui.DarculaMenuBarBorder
#InternalFrameUI=com.bulenkov.darcula.ui.DarculaInternalFrameUI
ToolBarUI=com.bulenkov.darcula.ui.DarculaToolBarUI #InternalFrame.border=com.bulenkov.darcula.ui.DarculaInternalBorder
ToggleButton.shadow=0d293e #RootPaneUI=com.bulenkov.darcula.ui.DarculaRootPaneUI
#InternalFrameUI=com.bulenkov.darcula.ui.win.DarculaWindowsInternalFrameUI

19
src/com/bulenkov/darcula/ui/DarculaButtonPainter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.DarculaUIUtil; import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.Gray;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.InsetsUIResource;
@ -35,19 +35,19 @@ public class DarculaButtonPainter implements Border, UIResource {
final Graphics2D g2d = (Graphics2D)g; final Graphics2D g2d = (Graphics2D)g;
final Insets ins = getBorderInsets(c); final Insets ins = getBorderInsets(c);
final int yOff = (ins.top + ins.bottom) / 4; final int yOff = (ins.top + ins.bottom) / 4;
int offset = getOffset(); final boolean square = DarculaButtonUI.isSquare(c);
int offset = square ? 1 : getOffset();
if (c.hasFocus()) { if (c.hasFocus()) {
DarculaUIUtil.paintFocusRing(g2d, offset, yOff, width - 2 * offset, height - 2 * yOff); DarculaUIUtil.paintFocusRing(g2d, offset, yOff, width - 2 * offset, height - 2 * yOff);
} else { } else {
final GraphicsConfig config = new GraphicsConfig(g); final GraphicsConfig config = new GraphicsConfig(g);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
g2d.setPaint( g2d.setPaint(new GradientPaint(width / 2, y + yOff + 1, Gray._80.withAlpha(90), width / 2, height - 2 * yOff, Gray._90.withAlpha(90)));
new GradientPaint(width / 2, y + yOff + 1, Gray._80.withAlpha(90), width / 2, height - 2 * yOff, Gray._90.withAlpha(90)));
//g.drawRoundRect(x + offset + 1, y + yOff + 1, width - 2 * offset, height - 2*yOff, 5, 5); //g.drawRoundRect(x + offset + 1, y + yOff + 1, width - 2 * offset, height - 2*yOff, 5, 5);
((Graphics2D)g).setPaint(Gray._100.withAlpha(180)); ((Graphics2D)g).setPaint(Gray._100.withAlpha(180));
g.drawRoundRect(x + offset, y + yOff, width - 2 * offset, height - 2*yOff, 5, 5); g.drawRoundRect(x + offset, y + yOff, width - 2 * offset, height - 2*yOff, square ? 3 : 5, square ? 3 : 5);
config.restore(); config.restore();
} }
@ -55,7 +55,10 @@ public class DarculaButtonPainter implements Border, UIResource {
@Override @Override
public Insets getBorderInsets(Component c) { public Insets getBorderInsets(Component c) {
return new InsetsUIResource(6, 12, 6, 12); if (DarculaButtonUI.isSquare(c)) {
return new InsetsUIResource(2, 0, 2, 0);
}
return new InsetsUIResource(8, 16, 8, 14);
} }
protected int getOffset() { protected int getOffset() {

83
src/com/bulenkov/darcula/ui/DarculaButtonUI.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,9 +15,15 @@
*/ */
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.iconloader.util.SystemInfo;
import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.iconloader.util.GraphicsUtil;
import sun.swing.SwingUtilities2;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicButtonUI; import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*; import java.awt.*;
@ -30,20 +36,89 @@ public class DarculaButtonUI extends BasicButtonUI {
return new DarculaButtonUI(); return new DarculaButtonUI();
} }
public static boolean isSquare(Component c) {
return c instanceof JButton && "square".equals(((JButton)c).getClientProperty("JButton.buttonType"));
}
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
final Border border = c.getBorder(); final Border border = c.getBorder();
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
final boolean square = isSquare(c);
if (c.isEnabled() && border != null) { if (c.isEnabled() && border != null) {
final Insets ins = border.getBorderInsets(c); final Insets ins = border.getBorderInsets(c);
final int yOff = (ins.top + ins.bottom) / 4; final int yOff = (ins.top + ins.bottom) / 4;
if (!square) {
if (((JButton)c).isDefaultButton()) { if (((JButton)c).isDefaultButton()) {
((Graphics2D)g).setPaint(new GradientPaint(0, 0, new Color(0x384F6B), 0, c.getHeight(), new Color(0x233143))); ((Graphics2D)g).setPaint(new GradientPaint(0, 0, getSelectedButtonColor1(), 0, c.getHeight(), getSelectedButtonColor2()));
} }
else { else {
((Graphics2D)g).setPaint(new GradientPaint(0, 0, new Color(85, 90, 92), 0, c.getHeight(), new Color(65, 70, 72))); ((Graphics2D)g).setPaint(new GradientPaint(0, 0, getButtonColor1(), 0, c.getHeight(), getButtonColor2()));
}
} }
g.fillRoundRect(4, yOff, c.getWidth() - 2 * 4, c.getHeight() - 2 * yOff, 5, 5); g.fillRoundRect(square ? 2 : 4, yOff, c.getWidth() - 2 * 4, c.getHeight() - 2 * yOff, square ? 3 : 5, square ? 3 : 5);
} }
config.restore();
super.paint(g, c); super.paint(g, c);
} }
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
AbstractButton button = (AbstractButton)c;
ButtonModel model = button.getModel();
Color fg = button.getForeground();
if (fg instanceof UIResource && button instanceof JButton && ((JButton)button).isDefaultButton()) {
final Color selectedFg = UIManager.getColor("Button.darcula.selectedButtonForeground");
if (selectedFg != null) {
fg = selectedFg;
}
}
g.setColor(fg);
FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g);
int mnemonicIndex = button.getDisplayedMnemonicIndex();
if (model.isEnabled()) {
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemonicIndex,
textRect.x + getTextShiftOffset(),
textRect.y + metrics.getAscent() + getTextShiftOffset());
}
else {
g.setColor(UIManager.getColor("Button.darcula.disabledText.shadow"));
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, -1,
textRect.x + getTextShiftOffset()+1,
textRect.y + metrics.getAscent() + getTextShiftOffset()+1);
g.setColor(UIManager.getColor("Button.disabledText"));
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, -1,
textRect.x + getTextShiftOffset(),
textRect.y + metrics.getAscent() + getTextShiftOffset());
}
}
@Override
public void update(Graphics g, JComponent c) {
super.update(g, c);
if (((JButton)c).isDefaultButton() && !SystemInfo.isMac) {
if (!c.getFont().isBold()) {
c.setFont(c.getFont().deriveFont(Font.BOLD));
}
}
}
protected Color getButtonColor1() {
return UIManager.getColor("Button.darcula.color1");
}
protected Color getButtonColor2() {
return UIManager.getColor("Button.darcula.color2");
}
protected Color getSelectedButtonColor1() {
return UIManager.getColor("Button.darcula.selection.color1");
}
protected Color getSelectedButtonColor2() {
return UIManager.getColor("Button.darcula.selection.color2");
}
} }

4
src/com/bulenkov/darcula/ui/DarculaCheckBoxBorder.java

@ -15,8 +15,8 @@
*/ */
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.SystemInfo; import com.bulenkov.iconloader.util.SystemInfo;
import com.bulenkov.darcula.util.UIUtil; import com.bulenkov.iconloader.util.UIUtil;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;

83
src/com/bulenkov/darcula/ui/DarculaCheckBoxUI.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,10 +16,10 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.DarculaUIUtil; import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.darcula.util.EmptyIcon; import com.bulenkov.iconloader.util.EmptyIcon;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.Gray;
import com.bulenkov.darcula.util.UIUtil; import com.bulenkov.iconloader.util.UIUtil;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import javax.swing.*; import javax.swing.*;
@ -69,11 +69,16 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI {
viewRect, iconRect, textRect, b.getIconTextGap()); viewRect, iconRect, textRect, b.getIconTextGap());
//background //background
if(c.isOpaque()) { if (c.isOpaque()) {
g.setColor(b.getBackground()); g.setColor(b.getBackground());
g.fillRect(0,0, size.width, size.height); g.fillRect(0, 0, size.width, size.height);
} }
if (b.isSelected() && b.getSelectedIcon() != null) {
b.getSelectedIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2);
} else if (!b.isSelected() && b.getIcon() != null) {
b.getIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2);
} else {
final int x = iconRect.x + 3; final int x = iconRect.x + 3;
final int y = iconRect.y + 3; final int y = iconRect.y + 3;
final int w = iconRect.width - 6; final int w = iconRect.width - 6;
@ -93,33 +98,34 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI {
final boolean armed = b.getModel().isArmed(); final boolean armed = b.getModel().isArmed();
if (c.hasFocus()) { if (c.hasFocus()) {
g.setPaint(new GradientPaint(w/2, 1, armed ? Gray._100: Gray._120, w/2, h, armed ? Gray._55 : Gray._75)); g.setPaint(new GradientPaint(w/2, 1, getFocusedBackgroundColor1(armed), w/2, h, getFocusedBackgroundColor2(armed)));
g.fillRoundRect(0, 0, w - 2, h - 2, 4, 4); g.fillRoundRect(0, 0, w - 2, h - 2, 4, 4);
DarculaUIUtil.paintFocusRing(g, 1, 1, w - 2, h - 2); DarculaUIUtil.paintFocusRing(g, 1, 1, w - 2, h - 2);
} else { } else {
g.setPaint(new GradientPaint(w / 2, 1, Gray._110, w / 2, h, Gray._95)); g.setPaint(new GradientPaint(w / 2, 1, getBackgroundColor1(), w / 2, h, getBackgroundColor2()));
g.fillRoundRect(0, 0, w , h , 4, 4); g.fillRoundRect(0, 0, w, h - 1 , 4, 4);
g.setPaint(new GradientPaint(w / 2, 1, Gray._120.withAlpha(90), w / 2, h, Gray._105.withAlpha(90))); g.setPaint(new GradientPaint(w / 2, 1, getBorderColor1(b.isEnabled()), w / 2, h, getBorderColor2(b.isEnabled())));
g.drawRoundRect(0, 1, w, h - 1, 4, 4); g.drawRoundRect(0, (UIUtil.isUnderDarcula() ? 1 : 0), w, h - 1, 4, 4);
g.setPaint(Gray._40.withAlpha(180)); g.setPaint(getInactiveFillColor());
g.drawRoundRect(0, 0, w, h - 1, 4, 4); g.drawRoundRect(0, 0, w, h - 1, 4, 4);
} }
if (b.getModel().isSelected()) { if (b.getModel().isSelected()) {
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g.setStroke(new BasicStroke(1 *2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); g.setStroke(new BasicStroke(1 *2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
g.setPaint(b.isEnabled() ? Gray._30 : Gray._60); g.setPaint(getShadowColor(b.isEnabled()));
g.drawLine(4, 7, 7, 11); g.drawLine(4, 7, 7, 11);
g.drawLine(7, 11, w, 2); g.drawLine(7, 11, w, 2);
g.setPaint(b.isEnabled() ? Gray._170 : Gray._120); g.setPaint(getCheckSignColor(b.isEnabled()));
g.drawLine(4, 5, 7, 9); g.drawLine(4, 5, 7, 9);
g.drawLine(7, 9, w, 0); g.drawLine(7, 9, w, 0);
} }
g.translate(-x, -y); g.translate(-x, -y);
config.restore(); config.restore();
}
//text //text
if(text != null) { if(text != null) {
@ -136,6 +142,53 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI {
} }
} }
protected Color getInactiveFillColor() {
return getColor("inactiveFillColor", Gray._40.withAlpha(180));
}
protected Color getBorderColor1(boolean enabled) {
return enabled ? getColor("borderColor1", Gray._120.withAlpha(0x5a))
: getColor("disabledBorderColor1", Gray._120.withAlpha(90));
}
protected Color getBorderColor2(boolean enabled) {
return enabled ? getColor("borderColor2", Gray._105.withAlpha(90))
: getColor("disabledBorderColor2", Gray._105.withAlpha(90));
}
protected Color getBackgroundColor1() {
return getColor("backgroundColor1", Gray._110);
}
protected Color getBackgroundColor2() {
return getColor("backgroundColor2", Gray._95);
}
protected Color getCheckSignColor(boolean enabled) {
return enabled ? getColor("checkSignColor", Gray._170)
: getColor("checkSignColorDisabled", Gray._120);
}
protected Color getShadowColor(boolean enabled) {
return enabled ? getColor("shadowColor", Gray._30)
: getColor("shadowColorDisabled", Gray._60);
}
protected Color getFocusedBackgroundColor1(boolean armed) {
return armed ? getColor("focusedArmed.backgroundColor1", Gray._100)
: getColor("focused.backgroundColor1", Gray._120);
}
protected Color getFocusedBackgroundColor2(boolean armed) {
return armed ? getColor("focusedArmed.backgroundColor2", Gray._55)
: getColor("focused.backgroundColor2", Gray._75);
}
protected static Color getColor(String shortPropertyName, Color defaultValue) {
final Color color = UIManager.getColor("CheckBox.darcula." + shortPropertyName);
return color == null ? defaultValue : color;
}
@Override @Override
public Icon getDefaultIcon() { public Icon getDefaultIcon() {
return new IconUIResource(EmptyIcon.create(20)); return new IconUIResource(EmptyIcon.create(20));

268
src/com/bulenkov/darcula/ui/DarculaComboBoxUI.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,17 +16,24 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.DarculaUIUtil; import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.DoubleColor;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.iconloader.util.Gray;
import com.bulenkov.iconloader.util.UIUtil;
import sun.swing.DefaultLookup;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.DimensionUIResource;
import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicArrowButton; import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.BasicComboBoxUI;
import java.awt.*; import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.geom.Path2D; import java.awt.geom.Path2D;
/** /**
@ -35,6 +42,12 @@ import java.awt.geom.Path2D;
@SuppressWarnings("GtkPreferredJComboBoxRenderer") @SuppressWarnings("GtkPreferredJComboBoxRenderer")
public class DarculaComboBoxUI extends BasicComboBoxUI implements Border { public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
private final JComboBox myComboBox; private final JComboBox myComboBox;
// Flag for calculating the display size
private boolean myDisplaySizeDirty = true;
// Cached the size that the display needs to render the largest item
private Dimension myDisplaySizeCache = new Dimension(0, 0);
private Insets myPadding;
public DarculaComboBoxUI(JComboBox comboBox) { public DarculaComboBoxUI(JComboBox comboBox) {
super(); super();
@ -48,25 +61,12 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
} }
@Override @Override
protected ListCellRenderer createRenderer() { protected void installDefaults() {
return new BasicComboBoxRenderer.UIResource() { super.installDefaults();
@Override myPadding = UIManager.getInsets("ComboBox.padding");
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JComponent) {
final JComponent jc = (JComponent)c;
if (index == -1) {
jc.setOpaque(false);
jc.setForeground(list.getForeground());
} else {
jc.setOpaque(true);
}
}
return c;
}
};
} }
protected JButton createArrowButton() { protected JButton createArrowButton() {
final Color bg = myComboBox.getBackground(); final Color bg = myComboBox.getBackground();
final Color fg = myComboBox.getForeground(); final Color fg = myComboBox.getForeground();
@ -79,38 +79,122 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
final int w = getWidth(); final int w = getWidth();
final int h = getHeight(); final int h = getHeight();
g.setColor(UIManager.getColor("control")); if (!isTableCellEditor(myComboBox)) {
g.setColor(getArrowButtonFillColor(UIUtil.getControlColor()));
g.fillRect(0, 0, w, h); g.fillRect(0, 0, w, h);
g.setColor(myComboBox.isEnabled() ? getForeground() : getForeground().darker()); }
g.setColor(comboBox.isEnabled() ? new DoubleColor(Gray._255, getForeground()) : new DoubleColor(Gray._255, getForeground().darker()));
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
final int xU = w / 4; final int xU = w / 4;
final int yU = h / 4; final int yU = h / 4;
final Path2D.Double path = new Path2D.Double(); final Path2D.Double path = new Path2D.Double();
g.translate(1, 1); g.translate(2, 0);
path.moveTo(xU + 1, yU + 2); path.moveTo(xU + 1, yU + 2);
path.lineTo(3 * xU + 1, yU + 2); path.lineTo(3 * xU + 1, yU + 2);
path.lineTo(2 * xU + 1, 3 * yU); path.lineTo(2 * xU + 1, 3 * yU);
path.lineTo(xU + 1, yU + 2); path.lineTo(xU + 1, yU + 2);
path.closePath(); path.closePath();
g.fill(path); g.fill(path);
g.translate(-1, -1); g.translate(-2, 0);
g.setColor(getBorderColor()); if (!isTableCellEditor(myComboBox)) {
g.setColor(getArrowButtonFillColor(getBorderColor()));
g.drawLine(0, -1, 0, h); g.drawLine(0, -1, 0, h);
}
config.restore(); config.restore();
} }
@Override
public Dimension getPreferredSize() {
int size = getFont().getSize() + 4;
if (size%2==1) size++;
return new DimensionUIResource(size, size);
}
}; };
button.setBorder(BorderFactory.createEmptyBorder()); button.setBorder(BorderFactory.createEmptyBorder());
button.setOpaque(false); button.setOpaque(false);
return button; return button;
} }
protected Color getArrowButtonFillColor(Color defaultColor) {
final Color color = myComboBox.hasFocus() ? UIManager.getColor("ComboBox.darcula.arrowFocusedFillColor")
: UIManager.getColor("ComboBox.darcula.arrowFillColor");
return color == null ? defaultColor : comboBox != null && !comboBox.isEnabled() ? UIUtil.getControlColor() : color;
}
@Override @Override
protected Insets getInsets() { protected Insets getInsets() {
return new InsetsUIResource(4, 7, 4, 5); return new InsetsUIResource(4, 7, 4, 5);
} }
protected Dimension getDisplaySize() {
Dimension display = new Dimension();
ListCellRenderer renderer = comboBox.getRenderer();
if (renderer == null) {
renderer = new DefaultListCellRenderer();
}
boolean sameBaseline = true;
Object prototypeValue = comboBox.getPrototypeDisplayValue();
if (prototypeValue != null) {
display = getSizeForComponent(renderer.getListCellRendererComponent(listBox, prototypeValue, -1, false, false));
} else {
final ComboBoxModel model = comboBox.getModel();
int baseline = -1;
Dimension d;
if (model.getSize() > 0) {
for (int i = 0; i < model.getSize(); i++) {
Object value = model.getElementAt(i);
Component rendererComponent = renderer.getListCellRendererComponent(listBox, value, -1, false, false);
d = getSizeForComponent(rendererComponent);
if (sameBaseline && value != null && (!(value instanceof String) || !"".equals(value))) {
int newBaseline = rendererComponent.getBaseline(d.width, d.height);
if (newBaseline == -1) {
sameBaseline = false;
}
else if (baseline == -1) {
baseline = newBaseline;
}
else if (baseline != newBaseline) {
sameBaseline = false;
}
}
display.width = Math.max(display.width, d.width);
display.height = Math.max(display.height, d.height);
}
}
else {
display = getDefaultSize();
if (comboBox.isEditable()) {
display.width = 100;
}
}
}
if (myPadding != null) {
display.width += myPadding.left + myPadding.right;
display.height += myPadding.top + myPadding.bottom;
}
myDisplaySizeCache.setSize(display.width, display.height);
myDisplaySizeDirty = false;
return display;
}
protected Dimension getSizeForComponent(Component comp) {
currentValuePane.add(comp);
comp.setFont(comboBox.getFont());
Dimension d = comp.getPreferredSize();
currentValuePane.remove(comp);
return d;
}
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
final Container parent = c.getParent(); final Container parent = c.getParent();
@ -118,18 +202,127 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
g.setColor(parent.getBackground()); g.setColor(parent.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight()); g.fillRect(0, 0, c.getWidth(), c.getHeight());
} }
Rectangle r = rectangleForCurrentValue();
if (!isTableCellEditor(c)) {
paintBorder(c, g, 0, 0, c.getWidth(), c.getHeight()); paintBorder(c, g, 0, 0, c.getWidth(), c.getHeight());
hasFocus = comboBox.hasFocus(); hasFocus = comboBox.hasFocus();
Rectangle r = rectangleForCurrentValue();
paintCurrentValueBackground(g, r, hasFocus); paintCurrentValueBackground(g, r, hasFocus);
}
paintCurrentValue(g, r, hasFocus); paintCurrentValue(g, r, hasFocus);
} }
private static boolean isTableCellEditor(JComponent c) {
return Boolean.TRUE.equals(c.getClientProperty("JComboBox.isTableCellEditor"));
}
@Override
protected Rectangle rectangleForCurrentValue() {
final Rectangle r = super.rectangleForCurrentValue();
r.x-=2;
r.y-= isTableCellEditor(myComboBox) ? 0 : 1;
return r;
}
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) {
ListCellRenderer renderer = comboBox.getRenderer();
Component c;
if (hasFocus && !isPopupVisible(comboBox)) {
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
}
else {
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
c.setBackground(UIManager.getColor("ComboBox.background"));
}
c.setFont(comboBox.getFont());
if (hasFocus && !isPopupVisible(comboBox)) {
c.setForeground(listBox.getForeground());
c.setBackground(listBox.getBackground());
}
else {
if (comboBox.isEnabled()) {
c.setForeground(comboBox.getForeground());
c.setBackground(comboBox.getBackground());
}
else {
c.setForeground(DefaultLookup.getColor(
comboBox, this, "ComboBox.disabledForeground", null));
c.setBackground(DefaultLookup.getColor(
comboBox, this, "ComboBox.disabledBackground", null));
}
}
// paint selection in table-cell-editor mode correctly
boolean changeOpaque = c instanceof JComponent && isTableCellEditor(comboBox) && c.isOpaque();
if (changeOpaque) {
((JComponent)c).setOpaque(false);
}
boolean shouldValidate = false;
if (c instanceof JPanel) {
shouldValidate = true;
}
Rectangle r = new Rectangle(bounds);
if (myPadding != null) {
r.x += myPadding.left;
r.y += myPadding.top;
r.width -= myPadding.left + myPadding.right;
r.height -= myPadding.top + myPadding.bottom;
}
currentValuePane.paintComponent(g, c, comboBox, r.x, r.y, r.width, r.height, shouldValidate);
// return opaque for combobox popup items painting
if (changeOpaque) {
((JComponent)c).setOpaque(true);
}
}
@Override @Override
protected void installKeyboardActions() { protected void installKeyboardActions() {
super.installKeyboardActions(); super.installKeyboardActions();
} }
@Override
protected ComboBoxEditor createEditor() {
final ComboBoxEditor comboBoxEditor = super.createEditor();
if (comboBoxEditor != null && comboBoxEditor.getEditorComponent() != null) {
comboBoxEditor.getEditorComponent().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
process(e);
}
private void process(KeyEvent e) {
final int code = e.getKeyCode();
if ((code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN) && e.getModifiers() == 0) {
comboBox.dispatchEvent(e);
}
}
@Override
public void keyReleased(KeyEvent e) {
process(e);
}
});
comboBoxEditor.getEditorComponent().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
comboBox.revalidate();
comboBox.repaint();
}
@Override
public void focusLost(FocusEvent e) {
comboBox.revalidate();
comboBox.repaint();
}
});
}
return comboBoxEditor;
}
@Override @Override
public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) {
if (comboBox == null || arrowButton == null) { if (comboBox == null || arrowButton == null) {
@ -148,26 +341,29 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
((JComponent)editor).setBorder(null); ((JComponent)editor).setBorder(null);
g.setColor(editor.getBackground()); g.setColor(editor.getBackground());
g.fillRoundRect(x + 1, y + 1, width - 2, height - 4, 5, 5); g.fillRoundRect(x + 1, y + 1, width - 2, height - 4, 5, 5);
g.setColor(arrowButton.getBackground()); g.setColor(getArrowButtonFillColor(arrowButton.getBackground()));
g.fillRoundRect(xxx, y + 1, width - xxx, height - 4, 5, 5); g.fillRoundRect(xxx, y + 1, width - xxx, height - 4, 5, 5);
g.setColor(editor.getBackground()); g.setColor(editor.getBackground());
g.fillRect(xxx, y + 1, 5, height - 4); g.fillRect(xxx, y + 1, 5, height - 4);
} else { } else {
g.setColor(UIManager.getColor("Panel.background")); g.setColor(UIUtil.getPanelBackground());
g.fillRoundRect(x + 1, y + 1, width - 2, height - 4, 5, 5); g.fillRoundRect(x + 1, y + 1, width - 2, height - 4, 5, 5);
g.setColor(getArrowButtonFillColor(arrowButton.getBackground()));
g.fillRoundRect(xxx, y + 1, width - xxx, height - 4, 5, 5);
g.setColor(UIUtil.getPanelBackground());
g.fillRect(xxx, y + 1, 5, height - 4);
} }
final Color borderColor = getBorderColor();//ColorUtil.shift(UIUtil.getBorderColor(), 4); final Color borderColor = getBorderColor();//ColorUtil.shift(UIUtil.getBorderColor(), 4);
g.setColor(borderColor); g.setColor(getArrowButtonFillColor(borderColor));
int off = hasFocus ? 1 : 0; int off = hasFocus ? 1 : 0;
g.drawLine(xxx + 5, y + 1 + off, xxx + 5, height - 3); g.drawLine(xxx + 5, y + 1 + off, xxx + 5, height - 3);
Rectangle r = rectangleForCurrentValue(); Rectangle r = rectangleForCurrentValue();
paintCurrentValueBackground(g,r,hasFocus); paintCurrentValueBackground(g, r, hasFocus);
paintCurrentValue(g,r,hasFocus); paintCurrentValue(g, r, false);
if (hasFocus) { if (hasFocus) {
DarculaUIUtil.paintFocusRing(g, 2, 2, width - 4, height - 4); DarculaUIUtil.paintFocusRing(g, 2, 2, width - 4, height - 5);
} }
else { else {
g.setColor(borderColor); g.setColor(borderColor);
@ -192,8 +388,8 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
return owner != null && SwingUtilities.isDescendingFrom(owner, c); return owner != null && SwingUtilities.isDescendingFrom(owner, c);
} }
private static Gray getBorderColor() { private static Color getBorderColor() {
return Gray._100; return new DoubleColor(Gray._150, Gray._100);
} }
@Override @Override

0
src/com/bulenkov/darcula/ui/DarculaEditorPaneUI.java

42
src/com/bulenkov/darcula/ui/DarculaInternalBorder.java

@ -0,0 +1,42 @@
/*
* Copyright 2000-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bulenkov.darcula.ui;
import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
public class DarculaInternalBorder implements UIResource, Border {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(Color.ORANGE);
g.fillRect(x, y, width, height);
}
@Override
public Insets getBorderInsets(Component c) {
return new InsetsUIResource(20, 3, 3, 3);
}
@Override
public boolean isBorderOpaque() {
return false;
}
}

55
src/com/bulenkov/darcula/ui/DarculaInternalFrameUI.java

@ -0,0 +1,55 @@
/*
* Copyright 2000-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bulenkov.darcula.ui;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
public class DarculaInternalFrameUI extends BasicInternalFrameUI {
public DarculaInternalFrameUI(JInternalFrame b) {
super(b);
}
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
public static ComponentUI createUI(JComponent c) {
return new DarculaInternalFrameUI((JInternalFrame)c);
}
@Override
protected JComponent createNorthPane(JInternalFrame w) {
this.titlePane = new BasicInternalFrameTitlePane(w) {
@Override
protected void paintBorder(Graphics g) {
super.paintBorder(g);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
}
};
return this.titlePane;
}
}

9
src/com/bulenkov/darcula/ui/DarculaMenuBarBorder.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,8 +15,7 @@
*/ */
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.util.Gray; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
@ -30,10 +29,10 @@ public class DarculaMenuBarBorder implements Border, UIResource {
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.translate(x, y); g.translate(x, y);
w--;h--; w--;h--;
g.setColor(Gray._85); g.setColor(UIManager.getColor("MenuBar.darcula.borderColor"));
g.drawLine(0, h, w, h); g.drawLine(0, h, w, h);
h--; h--;
g.setColor(Gray._40); g.setColor(UIManager.getColor("MenuBar.darcula.borderShadowColor"));
g.drawLine(0, h, w, h); g.drawLine(0, h, w, h);
g.translate(-x, -y); g.translate(-x, -y);
} }

0
src/com/bulenkov/darcula/ui/DarculaMenuItemBorder.java

0
src/com/bulenkov/darcula/ui/DarculaPanelUI.java

2
src/com/bulenkov/darcula/ui/DarculaPasswordFieldUI.java

@ -15,7 +15,7 @@
*/ */
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.GraphicsConfig;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;

0
src/com/bulenkov/darcula/ui/DarculaPopupMenuBorder.java

0
src/com/bulenkov/darcula/ui/DarculaProgressBarBorder.java

28
src/com/bulenkov/darcula/ui/DarculaProgressBarUI.java

@ -15,8 +15,9 @@
*/ */
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.util.GraphicsUtil; import com.bulenkov.iconloader.util.DoubleColor;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.GraphicsUtil;
import com.bulenkov.iconloader.util.Gray;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import javax.swing.*; import javax.swing.*;
@ -53,14 +54,15 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
return; return;
} }
//boxRect = getBox(boxRect); //boxRect = getBox(boxRect);
g.setColor(Gray._128); g.setColor(new DoubleColor(Gray._240, Gray._128));
int w = c.getWidth(); int w = c.getWidth();
int h = c.getHeight(); int h = c.getPreferredSize().height;
g.fillRect(0, 0, w, h); g.fillRect(0, (c.getHeight() - h)/2, w, h);
g.setColor(Gray._88); g.setColor(new DoubleColor(Gray._165, Gray._88));
GraphicsUtil.setupAAPainting(g); GraphicsUtil.setupAAPainting(g);
Path2D.Double path = new Path2D.Double(); Path2D.Double path = new Path2D.Double();
int ww = getPeriodLength() / 2; int ww = getPeriodLength() / 2;
g.translate(0, (c.getHeight() - h) / 2);
path.moveTo(0, 0); path.moveTo(0, 0);
path.lineTo(ww, 0); path.lineTo(ww, 0);
path.lineTo(ww - h / 2, h); path.lineTo(ww - h / 2, h);
@ -79,10 +81,11 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
area.subtract(new Area(new RoundRectangle2D.Double(1,1,w-2, h-2, 8,8))); area.subtract(new Area(new RoundRectangle2D.Double(1,1,w-2, h-2, 8,8)));
((Graphics2D)g).setPaint(Gray._128); ((Graphics2D)g).setPaint(Gray._128);
((Graphics2D)g).fill(area); ((Graphics2D)g).fill(area);
area.subtract(new Area(new RoundRectangle2D.Double(0,0,w, h, 9,9))); area.subtract(new Area(new RoundRectangle2D.Double(0, 0, w, h, 9, 9)));
((Graphics2D)g).setPaint(c.getParent().getBackground()); ((Graphics2D)g).setPaint(c.getParent().getBackground());
((Graphics2D)g).fill(area); ((Graphics2D)g).fill(area);
g.drawRoundRect(1,1, w-3, h-3, 8,8); g.drawRoundRect(1, 1, w - 3, h - 3, 8, 8);
g.translate(0, -(c.getHeight() - h) / 2);
// Deal with possible text painting // Deal with possible text painting
if (progressBar.isStringPainted()) { if (progressBar.isStringPainted()) {
@ -108,7 +111,7 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
GraphicsUtil.setupAAPainting(g); GraphicsUtil.setupAAPainting(g);
Insets b = progressBar.getInsets(); // area for border Insets b = progressBar.getInsets(); // area for border
final int w = progressBar.getWidth(); final int w = progressBar.getWidth();
final int h = progressBar.getHeight(); final int h = progressBar.getPreferredSize().height;
int barRectWidth = w - (b.right + b.left); int barRectWidth = w - (b.right + b.left);
int barRectHeight = h - (b.top + b.bottom); int barRectHeight = h - (b.top + b.bottom);
@ -122,13 +125,14 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
Graphics2D g2 = (Graphics2D)g; Graphics2D g2 = (Graphics2D)g;
g.fillRect(0, 0, w, h); g.fillRect(0, 0, w, h);
g2.translate(0, (c.getHeight() - h) / 2);
g2.setColor(progressBar.getForeground()); g2.setColor(progressBar.getForeground());
g2.fill(new RoundRectangle2D.Double(0, 0, w - 1, h - 1, 9, 9)); g2.fill(new RoundRectangle2D.Double(0, 0, w - 1, h - 1, 9, 9));
g2.setColor(c.getParent().getBackground()); g2.setColor(c.getParent().getBackground());
g2.fill(new RoundRectangle2D.Double(1,1,w-3,h-3,8,8)); g2.fill(new RoundRectangle2D.Double(1, 1, w - 3, h - 3, 8, 8));
g2.setColor(progressBar.getForeground()); g2.setColor(progressBar.getForeground());
g2.fill(new RoundRectangle2D.Double(2,2,amountFull-5,h-5,7,7)); g2.fill(new RoundRectangle2D.Double(2,2,amountFull-5,h-5,7,7));
g2.translate(0, -(c.getHeight() - h)/2);
// Deal with possible text painting // Deal with possible text painting
if (progressBar.isStringPainted()) { if (progressBar.isStringPainted()) {
@ -151,7 +155,7 @@ public class DarculaProgressBarUI extends BasicProgressBarUI {
x, y, w, h); x, y, w, h);
Rectangle oldClip = g2.getClipBounds(); Rectangle oldClip = g2.getClipBounds();
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) {
g2.setColor(getSelectionBackground()); g2.setColor(getSelectionBackground());
SwingUtilities2.drawString(progressBar, g2, progressString, SwingUtilities2.drawString(progressBar, g2, progressString,
renderLocation.x, renderLocation.y); renderLocation.x, renderLocation.y);

47
src/com/bulenkov/darcula/ui/DarculaRadioButtonUI.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,7 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.DarculaUIUtil; import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.darcula.SystemInfo; import com.bulenkov.iconloader.util.*;
import com.bulenkov.darcula.util.*;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
import javax.swing.*; import javax.swing.*;
@ -71,38 +70,52 @@ public class DarculaRadioButtonUI extends MetalRadioButtonUI {
g.fillRect(0,0, size.width, size.height); g.fillRect(0,0, size.width, size.height);
} }
int rad = 5;
// Paint the radio button // Paint the radio button
final int x = iconRect.x + 2; final int x = iconRect.x + (rad-1)/2;
final int y = iconRect.y + 2; final int y = iconRect.y + (rad-1)/2;
final int w = iconRect.width - 4; final int w = iconRect.width - (rad + 5) / 2;
final int h = iconRect.height - 4; final int h = iconRect.height - (rad + 5) / 2;
g.translate(x, y); g.translate(x, y);
//setup AA for lines //setup AA for lines
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
g.setPaint( final boolean focus = b.hasFocus();
new GradientPaint(0, 0, ColorUtil.shift(c.getBackground(), 1.5), 0, c.getHeight(), ColorUtil.shift(c.getBackground(), 1.2))); g.setPaint(new GradientPaint(0, 0, ColorUtil.shift(c.getBackground(), 1.5),
0, c.getHeight(), ColorUtil.shift(c.getBackground(), 1.2)));
if (focus) {
g.fillOval(0, 1, w, h);
} else {
g.fillOval(0, 1, w - 1, h - 1); g.fillOval(0, 1, w - 1, h - 1);
}
if (b.hasFocus()) { if (focus) {
int sysOffX = SystemInfo.isMac ? 0 : 1; if (UIUtil.isRetina()) {
int sysOffY = SystemInfo.isMac ? 0 : -1; DarculaUIUtil.paintFocusOval(g, 1, 2, w - 2, h - 2);
DarculaUIUtil.paintFocusOval(g, x - 6 + sysOffX, y - 3 + sysOffY, w - 2, h - 2); } else {
DarculaUIUtil.paintFocusOval(g, 0, 1, w, h);
}
} else { } else {
if (UIUtil.isUnderDarcula()) {
g.setPaint(new GradientPaint(w / 2, 1, Gray._160.withAlpha(90), w / 2, h, Gray._100.withAlpha(90))); g.setPaint(new GradientPaint(w / 2, 1, Gray._160.withAlpha(90), w / 2, h, Gray._100.withAlpha(90)));
g.drawOval(0, 2, w - 1, h - 1); g.drawOval(0, 2, w - 1, h - 1);
g.setPaint(Gray._40.withAlpha(200)); g.setPaint(Gray._40.withAlpha(200));
g.drawOval(0, 1, w - 1, h - 1); g.drawOval(0, 1, w - 1, h - 1);
} else {
g.setPaint(b.isEnabled() ? Gray._30 : Gray._130);
g.drawOval(0, 1, w - 1, h - 1);
}
} }
if (b.isSelected()) { if (b.isSelected()) {
g.setColor(b.isEnabled() ? Gray._30 : Gray._60); final boolean enabled = b.isEnabled();
g.fillOval(w/2 - 3, h/2 - 1, 5, 5); g.setColor(UIManager.getColor(enabled ? "RadioButton.darcula.selectionEnabledShadowColor" : "RadioButton.darcula.selectionDisabledShadowColor"));// ? Gray._30 : Gray._60);
g.setColor(b.isEnabled() ? Gray._170 : Gray._120); g.fillOval(w/2 - rad/2, h/2 , rad, rad);
g.fillOval(w/2 - 3, h/2 - 2, 5, 5); g.setColor(UIManager.getColor(enabled ? "RadioButton.darcula.selectionEnabledColor" : "RadioButton.darcula.selectionDisabledColor")); //Gray._170 : Gray._120);
g.fillOval(w/2 - rad/2, h/2 - 1, rad, rad);
} }
config.restore(); config.restore();
g.translate(-x, -y); g.translate(-x, -y);

1023
src/com/bulenkov/darcula/ui/DarculaRootPaneUI.java

File diff suppressed because it is too large Load Diff

57
src/com/bulenkov/darcula/ui/DarculaScrollBarUI.java

@ -16,9 +16,12 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.util.Animator; import com.bulenkov.darcula.util.Animator;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.DoubleColor;
import com.bulenkov.iconloader.util.Gray;
import com.bulenkov.iconloader.util.UIUtil;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI; import javax.swing.plaf.basic.BasicScrollBarUI;
import java.awt.*; import java.awt.*;
@ -34,30 +37,31 @@ public class DarculaScrollBarUI extends BasicScrollBarUI {
return new DarculaScrollBarUI(); return new DarculaScrollBarUI();
} }
public static DoubleColor getGradientLightColor() {
return new DoubleColor(Gray._251, Gray._95);
public static Color getGradientLightColor() {
return Gray._90;
} }
public static Color getGradientDarkColor() { public static DoubleColor getGradientDarkColor() {
return Gray._70; return new DoubleColor(Gray._215, Gray._80);
} }
private static Color getGradientThumbBorderColor() { private static DoubleColor getGradientThumbBorderColor() {
return Gray._75; return new DoubleColor(Gray._201, Gray._85);
} }
public static Color getTrackBackground() { public static DoubleColor getTrackBackground() {
return UIManager.getColor("control"); return new DoubleColor(Gray._245, UIUtil.getListBackground());
} }
public static Color getTrackBorderColor() { public static DoubleColor getTrackBorderColor() {
return UIManager.getColor("control"); return new DoubleColor(Gray._230, UIUtil.getListBackground());
} }
private static final BasicStroke BORDER_STROKE = new BasicStroke(); private static final BasicStroke BORDER_STROKE = new BasicStroke();
public static final int ANIMATION_COLOR_SHIFT = 20;
private static int getAnimationColorShift() {
return UIUtil.isUnderDarcula() ? 20 : 40;
}
private final AdjustmentListener myAdjustmentListener; private final AdjustmentListener myAdjustmentListener;
private final MouseMotionAdapter myMouseMotionListener; private final MouseMotionAdapter myMouseMotionListener;
@ -109,6 +113,18 @@ public class DarculaScrollBarUI extends BasicScrollBarUI {
} }
} }
@Override
protected ModelListener createModelListener() {
return new ModelListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (scrollbar != null) {
super.stateChanged(e);
}
}
};
}
public int getDecrementButtonHeight() { public int getDecrementButtonHeight() {
return decrButton.getHeight(); return decrButton.getHeight();
} }
@ -120,13 +136,16 @@ public class DarculaScrollBarUI extends BasicScrollBarUI {
myAnimator.reset(); myAnimator.reset();
if (scrollbar != null && scrollbar.getValueIsAdjusting() || myMouseIsOverThumb) { if (scrollbar != null && scrollbar.getValueIsAdjusting() || myMouseIsOverThumb) {
myAnimator.suspend(); myAnimator.suspend();
myAnimationColorShift = ANIMATION_COLOR_SHIFT; myAnimationColorShift = getAnimationColorShift();
} }
else { else {
myAnimator.resume(); myAnimator.resume();
} }
} }
public static BasicScrollBarUI createNormal() {
return new DarculaScrollBarUI();
}
@Override @Override
public void installUI(JComponent c) { public void installUI(JComponent c) {
@ -165,7 +184,7 @@ public class DarculaScrollBarUI extends BasicScrollBarUI {
return new Animator("Adjustment fadeout", FRAMES_COUNT, FRAMES_COUNT * 50, false) { return new Animator("Adjustment fadeout", FRAMES_COUNT, FRAMES_COUNT * 50, false) {
@Override @Override
public void paintNow(int frame, int totalFrames, int cycle) { public void paintNow(int frame, int totalFrames, int cycle) {
myAnimationColorShift = ANIMATION_COLOR_SHIFT; myAnimationColorShift = getAnimationColorShift();
if (frame > DELAY_FRAMES) { if (frame > DELAY_FRAMES) {
myAnimationColorShift *= 1 - ((double)(frame - DELAY_FRAMES)) / ((double)(totalFrames - DELAY_FRAMES)); myAnimationColorShift *= 1 - ((double)(frame - DELAY_FRAMES)) / ((double)(totalFrames - DELAY_FRAMES));
} }
@ -194,6 +213,7 @@ public class DarculaScrollBarUI extends BasicScrollBarUI {
super.uninstallListeners(); super.uninstallListeners();
} }
scrollbar.removeAdjustmentListener(myAdjustmentListener); scrollbar.removeAdjustmentListener(myAdjustmentListener);
myAnimator.dispose();
} }
@Override @Override
@ -295,7 +315,8 @@ public class DarculaScrollBarUI extends BasicScrollBarUI {
protected Color adjustColor(Color c) { protected Color adjustColor(Color c) {
if (myAnimationColorShift == 0) return c; if (myAnimationColorShift == 0) return c;
return Gray.get(c.getRed() + myAnimationColorShift); final int sign = UIUtil.isUnderDarcula() ? -1 : 1;
return Gray.get(Math.max(0, Math.min(255, c.getRed() - sign * myAnimationColorShift)));
} }
private boolean isVertical() { private boolean isVertical() {
@ -333,4 +354,4 @@ public class DarculaScrollBarUI extends BasicScrollBarUI {
return getMaximumSize(); return getMaximumSize();
} }
} }
} }

36
src/com/bulenkov/darcula/ui/DarculaSpinnerBorder.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,16 +16,15 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.DarculaUIUtil; import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.*;
import com.bulenkov.darcula.util.GraphicsUtil;
import com.bulenkov.darcula.util.Gray;
import com.bulenkov.darcula.util.UIUtil;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import java.awt.*; import java.awt.*;
import java.awt.geom.Area;
import java.awt.geom.RoundRectangle2D;
/** /**
* @author Konstantin Bulenkov * @author Konstantin Bulenkov
@ -36,26 +35,31 @@ public class DarculaSpinnerBorder implements Border, UIResource {
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
final JSpinner spinner = (JSpinner)c; final JSpinner spinner = (JSpinner)c;
final JFormattedTextField editor = UIUtil.findComponentOfType(spinner, JFormattedTextField.class); final JFormattedTextField editor = UIUtil.findComponentOfType(spinner, JFormattedTextField.class);
final int x1 = x + 3; final int x1 = x + 1;
final int y1 = y + 3; final int y1 = y + 3;
final int width1 = width - 8; final int width1 = width - 2;
final int height1 = height - 6; final int height1 = height - 6;
final boolean focused = c.isEnabled() && c.isVisible() && editor != null && editor.hasFocus(); final boolean focused = c.isEnabled() && c.isVisible() && editor != null && editor.hasFocus();
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
if (c.isOpaque()) { if (c.isOpaque()) {
g.setColor(UIManager.getColor("Panel.background")); g.setColor(UIUtil.getPanelBackground());
g.fillRect(x, y, width, height); g.fillRect(x, y, width, height);
} }
g.setColor(UIManager.getColor("TextField.background")); g.setColor(UIUtil.getTextFieldBackground());
g.fillRoundRect(x1, y1, width1, height1, 5, 5); g.fillRoundRect(x1, y1, width1, height1, 5, 5);
g.setColor(UIManager.getColor("Panel.background")); g.setColor(UIManager.getColor(spinner.isEnabled() ? "Spinner.darcula.enabledButtonColor" : "Spinner.darcula.disabledButtonColor"));
if (editor != null) { if (editor != null) {
final int off = editor.getBounds().x + editor.getWidth() + ((JSpinner)c).getInsets().left; final int off = editor.getBounds().x + editor.getWidth() + ((JSpinner)c).getInsets().left + 1;
g.fillRect(off, y1, 17, height1); final Area rect = new Area(new RoundRectangle2D.Double(x1, y1, width1, height1, 5, 5));
final Area blueRect = new Area(new Rectangle(off, y1, 22, height1));
rect.intersect(blueRect);
((Graphics2D)g).fill(rect);
if (UIUtil.isUnderDarcula()) {
g.setColor(Gray._100); g.setColor(Gray._100);
g.drawLine(off, y1, off, height1+2); g.drawLine(off, y1, off, height1 + 2);
}
} }
if (!c.isEnabled()) { if (!c.isEnabled()) {
@ -63,9 +67,9 @@ public class DarculaSpinnerBorder implements Border, UIResource {
} }
if (focused) { if (focused) {
DarculaUIUtil.paintFocusRing(g, x1, y1, width1, height1); DarculaUIUtil.paintFocusRing(g, x1 + 2, y1, width1 - 3, height1);
} else { } else {
g.setColor(Gray._100); g.setColor(new DoubleColor(Gray._149,Gray._100));
g.drawRoundRect(x1, y1, width1, height1, 5, 5); g.drawRoundRect(x1, y1, width1, height1, 5, 5);
} }
config.restore(); config.restore();
@ -73,7 +77,7 @@ public class DarculaSpinnerBorder implements Border, UIResource {
@Override @Override
public Insets getBorderInsets(Component c) { public Insets getBorderInsets(Component c) {
return new InsetsUIResource(6, 7, 6, 7); return new InsetsUIResource(5, 7, 5, 7);
} }
@Override @Override

16
src/com/bulenkov/darcula/ui/DarculaSpinnerUI.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,8 +15,7 @@
*/ */
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.*;
import com.bulenkov.darcula.util.GraphicsUtil;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
@ -113,13 +112,14 @@ public class DarculaSpinnerUI extends BasicSpinnerUI {
} }
private JButton createArrow(int direction) { private JButton createArrow(int direction) {
final Color shadow = UIManager.getColor("Panel.background"); final Color shadow = UIUtil.getPanelBackground();
final Color darkShadow = UIManager.getColor("Label.foreground"); final Color enabledColor = new DoubleColor(Gray._255, UIUtil.getLabelForeground());
JButton b = new BasicArrowButton(direction, shadow, shadow, darkShadow, shadow) { final Color disabledColor = new DoubleColor(Gray._200, UIUtil.getLabelForeground().darker());
JButton b = new BasicArrowButton(direction, shadow, shadow, enabledColor, shadow) {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
int y = direction == NORTH ? getHeight() - 6 : 2; int y = direction == NORTH ? getHeight() - 6 : 2;
paintTriangle(g, 0, y, 0, direction, DarculaSpinnerUI.this.spinner.isEnabled()); paintTriangle(g, (getWidth() - 8)/2 - 1, y, 0, direction, DarculaSpinnerUI.this.spinner.isEnabled());
} }
@Override @Override
@ -135,7 +135,7 @@ public class DarculaSpinnerUI extends BasicSpinnerUI {
final int h = 6; final int h = 6;
mid = w / 2; mid = w / 2;
g.setColor(isEnabled ? darkShadow : darkShadow.darker()); g.setColor(isEnabled ? enabledColor : disabledColor);
g.translate(x, y); g.translate(x, y);
switch (direction) { switch (direction) {

0
src/com/bulenkov/darcula/ui/DarculaTabbedPaneUI.java

607
src/com/bulenkov/darcula/ui/DarculaTest.form

@ -0,0 +1,607 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.ui.laf.darcula.ui.DarculaTest">
<grid id="27dc6" binding="myRoot" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="740" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<tabbedpane id="7fdea" class="com.intellij.ui.components.JBTabbedPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="82dae" layout-manager="GridLayoutManager" row-count="8" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Controls"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="18633" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Checkbox 1"/>
</properties>
</component>
<component id="9cf6e" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Checkbox 2"/>
</properties>
</component>
<component id="ccfb9" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Checkbox 3"/>
</properties>
</component>
<component id="cd11b" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Checkbox 4"/>
</properties>
</component>
<component id="210e8" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="Checkbox 5"/>
</properties>
</component>
<hspacer id="72565">
<constraints>
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="4309a">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="987f8" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox1" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="57e78" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox2" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="true"/>
</properties>
</component>
<component id="3fd84" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox3" default-binding="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="true"/>
</properties>
</component>
<component id="4c4e6" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox4" default-binding="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="true"/>
</properties>
</component>
<component id="4faf4" class="com.intellij.ui.components.JBCheckBox" binding="myJBCheckBox5" default-binding="true">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
</component>
<component id="389e3" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Radio button 1"/>
</properties>
</component>
<component id="2c501" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Radio button 2"/>
</properties>
</component>
<component id="74a2d" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Radio button 3"/>
</properties>
</component>
<component id="8b6b8" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Radio button 4"/>
</properties>
</component>
<component id="fbe33" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="Radio button 5"/>
</properties>
</component>
<component id="1935f" class="com.intellij.ui.components.JBRadioButton">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="3443a" class="com.intellij.ui.components.JBRadioButton">
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="46c61" class="com.intellij.ui.components.JBRadioButton">
<constraints>
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="b4c96" class="com.intellij.ui.components.JBRadioButton">
<constraints>
<grid row="3" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="3f56f" class="com.intellij.ui.components.JBRadioButton">
<constraints>
<grid row="4" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="cee3a" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Combo 1"/>
</properties>
</component>
<component id="21050" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Combo 2"/>
</properties>
</component>
<component id="402e8" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Combo 3"/>
</properties>
</component>
<component id="9de33" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="Combo 4"/>
</properties>
</component>
<component id="786c1" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="Combo 5"/>
</properties>
</component>
<component id="cf830" class="javax.swing.JComboBox" binding="myComboBox1" default-binding="true">
<constraints>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
<item value="item 1"/>
<item value="item 2"/>
<item value="long item"/>
<item value="very long item"/>
<item value="blah blah blah blah"/>
<item value="hello"/>
<item value="darcula"/>
</model>
</properties>
</component>
<component id="70b41" class="javax.swing.JComboBox" binding="myComboBox2" default-binding="true">
<constraints>
<grid row="1" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
<item value="item 1"/>
<item value="item 2"/>
<item value="long item"/>
<item value="very long item"/>
<item value="blah blah blah blah"/>
<item value="hello"/>
<item value="darcula"/>
</model>
</properties>
</component>
<component id="fd136" class="javax.swing.JComboBox" binding="myComboBox3" default-binding="true">
<constraints>
<grid row="2" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="true"/>
<model>
<item value="item 1"/>
<item value="item 2"/>
<item value="long item"/>
<item value="very long item"/>
<item value="blah blah blah blah"/>
<item value="hello"/>
<item value="darcula"/>
</model>
</properties>
</component>
<component id="f8aa2" class="javax.swing.JComboBox" binding="myComboBox4" default-binding="true">
<constraints>
<grid row="3" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<editable value="true"/>
<enabled value="false"/>
<model>
<item value="item 1"/>
<item value="item 2"/>
<item value="long item"/>
<item value="very long item"/>
<item value="blah blah blah blah"/>
<item value="hello"/>
<item value="darcula"/>
</model>
</properties>
</component>
<component id="15345" class="javax.swing.JComboBox" binding="myComboBox5" default-binding="true">
<constraints>
<grid row="4" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<model>
<item value="item 1"/>
<item value="item 2"/>
<item value="long item"/>
<item value="very long item"/>
<item value="blah blah blah blah"/>
<item value="hello"/>
<item value="darcula"/>
</model>
</properties>
</component>
<grid id="89ff7" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="6" column="0" row-span="1" col-span="8" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9f0fc" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Username:"/>
</properties>
</component>
<component id="4ae36" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Password:"/>
</properties>
</component>
<component id="da910" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="Disabled:"/>
</properties>
</component>
<hspacer id="fb796">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="4fa3a" class="javax.swing.JTextField" binding="myTextField1" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="55f5c" class="javax.swing.JTextField" binding="myThisTextIsDisabledTextField" default-binding="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<enabled value="false"/>
<text value="This text is disabled"/>
</properties>
</component>
<component id="a89cc" class="javax.swing.JPasswordField" binding="myPasswordField1" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
<component id="16094" class="javax.swing.JTextField" binding="myTextField2" default-binding="true">
<constraints>
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="9ca2c" class="javax.swing.JTextField" binding="myTextField3" default-binding="true">
<constraints>
<grid row="1" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="d3706" class="javax.swing.JTextField" binding="myTextField4" default-binding="true">
<constraints>
<grid row="2" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="b4c72" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Label"/>
</properties>
</component>
<component id="416fd" class="javax.swing.JSpinner" binding="mySpinner1" default-binding="true">
<constraints>
<grid row="5" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="df06" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Table"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="3105c" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="d2ccf" class="com.intellij.ui.table.JBTable" binding="myTable">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
<grid id="7e7c9" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Progress"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e24f4" class="javax.swing.JProgressBar" binding="myProgressBar1" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<indeterminate value="false"/>
</properties>
</component>
<vspacer id="17deb">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="9f8b4" class="javax.swing.JButton" binding="myProgressButton">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Start"/>
</properties>
</component>
<component id="cb89e" class="javax.swing.JProgressBar" binding="myProgressBar2" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="208a5" class="javax.swing.JButton" binding="myStartButton" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Start"/>
</properties>
</component>
</children>
</grid>
<grid id="3db09" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Untitled"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="9eb6c" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Untitled"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="519ad" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Untitled"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="79d38" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Untitled"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="4847f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Untitled"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="ccad" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Untitled"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</tabbedpane>
<grid id="7eadd" layout-manager="GridLayoutManager" row-count="1" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="b01de">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="137c6">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="908bc" class="javax.swing.JButton" binding="myHelpButton" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Help"/>
</properties>
</component>
<component id="fc247" class="javax.swing.JButton" binding="myCancelButton" default-binding="true">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Cancel"/>
</properties>
</component>
<component id="710e8" class="javax.swing.JButton" binding="myDisabledButton" default-binding="true">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="Disabled"/>
</properties>
</component>
<component id="bcace" class="javax.swing.JButton" binding="myDefaultButton" default-binding="true">
<constraints>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Default"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<buttonGroups>
<group name="myGroup1">
<member id="1935f"/>
<member id="3443a"/>
<member id="46c61"/>
<member id="b4c96"/>
<member id="3f56f"/>
</group>
</buttonGroups>
</form>

20
src/com/bulenkov/darcula/ui/DarculaTextBorder.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,10 @@
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.DarculaUIUtil; import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.darcula.util.Gray; import com.bulenkov.iconloader.util.Gray;
import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
@ -31,7 +32,17 @@ import java.awt.*;
public class DarculaTextBorder implements Border, UIResource { public class DarculaTextBorder implements Border, UIResource {
@Override @Override
public Insets getBorderInsets(Component c) { public Insets getBorderInsets(Component c) {
return new InsetsUIResource(4, 7, 4, 7); int vOffset = c instanceof JPasswordField ? 3 : 4;
if (DarculaTextFieldUI.isSearchField(c)) {
vOffset += 2;
}
if (DarculaTextFieldUI.isSearchFieldWithHistoryPopup(c)) {
return new InsetsUIResource(vOffset, 7 + 16 + 3, vOffset, 7 + 16);
} else if (DarculaTextFieldUI.isSearchField(c)) {
return new InsetsUIResource(vOffset, 4 + 16 + 3, vOffset, 7 + 16);
} else {
return new InsetsUIResource(vOffset, 7, vOffset, 7);
}
} }
@Override @Override
@ -41,6 +52,7 @@ public class DarculaTextBorder implements Border, UIResource {
@Override @Override
public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) {
if (DarculaTextFieldUI.isSearchField(c)) return;
Graphics2D g = ((Graphics2D)g2); Graphics2D g = ((Graphics2D)g2);
final GraphicsConfig config = new GraphicsConfig(g); final GraphicsConfig config = new GraphicsConfig(g);
g.translate(x, y); g.translate(x, y);

153
src/com/bulenkov/darcula/ui/DarculaTextFieldUI.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2012 JetBrains s.r.o. * Copyright 2000-2013 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +15,10 @@
*/ */
package com.bulenkov.darcula.ui; package com.bulenkov.darcula.ui;
import com.bulenkov.darcula.util.GraphicsConfig; import com.bulenkov.darcula.DarculaUIUtil;
import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.iconloader.util.Gray;
import com.bulenkov.iconloader.IconLoader;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
@ -23,16 +26,29 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTextFieldUI; import javax.swing.plaf.basic.BasicTextFieldUI;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import java.awt.*; import java.awt.*;
import java.awt.event.FocusAdapter; import java.awt.event.*;
import java.awt.event.FocusEvent;
/** /**
* @author Konstantin Bulenkov * @author Konstantin Bulenkov
*/ */
public class DarculaTextFieldUI extends BasicTextFieldUI { public class DarculaTextFieldUI extends BasicTextFieldUI {
private static final Icon SEARCH_ICON = IconLoader.findIcon("/com/intellij/ide/ui/laf/darcula/icons/search.png", DarculaTextFieldUI.class, true);
private static final Icon SEARCH_WITH_HISTORY_ICON = IconLoader.findIcon("/com/intellij/ide/ui/laf/darcula/icons/searchWithHistory.png", DarculaTextFieldUI.class, true);
private static final Icon CLEAR_ICON = IconLoader.findIcon("/com/intellij/ide/ui/laf/darcula/icons/clear.png", DarculaTextFieldUI.class, true);
private enum SearchAction {POPUP, CLEAR}
private final JTextField myTextField;
protected JLabel myClearIcon;
protected JLabel myRecentIcon;
public DarculaTextFieldUI(JTextField textField) {
myTextField = textField;
}
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass") @SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
final DarculaTextFieldUI ui = new DarculaTextFieldUI((JTextField)c);
c.addFocusListener(new FocusAdapter() { c.addFocusListener(new FocusAdapter() {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
@ -44,7 +60,78 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
c.repaint(); c.repaint();
} }
}); });
return new DarculaTextFieldUI(); c.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
if (ui.getComponent() != null && isSearchField(c)) {
if (ui.getActionUnder(e) != null) {
c.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else {
c.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
}
}
}
});
c.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (isSearchField(c)) {
final SearchAction action = ui.getActionUnder(e);
if (action != null) {
switch (action) {
case POPUP:
ui.showSearchPopup();
break;
case CLEAR:
((JTextField)c).setText("");
break;
}
e.consume();
}
}
}
});
return ui;
}
protected void showSearchPopup() {
final Object value = getComponent().getClientProperty("JTextField.Search.FindPopup");
if (value instanceof JPopupMenu) {
final JPopupMenu popup = (JPopupMenu)value;
popup.show(getComponent(), getSearchIconCoord().x, getComponent().getHeight());
}
}
private SearchAction getActionUnder(MouseEvent e) {
final Point cPoint = getClearIconCoord();
final Point sPoint = getSearchIconCoord();
cPoint.x+=8;
cPoint.y+=8;
sPoint.x+=8;
sPoint.y+=8;
final Point ePoint = e.getPoint();
return cPoint.distance(ePoint) <= 8 ? SearchAction.CLEAR : sPoint.distance(ePoint) <= 8 ? SearchAction.POPUP : null;
}
protected Rectangle getDrawingRect() {
final JTextComponent c = myTextField;
final Insets i = c.getInsets();
final int x = i.right - 4 - 16;
final int y = i.top - 3;
final int w = c.getWidth() - i.left - i.right + 16*2 +7*2 - 5;
int h = c.getBounds().height - i.top - i.bottom + 4*2 - 3;
if (h%2==1) h++;
return new Rectangle(x, y, w, h);
}
protected Point getSearchIconCoord() {
final Rectangle r = getDrawingRect();
return new Point(r.x + 3, r.y + (r.height - 16) / 2 + 1);
}
protected Point getClearIconCoord() {
final Rectangle r = getDrawingRect();
return new Point(r.x + r.width - 16 - 1, r.y + (r.height - 16) / 2);
} }
@Override @Override
@ -52,12 +139,44 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
Graphics2D g = (Graphics2D)graphics; Graphics2D g = (Graphics2D)graphics;
final JTextComponent c = getComponent(); final JTextComponent c = getComponent();
final Container parent = c.getParent(); final Container parent = c.getParent();
if (parent != null) { final Rectangle r = getDrawingRect();
if (c.isOpaque() && parent != null) {
g.setColor(parent.getBackground()); g.setColor(parent.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight()); g.fillRect(0, 0, c.getWidth(), c.getHeight());
} }
final GraphicsConfig config = new GraphicsConfig(g);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
final Border border = c.getBorder(); final Border border = c.getBorder();
if (border instanceof DarculaTextBorder) { if (isSearchField(c)) {
g.setColor(c.getBackground());
int radius = r.height-1;
g.fillRoundRect(r.x, r.y, r.width, r.height-1, radius, radius);
g.setColor(c.isEnabled() ? Gray._100 : new Color(0x535353));
if (c.getClientProperty("JTextField.Search.noBorderRing") != Boolean.TRUE) {
if (c.hasFocus()) {
DarculaUIUtil.paintSearchFocusRing(g, r);
} else {
g.drawRoundRect(r.x, r.y, r.width, r.height-1, radius, radius);
}
}
Point p = getSearchIconCoord();
Icon searchIcon = getComponent().getClientProperty("JTextField.Search.FindPopup") instanceof JPopupMenu ? UIManager.getIcon("TextField.darcula.searchWithHistory.icon") : UIManager.getIcon("TextField.darcula.search.icon");
if (searchIcon == null) {
searchIcon = IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/search.png", DarculaTextFieldUI.class, true);
}
searchIcon.paintIcon(null, g, p.x, p.y);
if (getComponent().hasFocus() && getComponent().getText().length() > 0) {
p = getClearIconCoord();
Icon clearIcon = UIManager.getIcon("TextField.darcula.clear.icon");
if (clearIcon == null) {
clearIcon = IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/clear.png", DarculaTextFieldUI.class, true);
}
clearIcon.paintIcon(null, g, p.x, p.y);
}
} else if (border instanceof DarculaTextBorder) {
if (c.isEnabled() && c.isEditable()) { if (c.isEnabled() && c.isEditable()) {
g.setColor(c.getBackground()); g.setColor(c.getBackground());
} }
@ -65,17 +184,27 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
final int height = c.getHeight(); final int height = c.getHeight();
final Insets i = border.getBorderInsets(c); final Insets i = border.getBorderInsets(c);
if (c.hasFocus()) { if (c.hasFocus()) {
final GraphicsConfig config = new GraphicsConfig(g);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g.fillRoundRect(i.left - 5, i.top - 2, width - i.right - i.left + 10, height - i.top - i.bottom + 6, 5, 5); g.fillRoundRect(i.left - 5, i.top - 2, width - i.right - i.left + 10, height - i.top - i.bottom + 6, 5, 5);
config.restore();
} else { } else {
g.fillRect(i.left - 5, i.top - 2, width - i.right - i.left + 12, height - i.top - i.bottom + 6); g.fillRect(i.left - 5, i.top - 2, width - i.right - i.left + 12, height - i.top - i.bottom + 6);
} }
} else { } else {
super.paintBackground(g); super.paintBackground(g);
} }
config.restore();
}
@Override
protected void paintSafely(Graphics g) {
paintBackground(g);
super.paintSafely(g);
}
public static boolean isSearchField(Component c) {
return c instanceof JTextField && "search".equals(((JTextField)c).getClientProperty("JTextField.variant"));
}
public static boolean isSearchFieldWithHistoryPopup(Component c) {
return isSearchField(c) && ((JTextField)c).getClientProperty("JTextField.Search.FindPopup") instanceof JPopupMenu;
} }
} }

729
src/com/bulenkov/darcula/ui/DarculaTitlePane.java

@ -0,0 +1,729 @@
/*
* Copyright 2000-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bulenkov.darcula.ui;
import sun.awt.SunToolkit;
import sun.swing.SwingUtilities2;
import javax.accessibility.AccessibleContext;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.UIResource;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
/**
* @author Konstantin Bulenkov
*/
public class DarculaTitlePane extends JComponent {
private static final int IMAGE_HEIGHT = 16;
private static final int IMAGE_WIDTH = 16;
private PropertyChangeListener myPropertyChangeListener;
private JMenuBar myMenuBar;
private Action myCloseAction;
private Action myIconifyAction;
private Action myRestoreAction;
private Action myMaximizeAction;
private JButton myToggleButton;
private JButton myIconifyButton;
private JButton myCloseButton;
private Icon myMaximizeIcon;
private Icon myMinimizeIcon;
private Image mySystemIcon;
private WindowListener myWindowListener;
private Window myWindow;
private JRootPane myRootPane;
private int myState;
private DarculaRootPaneUI rootPaneUI;
private Color myInactiveBackground = UIManager.getColor("inactiveCaption");
private Color myInactiveForeground = UIManager.getColor("inactiveCaptionText");
private Color myInactiveShadow = UIManager.getColor("inactiveCaptionBorder");
private Color myActiveBackground = null;
private Color myActiveForeground = null;
private Color myActiveShadow = null;
public DarculaTitlePane(JRootPane root, DarculaRootPaneUI ui) {
this.myRootPane = root;
rootPaneUI = ui;
myState = -1;
installSubcomponents();
determineColors();
installDefaults();
setLayout(createLayout());
}
private void uninstall() {
uninstallListeners();
myWindow = null;
removeAll();
}
private void installListeners() {
if (myWindow != null) {
myWindowListener = createWindowListener();
myWindow.addWindowListener(myWindowListener);
myPropertyChangeListener = createWindowPropertyChangeListener();
myWindow.addPropertyChangeListener(myPropertyChangeListener);
}
}
private void uninstallListeners() {
if (myWindow != null) {
myWindow.removeWindowListener(myWindowListener);
myWindow.removePropertyChangeListener(myPropertyChangeListener);
}
}
private WindowListener createWindowListener() {
return new WindowHandler();
}
private PropertyChangeListener createWindowPropertyChangeListener() {
return new PropertyChangeHandler();
}
public JRootPane getRootPane() {
return myRootPane;
}
private int getWindowDecorationStyle() {
return getRootPane().getWindowDecorationStyle();
}
public void addNotify() {
super.addNotify();
uninstallListeners();
myWindow = SwingUtilities.getWindowAncestor(this);
if (myWindow != null) {
if (myWindow instanceof Frame) {
setState(((Frame)myWindow).getExtendedState());
}
else {
setState(0);
}
setActive(myWindow.isActive());
installListeners();
updateSystemIcon();
}
}
public void removeNotify() {
super.removeNotify();
uninstallListeners();
myWindow = null;
}
private void installSubcomponents() {
int decorationStyle = getWindowDecorationStyle();
if (decorationStyle == JRootPane.FRAME) {
createActions();
myMenuBar = createMenuBar();
add(myMenuBar);
createButtons();
add(myIconifyButton);
add(myToggleButton);
add(myCloseButton);
}
else if (decorationStyle == JRootPane.PLAIN_DIALOG ||
decorationStyle == JRootPane.INFORMATION_DIALOG ||
decorationStyle == JRootPane.ERROR_DIALOG ||
decorationStyle == JRootPane.COLOR_CHOOSER_DIALOG ||
decorationStyle == JRootPane.FILE_CHOOSER_DIALOG ||
decorationStyle == JRootPane.QUESTION_DIALOG ||
decorationStyle == JRootPane.WARNING_DIALOG) {
createActions();
createButtons();
add(myCloseButton);
}
}
private void determineColors() {
switch (getWindowDecorationStyle()) {
case JRootPane.FRAME:
myActiveBackground = UIManager.getColor("activeCaption");
myActiveForeground = UIManager.getColor("activeCaptionText");
myActiveShadow = UIManager.getColor("activeCaptionBorder");
break;
case JRootPane.ERROR_DIALOG:
myActiveBackground = UIManager.getColor("OptionPane.errorDialog.titlePane.background");
myActiveForeground = UIManager.getColor("OptionPane.errorDialog.titlePane.foreground");
myActiveShadow = UIManager.getColor("OptionPane.errorDialog.titlePane.shadow");
break;
case JRootPane.QUESTION_DIALOG:
case JRootPane.COLOR_CHOOSER_DIALOG:
case JRootPane.FILE_CHOOSER_DIALOG:
myActiveBackground = UIManager.getColor("OptionPane.questionDialog.titlePane.background");
myActiveForeground = UIManager.getColor("OptionPane.questionDialog.titlePane.foreground");
myActiveShadow = UIManager.getColor("OptionPane.questionDialog.titlePane.shadow");
break;
case JRootPane.WARNING_DIALOG:
myActiveBackground = UIManager.getColor("OptionPane.warningDialog.titlePane.background");
myActiveForeground = UIManager.getColor("OptionPane.warningDialog.titlePane.foreground");
myActiveShadow = UIManager.getColor("OptionPane.warningDialog.titlePane.shadow");
break;
case JRootPane.PLAIN_DIALOG:
case JRootPane.INFORMATION_DIALOG:
default:
myActiveBackground = UIManager.getColor("activeCaption");
myActiveForeground = UIManager.getColor("activeCaptionText");
myActiveShadow = UIManager.getColor("activeCaptionBorder");
break;
}
}
private void installDefaults() {
setFont(UIManager.getFont("InternalFrame.titleFont", getLocale()));
}
protected JMenuBar createMenuBar() {
myMenuBar = new SystemMenuBar();
myMenuBar.setFocusable(false);
myMenuBar.setBorderPainted(true);
myMenuBar.add(createMenu());
return myMenuBar;
}
private void close() {
Window window = getWindow();
if (window != null) {
window.dispatchEvent(new WindowEvent(
window, WindowEvent.WINDOW_CLOSING));
}
}
private void iconify() {
Frame frame = getFrame();
if (frame != null) {
frame.setExtendedState(myState | Frame.ICONIFIED);
}
}
private void maximize() {
Frame frame = getFrame();
if (frame != null) {
frame.setExtendedState(myState | Frame.MAXIMIZED_BOTH);
}
}
private void restore() {
Frame frame = getFrame();
if (frame == null) {
return;
}
if ((myState & Frame.ICONIFIED) != 0) {
frame.setExtendedState(myState & ~Frame.ICONIFIED);
}
else {
frame.setExtendedState(myState & ~Frame.MAXIMIZED_BOTH);
}
}
private void createActions() {
myCloseAction = new CloseAction();
if (getWindowDecorationStyle() == JRootPane.FRAME) {
myIconifyAction = new IconifyAction();
myRestoreAction = new RestoreAction();
myMaximizeAction = new MaximizeAction();
}
}
private JMenu createMenu() {
JMenu menu = new JMenu("");
if (getWindowDecorationStyle() == JRootPane.FRAME) {
addMenuItems(menu);
}
return menu;
}
private void addMenuItems(JMenu menu) {
menu.add(myRestoreAction);
menu.add(myIconifyAction);
if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
menu.add(myMaximizeAction);
}
menu.add(new JSeparator());
menu.add(myCloseAction);
}
private static JButton createButton(String accessibleName, Icon icon, Action action) {
JButton button = new JButton();
button.setFocusPainted(false);
button.setFocusable(false);
button.setOpaque(true);
button.putClientProperty("paintActive", Boolean.TRUE);
button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
button.setBorder(new EmptyBorder(0, 0, 0, 0));
button.setText(null);
button.setAction(action);
button.setIcon(icon);
return button;
}
private void createButtons() {
myCloseButton = createButton("Close", UIManager.getIcon("InternalFrame.closeIcon"), myCloseAction);
if (getWindowDecorationStyle() == JRootPane.FRAME) {
myMaximizeIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
myMinimizeIcon = UIManager.getIcon("InternalFrame.minimizeIcon");
myIconifyButton = createButton("Iconify", UIManager.getIcon("InternalFrame.iconifyIcon"), myIconifyAction);
myToggleButton = createButton("Maximize", myMaximizeIcon, myRestoreAction);
}
}
private LayoutManager createLayout() {
return new TitlePaneLayout();
}
private void setActive(boolean active) {
myCloseButton.putClientProperty("paintActive", Boolean.valueOf(active));
if (getWindowDecorationStyle() == JRootPane.FRAME) {
myIconifyButton.putClientProperty("paintActive", Boolean.valueOf(active));
myToggleButton.putClientProperty("paintActive", Boolean.valueOf(active));
}
getRootPane().repaint();
}
private void setState(int state) {
setState(state, false);
}
private void setState(int state, boolean updateRegardless) {
Window wnd = getWindow();
if (wnd != null && getWindowDecorationStyle() == JRootPane.FRAME) {
if (myState == state && !updateRegardless) {
return;
}
Frame frame = getFrame();
if (frame != null) {
JRootPane rootPane = getRootPane();
if (((state & Frame.MAXIMIZED_BOTH) != 0) &&
(rootPane.getBorder() == null ||
(rootPane.getBorder() instanceof UIResource)) &&
frame.isShowing()) {
rootPane.setBorder(null);
}
else if ((state & Frame.MAXIMIZED_BOTH) == 0) {
// This is a croak, if state becomes bound, this can
// be nuked.
rootPaneUI.installBorder(rootPane);
}
if (frame.isResizable()) {
if ((state & Frame.MAXIMIZED_BOTH) != 0) {
updateToggleButton(myRestoreAction, myMinimizeIcon);
myMaximizeAction.setEnabled(false);
myRestoreAction.setEnabled(true);
}
else {
updateToggleButton(myMaximizeAction, myMaximizeIcon);
myMaximizeAction.setEnabled(true);
myRestoreAction.setEnabled(false);
}
if (myToggleButton.getParent() == null ||
myIconifyButton.getParent() == null) {
add(myToggleButton);
add(myIconifyButton);
revalidate();
repaint();
}
myToggleButton.setText(null);
}
else {
myMaximizeAction.setEnabled(false);
myRestoreAction.setEnabled(false);
if (myToggleButton.getParent() != null) {
remove(myToggleButton);
revalidate();
repaint();
}
}
}
else {
// Not contained in a Frame
myMaximizeAction.setEnabled(false);
myRestoreAction.setEnabled(false);
myIconifyAction.setEnabled(false);
remove(myToggleButton);
remove(myIconifyButton);
revalidate();
repaint();
}
myCloseAction.setEnabled(true);
myState = state;
}
}
private void updateToggleButton(Action action, Icon icon) {
myToggleButton.setAction(action);
myToggleButton.setIcon(icon);
myToggleButton.setText(null);
}
private Frame getFrame() {
Window window = getWindow();
if (window instanceof Frame) {
return (Frame)window;
}
return null;
}
private Window getWindow() {
return myWindow;
}
private String getTitle() {
Window w = getWindow();
if (w instanceof Frame) {
return ((Frame)w).getTitle();
}
else if (w instanceof Dialog) {
return ((Dialog)w).getTitle();
}
return null;
}
public void paintComponent(Graphics g) {
if (getFrame() != null) {
setState(getFrame().getExtendedState());
}
JRootPane rootPane = getRootPane();
Window window = getWindow();
boolean leftToRight = (window == null) ?
rootPane.getComponentOrientation().isLeftToRight() :
window.getComponentOrientation().isLeftToRight();
boolean isSelected = (window == null) ? true : window.isActive();
int width = getWidth();
int height = getHeight();
Color background;
Color foreground;
Color darkShadow;
if (isSelected) {
background = myActiveBackground;
foreground = myActiveForeground;
darkShadow = myActiveShadow;
}
else {
background = myInactiveBackground;
foreground = myInactiveForeground;
darkShadow = myInactiveShadow;
}
g.setColor(background);
g.fillRect(0, 0, width, height);
g.setColor(darkShadow);
g.drawLine(0, height - 1, width, height - 1);
g.drawLine(0, 0, 0, 0);
g.drawLine(width - 1, 0, width - 1, 0);
int xOffset = leftToRight ? 5 : width - 5;
if (getWindowDecorationStyle() == JRootPane.FRAME) {
xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5;
}
String theTitle = getTitle();
if (theTitle != null) {
FontMetrics fm = SwingUtilities2.getFontMetrics(rootPane, g);
g.setColor(foreground);
int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();
Rectangle rect = new Rectangle(0, 0, 0, 0);
if (myIconifyButton != null && myIconifyButton.getParent() != null) {
rect = myIconifyButton.getBounds();
}
int titleW;
if (leftToRight) {
if (rect.x == 0) {
rect.x = window.getWidth() - window.getInsets().right - 2;
}
titleW = rect.x - xOffset - 4;
theTitle = SwingUtilities2.clipStringIfNecessary(
rootPane, fm, theTitle, titleW);
}
else {
titleW = xOffset - rect.x - rect.width - 4;
theTitle = SwingUtilities2.clipStringIfNecessary(
rootPane, fm, theTitle, titleW);
xOffset -= SwingUtilities2.stringWidth(rootPane, fm, theTitle);
}
int titleLength = SwingUtilities2.stringWidth(rootPane, fm, theTitle);
SwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset);
xOffset += leftToRight ? titleLength + 5 : -5;
}
}
private class CloseAction extends AbstractAction {
public CloseAction() {
super(UIManager.getString("DarculaTitlePane.closeTitle", getLocale()));
}
public void actionPerformed(ActionEvent e) {
close();
}
}
private class IconifyAction extends AbstractAction {
public IconifyAction() {
super(UIManager.getString("DarculaTitlePane.iconifyTitle", getLocale()));
}
public void actionPerformed(ActionEvent e) {
iconify();
}
}
private class RestoreAction extends AbstractAction {
public RestoreAction() {
super(UIManager.getString
("DarculaTitlePane.restoreTitle", getLocale()));
}
public void actionPerformed(ActionEvent e) {
restore();
}
}
private class MaximizeAction extends AbstractAction {
public MaximizeAction() {
super(UIManager.getString("DarculaTitlePane.maximizeTitle", getLocale()));
}
public void actionPerformed(ActionEvent e) {
maximize();
}
}
private class SystemMenuBar extends JMenuBar {
public void paint(Graphics g) {
if (isOpaque()) {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
}
if (mySystemIcon != null) {
g.drawImage(mySystemIcon, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, null);
}
else {
Icon icon = UIManager.getIcon("InternalFrame.icon");
if (icon != null) {
icon.paintIcon(this, g, 0, 0);
}
}
}
public Dimension getMinimumSize() {
return getPreferredSize();
}
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(Math.max(IMAGE_WIDTH, size.width),
Math.max(size.height, IMAGE_HEIGHT));
}
}
private class TitlePaneLayout implements LayoutManager {
public void addLayoutComponent(String name, Component c) {
}
public void removeLayoutComponent(Component c) {
}
public Dimension preferredLayoutSize(Container c) {
int height = computeHeight();
//noinspection SuspiciousNameCombination
return new Dimension(height, height);
}
public Dimension minimumLayoutSize(Container c) {
return preferredLayoutSize(c);
}
private int computeHeight() {
FontMetrics fm = myRootPane.getFontMetrics(getFont());
int fontHeight = fm.getHeight();
fontHeight += 7;
int iconHeight = 0;
if (getWindowDecorationStyle() == JRootPane.FRAME) {
iconHeight = IMAGE_HEIGHT;
}
return Math.max(fontHeight, iconHeight);
}
public void layoutContainer(Container c) {
boolean leftToRight = (myWindow == null) ?
getRootPane().getComponentOrientation().isLeftToRight() :
myWindow.getComponentOrientation().isLeftToRight();
int w = getWidth();
int x;
int y = 3;
int spacing;
int buttonHeight;
int buttonWidth;
if (myCloseButton != null && myCloseButton.getIcon() != null) {
buttonHeight = myCloseButton.getIcon().getIconHeight();
buttonWidth = myCloseButton.getIcon().getIconWidth();
}
else {
buttonHeight = IMAGE_HEIGHT;
buttonWidth = IMAGE_WIDTH;
}
x = leftToRight ? w : 0;
spacing = 5;
x = leftToRight ? spacing : w - buttonWidth - spacing;
if (myMenuBar != null) {
myMenuBar.setBounds(x, y, buttonWidth, buttonHeight);
}
x = leftToRight ? w : 0;
spacing = 4;
x += leftToRight ? -spacing - buttonWidth : spacing;
if (myCloseButton != null) {
myCloseButton.setBounds(x, y, buttonWidth, buttonHeight);
}
if (!leftToRight) x += buttonWidth;
if (getWindowDecorationStyle() == JRootPane.FRAME) {
if (Toolkit.getDefaultToolkit().isFrameStateSupported(
Frame.MAXIMIZED_BOTH)) {
if (myToggleButton.getParent() != null) {
spacing = 10;
x += leftToRight ? -spacing - buttonWidth : spacing;
myToggleButton.setBounds(x, y, buttonWidth, buttonHeight);
if (!leftToRight) {
x += buttonWidth;
}
}
}
if (myIconifyButton != null && myIconifyButton.getParent() != null) {
spacing = 2;
x += leftToRight ? -spacing - buttonWidth : spacing;
myIconifyButton.setBounds(x, y, buttonWidth, buttonHeight);
if (!leftToRight) {
x += buttonWidth;
}
}
}
}
}
private class PropertyChangeHandler implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent pce) {
String name = pce.getPropertyName();
if ("resizable".equals(name) || "state".equals(name)) {
Frame frame = getFrame();
if (frame != null) {
setState(frame.getExtendedState(), true);
}
if ("resizable".equals(name)) {
getRootPane().repaint();
}
}
else if ("title".equals(name)) {
repaint();
}
else if ("componentOrientation" == name) {
revalidate();
repaint();
}
else if ("iconImage" == name) {
updateSystemIcon();
revalidate();
repaint();
}
}
}
private void updateSystemIcon() {
Window window = getWindow();
if (window == null) {
mySystemIcon = null;
return;
}
List<Image> icons = window.getIconImages();
assert icons != null;
if (icons.size() == 0) {
mySystemIcon = null;
} else if (icons.size() == 1) {
mySystemIcon = icons.get(0);
} else {
mySystemIcon = SunToolkit.getScaledIconImage(icons, IMAGE_WIDTH, IMAGE_HEIGHT);
}
}
private class WindowHandler extends WindowAdapter {
public void windowActivated(WindowEvent ev) {
setActive(true);
}
public void windowDeactivated(WindowEvent ev) {
setActive(false);
}
}
}

423
src/com/bulenkov/darcula/ui/DarculaTreeUI.java

@ -0,0 +1,423 @@
/*
* Copyright 2000-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bulenkov.darcula.ui;
import com.bulenkov.iconloader.util.SystemInfo;
import com.bulenkov.iconloader.util.UIUtil;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicTreeUI;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* @author Konstantin Bulenkov
*/
public class DarculaTreeUI extends BasicTreeUI {
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
public static ComponentUI createUI(JComponent c) {
return new DarculaTreeUI();
}
public static final String TREE_TABLE_TREE_KEY = "TreeTableTree";
public static final String SOURCE_LIST_CLIENT_PROPERTY = "mac.ui.source.list";
public static final String STRIPED_CLIENT_PROPERTY = "mac.ui.striped";
private static final Border LIST_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListBackgroundPainter");
private static final Border LIST_SELECTION_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListSelectionBackgroundPainter");
private static final Border LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER = UIManager.getBorder("List.sourceListFocusedSelectionBackgroundPainter");
private boolean myOldRepaintAllRowValue;
private boolean invertLineColor;
private boolean myForceDontPaintLines = false;
@Override
public int getRightChildIndent() {
return isSkinny() ? 8 : super.getRightChildIndent();
}
private static boolean isSkinny() {
return true;
}
private final MouseListener mySelectionListener = new MouseAdapter() {
boolean handled = false;
@Override
public void mousePressed(final MouseEvent e) {
handled = false;
if (!isSelected(e)) {
handled = true;
handle(e);
}
}
@Override
public void mouseReleased(final MouseEvent e) {
if (!handled) {
handle(e);
}
}
private boolean isSelected(MouseEvent e) {
final JTree tree = (JTree)e.getSource();
final int selected = tree.getClosestRowForLocation(e.getX(), e.getY());
final int[] rows = tree.getSelectionRows();
if (rows != null) {
for (int row : rows) {
if (row == selected) {
return true;
}
}
}
return false;
}
private void handle(MouseEvent e) {
final JTree tree = (JTree)e.getSource();
if (SwingUtilities.isLeftMouseButton(e) && !e.isPopupTrigger()) {
// if we can't stop any ongoing editing, do nothing
if (isEditing(tree) && tree.getInvokesStopCellEditing() && !stopEditing(tree)) {
return;
}
final TreePath pressedPath = getClosestPathForLocation(tree, e.getX(), e.getY());
if (pressedPath != null) {
Rectangle bounds = getPathBounds(tree, pressedPath);
if (e.getY() >= bounds.y + bounds.height) {
return;
}
if (bounds.contains(e.getPoint()) || isLocationInExpandControl(pressedPath, e.getX(), e.getY())) {
return;
}
if (tree.getDragEnabled() || !startEditing(pressedPath, e)) {
selectPathForEvent(pressedPath, e);
}
}
}
}
};
@Override
protected void completeUIInstall() {
super.completeUIInstall();
myOldRepaintAllRowValue = UIManager.getBoolean("Tree.repaintWholeRow");
UIManager.put("Tree.repaintWholeRow", true);
tree.setShowsRootHandles(true);
tree.addMouseListener(mySelectionListener);
}
@Override
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
UIManager.put("Tree.repaintWholeRow", myOldRepaintAllRowValue);
c.removeMouseListener(mySelectionListener);
}
@Override
protected void installKeyboardActions() {
super.installKeyboardActions();
if (Boolean.TRUE.equals(tree.getClientProperty("MacTreeUi.actionsInstalled"))) return;
tree.putClientProperty("MacTreeUi.actionsInstalled", Boolean.TRUE);
final InputMap inputMap = tree.getInputMap(JComponent.WHEN_FOCUSED);
inputMap.put(KeyStroke.getKeyStroke("pressed LEFT"), "collapse_or_move_up");
inputMap.put(KeyStroke.getKeyStroke("pressed RIGHT"), "expand");
final ActionMap actionMap = tree.getActionMap();
final Action expandAction = actionMap.get("expand");
if (expandAction != null) {
actionMap.put("expand", new TreeUIAction() {
@Override
public void actionPerformed(ActionEvent e) {
final Object source = e.getSource();
if (source instanceof JTree) {
JTree tree = (JTree)source;
int selectionRow = tree.getLeadSelectionRow();
if (selectionRow != -1) {
TreePath selectionPath = tree.getPathForRow(selectionRow);
if (selectionPath != null) {
boolean leaf = tree.getModel().isLeaf(selectionPath.getLastPathComponent());
int toSelect = -1;
int toScroll = -1;
if (!leaf && tree.isExpanded(selectionRow)) {
if (selectionRow + 1 < tree.getRowCount()) {
toSelect = selectionRow + 1;
toScroll = toSelect;
}
} else if (leaf) {
toScroll = selectionRow;
}
if (toSelect != -1) {
tree.setSelectionInterval(toSelect, toSelect);
}
if (toScroll != -1) {
tree.scrollRowToVisible(toScroll);
}
if (toSelect != -1 || toScroll != -1) return;
}
}
}
expandAction.actionPerformed(e);
}
});
}
actionMap.put("collapse_or_move_up", new TreeUIAction() {
@Override
public void actionPerformed(final ActionEvent e) {
final Object source = e.getSource();
if (source instanceof JTree) {
JTree tree = (JTree)source;
int selectionRow = tree.getLeadSelectionRow();
if (selectionRow == -1) return;
TreePath selectionPath = tree.getPathForRow(selectionRow);
if (selectionPath == null) return;
if (tree.getModel().isLeaf(selectionPath.getLastPathComponent()) || tree.isCollapsed(selectionRow)) {
final TreePath parentPath = tree.getPathForRow(selectionRow).getParentPath();
if (parentPath != null) {
if (parentPath.getParentPath() != null || tree.isRootVisible()) {
final int parentRow = tree.getRowForPath(parentPath);
tree.scrollRowToVisible(parentRow);
tree.setSelectionInterval(parentRow, parentRow);
}
}
}
else {
tree.collapseRow(selectionRow);
}
}
}
});
}
public void setForceDontPaintLines() {
myForceDontPaintLines = true;
}
private abstract static class TreeUIAction extends AbstractAction implements UIResource {
}
@Override
protected int getRowX(int row, int depth) {
return isSkinny() ? 8 * depth + 8 : super.getRowX(row, depth);
}
@Override
protected void paintHorizontalPartOfLeg(final Graphics g,
final Rectangle clipBounds,
final Insets insets,
final Rectangle bounds,
final TreePath path,
final int row,
final boolean isExpanded,
final boolean hasBeenExpanded,
final boolean isLeaf) {
}
private boolean shouldPaintLines() {
return myForceDontPaintLines || !"None".equals(tree.getClientProperty("JTree.lineStyle"));
}
@Override
protected boolean isToggleSelectionEvent(MouseEvent e) {
return SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown()) && !e.isPopupTrigger();
}
@Override
protected void paintVerticalPartOfLeg(final Graphics g, final Rectangle clipBounds, final Insets insets, final TreePath path) {
}
@Override
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom) {
}
@Override
protected Color getHashColor() {
if (invertLineColor && !equalsNullable(UIUtil.getTreeSelectionForeground(), UIUtil.getTreeForeground())) {
final Color c = UIUtil.getTreeSelectionForeground();
if (c != null) {
return c.darker();
}
}
return super.getHashColor();
}
private static <T> boolean equalsNullable(T a, T b) {
if (a == null) {
return b == null;
} else {
return b != null && a.equals(b);
}
}
@Override
protected void paintRow(final Graphics g,
final Rectangle clipBounds,
final Insets insets,
final Rectangle bounds,
final TreePath path,
final int row,
final boolean isExpanded,
final boolean hasBeenExpanded,
final boolean isLeaf) {
final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;
if (path != null) {
boolean selected = tree.isPathSelected(path);
Graphics2D rowGraphics = (Graphics2D)g.create();
rowGraphics.setClip(clipBounds);
final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
Color background = tree.getBackground();
if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) {
background = UIUtil.getDecoratedRowColor();
}
if (sourceList != null && (Boolean)sourceList) {
if (selected) {
if (tree.hasFocus()) {
LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
}
else {
LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
}
}
else {
rowGraphics.setColor(background);
rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
}
}
else {
if (selected) {
Color bg = UIUtil.getTreeSelectionBackground(tree.hasFocus() || Boolean.TRUE.equals(tree.getClientProperty(TREE_TABLE_TREE_KEY)));
rowGraphics.setColor(bg);
rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
}
}
if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
}
super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
rowGraphics.dispose();
}
else {
super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
}
}
@Override
public void paint(Graphics g, JComponent c) {
final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport) tree.getParent()).getViewPosition().x : 0;
final Rectangle bounds = g.getClipBounds();
// draw background for the given clip bounds
final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
if (sourceList != null && (Boolean) sourceList) {
Graphics2D backgroundGraphics = (Graphics2D) g.create();
backgroundGraphics.setClip(xOffset, bounds.y, containerWidth, bounds.height);
LIST_BACKGROUND_PAINTER.paintBorder(tree, backgroundGraphics, xOffset, bounds.y, containerWidth, bounds.height);
backgroundGraphics.dispose();
}
super.paint(g, c);
}
protected void paintSelectedRows(Graphics g, JTree tr) {
final Rectangle rect = tr.getVisibleRect();
final int firstVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y);
final int lastVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y + rect.height);
for (int row = firstVisibleRow; row <= lastVisibleRow; row++) {
if (tr.getSelectionModel().isRowSelected(row)) {
final Rectangle bounds = tr.getRowBounds(row);
Color color = UIUtil.getTreeSelectionBackground(tr.hasFocus());
if (color != null) {
g.setColor(color);
g.fillRect(0, bounds.y, tr.getWidth(), bounds.height);
}
}
}
}
@Override
protected CellRendererPane createCellRendererPane() {
return new CellRendererPane() {
@Override
public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate) {
if (c instanceof JComponent) {
((JComponent)c).setOpaque(false);
}
super.paintComponent(g, c, p, x, y, w, h, shouldValidate);
}
};
}
@Override
protected void paintExpandControl(Graphics g,
Rectangle clipBounds,
Insets insets,
Rectangle bounds,
TreePath path,
int row,
boolean isExpanded,
boolean hasBeenExpanded,
boolean isLeaf) {
boolean isPathSelected = tree.getSelectionModel().isPathSelected(path);
if (!isLeaf(row)) {
setExpandedIcon(UIUtil.getTreeNodeIcon(true, isPathSelected, tree.hasFocus()));
setCollapsedIcon(UIUtil.getTreeNodeIcon(false, isPathSelected, tree.hasFocus()));
}
super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
}
}

0
src/com/bulenkov/darcula/ui/win/DarculaWindowsInternalFrameUI.java

0
src/com/bulenkov/darcula/util/Animator.java

11
src/com/bulenkov/darcula/util/DarculaColors.java

@ -0,0 +1,11 @@
package com.bulenkov.darcula.util;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
public interface DarculaColors {
Color BLUE = new Color(0x589df6);
Color RED = new Color(0xff6464);
}

142
src/com/bulenkov/darcula/util/StringUtil.java

@ -1,142 +0,0 @@
package com.bulenkov.darcula.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author Konstantin Bulenkov
*/
public class StringUtil {
public static List<String> split(String s, String separator) {
return split(s, separator, true);
}
public static List<String> split(String s, String separator,
boolean excludeSeparator) {
return split(s, separator, excludeSeparator, true);
}
public static List<String> split(String s, String separator,
boolean excludeSeparator, boolean excludeEmptyStrings) {
if (separator.isEmpty()) {
return Collections.singletonList(s);
}
List<String> result = new ArrayList<String>();
int pos = 0;
while (true) {
int index = s.indexOf(separator, pos);
if (index == -1) break;
final int nextPos = index + separator.length();
String token = s.substring(pos, excludeSeparator ? index : nextPos);
if (!token.isEmpty() || !excludeEmptyStrings) {
result.add(token);
}
pos = nextPos;
}
if (pos < s.length() || (!excludeEmptyStrings && pos == s.length())) {
result.add(s.substring(pos, s.length()));
}
return result;
}
public static int naturalCompare(String string1, String string2) {
return naturalCompare(string1, string2, false);
}
private static int naturalCompare(String string1, String string2, boolean caseSensitive) {
final int string1Length = string1.length();
final int string2Length = string2.length();
for (int i = 0, j = 0; i < string1Length && j < string2Length; i++, j++) {
char ch1 = string1.charAt(i);
char ch2 = string2.charAt(j);
if ((isDigit(ch1) || ch1 == ' ') && (isDigit(ch2) || ch2 == ' ')) {
int startNum1 = i;
while (ch1 == ' ' || ch1 == '0') { // skip leading spaces and zeros
startNum1++;
if (startNum1 >= string1Length) break;
ch1 = string1.charAt(startNum1);
}
int startNum2 = j;
while (ch2 == ' ' || ch2 == '0') {
startNum2++;
if (startNum2 >= string2Length) break;
ch2 = string2.charAt(startNum2);
}
i = startNum1;
j = startNum2;
while (i < string1Length && isDigit(string1.charAt(i))) i++;
while (j < string2Length && isDigit(string2.charAt(j))) j++;
String digits1 = string1.substring(startNum1, i);
String digits2 = string2.substring(startNum2, j);
if (digits1.length() != digits2.length()) {
return digits1.length() - digits2.length();
}
int numberDiff = digits1.compareTo(digits2);
if (numberDiff != 0) {
return numberDiff;
}
i--;
j--;
final int lengthDiff = (i - startNum1) - (j - startNum2);
if (lengthDiff != 0) {
return lengthDiff;
}
for (; startNum1 < i; startNum1++, startNum2++) {
final int diff = string1.charAt(startNum1) - string2.charAt(startNum2);
if (diff != 0) {
return diff;
}
}
}
else {
if (caseSensitive) {
return ch1 - ch2;
}
else {
// similar logic to charsMatch() below
if (ch1 != ch2) {
final int diff1 = toUpperCase(ch1) - toUpperCase(ch2);
if (diff1 != 0) {
final int diff2 = toLowerCase(ch1) - toLowerCase(ch2);
if (diff2 != 0) {
return diff2;
}
}
}
}
}
}
if (!caseSensitive && string1Length == string2Length) {
// do case sensitive compare if case insensitive strings are equal
return naturalCompare(string1, string2, true);
}
return string1Length - string2Length;
}
public static char toUpperCase(char a) {
if (a < 'a') {
return a;
}
if (a <= 'z') {
return (char)(a + ('A' - 'a'));
}
return Character.toUpperCase(a);
}
public static char toLowerCase(char a) {
if (a < 'A' || a >= 'a' && a <= 'z') {
return a;
}
if (a <= 'Z') {
return (char)(a + ('a' - 'A'));
}
return Character.toLowerCase(a);
}
private static boolean isDigit(char c) {
return c >= '0' && c <= '9';
}
}

39
src/com/bulenkov/darcula/util/UIUtil.java

@ -1,39 +0,0 @@
package com.bulenkov.darcula.util;
import javax.swing.*;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
public class UIUtil {
public static <T extends JComponent> T findComponentOfType(JComponent parent, Class<T> cls) {
if (parent == null || cls.isAssignableFrom(parent.getClass())) {
@SuppressWarnings({"unchecked"}) final T t = (T)parent;
return t;
}
for (Component component : parent.getComponents()) {
if (component instanceof JComponent) {
T comp = findComponentOfType((JComponent)component, cls);
if (comp != null) return comp;
}
}
return null;
}
public static <T> T getParentOfType(Class<? extends T> cls, Component c) {
Component eachParent = c;
while (eachParent != null) {
if (cls.isAssignableFrom(eachParent.getClass())) {
@SuppressWarnings({"unchecked"}) final T t = (T)eachParent;
return t;
}
eachParent = eachParent.getParent();
}
return null;
}
}

0
swingset2/AquaTheme.java

0
swingset2/BezierAnimationPanel.java

0
swingset2/ButtonDemo.java

0
swingset2/CharcoalTheme.java

0
swingset2/CodeViewer.java

0
swingset2/ColorChooserDemo.java

0
swingset2/ComboBoxDemo.java

0
swingset2/ContrastTheme.java

0
swingset2/DemoModule.java

0
swingset2/DirectionPanel.java

0
swingset2/EmeraldTheme.java

0
swingset2/ExampleFileFilter.java

0
swingset2/ExampleFileView.java

0
swingset2/FileChooserDemo.java

0
swingset2/HtmlDemo.java

0
swingset2/InternalFrameDemo.java

0
swingset2/LayoutControlPanel.java

0
swingset2/ListDemo.java

0
swingset2/OptionPaneDemo.java

0
swingset2/Permuter.java

0
swingset2/ProgressBarDemo.java

0
swingset2/RubyTheme.java

0
swingset2/ScrollPaneDemo.java

0
swingset2/SliderDemo.java

0
swingset2/SplitPaneDemo.java

22
swingset2/SwingSet2.java

@ -38,24 +38,18 @@
*/ */
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*; import javax.swing.border.EtchedBorder;
import javax.swing.text.*; import javax.swing.event.ChangeEvent;
import javax.swing.border.*; import javax.swing.event.ChangeListener;
import javax.swing.colorchooser.*;
import javax.swing.filechooser.*;
import javax.accessibility.*;
import javax.swing.plaf.metal.DefaultMetalTheme; import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.plaf.metal.MetalLookAndFeel;
import java.lang.reflect.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.beans.*; import java.lang.reflect.Constructor;
import java.util.*; import java.util.Iterator;
import java.io.*; import java.util.MissingResourceException;
import java.applet.*; import java.util.ResourceBundle;
import java.net.*; import java.util.Vector;
/** /**
* A demo that shows all of the Swing components. * A demo that shows all of the Swing components.

0
swingset2/SwingSet2Applet.java

0
swingset2/TabbedPaneDemo.java

0
swingset2/TableDemo.java

15
swingset2/ToolTipDemo.java

@ -39,20 +39,7 @@
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.border.*;
import javax.swing.colorchooser.*;
import javax.swing.filechooser.*;
import javax.accessibility.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.util.*;
import java.io.*;
import java.applet.*;
import java.net.*;
/** /**
* ToolTip Demo * ToolTip Demo
@ -133,7 +120,7 @@ public class ToolTipDemo extends DemoModule {
if((x > 30) && (x < 60) && (y > 60) && (y < 85)) { if((x > 30) && (x < 60) && (y > 60) && (y < 85)) {
if(!moo) { if(!moo) {
setToolTipText("<html><center><font color=blue size=+2>" + setToolTipText("<html><center><font color='#589df6' size=+2>" +
getString("ToolTipDemo.moo") + "</font></center></html>"); getString("ToolTipDemo.moo") + "</font></center></html>");
moo = true; moo = true;
milk = false; milk = false;

0
swingset2/TreeDemo.java

0
swingset2/resources/ant.html

0
swingset2/resources/bug.html

0
swingset2/resources/images/About.jpg

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

0
swingset2/resources/images/ImageClub/COPYRIGHT

0
swingset2/resources/images/ImageClub/food/apple.jpg

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

0
swingset2/resources/images/ImageClub/food/asparagus.jpg

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

0
swingset2/resources/images/ImageClub/food/banana.jpg

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

0
swingset2/resources/images/ImageClub/food/broccoli.jpg

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

0
swingset2/resources/images/ImageClub/food/cantaloupe.jpg

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save