|
| 1 | +package com.fulinlin.ui.commit; |
| 2 | + |
| 3 | +import com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder; |
| 4 | +import com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI; |
| 5 | +import com.intellij.util.ui.JBInsets; |
| 6 | +import com.intellij.util.ui.MacUIUtil; |
| 7 | + |
| 8 | +import javax.swing.*; |
| 9 | +import javax.swing.text.JTextComponent; |
| 10 | +import java.awt.*; |
| 11 | +import java.awt.geom.Path2D; |
| 12 | +import java.awt.geom.Rectangle2D; |
| 13 | + |
| 14 | +import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.*; |
| 15 | + |
| 16 | +public class CommitDarculaTextBorder extends DarculaTextBorder { |
| 17 | + |
| 18 | + @Override |
| 19 | + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { |
| 20 | + if (((JComponent) c).getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE) return; |
| 21 | + |
| 22 | + Rectangle r = new Rectangle(x, y, width, height); |
| 23 | + boolean focused = isFocused(c); |
| 24 | + |
| 25 | + if (TextFieldWithPopupHandlerUI.isSearchField(c)) { |
| 26 | + paintSearchArea((Graphics2D) g, r, (JTextComponent) c, false); |
| 27 | + } else if (isTableCellEditor(c)) { |
| 28 | + paintCellEditorBorder((Graphics2D) g, c, r, focused); |
| 29 | + } else if (!(c.getParent() instanceof JComboBox)) { |
| 30 | + Graphics2D g2 = (Graphics2D) g.create(); |
| 31 | + try { |
| 32 | + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| 33 | + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, |
| 34 | + MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE); |
| 35 | + |
| 36 | + JBInsets.removeFrom(r, paddings()); |
| 37 | + g2.translate(r.x, r.y); |
| 38 | + |
| 39 | + float lw = lw(g2); |
| 40 | + float bw = bw(); |
| 41 | + |
| 42 | + clipForBorder(c, g2, r.width, r.height); |
| 43 | + /* |
| 44 | + Object op = ((JComponent) c).getClientProperty("JComponent.outline"); |
| 45 | + if (c.isEnabled() && op != null) { |
| 46 | + paintOutlineBorder(g2, r.width, r.height, 0, isSymmetric(), focused, Outline.valueOf(op.toString())); |
| 47 | + } else { |
| 48 | + Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD); |
| 49 | + border.append(new Rectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2), false); |
| 50 | + border.append(new Rectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2), false); |
| 51 | + boolean editable = !(c instanceof JTextComponent) || ((JTextComponent) c).isEditable(); |
| 52 | + g2.setColor(getOutlineColor(c.isEnabled() && editable, focused)); |
| 53 | + g2.fill(border); |
| 54 | + } |
| 55 | + */ |
| 56 | + Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD); |
| 57 | + border.append(new Rectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2), false); |
| 58 | + border.append(new Rectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2), false); |
| 59 | + g2.setColor(getOutlineColor(false, focused)); |
| 60 | + g2.fill(border); |
| 61 | + } finally { |
| 62 | + g2.dispose(); |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments