diff options
| author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-16 00:30:23 +0000 |
|---|---|---|
| committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-16 00:30:23 +0000 |
| commit | c8875fb97fc03779a5bba09872227b1d08e5d52a (patch) | |
| tree | a0b991cf5866ae1d616639b906ac001811d74508 /libjava/classpath/gnu/javax/swing/plaf | |
| parent | c40c1730800ed292b6db39a83d592476fa59623c (diff) | |
| download | ppe42-gcc-c8875fb97fc03779a5bba09872227b1d08e5d52a.tar.gz ppe42-gcc-c8875fb97fc03779a5bba09872227b1d08e5d52a.zip | |
Initial revision
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102074 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/javax/swing/plaf')
21 files changed, 930 insertions, 0 deletions
diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkBorders.java b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkBorders.java new file mode 100644 index 00000000000..ebba6a49b2a --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkBorders.java @@ -0,0 +1,83 @@ +/* GtkBorders.java + Copyright (c) 1999 by 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.gtk; +import java.awt.*; +import javax.swing.*; +import javax.swing.border.*; +import javax.swing.plaf.*; + +/** + * Optional class, can be used to define nifty borders. + * + * @author Brian Jones + * @see javax.swing.LookAndFeel + */ +public class GtkBorders +{ + public static class ButtonBorder extends AbstractBorder + implements UIResource + { + private Border raised; // use by default + private Border lowered; // use this one when pressed + + // creat the border + public ButtonBorder() + { + raised = BorderFactory.createRaisedBevelBorder(); + lowered = BorderFactory.createLoweredBevelBorder(); + } + + // define the insets (in terms of one of the others) + public Insets getBorderInsets(Component c) + { + return raised.getBorderInsets(c); + } + + public void paintBorder(Component c, Graphics g, int x, int y, + int width, int height) + { + AbstractButton b = (AbstractButton)c; + ButtonModel model = b.getModel(); + + if (model.isPressed() && model.isArmed()) + lowered.paintBorder(c, g, x, y, width, height); + else + raised.paintBorder(c, g, x, y, width, height); + } + } +} diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkCheckBoxUI.java b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkCheckBoxUI.java new file mode 100644 index 00000000000..0395af61bfb --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkCheckBoxUI.java @@ -0,0 +1,69 @@ +/* GtkCheckBoxUI.java + Copyright (c) 1999 by 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.gtk; + +import java.awt.*; +import javax.swing.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; + +/** + * + * @author Brian Jones + * @see javax.swing.LookAndFeel + */ +public class GtkCheckBoxUI extends GtkRadioButtonUI +{ + public GtkCheckBoxUI() + { + super(); + } + + public static ComponentUI createUI(JComponent c) + { + return new GtkCheckBoxUI(); + } + + public String getPropertyPrefix() + { + // FIXME + System.err.println(super.getPropertyPrefix()); + return super.getPropertyPrefix(); + } +} + diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkIconFactory.java b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkIconFactory.java new file mode 100644 index 00000000000..28fd36e897c --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkIconFactory.java @@ -0,0 +1,99 @@ +/* GtkIconFactory.java + Copyright (c) 1999 by 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.gtk; +import java.awt.*; +import javax.swing.*; +import javax.swing.plaf.*; +import java.io.Serializable; + +/** + * + * @author Brian Jones + * @see javax.swing.LookAndFeel + */ +public class GtkIconFactory implements Serializable +{ + private static Icon radioButtonIcon; + private static Icon checkBoxIcon; + + public static Icon getRadioButtonIcon() + { + if (radioButtonIcon == null) + radioButtonIcon = new RadioButtonIcon(); + return radioButtonIcon; + } + + private static class RadioButtonIcon + implements Icon, UIResource, Serializable + { + private static final int size = 15; + + public int getIconWidth() { return size; } + public int getIconHeight() { return size; } + + public void paintIcon(Component c, Graphics g, int x, int y) + { + System.out.println("radiobuttonicon: paintIcon()"); + // get the button and model containing the state we are + // supposed to show + AbstractButton b = (AbstractButton)c; + ButtonModel model = b.getModel(); + + // If the button is being pressed (& armed), change the + // background color + // Note: could also do something different if the button is + // disabled + + if (model.isPressed() && model.isArmed()) + { + System.out.println("radiobuttonicon: pressed & armed"); + g.setColor(UIManager.getColor("RadioButton.pressed")); + g.fillOval(x,y,size-1, size-1); + } + // draw an outer circle + g.setColor(UIManager.getColor("RadioButton.foreground")); + g.drawOval(x,y,size-1, size-1); + + // fill a small circle inside if the button is selected + if (model.isSelected()) { + g.fillOval(x+4, y+4, size-8, size-8); + System.out.println("radiobuttonicon: is selected"); + } + } + } +} diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkLookAndFeel.java b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkLookAndFeel.java new file mode 100644 index 00000000000..ed99e6d216b --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkLookAndFeel.java @@ -0,0 +1,241 @@ +/* GtkLookAndFeel.java + Copyright (c) 1999 by 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.gtk; +import java.awt.*; +import javax.swing.*; +import javax.swing.border.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; + +/** + * + * @author Brian Jones + * @see javax.swing.LookAndFeel + */ +public class GtkLookAndFeel extends BasicLookAndFeel +{ + private UIDefaults uiDefaults; + + /** + */ + public GtkLookAndFeel() + { + super(); + } + + /** + * A short string to identify this look and feel, for example in a + * drop down list to choose between several look and feels. + */ + public String getName() { return "GIMP Toolkit"; } + + /** + * A much longer description of the look and feel. + */ + public String getDescription() + { + return new String("The GIMP Toolkit Look and Feel for Java, " + + "written by Brian Jones (cbj@gnu.org), " + + "(c) 1999 by Free Software Foundation, Inc. " + + "http://www.classpath.org"); + } + + /** + * Return a unique string identifying this look and feel as different + * from and not a subclass of any other look and feel. Usually, a + * subclass will return the same <code>String</code> here as the + * original look and feel if only a few changes are being made rather + * than something completely new and different. + */ + public String getID() + { + return "Gtk"; + } + + public boolean isNativeLookAndFeel() + { + return false; + } + + public boolean isSupportedLookAndFeel() + { + return true; + } + + protected void initClassDefaults(UIDefaults table) + { + super.initClassDefaults(table); + + String gtkPkgName = "gnu.javax.swing.plaf.gtk."; + + + Object[] defaults = { + "SliderUI", gtkPkgName + "GtkSliderUI" + }; + /* + "CheckBoxUI", gtkPkgName + "GtkCheckBoxUI", + "ButtonUI", gtkPkgName + "GtkButtonUI" + "ColorChooserUI", "MetalColorChooserUI", + "MenuBarUI", "MetalMenuBarUI", + "MenuUI", "MetalMenuUI", + "MenuItemUI", "MetalMenuItemUI", + "CheckBoxMenuItemUI", "MetalCheckBoxMenuItemUI", + "RadioButtonMenuItemUI", "MetalRadioButtonMenuItemUI", + "RadioButtonUI", "MetalRadioButtonUI", + "ToggleButtonUI", "MetalToggleButtonUI", + "PopupMenuUI", "MetalPopupMenuUI", + "ProgressBarUI", "MetalProgressBarUI", + "ScrollBarUI", "MetalScrollBarUI", + "ScrollPaneUI", "MetalScrollPaneUI", + "SplitPaneUI", "MetalSplitPaneUI", + "SeparatorUI", "MetalSeparatorUI", + "ToolBarSeparatorUI", "MetalToolBarSeparatorUI", + "PopupMenuSeparatorUI", "MetalPopupMenuSeparatorUI", + "TabbedPaneUI", "MetalTabbedPaneUI", + "TextAreaUI", "MetalTextAreaUI", + "TextFieldUI", "MetalTextFieldUI", + "PasswordFieldUI", "MetalPasswordFieldUI", + "TextPaneUI", "MetalTextPaneUI", + "EditorPaneUI", "MetalEditorPaneUI", + "TreeUI", "MetalTreeUI", + "LabelUI", "MetalLabelUI", + "ListUI", "MetalListUI", + "ToolBarUI", "MetalToolBarUI", + "ToolTipUI", "MetalToolTipUI", + "ComboBoxUI", "MetalComboBoxUI", + "TableUI", "MetalTableUI", + "TableHeaderUI", "MetalTableHeaderUI", + "InternalFrameUI", "GtkInternalFrameUI", + "StandardDialogUI", "GtkStandardDialogUI", + "DesktopPaneUI", "GtkDesktopPaneUI", + "DesktopIconUI", "GtkDesktopIconUI", + "DirectoryPaneUI", "GtkDirectoryPaneUI", + "FileChooserUI", "GtkFileChooserUI", + "OptionPaneUI", "GtkOptionPaneUI" } + */ + table.putDefaults(defaults); + + } + + protected void initSystemColorDefaults(UIDefaults table) + { + String[] colors = { + "desktop", "#000000", + "activeCaption", "#163555", + "activeCaptionText", "#FFFFFF", + "activeCaptionBorder", "#000000", + "inactiveCaption", "#375676", + "inactiveCaptionText", "#999999", + "inactiveCaptionBorder", "#000000", + "window", "#FFFFFF", + "windowBorder", "#969696", + "windowText", "#000000", + "menu", "#d6d6d6", + "menuText", "#000000", + "text", "#FFFFFF", + "textText", "#000000", + "textHighlight", "#00009c", + "textHighlightText", "#FFFFFF", + "textInactiveText", "#999999", + "control", "#d6d6d6", + "controlText", "#000000", + "controlHighlight", "#eaeaea", + "controlLtHighlight", "#eaeaea", + "controlShadow", "#c3c3c3", + "controlDkShadow", "#888888", + "scrollbar", "#c3c3c3", + "info", "#d6d6d6", + "infoText", "#000000" + }; + + loadSystemColors(table, colors, false); + } + + protected void initComponentDefaults(UIDefaults table) + { + super.initComponentDefaults(table); + + // define common resources + // fonts + FontUIResource sansSerifPlain10 = + new FontUIResource("SansSerif", Font.PLAIN, 10); + FontUIResource serifPlain10 = + new FontUIResource("Serif", Font.PLAIN, 10); + // insets + // borders + // colors + ColorUIResource controlDkShadow = new ColorUIResource(table.getColor("controlDkShadow")); + ColorUIResource controlShadow = new ColorUIResource(table.getColor("controlShadow")); + ColorUIResource control = new ColorUIResource(table.getColor("control")); + ColorUIResource scrollbar = new ColorUIResource(table.getColor("scrollbar")); + ColorUIResource controlHighlight = new ColorUIResource(table.getColor("controlHighlight")); + if (scrollbar == null) + System.out.println("scrollbar is null"); + + ColorUIResource white = new ColorUIResource(Color.white); + ColorUIResource black = new ColorUIResource(Color.black); + ColorUIResource blue = new ColorUIResource(Color.blue); + + // icons + Object errorIcon = LookAndFeel.makeIcon(getClass(), "icons/error.gif"); + // any other resources like dimensions and integer values + + // define defaults + Object[] defaults = + { + "Button.font", sansSerifPlain10, + "CheckBox.font", sansSerifPlain10, + "RadioButton.pressed", black, + "Slider.focus", blue, + "Slider.foreground", control, + "Slider.highlight", controlHighlight, + "Slider.shadow", controlShadow, + "Slider.background", controlDkShadow + +// "Slider.background", "#888888", +// "Slider.focus", "#c3c3c3", +// "Slider.foreground", "#d6d6d6", +// "Slider.highlight", "#ffffff", +// "Slider.shadow", "#000000" + + + }; + + table.putDefaults(defaults); + } +} diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkRadioButtonUI.java b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkRadioButtonUI.java new file mode 100644 index 00000000000..19d53387910 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkRadioButtonUI.java @@ -0,0 +1,69 @@ +/* GtkRadioButtonUI.java + Copyright (c) 1999 by 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.gtk; + +import java.awt.*; +import javax.swing.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; + +/** + * + * @author Brian Jones + * @see javax.swing.LookAndFeel + */ +public class GtkRadioButtonUI extends BasicRadioButtonUI +{ + public GtkRadioButtonUI() + { + super(); + } + + public static ComponentUI createUI(JComponent c) + { + return new GtkRadioButtonUI(); + } + + public String getPropertyPrefix() + { + // FIXME + System.err.println(super.getPropertyPrefix()); + return super.getPropertyPrefix(); + } +} + diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkSliderUI.java b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkSliderUI.java new file mode 100644 index 00000000000..c576b3d4b50 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/GtkSliderUI.java @@ -0,0 +1,230 @@ +/* GtkSliderUI.java + Copyright (c) 1999 by 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.gtk; +import java.awt.*; +import javax.swing.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; + +/** + * Gtk-like slider + * + * @author Brian Jones + * @see javax.swing.LookAndFeel + */ +public class GtkSliderUI extends BasicSliderUI +{ + private static Color thumbFgColor; + private static Color thumbBgColor; + private static Color thumbHighlight; + private static Color thumbFocus; + + private static Color bgColor; + private static Color fgColor; + private static Color focusColor; + private static Color highlight; + private static Color shadow; + + private static final Dimension PREF_HORIZ = new Dimension(250, 15); + private static final Dimension PREF_VERT = new Dimension(15, 250); + private static final Dimension MIN_HORIZ = new Dimension(25, 15); + private static final Dimension MIN_VERT = new Dimension(15, 25); + + public GtkSliderUI() + { + super(null); + bgColor = UIManager.getColor("Slider.background"); + fgColor = UIManager.getColor("Slider.foreground"); + focusColor = UIManager.getColor("Slider.focus"); + highlight = UIManager.getColor("Slider.highlight"); + shadow = UIManager.getColor("Slider.shadow"); + + System.out.println("bgColor: " + bgColor); + System.out.println("fgColor: " + fgColor); + System.out.println("focusColor: " + focusColor); + System.out.println("highlight: " + highlight); + System.out.println("shadow: " + shadow); + } + + public static ComponentUI createUI(JComponent c) + { + return new GtkSliderUI(); + } + + // methods not overridden here, using Basic defaults + // installUI() + // uninstall() + + public Dimension getPreferredHorizontalSize() + { + /* + Dimension thumbSize = getThumbSize(); + Dimenstion labelSize = getLabelSize(); + // getTickLength() + int width = thumbSize.width + + getWidthOfWidestLabel + */ + return PREF_HORIZ; + } + + public Dimension getPreferredVerticalSize() + { + return PREF_VERT; + } + + public Dimension getMinimumHorizontalSize() + { + return MIN_HORIZ; + } + + public Dimension getMinimumVerticalSize() + { + return MIN_VERT; + } + + /** + * Returns thumb size based on slider orientation + */ + protected Dimension getThumbSize() + { + Dimension size = new Dimension(); + + if (slider.getOrientation() == JSlider.VERTICAL) { + size.width = 15; + size.height = 33; + } + else { + size.width = 33; + size.height = 15; + } + return size; + } + + /** + * Reserved width or height for ticks, as appropriate to the slider + * orientation. + */ + protected int getTickLength() + { + return 10; + } + + public void paintFocus(Graphics g) + { + super.paintFocus(g); + System.err.println("focus " + focusRect); + } + + /** + * Must account for Unicode when drawing text. + */ + public void paintLabels(Graphics g) + { + super.paintLabels(g); + System.err.println("label " + labelRect); + } + + /** + * A drawRect() generated slider has ghosting when moving left on + * a horizontal slider and the bottom is not painted when moving + * right. + */ + public void paintThumb(Graphics g) + { + int x = thumbRect.x; + int y = thumbRect.y; + int h = thumbRect.height; + int w = thumbRect.width; + +// "Slider.background", "#888888", +// "Slider.focus", "#c3c3c3", +// "Slider.foreground", "#d6d6d6", +// "Slider.highlight", "#ffffff", +// "Slider.shadow", "#000000" + + g.setColor(fgColor); + g.fillRect(x,y,w,h); + g.setColor(bgColor); + + if (slider.getOrientation() == JSlider.HORIZONTAL) { + g.drawRect(x, y, w, h); + g.setColor(highlight); + g.drawLine(x+1, y+h-1, x+w, y+h-1); + g.setColor(focusColor); + g.drawLine(x+2, y+h-2, x+w, y+h-2); + g.setColor(Color.black); + g.drawLine(x+1, y+h-2, x+1, y+h-2); + g.drawRect(x+1, y+1, w-1, 12); + } + else + g.drawRect(x, y, w, h); + + System.err.println("thumb " + thumbRect); + } + + // public void paintTicks(Graphics g) + + public void paintTrack(Graphics g) + { +// super.paintTrack(g); + int x = trackRect.x; + int y = trackRect.y; + int h = trackRect.height; + int w = trackRect.width; + + System.err.println("track " + trackRect); + + g.setColor(Color.black); + g.fillRect(x,y,w,h); + +// if (slider.getOrientation() == JSlider.HORIZONTAL) +// g.drawLine(x, y+h-1, x+w-1, y+h-1); +// else +// g.drawLine(x+w-1, y, x+w-1, y+h-1); + +// System.err.println("track " + trackRect); +// System.err.println("content " + contentRect); + } + + // the four methods below allow you to control tick painting without + // worrying about what paintTicks does, look for in other UI delegates + // protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) + // protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) + // protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) + // protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) +} diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/README b/libjava/classpath/gnu/javax/swing/plaf/gtk/README new file mode 100644 index 00000000000..2b3f001ddc2 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/README @@ -0,0 +1,37 @@ +This is a start at a GTK look and feel for Java. +It is usable already, but it mainly just defaults back to Basic Look and +Feel for everything. + +Sliders are currently broken. I haven't figured out why yet. + +A bunch of system colors defined in GtkLookandFeel though I have a feeling +I'll be defining more ColorUIResources shortly. + +Based on Gnome File Manager colors... or my Window Manager setup + +desktop #000000 (gtk) +activeCaption #163555 (window manager) +activeCaptionText #FFFFFF (window manager) +activeCaptionBorder #000000 (unsure of this) +inactiveCaption #375676 (window manager) +inactiveCaptionText #999999 (window manager) +inactiveCaptionBorder #000000 (unsure of this) +window #FFFFFF (gtk) +windowBorder #969696 (gtk) +windowText #000000 (gtk) +menu #d6d6d6 (gtk) +menuText #000000 (gtk) +text #FFFFFF (gtk) +textText #000000 (gtk) +textHighlight #00009c (gtk) +textHighlightText #FFFFFF (gtk) +textInactiveText #999999 (unsure of this) +control #d6d6d6 (gtk) +controlText #000000 (gtk) +controlHighlight #eaeaea (gtk) +controlLtHighlight #eaeaea (unsure of this) +controlShadow #c3c3c3 (gtk) +controlDkShadow #888888 (unsure of this) +scrollbar #c3c3c3 (gtk) +info #d6d6d6 (gtk) +infoText #000000 (gtk) diff --git a/libjava/classpath/gnu/javax/swing/plaf/gtk/SliderTest.java b/libjava/classpath/gnu/javax/swing/plaf/gtk/SliderTest.java new file mode 100644 index 00000000000..a838444924d --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/SliderTest.java @@ -0,0 +1,82 @@ +import javax.swing.*; +import javax.swing.event.*; +import java.awt.*; +import java.awt.event.*; +import gnu.javax.swing.plaf.gtk.*; + +public class SliderTest extends JFrame +{ + public SliderTest() + { + super("JSlider Test"); + Container c = getContentPane(); + c.setLayout(new BorderLayout()); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { System.exit(0); } + }); + + JSlider s = new JSlider(); + s.createStandardLabels(10); + s.setMinorTickSpacing(10); + s.setMajorTickSpacing(20); + s.setPaintTicks(true); + s.setPaintTrack(true); + s.setPaintLabels(true); + s.setRequestFocusEnabled(true); + + // turning off double buffering in repaint manager + // in order to use debug graphics + RepaintManager repaintManager = RepaintManager.currentManager(s); + repaintManager.setDoubleBufferingEnabled(false); + + s.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION | DebugGraphics.FLASH_OPTION); + DebugGraphics.setFlashColor(Color.red); // color of flash + DebugGraphics.setFlashTime(4); // time delay of drawing operation flashing + DebugGraphics.setFlashCount(3); // number of time to draw + + this.setSize(250, 100); + c.add(new JLabel("Default Slider"), "North"); + c.add(s, "Center"); + + try { + UIManager.setLookAndFeel("gnu.javax.swing.plaf.gtk.GtkLookAndFeel"); + SwingUtilities.updateComponentTreeUI(this); + } catch (Exception e) { + e.printStackTrace(); + System.exit(0); + } + + center(); + } + + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + + public void center() + { + // Centering the frame + Toolkit t = this.getToolkit(); + Dimension framesize = this.getSize(); + Dimension screensize = t.getScreenSize(); + + // Calculate point for frame (main) + Point pframe = new Point(); + pframe.x = (screensize.width - framesize.width) / 2; + pframe.y = (screensize.height - framesize.height) / 2; + + // Set the location of each to be centered + this.setLocation(pframe); + } + + public static void main(String [] argv) + { + SliderTest t = new SliderTest(); + t.show(); + } + +} + + + + 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 00000000000..9d6f1227892 --- /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 00000000000..89931d54d61 --- /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 00000000000..d2cff625862 --- /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 00000000000..6a4f7923a2e --- /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 00000000000..89931d54d61 --- /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 00000000000..755f3182043 --- /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 00000000000..e2edbf78e4f --- /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 00000000000..fb8dbc98241 --- /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 00000000000..cdf058fe66c --- /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 00000000000..fba82587a22 --- /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 00000000000..9d6f1227892 --- /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 00000000000..e1a03d0c916 --- /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 00000000000..ac429b15875 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/plaf/gtk/icons/slider.png |

