/[debian]/libjgoodies-looks-java/trunk/debian/patches/02_windows.patch
ViewVC logotype

Annotation of /libjgoodies-looks-java/trunk/debian/patches/02_windows.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1381 - (hide annotations)
Fri Jul 25 19:07:03 2008 UTC (12 years, 8 months ago) by gregoa
File size: 253189 byte(s)
Refresh patches.
1 gregoa 1326 Author: <gregor+debian@comodo.priv.at>
2     Description: remove windows look
3 gregoa 1381 --- a/build.xml
4     +++ b/build.xml
5     @@ -94,7 +94,7 @@
6 gregoa 1326 <!-- C O M P I L A T I O N -->
7     <!-- ***************************************************************** -->
8     <target name="compile"
9     - depends="compile-core, compile-demo, compile-tests"
10     + depends="compile-core, compile-tests"
11     description="Compiles the l&amp;fs, demo, and tests." />
12    
13     <!-- ***************************************************************** -->
14 gregoa 1381 @@ -119,33 +119,11 @@
15 gregoa 1326 <copy toDir="${build.core.dir}" >
16     <fileset dir="${src.core.dir}"
17     includes="com/jgoodies/looks/common/shadow.png,
18     - com/jgoodies/looks/plastic/icons/**/*,
19     - com/jgoodies/looks/windows/icons/**/*" />
20     + com/jgoodies/looks/plastic/icons/**/*" />
21     </copy>
22     </target>
23    
24     <!-- ***************************************************************** -->
25     - <target name="compile-demo" depends="compile-core"
26     - description="Compiles the demo sources." >
27     - <javac
28     - srcdir ="${src.demo.dir}"
29     - destdir ="${build.demo.dir}"
30     - encoding ="${build.encoding}"
31     - executable ="${build.compile.executable}"
32     - fork ="${build.compile.fork}"
33     - debug ="${build.compile.debug}"
34     - depend ="${build.compile.depend}"
35     - deprecation ="${build.compile.deprecation}"
36     - nowarn ="${build.compile.nowarn}"
37     - optimize ="${build.compile.optimize}"
38     - source ="${build.compile.source}"
39     - target ="${build.compile.target}"
40     - verbose ="${build.compile.verbose}"
41     - classpathref ="classpath.demo" />
42     - <!-- bootclasspath="${build.boot.classpath}" -->
43     - </target>
44     -
45     - <!-- ***************************************************************** -->
46     <target name="compile-tests" depends="compile-core" if="junit.jar.present"
47     description="Compiles the unit tests." >
48     <mkdir dir="${build.test.dir}"/>
49 gregoa 1381 @@ -213,7 +191,7 @@
50 gregoa 1326 <!-- J A R -->
51     <!-- ***************************************************************** -->
52     <target name="jar"
53     - depends="jar-all, jar-plastic, jar-windows, jar-demo, jar-tiny, jar-fonttest"
54     + depends="jar-all, jar-plastic, jar-demo, jar-tiny, jar-fonttest"
55     description="Creates library and example jars." >
56     </target>
57    
58 gregoa 1381 @@ -268,20 +246,6 @@
59 gregoa 1326 </target>
60    
61     <!-- ***************************************************************** -->
62     - <target name="jar-windows" depends="compile, manifest"
63     - description="Creates the library jar for the windows l&amp;f." >
64     - <jar
65     - destfile="${build.windows.jar}"
66     - manifest="${build.manifest}" >
67     - <fileset dir="${build.core.dir}"
68     - excludes="com/jgoodies/looks/plastic/**/*" />
69     - <zipfileset dir="${descriptors.dir}"
70     - includes="windows.txt"
71     - fullpath="META-INF/services/javax.swing.LookAndFeel" />
72     - </jar>
73     - </target>
74     -
75     - <!-- ***************************************************************** -->
76     <target name="jar-demo" depends="jar-plastic"
77     description="Creates the demo jar." >
78     <jar
79 gregoa 1381 --- a/src/core/com/jgoodies/looks/Options.java
80     +++ b/src/core/com/jgoodies/looks/Options.java
81     @@ -40,8 +40,6 @@
82 gregoa 1326
83     import com.jgoodies.looks.common.ShadowPopup;
84     import com.jgoodies.looks.plastic.PlasticLookAndFeel;
85     -import com.jgoodies.looks.windows.WindowsLookAndFeel;
86     -import com.sun.java.swing.plaf.windows.WindowsComboBoxUI;
87    
88     /**
89 gregoa 1381 * Provides access to optional features of the JGoodies L&amp;Fs
90     --- a/src/core/com/jgoodies/looks/windows/WindowsArrowButton.java
91 gregoa 1326 +++ /dev/null
92     @@ -1,142 +0,0 @@
93     -/*
94 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
95 gregoa 1326 - *
96 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
97 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
98 gregoa 1381 - *
99     - * o Redistributions of source code must retain the above copyright notice,
100     - * this list of conditions and the following disclaimer.
101     - *
102     - * o Redistributions in binary form must reproduce the above copyright notice,
103     - * this list of conditions and the following disclaimer in the documentation
104     - * and/or other materials provided with the distribution.
105     - *
106     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
107     - * its contributors may be used to endorse or promote products derived
108     - * from this software without specific prior written permission.
109     - *
110     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
111     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
112     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
113     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
114     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
115     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
116     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
117     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
118     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
119     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
120     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
121 gregoa 1326 - */
122     -
123     -package com.jgoodies.looks.windows;
124     -
125     -import java.awt.Color;
126     -import java.awt.Dimension;
127     -import java.awt.Graphics;
128     -
129     -import javax.swing.UIManager;
130     -import javax.swing.plaf.basic.BasicArrowButton;
131     -
132     -/**
133 gregoa 1381 - * The JGoodies Windows Look&amp;Feel implementation for
134 gregoa 1326 - * arrow buttons used in scrollbars and comboboxes.
135     - * <p>
136 gregoa 1381 - * It differs from <code>BasicArrowButton</code> in that the preferred size
137     - * is always a square.
138 gregoa 1326 - * It differs from <code>WindowsScrollBarUI.WindowsArrowButton</code>
139     - * in that the triangle is black and positioned correctly.
140     - *
141     - * @author Karsten Lentzsch
142 gregoa 1381 - * @version $Revision: 1.5 $
143 gregoa 1326 - */
144     -final class WindowsArrowButton extends BasicArrowButton {
145     -
146     - public WindowsArrowButton(int direction) {
147     - super(direction);
148     - }
149     -
150     - public Dimension getPreferredSize() {
151     - int width = Math.max(5, UIManager.getInt("ScrollBar.width"));
152     - return new Dimension(width, width);
153     - }
154     -
155     - public void paintTriangle(
156     - Graphics g,
157     - int x,
158     - int y,
159     - int size,
160     - int triangleDirection,
161     - boolean isEnabled) {
162     - Color oldColor = g.getColor();
163     - int mid, i, j;
164     -
165     - j = 0;
166     - size = Math.max(size, 2);
167     - mid = (size - 1) / 2; // Modified by JGoodies
168     -
169     - g.translate(x, y);
170     - if (isEnabled)
171     - g.setColor(Color.black);
172     - else
173     - g.setColor(UIManager.getColor("controlShadow"));
174     -
175     - switch (triangleDirection) {
176     - case NORTH :
177     - for (i = 0; i < size; i++) {
178     - g.drawLine(mid - i, i, mid + i, i);
179     - }
180     - if (!isEnabled) {
181     - g.setColor(UIManager.getColor("controlLtHighlight"));
182     - g.drawLine(mid - i + 2, i, mid + i, i);
183     - }
184     - break;
185     - case SOUTH :
186     - if (!isEnabled) {
187     - g.translate(1, 1);
188     - g.setColor(UIManager.getColor("controlLtHighlight"));
189     - for (i = size - 1; i >= 0; i--) {
190     - g.drawLine(mid - i, j, mid + i, j);
191     - j++;
192     - }
193     - g.translate(-1, -1);
194     - g.setColor(UIManager.getColor("controlShadow"));
195     - }
196     -
197     - j = 0;
198     - for (i = size - 1; i >= 0; i--) {
199     - g.drawLine(mid - i, j, mid + i, j);
200     - j++;
201     - }
202     - break;
203     - case WEST :
204     - for (i = 0; i < size; i++) {
205     - g.drawLine(i, mid - i, i, mid + i);
206     - }
207     - if (!isEnabled) {
208     - g.setColor(UIManager.getColor("controlLtHighlight"));
209     - g.drawLine(i, mid - i + 2, i, mid + i);
210     - }
211     - break;
212     - case EAST :
213     - if (!isEnabled) {
214     - g.translate(1, 1);
215     - g.setColor(UIManager.getColor("controlLtHighlight"));
216     - for (i = size - 1; i >= 0; i--) {
217     - g.drawLine(j, mid - i, j, mid + i);
218     - j++;
219     - }
220     - g.translate(-1, -1);
221     - g.setColor(UIManager.getColor("controlShadow"));
222     - }
223     -
224     - j = 0;
225     - for (i = size - 1; i >= 0; i--) {
226     - g.drawLine(j, mid - i, j, mid + i);
227     - j++;
228     - }
229     - break;
230     - }
231     - g.translate(-x, -y);
232     - g.setColor(oldColor);
233     - }
234     -}
235 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsBorders.java
236 gregoa 1326 +++ /dev/null
237 gregoa 1381 @@ -1,584 +0,0 @@
238 gregoa 1326 -/*
239 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
240 gregoa 1326 - *
241 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
242 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
243 gregoa 1381 - *
244     - * o Redistributions of source code must retain the above copyright notice,
245     - * this list of conditions and the following disclaimer.
246     - *
247     - * o Redistributions in binary form must reproduce the above copyright notice,
248     - * this list of conditions and the following disclaimer in the documentation
249     - * and/or other materials provided with the distribution.
250     - *
251     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
252     - * its contributors may be used to endorse or promote products derived
253     - * from this software without specific prior written permission.
254     - *
255     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
256     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
257     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
258     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
259     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
260     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
261     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
262     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
263     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
264     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
265     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
266 gregoa 1326 - */
267     -
268     -package com.jgoodies.looks.windows;
269     -
270     -import java.awt.Color;
271     -import java.awt.Component;
272     -import java.awt.Graphics;
273     -import java.awt.Insets;
274     -
275 gregoa 1381 -import javax.swing.*;
276 gregoa 1326 -import javax.swing.border.AbstractBorder;
277     -import javax.swing.border.Border;
278     -import javax.swing.border.CompoundBorder;
279     -import javax.swing.border.EmptyBorder;
280     -import javax.swing.plaf.BorderUIResource;
281     -import javax.swing.plaf.UIResource;
282     -import javax.swing.plaf.basic.BasicBorders;
283     -import javax.swing.plaf.basic.BasicGraphicsUtils;
284     -
285     -/**
286 gregoa 1381 - * Consists of static inner classes that define different
287 gregoa 1326 - * <code>Borders</code> used in the JGoodies Windows look&amp;feel.
288     - *
289     - * @author Karsten Lentzsch
290 gregoa 1381 - * @version $Revision: 1.7 $
291 gregoa 1326 - */
292     -final class WindowsBorders {
293 gregoa 1381 -
294 gregoa 1326 - private WindowsBorders() {
295     - // Overrides default constructor; prevents instantiation.
296     - }
297 gregoa 1381 -
298 gregoa 1326 - // Accessing and Creating Borders ***************************************************
299     -
300     - private static Border menuBorder;
301     - private static Border xpMenuBorder;
302     - private static Border menuItemBorder;
303     - private static Border popupMenuBorder;
304     - private static Border noMarginPopupMenuBorder;
305     - private static Border separatorBorder;
306     - private static Border etchedBorder;
307     - private static Border menuBarHeaderBorder;
308     - private static Border toolBarHeaderBorder;
309     - private static Border rolloverButtonBorder;
310     -
311     -
312     - /**
313     - * Returns a <code>Border</code> for a <code>JButton</code>.
314     - */
315     - public static Border getButtonBorder() {
316     - UIDefaults table = UIManager.getLookAndFeelDefaults();
317     - Border outerBorder = new ButtonBorder(table.getColor("Button.shadow"),
318     - table.getColor("Button.darkShadow"), table
319     - .getColor("Button.light"), table
320     - .getColor("Button.highlight"), table
321     - .getColor("controlText"));
322     -
323     - Border buttonBorder = new BorderUIResource.CompoundBorderUIResource(
324     - outerBorder, new BasicBorders.MarginBorder());
325     - return buttonBorder;
326     - }
327     -
328     -
329     - /**
330     - * Returns a Border for a JMenu in classic mode.
331     - */
332     - static Border getMenuBorder() {
333     - if (menuBorder == null) {
334     - menuBorder = new BorderUIResource.CompoundBorderUIResource(
335     - new MenuBorder(),
336     - new BasicBorders.MarginBorder());
337     - }
338     - return menuBorder;
339     - }
340     -
341     - /**
342     - * Returns a Border for a JMenu in XP mode.
343     - */
344     - static Border getXPMenuBorder() {
345     - if (xpMenuBorder == null) {
346     - xpMenuBorder = new BasicBorders.MarginBorder();
347     - }
348     - return xpMenuBorder;
349     - }
350     -
351     - /**
352     - * Returns a border instance for a <code>JMenuItem</code>.
353     - */
354     - static Border getMenuItemBorder() {
355     - if (menuItemBorder == null) {
356     - menuItemBorder = new BorderUIResource(new BasicBorders.MarginBorder());
357     - }
358     - return menuItemBorder;
359     - }
360     -
361     - /**
362     - * Returns a separator border instance for <code>JMenuBar</code> or <code>JToolBar</code>.
363     - */
364     - static Border getSeparatorBorder() {
365     - if (separatorBorder == null) {
366     - separatorBorder = new BorderUIResource.CompoundBorderUIResource(
367     - new SeparatorBorder(),
368     - new BasicBorders.MarginBorder());
369     - }
370     - return separatorBorder;
371     - }
372     -
373     - /**
374     - * Returns an etched border instance for <code>JMenuBar</code> or <code>JToolBar</code>.
375     - */
376     - static Border getEtchedBorder() {
377     - if (etchedBorder == null) {
378     - etchedBorder = new BorderUIResource.CompoundBorderUIResource(
379     - new EtchedBorder(),
380     - new BasicBorders.MarginBorder());
381     - }
382     - return etchedBorder;
383     - }
384     -
385     - /**
386 gregoa 1381 - * Returns a special border for a <code>JMenuBar</code> that
387 gregoa 1326 - * is used in a header just above a <code>JToolBar</code>.
388     - */
389     - static Border getMenuBarHeaderBorder() {
390     - if (menuBarHeaderBorder == null) {
391     - menuBarHeaderBorder = new BorderUIResource.CompoundBorderUIResource(
392     - new MenuBarHeaderBorder(),
393     - new BasicBorders.MarginBorder());
394     - }
395     - return menuBarHeaderBorder;
396     - }
397     -
398     - /**
399     - * Returns a border instance for a <code>JPopupMenu</code>.
400 gregoa 1381 - *
401 gregoa 1326 - * @return the lazily created popup menu border
402     - */
403     - static Border getPopupMenuBorder() {
404     - if (popupMenuBorder == null) {
405     - popupMenuBorder = new PopupMenuBorder();
406     - }
407     - return popupMenuBorder;
408     - }
409     -
410     - /**
411     - * Returns a no-margin border instance for a <code>JPopupMenu</code>.
412 gregoa 1381 - *
413 gregoa 1326 - * @return the lazily created no-margin popup menu border
414     - */
415     - static Border getNoMarginPopupMenuBorder() {
416     - if (noMarginPopupMenuBorder == null) {
417     - noMarginPopupMenuBorder = new NoMarginPopupMenuBorder();
418     - }
419     - return noMarginPopupMenuBorder;
420     - }
421     -
422     - /**
423 gregoa 1381 - * Returns a special border for a <code>JToolBar</code> that
424 gregoa 1326 - * is used in a header just below a <code>JMenuBar</code>.
425     - */
426     - static Border getToolBarHeaderBorder() {
427 gregoa 1381 - if (toolBarHeaderBorder == null) {
428 gregoa 1326 - toolBarHeaderBorder = new BorderUIResource.CompoundBorderUIResource(
429     - new ToolBarHeaderBorder(),
430     - new BasicBorders.MarginBorder());
431     - }
432     - return toolBarHeaderBorder;
433     - }
434     -
435     - /**
436     - * Returns a border for a rollover <code>AbstractButton</code>.
437     - */
438     - static Border getRolloverButtonBorder() {
439 gregoa 1381 - if (rolloverButtonBorder == null) {
440 gregoa 1326 - rolloverButtonBorder = new CompoundBorder( // No UIResource
441     - new RolloverButtonBorder(),
442     - new RolloverMarginBorder());
443     - }
444     - return rolloverButtonBorder;
445     - }
446     -
447     -
448     - // Helper Classes *******************************************************************
449     -
450     -
451     - // Copied from BasicBorders, has correct black color for the outer default rectangle.
452     - private static final class ButtonBorder extends AbstractBorder implements UIResource {
453 gregoa 1381 -
454 gregoa 1326 - private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
455 gregoa 1381 -
456 gregoa 1326 - private final Color shadow;
457     - private final Color darkShadow;
458     - private final Color highlight;
459     - private final Color lightHighlight;
460     - private final Color defaultColor;
461     -
462 gregoa 1381 - public ButtonBorder(Color shadow, Color darkShadow,
463 gregoa 1326 - Color highlight, Color lightHighlight, Color defaultColor) {
464     - this.shadow = shadow;
465     - this.darkShadow = darkShadow;
466 gregoa 1381 - this.highlight = highlight;
467 gregoa 1326 - this.lightHighlight = lightHighlight;
468     - this.defaultColor = defaultColor;
469     - }
470     -
471     - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
472     - boolean isPressed = false;
473     - boolean isDefault = false;
474 gregoa 1381 -
475 gregoa 1326 - if (c instanceof AbstractButton) {
476     - AbstractButton b = (AbstractButton) c;
477     - ButtonModel model = b.getModel();
478 gregoa 1381 -
479 gregoa 1326 - isPressed = model.isPressed() && model.isArmed();
480     - if (c instanceof JButton) {
481     - isDefault = ((JButton) c).isDefaultButton();
482     - }
483 gregoa 1381 - }
484 gregoa 1326 - drawBezel(g, x, y, width, height, isPressed, isDefault, shadow,
485     - darkShadow, highlight, lightHighlight, defaultColor);
486     - }
487     -
488     - public Insets getBorderInsets(Component c) {
489     - return getBorderInsets(c, EMPTY_INSETS);
490     - }
491     -
492     - public Insets getBorderInsets(Component c, Insets insets) {
493     - // leave room for default visual
494     - insets.top = 2;
495     - insets.left = insets.bottom = insets.right = 3;
496     - return insets;
497     - }
498     -
499     - }
500     -
501     - /**
502     - * An abstract superclass for borders.
503     - */
504     - private abstract static class AbstractButtonBorder extends AbstractBorder implements UIResource {
505     -
506     - private static final Insets INSETS = new Insets(2, 2, 2, 2);
507     -
508     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
509     - AbstractButton button = (AbstractButton) c;
510     - ButtonModel model = button.getModel();
511     -
512     - //
513     - //System.out.println("Pressed=" + model.isPressed() + "; armed=" + model.isArmed());
514     - //if (!model.isArmed()) return;
515     -
516     - if (model.isPressed())
517     - WindowsUtils.drawPressed3DBorder(g, x, y, w, h);
518     - else
519     - WindowsUtils.drawFlush3DBorder(g, x, y, w, h);
520     - }
521     -
522     - public Insets getBorderInsets(Component c) { return INSETS; }
523     - }
524     -
525 gregoa 1381 -
526 gregoa 1326 - /**
527     - * A border used for <code>Buttons</code> that have the rollover property enabled.
528     - */
529     - private static final class RolloverButtonBorder extends AbstractButtonBorder {
530 gregoa 1381 -
531 gregoa 1326 - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
532     - AbstractButton b = (AbstractButton) c;
533     - ButtonModel model = b.getModel();
534     -
535     - if (!model.isEnabled())
536     - return;
537     -
538     - if (!(c instanceof JToggleButton)) {
539     - if (model.isRollover()) // && !( model.isPressed() && !model.isArmed()))
540     - super.paintBorder(c, g, x, y, w, h);
541     - return;
542     - }
543     -
544     - if (model.isSelected())
545     - WindowsUtils.drawPressed3DBorder(g, x, y, w, h);
546     - else if (model.isRollover()) {
547     - super.paintBorder(c, g, x, y, w, h);
548     - /*
549     - if (model.isPressed() && model.isArmed()) {
550     - ExtMetalUtils.drawPressed3DBorder(g, x, y, w, h);
551     - } else {
552     - ExtMetalUtils.drawFlush3DBorder(g, x, y, w, h);
553     - }*/
554     - }
555     - }
556     - }
557     -
558     -
559     - /**
560     - * A border which is like a Margin border but it will only honor the margin
561     - * if the margin has been explicitly set by the developer.
562     - */
563     - private static final class RolloverMarginBorder extends EmptyBorder {
564     -
565     - private RolloverMarginBorder() {
566 gregoa 1381 - super(1, 1, 1, 1);
567 gregoa 1326 - }
568     -
569     -
570     - public Insets getBorderInsets(Component c) {
571     - return getBorderInsets(c, new Insets(0, 0, 0, 0));
572     - }
573     -
574     -
575     - public Insets getBorderInsets(Component c, Insets insets) {
576     - Insets margin = null;
577     -
578     - if (c instanceof AbstractButton) {
579     - margin = ((AbstractButton) c).getMargin();
580     - }
581     - if (margin == null || margin instanceof UIResource) {
582     - // default margin so replace
583     - insets.left = left;
584     - insets.top = top;
585     - insets.right = right;
586     - insets.bottom = bottom;
587     - } else {
588     - // Margin which has been explicitly set by the user.
589     - insets.left = margin.left;
590     - insets.top = margin.top;
591     - insets.right = margin.right;
592     - insets.bottom = margin.bottom;
593     - }
594     - return insets;
595     - }
596     - }
597     -
598     - /**
599     - * A border that looks like a separator line; used for menu bars and tool bars.
600 gregoa 1381 - */
601 gregoa 1326 - private static final class SeparatorBorder extends AbstractBorder implements UIResource {
602     -
603     - private static final Insets INSETS = new Insets(0, 3, 2, 1);
604     -
605     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
606     - g.translate(x, y);
607     - g.setColor( UIManager.getColor("Separator.foreground"));
608     - g.drawLine( 0, h - 2, w - 1, h - 2 );
609     -
610     - g.setColor( UIManager.getColor("Separator.background"));
611     - g.drawLine( 0, h - 1, w - 1, h - 1 );
612     - g.translate(-x, -y);
613     - }
614 gregoa 1381 -
615 gregoa 1326 - public Insets getBorderInsets(Component c) { return INSETS; }
616     - }
617     -
618     -
619     - /**
620     - * A thin raised border.
621 gregoa 1381 - */
622 gregoa 1326 - static final class ThinRaisedBorder extends AbstractBorder implements UIResource {
623     -
624     - private static final Insets INSETS = new Insets(1, 1, 1, 1);
625     -
626     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
627     - WindowsUtils.drawFlush3DBorder(g, x, y, w, h);
628     - }
629 gregoa 1381 -
630 gregoa 1326 - public Insets getBorderInsets(Component c) { return INSETS; }
631     - }
632 gregoa 1381 -
633     -
634 gregoa 1326 - /**
635     - * A thin lowered border.
636 gregoa 1381 - */
637 gregoa 1326 - static final class ThinLoweredBorder extends AbstractBorder implements UIResource {
638     -
639     - private static final Insets INSETS = new Insets(1, 1, 1, 1);
640     -
641     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
642     - WindowsUtils.drawPressed3DBorder(g, x, y, w, h);
643     - }
644 gregoa 1381 -
645 gregoa 1326 - public Insets getBorderInsets(Component c) { return INSETS; }
646     - }
647 gregoa 1381 -
648     -
649 gregoa 1326 - /**
650     - * A border used for menu bars and tool bars in <code>HeaderStyle.SINGLE</code>.
651 gregoa 1381 - * The bar is wrapped by an inner thin raised border,
652 gregoa 1326 - * which in turn is wrapped by an outer thin lowered border.
653 gregoa 1381 - */
654 gregoa 1326 - private static final class EtchedBorder extends AbstractBorder implements UIResource {
655     -
656     - private static final Insets INSETS = new Insets(2, 2, 2, 2);
657     -
658     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
659     - WindowsUtils.drawPressed3DBorder(g, x, y, w, h);
660     - WindowsUtils.drawFlush3DBorder (g, x + 1, y + 1, w - 2, h - 2);
661     - }
662     -
663     - public Insets getBorderInsets(Component c) { return INSETS; }
664     - }
665 gregoa 1381 -
666     -
667 gregoa 1326 - /**
668     - * A border used for menu bars in <code>HeaderStyle.BOTH</code>.
669     - * The menu bar and tool bar are wrapped by a thin raised border,
670     - * both together are wrapped by a thin lowered border.
671     - */
672     - private static final class MenuBarHeaderBorder extends AbstractBorder implements UIResource {
673     -
674 gregoa 1381 - private static final Insets INSETS = new Insets(2, 2, 1, 2);
675 gregoa 1326 -
676     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
677     - WindowsUtils.drawPressed3DBorder(g, x, y, w, h + 1);
678     - WindowsUtils.drawFlush3DBorder (g, x + 1, y + 1, w - 2, h - 1);
679     - }
680     -
681     - public Insets getBorderInsets(Component c) { return INSETS; }
682     - }
683 gregoa 1381 -
684     -
685 gregoa 1326 - private static final class PopupMenuBorder extends AbstractBorder implements UIResource {
686     -
687     - private static final Insets INSETS = new Insets(3, 3, 3, 3);
688     -
689     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
690     - g.translate(x, y);
691     - g.setColor(UIManager.getColor("controlShadow"));
692     - g.drawRect(0, 0, w-1, h-1);
693     - g.setColor(UIManager.getColor("MenuItem.background"));
694     - g.drawRect(1, 1, w-3, h-3);
695     - g.drawRect(2, 2, w-5, h-5);
696     - g.translate(-x, -y);
697     - }
698     -
699     - public Insets getBorderInsets(Component c) { return INSETS; }
700     - }
701     -
702 gregoa 1381 -
703 gregoa 1326 - private static final class NoMarginPopupMenuBorder extends AbstractBorder implements UIResource {
704     -
705     - private static final Insets INSETS = new Insets(1, 1, 1, 1);
706     -
707     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
708     - g.translate(x, y);
709     - g.setColor(UIManager.getColor("controlShadow"));
710     - g.drawRect(0, 0, w-1, h-1);
711     -// g.setColor(UIManager.getColor("MenuItem.background"));
712     -// g.drawRect(1, 1, 0, h-3);
713     - g.translate(-x, -y);
714     - }
715     -
716     - public Insets getBorderInsets(Component c) { return INSETS; }
717     - }
718 gregoa 1381 -
719 gregoa 1326 - /**
720     - * A border used for tool bars in <code>HeaderStyle.BOTH</code>.
721     - * The menu bar and tool bar are wrapped by a thin raised border,
722     - * both together are wrapped by a thin lowered border.
723     - */
724     - private static final class ToolBarHeaderBorder extends AbstractBorder implements UIResource {
725     -
726 gregoa 1381 - private static final Insets INSETS = new Insets(1, 2, 2, 2);
727 gregoa 1326 -
728     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
729     - WindowsUtils.drawPressed3DBorder(g, x, y - 1, w, h + 1);
730     - WindowsUtils.drawFlush3DBorder (g, x + 1, y, w - 2, h - 1);
731     - }
732     -
733     - public Insets getBorderInsets(Component c) { return INSETS; }
734     - }
735 gregoa 1381 -
736     -
737 gregoa 1326 - /**
738     - * A border used for menus.
739     - */
740     - private static final class MenuBorder extends AbstractBorder implements UIResource {
741 gregoa 1381 -
742 gregoa 1326 - private static final Insets INSETS = new Insets(1, 1, 1, 1);
743     -
744     - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
745     - AbstractButton b = (AbstractButton) c;
746     - ButtonModel model = b.getModel();
747     -
748     - //System.out.println("rollover=" + model.isRollover());
749     - //if ((3 < 4) || model.isRollover()) { // && !(model.isPressed() && !model.isArmed())) {
750     - if (model.isSelected())
751     - WindowsUtils.drawPressed3DBorder(g, x, y, w, h);
752     - else if (model.isRollover())
753     - WindowsUtils.drawFlush3DBorder(g, x, y, w, h);
754     - //}
755     - }
756 gregoa 1381 -
757 gregoa 1326 - public Insets getBorderInsets(Component c) { return INSETS; }
758     -
759     - }
760     -
761     -
762     - // Helper Code **********************************************************************
763     -
764     - // Copied from BasicGraphicsUtils, has an additional color for the default rectangle.
765 gregoa 1381 - private static void drawBezel(Graphics g, int x, int y, int w, int h,
766     - boolean isPressed, boolean isDefault,
767     - Color shadow, Color darkShadow,
768 gregoa 1326 - Color highlight, Color lightHighlight, Color defaultColor)
769     - {
770     - Color oldColor = g.getColor(); // Make no net change to g
771     - g.translate(x, y);
772 gregoa 1381 -
773 gregoa 1326 - if (isPressed && isDefault) {
774     - g.setColor(darkShadow);
775     - g.drawRect(0, 0, w - 1, h - 1);
776     - g.setColor(shadow);
777     - g.drawRect(1, 1, w - 3, h - 3);
778     - } else if (isPressed) {
779     - BasicGraphicsUtils.drawLoweredBezel(g, x, y, w, h,
780     - shadow, darkShadow, highlight, lightHighlight);
781     - } else if (isDefault) {
782 gregoa 1381 - g.setColor(defaultColor);
783 gregoa 1326 - g.drawRect(0, 0, w-1, h-1);
784     -
785 gregoa 1381 - g.setColor(lightHighlight);
786 gregoa 1326 - g.drawLine(1, 1, 1, h-3);
787     - g.drawLine(2, 1, w-3, 1);
788     -
789     - g.setColor(highlight);
790     - g.drawLine(2, 2, 2, h-4);
791     - g.drawLine(3, 2, w-4, 2);
792     -
793     - g.setColor(shadow);
794     - g.drawLine(2, h-3, w-3, h-3);
795     - g.drawLine(w-3, 2, w-3, h-4);
796     -
797 gregoa 1381 - g.setColor(darkShadow);
798 gregoa 1326 - g.drawLine(1, h-2, w-2, h-2);
799     - g.drawLine(w-2, h-2, w-2, 1);
800     - } else {
801 gregoa 1381 - g.setColor(lightHighlight);
802 gregoa 1326 - g.drawLine(0, 0, 0, h-1);
803     - g.drawLine(1, 0, w-2, 0);
804     -
805     - g.setColor(highlight);
806     - g.drawLine(1, 1, 1, h-3);
807     - g.drawLine(2, 1, w-3, 1);
808     -
809     - g.setColor(shadow);
810     - g.drawLine(1, h-2, w-2, h-2);
811     - g.drawLine(w-2, 1, w-2, h-3);
812     -
813 gregoa 1381 - g.setColor(darkShadow);
814 gregoa 1326 - g.drawLine(0, h-1, w-1, h-1);
815     - g.drawLine(w-1, h-1, w-1, 0);
816     - }
817     - g.translate(-x, -y);
818     - g.setColor(oldColor);
819     - }
820     -
821     -}
822 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsButtonUI.java
823 gregoa 1326 +++ /dev/null
824     @@ -1,71 +0,0 @@
825     -/*
826 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
827 gregoa 1326 - *
828 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
829 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
830 gregoa 1381 - *
831     - * o Redistributions of source code must retain the above copyright notice,
832     - * this list of conditions and the following disclaimer.
833     - *
834     - * o Redistributions in binary form must reproduce the above copyright notice,
835     - * this list of conditions and the following disclaimer in the documentation
836     - * and/or other materials provided with the distribution.
837     - *
838     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
839     - * its contributors may be used to endorse or promote products derived
840     - * from this software without specific prior written permission.
841     - *
842     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
843     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
844     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
845     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
846     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
847     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
848     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
849     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
850     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
851     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
852     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
853 gregoa 1326 - */
854     -
855     -package com.jgoodies.looks.windows;
856     -
857     -import java.awt.Dimension;
858     -
859     -import javax.swing.AbstractButton;
860     -import javax.swing.JComponent;
861     -import javax.swing.plaf.ComponentUI;
862     -import javax.swing.plaf.basic.BasicGraphicsUtils;
863     -
864     -/**
865     - * The JGoodies Windows look&amp;feel implementation of <code>ButtonUI</code>.<p>
866 gregoa 1381 - *
867 gregoa 1326 - * Unlike its superclass it returns even and odd preferred heights.
868     - *
869     - * @author Karsten Lentzsch
870 gregoa 1381 - * @version $Revision: 1.5 $
871 gregoa 1326 - */
872     -public final class WindowsButtonUI extends com.sun.java.swing.plaf.windows.WindowsButtonUI {
873     -
874     - public static ComponentUI createUI(JComponent b) {
875     - return new WindowsButtonUI();
876     - }
877     -
878     - public Dimension getPreferredSize(JComponent c) {
879     - AbstractButton b = (AbstractButton) c;
880     - Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, b
881     - .getIconTextGap());
882     -
883     - /* Ensure that the width of the button is odd,
884     - * to improve the painting of the dashed focus line
885     - */
886     - if (d != null && b.isFocusPainted()) {
887     - if (d.width % 2 == 0) {
888     - d.width += 1;
889     - }
890     - }
891     - return d;
892     - }
893     -
894     -
895     -}
896     \ No newline at end of file
897 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsComboBoxEditor.java
898 gregoa 1326 +++ /dev/null
899     @@ -1,71 +0,0 @@
900     -/*
901 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
902 gregoa 1326 - *
903 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
904 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
905 gregoa 1381 - *
906     - * o Redistributions of source code must retain the above copyright notice,
907     - * this list of conditions and the following disclaimer.
908     - *
909     - * o Redistributions in binary form must reproduce the above copyright notice,
910     - * this list of conditions and the following disclaimer in the documentation
911     - * and/or other materials provided with the distribution.
912     - *
913     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
914     - * its contributors may be used to endorse or promote products derived
915     - * from this software without specific prior written permission.
916     - *
917     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
918     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
919     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
920     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
921     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
922     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
923     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
924     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
925     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
926     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
927     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
928 gregoa 1326 - */
929     -
930     -package com.jgoodies.looks.windows;
931     -
932     -import javax.swing.plaf.basic.BasicComboBoxEditor;
933     -
934     -import com.jgoodies.looks.common.ComboBoxEditorTextField;
935     -
936     -/**
937 gregoa 1381 - * The default editor for editable combo boxes in the
938 gregoa 1326 - * JGoodies Windows Look&amp;Feel.<p>
939 gregoa 1381 - *
940     - * It differs from its superclass in that the border is quite the same as for
941 gregoa 1326 - * text fields: a compound border with an inner <code>MarginBorder</code>.
942 gregoa 1381 - *
943 gregoa 1326 - * @author Karsten Lentzsch
944 gregoa 1381 - * @version $Revision: 1.8 $
945 gregoa 1326 - */
946     -class WindowsComboBoxEditor extends BasicComboBoxEditor {
947     -
948     - WindowsComboBoxEditor(boolean isTableCellEditor) {
949     - editor = new ComboBoxEditorTextField(isTableCellEditor);
950     - }
951     -
952     - public void setItem(Object item) {
953     - super.setItem(item);
954     - editor.selectAll();
955     - }
956     -
957     - /**
958     - * A subclass of BasicComboBoxEditor that implements UIResource.
959     - * BasicComboBoxEditor and WindowsComboBoxEditor don't implement UIResource
960     - * directly so that applications can safely override the cellRenderer
961     - * property with BasicListCellRenderer subclasses.
962     - */
963     - static final class UIResource extends WindowsComboBoxEditor implements
964     - javax.swing.plaf.UIResource {
965 gregoa 1381 -
966 gregoa 1326 - UIResource(boolean isTableCellEditor) {
967     - super(isTableCellEditor);
968     - }
969     - }
970     -}
971     \ No newline at end of file
972 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsComboBoxUI.java
973 gregoa 1326 +++ /dev/null
974     @@ -1,557 +0,0 @@
975     -/*
976 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
977 gregoa 1326 - *
978 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
979 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
980 gregoa 1381 - *
981     - * o Redistributions of source code must retain the above copyright notice,
982     - * this list of conditions and the following disclaimer.
983     - *
984     - * o Redistributions in binary form must reproduce the above copyright notice,
985     - * this list of conditions and the following disclaimer in the documentation
986     - * and/or other materials provided with the distribution.
987     - *
988     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
989     - * its contributors may be used to endorse or promote products derived
990     - * from this software without specific prior written permission.
991     - *
992     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
993     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
994     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
995     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
996     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
997     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
998     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
999     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1000     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
1001     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1002     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1003 gregoa 1326 - */
1004     -
1005     -package com.jgoodies.looks.windows;
1006     -
1007     -import java.awt.*;
1008     -import java.beans.PropertyChangeEvent;
1009     -import java.beans.PropertyChangeListener;
1010     -
1011     -import javax.swing.*;
1012     -import javax.swing.border.Border;
1013     -import javax.swing.border.EmptyBorder;
1014     -import javax.swing.plaf.ComponentUI;
1015     -import javax.swing.plaf.UIResource;
1016     -import javax.swing.plaf.basic.BasicComboBoxRenderer;
1017     -import javax.swing.plaf.basic.BasicComboBoxUI;
1018     -import javax.swing.plaf.basic.BasicComboPopup;
1019     -import javax.swing.plaf.basic.ComboPopup;
1020     -
1021     -import com.jgoodies.looks.LookUtils;
1022     -import com.jgoodies.looks.Options;
1023     -import com.sun.java.swing.plaf.windows.WindowsTextFieldUI;
1024     -
1025     -/**
1026 gregoa 1381 - * The JGoodies Windows Look&amp;Feel implementation of
1027 gregoa 1326 - * {@link javax.swing.plaf.ComboBoxUI}.
1028 gregoa 1381 - * Corrects the editor insets for editable combo boxes
1029     - * as well as the render insets for non-editable combos. And it has
1030 gregoa 1326 - * the same height as text fields - unless you change the renderer.<p>
1031 gregoa 1381 - *
1032     - * Also, this class offers to use the combo's popup prototype display value
1033     - * to compute the popup menu width. This is an optional feature of
1034 gregoa 1326 - * the JGoodies Windows L&amp;f implemented via a client property key.
1035     - *
1036     - * @author Karsten Lentzsch
1037 gregoa 1381 - * @version $Revision: 1.21 $
1038     - *
1039 gregoa 1326 - * @see Options#COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
1040     - */
1041     -public class WindowsComboBoxUI extends com.sun.java.swing.plaf.windows.WindowsComboBoxUI {
1042 gregoa 1381 -
1043 gregoa 1326 - private static final String CELL_EDITOR_KEY = "JComboBox.isTableCellEditor";
1044 gregoa 1381 -
1045     - /**
1046     - * Used to determine the minimum height of a text field,
1047 gregoa 1326 - * which in turn is used to answer the combobox's minimum height.
1048     - */
1049     - private static final JTextField PHANTOM = new JTextField("Phantom");
1050 gregoa 1381 -
1051 gregoa 1326 - private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
1052     - private static final Border EMPTY_BORDER = new EmptyBorder(EMPTY_INSETS);
1053 gregoa 1381 -
1054     -
1055 gregoa 1326 - private boolean tableCellEditor;
1056     - private PropertyChangeListener propertyChangeListener;
1057 gregoa 1381 -
1058     -
1059 gregoa 1326 - // ************************************************************************
1060 gregoa 1381 -
1061 gregoa 1326 - public static ComponentUI createUI(JComponent b) {
1062     - ensurePhantomHasWindowsUI();
1063     - return new WindowsComboBoxUI();
1064     - }
1065     -
1066 gregoa 1381 -
1067 gregoa 1326 - /**
1068     - * Ensures that the phantom text field has a Windows text field UI.
1069     - */
1070     - private static void ensurePhantomHasWindowsUI() {
1071     - if (!(PHANTOM.getUI() instanceof WindowsTextFieldUI)) {
1072     - PHANTOM.updateUI();
1073     - }
1074     - }
1075 gregoa 1381 -
1076     -
1077 gregoa 1326 - // ************************************************************************
1078 gregoa 1381 -
1079 gregoa 1326 - public void installUI(JComponent c) {
1080     - super.installUI(c);
1081     - tableCellEditor = isTableCellEditor();
1082 gregoa 1381 - }
1083     -
1084 gregoa 1326 - protected void installListeners() {
1085     - super.installListeners();
1086     - propertyChangeListener = new TableCellEditorPropertyChangeHandler();
1087     - comboBox.addPropertyChangeListener(CELL_EDITOR_KEY, propertyChangeListener);
1088     - }
1089 gregoa 1381 -
1090 gregoa 1326 - protected void uninstallListeners() {
1091     - super.uninstallListeners();
1092     - comboBox.removePropertyChangeListener(CELL_EDITOR_KEY, propertyChangeListener);
1093     - propertyChangeListener = null;
1094     - }
1095 gregoa 1381 -
1096     -
1097 gregoa 1326 - /**
1098     - * Creates the arrow button that is to be used in the combo box.<p>
1099 gregoa 1381 - *
1100 gregoa 1326 - * Overridden to paint black triangles.
1101     - */
1102     - protected JButton createArrowButton() {
1103     - return LookUtils.IS_LAF_WINDOWS_XP_ENABLED
1104     - ? super.createArrowButton()
1105     - : new WindowsArrowButton(SwingConstants.SOUTH);
1106     - }
1107 gregoa 1381 -
1108     -
1109 gregoa 1326 - /**
1110 gregoa 1381 - * Creates the editor that is to be used in editable combo boxes.
1111     - * This method only gets called if a custom editor has not already
1112 gregoa 1326 - * been installed in the JComboBox.
1113     - */
1114     - protected ComboBoxEditor createEditor() {
1115     - return new com.jgoodies.looks.windows.WindowsComboBoxEditor.UIResource(tableCellEditor);
1116     - }
1117     -
1118     -
1119     - /**
1120 gregoa 1381 - * Creates a layout manager for managing the components which
1121 gregoa 1326 - * make up the combo box.<p>
1122 gregoa 1381 - *
1123 gregoa 1326 - * Overriden to use a layout that has a fixed width arrow button.
1124 gregoa 1381 - *
1125 gregoa 1326 - * @return an instance of a layout manager
1126     - */
1127     - protected LayoutManager createLayoutManager() {
1128     - return new WindowsComboBoxLayoutManager();
1129     - }
1130     -
1131     -
1132     - protected void configureEditor() {
1133     - super.configureEditor();
1134     - if (!comboBox.isEnabled()) {
1135     - editor.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
1136     - }
1137     - }
1138 gregoa 1381 -
1139 gregoa 1326 - /**
1140     - * Creates a ComboPopup that honors the optional combo popup display value
1141 gregoa 1381 - * that is used to compute the popup menu width.
1142 gregoa 1326 - */
1143     - protected ComboPopup createPopup() {
1144     - return new WindowsComboPopup(comboBox);
1145     - }
1146 gregoa 1381 -
1147     -
1148 gregoa 1326 - /**
1149 gregoa 1381 - * Creates the default renderer that will be used in a non-editiable combo
1150     - * box. A default renderer will used only if a renderer has not been
1151 gregoa 1326 - * explicitly set with <code>setRenderer</code>.<p>
1152 gregoa 1381 - *
1153     - * This method differs from the superclass implementation in that
1154 gregoa 1326 - * it uses an empty border with the default left and right text insets,
1155 gregoa 1381 - * the same as used by a combo box editor.
1156     - *
1157 gregoa 1326 - * @return a <code>ListCellRender</code> used for the combo box
1158     - * @see javax.swing.JComboBox#setRenderer
1159     - */
1160     - protected ListCellRenderer createRenderer() {
1161     - if (tableCellEditor) {
1162     - return super.createRenderer();
1163     - }
1164     - BasicComboBoxRenderer renderer = new BasicComboBoxRenderer.UIResource();
1165     - renderer.setBorder(UIManager.getBorder("ComboBox.rendererBorder"));
1166     - return renderer;
1167     - }
1168     -
1169     -
1170     - /**
1171     - * The minumum size is the size of the display area plus insets plus the button.
1172     - */
1173     - public Dimension getMinimumSize(JComponent c) {
1174     - if (!isMinimumSizeDirty) {
1175     - return new Dimension(cachedMinimumSize);
1176     - }
1177     - Dimension size = getDisplaySize();
1178     - Insets insets = getInsets();
1179     - size.height += insets.top + insets.bottom;
1180     - int buttonWidth = getEditableButtonWidth();
1181     - size.width += insets.left + insets.right + buttonWidth;
1182     - // The combo editor benefits from extra space for the caret.
1183 gregoa 1381 - // To make editable and non-editable equally wide,
1184 gregoa 1326 - // we always add 1 pixel.
1185     - size.width += 1;
1186 gregoa 1381 -
1187 gregoa 1326 - // Honor corrections made in #paintCurrentValue
1188     - ListCellRenderer renderer = comboBox.getRenderer();
1189     - if (renderer instanceof JComponent) {
1190     - JComponent component = (JComponent) renderer;
1191     - Insets rendererInsets = component.getInsets();
1192     - Insets editorInsets = UIManager.getInsets("ComboBox.editorInsets");
1193     - int offsetLeft = Math.max(0, editorInsets.left - rendererInsets.left);
1194     - int offsetRight = Math.max(0, editorInsets.right - rendererInsets.right);
1195     - // int offsetTop = Math.max(0, editorInsets.top - rendererInsets.top);
1196     - // int offsetBottom = Math.max(0, editorInsets.bottom - rendererInsets.bottom);
1197     - size.width += offsetLeft + offsetRight;
1198     - //size.height += offsetTop + offsetBottom;
1199     - }
1200 gregoa 1381 -
1201 gregoa 1326 - // The height is oriented on the JTextField height
1202     - Dimension textFieldSize = PHANTOM.getMinimumSize();
1203 gregoa 1381 - size.height = (LookUtils.IS_OS_WINDOWS_VISTA && !LookUtils.IS_LAF_WINDOWS_XP_ENABLED)
1204 gregoa 1326 - ? textFieldSize.height
1205     - : Math.max(textFieldSize.height, size.height);
1206     -
1207 gregoa 1381 - cachedMinimumSize.setSize(size.width, size.height);
1208 gregoa 1326 - isMinimumSizeDirty = false;
1209 gregoa 1381 -
1210 gregoa 1326 - return new Dimension(size);
1211     - }
1212     -
1213     - /**
1214     - * Delegates to #getMinimumSize(Component).
1215     - * Overridden to return the same result in JDK 1.5 as in JDK 1.4.
1216     - */
1217     - public Dimension getPreferredSize(JComponent c) {
1218     - return getMinimumSize(c);
1219     - }
1220     -
1221 gregoa 1381 -
1222 gregoa 1326 - /**
1223     - * Paints the currently selected item.
1224     - */
1225     - public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) {
1226     - ListCellRenderer renderer = comboBox.getRenderer();
1227     - Component c;
1228     - boolean isVistaReadOnlyCombo = isVistaXPStyleReadOnlyCombo();
1229     -
1230     - if (hasFocus && !isPopupVisible(comboBox)) {
1231     - c = renderer.getListCellRendererComponent(listBox,
1232     - comboBox.getSelectedItem(),
1233     - -1,
1234     - true,
1235     - false);
1236     - } else {
1237     - c = renderer.getListCellRendererComponent(listBox,
1238     - comboBox.getSelectedItem(),
1239     - -1,
1240     - false,
1241     - false );
1242     - c.setBackground(UIManager.getColor("ComboBox.background"));
1243     - }
1244     - Border oldBorder = null;
1245     - Rectangle originalBounds = new Rectangle(bounds);
1246     - if ((c instanceof JComponent) && !tableCellEditor) {
1247     - JComponent component = (JComponent) c;
1248     - if (isRendererBorderRemovable(component)) {
1249     - oldBorder = component.getBorder();
1250     - component.setBorder(EMPTY_BORDER); //new WindowsBorders.DashedBorder(c.getForeground(), 1));
1251     - }
1252     - Insets rendererInsets = component.getInsets();
1253     - Insets editorInsets = UIManager.getInsets("ComboBox.editorInsets");
1254     - int offsetLeft = Math.max(0, editorInsets.left - rendererInsets.left);
1255     - int offsetRight = Math.max(0, editorInsets.right - rendererInsets.right);
1256     - int offsetTop = Math.max(0, editorInsets.top - rendererInsets.top);
1257     - int offsetBottom = Math.max(0, editorInsets.bottom - rendererInsets.bottom);
1258     - bounds.x += offsetLeft;
1259     - bounds.y += offsetTop;
1260     - bounds.width -= offsetLeft + offsetRight - 1;
1261     - bounds.height -= offsetTop + offsetBottom;
1262     - }
1263 gregoa 1381 -
1264 gregoa 1326 - c.setFont(comboBox.getFont());
1265     - if (hasFocus && !isPopupVisible(comboBox) && !isVistaReadOnlyCombo) {
1266     - c.setForeground(listBox.getSelectionForeground());
1267     - c.setBackground(listBox.getSelectionBackground());
1268     - } else {
1269     - if (comboBox.isEnabled()) {
1270     - c.setForeground(comboBox.getForeground());
1271     - c.setBackground(comboBox.getBackground());
1272     - } else {
1273     - c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
1274     - c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
1275     - }
1276     - }
1277     -
1278     - // Fix for 4238829: should lay out the JPanel.
1279     - boolean shouldValidate = c instanceof JPanel;
1280     -
1281     - Boolean oldOpaque = null;
1282     - if (isVistaReadOnlyCombo && (c instanceof JComponent) && !(c instanceof DefaultListCellRenderer)) {
1283     - oldOpaque = Boolean.valueOf(c.isOpaque());
1284     - ((JComponent) c).setOpaque(false);
1285     - }
1286     - currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y,
1287     - bounds.width, bounds.height, shouldValidate);
1288     - if (hasFocus) {
1289     - Color oldColor = g.getColor();
1290     - g.setColor(comboBox.getForeground());
1291     - if (isVistaReadOnlyCombo) {
1292     - int width = originalBounds.width - 2;
1293     - if ((width % 2) == 0) {
1294     - width += 1;
1295     - }
1296 gregoa 1381 - WindowsUtils.drawRoundedDashedRect(g,
1297     - originalBounds.x+1, originalBounds.y+1,
1298 gregoa 1326 - width, originalBounds.height-2);
1299     - } /*else {
1300     - BasicGraphicsUtils.drawDashedRect(g,
1301     - bounds.x, bounds.y, bounds.width, bounds.height);
1302     - }*/
1303     - g.setColor(oldColor);
1304     - }
1305     - if (oldOpaque != null) {
1306     - ((JComponent) c).setOpaque(oldOpaque.booleanValue());
1307     - }
1308     - if (oldBorder != null) {
1309     - ((JComponent) c).setBorder(oldBorder);
1310     - }
1311     - }
1312 gregoa 1381 -
1313 gregoa 1326 - /**
1314     - * Checks and answer whether the border of the given renderer component
1315     - * can be removed temporarily, so the combo's selection background will
1316     - * be consistent with the default renderer and native appearance.
1317     - * This test is invoked from <code>#paintCurrentValue</code>.<p>
1318 gregoa 1381 - *
1319 gregoa 1326 - * It is safe to remove an EmptyBorder if the component doesn't override
1320     - * <code>#update</code>, <code>#paint</code> and <code>#paintBorder</code>.
1321     - * Since we know the default renderer, we can remove its border.<p>
1322 gregoa 1381 - *
1323 gregoa 1326 - * Custom renderers may set a hint to make their border removable.
1324 gregoa 1381 - * To do so, set the client property "isBorderRemovable"
1325 gregoa 1326 - * to <code>Boolean.TRUE</code>. If this client property is set,
1326     - * its value will be returned. If it is not set, <code>true</code> is returned
1327     - * if and only if the component's border is an EmptyBorder.
1328 gregoa 1381 - *
1329 gregoa 1326 - * @param rendererComponent the renderer component to check
1330     - * @return true if the component's border can be removed, false if not
1331     - * @see #paintCurrentValue(Graphics, Rectangle, boolean)
1332     - */
1333     - protected boolean isRendererBorderRemovable(JComponent rendererComponent) {
1334     - if (rendererComponent instanceof BasicComboBoxRenderer.UIResource)
1335     - return true;
1336     - Object hint = rendererComponent.getClientProperty(Options.COMBO_RENDERER_IS_BORDER_REMOVABLE);
1337     - if (hint != null)
1338     - return Boolean.TRUE.equals(hint);
1339     - Border border = rendererComponent.getBorder();
1340     - return border instanceof EmptyBorder;
1341     - }
1342 gregoa 1381 -
1343     -
1344 gregoa 1326 - private boolean isVistaXPStyleReadOnlyCombo() {
1345 gregoa 1381 - return LookUtils.IS_OS_WINDOWS_VISTA
1346 gregoa 1326 - && LookUtils.IS_LAF_WINDOWS_XP_ENABLED
1347     - && !comboBox.isEditable();
1348     - }
1349 gregoa 1381 -
1350     -
1351 gregoa 1326 - /**
1352     - * Returns the area that is reserved for drawing the currently selected item.
1353     - */
1354     - protected Rectangle rectangleForCurrentValue() {
1355     - int width = comboBox.getWidth();
1356     - int height = comboBox.getHeight();
1357     - Insets insets = getInsets();
1358     - int buttonWidth = getEditableButtonWidth();
1359     - if (arrowButton != null) {
1360     - buttonWidth = arrowButton.getWidth();
1361     - }
1362     - if (comboBox.getComponentOrientation().isLeftToRight()) {
1363     - return new Rectangle(
1364     - insets.left,
1365     - insets.top,
1366     - width - (insets.left + insets.right + buttonWidth),
1367     - height - (insets.top + insets.bottom));
1368     - } else {
1369     - return new Rectangle(
1370     - insets.left + buttonWidth,
1371     - insets.top ,
1372     - width - (insets.left + insets.right + buttonWidth),
1373     - height - (insets.top + insets.bottom));
1374     - }
1375     - }
1376     -
1377 gregoa 1381 -
1378 gregoa 1326 - // Helper Code ************************************************************
1379 gregoa 1381 -
1380 gregoa 1326 - /**
1381     - * Computes and returns the width of the arrow button in editable state.
1382 gregoa 1381 - *
1383 gregoa 1326 - * @return the width of the arrow button in editable state
1384     - */
1385     - private int getEditableButtonWidth() {
1386     - return UIManager.getInt("ScrollBar.width");
1387     - }
1388 gregoa 1381 -
1389 gregoa 1326 - /**
1390     - * Checks and answers if this UI's combo has a client property
1391     - * that indicates that the combo is used as a table cell editor.
1392 gregoa 1381 - *
1393 gregoa 1326 - * @return <code>true</code> if the table cell editor client property
1394     - * is set to <code>Boolean.TRUE</code>, <code>false</code> otherwise
1395     - */
1396     - private boolean isTableCellEditor() {
1397     - return Boolean.TRUE.equals(comboBox.getClientProperty(CELL_EDITOR_KEY));
1398     - }
1399     -
1400 gregoa 1381 -
1401 gregoa 1326 - // Collaborator Classes ***************************************************
1402     -
1403     - /**
1404 gregoa 1381 - * This layout manager handles the 'standard' layout of combo boxes.
1405 gregoa 1326 - * It puts the arrow button to the right and the editor to the left.
1406     - * If there is no editor it still keeps the arrow button to the right.
1407 gregoa 1381 - *
1408     - * Overriden to use a fixed arrow button width.
1409 gregoa 1326 - */
1410     - private final class WindowsComboBoxLayoutManager
1411     - extends BasicComboBoxUI.ComboBoxLayoutManager {
1412     -
1413     - public void layoutContainer(Container parent) {
1414     - JComboBox cb = (JComboBox) parent;
1415     -
1416     - int width = cb.getWidth();
1417     - int height = cb.getHeight();
1418     -
1419     - Insets insets = getInsets();
1420     - int buttonWidth = getEditableButtonWidth();
1421     - int buttonHeight = height - (insets.top + insets.bottom);
1422     -
1423     - if (arrowButton != null) {
1424     - if (cb.getComponentOrientation().isLeftToRight()) {
1425     - arrowButton.setBounds(
1426     - width - (insets.right + buttonWidth),
1427     - insets.top,
1428     - buttonWidth,
1429     - buttonHeight);
1430     - } else {
1431     - arrowButton.setBounds(
1432     - insets.left,
1433     - insets.top,
1434     - buttonWidth,
1435     - buttonHeight);
1436     - }
1437     - }
1438     - if (editor != null) {
1439     - editor.setBounds(rectangleForCurrentValue());
1440     - }
1441     - }
1442 gregoa 1381 -
1443 gregoa 1326 - }
1444 gregoa 1381 -
1445     -
1446 gregoa 1326 - /**
1447 gregoa 1381 - * Differs from the BasicComboPopup in that it uses the standard
1448 gregoa 1326 - * popmenu border and honors an optional popup prototype display value.
1449     - */
1450     - private static final class WindowsComboPopup extends BasicComboPopup {
1451     -
1452     - private WindowsComboPopup(JComboBox combo) {
1453     - super(combo);
1454     - }
1455     -
1456     - /**
1457 gregoa 1381 - * Calculates the placement and size of the popup portion
1458     - * of the combo box based on the combo box location and
1459 gregoa 1326 - * the enclosing screen bounds. If no transformations are required,
1460 gregoa 1381 - * then the returned rectangle will have the same values
1461 gregoa 1326 - * as the parameters.<p>
1462 gregoa 1381 - *
1463     - * In addition to the superclass behavior, this class offers
1464     - * to use the combo's popup prototype display value to compute
1465     - * the popup menu width. This is an optional feature of
1466 gregoa 1326 - * the JGoodies Windows L&amp;f implemented via a client property key.<p>
1467 gregoa 1381 - *
1468 gregoa 1326 - * If a prototype is set, the popup width is the maximum of the
1469     - * combobox width and the prototype based popup width.
1470     - * For the latter the renderer is used to render the prototype.
1471 gregoa 1381 - * The prototype based popup width is the prototype's width
1472     - * plus the scrollbar width - if any. The scrollbar test checks
1473     - * if there are more items than the combo's maximum row count.
1474     - *
1475 gregoa 1326 - * @param px starting x location
1476     - * @param py starting y location
1477     - * @param pw starting width
1478     - * @param ph starting height
1479     - * @return a rectangle which represents the placement and size of the popup
1480 gregoa 1381 - *
1481 gregoa 1326 - * @see Options#COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
1482     - * @see JComboBox#getMaximumRowCount()
1483     - */
1484     - protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
1485 gregoa 1381 - Rectangle defaultBounds = super.computePopupBounds(px, py, pw, ph);
1486 gregoa 1326 - Object popupPrototypeDisplayValue = comboBox.getClientProperty(
1487     - Options.COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY);
1488 gregoa 1381 - if (popupPrototypeDisplayValue == null) {
1489 gregoa 1326 - return defaultBounds;
1490     - }
1491 gregoa 1381 -
1492 gregoa 1326 - ListCellRenderer renderer = list.getCellRenderer();
1493     - Component c = renderer.getListCellRendererComponent(
1494     - list, popupPrototypeDisplayValue, -1, true, true);
1495     - pw = c.getPreferredSize().width;
1496 gregoa 1381 - boolean hasVerticalScrollBar =
1497 gregoa 1326 - comboBox.getItemCount() > comboBox.getMaximumRowCount();
1498     - if (hasVerticalScrollBar) {
1499     - // Add the scrollbar width.
1500     - JScrollBar verticalBar = scroller.getVerticalScrollBar();
1501     - pw += verticalBar.getPreferredSize().width;
1502     - }
1503     - Rectangle prototypeBasedBounds = super.computePopupBounds(px, py, pw, ph);
1504     - return prototypeBasedBounds.width > defaultBounds.width
1505     - ? prototypeBasedBounds
1506     - : defaultBounds;
1507     - }
1508     -
1509 gregoa 1381 - }
1510     -
1511     -
1512 gregoa 1326 - // Handling Combo Changes *************************************************
1513 gregoa 1381 -
1514 gregoa 1326 - /**
1515     - * Listens to changes in the table cell editor client property
1516     - * and updates the default editor - if any - to use the correct
1517     - * insets for this case.
1518     - */
1519     - private final class TableCellEditorPropertyChangeHandler implements PropertyChangeListener {
1520     - public void propertyChange(PropertyChangeEvent evt) {
1521     - tableCellEditor = isTableCellEditor();
1522     - if (comboBox.getRenderer() == null || comboBox.getRenderer() instanceof UIResource) {
1523     - comboBox.setRenderer(createRenderer());
1524     - }
1525     - if (comboBox.getEditor() == null || comboBox.getEditor() instanceof UIResource) {
1526     - comboBox.setEditor(createEditor());
1527     - }
1528     - }
1529     - }
1530     -
1531     -}
1532 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsFieldCaret.java
1533 gregoa 1326 +++ /dev/null
1534 gregoa 1381 @@ -1,367 +0,0 @@
1535 gregoa 1326 -/*
1536 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
1537 gregoa 1326 - *
1538 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
1539 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
1540 gregoa 1381 - *
1541     - * o Redistributions of source code must retain the above copyright notice,
1542     - * this list of conditions and the following disclaimer.
1543     - *
1544     - * o Redistributions in binary form must reproduce the above copyright notice,
1545     - * this list of conditions and the following disclaimer in the documentation
1546     - * and/or other materials provided with the distribution.
1547     - *
1548     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
1549     - * its contributors may be used to endorse or promote products derived
1550     - * from this software without specific prior written permission.
1551     - *
1552     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1553     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1554     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1555     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1556     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1557     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1558     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
1559     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1560     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
1561     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1562     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1563 gregoa 1326 - */
1564     -
1565     -package com.jgoodies.looks.windows;
1566     -
1567     -import java.awt.*;
1568     -import java.awt.event.FocusEvent;
1569     -import java.awt.event.MouseEvent;
1570     -
1571     -import javax.swing.BoundedRangeModel;
1572     -import javax.swing.JFormattedTextField;
1573     -import javax.swing.JTextField;
1574     -import javax.swing.SwingUtilities;
1575     -import javax.swing.plaf.TextUI;
1576     -import javax.swing.plaf.UIResource;
1577     -import javax.swing.text.*;
1578     -
1579 gregoa 1381 -import com.jgoodies.looks.Options;
1580     -
1581 gregoa 1326 -/**
1582     - * WindowsFieldCaret has different scrolling behavior than the DefaultCaret.
1583 gregoa 1381 - * Also, this caret is visible in non-editable fields,
1584 gregoa 1326 - * and the text is selected after a keyboard focus gained event.
1585     - * For the latter see also issue #4337647 in Sun's bug database.
1586 gregoa 1381 - *
1587 gregoa 1326 - * @author Karsten Lentzsch
1588 gregoa 1381 - * @version $Revision: 1.10 $
1589     - *
1590 gregoa 1326 - */
1591     -final class WindowsFieldCaret extends DefaultCaret implements UIResource {
1592     -
1593 gregoa 1381 - private static final LayeredHighlighter.LayerPainter WindowsPainter =
1594 gregoa 1326 - new WindowsHighlightPainter(null);
1595     -
1596     -
1597     - WindowsFieldCaret() {
1598     - super();
1599     - }
1600     -
1601     -
1602     - // Begin of Added Code ----------------------------------------------
1603     -
1604     - private boolean isKeyboardFocusEvent = true;
1605     -
1606     -
1607     - public void focusGained(FocusEvent e) {
1608 gregoa 1381 - final JTextComponent c = getComponent();
1609     - if (c.isEnabled()) {
1610 gregoa 1326 - setVisible(true);
1611     - setSelectionVisible(true);
1612     - }
1613 gregoa 1381 - if (!c.isEditable()) {
1614     - return;
1615     - }
1616     - if ( c.isEnabled()
1617     - && isKeyboardFocusEvent
1618     - && Options.isSelectOnFocusGainActive(c)) {
1619 gregoa 1326 - if (c instanceof JFormattedTextField) {
1620     - EventQueue.invokeLater(new Runnable() {
1621     - public void run() {
1622 gregoa 1381 - selectAll();
1623 gregoa 1326 - }
1624     - });
1625     - } else {
1626 gregoa 1381 - selectAll();
1627 gregoa 1326 - }
1628     - }
1629     - }
1630     -
1631     -
1632 gregoa 1381 - private void selectAll() {
1633     - final JTextComponent c = getComponent();
1634     - boolean backward = Boolean.TRUE.equals(c.getClientProperty(Options.INVERT_SELECTION_CLIENT_KEY));
1635     - if (backward) {
1636     - setDot(c.getDocument().getLength());
1637     - moveDot(0);
1638     - } else {
1639     - setDot(0);
1640     - moveDot(c.getDocument().getLength());
1641     - }
1642     - }
1643     -
1644     -
1645 gregoa 1326 - public void focusLost(FocusEvent e) {
1646     - super.focusLost(e);
1647     - if (!e.isTemporary()) {
1648     - isKeyboardFocusEvent = true;
1649 gregoa 1381 - if (Boolean.TRUE.equals(getComponent().getClientProperty(Options.SET_CARET_TO_START_ON_FOCUS_LOST_CLIENT_KEY))) {
1650     - setDot(0);
1651     - }
1652 gregoa 1326 - }
1653     - }
1654     -
1655     -
1656     - public void mousePressed(MouseEvent e) {
1657     - if (SwingUtilities.isLeftMouseButton(e) || e.isPopupTrigger()) {
1658     - isKeyboardFocusEvent = false;
1659     - }
1660     - super.mousePressed(e);
1661     -
1662     - }
1663     -
1664     -
1665     - public void mouseReleased(MouseEvent e) {
1666     - super.mouseReleased(e);
1667 gregoa 1381 - // super.mousePressed() does not transfer focus on popup clicks.
1668 gregoa 1326 - // Windows does.
1669     - if (e.isPopupTrigger()) {
1670     - isKeyboardFocusEvent = false;
1671     - if ((getComponent() != null) && getComponent().isEnabled()
1672     - && getComponent().isRequestFocusEnabled()) {
1673     - getComponent().requestFocus();
1674     - }
1675     - }
1676     - }
1677     -
1678     - // End of Added Code ------------------------------------------------
1679     -
1680     - /**
1681     - * Adjusts the visibility of the caret according to
1682     - * the windows feel which seems to be to move the
1683     - * caret out into the field by about a quarter of
1684     - * a field length if not visible.
1685     - */
1686     - protected void adjustVisibility(Rectangle r) {
1687     - SwingUtilities.invokeLater(new SafeScroller(r));
1688     - }
1689     -
1690     -
1691     - /**
1692     - * Gets the painter for the Highlighter.
1693     - *
1694     - * @return the painter
1695     - */
1696     - protected Highlighter.HighlightPainter getSelectionPainter() {
1697     - return WindowsPainter;
1698     - }
1699     -
1700     -
1701     - private final class SafeScroller implements Runnable {
1702     -
1703     - SafeScroller(Rectangle r) {
1704     - this.r = r;
1705     - }
1706     -
1707     -
1708     - public void run() {
1709     - JTextField field = (JTextField) getComponent();
1710     - if (field != null) {
1711     - TextUI ui = field.getUI();
1712     - int dot = getDot();
1713     - // PENDING: We need to expose the bias in DefaultCaret.
1714     - Position.Bias bias = Position.Bias.Forward;
1715     - Rectangle startRect = null;
1716     - try {
1717     - startRect = ui.modelToView(field, dot, bias);
1718     - } catch (BadLocationException ble) {}
1719     -
1720     - Insets i = field.getInsets();
1721     - BoundedRangeModel vis = field.getHorizontalVisibility();
1722     - int x = r.x + vis.getValue() - i.left;
1723     - int quarterSpan = vis.getExtent() / 4;
1724     - if (r.x < i.left) {
1725     - vis.setValue(x - quarterSpan);
1726     - } else if (r.x + r.width > i.left + vis.getExtent()) {
1727     - vis.setValue(x - (3 * quarterSpan));
1728     - }
1729     - // If we scroll, our visual location will have changed,
1730     - // but we won't have updated our internal location as
1731     - // the model hasn't changed. This checks for the change,
1732     - // and if necessary, resets the internal location.
1733     - if (startRect != null) {
1734     - try {
1735     - Rectangle endRect;
1736     - endRect = ui.modelToView(field, dot, bias);
1737     - if (endRect != null && !endRect.equals(startRect)){
1738     - damage(endRect);
1739     - }
1740     - } catch (BadLocationException ble) {}
1741     - }
1742     - }
1743     - }
1744     -
1745 gregoa 1381 - private final Rectangle r;
1746 gregoa 1326 - }
1747 gregoa 1381 -
1748 gregoa 1326 - // Helper Classes *********************************************************
1749 gregoa 1381 -
1750 gregoa 1326 - private static final class WindowsHighlightPainter extends
1751     - DefaultHighlighter.DefaultHighlightPainter {
1752     - WindowsHighlightPainter(Color c) {
1753     - super(c);
1754     - }
1755     -
1756     -
1757     - // --- HighlightPainter methods ---------------------------------------
1758     -
1759     - /**
1760     - * Paints a highlight.
1761     - *
1762     - * @param g the graphics context
1763     - * @param offs0 the starting model offset >= 0
1764     - * @param offs1 the ending model offset >= offs1
1765     - * @param bounds the bounding box for the highlight
1766     - * @param c the editor
1767     - */
1768     - public void paint(Graphics g, int offs0, int offs1, Shape bounds,
1769     - JTextComponent c) {
1770     - Rectangle alloc = bounds.getBounds();
1771     - try {
1772     - // --- determine locations ---
1773     - TextUI mapper = c.getUI();
1774     - Rectangle p0 = mapper.modelToView(c, offs0);
1775     - Rectangle p1 = mapper.modelToView(c, offs1);
1776     -
1777     - // --- render ---
1778     - Color color = getColor();
1779     -
1780     - if (color == null) {
1781     - g.setColor(c.getSelectionColor());
1782     - } else {
1783     - g.setColor(color);
1784     - }
1785     - boolean firstIsDot = false;
1786     - boolean secondIsDot = false;
1787     - if (c.isEditable()) {
1788     - int dot = c.getCaretPosition();
1789     - firstIsDot = (offs0 == dot);
1790     - secondIsDot = (offs1 == dot);
1791     - }
1792     - if (p0.y == p1.y) {
1793     - // same line, render a rectangle
1794     - Rectangle r = p0.union(p1);
1795     - if (r.width > 0) {
1796     - if (firstIsDot) {
1797     - r.x++;
1798     - r.width--;
1799     - } else if (secondIsDot) {
1800     - r.width--;
1801     - }
1802     - }
1803     - g.fillRect(r.x, r.y, r.width, r.height);
1804     - } else {
1805     - // different lines
1806     - int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
1807     - if (firstIsDot && p0ToMarginWidth > 0) {
1808     - p0.x++;
1809     - p0ToMarginWidth--;
1810     - }
1811     - g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
1812     - if ((p0.y + p0.height) != p1.y) {
1813     - g.fillRect(alloc.x, p0.y + p0.height, alloc.width, p1.y
1814     - - (p0.y + p0.height));
1815     - }
1816     - if (secondIsDot && p1.x > alloc.x) {
1817     - p1.x--;
1818     - }
1819     - g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
1820     - }
1821     - } catch (BadLocationException e) {
1822     - // can't render
1823     - }
1824     - }
1825     -
1826     -
1827     - // --- LayerPainter methods ----------------------------
1828     - /**
1829     - * Paints a portion of a highlight.
1830     - *
1831     - * @param g the graphics context
1832     - * @param offs0 the starting model offset >= 0
1833     - * @param offs1 the ending model offset >= offs1
1834     - * @param bounds the bounding box of the view, which is not
1835     - * necessarily the region to paint.
1836     - * @param c the editor
1837     - * @param view View painting for
1838     - * @return region drawing occured in
1839     - */
1840     - public Shape paintLayer(Graphics g, int offs0, int offs1, Shape bounds,
1841     - JTextComponent c, View view) {
1842     - Color color = getColor();
1843     -
1844     - if (color == null) {
1845     - g.setColor(c.getSelectionColor());
1846     - } else {
1847     - g.setColor(color);
1848     - }
1849     - boolean firstIsDot = false;
1850     - boolean secondIsDot = false;
1851     - if (c.isEditable()) {
1852     - int dot = c.getCaretPosition();
1853     - firstIsDot = (offs0 == dot);
1854     - secondIsDot = (offs1 == dot);
1855     - }
1856     - if (offs0 == view.getStartOffset() && offs1 == view.getEndOffset()) {
1857     - // Contained in view, can just use bounds.
1858     - Rectangle alloc;
1859     - if (bounds instanceof Rectangle) {
1860     - alloc = (Rectangle) bounds;
1861     - } else {
1862     - alloc = bounds.getBounds();
1863     - }
1864     - if (firstIsDot && alloc.width > 0) {
1865     - g.fillRect(alloc.x + 1, alloc.y, alloc.width - 1,
1866     - alloc.height);
1867     - } else if (secondIsDot && alloc.width > 0) {
1868     - g.fillRect(alloc.x, alloc.y, alloc.width - 1, alloc.height);
1869     - } else {
1870     - g.fillRect(alloc.x, alloc.y, alloc.width, alloc.height);
1871     - }
1872     - return alloc;
1873     - } else {
1874     - // Should only render part of View.
1875     - try {
1876     - // --- determine locations ---
1877     - Shape shape = view.modelToView(offs0,
1878     - Position.Bias.Forward, offs1,
1879     - Position.Bias.Backward, bounds);
1880     - Rectangle r = (shape instanceof Rectangle)
1881     - ? (Rectangle) shape
1882     - : shape.getBounds();
1883     - if (firstIsDot && r.width > 0) {
1884     - g.fillRect(r.x + 1, r.y, r.width - 1, r.height);
1885     - } else if (secondIsDot && r.width > 0) {
1886     - g.fillRect(r.x, r.y, r.width - 1, r.height);
1887     - } else {
1888     - g.fillRect(r.x, r.y, r.width, r.height);
1889     - }
1890     - return r;
1891     - } catch (BadLocationException e) {
1892     - // can't render
1893     - }
1894     - }
1895     - // Only if exception
1896     - return null;
1897     - }
1898     -
1899     - }
1900     -
1901     -}
1902 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsFormattedTextFieldUI.java
1903 gregoa 1326 +++ /dev/null
1904     @@ -1,68 +0,0 @@
1905     -/*
1906 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
1907 gregoa 1326 - *
1908 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
1909 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
1910 gregoa 1381 - *
1911     - * o Redistributions of source code must retain the above copyright notice,
1912     - * this list of conditions and the following disclaimer.
1913     - *
1914     - * o Redistributions in binary form must reproduce the above copyright notice,
1915     - * this list of conditions and the following disclaimer in the documentation
1916     - * and/or other materials provided with the distribution.
1917     - *
1918     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
1919     - * its contributors may be used to endorse or promote products derived
1920     - * from this software without specific prior written permission.
1921     - *
1922     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1923     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1924     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1925     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1926     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1927     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1928     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
1929     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1930     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
1931     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1932     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1933 gregoa 1326 - */
1934     -
1935     -package com.jgoodies.looks.windows;
1936     -
1937     -import javax.swing.JComponent;
1938     -import javax.swing.plaf.ComponentUI;
1939     -import javax.swing.plaf.basic.BasicFormattedTextFieldUI;
1940     -import javax.swing.text.Caret;
1941     -
1942     -/**
1943     - * The JGoodies Windows L&amp;F implementation of <code>FormattedTextFieldUI</code>.
1944 gregoa 1381 - * It uses a caret that selects all text if the field gains focus
1945 gregoa 1326 - * after a keyboard focus traversal.
1946 gregoa 1381 - *
1947 gregoa 1326 - * @author Karsten Lentzsch
1948 gregoa 1381 - * @version $Revision: 1.4 $
1949 gregoa 1326 - */
1950     -public final class WindowsFormattedTextFieldUI extends BasicFormattedTextFieldUI {
1951 gregoa 1381 -
1952 gregoa 1326 - /**
1953     - * Creates a UI for a JFormattedTextField.
1954     - *
1955     - * @param c the formatted text field
1956     - * @return the UI
1957     - */
1958     - public static ComponentUI createUI(JComponent c) {
1959     - return new WindowsFormattedTextFieldUI();
1960     - }
1961     -
1962     -
1963     - /**
1964     - * Creates the caret for a field.
1965     - *
1966     - * @return the caret
1967     - */
1968     - protected Caret createCaret() {
1969     - return new WindowsFieldCaret();
1970     - }
1971     -
1972     -}
1973 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsIconFactory.java
1974 gregoa 1326 +++ /dev/null
1975 gregoa 1381 @@ -1,215 +0,0 @@
1976 gregoa 1326 -/*
1977 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
1978 gregoa 1326 - *
1979 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
1980 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
1981 gregoa 1381 - *
1982     - * o Redistributions of source code must retain the above copyright notice,
1983     - * this list of conditions and the following disclaimer.
1984     - *
1985     - * o Redistributions in binary form must reproduce the above copyright notice,
1986     - * this list of conditions and the following disclaimer in the documentation
1987     - * and/or other materials provided with the distribution.
1988     - *
1989     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
1990     - * its contributors may be used to endorse or promote products derived
1991     - * from this software without specific prior written permission.
1992     - *
1993     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1994     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1995     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1996     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1997     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1998     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1999     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2000     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2001     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2002     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2003     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2004 gregoa 1326 - */
2005     -
2006     -package com.jgoodies.looks.windows;
2007     -
2008     -import java.awt.Component;
2009     -import java.awt.Graphics;
2010     -import java.io.Serializable;
2011     -
2012 gregoa 1381 -import javax.swing.*;
2013 gregoa 1326 -import javax.swing.plaf.UIResource;
2014     -
2015     -/**
2016     - * Factory class that vends <code>Icon</code>s used in the JGoodies Windows look&amp;feel.
2017     - *
2018     - * @author Karsten Lentzsch
2019 gregoa 1381 - * @version $Revision: 1.5 $
2020 gregoa 1326 - */
2021     -final class WindowsIconFactory {
2022     -
2023     - private WindowsIconFactory() {
2024     - // Overrides default constructor; prevents instantiation.
2025     - }
2026 gregoa 1381 -
2027 gregoa 1326 - // Accessing and Creating Icons *****************************************************
2028     -
2029     - private static Icon checkBoxIcon;
2030     - private static Icon radioButtonIcon;
2031     -
2032     -
2033     - /**
2034     - * Returns an <code>Icon</code> for a <code>JCheckBox</code>.
2035     - */
2036     - static Icon getCheckBoxIcon() {
2037     - if (checkBoxIcon == null) {
2038     - checkBoxIcon = new CheckBoxIcon();
2039     - }
2040     - return checkBoxIcon;
2041     - }
2042     -
2043     -
2044     - /**
2045     - * Returns an <code>Icon</code> for a <code>JCheckBox</code>.
2046     - */
2047     - static Icon getRadioButtonIcon() {
2048     - if (radioButtonIcon == null) {
2049     - radioButtonIcon = new RadioButtonIcon();
2050     - }
2051     - return radioButtonIcon;
2052     - }
2053     -
2054     -
2055     - // Helper Classes *******************************************************************
2056 gregoa 1381 -
2057 gregoa 1326 - // Paints the icon for a check box.
2058     - private static class CheckBoxIcon implements Icon, Serializable {
2059 gregoa 1381 -
2060 gregoa 1326 - private static final int SIZE = 13;
2061 gregoa 1381 -
2062 gregoa 1326 - public void paintIcon(Component c, Graphics g, int x, int y) {
2063     - JCheckBox cb = (JCheckBox) c;
2064     - ButtonModel model = cb.getModel();
2065 gregoa 1381 -
2066 gregoa 1326 - // outer bevel
2067     - if (!cb.isBorderPaintedFlat()) {
2068     - // Outer top/left
2069     - g.setColor(UIManager.getColor("CheckBox.shadow"));
2070     - g.drawLine(x, y, x+11, y);
2071     - g.drawLine(x, y+1, x, y+11);
2072 gregoa 1381 -
2073 gregoa 1326 - // Outer bottom/right
2074     - g.setColor(UIManager.getColor("CheckBox.highlight"));
2075     - g.drawLine(x+12, y, x+12, y+12);
2076     - g.drawLine(x, y+12, x+11, y+12);
2077 gregoa 1381 -
2078 gregoa 1326 - // Inner top.left
2079     - g.setColor(UIManager.getColor("CheckBox.darkShadow"));
2080     - g.drawLine(x+1, y+1, x+10, y+1);
2081     - g.drawLine(x+1, y+2, x+1, y+10);
2082 gregoa 1381 -
2083 gregoa 1326 - // Inner bottom/right
2084     - g.setColor(UIManager.getColor("CheckBox.light"));
2085     - g.drawLine(x+1, y+11, x+11, y+11);
2086     - g.drawLine(x+11, y+1, x+11, y+10);
2087     - } else {
2088     - g.setColor(UIManager.getColor("CheckBox.shadow"));
2089     - g.drawRect(x+1, y+1, SIZE-3, SIZE-3);
2090     - }
2091 gregoa 1381 - // inside box
2092 gregoa 1326 - g.setColor(UIManager.getColor(
2093     - (model.isPressed() && model.isArmed()) || !model.isEnabled()
2094     - ? "CheckBox.background"
2095     - : "CheckBox.interiorBackground"));
2096     - g.fillRect(x+2, y+2, SIZE-4, SIZE-4);
2097 gregoa 1381 -
2098 gregoa 1326 - g.setColor(UIManager.getColor(model.isEnabled()
2099     - ? "CheckBox.checkColor" // Modified by JGoodies
2100     - : "CheckBox.shadow"));
2101 gregoa 1381 -
2102 gregoa 1326 - // paint check
2103     - if (model.isSelected()) {
2104     - g.drawLine(x+9, y+3, x+9, y+3);
2105     - g.drawLine(x+8, y+4, x+9, y+4);
2106     - g.drawLine(x+7, y+5, x+9, y+5);
2107     - g.drawLine(x+6, y+6, x+8, y+6);
2108     - g.drawLine(x+3, y+7, x+7, y+7);
2109     - g.drawLine(x+4, y+8, x+6, y+8);
2110     - g.drawLine(x+5, y+9, x+5, y+9);
2111     - g.drawLine(x+3, y+5, x+3, y+5);
2112     - g.drawLine(x+3, y+6, x+4, y+6);
2113     - }
2114     - }
2115 gregoa 1381 -
2116 gregoa 1326 - public int getIconWidth() { return SIZE; }
2117     - public int getIconHeight() { return SIZE; }
2118     - }
2119     -
2120 gregoa 1381 -
2121 gregoa 1326 - // Paints the icon for a radio button.
2122     - private static class RadioButtonIcon implements Icon, UIResource, Serializable {
2123 gregoa 1381 -
2124 gregoa 1326 - private static final int SIZE = 13;
2125     -
2126     - public void paintIcon(Component c, Graphics g, int x, int y) {
2127     - AbstractButton b = (AbstractButton) c;
2128     - ButtonModel model = b.getModel();
2129 gregoa 1381 -
2130 gregoa 1326 - // fill interior
2131     - g.setColor(UIManager.getColor(
2132     - (model.isPressed() && model.isArmed()) || !model.isEnabled()
2133     - ? "RadioButton.background"
2134     - : "RadioButton.interiorBackground"));
2135     - g.fillRect(x+2, y+2, 8, 8);
2136 gregoa 1381 -
2137     -
2138 gregoa 1326 - // outter left arc
2139     - g.setColor(UIManager.getColor("RadioButton.shadow"));
2140     - g.drawLine(x+4, y+0, x+7, y+0);
2141     - g.drawLine(x+2, y+1, x+3, y+1);
2142     - g.drawLine(x+8, y+1, x+9, y+1);
2143     - g.drawLine(x+1, y+2, x+1, y+3);
2144     - g.drawLine(x+0, y+4, x+0, y+7);
2145     - g.drawLine(x+1, y+8, x+1, y+9);
2146 gregoa 1381 -
2147 gregoa 1326 - // outter right arc
2148     - g.setColor(UIManager.getColor("RadioButton.highlight"));
2149     - g.drawLine(x+2, y+10, x+3, y+10);
2150     - g.drawLine(x+4, y+11, x+7, y+11);
2151     - g.drawLine(x+8, y+10, x+9, y+10);
2152     - g.drawLine(x+10, y+9, x+10, y+8);
2153     - g.drawLine(x+11, y+7, x+11, y+4);
2154     - g.drawLine(x+10, y+3, x+10, y+2);
2155 gregoa 1381 -
2156     -
2157 gregoa 1326 - // inner left arc
2158     - g.setColor(UIManager.getColor("RadioButton.darkShadow"));
2159     - g.drawLine(x+4, y+1, x+7, y+1);
2160     - g.drawLine(x+2, y+2, x+3, y+2);
2161     - g.drawLine(x+8, y+2, x+9, y+2);
2162     - g.drawLine(x+2, y+3, x+2, y+3);
2163     - g.drawLine(x+1, y+4, x+1, y+7);
2164     - g.drawLine(x+2, y+8, x+2, y+8);
2165 gregoa 1381 -
2166     -
2167 gregoa 1326 - // inner right arc
2168     - g.setColor(UIManager.getColor("RadioButton.light"));
2169     - g.drawLine(x+2, y+9, x+3, y+9);
2170     - g.drawLine(x+4, y+10, x+7, y+10);
2171     - g.drawLine(x+8, y+9, x+9, y+9);
2172     - g.drawLine(x+9, y+8, x+9, y+8);
2173     - g.drawLine(x+10, y+7, x+10, y+4);
2174     - g.drawLine(x+9, y+3, x+9, y+3);
2175 gregoa 1381 -
2176     -
2177 gregoa 1326 - // indicate whether selected or not
2178     - if(model.isSelected()) {
2179     - g.setColor(UIManager.getColor("RadioButton.checkColor")); // Modified by JGoodies
2180     - g.fillRect(x+4, y+5, 4, 2);
2181     - g.fillRect(x+5, y+4, 2, 4);
2182 gregoa 1381 - }
2183 gregoa 1326 - }
2184 gregoa 1381 -
2185 gregoa 1326 - public int getIconWidth() { return SIZE; }
2186     - public int getIconHeight() { return SIZE; }
2187 gregoa 1381 -
2188 gregoa 1326 - }
2189 gregoa 1381 -
2190 gregoa 1326 -}
2191     \ No newline at end of file
2192 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsLookAndFeel.java
2193 gregoa 1326 +++ /dev/null
2194 gregoa 1381 @@ -1,759 +0,0 @@
2195 gregoa 1326 -/*
2196 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
2197 gregoa 1326 - *
2198 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
2199 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
2200 gregoa 1381 - *
2201     - * o Redistributions of source code must retain the above copyright notice,
2202     - * this list of conditions and the following disclaimer.
2203     - *
2204     - * o Redistributions in binary form must reproduce the above copyright notice,
2205     - * this list of conditions and the following disclaimer in the documentation
2206     - * and/or other materials provided with the distribution.
2207     - *
2208     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
2209     - * its contributors may be used to endorse or promote products derived
2210     - * from this software without specific prior written permission.
2211     - *
2212     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2213     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2214     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2215     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2216     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2217     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2218     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2219     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2220     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2221     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2222     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2223 gregoa 1326 - */
2224     -
2225     -package com.jgoodies.looks.windows;
2226     -
2227     -import java.awt.Color;
2228     -import java.awt.Font;
2229     -import java.awt.Insets;
2230     -import java.lang.reflect.Method;
2231     -
2232 gregoa 1381 -import javax.swing.*;
2233 gregoa 1326 -import javax.swing.border.Border;
2234     -import javax.swing.border.EmptyBorder;
2235     -import javax.swing.plaf.DimensionUIResource;
2236     -import javax.swing.plaf.IconUIResource;
2237     -import javax.swing.plaf.InsetsUIResource;
2238     -import javax.swing.plaf.basic.BasicBorders;
2239     -
2240     -import com.jgoodies.looks.*;
2241     -import com.jgoodies.looks.common.MinimumSizedIcon;
2242     -import com.jgoodies.looks.common.RGBGrayFilter;
2243     -import com.jgoodies.looks.common.ShadowPopupFactory;
2244     -
2245     -/**
2246     - * The main class of the JGoodies Windows Look&amp;Feel.
2247     - * This look provides several corrections and extensions to Sun's Windows L&F.
2248     - * In addition it tries to provide a unified look for the J2SE 1.4.0x, 1.4.1x,
2249     - * 1.4.2, and 1.5 environments.
2250 gregoa 1381 - *
2251 gregoa 1326 - * @author Karsten Lentzsch
2252 gregoa 1381 - * @version $Revision: 1.39 $
2253 gregoa 1326 - */
2254     -public final class WindowsLookAndFeel extends com.sun.java.swing.plaf.windows.WindowsLookAndFeel {
2255     -
2256 gregoa 1381 - /**
2257 gregoa 1326 - * An optional client property key for JMenu and JToolBar
2258 gregoa 1381 - * to set a border style - shadows the header style.
2259 gregoa 1326 - */
2260     - public static final String BORDER_STYLE_KEY = "jgoodies.windows.borderStyle";
2261     -
2262 gregoa 1381 -
2263     - /**
2264     - * Returns the String &quot;JGoodies Windows&quot;.
2265     - * Note that this L&amp;f's ID (&quot;Windows&quot;) is inherited
2266     - * from the superclass, because we don't do any fundamental changes.
2267     - *
2268     - * @see LookAndFeel#getID()
2269     - */
2270 gregoa 1326 - public String getName() {
2271     - return "JGoodies Windows";
2272     - }
2273     -
2274 gregoa 1381 -
2275 gregoa 1326 - public String getDescription() {
2276     - return "The JGoodies Windows Look and Feel"
2277 gregoa 1381 - + " - \u00a9 2001-2008 JGoodies Karsten Lentzsch";
2278 gregoa 1326 - }
2279 gregoa 1381 -
2280     -
2281 gregoa 1326 - // Optional Settings ******************************************************
2282 gregoa 1381 -
2283 gregoa 1326 - /**
2284 gregoa 1381 - * Looks up and retrieves the FontPolicy used by
2285     - * the JGoodies Windows Look&amp;Feel.
2286 gregoa 1326 - * If a FontPolicy has been set for this look, it'll be returned.
2287 gregoa 1381 - * Otherwise, this method checks if a FontPolicy or FontSet is defined
2288 gregoa 1326 - * in the system properties or UIDefaults. If so, it is returned.
2289     - * If no FontPolicy has been set for this look, in the system
2290 gregoa 1381 - * properties or UIDefaults, the default Windows font policy
2291 gregoa 1326 - * will be returned.
2292 gregoa 1381 - *
2293 gregoa 1326 - * @return the FontPolicy set for this Look&amp;feel - if any,
2294     - * the FontPolicy specified in the system properties or UIDefaults
2295 gregoa 1381 - * - if any, or the default Windows font policy.
2296     - *
2297 gregoa 1326 - * @see #setFontPolicy
2298     - * @see Options#WINDOWS_FONT_POLICY_KEY
2299     - * @see FontPolicies
2300     - * @see FontPolicies#customSettingsPolicy(FontPolicy)
2301     - * @see FontPolicies#getDefaultWindowsPolicy()
2302     - */
2303     - public static FontPolicy getFontPolicy() {
2304 gregoa 1381 - FontPolicy policy =
2305 gregoa 1326 - (FontPolicy) UIManager.get(Options.WINDOWS_FONT_POLICY_KEY);
2306     - if (policy != null)
2307     - return policy;
2308 gregoa 1381 -
2309 gregoa 1326 - FontPolicy defaultPolicy = FontPolicies.getDefaultWindowsPolicy();
2310     - return FontPolicies.customSettingsPolicy(defaultPolicy);
2311     - }
2312 gregoa 1381 -
2313     -
2314 gregoa 1326 - /**
2315     - * Sets the FontPolicy to be used with the JGoodies Windows L&amp;F.
2316     - * If the specified policy is <code>null</code>, the default will be reset.
2317 gregoa 1381 - *
2318     - * @param fontPolicy the FontPolicy to be used with the JGoodies Windows
2319 gregoa 1326 - * L&amp;F, or <code>null</code> to reset to the default
2320 gregoa 1381 - *
2321 gregoa 1326 - * @see #getFontPolicy()
2322     - * @see Options#WINDOWS_FONT_POLICY_KEY
2323     - */
2324     - public static void setFontPolicy(FontPolicy fontPolicy) {
2325     - UIManager.put(Options.WINDOWS_FONT_POLICY_KEY, fontPolicy);
2326     - }
2327     -
2328 gregoa 1381 -
2329 gregoa 1326 - /**
2330 gregoa 1381 - * Looks up and retrieves the MicroLayoutPolicy used by
2331     - * the JGoodies Windows Look&amp;Feel.
2332 gregoa 1326 - * If a MicroLayoutPolicy has been set for this look, it'll be returned.
2333     - * Otherwise, the default Windows micro layout policy will be returned.
2334 gregoa 1381 - *
2335 gregoa 1326 - * @return the MicroLayoutPolicy set for this Look&amp;feel - if any,
2336 gregoa 1381 - * or the default Windows MicroLayoutPolicy.
2337     - *
2338 gregoa 1326 - * @see #setMicroLayoutPolicy
2339     - * @see Options#WINDOWS_MICRO_LAYOUT_POLICY_KEY
2340     - * @see MicroLayoutPolicies
2341     - * @see MicroLayoutPolicies#getDefaultWindowsPolicy()
2342     - */
2343     - public static MicroLayoutPolicy getMicroLayoutPolicy() {
2344 gregoa 1381 - MicroLayoutPolicy policy =
2345 gregoa 1326 - (MicroLayoutPolicy) UIManager.get(Options.WINDOWS_MICRO_LAYOUT_POLICY_KEY);
2346     - return policy != null
2347     - ? policy
2348     - : MicroLayoutPolicies.getDefaultWindowsPolicy();
2349     - }
2350 gregoa 1381 -
2351     -
2352 gregoa 1326 - /**
2353     - * Sets the MicroLayoutPolicy to be used with the JGoodies Windows L&amp;F.
2354     - * If the specified policy is <code>null</code>, the default will be reset.
2355 gregoa 1381 - *
2356     - * @param microLayoutPolicy the MicroLayoutPolicy to be used with
2357     - * the JGoodies Windows L&amp;F, or <code>null</code> to reset
2358 gregoa 1326 - * to the default
2359 gregoa 1381 - *
2360 gregoa 1326 - * @see #getMicroLayoutPolicy()
2361     - * @see Options#WINDOWS_MICRO_LAYOUT_POLICY_KEY
2362     - */
2363     - public static void setMicroLayoutPolicy(MicroLayout microLayoutPolicy) {
2364     - UIManager.put(Options.WINDOWS_MICRO_LAYOUT_POLICY_KEY, microLayoutPolicy);
2365     - }
2366     -
2367 gregoa 1381 -
2368 gregoa 1326 - // Overriding Superclass Behavior ***************************************
2369     -
2370     - /**
2371 gregoa 1381 - * Invoked during <code>UIManager#setLookAndFeel</code>. In addition
2372 gregoa 1326 - * to the superclass behavior, we install the ShadowPopupFactory.
2373 gregoa 1381 - *
2374 gregoa 1326 - * @see #uninitialize
2375     - */
2376     - public void initialize() {
2377     - super.initialize();
2378     - ShadowPopupFactory.install();
2379     - }
2380 gregoa 1381 -
2381     -
2382 gregoa 1326 - /**
2383 gregoa 1381 - * Invoked during <code>UIManager#setLookAndFeel</code>. In addition
2384 gregoa 1326 - * to the superclass behavior, we uninstall the ShadowPopupFactory.
2385 gregoa 1381 - *
2386 gregoa 1326 - * @see #initialize
2387     - */
2388     - public void uninitialize() {
2389     - super.uninitialize();
2390     - ShadowPopupFactory.uninstall();
2391     - }
2392     -
2393     -
2394     - /**
2395     - * Returns an icon with a disabled appearance. This method is used
2396     - * to generate a disabled icon when one has not been specified.<p>
2397 gregoa 1381 - *
2398 gregoa 1326 - * This method will be used only on JDK 5.0 and later.
2399     - *
2400     - * @param component the component that will display the icon, may be null.
2401     - * @param icon the icon to generate disabled icon from.
2402     - * @return disabled icon, or null if a suitable icon can not be generated.
2403     - */
2404     - public Icon getDisabledIcon(JComponent component, Icon icon) {
2405     - Icon disabledIcon = RGBGrayFilter.getDisabledIcon(component, icon);
2406     - return disabledIcon != null
2407     - ? new IconUIResource(disabledIcon)
2408     - : null;
2409     - }
2410     -
2411     -
2412     - /**
2413     - * Initializes the class defaults, that is, overrides some UI delegates
2414     - * with JGoodies Windows implementations.
2415     - */
2416     - protected void initClassDefaults(UIDefaults table) {
2417     - super.initClassDefaults(table);
2418     - final String windowsPrefix = "com.jgoodies.looks.windows.Windows";
2419     - final String commonPrefix = "com.jgoodies.looks.common.ExtBasic";
2420     -
2421     - // Overwrite some of the uiDefaults.
2422     - Object[] uiDefaults = {
2423 gregoa 1381 - // Modified size
2424     - "ComboBoxUI", windowsPrefix + "ComboBoxUI",
2425 gregoa 1326 -
2426 gregoa 1381 - // Modified preferred height: can be even or odd
2427     - "ButtonUI", windowsPrefix + "ButtonUI",
2428 gregoa 1326 -
2429     - // Can installs an optional etched border
2430 gregoa 1381 - "ScrollPaneUI", windowsPrefix + "ScrollPaneUI",
2431 gregoa 1326 -
2432     - // Optional style and optional special borders
2433 gregoa 1381 - "MenuBarUI", windowsPrefix + "MenuBarUI",
2434 gregoa 1326 -
2435 gregoa 1381 - // Provides an option for a no margin border
2436 gregoa 1326 - "PopupMenuUI", windowsPrefix + "PopupMenuUI",
2437     -
2438 gregoa 1381 - // Honors the screen resolution and uses a minimum button width
2439     - "OptionPaneUI", windowsPrefix + "OptionPaneUI",
2440     -
2441 gregoa 1326 - // 1.4.1 has ugly one touch triangles
2442 gregoa 1381 - "SplitPaneUI", windowsPrefix + "SplitPaneUI",
2443 gregoa 1326 -
2444     - // Work in progress: Can have a flat presentation
2445 gregoa 1381 - "TabbedPaneUI", windowsPrefix + "TabbedPaneUI",
2446     -
2447 gregoa 1326 - // Selects text after focus gained via keyboard
2448     - "TextFieldUI", windowsPrefix + "TextFieldUI",
2449     - "FormattedTextFieldUI", windowsPrefix + "FormattedTextFieldUI",
2450     -
2451     - // Selects text after focus gained via keyboard
2452 gregoa 1381 - // Renders a dot, not the star ("*") character on Java 1.4 and 5
2453     - "PasswordFieldUI", windowsPrefix + "PasswordFieldUI",
2454 gregoa 1326 -
2455 gregoa 1381 -
2456 gregoa 1326 - // Updates the disabled and inactive background
2457     - "TextAreaUI", windowsPrefix + "TextAreaUI",
2458     -
2459     - // Corrected position of the tree button icon
2460     - "TreeUI", windowsPrefix + "TreeUI",
2461 gregoa 1381 -
2462 gregoa 1326 - // Just to use shared UI delegate
2463     - "SeparatorUI", windowsPrefix + "SeparatorUI"};
2464     -
2465     - if (LookUtils.IS_JAVA_1_4_2_OR_LATER) {
2466     - // Modified Border
2467 gregoa 1381 - uiDefaults = append(uiDefaults,
2468     - "SpinnerUI", windowsPrefix + "SpinnerUI");
2469 gregoa 1326 - }
2470     -
2471     - // Aligned menu items
2472 gregoa 1381 - if ( !LookUtils.IS_JAVA_6_OR_LATER
2473     - || !LookUtils.IS_OS_WINDOWS_VISTA
2474 gregoa 1326 - || !LookUtils.IS_LAF_WINDOWS_XP_ENABLED) {
2475 gregoa 1381 - uiDefaults = append(uiDefaults,
2476 gregoa 1326 - "MenuItemUI", windowsPrefix + "MenuItemUI");
2477 gregoa 1381 - uiDefaults = append(uiDefaults,
2478 gregoa 1326 - "CheckBoxMenuItemUI", commonPrefix + "CheckBoxMenuItemUI");
2479 gregoa 1381 - uiDefaults = append(uiDefaults,
2480 gregoa 1326 - "RadioButtonMenuItemUI", commonPrefix + "RadioButtonMenuItemUI");
2481 gregoa 1381 - // Has padding above and below the separator lines
2482     - uiDefaults = append(uiDefaults,
2483     - "PopupMenuSeparatorUI", commonPrefix + "PopupMenuSeparatorUI");
2484 gregoa 1326 - }
2485 gregoa 1381 -
2486 gregoa 1326 - if (LookUtils.IS_LAF_WINDOWS_XP_ENABLED) {
2487     - // Aligned menu items
2488     - if (!LookUtils.IS_JAVA_6_OR_LATER || !LookUtils.IS_OS_WINDOWS_VISTA) {
2489     - uiDefaults = append(uiDefaults,
2490     - "MenuUI", windowsPrefix + "XPMenuUI");
2491     - }
2492 gregoa 1381 -
2493     - // Optional style and optional special borders;
2494 gregoa 1326 - // rollover borders for compound buttons
2495 gregoa 1381 - uiDefaults = append(uiDefaults,
2496 gregoa 1326 - "ToolBarUI", windowsPrefix + "XPToolBarUI");
2497 gregoa 1381 -
2498     - // Honors XP table header style for custom user renderers.
2499 gregoa 1326 - uiDefaults = append(uiDefaults,
2500 gregoa 1381 - "TableHeaderUI", windowsPrefix + "XPTableHeaderUI");
2501 gregoa 1326 - } else {
2502     - // Aligned menu items
2503     - uiDefaults = append(uiDefaults,
2504     - "MenuUI", commonPrefix + "MenuUI");
2505 gregoa 1381 -
2506     - // Optional style and optional special borders;
2507 gregoa 1326 - // rollover borders corrected
2508 gregoa 1381 - uiDefaults = append(uiDefaults,
2509     - "ToolBarUI", windowsPrefix + "ToolBarUI");
2510 gregoa 1326 -
2511     - // Black arrows
2512 gregoa 1381 - uiDefaults = append(uiDefaults,
2513     - "ScrollBarUI", windowsPrefix + "ScrollBarUI");
2514 gregoa 1326 -
2515     - if (!LookUtils.IS_JAVA_1_4_2_OR_LATER) {
2516     - // Uses unmodified size specified by "ToolBar.separatorSize"
2517 gregoa 1381 - uiDefaults = append(uiDefaults,
2518 gregoa 1326 - "ToolBarSeparatorUI", windowsPrefix + "ToolBarSeparatorUI");
2519     - }
2520     - }
2521     - table.putDefaults(uiDefaults);
2522     - }
2523     -
2524     - /**
2525     - * Initializes the component defaults.
2526     - */
2527     - protected void initComponentDefaults(UIDefaults table) {
2528     - super.initComponentDefaults(table);
2529 gregoa 1381 -
2530 gregoa 1326 - final boolean isXP = LookUtils.IS_LAF_WINDOWS_XP_ENABLED;
2531     - final boolean isClassic = !isXP;
2532     - final boolean isVista = LookUtils.IS_OS_WINDOWS_VISTA;
2533     -
2534     - initFontDefaults(table);
2535     -
2536     - if (isClassic) {
2537     - initComponentDefaultsClassic(table);
2538     - }
2539     - if (isXP && LookUtils.IS_JAVA_1_4) {
2540     - initComponentDefaultsXP14(table);
2541     - }
2542 gregoa 1381 -
2543 gregoa 1326 - MicroLayout microLayout = getMicroLayoutPolicy().getMicroLayout("Windows", table);
2544     - if (!isVista || !LookUtils.IS_JAVA_6_OR_LATER || !LookUtils.IS_LAF_WINDOWS_XP_ENABLED) {
2545     - initMenuItemDefaults(table, microLayout);
2546     - }
2547     -
2548     - Object marginBorder = new BasicBorders.MarginBorder();
2549     - Object checkBoxMargin = microLayout.getCheckBoxMargin();
2550     -
2551     - Object etchedBorder = new UIDefaults.ProxyLazyValue(
2552     - "javax.swing.plaf.BorderUIResource",
2553     - "getEtchedBorderUIResource");
2554     - Object buttonBorder = new SimpleProxyLazyValue(
2555     - "com.jgoodies.looks.windows.WindowsLookAndFeel",
2556     - "getButtonBorder");
2557 gregoa 1381 -
2558 gregoa 1326 - Object menuBorder = isXP
2559     - ? WindowsBorders.getXPMenuBorder()
2560     - : WindowsBorders.getMenuBorder();
2561     -
2562     - Object menuBarEmptyBorder = marginBorder;
2563     - Object menuBarSeparatorBorder = WindowsBorders.getSeparatorBorder();
2564     - Object menuBarEtchedBorder = WindowsBorders.getEtchedBorder();
2565     - Object menuBarHeaderBorder = WindowsBorders.getMenuBarHeaderBorder();
2566     -
2567     - Object toolBarEmptyBorder = marginBorder;
2568     - Object toolBarSeparatorBorder = WindowsBorders.getSeparatorBorder();
2569     - Object toolBarEtchedBorder = WindowsBorders.getEtchedBorder();
2570     - Object toolBarHeaderBorder = WindowsBorders.getToolBarHeaderBorder();
2571     -
2572     - Object buttonMargin = microLayout.getButtonMargin();
2573     -
2574     - Object toolBarSeparatorSize = LookUtils.IS_JAVA_1_4_2_OR_LATER
2575     - ? null
2576     - : new DimensionUIResource(6, Options.getDefaultIconSize().height);
2577     -
2578     - Object textInsets = microLayout.getTextInsets();
2579     - Object wrappedTextInsets = microLayout.getWrappedTextInsets();
2580     - Insets comboEditorInsets = microLayout.getComboBoxEditorInsets();
2581 gregoa 1381 -
2582 gregoa 1326 - int comboBorderSize = microLayout.getComboBorderSize();
2583     - int comboPopupBorderSize = microLayout.getComboPopupBorderSize();
2584     - int comboRendererGap = comboEditorInsets.left + comboBorderSize - comboPopupBorderSize;
2585     - Object comboRendererBorder = new EmptyBorder(1, comboRendererGap, 1, comboRendererGap);
2586     - Object comboTableEditorInsets = new Insets(0, 0, 0, 0);
2587 gregoa 1381 -
2588 gregoa 1326 - Object popupMenuSeparatorMargin = microLayout.getPopupMenuSeparatorMargin();
2589     -
2590     - // Should be active.
2591     - int treeFontSize = table.getFont("Tree.font").getSize();
2592     - Integer rowHeight = new Integer(treeFontSize + 6);
2593     -
2594     - Class superclass = getClass().getSuperclass();
2595     - Color controlColor = table.getColor("control");
2596     - Object disabledTextBackground = table.getColor("TextField.disabledBackground");
2597     - Object inactiveTextBackground = table.getColor("TextField.inactiveBackground");
2598 gregoa 1381 -
2599 gregoa 1326 - Object comboBoxDisabledBackground = (isVista && isXP)
2600     - ? table.getColor("ComboBox.background")
2601     - : disabledTextBackground;
2602     -
2603 gregoa 1381 - Object menuBarBackground = isXP
2604     - ? table.get("control")
2605 gregoa 1326 - : table.get("menu");
2606     - Object menuSelectionBackground = isXP
2607     - ? table.get("MenuItem.selectionBackground")
2608     - : table.get("Menu.background");
2609     - Object menuSelectionForeground = isXP
2610     - ? table.get("MenuItem.selectionForeground")
2611     - : table.get("Menu.foreground");
2612 gregoa 1381 -
2613 gregoa 1326 - Character passwordEchoChar = new Character(isXP ? '\u25CF' : '*');
2614 gregoa 1381 -
2615 gregoa 1326 - Object[] defaults = {
2616 gregoa 1381 - "Button.border", buttonBorder,
2617 gregoa 1326 - "Button.margin", buttonMargin, // Sun's 14px margin is too wide
2618     -
2619     - // 1.4.2 uses a 2 pixel non-standard border that leads to bad
2620     - // alignment in the typical case that the border is not painted
2621 gregoa 1381 - "CheckBox.border", marginBorder,
2622 gregoa 1326 - "CheckBox.margin", checkBoxMargin,
2623 gregoa 1381 -
2624 gregoa 1326 - "ComboBox.disabledBackground", comboBoxDisabledBackground,
2625     - "ComboBox.editorBorder", marginBorder,
2626     - "ComboBox.editorColumns", new Integer(5),
2627     - "ComboBox.editorInsets", comboEditorInsets, // Added by JGoodies
2628 gregoa 1381 - "ComboBox.tableEditorInsets", comboTableEditorInsets,
2629 gregoa 1326 - "ComboBox.rendererBorder", comboRendererBorder, // Added by JGoodies
2630 gregoa 1381 -
2631 gregoa 1326 - "EditorPane.margin", wrappedTextInsets,
2632 gregoa 1381 -
2633 gregoa 1326 - // Begin 1.3 und 1.4.0
2634     - "Menu.border", menuBorder, // Fixed in 1.4.1
2635 gregoa 1381 - "Menu.borderPainted", Boolean.TRUE,
2636     - "Menu.background", menuBarBackground,
2637     - "Menu.selectionForeground", menuSelectionForeground,
2638     - "Menu.selectionBackground", menuSelectionBackground,
2639 gregoa 1326 - // End 1.3 und 1.4.0
2640     -
2641 gregoa 1381 - "MenuBar.background", menuBarBackground,
2642 gregoa 1326 - "MenuBar.border", menuBarSeparatorBorder, // 1.4.1 Separator wrong
2643 gregoa 1381 - "MenuBar.emptyBorder", menuBarEmptyBorder, // Added by JGoodies
2644     - "MenuBar.separatorBorder", menuBarSeparatorBorder, // Added by JGoodies
2645 gregoa 1326 - "MenuBar.etchedBorder", menuBarEtchedBorder, // Added by JGoodies
2646     - "MenuBar.headerBorder", menuBarHeaderBorder, // Added by JGoodies
2647     -
2648     - "FormattedTextField.disabledBackground", disabledTextBackground, // for readonly
2649     - "FormattedTextField.inactiveBackground", inactiveTextBackground, // for readonly
2650     - "FormattedTextField.margin", textInsets, // Poor in 1.6
2651 gregoa 1381 -
2652 gregoa 1326 - "PasswordField.margin", textInsets, // Poor in 1.6
2653     - "PasswordField.echoChar", passwordEchoChar,
2654 gregoa 1381 -
2655 gregoa 1326 - "PopupMenu.border", WindowsBorders.getPopupMenuBorder(),
2656     - "PopupMenu.noMarginBorder", WindowsBorders.getNoMarginPopupMenuBorder(),
2657 gregoa 1381 - "PopupMenuSeparator.margin", popupMenuSeparatorMargin,
2658 gregoa 1326 -
2659     - "ScrollPane.etchedBorder", etchedBorder, // Added by JGoodies
2660 gregoa 1381 -
2661 gregoa 1326 - "Spinner.defaultEditorInsets", textInsets, // Added by JGoodies
2662 gregoa 1381 -
2663 gregoa 1326 - // 1.4.1 uses a 2 pixel non-standard border, that leads to bad
2664     - // alignment in the typical case that the border is not painted
2665 gregoa 1381 - "RadioButton.border", marginBorder,
2666     - "RadioButton.margin", checkBoxMargin,
2667     -
2668 gregoa 1326 - "Table.gridColor", controlColor, // 1.4.1 Bug; active
2669     - "TextArea.margin", wrappedTextInsets, // 1.4.1 Bug
2670     - "TextArea.disabledBackground", disabledTextBackground,
2671     - "TextArea.inactiveBackground", inactiveTextBackground,
2672     - "TextField.margin", textInsets, // 1.4.1 Bug
2673     - "ToggleButton.margin", buttonMargin, // Sun's 14px margin is too wide
2674     -
2675     - "ToolBar.emptyBorder", toolBarEmptyBorder, // Added by JGoodies
2676     - "ToolBar.separatorBorder", toolBarSeparatorBorder, // Added by JGoodies
2677     - "ToolBar.etchedBorder", toolBarEtchedBorder, // Added by JGoodies
2678     - "ToolBar.headerBorder", toolBarHeaderBorder, // Added by JGoodies
2679 gregoa 1381 - "ToolBar.separatorSize", toolBarSeparatorSize,
2680     - "ToolBar.margin", new InsetsUIResource(0, 10, 0, 0),
2681 gregoa 1326 -
2682     - "Tree.selectionBorderColor", controlColor, // 1.4.1 Bug; active
2683     - "Tree.rowHeight", rowHeight, // 1.4.1 Bug
2684     - };
2685     - if (LookUtils.IS_JAVA_1_4) {
2686     - defaults = append(defaults, new Object[] {
2687     - "InternalFrame.icon", makeIcon(superclass, "icons/JavaCup.gif"),
2688     - "OptionPane.errorIcon", isXP ? makeIcon(getClass(), "icons/xp/Error.png")
2689     - : makeIcon(superclass, "icons/Error.gif"),
2690     - "OptionPane.informationIcon", isXP ? makeIcon(getClass(), "icons/xp/Inform.png")
2691 gregoa 1381 - : makeIcon(superclass, "icons/Inform.gif"),
2692 gregoa 1326 - "OptionPane.warningIcon", isXP ? makeIcon(getClass(), "icons/xp/Warn.png")
2693 gregoa 1381 - : makeIcon(superclass, "icons/Warn.gif"),
2694 gregoa 1326 - "OptionPane.questionIcon", isXP ? makeIcon(getClass(), "icons/xp/Inform.png")
2695     - : makeIcon(superclass, "icons/Question.gif")
2696     - });
2697     - }
2698     - if (LookUtils.IS_JAVA_1_4 || LookUtils.IS_JAVA_5) {
2699     - defaults = append(defaults, new Object[] {
2700     - "Tree.openIcon", isXP ? makeIcon(getClass(), "icons/xp/TreeOpen.png")
2701     - : makeIcon(getClass(), "icons/TreeOpen.gif"),
2702     - "Tree.closedIcon", isXP ? makeIcon(getClass(), "icons/xp/TreeClosed.png")
2703     - : makeIcon(getClass(), "icons/TreeClosed.gif")
2704     - });
2705     - }
2706     - if (LookUtils.IS_JAVA_6_OR_LATER) {
2707     - defaults = append(defaults, new Object[] {
2708     - "Spinner.border", table.get("TextField.border")
2709     - });
2710     - }
2711     - table.putDefaults(defaults);
2712     - }
2713     -
2714     - /**
2715     - * Initializes component defaults required in classic mode only.
2716     - */
2717     - private void initComponentDefaultsClassic(UIDefaults table) {
2718     - Object checkBoxIcon = new SimpleProxyLazyValue(
2719     - "com.jgoodies.looks.windows.WindowsLookAndFeel",
2720     - "getCheckBoxIcon");
2721     -
2722     - Object radioButtonIcon = new SimpleProxyLazyValue(
2723     - "com.jgoodies.looks.windows.WindowsLookAndFeel",
2724     - "getRadioButtonIcon");
2725     -
2726     - Border winInsetBorder = new BasicBorders.FieldBorder(table
2727     - .getColor("controlShadow"), table
2728     - .getColor("controlDkShadow"),
2729     - table.getColor("controlHighlight"), table
2730     - .getColor("controlLtHighlight"));
2731     -
2732     - Object[] defaults = {
2733     - "CheckBox.checkColor", table.get("controlText"), // kind-of black
2734 gregoa 1381 - "CheckBox.icon", checkBoxIcon,
2735 gregoa 1326 - "RadioButton.checkColor", table.get("controlText"), // kind-of black
2736 gregoa 1381 - "RadioButton.icon", radioButtonIcon,
2737 gregoa 1326 - "Table.scrollPaneBorder", winInsetBorder, // 1.4.1 Bug
2738     -
2739     - };
2740     - table.putDefaults(defaults);
2741     - }
2742     -
2743     - /**
2744     - * Initializes component defaults required in XP mode on Java 1.4.2 only.
2745     - */
2746     - private void initComponentDefaultsXP14(UIDefaults table) {
2747     - Object[] defaults = {
2748     - "TitledBorder.titleColor", table.getColor("activeCaption")
2749     - };
2750     - table.putDefaults(defaults);
2751     - }
2752     -
2753     - /**
2754     - * Looks up the correct control font and sets it for all controls.
2755     - */
2756     - private void initFontDefaults(UIDefaults table) {
2757     - FontPolicy fontChoicePolicy = getFontPolicy();
2758     - FontSet fontSet = fontChoicePolicy.getFontSet("Windows", table);
2759     - initFontDefaults(table, fontSet);
2760     - }
2761 gregoa 1381 -
2762     -
2763 gregoa 1326 - private void initMenuItemDefaults(UIDefaults table, MicroLayout microLayout) {
2764     - Object menuMargin = microLayout.getMenuMargin();
2765     - Object menuItemMargin = microLayout.getMenuItemMargin();
2766     - Icon menuItemCheckIcon = new MinimumSizedIcon();
2767     - Object[] defaults = {
2768     -
2769     - "Menu.margin", menuMargin, // 1.4.1 Bug
2770     -
2771 gregoa 1381 - "MenuItem.borderPainted", Boolean.TRUE,
2772 gregoa 1326 - "MenuItem.checkIcon", menuItemCheckIcon, // Aligns menu items
2773     - "MenuItem.margin", menuItemMargin, // 1.4.1 Bug
2774     - "CheckBoxMenuItem.margin", menuItemMargin, // 1.4.1 Bug
2775     - "RadioButtonMenuItem.margin", menuItemMargin, // 1.4.1 Bug
2776     - };
2777     - table.putDefaults(defaults);
2778     - }
2779     -
2780 gregoa 1381 -
2781 gregoa 1326 - /**
2782 gregoa 1381 - * Sets Fonts in the given FontSet as defaults for all known
2783 gregoa 1326 - * component types in the given UIDefaults table.
2784 gregoa 1381 - *
2785 gregoa 1326 - * @param table the UIDefaults table used to set fonts
2786     - * @param fontSet describes the set of Fonts to be installed
2787     - */
2788     - private static void initFontDefaults(UIDefaults table, FontSet fontSet) {
2789     - Font controlFont = fontSet.getControlFont();
2790     - Font menuFont = fontSet.getMenuFont();
2791     - Font messageFont = fontSet.getMessageFont();
2792     - Font toolTipFont = fontSet.getSmallFont();
2793     - Font titleFont = fontSet.getTitleFont();
2794     - Font windowFont = fontSet.getWindowTitleFont();
2795 gregoa 1381 -
2796 gregoa 1326 - Object[] defaults = {
2797     - "Button.font", controlFont,
2798     - "CheckBox.font", controlFont,
2799     - "ColorChooser.font", controlFont,
2800     - "ComboBox.font", controlFont,
2801     - "EditorPane.font", controlFont,
2802     - "FormattedTextField.font", controlFont,
2803     - "Label.font", controlFont,
2804     - "List.font", controlFont,
2805     - "Panel.font", controlFont,
2806     - "PasswordField.font", controlFont,
2807     - "ProgressBar.font", controlFont,
2808     - "RadioButton.font", controlFont,
2809     - "ScrollPane.font", controlFont,
2810     - "Spinner.font", controlFont,
2811     - "TabbedPane.font", controlFont,
2812     - "Table.font", controlFont,
2813     - "TableHeader.font", controlFont,
2814 gregoa 1381 - "TextArea.font", controlFont,
2815 gregoa 1326 - "TextField.font", controlFont,
2816     - "TextPane.font", controlFont,
2817     - "ToolBar.font", controlFont,
2818     - "ToggleButton.font", controlFont,
2819     - "Tree.font", controlFont,
2820     - "Viewport.font", controlFont,
2821     -
2822     - "InternalFrame.titleFont", windowFont, // controlBold
2823     - "OptionPane.font", messageFont,
2824     - "OptionPane.messageFont", messageFont,
2825     - "OptionPane.buttonFont", messageFont,
2826     - "TitledBorder.font", titleFont,
2827     - "ToolTip.font", toolTipFont,
2828     -
2829     - "CheckBoxMenuItem.font", menuFont,
2830     - "CheckBoxMenuItem.acceleratorFont", menuFont, // 1.3 only ?
2831     - "Menu.font", menuFont,
2832     - "Menu.acceleratorFont", menuFont,
2833     - "MenuBar.font", menuFont,
2834     - "MenuItem.font", menuFont,
2835     - "MenuItem.acceleratorFont", menuFont,
2836     - "PopupMenu.font", menuFont,
2837     - "RadioButtonMenuItem.font", menuFont,
2838     - "RadioButtonMenuItem.acceleratorFont", menuFont, // 1.3 only ?
2839     - };
2840     - table.putDefaults(defaults);
2841     - }
2842     -
2843 gregoa 1381 -
2844 gregoa 1326 - // Getters for Proxy Access (Referred classes can stay package visible) ***
2845     -
2846     - public static Border getButtonBorder() {
2847     - return WindowsBorders.getButtonBorder();
2848     - }
2849     -
2850     - public static Icon getCheckBoxIcon() {
2851     - return WindowsIconFactory.getCheckBoxIcon();
2852     - }
2853     -
2854     - public static Icon getRadioButtonIcon() {
2855     - return WindowsIconFactory.getRadioButtonIcon();
2856     - }
2857 gregoa 1381 -
2858     -
2859 gregoa 1326 - // Helper Code ************************************************************
2860 gregoa 1381 -
2861 gregoa 1326 - /**
2862     - * Appends the key and value to the given source array and returns
2863     - * a copy that has the two new elements at its end.
2864 gregoa 1381 - *
2865 gregoa 1326 - * @return an array with the key and value appended
2866     - */
2867     - private static Object[] append(Object[] source, String key, Object value) {
2868     - int length = source.length;
2869     - Object[] destination = new Object[length + 2];
2870     - System.arraycopy(source, 0, destination, 0, length);
2871     - destination[length] = key;
2872     - destination[length + 1] = value;
2873     - return destination;
2874     - }
2875     -
2876     -
2877     - /**
2878     - * Appends the key and value to the given source array and returns
2879     - * a copy that has the two new elements at its end.
2880 gregoa 1381 - *
2881 gregoa 1326 - * @return an array with the key and value appended
2882     - */
2883     - private static Object[] append(Object[] source, Object[] keysAndValues) {
2884     - int length = source.length;
2885     - Object[] destination = new Object[length + keysAndValues.length];
2886     - System.arraycopy(source, 0, destination, 0, length);
2887     - for (int i = 0; i < keysAndValues.length; i++) {
2888     - destination[length + i] = keysAndValues[i];
2889     - }
2890     - return destination;
2891     - }
2892     -
2893 gregoa 1381 - // Helper Class ***********************************************************
2894 gregoa 1326 -
2895     - /**
2896     - * This class provides an implementation of <code>LazyValue</code> that
2897     - * can be used to delay loading of the Class for the instance to be created.
2898     - * It also avoids creation of an anonymous inner class for the
2899     - * <code>LazyValue</code>
2900     - * subclass. Both of these improve performance at the time that a
2901     - * a Look and Feel is loaded, at the cost of a slight performance
2902     - * reduction the first time <code>createValue</code> is called
2903     - * (since Reflection APIs are used).
2904     - */
2905     - private static class SimpleProxyLazyValue implements UIDefaults.LazyValue {
2906     -
2907     - private final String className;
2908     - private final String methodName;
2909     -
2910     - /**
2911     - * Creates a <code>LazyValue</code> which will construct an instance
2912     - * when asked.
2913 gregoa 1381 - *
2914 gregoa 1326 - * @param c a <code>String</code> specifying the classname of the class
2915     - * containing a static method to be called for instance creation
2916 gregoa 1381 - * @param m a <code>String</code> specifying the static
2917 gregoa 1326 - * method to be called on class c
2918     - */
2919     - public SimpleProxyLazyValue(String c, String m) {
2920     - className = c;
2921     - methodName = m;
2922     - }
2923     -
2924     - /**
2925     - * Creates the value retrieved from the <code>UIDefaults</code> table.
2926     - * The object is created each time it is accessed.
2927     - *
2928     - * @param table a <code>UIDefaults</code> table
2929     - * @return the created <code>Object</code>
2930     - */
2931     - public Object createValue(UIDefaults table) {
2932     - Object instance = null;
2933     - try {
2934     - Class c;
2935     - // We use a separate ClassLoader
2936     - ClassLoader classLoader = table != null
2937     - ? (ClassLoader) table.get("ClassLoader")
2938     - : Thread.currentThread().getContextClassLoader();
2939     - if (classLoader == null) {
2940     - classLoader = getClass().getClassLoader();
2941     - }
2942     - c = Class.forName(className, true, classLoader);
2943     - Method m = c.getMethod(methodName, null);
2944     - instance = m.invoke(c, null);
2945     - } catch (Throwable t) {
2946     - LookUtils.log("Problem creating " + className + " with method "
2947     - + methodName + t);
2948     - }
2949     - return instance;
2950     - }
2951     - }
2952     -
2953     -}
2954     \ No newline at end of file
2955 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsMenuBarUI.java
2956 gregoa 1326 +++ /dev/null
2957     @@ -1,126 +0,0 @@
2958     -/*
2959 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
2960 gregoa 1326 - *
2961 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
2962 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
2963 gregoa 1381 - *
2964     - * o Redistributions of source code must retain the above copyright notice,
2965     - * this list of conditions and the following disclaimer.
2966     - *
2967     - * o Redistributions in binary form must reproduce the above copyright notice,
2968     - * this list of conditions and the following disclaimer in the documentation
2969     - * and/or other materials provided with the distribution.
2970     - *
2971     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
2972     - * its contributors may be used to endorse or promote products derived
2973     - * from this software without specific prior written permission.
2974     - *
2975     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2976     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2977     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2978     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2979     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2980     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2981     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2982     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2983     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2984     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2985     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2986 gregoa 1326 - */
2987     -
2988     -package com.jgoodies.looks.windows;
2989     -
2990     -import java.beans.PropertyChangeEvent;
2991     -import java.beans.PropertyChangeListener;
2992     -
2993     -import javax.swing.JComponent;
2994     -import javax.swing.LookAndFeel;
2995     -import javax.swing.plaf.ComponentUI;
2996     -
2997     -import com.jgoodies.looks.BorderStyle;
2998     -import com.jgoodies.looks.HeaderStyle;
2999     -import com.jgoodies.looks.Options;
3000     -
3001     -/**
3002     - * The JGoodies Windows look and feel implemenation of <code>MenuBarUI</code>.<p>
3003 gregoa 1381 - *
3004     - * Can handle optional <code>Border</code> types as specified by the
3005 gregoa 1326 - * <code>BorderStyle</code> or <code>HeaderStyle</code> client properties.
3006     - *
3007     - * @author Karsten Lentzsch
3008 gregoa 1381 - * @version $Revision: 1.5 $
3009 gregoa 1326 - */
3010     -public final class WindowsMenuBarUI extends com.sun.java.swing.plaf.windows.WindowsMenuBarUI {
3011 gregoa 1381 -
3012 gregoa 1326 - private PropertyChangeListener listener;
3013 gregoa 1381 -
3014     -
3015 gregoa 1326 - public static ComponentUI createUI(JComponent b) {
3016     - return new WindowsMenuBarUI();
3017     - }
3018 gregoa 1381 -
3019     -
3020 gregoa 1326 - // Handling Special Borders *********************************************************
3021 gregoa 1381 -
3022 gregoa 1326 - protected void installDefaults() {
3023     - super.installDefaults();
3024     - installSpecialBorder();
3025     - }
3026 gregoa 1381 -
3027     -
3028 gregoa 1326 - protected void installListeners() {
3029     - super.installListeners();
3030     - listener = createBorderStyleListener();
3031     - menuBar.addPropertyChangeListener(listener);
3032     - }
3033 gregoa 1381 -
3034     -
3035 gregoa 1326 - protected void uninstallListeners() {
3036     - menuBar.removePropertyChangeListener(listener);
3037     - super.uninstallListeners();
3038     - }
3039 gregoa 1381 -
3040     -
3041 gregoa 1326 - private PropertyChangeListener createBorderStyleListener() {
3042     - return new PropertyChangeListener() {
3043 gregoa 1381 -
3044 gregoa 1326 - public void propertyChange(PropertyChangeEvent e) {
3045     - String prop = e.getPropertyName();
3046 gregoa 1381 - if (prop.equals(Options.HEADER_STYLE_KEY) ||
3047 gregoa 1326 - prop.equals(WindowsLookAndFeel.BORDER_STYLE_KEY)) {
3048     - WindowsMenuBarUI.this.installSpecialBorder();
3049     - }
3050     - }
3051 gregoa 1381 -
3052 gregoa 1326 - };
3053     - }
3054 gregoa 1381 -
3055     -
3056 gregoa 1326 - /**
3057 gregoa 1381 - * Installs a special border, if either a look-dependent
3058     - * <code>BorderStyle</code> or a look-independent
3059 gregoa 1326 - * <code>HeaderStyle</code> has been specified.
3060 gregoa 1381 - * A look specific BorderStyle shadows
3061 gregoa 1326 - * a HeaderStyle.<p>
3062 gregoa 1381 - *
3063 gregoa 1326 - * Specifying a HeaderStyle is recommend.
3064 gregoa 1381 - */
3065 gregoa 1326 - private void installSpecialBorder() {
3066     - String suffix;
3067 gregoa 1381 - BorderStyle borderStyle = BorderStyle.from(menuBar,
3068 gregoa 1326 - WindowsLookAndFeel.BORDER_STYLE_KEY);
3069     - if (borderStyle == BorderStyle.EMPTY)
3070     - suffix = "emptyBorder";
3071     - else if (borderStyle == BorderStyle.ETCHED)
3072     - suffix = "etchedBorder";
3073     - else if (borderStyle == BorderStyle.SEPARATOR)
3074     - suffix = "separatorBorder";
3075     - else if (HeaderStyle.from(menuBar) == HeaderStyle.BOTH)
3076     - suffix = "headerBorder";
3077     - else
3078     - return;
3079 gregoa 1381 -
3080 gregoa 1326 - LookAndFeel.installBorder(menuBar, "MenuBar." + suffix);
3081     - }
3082     -
3083     -}
3084     \ No newline at end of file
3085 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsMenuItemRenderer.java
3086 gregoa 1326 +++ /dev/null
3087     @@ -1,77 +0,0 @@
3088     -/*
3089 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3090 gregoa 1326 - *
3091 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
3092 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
3093 gregoa 1381 - *
3094     - * o Redistributions of source code must retain the above copyright notice,
3095     - * this list of conditions and the following disclaimer.
3096     - *
3097     - * o Redistributions in binary form must reproduce the above copyright notice,
3098     - * this list of conditions and the following disclaimer in the documentation
3099     - * and/or other materials provided with the distribution.
3100     - *
3101     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3102     - * its contributors may be used to endorse or promote products derived
3103     - * from this software without specific prior written permission.
3104     - *
3105     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3106     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3107     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3108     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3109     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3110     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3111     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3112     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3113     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3114     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3115     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3116 gregoa 1326 - */
3117     -
3118     -package com.jgoodies.looks.windows;
3119     -
3120     -import java.awt.Color;
3121     -import java.awt.Font;
3122     -
3123     -import javax.swing.JMenuItem;
3124     -import javax.swing.UIManager;
3125     -
3126     -import com.jgoodies.looks.LookUtils;
3127     -import com.jgoodies.looks.common.MenuItemRenderer;
3128     -
3129     -/**
3130     - * Renders and lays out Windows menu items.
3131     - * It overrides superclass behavior for the mnemonic check
3132     - * and the text shadow feature.
3133 gregoa 1381 - *
3134 gregoa 1326 - * @author Karsten Lentzsch
3135 gregoa 1381 - * @version $Revision: 1.4 $
3136 gregoa 1326 - */
3137     -final class WindowsMenuItemRenderer extends MenuItemRenderer {
3138     -
3139     - /**
3140     - * Constructs a WindowsMenuItemRenderer for the specified menu item and settings.
3141     - */
3142     - public WindowsMenuItemRenderer(JMenuItem menuItem, boolean iconBorderEnabled,
3143     - Font acceleratorFont,
3144     - Color selectionForeground,
3145     - Color disabledForeground,
3146     - Color acceleratorForeground,
3147     - Color acceleratorSelectionForeground) {
3148     - super(menuItem, iconBorderEnabled, acceleratorFont, selectionForeground, disabledForeground,
3149     - acceleratorForeground, acceleratorSelectionForeground);
3150     - }
3151 gregoa 1381 -
3152     -
3153 gregoa 1326 - protected boolean isMnemonicHidden() {
3154     - return WindowsLookAndFeel.isMnemonicHidden();
3155     - }
3156 gregoa 1381 -
3157     -
3158 gregoa 1326 - protected boolean disabledTextHasShadow() {
3159     - return (!LookUtils.IS_LAF_WINDOWS_XP_ENABLED)
3160     - || (UIManager.getColor("MenuItem.disabledForeground") == null);
3161     - }
3162 gregoa 1381 -
3163     -
3164 gregoa 1326 -}
3165     \ No newline at end of file
3166 gregoa 1381 --- a/src/core/com/jgoodies/looks/windows/WindowsMenuItemUI.java
3167 gregoa 1326 +++ /dev/null
3168     @@ -1,80 +0,0 @@
3169     -/*
3170 gregoa 1381 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3171 gregoa 1326 - *
3172 gregoa 1381 - * Redistribution and use in source and binary forms, with or without
3173 gregoa 1326 - * modification, are permitted provided that the following conditions are met:
3174 gregoa 1381 - *
3175     - * o Redistributions of source code must retain the above copyright notice,
3176     - * this list of conditions and the following disclaimer.
3177     - *
3178     - * o Redistributions in binary form must reproduce the above copyright notice,
3179     - * this list of conditions and the following disclaimer in the documentation
3180     - * and/or other materials provided with the distribution.
3181     - *
3182     - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3183     - * its contributors may be used to endorse or promote products derived
3184     - * from this software without specific prior written permission.
3185     - *
3186     - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3187     - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3188     - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3189     - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3190     - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3191     - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3192     - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3193     - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3194     - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3195     - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3196     - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3197 gregoa 1326 - */
3198     -
3199     -package com.jgoodies.looks.windows;
3200     -
3201     -import java.awt.Color;
3202     -import java.awt.Font;
3203     -
3204     -import javax.swing.JComponent;
3205     -import javax.swing.JMenuItem;
3206     -import javax.swing.plaf.ComponentUI;
3207     -
3208     -import com.jgoodies.looks.common.ExtBasicMenuItemUI;
3209     -import com.jgoodies.looks.common.MenuItemRenderer;
3210     -
3211     -/**
3212     - * The JGoodies Windows look&amp;feel implementation of <code>MenuItemUI</code>.<p>
3213 gregoa 1381 - *
3214 gregoa 1326 - * It differs from the superclass in that it uses a Windows specific
3215     - * menu item renderer that checks if mnemonics shall be shown or hidden
3216     - * and may paint disabled text with a shadow.
3217     - *
3218     - * @author Karsten Lentzsch
3219 gregoa 1381 - * @version $Revision: 1.4 $
3220 gregoa 1326 - */
3221     -public final class WindowsMenuItemUI extends ExtBasicMenuItemUI {
3222     -
3223     -
3224     - public static ComponentUI createUI(JComponent b) {
3225     - return new WindowsMenuItemUI();
3226     - }
3227     -
3228 gregoa 1381 -
3229 gregoa 1326 - protected MenuItemRenderer createRenderer(
3230 gregoa 1381 - JMenuItem menuItem,
3231 gregoa 1326 - boolean iconBorderEnabled,
3232     - Font acceleratorFont,
3233     - Color selectionForeground,
3234     - Color disabledForeground,
3235     - Color acceleratorForeground,
3236     - Color acceleratorSelectionForeground) {
3237     - return new WindowsMenuItemRenderer(
3238     - menuItem,
3239     - iconBorderEnabled(),
3240     - acceleratorFont,
3241     - selectionForeground,
3242     - disabledForeground,
3243     - acceleratorForeground,
3244