private static Icon getIcon(String suffix, AbstractButton button) { boolean isDefault = isDefaultButton(button); boolean isFocused = button.hasFocus(); boolean combo = isComboButton(button); String comboPrefix = combo ? "Combo" : ""; String iconName = "button" + comboPrefix + suffix; return MacIntelliJIconCache.getIcon(iconName, isDefault, isFocused && !combo); }
@Override public void paint(Graphics g, JComponent c) { if (!(c.getBorder() instanceof MacIntelliJButtonBorder) && !isComboButton(c)) { super.paint(g, c); return; } int w = c.getWidth(); int h = c.getHeight(); if (isHelpButton(c)) { Icon icon = MacIntelliJIconCache.getIcon("helpButton", false, c.hasFocus()); int x = (w - icon.getIconWidth()) / 2; int y = (h - icon.getIconHeight()) / 2; icon.paintIcon(c, g, x, y); } else { AbstractButton b = (AbstractButton) c; String text = layout(b, SwingUtilities2.getFontMetrics(b, g), b.getWidth(), b.getHeight()); boolean isFocused = c.hasFocus(); if (isSquare(c)) { Icon icon = MacIntelliJIconCache.getIcon("browseButton"); int x = (c.getWidth() - icon.getIconWidth()) / 2; int y = (c.getHeight() - icon.getIconHeight()) / 2; icon.paintIcon(c, g, x, y); return; } else { int x = isFocused ? 0 : 2; int y = isFocused ? 0 : (h - viewRect.height) / 2; Icon icon; icon = getLeftIcon(b); icon.paintIcon(b, g, x, y); x += icon.getIconWidth(); int stop = w - (isFocused ? 0 : 2) - (getRightIcon(b).getIconWidth()); Graphics gg = g.create(0, 0, w, h); gg.setClip(x, y, stop - x, h); icon = getMiddleIcon(b); while (x < stop) { icon.paintIcon(b, gg, x, y); x += icon.getIconWidth(); } gg.dispose(); icon = getRightIcon(b); icon.paintIcon(b, g, stop, y); clearTextShiftOffset(); } // Paint the Icon if (b.getIcon() != null) { paintIcon(g, c, iconRect); } if (text != null && !text.isEmpty()) { View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g, textRect); } else { UISettings.setupAntialiasing(g); paintText(g, b, textRect, text); } } } }