diff options
Diffstat (limited to 'libjava/classpath/gnu/javax/swing/plaf')
15 files changed, 504 insertions, 0 deletions
diff --git a/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java b/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java new file mode 100644 index 000000000..75ba45506 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gnu/GNULookAndFeel.java @@ -0,0 +1,266 @@ +/* GNULookAndFeel.java -- An example of using the javax.swing UI. + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath examples. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. +*/ + +package gnu.javax.swing.plaf.gnu; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; + +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JCheckBox; +import javax.swing.JRadioButton; +import javax.swing.UIDefaults; +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.IconUIResource; +import javax.swing.plaf.basic.BasicLookAndFeel; + +public class GNULookAndFeel extends BasicLookAndFeel +{ + + static Color blueGray = new Color(0xdc, 0xda, 0xd5); + + public boolean isNativeLookAndFeel() { return true; } + public boolean isSupportedLookAndFeel() { return true; } + public String getDescription() { return "GNU Look and Feel"; } + public String getID() { return "GNULookAndFeel"; } + public String getName() { return "GNU"; } + + static UIDefaults LAF_defaults; + + private final static String iconspath = "/gnu/javax/swing/plaf/gtk/icons/"; + + public UIDefaults getDefaults() + { + if (LAF_defaults == null) + { + LAF_defaults = super.getDefaults(); + Object[] myDefaults = new Object[] { + "Button.background", new ColorUIResource(blueGray), + "CheckBox.background", new ColorUIResource(blueGray), + "CheckBoxMenuItem.background", new ColorUIResource(blueGray), + "ToolBar.background", new ColorUIResource(blueGray), + "Panel.background", new ColorUIResource(blueGray), + "Slider.background", new ColorUIResource(blueGray), + "OptionPane.background", new ColorUIResource(blueGray), + "ProgressBar.background", new ColorUIResource(blueGray), + "TabbedPane.background", new ColorUIResource(blueGray), + "Label.background", new ColorUIResource(blueGray), + "Menu.background", new ColorUIResource(blueGray), + "MenuBar.background", new ColorUIResource(blueGray), + "MenuItem.background", new ColorUIResource(blueGray), + "ScrollBar.background", new ColorUIResource(blueGray), + "CheckBox.icon", new CheckBoxIcon(), + "RadioButton.icon", new RadioButtonIcon(), + "Tree.hash", new ColorUIResource(Color.black), + + "Tree.closedIcon", + new IconUIResource(new ImageIcon + (getClass().getResource + (iconspath + "TreeClosed.png"))), + "Tree.leafIcon", + new IconUIResource(new ImageIcon + (getClass().getResource + (iconspath + "TreeLeaf.png"))), + "Tree.openIcon", + new IconUIResource(new ImageIcon + (getClass().getResource + (iconspath + "TreeOpen.png"))), + }; + LAF_defaults.putDefaults(myDefaults); + } + return LAF_defaults; + } + + /** + * The icon used for CheckBoxes in the BasicLookAndFeel. This is an empty + * icon with a size of 13x13 pixels. + */ + static class CheckBoxIcon + implements Icon + { + /** + * Returns the height of the icon. The BasicLookAndFeel CheckBox icon + * has a height of 13 pixels. + * + * @return the height of the icon + */ + public int getIconHeight() + { + return 13; + } + + /** + * Returns the width of the icon. The BasicLookAndFeel CheckBox icon + * has a width of 13 pixels. + * + * @return the height of the icon + */ + public int getIconWidth() + { + return 13; + } + + /** + * Paints the icon. The BasicLookAndFeel CheckBox icon is empty and does + * not need to be painted. + * + * @param c the component to be painted + * @param g the Graphics context to be painted with + * @param x the x position of the icon + * @param y the y position of the icon + */ + public void paintIcon(Component c, Graphics g, int x, int y) + { + Color save = g.getColor(); + g.setColor(c.getForeground()); + g.drawRect(x, y, getIconWidth(), getIconHeight()); + + JCheckBox item = (JCheckBox) c; + if (item.isSelected()) + { + g.drawLine(3 + x, 5 + y, 3 + x, 9 + y); + g.drawLine(4 + x, 5 + y, 4 + x, 9 + y); + g.drawLine(5 + x, 7 + y, 9 + x, 3 + y); + g.drawLine(5 + x, 8 + y, 9 + x, 4 + y); + } + + g.setColor(save); + } + } + + /** + * The icon used for RadioButtons in the GNULookAndFeel. This is an empty + * icon with a size of 13x13 pixels. + */ + static class RadioButtonIcon + implements Icon + { + /** + * Returns the height of the icon. The GNULookAndFeel RadioButton icon + * has a height of 13 pixels. + * + * @return the height of the icon + */ + public int getIconHeight() + { + return 13; + } + + /** + * Returns the width of the icon. The GNULookAndFeel RadioButton icon + * has a width of 13 pixels. + * + * @return the height of the icon + */ + public int getIconWidth() + { + return 13; + } + + /** + * Paints the icon. The GNULookAndFeel RadioButton icon is empty and does + * not need to be painted. + * + * @param c the component to be painted + * @param g the Graphics context to be painted with + * @param x the x position of the icon + * @param y the y position of the icon + */ + public void paintIcon(Component c, Graphics g, int x, int y) + { + Color savedColor = g.getColor(); + JRadioButton b = (JRadioButton) c; + + // draw outer circle + if (b.isEnabled()) + g.setColor(Color.GRAY); + else + g.setColor(Color.GRAY); + g.drawLine(x + 2, y + 1, x + 3, y + 1); + g.drawLine(x + 4, y, x + 7, y); + g.drawLine(x + 8, y + 1, x + 9, y + 1); + g.drawLine(x + 10, y + 2, x + 10, y + 3); + g.drawLine(x + 11, y + 4, x + 11, y + 7); + g.drawLine(x + 10, y + 8, x + 10, y + 9); + g.drawLine(x + 8, y + 10, x + 9, y + 10); + g.drawLine(x + 4, y + 11, x + 7, y + 11); + g.drawLine(x + 2, y + 10, x + 3, y + 10); + g.drawLine(x + 1, y + 9, x + 1, y + 8); + g.drawLine(x, y + 7, x, y + 4); + g.drawLine(x + 1, y + 2, x + 1, y + 3); + + if (b.getModel().isArmed()) + { + g.setColor(Color.GRAY); + g.drawLine(x + 4, y + 1, x + 7, y + 1); + g.drawLine(x + 4, y + 10, x + 7, y + 10); + g.drawLine(x + 1, y + 4, x + 1, y + 7); + g.drawLine(x + 10, y + 4, x + 10, y + 7); + g.fillRect(x + 2, y + 2, 8, 8); + } + else + { + // only draw inner highlight if not filled + if (b.isEnabled()) + { + g.setColor(Color.WHITE); + + g.drawLine(x + 2, y + 8, x + 2, y + 9); + g.drawLine(x + 1, y + 4, x + 1, y + 7); + g.drawLine(x + 2, y + 2, x + 2, y + 3); + g.drawLine(x + 3, y + 2, x + 3, y + 2); + g.drawLine(x + 4, y + 1, x + 7, y + 1); + g.drawLine(x + 8, y + 2, x + 9, y + 2); + } + } + + // draw outer highlight + if (b.isEnabled()) + { + g.setColor(Color.WHITE); + + // outer + g.drawLine(x + 10, y + 1, x + 10, y + 1); + g.drawLine(x + 11, y + 2, x + 11, y + 3); + g.drawLine(x + 12, y + 4, x + 12, y + 7); + g.drawLine(x + 11, y + 8, x + 11, y + 9); + g.drawLine(x + 10, y + 10, x + 10, y + 10); + g.drawLine(x + 8, y + 11, x + 9, y + 11); + g.drawLine(x + 4, y + 12, x + 7, y + 12); + g.drawLine(x + 2, y + 11, x + 3, y + 11); + } + + if (b.isSelected()) + { + if (b.isEnabled()) + g.setColor(Color.BLACK); + else + g.setColor(Color.GRAY); + g.drawLine(x + 4, y + 3, x + 7, y + 3); + g.fillRect(x + 3, y + 4, 6, 4); + g.drawLine(x + 4, y + 8, x + 7, y + 8); + } + g.setColor(savedColor); + } + } +} diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Error.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Error.png Binary files differnew file mode 100644 index 000000000..9d6f12278 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Error.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Inform.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Inform.png Binary files differnew file mode 100644 index 000000000..89931d54d --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Inform.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCup.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCup.png Binary files differnew file mode 100644 index 000000000..d2cff6258 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCup.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCupLarge.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCupLarge.png Binary files differnew file mode 100644 index 000000000..6a4f7923a --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/JavaCupLarge.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Question.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Question.png Binary files differnew file mode 100644 index 000000000..89931d54d --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Question.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/README b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/README new file mode 100644 index 000000000..755f31820 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/README @@ -0,0 +1,20 @@ +Images required by Basic Look and Feel + +Information based on images from Swing 1.1.1b2 +JavaCup.gif - a picture of the steaming cup of Java - 16x16 - 3 colors + +TreeOpen.gif - a picture of an open file folder - 16x13 - 8 colors +TreeClosed.gif - a picture of a closed file folder - 16x13 - 7 colors +TreeLeaf.gif - a picture of a small circle with points in four + directions - 16x13 - 2 colors + +Information on images used by Gtk Look and Feel, really need to work the +number of colors down I think. + +JavaCup.gif - a picture of Classpath's mascot - 16x16 - 58 colors + +TreeOpen.gif - taken from Gnome File Manager - 16x12 - 34 colors +TreeClosed.gif - taken from Gnome File Manager 14x12 - 28 colors +TreeLeaf.gif - a blank gif - 16x12 - 1 color + +Error.gif - think this will be needed later (taken from gnome) diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeClosed.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeClosed.png Binary files differnew file mode 100644 index 000000000..e2edbf78e --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeClosed.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf-normal.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf-normal.png Binary files differnew file mode 100644 index 000000000..fb8dbc982 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf-normal.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf.png Binary files differnew file mode 100644 index 000000000..cdf058fe6 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeLeaf.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeOpen.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeOpen.png Binary files differnew file mode 100644 index 000000000..fba82587a --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/TreeOpen.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Warn.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Warn.png Binary files differnew file mode 100644 index 000000000..9d6f12278 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/Warn.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/file-folders.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/file-folders.png Binary files differnew file mode 100644 index 000000000..e1a03d0c9 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/file-folders.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/slider.png b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/slider.png Binary files differnew file mode 100644 index 000000000..ac429b158 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/slider.png diff --git a/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java b/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java new file mode 100644 index 000000000..7dbf6e12a --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java @@ -0,0 +1,218 @@ +/* CustomizableTheme.java -- A customizable metal theme + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.javax.swing.plaf.metal; + +import java.awt.Color; + +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.metal.DefaultMetalTheme; + +/** + * A Metal theme that can be customized by setting the primary and secondary + * colors. + * + * @author Roman Kennke (kennke@aicas.com) + */ +public class CustomizableTheme + extends DefaultMetalTheme + implements Cloneable +{ + + /** + * The primary1 color. + */ + private ColorUIResource primary1; + + /** + * The primary2 color. + */ + private ColorUIResource primary2; + + /** + * The primary3 color. + */ + private ColorUIResource primary3; + + /** + * The secondary1 color. + */ + private ColorUIResource secondary1; + + /** + * The secondary2 color. + */ + private ColorUIResource secondary2; + + /** + * The secondary3 color. + */ + private ColorUIResource secondary3; + + /** + * Sets the primary1 color of the theme. + * + * @param c the primary1 color to set + */ + public void setPrimary1(Color c) + { + primary1 = new ColorUIResource(c); + } + + /** + * Returns the primary1 color of this theme. + * + * @return the primary1 color of this theme + */ + public ColorUIResource getPrimary1() + { + return primary1 == null ? super.getPrimary1() : primary1; + } + + + /** + * Sets the primary2 color of the theme. + * + * @param c the primary2 color to set + */ + public void setPrimary2(Color c) + { + primary2 = new ColorUIResource(c); + } + + /** + * Returns the primary2 color of this theme. + * + * @return the primary2 color of this theme + */ + public ColorUIResource getPrimary2() + { + return primary2 == null ? super.getPrimary2() : primary2; + } + + /** + * Sets the primary3 color of the theme. + * + * @param c the primary3 color to set + */ + public void setPrimary3(Color c) + { + primary3 = new ColorUIResource(c); + } + + /** + * Returns the primary3 color of this theme. + * + * @return the primary3 color of this theme + */ + public ColorUIResource getPrimary3() + { + return primary3 == null ? super.getPrimary3() : primary3; + } + + /** + * Sets the secondary1 color of the theme. + * + * @param c the secondary1 color to set + */ + public void setSecondary1(Color c) + { + secondary1 = new ColorUIResource(c); + } + + /** + * Returns the secondary1 color of this theme. + * + * @return the secondary1 color of this theme + */ + public ColorUIResource getSecondary1() + { + return secondary1 == null ? super.getSecondary1() : secondary1; + } + + /** + * Sets the secondary2 color of the theme. + * + * @param c the secondary2 color to set + */ + public void setSecondary2(Color c) + { + secondary2 = new ColorUIResource(c); + } + + /** + * Returns the secondary2 color of this theme. + * + * @return the secondary2 color of this theme + */ + public ColorUIResource getSecondary2() + { + return secondary2 == null ? super.getSecondary2() : secondary2; + } + + /** + * Sets the secondary3 color of the theme. + * + * @param c the secondary3 color to set + */ + public void setSecondary3(Color c) + { + secondary3 = new ColorUIResource(c); + } + + /** + * Returns the secondary3 color of this theme. + * + * @return the secondary3 color of this theme + */ + public ColorUIResource getSecondary3() + { + return secondary3 == null ? super.getSecondary3() : secondary3; + } + + /** + * Returns a clone of this theme. + * + * @return a clone of this theme + */ + public Object clone() + throws CloneNotSupportedException + { + return super.clone(); + } +} |