public int getIconHeight(SynthContext context) { Icon icon = getIcon(context); if (icon != null) { return icon.getIconHeight(); } return 0; }
protected Rectangle rectangleForArrowIcon() { Rectangle b = comboBox.getBounds(); Border border = comboBox.getBorder(); Insets in; if (border != null) { in = border.getBorderInsets(comboBox); } else { in = new Insets(0, 0, 0, 0); } b.x = in.left; b.y = in.top; b.width -= (in.left + in.right); b.height -= (in.top + in.bottom); if (MotifGraphicsUtils.isLeftToRight(comboBox)) { b.x = b.x + b.width - HORIZ_MARGIN - arrowIcon.getIconWidth(); } else { b.x += HORIZ_MARGIN; } b.y = b.y + (b.height - arrowIcon.getIconHeight()) / 2; b.width = arrowIcon.getIconWidth(); b.height = arrowIcon.getIconHeight(); return b; }
public static Dimension getPreferredSize(AbstractButton b) { String style = (String) b.getClientProperty("Quaqua.Button.style"); if (style == null) { style = "push"; } if (style.equals("help")) { Icon helpIcon = UIManager.getIcon("Button.helpIcon"); Insets insets = b.getInsets(); return new Dimension( helpIcon.getIconWidth() + insets.left + insets.right, helpIcon.getIconHeight() + insets.top + insets.bottom); } if (b.getComponentCount() > 0) { return null; } int textIconGap = Methods.invokeGetter(b, "getIconTextGap", 4); Icon icon = (Icon) b.getIcon(); String text = b.getText(); Font font = b.getFont(); FontMetrics fm = b.getFontMetrics(font); viewR.x = viewR.y = 0; viewR.width = Short.MAX_VALUE; viewR.height = Short.MAX_VALUE; iconR.x = iconR.y = iconR.width = iconR.height = 0; textR.x = textR.y = textR.width = textR.height = 0; SwingUtilities.layoutCompoundLabel( (JComponent) b, fm, text, icon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewR, iconR, textR, (text == null ? 0 : textIconGap)); /* The preferred size of the button is the size of * the text and icon rectangles plus the buttons insets. */ Rectangle r = iconR.union(textR); // if (b.isBorderPainted()) { Insets insets = b.getInsets(); r.width += insets.left + insets.right; r.height += insets.top + insets.bottom; // } if (!QuaquaUtilities.isSmallSizeVariant(b) && style.equals("push") && b.getIcon() == null && b.getText() != null) { r.width = Math.max(r.width, UIManager.getInt("Button.minimumWidth")); } return r.getSize(); }