2 Copyright (c) 1999 by Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package gnu.javax.swing.plaf.gtk;
41 import javax.swing.plaf.*;
42 import javax.swing.plaf.basic.*;
48 * @see javax.swing.LookAndFeel
50 public class GtkSliderUI extends BasicSliderUI
52 private static Color thumbFgColor;
53 private static Color thumbBgColor;
54 private static Color thumbHighlight;
55 private static Color thumbFocus;
57 private static Color bgColor;
58 private static Color fgColor;
59 private static Color focusColor;
60 private static Color highlight;
61 private static Color shadow;
63 private static final Dimension PREF_HORIZ = new Dimension(250, 15);
64 private static final Dimension PREF_VERT = new Dimension(15, 250);
65 private static final Dimension MIN_HORIZ = new Dimension(25, 15);
66 private static final Dimension MIN_VERT = new Dimension(15, 25);
71 bgColor = UIManager.getColor("Slider.background");
72 fgColor = UIManager.getColor("Slider.foreground");
73 focusColor = UIManager.getColor("Slider.focus");
74 highlight = UIManager.getColor("Slider.highlight");
75 shadow = UIManager.getColor("Slider.shadow");
77 System.out.println("bgColor: " + bgColor);
78 System.out.println("fgColor: " + fgColor);
79 System.out.println("focusColor: " + focusColor);
80 System.out.println("highlight: " + highlight);
81 System.out.println("shadow: " + shadow);
84 public static ComponentUI createUI(JComponent c)
86 return new GtkSliderUI();
89 // methods not overridden here, using Basic defaults
93 public Dimension getPreferredHorizontalSize()
96 Dimension thumbSize = getThumbSize();
97 Dimenstion labelSize = getLabelSize();
99 int width = thumbSize.width +
100 getWidthOfWidestLabel
105 public Dimension getPreferredVerticalSize()
110 public Dimension getMinimumHorizontalSize()
115 public Dimension getMinimumVerticalSize()
121 * Returns thumb size based on slider orientation
123 protected Dimension getThumbSize()
125 Dimension size = new Dimension();
127 if (slider.getOrientation() == JSlider.VERTICAL) {
139 * Reserved width or height for ticks, as appropriate to the slider
142 protected int getTickLength()
147 public void paintFocus(Graphics g)
150 System.err.println("focus " + focusRect);
154 * Must account for Unicode when drawing text.
156 public void paintLabels(Graphics g)
158 super.paintLabels(g);
159 System.err.println("label " + labelRect);
163 * A drawRect() generated slider has ghosting when moving left on
164 * a horizontal slider and the bottom is not painted when moving
167 public void paintThumb(Graphics g)
171 int h = thumbRect.height;
172 int w = thumbRect.width;
174 // "Slider.background", "#888888",
175 // "Slider.focus", "#c3c3c3",
176 // "Slider.foreground", "#d6d6d6",
177 // "Slider.highlight", "#ffffff",
178 // "Slider.shadow", "#000000"
184 if (slider.getOrientation() == JSlider.HORIZONTAL) {
185 g.drawRect(x, y, w, h);
186 g.setColor(highlight);
187 g.drawLine(x+1, y+h-1, x+w, y+h-1);
188 g.setColor(focusColor);
189 g.drawLine(x+2, y+h-2, x+w, y+h-2);
190 g.setColor(Color.black);
191 g.drawLine(x+1, y+h-2, x+1, y+h-2);
192 g.drawRect(x+1, y+1, w-1, 12);
195 g.drawRect(x, y, w, h);
197 System.err.println("thumb " + thumbRect);
200 // public void paintTicks(Graphics g)
202 public void paintTrack(Graphics g)
204 // super.paintTrack(g);
207 int h = trackRect.height;
208 int w = trackRect.width;
210 System.err.println("track " + trackRect);
212 g.setColor(Color.black);
215 // if (slider.getOrientation() == JSlider.HORIZONTAL)
216 // g.drawLine(x, y+h-1, x+w-1, y+h-1);
218 // g.drawLine(x+w-1, y, x+w-1, y+h-1);
220 // System.err.println("track " + trackRect);
221 // System.err.println("content " + contentRect);
224 // the four methods below allow you to control tick painting without
225 // worrying about what paintTicks does, look for in other UI delegates
226 // protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
227 // protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
228 // protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
229 // protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)