mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
+ Tests
This commit is contained in:
+2
-1
@@ -17,6 +17,7 @@ package com.intellij.ide.util.treeView;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -167,7 +168,7 @@ public abstract class PresentableNodeDescriptor<E> extends NodeDescriptor<E> {
|
||||
}
|
||||
|
||||
public Color getHighlightColor() {
|
||||
return UIUtil.isUnderDarcula() ? UIUtil.getPanelBackground().brighter() : UIUtil.getTreeBackground().brighter();
|
||||
return UIUtil.isUnderDarcula() ? Gray._100 : UIUtil.getTreeBackground().brighter();
|
||||
}
|
||||
|
||||
public static class ColoredFragment {
|
||||
|
||||
@@ -21,7 +21,8 @@ import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
@@ -104,8 +105,7 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
static void initIdeaDefaults(UIDefaults defaults) {
|
||||
loadDefaults(defaults, null); //load defaults
|
||||
loadDefaults(defaults, SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux"); // load OS customization
|
||||
loadDefaults(defaults);
|
||||
defaults.put("Table.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
|
||||
"ctrl C", "copy",
|
||||
"ctrl V", "paste",
|
||||
@@ -158,44 +158,70 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
}));
|
||||
}
|
||||
|
||||
private static void loadDefaults(UIDefaults defaults, @Nullable String postfix) {
|
||||
private static void loadDefaults(UIDefaults defaults) {
|
||||
final Properties properties = new Properties();
|
||||
final String osSuffix = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux";
|
||||
try {
|
||||
final Properties properties = new Properties();
|
||||
final String secondPart = postfix == null ? "" : "_" + postfix;
|
||||
final String name = "darcula" + secondPart + ".properties";
|
||||
final InputStream stream = DarculaLaf.class.getResourceAsStream(name);
|
||||
InputStream stream = DarculaLaf.class.getResourceAsStream("darcula.properties");
|
||||
properties.load(stream);
|
||||
stream.close();
|
||||
|
||||
stream = DarculaLaf.class.getResourceAsStream("darcula_" + osSuffix + ".properties");
|
||||
properties.load(stream);
|
||||
stream.close();
|
||||
|
||||
HashMap<String, Object> darculaGlobalSettings = new HashMap<String, Object>();
|
||||
final String prefix = "darcula.";
|
||||
for (String key : properties.stringPropertyNames()) {
|
||||
final String value = properties.getProperty(key);
|
||||
if (key.endsWith("Insets")) {
|
||||
final List<String> numbers = StringUtil.split(value, ",");
|
||||
defaults.put(key, new InsetsUIResource(Integer.parseInt(numbers.get(0)),
|
||||
Integer.parseInt(numbers.get(1)),
|
||||
Integer.parseInt(numbers.get(2)),
|
||||
Integer.parseInt(numbers.get(3))));
|
||||
} else if (key.endsWith(".border")) {
|
||||
try {
|
||||
defaults.put(key, Class.forName(value).newInstance());
|
||||
} catch (Exception e) {log(e);}
|
||||
} else {
|
||||
final Color color = ColorUtil.fromHex(value, null);
|
||||
final Integer invVal = getInteger(value);
|
||||
Icon icon = value != null && value.startsWith("AllIcons.") ? IconLoader.getIcon(value) : null;
|
||||
if (color != null) {
|
||||
defaults.put(key, new ColorUIResource(color));
|
||||
} else if (invVal != null) {
|
||||
defaults.put(key, invVal);
|
||||
} else if (icon != null) {
|
||||
defaults.put(key, new IconUIResource(icon));
|
||||
} else {
|
||||
defaults.put(key, value);
|
||||
if (key.startsWith(prefix)) {
|
||||
darculaGlobalSettings.put(key.substring(prefix.length()), parseValue(key, properties.getProperty(key)));
|
||||
}
|
||||
}
|
||||
|
||||
for (Object key : defaults.keySet()) {
|
||||
if (key instanceof String && ((String)key).contains(".")) {
|
||||
final String s = (String)key;
|
||||
final String darculaKey = s.substring(s.lastIndexOf('.') + 1);
|
||||
if (darculaGlobalSettings.containsKey(darculaKey)) {
|
||||
defaults.put(key, darculaGlobalSettings.get(darculaKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String key : properties.stringPropertyNames()) {
|
||||
final String value = properties.getProperty(key);
|
||||
defaults.put(key, parseValue(key, value));
|
||||
}
|
||||
}
|
||||
catch (IOException e) {log(e);}
|
||||
}
|
||||
|
||||
private static Object parseValue(String key, @NotNull String value) {
|
||||
if (key.endsWith("Insets")) {
|
||||
final List<String> numbers = StringUtil.split(value, ",");
|
||||
return new InsetsUIResource(Integer.parseInt(numbers.get(0)),
|
||||
Integer.parseInt(numbers.get(1)),
|
||||
Integer.parseInt(numbers.get(2)),
|
||||
Integer.parseInt(numbers.get(3)));
|
||||
} else if (key.endsWith(".border")) {
|
||||
try {
|
||||
return Class.forName(value).newInstance();
|
||||
} catch (Exception e) {log(e);}
|
||||
} else {
|
||||
final Color color = ColorUtil.fromHex(value, null);
|
||||
final Integer invVal = getInteger(value);
|
||||
Icon icon = value.startsWith("AllIcons.") ? IconLoader.getIcon(value) : null;
|
||||
if (color != null) {
|
||||
return new ColorUIResource(color);
|
||||
} else if (invVal != null) {
|
||||
return invVal;
|
||||
} else if (icon != null) {
|
||||
return new IconUIResource(icon);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Integer getInteger(String value) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
|
||||
@@ -1,84 +1,50 @@
|
||||
darcula.background=535353
|
||||
darcula.textBackground=535353
|
||||
darcula.foreground=eeeeee
|
||||
darcula.textForeground=eeeeee
|
||||
darcula.caretForeground=eeeeee
|
||||
|
||||
text=eeeeee
|
||||
|
||||
Menu.maxGutterIconWidth=18
|
||||
MenuItem.maxGutterIconWidth=18
|
||||
MenuItem.acceleratorDelimiter=-
|
||||
|
||||
#Trees
|
||||
Tree.background=535353
|
||||
Tree.foreground=eeeeee
|
||||
Tree.textForeground=eeeeee
|
||||
Tree.textBackground=535353
|
||||
#Tree.selectionBackground=BEBEBE
|
||||
#Tree.selectionForeground=535353
|
||||
|
||||
EditorPane.background=535353
|
||||
EditorPane.inactiveBackground=535353
|
||||
EditorPane.foreground=eeeeee
|
||||
EditorPane.inactiveForeground=eeeeee
|
||||
EditorPaneUI=com.intellij.ide.ui.laf.darcula.ui.DarculaEditorPaneUI
|
||||
|
||||
#Lists
|
||||
List.background=535353
|
||||
List.foreground=eeeeee
|
||||
|
||||
#Tables
|
||||
Table.background=535353
|
||||
Table.foreground=eeeeee
|
||||
control=535353
|
||||
Panel.background=535353
|
||||
Panel.foreground=eeeeee
|
||||
|
||||
ScrollBarUI=com.intellij.ide.ui.laf.darcula.ui.DarculaScrollBarUI
|
||||
|
||||
Menu.selectionBackground=bebebe
|
||||
MenuBar.background=535353
|
||||
MenuBar.disabledBackground=535353
|
||||
MenuBar.shadow=535353
|
||||
Menu.background=535353
|
||||
MenuItem.background=535353
|
||||
Menu.foreground=eeeeee
|
||||
MenuItem.foreground=eeeeee
|
||||
TabbedPane.tabInsets=0,4,0,4
|
||||
ToggleButton.foreground=eeeeee
|
||||
Separator.background=535353
|
||||
Separator.foreground=888888
|
||||
|
||||
Label.background=535353
|
||||
Label.foreground=eeeeee
|
||||
Focus.color=ff0000
|
||||
|
||||
TextField.background=535353
|
||||
TextField.foreground=eeeeee
|
||||
TextField.caretForeground=eeeeee
|
||||
#TextFieldUI=com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI
|
||||
TextField.background=737373
|
||||
TextFieldUI=com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI
|
||||
TextField.border=com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder
|
||||
|
||||
PasswordField.background=535353
|
||||
PasswordField.foreground=eeeeee
|
||||
PasswordField.caretForeground=eeeeee
|
||||
PasswordField.background=aaaaaa
|
||||
|
||||
TextArea.background=535353
|
||||
TextArea.foreground=eeeeee
|
||||
TextArea.caretForeground=eeeeee
|
||||
|
||||
TextPane.background=535353
|
||||
TextPane.foreground=eeeeee
|
||||
TextPane.caretForeground=eeeeee
|
||||
|
||||
CheckBox.background=535353
|
||||
CheckBox.foreground=eeeeee
|
||||
CheckBoxUI=com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxUI
|
||||
|
||||
RadioButton.foreground=eeeeee
|
||||
RadioButton.background=535353
|
||||
#ComboBoxUI=com.intellij.ide.ui.laf.darcula.ui.DarculaComboBoxUI
|
||||
ComboBox.background=eeeeee
|
||||
ComboBox.foreground=000000
|
||||
RadioButtonUI=com.intellij.ide.ui.laf.darcula.ui.DarculaRadioButtonUI
|
||||
|
||||
StatusBar.topColor=2c2c2c
|
||||
StatusBar.top2Color=2c2c2c
|
||||
StatusBar.bottomColor=2c2c2c
|
||||
|
||||
Button.foreground=eeeeee
|
||||
Button.background=535353
|
||||
Button.border=com.intellij.ide.ui.laf.darcula.ui.DarculaButtonPainter
|
||||
#ButtonUI=com.intellij.ide.ui.laf.borders.DarculaButtonUI
|
||||
|
||||
MenuItem.acceleratorForeground=eeeeee
|
||||
PopupMenu.background=535353
|
||||
PopupMenu.translucentBackground=535353
|
||||
|
||||
+1
-1
@@ -63,6 +63,6 @@ public class DarculaButtonPainter implements Border, UIResource {
|
||||
|
||||
@Override
|
||||
public boolean isBorderOpaque() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicButtonUI;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaComboBoxButton extends JButton {
|
||||
private final JComboBox myComboBox;
|
||||
|
||||
public DarculaComboBoxButton(JComboBox comboBox) {
|
||||
myComboBox = comboBox;
|
||||
setUI(new BasicButtonUI() {
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
final Icon i;
|
||||
if (myComboBox.isEditable()) {
|
||||
g.drawLine(0,0,0,c.getHeight());
|
||||
i = AllIcons.Mac.Tree_white_down_arrow;
|
||||
} else {
|
||||
i = AllIcons.Ide.Statusbar_arrows;
|
||||
}
|
||||
i.paintIcon(c, g, (c.getWidth() - i.getIconWidth()) / 2, (c.getHeight() - i.getIconHeight()) / 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
return super.getPreferredSize(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicComboBoxUI;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaComboBoxUI extends BasicComboBoxUI {
|
||||
private final JComboBox myComboBox;
|
||||
|
||||
public DarculaComboBoxUI(JComboBox c) {
|
||||
myComboBox = c;
|
||||
c.setBorder(null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new DarculaComboBoxUI(((JComboBox)c));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutManager createLayoutManager() {
|
||||
return new DarculaComboBoxLayoutManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus) {
|
||||
super.paintCurrentValueBackground(g, bounds, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
super.paint(g, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createArrowButton() {
|
||||
return new DarculaComboBoxButton(myComboBox);
|
||||
}
|
||||
|
||||
class DarculaComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager {
|
||||
public void layoutContainer(final Container parent) {
|
||||
if (arrowButton != null && !comboBox.isEditable()) {
|
||||
final Insets insets = comboBox.getInsets();
|
||||
final int width = comboBox.getWidth();
|
||||
final int height = comboBox.getHeight();
|
||||
arrowButton.setBounds(insets.left, insets.top, width - (insets.left + insets.right), height - (insets.top + insets.bottom));
|
||||
return;
|
||||
}
|
||||
|
||||
final JComboBox cb = (JComboBox)parent;
|
||||
final int width = cb.getWidth();
|
||||
final int height = cb.getHeight();
|
||||
|
||||
final Insets insets = getInsets();
|
||||
final int buttonHeight = height - (insets.top + insets.bottom);
|
||||
final int buttonWidth = 20;
|
||||
|
||||
if (arrowButton != null) {
|
||||
arrowButton.setBounds(width - (insets.right + buttonWidth), insets.top, buttonWidth, buttonHeight);
|
||||
}
|
||||
|
||||
if (editor != null) {
|
||||
final Rectangle editorRect = rectangleForCurrentValue();
|
||||
editorRect.width += 4;
|
||||
editor.setBounds(editorRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaScrollBarUI extends ButtonlessScrollBarUI {
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new DarculaScrollBarUI();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
<?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="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>
|
||||
<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="7" column-count="7" 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="6" 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="6" 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="5" column="0" row-span="1" col-span="7" 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>
|
||||
</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">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</tabbedpane>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
<group name="myGroup1">
|
||||
<member id="1935f"/>
|
||||
<member id="3443a"/>
|
||||
<member id="46c61"/>
|
||||
<member id="b4c96"/>
|
||||
<member id="3f56f"/>
|
||||
</group>
|
||||
</buttonGroups>
|
||||
</form>
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaLaf;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaTest {
|
||||
private JBCheckBox myJBCheckBox1;
|
||||
private JBCheckBox myJBCheckBox2;
|
||||
private JBCheckBox myJBCheckBox3;
|
||||
private JBCheckBox myJBCheckBox4;
|
||||
private JBCheckBox myJBCheckBox5;
|
||||
private JComboBox myComboBox1;
|
||||
private JComboBox myComboBox2;
|
||||
private JComboBox myComboBox3;
|
||||
private JComboBox myComboBox4;
|
||||
private JComboBox myComboBox5;
|
||||
private JTextField myTextField1;
|
||||
private JTextField myThisTextIsDisabledTextField;
|
||||
private JPasswordField myPasswordField1;
|
||||
private JPanel myRoot;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(new DarculaLaf());
|
||||
}
|
||||
catch (UnsupportedLookAndFeelException ignored) {}
|
||||
final JFrame frame = new JFrame("Darcula Demo");
|
||||
frame.setSize(600, 500);
|
||||
frame.setContentPane(new DarculaTest().myRoot);
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
frame.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaTextBorder implements Border, UIResource {
|
||||
private JBInsets myInsets = new JBInsets(4, 7, 4, 7);
|
||||
|
||||
@Override
|
||||
public JBInsets getBorderInsets(Component c) {
|
||||
return myInsets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderOpaque() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) {
|
||||
Graphics2D g = ((Graphics2D)g2);
|
||||
g.setColor(ColorUtil.fromHex("737373"));
|
||||
int cX = myInsets.right;
|
||||
int cY = myInsets.top;
|
||||
int cW = width - myInsets.width();
|
||||
int cH = height - myInsets.height();
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
g.translate(x, y);
|
||||
|
||||
if (c.hasFocus()) {
|
||||
int sysOffX = SystemInfo.isMac ? 0 : 1;
|
||||
int sysOffY = SystemInfo.isMac ? 0 : -1;
|
||||
DarculaUIUtil.paintFocusRing(g, 2, 2, width-4, height-4);
|
||||
|
||||
//g.setColor(DarculaUIUtil.GLOW_COLOR.darker().darker());
|
||||
//g.drawRect(1, 1, width - 2, height - 2);
|
||||
//g.drawRect(2, 2, width-4, height-4);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 70));
|
||||
//g.drawRoundRect(0, 0, width, height, 5, 5);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 80));
|
||||
//g.drawRoundRect(1, 1, width - 2, height-2, 5, 5);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 120));
|
||||
//g.drawRoundRect(2, 2, width - 4, height - 4, 5, 5);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 140));
|
||||
//g.drawRoundRect(3, 2, width - 6, height - 4, 5, 5);
|
||||
} else {
|
||||
//g.fillRect(2, 1, cX-2, height - 2); //left
|
||||
//g.fillRect(cX + cW , 1, width-cW - cX, height - 2); //right
|
||||
//g.fillRect(1, 1, width - 2, cY); //top
|
||||
//g.fillRect(1, cY + cH, width - 2, height - 2); //bottom
|
||||
g.setColor(ColorUtil.fromHex("939393"));
|
||||
g.drawRect(1, 1, width - 2, height - 2);
|
||||
}
|
||||
g.translate(-x, -y);
|
||||
config.restore();
|
||||
}
|
||||
}
|
||||
+59
-1
@@ -15,9 +15,17 @@
|
||||
*/
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicTextFieldUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -25,7 +33,57 @@ import javax.swing.plaf.basic.BasicTextFieldUI;
|
||||
public class DarculaTextFieldUI extends BasicTextFieldUI {
|
||||
|
||||
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
public static ComponentUI createUI(final JComponent c) {
|
||||
c.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
c.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
c.repaint();
|
||||
}
|
||||
});
|
||||
return new DarculaTextFieldUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintSafely(Graphics g) {
|
||||
super.paintSafely(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
final JTextComponent c = getComponent();
|
||||
final Container parent = c.getParent();
|
||||
if (parent != null) {
|
||||
g.setColor(parent.getBackground());
|
||||
g.fillRect(0,0,c.getWidth(), c.getHeight());
|
||||
}
|
||||
final Border border = c.getBorder();
|
||||
if (border instanceof DarculaTextBorder) {
|
||||
g.setColor(c.getBackground());
|
||||
final int width = c.getWidth();
|
||||
final int height = c.getHeight();
|
||||
final JBInsets insets = ((DarculaTextBorder)border).getBorderInsets(c);
|
||||
if (c.hasFocus()) {
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
g.fillRoundRect(insets.left-5, insets.top-2, width - insets.width() + 10, height - insets.height() + 6, 5, 5);
|
||||
config.restore();
|
||||
} else {
|
||||
g.fillRect(insets.left-5, insets.top-2, width - insets.width() + 12, height - insets.height() + 6);
|
||||
}
|
||||
} else {
|
||||
super.paintBackground(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user