| 6964 | /// |
| 6965 | /// - `size`: the size of the icon in millimeters, or -1 to use the default height of the font |
| 6966 | public static void setIcon(IconHolder l, Font font, char icon, float size) { |
| 6967 | Style s = new Style(l.getIconStyleComponent().getUnselectedStyle()); |
| 6968 | s.setFont(font.derive(rightSize(s, size), Font.STYLE_PLAIN)); |
| 6969 | l.setIcon(FontImage.create("" + icon, s)); |
| 6970 | if (l instanceof SelectableIconHolder) { |
| 6971 | SelectableIconHolder b = (SelectableIconHolder) l; |
| 6972 | Style sel = b.getIconStyleComponent().getSelectedStyle(); |
| 6973 | Style pre = b.getIconStyleComponent().getPressedStyle(); |
| 6974 | Style dis = b.getIconStyleComponent().getDisabledStyle(); |
| 6975 | if (sel.getFgColor() != s.getFgColor() || (sel.getBgColor() != s.getBgColor()) || (sel.getBgTransparency() != s.getBgTransparency()) || (sel.getFgAlpha() != s.getFgAlpha())) { |
| 6976 | sel = new Style(sel); |
| 6977 | sel.setFont(font.derive(rightSize(sel, size), Font.STYLE_PLAIN)); |
| 6978 | b.setRolloverIcon(FontImage.create("" + icon, sel)); |
| 6979 | } else { |
| 6980 | b.setRolloverIcon(null); |
| 6981 | } |
| 6982 | if (pre.getFgColor() != s.getFgColor() || (pre.getBgColor() != s.getBgColor()) || (pre.getBgTransparency() != s.getBgTransparency()) || (pre.getFgAlpha() != s.getFgAlpha())) { |
| 6983 | pre = new Style(pre); |
| 6984 | pre.setFont(font.derive(rightSize(pre, size), Font.STYLE_PLAIN)); |
| 6985 | b.setPressedIcon(FontImage.create("" + icon, pre)); |
| 6986 | b.setRolloverPressedIcon(FontImage.create("" + icon, pre)); |
| 6987 | } else { |
| 6988 | b.setPressedIcon(null); |
| 6989 | } |
| 6990 | if (dis.getFgColor() != s.getFgColor() || (dis.getBgColor() != s.getBgColor()) || (dis.getBgTransparency() != s.getBgTransparency()) || (dis.getFgAlpha() != s.getFgAlpha())) { |
| 6991 | dis = new Style(dis); |
| 6992 | dis.setFont(font.derive(rightSize(dis, size), Font.STYLE_PLAIN)); |
| 6993 | b.setDisabledIcon(FontImage.create("" + icon, dis)); |
| 6994 | } else { |
| 6995 | b.setDisabledIcon(null); |
| 6996 | } |
| 6997 | } |
| 6998 | } |
| 6999 | |
| 7000 | /// Applies icon font from the font to the given label using the styling of the label. |
| 7001 | /// |