|
|
@ -63,7 +63,7 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh |
|
|
|
protected Color inactiveBackground; |
|
|
|
protected Color inactiveBackground; |
|
|
|
private long lastSearchEvent; |
|
|
|
private long lastSearchEvent; |
|
|
|
|
|
|
|
|
|
|
|
protected Insets padding; |
|
|
|
private int buttonPad; |
|
|
|
|
|
|
|
|
|
|
|
private final PopupMenuListener searchPopupListener = new PopupMenuAdapter() { |
|
|
|
private final PopupMenuListener searchPopupListener = new PopupMenuAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -118,9 +118,8 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh |
|
|
|
|
|
|
|
|
|
|
|
protected Dimension addIconSizes(final Dimension dim) { |
|
|
|
protected Dimension addIconSizes(final Dimension dim) { |
|
|
|
JTextComponent comp = getComponent(); |
|
|
|
JTextComponent comp = getComponent(); |
|
|
|
boolean ltr = comp.getComponentOrientation().isLeftToRight(); |
|
|
|
int leftPad = buttonPad; |
|
|
|
int leftPad = ltr ? padding.left : padding.right; |
|
|
|
int rightPad = buttonPad; |
|
|
|
int rightPad = ltr ? padding.right : padding.left; |
|
|
|
|
|
|
|
if (doPaintLeftIcon(comp)) { |
|
|
|
if (doPaintLeftIcon(comp)) { |
|
|
|
Icon left = getLeftIcon(comp); |
|
|
|
Icon left = getLeftIcon(comp); |
|
|
|
dim.width += left.getIconWidth() + leftPad; |
|
|
|
dim.width += left.getIconWidth() + leftPad; |
|
|
@ -157,12 +156,12 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh |
|
|
|
protected void adjustTextRect(final JTextComponent c, final Rectangle r) { |
|
|
|
protected void adjustTextRect(final JTextComponent c, final Rectangle r) { |
|
|
|
boolean ltr = c.getComponentOrientation().isLeftToRight(); |
|
|
|
boolean ltr = c.getComponentOrientation().isLeftToRight(); |
|
|
|
if (doPaintLeftIcon(c)) { |
|
|
|
if (doPaintLeftIcon(c)) { |
|
|
|
int w = getLeftIcon(c).getIconWidth() + padding.left; |
|
|
|
int w = getLeftIcon(c).getIconWidth() + buttonPad; |
|
|
|
if (ltr) r.x += w; |
|
|
|
if (ltr) r.x += w; |
|
|
|
r.width -= w; |
|
|
|
r.width -= w; |
|
|
|
} |
|
|
|
} |
|
|
|
if (doPaintRightIcon(c)) { |
|
|
|
if (doPaintRightIcon(c)) { |
|
|
|
int w = getRightIcon(c).getIconWidth() + padding.right; |
|
|
|
int w = getRightIcon(c).getIconWidth() + buttonPad; |
|
|
|
if (!ltr) r.x += w; |
|
|
|
if (!ltr) r.x += w; |
|
|
|
r.width -= w; |
|
|
|
r.width -= w; |
|
|
|
} |
|
|
|
} |
|
|
@ -192,10 +191,10 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh |
|
|
|
protected ClickAction getActionUnder(final Point p) { |
|
|
|
protected ClickAction getActionUnder(final Point p) { |
|
|
|
JTextComponent c = getComponent(); |
|
|
|
JTextComponent c = getComponent(); |
|
|
|
if (!c.isEnabled()) return ClickAction.NONE; |
|
|
|
if (!c.isEnabled()) return ClickAction.NONE; |
|
|
|
if (isOver(getRightIconCoord(), getRightIcon(c), p) && doPaintRightIcon(c)) { |
|
|
|
if (isOver(getRightIconPos(), getRightIcon(c), p) && doPaintRightIcon(c)) { |
|
|
|
return ClickAction.RIGHT_ACTION; |
|
|
|
return ClickAction.RIGHT_ACTION; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isOver(getLeftIconCoord(), getLeftIcon(c), p) && doPaintLeftIcon(c)) { |
|
|
|
if (isOver(getLeftIconPos(), getLeftIcon(c), p) && doPaintLeftIcon(c)) { |
|
|
|
return ClickAction.LEFT_ACTION; |
|
|
|
return ClickAction.LEFT_ACTION; |
|
|
|
} |
|
|
|
} |
|
|
|
return ClickAction.NONE; |
|
|
|
return ClickAction.NONE; |
|
|
@ -240,35 +239,43 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void paintRightIcon(final Graphics g) { |
|
|
|
protected void paintRightIcon(final Graphics g) { |
|
|
|
Point p = getRightIconCoord(); |
|
|
|
Point p = getRightIconPos(); |
|
|
|
getRightIcon(editor).paintIcon(null, g, p.x, p.y); |
|
|
|
getRightIcon(editor).paintIcon(null, g, p.x, p.y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void paintLeftIcon(final Graphics g) { |
|
|
|
protected void paintLeftIcon(final Graphics g) { |
|
|
|
Point p = getLeftIconCoord(); |
|
|
|
Point p = getLeftIconPos(); |
|
|
|
getLeftIcon(editor).paintIcon(null, g, p.x, p.y); |
|
|
|
getLeftIcon(editor).paintIcon(null, g, p.x, p.y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected Point getLeftIconCoord() { |
|
|
|
protected Point getLeftIconPos() { |
|
|
|
Rectangle r = getDrawingRect(getComponent()); |
|
|
|
Rectangle r = getDrawingRect(getComponent()); |
|
|
|
int w = getLeftIcon(getComponent()).getIconWidth(); |
|
|
|
int iconSize = getLeftIcon(getComponent()).getIconWidth(); |
|
|
|
int left = getBorderInsets(getComponent()).left + padding.left; |
|
|
|
int y = getIconY(r, iconSize); |
|
|
|
return DarkUIUtil.adjustForOrientation(new Point(r.x + left, r.y + (r.height - w) / 2), w, editor); |
|
|
|
return DarkUIUtil.adjustForOrientation(new Point(r.x + buttonPad, y), iconSize, editor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected Point getRightIconCoord() { |
|
|
|
private int getIconY(final Rectangle r, final int iconSize) { |
|
|
|
|
|
|
|
int contentHeight = r.height; |
|
|
|
|
|
|
|
Insets margin = editor.getMargin(); |
|
|
|
|
|
|
|
if (margin != null) contentHeight -= margin.top + margin.bottom; |
|
|
|
|
|
|
|
int y = r.y + (contentHeight - iconSize) / 2; |
|
|
|
|
|
|
|
if (margin != null) y += margin.top; |
|
|
|
|
|
|
|
return y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Point getRightIconPos() { |
|
|
|
Rectangle r = getDrawingRect(getComponent()); |
|
|
|
Rectangle r = getDrawingRect(getComponent()); |
|
|
|
int w = getRightIcon(getComponent()).getIconWidth(); |
|
|
|
int iconSize = getRightIcon(getComponent()).getIconWidth(); |
|
|
|
int right = getBorderInsets(getComponent()).right + padding.right; |
|
|
|
int y = getIconY(r, iconSize); |
|
|
|
return DarkUIUtil.adjustForOrientation(new Point(r.x + r.width - w - right, r.y + (r.height - w) / 2), w, |
|
|
|
return DarkUIUtil.adjustForOrientation(new Point(r.x + r.width - iconSize - buttonPad, y), iconSize, editor); |
|
|
|
editor); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void showSearchPopup() { |
|
|
|
protected void showSearchPopup() { |
|
|
|
if (lastSearchEvent == 0 || (System.currentTimeMillis() - lastSearchEvent) > 250) { |
|
|
|
if (lastSearchEvent == 0 || (System.currentTimeMillis() - lastSearchEvent) > 250) { |
|
|
|
JPopupMenu menu = getSearchPopup(getComponent()); |
|
|
|
JPopupMenu menu = getSearchPopup(getComponent()); |
|
|
|
if (menu != null) { |
|
|
|
if (menu != null) { |
|
|
|
menu.show(getComponent(), getLeftIconCoord().x, getComponent().getHeight()); |
|
|
|
menu.show(getComponent(), getLeftIconPos().x, getComponent().getHeight()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -291,8 +298,7 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh |
|
|
|
searchWithHistoryDisabled = UIManager.getIcon("TextField.search.searchWithHistory.disabled.icon"); |
|
|
|
searchWithHistoryDisabled = UIManager.getIcon("TextField.search.searchWithHistory.disabled.icon"); |
|
|
|
search = UIManager.getIcon("TextField.search.search.icon"); |
|
|
|
search = UIManager.getIcon("TextField.search.search.icon"); |
|
|
|
searchDisabled = UIManager.getIcon("TextField.search.search.disabled.icon"); |
|
|
|
searchDisabled = UIManager.getIcon("TextField.search.search.disabled.icon"); |
|
|
|
padding = UIManager.getInsets("TextField.insets"); |
|
|
|
buttonPad = UIManager.getInt("TextField.iconPad"); |
|
|
|
if (padding == null) padding = new Insets(0, 0, 0, 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|