Browse Source

fix internal frame border and title (pull request from Brian Hudson)

master
Konstantin Bulenkov 11 years ago
parent
commit
6da3450f6a
  1. BIN
      build/darcula.jar
  2. 2
      src/com/bulenkov/darcula/DarculaLaf.java
  3. 21
      src/com/bulenkov/darcula/darcula.properties
  4. BIN
      src/com/bulenkov/darcula/icons/internalFrame.png
  5. 32
      src/com/bulenkov/darcula/ui/DarculaInternalFrameBorder.java
  6. 232
      src/com/bulenkov/darcula/ui/DarculaInternalFrameUI.java

BIN
build/darcula.jar

Binary file not shown.

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

@ -98,7 +98,7 @@ public final class DarculaLaf extends BasicLookAndFeel {
defaults.put("Tree.expandedIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/treeNodeExpanded.png")));
defaults.put("CheckBoxMenuItem.checkIcon", EmptyIcon.create(16));
defaults.put("RadioButtonMenuItem.checkIcon", EmptyIcon.create(16));
defaults.put("InternalFrame.icon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/internalFrame.png")));
return defaults;
}
catch (Exception ignore) {

21
src/com/bulenkov/darcula/darcula.properties

@ -56,7 +56,7 @@ Table.descendingSortIcon=AllIcons.General.SplitDown
TableHeader.cellBorder=com.bulenkov.darcula.DarculaTableHeaderBorder
TitledBorder.titleColor=bbbbbb
internal
MenuBar.disabledBackground=3c3f41
MenuBar.shadow=3c3f41
MenuBar.darcula.borderColor=555555
@ -65,7 +65,7 @@ MenuBar.darcula.borderShadowColor=282828
TabbedPaneUI=com.bulenkov.darcula.ui.DarculaTabbedPaneUI
TabbedPane.tabInsets=0,4,0,4
TabbedPane.highlight=292b2d
TabbedPane.light=444444
TabbedPane.light=444444 internal
TabbedPane.selected=41516D
TabbedPane.selectHighlight=3c3f41
TabbedPane.contentBorderInsets=3,1,1,1
@ -166,4 +166,19 @@ Hyperlink.linkColor=589df6
#Tree.background=45494A
FileView.fileIcon=AllIcons.FileTypes.Unknown
FileView.fileIcon=AllIcons.FileTypes.Unknown
InternalFrameUI=com.bulenkov.darcula.ui.DarculaInternalFrameUI
InternalFrame.border=com.bulenkov.darcula.ui.DarculaInternalFrameBorder
InternalFrame.darcula.borderColor=5F5F5F
InternalFrame.darcula.borderInnerColor=3C3F41
InternalFrameTitlePane.darcula.borderColorTop=5F5F5F
InternalFrameTitlePane.darcula.borderColorLeft=27292A
InternalFrameTitlePane.darcula.borderColorBottom=3C3F41
InternalFrameTitlePane.darcula.selected.borderColorTop=566172
InternalFrameTitlePane.darcula.selected.borderColorLeft=27292A
InternalFrameTitlePane.darcula.selected.borderColorBottom=313C4C
InternalFrameTitlePane.darcula.backgroundColor=3A3D3F
InternalFrameTitlePane.darcula.selected.backgroundColor=424D5F
InternalFrameTitlePane.darcula.buttonColor=8B8B8B
InternalFrameTitlePane.darcula.hovered.buttonColor=A8A8A8

BIN
src/com/bulenkov/darcula/icons/internalFrame.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

32
src/com/bulenkov/darcula/ui/win/DarculaWindowsInternalFrameUI.java → src/com/bulenkov/darcula/ui/DarculaInternalFrameBorder.java

@ -14,25 +14,31 @@
* limitations under the License.
*/
package com.bulenkov.darcula.ui.win;
package com.bulenkov.darcula.ui;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
public class DarculaWindowsInternalFrameUI extends BasicInternalFrameUI {
public DarculaWindowsInternalFrameUI(JInternalFrame b) {
super(b);
}
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
public static ComponentUI createUI(JComponent c) {
return new DarculaWindowsInternalFrameUI(((JInternalFrame) c));
}
public class DarculaInternalFrameBorder implements Border, UIResource {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.setColor(UIManager.getColor("InternalFrame.darcula.borderColor"));
g.drawRect(x, y, w-1, h-1);
}
@Override
public Insets getBorderInsets(Component c) {
return new InsetsUIResource(1, 1, 1, 1);
}
@Override
public boolean isBorderOpaque() {
return true;
}
}

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

@ -15,41 +15,233 @@
*/
package com.bulenkov.darcula.ui;
import com.bulenkov.iconloader.util.GraphicsConfig;
import com.bulenkov.iconloader.util.GraphicsUtil;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* @author Konstantin Bulenkov
*/
public class DarculaInternalFrameUI extends BasicInternalFrameUI {
public DarculaInternalFrameUI(JInternalFrame b) {
super(b);
}
public DarculaInternalFrameUI(JInternalFrame b) {
super(b);
}
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
public static ComponentUI createUI(JComponent c) {
return new DarculaInternalFrameUI((JInternalFrame)c);
}
@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 installDefaults() {
super.installDefaults();
closeIcon = new CloseIcon();
maxIcon = new MaximizeIcon();
minIcon = new MinimizeIcon();
iconIcon = new IconifyIcon();
selectedTitleColor = UIManager.getColor("InternalFrameTitlePane.darcula.selected.backgroundColor");
selectedTextColor = UIManager.getColor("darcula.textForeground");
notSelectedTitleColor = UIManager.getColor("InternalFrameTitlePane.darcula.backgroundColor");
notSelectedTextColor = UIManager.getColor("darcula.textForeground");
}
@Override
protected void createButtons() {
super.createButtons();
MouseListener listener = new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
Icon icon = ((JButton) e.getComponent()).getIcon();
if (icon instanceof FrameIcon) {
Color c = ((FrameIcon) icon).getColor();
((FrameIcon) icon).setColor(c.brighter());
e.getComponent().repaint();
}
}
@Override
public void mouseExited(MouseEvent e) {
Icon icon = ((JButton) e.getComponent()).getIcon();
if (icon instanceof FrameIcon) {
((FrameIcon) icon).setColor(UIManager.getColor("InternalFrameTitlePane.darcula.buttonColor"));
e.getComponent().repaint();
}
}
};
closeButton.setBorder(null);
closeButton.setOpaque(false);
closeButton.addMouseListener(listener);
maxButton.setBorder(null);
maxButton.setOpaque(false);
maxButton.addMouseListener(listener);
iconButton.setBorder(null);
iconButton.setOpaque(false);
iconButton.addMouseListener(listener);
}
@Override
protected void paintBorder(Graphics g) {
int w = getWidth();
int h = getHeight();
Color top = UIManager.getColor("InternalFrameTitlePane.darcula.borderColorTop");
Color left = UIManager.getColor("InternalFrameTitlePane.darcula.borderColorLeft");
Color bottom = UIManager.getColor("InternalFrameTitlePane.darcula.borderColorBottom");
if (frame.isSelected()) {
top = UIManager.getColor("InternalFrameTitlePane.darcula.selected.borderColorTop");
left = UIManager.getColor("InternalFrameTitlePane.darcula.selected.borderColorLeft");
bottom = UIManager.getColor("InternalFrameTitlePane.darcula.selected.borderColorBottom");
}
g.setColor(top);
g.drawLine(2, 0, w, 0);
g.setColor(left);
g.drawLine(0, 1, 0, h);
g.setColor(bottom);
g.drawLine(2, h, w, h);
}
};
this.titlePane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 0));
return this.titlePane;
}
private static abstract class FrameIcon implements Icon {
private Color mColor;
public FrameIcon(Color c) {
mColor = c;
}
public Color getColor() {
return mColor;
}
public void setColor(Color c) {
mColor = c;
}
@Override
public int getIconWidth() {
return 16;
}
@Override
public int getIconHeight() {
return 16;
}
}
private static class CloseIcon extends FrameIcon {
public CloseIcon() {
this(UIManager.getColor("InternalFrameTitlePane.darcula.buttonColor"));
}
public CloseIcon(Color c) {
super(c);
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g;
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.setStroke(new BasicStroke(1.5f));
g2.setPaint(getColor());
g.drawLine(5, 4, 11, 10);
g.drawLine(11, 4, 5, 10);
config.restore();
}
}
private static class MaximizeIcon extends FrameIcon {
public MaximizeIcon() {
this(UIManager.getColor("InternalFrameTitlePane.darcula.buttonColor"));
}
public MaximizeIcon(Color c) {
super(c);
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g;
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
g2.setStroke(new BasicStroke(2f));
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.setPaint(getColor());
g2.setStroke(new BasicStroke(2f));
g2.drawRect(3, 3, 10, 9);
config.restore();
}
}
@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;
protected void installDefaults() {
super.installDefaults();
}
private static class MinimizeIcon extends FrameIcon {
public MinimizeIcon() {
this(UIManager.getColor("InternalFrameTitlePane.darcula.buttonColor"));
}
public MinimizeIcon(Color c) {
super(c);
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g;
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
g2.setStroke(new BasicStroke(2f));
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.setPaint(getColor());
g2.setStroke(new BasicStroke(2f));
g2.drawRect(1, 5, 8, 8);
g2.drawLine(4, 2, 12, 2);
g2.drawLine(12, 3, 12, 10);
config.restore();
}
}
private static class IconifyIcon extends FrameIcon {
public IconifyIcon() {
this(UIManager.getColor("InternalFrameTitlePane.darcula.buttonColor"));
}
public IconifyIcon(Color c) {
super(c);
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g;
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.setPaint(getColor());
g2.setStroke(new BasicStroke(2f));
g2.drawLine(4, 12, 12, 12);
config.restore();
}
}
}

Loading…
Cancel
Save