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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1381 - (show annotations)
Fri Jul 25 19:07:03 2008 UTC (12 years, 8 months ago) by gregoa
File size: 253189 byte(s)
Refresh patches.
1 Author: <gregor+debian@comodo.priv.at>
2 Description: remove windows look
3 --- a/build.xml
4 +++ b/build.xml
5 @@ -94,7 +94,7 @@
6 <!-- 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 @@ -119,33 +119,11 @@
15 <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 @@ -213,7 +191,7 @@
50 <!-- 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 @@ -268,20 +246,6 @@
59 </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 --- a/src/core/com/jgoodies/looks/Options.java
80 +++ b/src/core/com/jgoodies/looks/Options.java
81 @@ -40,8 +40,6 @@
82
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 * Provides access to optional features of the JGoodies L&amp;Fs
90 --- a/src/core/com/jgoodies/looks/windows/WindowsArrowButton.java
91 +++ /dev/null
92 @@ -1,142 +0,0 @@
93 -/*
94 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
95 - *
96 - * Redistribution and use in source and binary forms, with or without
97 - * modification, are permitted provided that the following conditions are met:
98 - *
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 - */
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 - * The JGoodies Windows Look&amp;Feel implementation for
134 - * arrow buttons used in scrollbars and comboboxes.
135 - * <p>
136 - * It differs from <code>BasicArrowButton</code> in that the preferred size
137 - * is always a square.
138 - * It differs from <code>WindowsScrollBarUI.WindowsArrowButton</code>
139 - * in that the triangle is black and positioned correctly.
140 - *
141 - * @author Karsten Lentzsch
142 - * @version $Revision: 1.5 $
143 - */
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 --- a/src/core/com/jgoodies/looks/windows/WindowsBorders.java
236 +++ /dev/null
237 @@ -1,584 +0,0 @@
238 -/*
239 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
240 - *
241 - * Redistribution and use in source and binary forms, with or without
242 - * modification, are permitted provided that the following conditions are met:
243 - *
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 - */
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 -import javax.swing.*;
276 -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 - * Consists of static inner classes that define different
287 - * <code>Borders</code> used in the JGoodies Windows look&amp;feel.
288 - *
289 - * @author Karsten Lentzsch
290 - * @version $Revision: 1.7 $
291 - */
292 -final class WindowsBorders {
293 -
294 - private WindowsBorders() {
295 - // Overrides default constructor; prevents instantiation.
296 - }
297 -
298 - // 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 - * Returns a special border for a <code>JMenuBar</code> that
387 - * 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 - *
401 - * @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 - *
413 - * @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 - * Returns a special border for a <code>JToolBar</code> that
424 - * is used in a header just below a <code>JMenuBar</code>.
425 - */
426 - static Border getToolBarHeaderBorder() {
427 - if (toolBarHeaderBorder == null) {
428 - 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 - if (rolloverButtonBorder == null) {
440 - 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 -
454 - private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
455 -
456 - 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 - public ButtonBorder(Color shadow, Color darkShadow,
463 - Color highlight, Color lightHighlight, Color defaultColor) {
464 - this.shadow = shadow;
465 - this.darkShadow = darkShadow;
466 - this.highlight = highlight;
467 - 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 -
475 - if (c instanceof AbstractButton) {
476 - AbstractButton b = (AbstractButton) c;
477 - ButtonModel model = b.getModel();
478 -
479 - isPressed = model.isPressed() && model.isArmed();
480 - if (c instanceof JButton) {
481 - isDefault = ((JButton) c).isDefaultButton();
482 - }
483 - }
484 - 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 -
526 - /**
527 - * A border used for <code>Buttons</code> that have the rollover property enabled.
528 - */
529 - private static final class RolloverButtonBorder extends AbstractButtonBorder {
530 -
531 - 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 - super(1, 1, 1, 1);
567 - }
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 - */
601 - 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 -
615 - public Insets getBorderInsets(Component c) { return INSETS; }
616 - }
617 -
618 -
619 - /**
620 - * A thin raised border.
621 - */
622 - 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 -
630 - public Insets getBorderInsets(Component c) { return INSETS; }
631 - }
632 -
633 -
634 - /**
635 - * A thin lowered border.
636 - */
637 - 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 -
645 - public Insets getBorderInsets(Component c) { return INSETS; }
646 - }
647 -
648 -
649 - /**
650 - * A border used for menu bars and tool bars in <code>HeaderStyle.SINGLE</code>.
651 - * The bar is wrapped by an inner thin raised border,
652 - * which in turn is wrapped by an outer thin lowered border.
653 - */
654 - 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 -
666 -
667 - /**
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 - private static final Insets INSETS = new Insets(2, 2, 1, 2);
675 -
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 -
684 -
685 - 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 -
703 - 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 -
719 - /**
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 - private static final Insets INSETS = new Insets(1, 2, 2, 2);
727 -
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 -
736 -
737 - /**
738 - * A border used for menus.
739 - */
740 - private static final class MenuBorder extends AbstractBorder implements UIResource {
741 -
742 - 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 -
757 - 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 - 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 - Color highlight, Color lightHighlight, Color defaultColor)
769 - {
770 - Color oldColor = g.getColor(); // Make no net change to g
771 - g.translate(x, y);
772 -
773 - 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 - g.setColor(defaultColor);
783 - g.drawRect(0, 0, w-1, h-1);
784 -
785 - g.setColor(lightHighlight);
786 - 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 - g.setColor(darkShadow);
798 - g.drawLine(1, h-2, w-2, h-2);
799 - g.drawLine(w-2, h-2, w-2, 1);
800 - } else {
801 - g.setColor(lightHighlight);
802 - 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 - g.setColor(darkShadow);
814 - 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 --- a/src/core/com/jgoodies/looks/windows/WindowsButtonUI.java
823 +++ /dev/null
824 @@ -1,71 +0,0 @@
825 -/*
826 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
827 - *
828 - * Redistribution and use in source and binary forms, with or without
829 - * modification, are permitted provided that the following conditions are met:
830 - *
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 - */
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 - *
867 - * Unlike its superclass it returns even and odd preferred heights.
868 - *
869 - * @author Karsten Lentzsch
870 - * @version $Revision: 1.5 $
871 - */
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 --- a/src/core/com/jgoodies/looks/windows/WindowsComboBoxEditor.java
898 +++ /dev/null
899 @@ -1,71 +0,0 @@
900 -/*
901 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
902 - *
903 - * Redistribution and use in source and binary forms, with or without
904 - * modification, are permitted provided that the following conditions are met:
905 - *
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 - */
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 - * The default editor for editable combo boxes in the
938 - * JGoodies Windows Look&amp;Feel.<p>
939 - *
940 - * It differs from its superclass in that the border is quite the same as for
941 - * text fields: a compound border with an inner <code>MarginBorder</code>.
942 - *
943 - * @author Karsten Lentzsch
944 - * @version $Revision: 1.8 $
945 - */
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 -
966 - UIResource(boolean isTableCellEditor) {
967 - super(isTableCellEditor);
968 - }
969 - }
970 -}
971 \ No newline at end of file
972 --- a/src/core/com/jgoodies/looks/windows/WindowsComboBoxUI.java
973 +++ /dev/null
974 @@ -1,557 +0,0 @@
975 -/*
976 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
977 - *
978 - * Redistribution and use in source and binary forms, with or without
979 - * modification, are permitted provided that the following conditions are met:
980 - *
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 - */
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 - * The JGoodies Windows Look&amp;Feel implementation of
1027 - * {@link javax.swing.plaf.ComboBoxUI}.
1028 - * Corrects the editor insets for editable combo boxes
1029 - * as well as the render insets for non-editable combos. And it has
1030 - * the same height as text fields - unless you change the renderer.<p>
1031 - *
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 - * the JGoodies Windows L&amp;f implemented via a client property key.
1035 - *
1036 - * @author Karsten Lentzsch
1037 - * @version $Revision: 1.21 $
1038 - *
1039 - * @see Options#COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
1040 - */
1041 -public class WindowsComboBoxUI extends com.sun.java.swing.plaf.windows.WindowsComboBoxUI {
1042 -
1043 - private static final String CELL_EDITOR_KEY = "JComboBox.isTableCellEditor";
1044 -
1045 - /**
1046 - * Used to determine the minimum height of a text field,
1047 - * which in turn is used to answer the combobox's minimum height.
1048 - */
1049 - private static final JTextField PHANTOM = new JTextField("Phantom");
1050 -
1051 - private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
1052 - private static final Border EMPTY_BORDER = new EmptyBorder(EMPTY_INSETS);
1053 -
1054 -
1055 - private boolean tableCellEditor;
1056 - private PropertyChangeListener propertyChangeListener;
1057 -
1058 -
1059 - // ************************************************************************
1060 -
1061 - public static ComponentUI createUI(JComponent b) {
1062 - ensurePhantomHasWindowsUI();
1063 - return new WindowsComboBoxUI();
1064 - }
1065 -
1066 -
1067 - /**
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 -
1076 -
1077 - // ************************************************************************
1078 -
1079 - public void installUI(JComponent c) {
1080 - super.installUI(c);
1081 - tableCellEditor = isTableCellEditor();
1082 - }
1083 -
1084 - protected void installListeners() {
1085 - super.installListeners();
1086 - propertyChangeListener = new TableCellEditorPropertyChangeHandler();
1087 - comboBox.addPropertyChangeListener(CELL_EDITOR_KEY, propertyChangeListener);
1088 - }
1089 -
1090 - protected void uninstallListeners() {
1091 - super.uninstallListeners();
1092 - comboBox.removePropertyChangeListener(CELL_EDITOR_KEY, propertyChangeListener);
1093 - propertyChangeListener = null;
1094 - }
1095 -
1096 -
1097 - /**
1098 - * Creates the arrow button that is to be used in the combo box.<p>
1099 - *
1100 - * 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 -
1108 -
1109 - /**
1110 - * 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 - * 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 - * Creates a layout manager for managing the components which
1121 - * make up the combo box.<p>
1122 - *
1123 - * Overriden to use a layout that has a fixed width arrow button.
1124 - *
1125 - * @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 -
1139 - /**
1140 - * Creates a ComboPopup that honors the optional combo popup display value
1141 - * that is used to compute the popup menu width.
1142 - */
1143 - protected ComboPopup createPopup() {
1144 - return new WindowsComboPopup(comboBox);
1145 - }
1146 -
1147 -
1148 - /**
1149 - * 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 - * explicitly set with <code>setRenderer</code>.<p>
1152 - *
1153 - * This method differs from the superclass implementation in that
1154 - * it uses an empty border with the default left and right text insets,
1155 - * the same as used by a combo box editor.
1156 - *
1157 - * @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 - // To make editable and non-editable equally wide,
1184 - // we always add 1 pixel.
1185 - size.width += 1;
1186 -
1187 - // 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 -
1201 - // The height is oriented on the JTextField height
1202 - Dimension textFieldSize = PHANTOM.getMinimumSize();
1203 - size.height = (LookUtils.IS_OS_WINDOWS_VISTA && !LookUtils.IS_LAF_WINDOWS_XP_ENABLED)
1204 - ? textFieldSize.height
1205 - : Math.max(textFieldSize.height, size.height);
1206 -
1207 - cachedMinimumSize.setSize(size.width, size.height);
1208 - isMinimumSizeDirty = false;
1209 -
1210 - 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 -
1222 - /**
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 -
1264 - 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 - WindowsUtils.drawRoundedDashedRect(g,
1297 - originalBounds.x+1, originalBounds.y+1,
1298 - 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 -
1313 - /**
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 - *
1319 - * 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 - *
1323 - * Custom renderers may set a hint to make their border removable.
1324 - * To do so, set the client property "isBorderRemovable"
1325 - * 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 - *
1329 - * @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 -
1343 -
1344 - private boolean isVistaXPStyleReadOnlyCombo() {
1345 - return LookUtils.IS_OS_WINDOWS_VISTA
1346 - && LookUtils.IS_LAF_WINDOWS_XP_ENABLED
1347 - && !comboBox.isEditable();
1348 - }
1349 -
1350 -
1351 - /**
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 -
1378 - // Helper Code ************************************************************
1379 -
1380 - /**
1381 - * Computes and returns the width of the arrow button in editable state.
1382 - *
1383 - * @return the width of the arrow button in editable state
1384 - */
1385 - private int getEditableButtonWidth() {
1386 - return UIManager.getInt("ScrollBar.width");
1387 - }
1388 -
1389 - /**
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 - *
1393 - * @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 -
1401 - // Collaborator Classes ***************************************************
1402 -
1403 - /**
1404 - * This layout manager handles the 'standard' layout of combo boxes.
1405 - * 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 - *
1408 - * Overriden to use a fixed arrow button width.
1409 - */
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 -
1443 - }
1444 -
1445 -
1446 - /**
1447 - * Differs from the BasicComboPopup in that it uses the standard
1448 - * 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 - * Calculates the placement and size of the popup portion
1458 - * of the combo box based on the combo box location and
1459 - * the enclosing screen bounds. If no transformations are required,
1460 - * then the returned rectangle will have the same values
1461 - * as the parameters.<p>
1462 - *
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 - * the JGoodies Windows L&amp;f implemented via a client property key.<p>
1467 - *
1468 - * 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 - * 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 - * @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 - *
1481 - * @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 - Rectangle defaultBounds = super.computePopupBounds(px, py, pw, ph);
1486 - Object popupPrototypeDisplayValue = comboBox.getClientProperty(
1487 - Options.COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY);
1488 - if (popupPrototypeDisplayValue == null) {
1489 - return defaultBounds;
1490 - }
1491 -
1492 - ListCellRenderer renderer = list.getCellRenderer();
1493 - Component c = renderer.getListCellRendererComponent(
1494 - list, popupPrototypeDisplayValue, -1, true, true);
1495 - pw = c.getPreferredSize().width;
1496 - boolean hasVerticalScrollBar =
1497 - 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 - }
1510 -
1511 -
1512 - // Handling Combo Changes *************************************************
1513 -
1514 - /**
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 --- a/src/core/com/jgoodies/looks/windows/WindowsFieldCaret.java
1533 +++ /dev/null
1534 @@ -1,367 +0,0 @@
1535 -/*
1536 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
1537 - *
1538 - * Redistribution and use in source and binary forms, with or without
1539 - * modification, are permitted provided that the following conditions are met:
1540 - *
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 - */
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 -import com.jgoodies.looks.Options;
1580 -
1581 -/**
1582 - * WindowsFieldCaret has different scrolling behavior than the DefaultCaret.
1583 - * Also, this caret is visible in non-editable fields,
1584 - * 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 - *
1587 - * @author Karsten Lentzsch
1588 - * @version $Revision: 1.10 $
1589 - *
1590 - */
1591 -final class WindowsFieldCaret extends DefaultCaret implements UIResource {
1592 -
1593 - private static final LayeredHighlighter.LayerPainter WindowsPainter =
1594 - 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 - final JTextComponent c = getComponent();
1609 - if (c.isEnabled()) {
1610 - setVisible(true);
1611 - setSelectionVisible(true);
1612 - }
1613 - if (!c.isEditable()) {
1614 - return;
1615 - }
1616 - if ( c.isEnabled()
1617 - && isKeyboardFocusEvent
1618 - && Options.isSelectOnFocusGainActive(c)) {
1619 - if (c instanceof JFormattedTextField) {
1620 - EventQueue.invokeLater(new Runnable() {
1621 - public void run() {
1622 - selectAll();
1623 - }
1624 - });
1625 - } else {
1626 - selectAll();
1627 - }
1628 - }
1629 - }
1630 -
1631 -
1632 - 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 - public void focusLost(FocusEvent e) {
1646 - super.focusLost(e);
1647 - if (!e.isTemporary()) {
1648 - isKeyboardFocusEvent = true;
1649 - if (Boolean.TRUE.equals(getComponent().getClientProperty(Options.SET_CARET_TO_START_ON_FOCUS_LOST_CLIENT_KEY))) {
1650 - setDot(0);
1651 - }
1652 - }
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 - // super.mousePressed() does not transfer focus on popup clicks.
1668 - // 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 - private final Rectangle r;
1746 - }
1747 -
1748 - // Helper Classes *********************************************************
1749 -
1750 - 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 --- a/src/core/com/jgoodies/looks/windows/WindowsFormattedTextFieldUI.java
1903 +++ /dev/null
1904 @@ -1,68 +0,0 @@
1905 -/*
1906 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
1907 - *
1908 - * Redistribution and use in source and binary forms, with or without
1909 - * modification, are permitted provided that the following conditions are met:
1910 - *
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 - */
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 - * It uses a caret that selects all text if the field gains focus
1945 - * after a keyboard focus traversal.
1946 - *
1947 - * @author Karsten Lentzsch
1948 - * @version $Revision: 1.4 $
1949 - */
1950 -public final class WindowsFormattedTextFieldUI extends BasicFormattedTextFieldUI {
1951 -
1952 - /**
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 --- a/src/core/com/jgoodies/looks/windows/WindowsIconFactory.java
1974 +++ /dev/null
1975 @@ -1,215 +0,0 @@
1976 -/*
1977 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
1978 - *
1979 - * Redistribution and use in source and binary forms, with or without
1980 - * modification, are permitted provided that the following conditions are met:
1981 - *
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 - */
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 -import javax.swing.*;
2013 -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 - * @version $Revision: 1.5 $
2020 - */
2021 -final class WindowsIconFactory {
2022 -
2023 - private WindowsIconFactory() {
2024 - // Overrides default constructor; prevents instantiation.
2025 - }
2026 -
2027 - // 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 -
2057 - // Paints the icon for a check box.
2058 - private static class CheckBoxIcon implements Icon, Serializable {
2059 -
2060 - private static final int SIZE = 13;
2061 -
2062 - public void paintIcon(Component c, Graphics g, int x, int y) {
2063 - JCheckBox cb = (JCheckBox) c;
2064 - ButtonModel model = cb.getModel();
2065 -
2066 - // 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 -
2073 - // 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 -
2078 - // 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 -
2083 - // 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 - // inside box
2092 - 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 -
2098 - g.setColor(UIManager.getColor(model.isEnabled()
2099 - ? "CheckBox.checkColor" // Modified by JGoodies
2100 - : "CheckBox.shadow"));
2101 -
2102 - // 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 -
2116 - public int getIconWidth() { return SIZE; }
2117 - public int getIconHeight() { return SIZE; }
2118 - }
2119 -
2120 -
2121 - // Paints the icon for a radio button.
2122 - private static class RadioButtonIcon implements Icon, UIResource, Serializable {
2123 -
2124 - 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 -
2130 - // 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 -
2137 -
2138 - // 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 -
2147 - // 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 -
2156 -
2157 - // 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 -
2166 -
2167 - // 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 -
2176 -
2177 - // 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 - }
2183 - }
2184 -
2185 - public int getIconWidth() { return SIZE; }
2186 - public int getIconHeight() { return SIZE; }
2187 -
2188 - }
2189 -
2190 -}
2191 \ No newline at end of file
2192 --- a/src/core/com/jgoodies/looks/windows/WindowsLookAndFeel.java
2193 +++ /dev/null
2194 @@ -1,759 +0,0 @@
2195 -/*
2196 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
2197 - *
2198 - * Redistribution and use in source and binary forms, with or without
2199 - * modification, are permitted provided that the following conditions are met:
2200 - *
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 - */
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 -import javax.swing.*;
2233 -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 - *
2251 - * @author Karsten Lentzsch
2252 - * @version $Revision: 1.39 $
2253 - */
2254 -public final class WindowsLookAndFeel extends com.sun.java.swing.plaf.windows.WindowsLookAndFeel {
2255 -
2256 - /**
2257 - * An optional client property key for JMenu and JToolBar
2258 - * to set a border style - shadows the header style.
2259 - */
2260 - public static final String BORDER_STYLE_KEY = "jgoodies.windows.borderStyle";
2261 -
2262 -
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 - public String getName() {
2271 - return "JGoodies Windows";
2272 - }
2273 -
2274 -
2275 - public String getDescription() {
2276 - return "The JGoodies Windows Look and Feel"
2277 - + " - \u00a9 2001-2008 JGoodies Karsten Lentzsch";
2278 - }
2279 -
2280 -
2281 - // Optional Settings ******************************************************
2282 -
2283 - /**
2284 - * Looks up and retrieves the FontPolicy used by
2285 - * the JGoodies Windows Look&amp;Feel.
2286 - * If a FontPolicy has been set for this look, it'll be returned.
2287 - * Otherwise, this method checks if a FontPolicy or FontSet is defined
2288 - * 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 - * properties or UIDefaults, the default Windows font policy
2291 - * will be returned.
2292 - *
2293 - * @return the FontPolicy set for this Look&amp;feel - if any,
2294 - * the FontPolicy specified in the system properties or UIDefaults
2295 - * - if any, or the default Windows font policy.
2296 - *
2297 - * @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 - FontPolicy policy =
2305 - (FontPolicy) UIManager.get(Options.WINDOWS_FONT_POLICY_KEY);
2306 - if (policy != null)
2307 - return policy;
2308 -
2309 - FontPolicy defaultPolicy = FontPolicies.getDefaultWindowsPolicy();
2310 - return FontPolicies.customSettingsPolicy(defaultPolicy);
2311 - }
2312 -
2313 -
2314 - /**
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 - *
2318 - * @param fontPolicy the FontPolicy to be used with the JGoodies Windows
2319 - * L&amp;F, or <code>null</code> to reset to the default
2320 - *
2321 - * @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 -
2329 - /**
2330 - * Looks up and retrieves the MicroLayoutPolicy used by
2331 - * the JGoodies Windows Look&amp;Feel.
2332 - * 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 - *
2335 - * @return the MicroLayoutPolicy set for this Look&amp;feel - if any,
2336 - * or the default Windows MicroLayoutPolicy.
2337 - *
2338 - * @see #setMicroLayoutPolicy
2339 - * @see Options#WINDOWS_MICRO_LAYOUT_POLICY_KEY
2340 - * @see MicroLayoutPolicies
2341 - * @see MicroLayoutPolicies#getDefaultWindowsPolicy()
2342 - */
2343 - public static MicroLayoutPolicy getMicroLayoutPolicy() {
2344 - MicroLayoutPolicy policy =
2345 - (MicroLayoutPolicy) UIManager.get(Options.WINDOWS_MICRO_LAYOUT_POLICY_KEY);
2346 - return policy != null
2347 - ? policy
2348 - : MicroLayoutPolicies.getDefaultWindowsPolicy();
2349 - }
2350 -
2351 -
2352 - /**
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 - *
2356 - * @param microLayoutPolicy the MicroLayoutPolicy to be used with
2357 - * the JGoodies Windows L&amp;F, or <code>null</code> to reset
2358 - * to the default
2359 - *
2360 - * @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 -
2368 - // Overriding Superclass Behavior ***************************************
2369 -
2370 - /**
2371 - * Invoked during <code>UIManager#setLookAndFeel</code>. In addition
2372 - * to the superclass behavior, we install the ShadowPopupFactory.
2373 - *
2374 - * @see #uninitialize
2375 - */
2376 - public void initialize() {
2377 - super.initialize();
2378 - ShadowPopupFactory.install();
2379 - }
2380 -
2381 -
2382 - /**
2383 - * Invoked during <code>UIManager#setLookAndFeel</code>. In addition
2384 - * to the superclass behavior, we uninstall the ShadowPopupFactory.
2385 - *
2386 - * @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 - *
2398 - * 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 - // Modified size
2424 - "ComboBoxUI", windowsPrefix + "ComboBoxUI",
2425 -
2426 - // Modified preferred height: can be even or odd
2427 - "ButtonUI", windowsPrefix + "ButtonUI",
2428 -
2429 - // Can installs an optional etched border
2430 - "ScrollPaneUI", windowsPrefix + "ScrollPaneUI",
2431 -
2432 - // Optional style and optional special borders
2433 - "MenuBarUI", windowsPrefix + "MenuBarUI",
2434 -
2435 - // Provides an option for a no margin border
2436 - "PopupMenuUI", windowsPrefix + "PopupMenuUI",
2437 -
2438 - // Honors the screen resolution and uses a minimum button width
2439 - "OptionPaneUI", windowsPrefix + "OptionPaneUI",
2440 -
2441 - // 1.4.1 has ugly one touch triangles
2442 - "SplitPaneUI", windowsPrefix + "SplitPaneUI",
2443 -
2444 - // Work in progress: Can have a flat presentation
2445 - "TabbedPaneUI", windowsPrefix + "TabbedPaneUI",
2446 -
2447 - // 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 - // Renders a dot, not the star ("*") character on Java 1.4 and 5
2453 - "PasswordFieldUI", windowsPrefix + "PasswordFieldUI",
2454 -
2455 -
2456 - // Updates the disabled and inactive background
2457 - "TextAreaUI", windowsPrefix + "TextAreaUI",
2458 -
2459 - // Corrected position of the tree button icon
2460 - "TreeUI", windowsPrefix + "TreeUI",
2461 -
2462 - // 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 - uiDefaults = append(uiDefaults,
2468 - "SpinnerUI", windowsPrefix + "SpinnerUI");
2469 - }
2470 -
2471 - // Aligned menu items
2472 - if ( !LookUtils.IS_JAVA_6_OR_LATER
2473 - || !LookUtils.IS_OS_WINDOWS_VISTA
2474 - || !LookUtils.IS_LAF_WINDOWS_XP_ENABLED) {
2475 - uiDefaults = append(uiDefaults,
2476 - "MenuItemUI", windowsPrefix + "MenuItemUI");
2477 - uiDefaults = append(uiDefaults,
2478 - "CheckBoxMenuItemUI", commonPrefix + "CheckBoxMenuItemUI");
2479 - uiDefaults = append(uiDefaults,
2480 - "RadioButtonMenuItemUI", commonPrefix + "RadioButtonMenuItemUI");
2481 - // Has padding above and below the separator lines
2482 - uiDefaults = append(uiDefaults,
2483 - "PopupMenuSeparatorUI", commonPrefix + "PopupMenuSeparatorUI");
2484 - }
2485 -
2486 - 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 -
2493 - // Optional style and optional special borders;
2494 - // rollover borders for compound buttons
2495 - uiDefaults = append(uiDefaults,
2496 - "ToolBarUI", windowsPrefix + "XPToolBarUI");
2497 -
2498 - // Honors XP table header style for custom user renderers.
2499 - uiDefaults = append(uiDefaults,
2500 - "TableHeaderUI", windowsPrefix + "XPTableHeaderUI");
2501 - } else {
2502 - // Aligned menu items
2503 - uiDefaults = append(uiDefaults,
2504 - "MenuUI", commonPrefix + "MenuUI");
2505 -
2506 - // Optional style and optional special borders;
2507 - // rollover borders corrected
2508 - uiDefaults = append(uiDefaults,
2509 - "ToolBarUI", windowsPrefix + "ToolBarUI");
2510 -
2511 - // Black arrows
2512 - uiDefaults = append(uiDefaults,
2513 - "ScrollBarUI", windowsPrefix + "ScrollBarUI");
2514 -
2515 - if (!LookUtils.IS_JAVA_1_4_2_OR_LATER) {
2516 - // Uses unmodified size specified by "ToolBar.separatorSize"
2517 - uiDefaults = append(uiDefaults,
2518 - "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 -
2530 - 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 -
2543 - 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 -
2558 - 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 -
2582 - 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 -
2588 - 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 -
2599 - Object comboBoxDisabledBackground = (isVista && isXP)
2600 - ? table.getColor("ComboBox.background")
2601 - : disabledTextBackground;
2602 -
2603 - Object menuBarBackground = isXP
2604 - ? table.get("control")
2605 - : 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 -
2613 - Character passwordEchoChar = new Character(isXP ? '\u25CF' : '*');
2614 -
2615 - Object[] defaults = {
2616 - "Button.border", buttonBorder,
2617 - "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 - "CheckBox.border", marginBorder,
2622 - "CheckBox.margin", checkBoxMargin,
2623 -
2624 - "ComboBox.disabledBackground", comboBoxDisabledBackground,
2625 - "ComboBox.editorBorder", marginBorder,
2626 - "ComboBox.editorColumns", new Integer(5),
2627 - "ComboBox.editorInsets", comboEditorInsets, // Added by JGoodies
2628 - "ComboBox.tableEditorInsets", comboTableEditorInsets,
2629 - "ComboBox.rendererBorder", comboRendererBorder, // Added by JGoodies
2630 -
2631 - "EditorPane.margin", wrappedTextInsets,
2632 -
2633 - // Begin 1.3 und 1.4.0
2634 - "Menu.border", menuBorder, // Fixed in 1.4.1
2635 - "Menu.borderPainted", Boolean.TRUE,
2636 - "Menu.background", menuBarBackground,
2637 - "Menu.selectionForeground", menuSelectionForeground,
2638 - "Menu.selectionBackground", menuSelectionBackground,
2639 - // End 1.3 und 1.4.0
2640 -
2641 - "MenuBar.background", menuBarBackground,
2642 - "MenuBar.border", menuBarSeparatorBorder, // 1.4.1 Separator wrong
2643 - "MenuBar.emptyBorder", menuBarEmptyBorder, // Added by JGoodies
2644 - "MenuBar.separatorBorder", menuBarSeparatorBorder, // Added by JGoodies
2645 - "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 -
2652 - "PasswordField.margin", textInsets, // Poor in 1.6
2653 - "PasswordField.echoChar", passwordEchoChar,
2654 -
2655 - "PopupMenu.border", WindowsBorders.getPopupMenuBorder(),
2656 - "PopupMenu.noMarginBorder", WindowsBorders.getNoMarginPopupMenuBorder(),
2657 - "PopupMenuSeparator.margin", popupMenuSeparatorMargin,
2658 -
2659 - "ScrollPane.etchedBorder", etchedBorder, // Added by JGoodies
2660 -
2661 - "Spinner.defaultEditorInsets", textInsets, // Added by JGoodies
2662 -
2663 - // 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 - "RadioButton.border", marginBorder,
2666 - "RadioButton.margin", checkBoxMargin,
2667 -
2668 - "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 - "ToolBar.separatorSize", toolBarSeparatorSize,
2680 - "ToolBar.margin", new InsetsUIResource(0, 10, 0, 0),
2681 -
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 - : makeIcon(superclass, "icons/Inform.gif"),
2692 - "OptionPane.warningIcon", isXP ? makeIcon(getClass(), "icons/xp/Warn.png")
2693 - : makeIcon(superclass, "icons/Warn.gif"),
2694 - "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 - "CheckBox.icon", checkBoxIcon,
2735 - "RadioButton.checkColor", table.get("controlText"), // kind-of black
2736 - "RadioButton.icon", radioButtonIcon,
2737 - "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 -
2762 -
2763 - 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 - "MenuItem.borderPainted", Boolean.TRUE,
2772 - "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 -
2781 - /**
2782 - * Sets Fonts in the given FontSet as defaults for all known
2783 - * component types in the given UIDefaults table.
2784 - *
2785 - * @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 -
2796 - 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 - "TextArea.font", controlFont,
2815 - "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 -
2844 - // 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 -
2858 -
2859 - // Helper Code ************************************************************
2860 -
2861 - /**
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 - *
2865 - * @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 - *
2881 - * @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 - // Helper Class ***********************************************************
2894 -
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 - *
2914 - * @param c a <code>String</code> specifying the classname of the class
2915 - * containing a static method to be called for instance creation
2916 - * @param m a <code>String</code> specifying the static
2917 - * 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 --- a/src/core/com/jgoodies/looks/windows/WindowsMenuBarUI.java
2956 +++ /dev/null
2957 @@ -1,126 +0,0 @@
2958 -/*
2959 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
2960 - *
2961 - * Redistribution and use in source and binary forms, with or without
2962 - * modification, are permitted provided that the following conditions are met:
2963 - *
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 - */
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 - *
3004 - * Can handle optional <code>Border</code> types as specified by the
3005 - * <code>BorderStyle</code> or <code>HeaderStyle</code> client properties.
3006 - *
3007 - * @author Karsten Lentzsch
3008 - * @version $Revision: 1.5 $
3009 - */
3010 -public final class WindowsMenuBarUI extends com.sun.java.swing.plaf.windows.WindowsMenuBarUI {
3011 -
3012 - private PropertyChangeListener listener;
3013 -
3014 -
3015 - public static ComponentUI createUI(JComponent b) {
3016 - return new WindowsMenuBarUI();
3017 - }
3018 -
3019 -
3020 - // Handling Special Borders *********************************************************
3021 -
3022 - protected void installDefaults() {
3023 - super.installDefaults();
3024 - installSpecialBorder();
3025 - }
3026 -
3027 -
3028 - protected void installListeners() {
3029 - super.installListeners();
3030 - listener = createBorderStyleListener();
3031 - menuBar.addPropertyChangeListener(listener);
3032 - }
3033 -
3034 -
3035 - protected void uninstallListeners() {
3036 - menuBar.removePropertyChangeListener(listener);
3037 - super.uninstallListeners();
3038 - }
3039 -
3040 -
3041 - private PropertyChangeListener createBorderStyleListener() {
3042 - return new PropertyChangeListener() {
3043 -
3044 - public void propertyChange(PropertyChangeEvent e) {
3045 - String prop = e.getPropertyName();
3046 - if (prop.equals(Options.HEADER_STYLE_KEY) ||
3047 - prop.equals(WindowsLookAndFeel.BORDER_STYLE_KEY)) {
3048 - WindowsMenuBarUI.this.installSpecialBorder();
3049 - }
3050 - }
3051 -
3052 - };
3053 - }
3054 -
3055 -
3056 - /**
3057 - * Installs a special border, if either a look-dependent
3058 - * <code>BorderStyle</code> or a look-independent
3059 - * <code>HeaderStyle</code> has been specified.
3060 - * A look specific BorderStyle shadows
3061 - * a HeaderStyle.<p>
3062 - *
3063 - * Specifying a HeaderStyle is recommend.
3064 - */
3065 - private void installSpecialBorder() {
3066 - String suffix;
3067 - BorderStyle borderStyle = BorderStyle.from(menuBar,
3068 - 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 -
3080 - LookAndFeel.installBorder(menuBar, "MenuBar." + suffix);
3081 - }
3082 -
3083 -}
3084 \ No newline at end of file
3085 --- a/src/core/com/jgoodies/looks/windows/WindowsMenuItemRenderer.java
3086 +++ /dev/null
3087 @@ -1,77 +0,0 @@
3088 -/*
3089 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3090 - *
3091 - * Redistribution and use in source and binary forms, with or without
3092 - * modification, are permitted provided that the following conditions are met:
3093 - *
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 - */
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 - *
3134 - * @author Karsten Lentzsch
3135 - * @version $Revision: 1.4 $
3136 - */
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 -
3152 -
3153 - protected boolean isMnemonicHidden() {
3154 - return WindowsLookAndFeel.isMnemonicHidden();
3155 - }
3156 -
3157 -
3158 - protected boolean disabledTextHasShadow() {
3159 - return (!LookUtils.IS_LAF_WINDOWS_XP_ENABLED)
3160 - || (UIManager.getColor("MenuItem.disabledForeground") == null);
3161 - }
3162 -
3163 -
3164 -}
3165 \ No newline at end of file
3166 --- a/src/core/com/jgoodies/looks/windows/WindowsMenuItemUI.java
3167 +++ /dev/null
3168 @@ -1,80 +0,0 @@
3169 -/*
3170 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3171 - *
3172 - * Redistribution and use in source and binary forms, with or without
3173 - * modification, are permitted provided that the following conditions are met:
3174 - *
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 - */
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 - *
3214 - * 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 - * @version $Revision: 1.4 $
3220 - */
3221 -public final class WindowsMenuItemUI extends ExtBasicMenuItemUI {
3222 -
3223 -
3224 - public static ComponentUI createUI(JComponent b) {
3225 - return new WindowsMenuItemUI();
3226 - }
3227 -
3228 -
3229 - protected MenuItemRenderer createRenderer(
3230 - JMenuItem menuItem,
3231 - 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 - acceleratorSelectionForeground);
3245 - }
3246 -
3247 -
3248 -}
3249 \ No newline at end of file
3250 --- a/src/core/com/jgoodies/looks/windows/WindowsOptionPaneUI.java
3251 +++ /dev/null
3252 @@ -1,68 +0,0 @@
3253 -/*
3254 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3255 - *
3256 - * Redistribution and use in source and binary forms, with or without
3257 - * modification, are permitted provided that the following conditions are met:
3258 - *
3259 - * o Redistributions of source code must retain the above copyright notice,
3260 - * this list of conditions and the following disclaimer.
3261 - *
3262 - * o Redistributions in binary form must reproduce the above copyright notice,
3263 - * this list of conditions and the following disclaimer in the documentation
3264 - * and/or other materials provided with the distribution.
3265 - *
3266 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3267 - * its contributors may be used to endorse or promote products derived
3268 - * from this software without specific prior written permission.
3269 - *
3270 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3271 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3272 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3273 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3274 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3275 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3276 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3277 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3278 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3279 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3280 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3281 - */
3282 -
3283 -package com.jgoodies.looks.windows;
3284 -
3285 -import java.awt.Container;
3286 -
3287 -import javax.swing.JComponent;
3288 -import javax.swing.JPanel;
3289 -import javax.swing.UIManager;
3290 -import javax.swing.plaf.ComponentUI;
3291 -import javax.swing.plaf.basic.BasicOptionPaneUI;
3292 -
3293 -import com.jgoodies.looks.common.ExtButtonAreaLayout;
3294 -
3295 -/**
3296 - * The JGoodies Windows Look&amp;Feel implementation of
3297 - * <code>OptionPaneUI</code>. Honors the screen resolution and uses a
3298 - * minimum button with that complies better with the Windows UI style guide.
3299 - *
3300 - * @author Karsten Lentzsch
3301 - * @version $Revision: 1.5 $
3302 - */
3303 -public final class WindowsOptionPaneUI extends BasicOptionPaneUI {
3304 -
3305 - public static ComponentUI createUI(JComponent b) {
3306 - return new WindowsOptionPaneUI();
3307 - }
3308 -
3309 - /**
3310 - * Creates and returns a Container containin the buttons. The buttons
3311 - * are created by calling <code>getButtons</code>.
3312 - */
3313 - protected Container createButtonArea() {
3314 - JPanel bottom = new JPanel(new ExtButtonAreaLayout(true, 6));
3315 - bottom.setBorder(UIManager.getBorder("OptionPane.buttonAreaBorder"));
3316 - addButtonComponents(bottom, getButtons(), getInitialValueIndex());
3317 - return bottom;
3318 - }
3319 -
3320 -}
3321 \ No newline at end of file
3322 --- a/src/core/com/jgoodies/looks/windows/WindowsPasswordFieldUI.java
3323 +++ /dev/null
3324 @@ -1,102 +0,0 @@
3325 -/*
3326 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3327 - *
3328 - * Redistribution and use in source and binary forms, with or without
3329 - * modification, are permitted provided that the following conditions are met:
3330 - *
3331 - * o Redistributions of source code must retain the above copyright notice,
3332 - * this list of conditions and the following disclaimer.
3333 - *
3334 - * o Redistributions in binary form must reproduce the above copyright notice,
3335 - * this list of conditions and the following disclaimer in the documentation
3336 - * and/or other materials provided with the distribution.
3337 - *
3338 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3339 - * its contributors may be used to endorse or promote products derived
3340 - * from this software without specific prior written permission.
3341 - *
3342 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3343 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3344 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3345 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3346 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3347 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3348 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3349 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3350 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3351 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3352 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3353 - */
3354 -
3355 -package com.jgoodies.looks.windows;
3356 -
3357 -
3358 -import javax.swing.JComponent;
3359 -import javax.swing.JPasswordField;
3360 -import javax.swing.plaf.ComponentUI;
3361 -import javax.swing.text.Caret;
3362 -import javax.swing.text.Element;
3363 -import javax.swing.text.View;
3364 -
3365 -import com.jgoodies.looks.LookUtils;
3366 -import com.jgoodies.looks.common.ExtPasswordView;
3367 -
3368 -/**
3369 - * The JGoodies Windows Look&amp;Feel implementation of a password field UI
3370 - * delegate. It differs from its superclass in that it utilizes a password
3371 - * view that renders a customizable echo char, not a star (&quot;*&quot;).
3372 - *
3373 - * Used for Java 1.4 and Java 5.
3374 - *
3375 - * @author Karsten Lentzsch
3376 - * @version $Revision: 1.5 $
3377 - */
3378 -public final class WindowsPasswordFieldUI extends com.sun.java.swing.plaf.windows.WindowsPasswordFieldUI {
3379 -
3380 - /**
3381 - * Creates a UI for a {@link JPasswordField}.
3382 - *
3383 - * @param c the password field component
3384 - * @return the UI
3385 - */
3386 - public static ComponentUI createUI(JComponent c) {
3387 - return new WindowsPasswordFieldUI();
3388 - }
3389 -
3390 - /*
3391 - * We'd like to just set the dot as echo character.
3392 - * But the JPasswordField (in Java 1.4 and Java 5)
3393 - * installs the UI in a superclass and then sets the echo character.
3394 - * The latter would override our call to #setEchoChar.
3395 - */
3396 -// protected void installDefaults() {
3397 -// super.installDefaults();
3398 -// JPasswordField field = (JPasswordField) getComponent();
3399 -// field.setEchoChar('\u25CF');
3400 -// }
3401 -
3402 -
3403 - /**
3404 - * Creates and returns a view (an <code>ExtPasswordView</code>) for an element.
3405 - *
3406 - * @param elem the element
3407 - * @return the view
3408 - */
3409 - public View create(Element elem) {
3410 - return (LookUtils.IS_JAVA_1_4_OR_5)
3411 - ? new ExtPasswordView(elem)
3412 - : super.create(elem);
3413 - }
3414 -
3415 -
3416 - /**
3417 - * Creates the caret for a field.
3418 - *
3419 - * @return the caret
3420 - */
3421 - protected Caret createCaret() {
3422 - return new WindowsFieldCaret();
3423 - }
3424 -
3425 -
3426 -}
3427 \ No newline at end of file
3428 --- a/src/core/com/jgoodies/looks/windows/WindowsPopupMenuUI.java
3429 +++ /dev/null
3430 @@ -1,110 +0,0 @@
3431 -/*
3432 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3433 - *
3434 - * Redistribution and use in source and binary forms, with or without
3435 - * modification, are permitted provided that the following conditions are met:
3436 - *
3437 - * o Redistributions of source code must retain the above copyright notice,
3438 - * this list of conditions and the following disclaimer.
3439 - *
3440 - * o Redistributions in binary form must reproduce the above copyright notice,
3441 - * this list of conditions and the following disclaimer in the documentation
3442 - * and/or other materials provided with the distribution.
3443 - *
3444 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3445 - * its contributors may be used to endorse or promote products derived
3446 - * from this software without specific prior written permission.
3447 - *
3448 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3449 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3450 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3451 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3452 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3453 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3454 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3455 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3456 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3457 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3458 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3459 - */
3460 -
3461 -package com.jgoodies.looks.windows;
3462 -
3463 -import java.beans.PropertyChangeEvent;
3464 -import java.beans.PropertyChangeListener;
3465 -
3466 -import javax.swing.BoxLayout;
3467 -import javax.swing.JComponent;
3468 -import javax.swing.LookAndFeel;
3469 -import javax.swing.plaf.ComponentUI;
3470 -import javax.swing.plaf.UIResource;
3471 -
3472 -import com.jgoodies.looks.Options;
3473 -import com.jgoodies.looks.common.PopupMenuLayout;
3474 -
3475 -/**
3476 - * The JGoodies Windows look&amp;feel implementation of <code>PopMenuUI</code>.
3477 - * It differs from the superclass in that it provides an option to get a
3478 - * narrow border. You can set a client property
3479 - * {@link Options#NO_MARGIN_KEY} to indicate that this popup menu
3480 - * has a border without margin. That is useful in the special case
3481 - * where the popup contains only a single component, for example
3482 - * a JScrollPane.
3483 - *
3484 - * @author Karsten Lentzsch
3485 - * @version $Revision: 1.6 $
3486 - *
3487 - * @see com.jgoodies.looks.Options#NO_MARGIN_KEY
3488 - */
3489 -public final class WindowsPopupMenuUI extends com.sun.java.swing.plaf.windows.WindowsPopupMenuUI {
3490 -
3491 - private PropertyChangeListener borderListener;
3492 -
3493 - public static ComponentUI createUI(JComponent b) {
3494 - return new WindowsPopupMenuUI();
3495 - }
3496 -
3497 -
3498 - public void installDefaults() {
3499 - super.installDefaults();
3500 - installBorder();
3501 - if ( (popupMenu.getLayout() == null)
3502 - || (popupMenu.getLayout() instanceof UIResource)) {
3503 - popupMenu.setLayout(new PopupMenuLayout(popupMenu, BoxLayout.Y_AXIS));
3504 - }
3505 - }
3506 -
3507 - public void installListeners() {
3508 - super.installListeners();
3509 - borderListener = new BorderStyleChangeHandler();
3510 - popupMenu.addPropertyChangeListener(Options.NO_MARGIN_KEY, borderListener);
3511 - }
3512 -
3513 - protected void uninstallListeners() {
3514 - popupMenu.removePropertyChangeListener(Options.NO_MARGIN_KEY, borderListener);
3515 - super.uninstallListeners();
3516 - }
3517 -
3518 - // Narrow Border **********************************************************
3519 -
3520 - private final class BorderStyleChangeHandler implements PropertyChangeListener {
3521 -
3522 - public void propertyChange(PropertyChangeEvent e) {
3523 - installBorder();
3524 - }
3525 -
3526 - }
3527 -
3528 - /**
3529 - * Installs a border without margin, iff the client property
3530 - * <code>Options.NO_MARGIN_KEY</code> is set to <code>Boolean.TRUE</code>.
3531 - */
3532 - private void installBorder() {
3533 - boolean useNarrowBorder = Boolean.TRUE.equals(
3534 - popupMenu.getClientProperty(Options.NO_MARGIN_KEY));
3535 - String suffix = useNarrowBorder ? "noMarginBorder" : "border";
3536 - LookAndFeel.installBorder(popupMenu, "PopupMenu." + suffix);
3537 - }
3538 -
3539 -
3540 -}
3541 \ No newline at end of file
3542 --- a/src/core/com/jgoodies/looks/windows/WindowsScrollBarUI.java
3543 +++ /dev/null
3544 @@ -1,63 +0,0 @@
3545 -/*
3546 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3547 - *
3548 - * Redistribution and use in source and binary forms, with or without
3549 - * modification, are permitted provided that the following conditions are met:
3550 - *
3551 - * o Redistributions of source code must retain the above copyright notice,
3552 - * this list of conditions and the following disclaimer.
3553 - *
3554 - * o Redistributions in binary form must reproduce the above copyright notice,
3555 - * this list of conditions and the following disclaimer in the documentation
3556 - * and/or other materials provided with the distribution.
3557 - *
3558 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3559 - * its contributors may be used to endorse or promote products derived
3560 - * from this software without specific prior written permission.
3561 - *
3562 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3563 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3564 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3565 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3566 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3567 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3568 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3569 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3570 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3571 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3572 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3573 - */
3574 -
3575 -package com.jgoodies.looks.windows;
3576 -
3577 -import javax.swing.JButton;
3578 -import javax.swing.JComponent;
3579 -import javax.swing.plaf.ComponentUI;
3580 -
3581 -/**
3582 - * The JGoodies Windows L&amp;F implementation of* <code>ScrollBarUI</code>.
3583 - * It differs from Sun's Windows Look in that it paints black button triangles
3584 - * and that it honors the <code>ScrollBar.width</code> property to determine
3585 - * the preferred size.
3586 - *
3587 - * @author Karsten Lentzsch
3588 - * @version $Revision: 1.5 $
3589 - */
3590 -public final class WindowsScrollBarUI extends com.sun.java.swing.plaf.windows.WindowsScrollBarUI {
3591 -
3592 - public static ComponentUI createUI(JComponent b) {
3593 - return new WindowsScrollBarUI();
3594 - }
3595 -
3596 -
3597 - protected JButton createDecreaseButton(int orientation) {
3598 - return new WindowsArrowButton(orientation);
3599 - }
3600 -
3601 -
3602 - protected JButton createIncreaseButton(int orientation) {
3603 - return createDecreaseButton(orientation);
3604 - }
3605 -
3606 -
3607 -}
3608 \ No newline at end of file
3609 --- a/src/core/com/jgoodies/looks/windows/WindowsScrollPaneUI.java
3610 +++ /dev/null
3611 @@ -1,99 +0,0 @@
3612 -/*
3613 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3614 - *
3615 - * Redistribution and use in source and binary forms, with or without
3616 - * modification, are permitted provided that the following conditions are met:
3617 - *
3618 - * o Redistributions of source code must retain the above copyright notice,
3619 - * this list of conditions and the following disclaimer.
3620 - *
3621 - * o Redistributions in binary form must reproduce the above copyright notice,
3622 - * this list of conditions and the following disclaimer in the documentation
3623 - * and/or other materials provided with the distribution.
3624 - *
3625 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3626 - * its contributors may be used to endorse or promote products derived
3627 - * from this software without specific prior written permission.
3628 - *
3629 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3630 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3631 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3632 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3633 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3634 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3635 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3636 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3637 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3638 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3639 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3640 - */
3641 -
3642 -package com.jgoodies.looks.windows;
3643 -
3644 -import java.beans.PropertyChangeEvent;
3645 -import java.beans.PropertyChangeListener;
3646 -
3647 -import javax.swing.JComponent;
3648 -import javax.swing.JScrollPane;
3649 -import javax.swing.LookAndFeel;
3650 -import javax.swing.plaf.ComponentUI;
3651 -
3652 -import com.jgoodies.looks.Options;
3653 -
3654 -/**
3655 - * The JGoodies Windows L&amp;F implementation of <code>ScrollPaneUI</code>.
3656 - * Installs an etched border if the client property
3657 - * <code>Options.IS_ETCHED_KEY</code> is set.
3658 - *
3659 - * @author Karsten Lentzsch
3660 - * @version $Revision: 1.5 $
3661 - *
3662 - * @see com.jgoodies.looks.Options#IS_ETCHED_KEY
3663 - */
3664 -public final class WindowsScrollPaneUI extends com.sun.java.swing.plaf.windows.WindowsScrollPaneUI {
3665 -
3666 - private PropertyChangeListener borderStyleChangeHandler;
3667 -
3668 - public static ComponentUI createUI(JComponent b) {
3669 - return new WindowsScrollPaneUI();
3670 - }
3671 -
3672 - protected void installDefaults(JScrollPane scrollPane) {
3673 - super.installDefaults(scrollPane);
3674 - installEtchedBorder(scrollPane);
3675 - }
3676 -
3677 - protected void installEtchedBorder(JScrollPane scrollPane) {
3678 - Object value = scrollPane.getClientProperty(Options.IS_ETCHED_KEY);
3679 - boolean hasEtchedBorder = Boolean.TRUE.equals(value);
3680 - LookAndFeel.installBorder(scrollPane,
3681 - hasEtchedBorder
3682 - ? "ScrollPane.etchedBorder"
3683 - : "ScrollPane.border");
3684 - }
3685 -
3686 -
3687 - // Managing the Etched Property *******************************************
3688 -
3689 - public void installListeners(JScrollPane scrollPane) {
3690 - super.installListeners(scrollPane);
3691 - borderStyleChangeHandler = new BorderStyleChangeHandler();
3692 - scrollPane.addPropertyChangeListener(Options.IS_ETCHED_KEY, borderStyleChangeHandler);
3693 - }
3694 -
3695 - protected void uninstallListeners(JComponent c) {
3696 - ((JScrollPane) c).removePropertyChangeListener(Options.IS_ETCHED_KEY,
3697 - borderStyleChangeHandler);
3698 - super.uninstallListeners(c);
3699 - }
3700 -
3701 - private class BorderStyleChangeHandler implements PropertyChangeListener {
3702 -
3703 - public void propertyChange(PropertyChangeEvent evt) {
3704 - JScrollPane scrollPane = (JScrollPane) evt.getSource();
3705 - installEtchedBorder(scrollPane);
3706 - }
3707 -
3708 - }
3709 -
3710 -}
3711 \ No newline at end of file
3712 --- a/src/core/com/jgoodies/looks/windows/WindowsSeparatorUI.java
3713 +++ /dev/null
3714 @@ -1,57 +0,0 @@
3715 -/*
3716 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3717 - *
3718 - * Redistribution and use in source and binary forms, with or without
3719 - * modification, are permitted provided that the following conditions are met:
3720 - *
3721 - * o Redistributions of source code must retain the above copyright notice,
3722 - * this list of conditions and the following disclaimer.
3723 - *
3724 - * o Redistributions in binary form must reproduce the above copyright notice,
3725 - * this list of conditions and the following disclaimer in the documentation
3726 - * and/or other materials provided with the distribution.
3727 - *
3728 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3729 - * its contributors may be used to endorse or promote products derived
3730 - * from this software without specific prior written permission.
3731 - *
3732 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3733 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3734 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3735 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3736 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3737 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3738 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3739 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3740 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3741 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3742 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3743 - */
3744 -
3745 -package com.jgoodies.looks.windows;
3746 -
3747 -import javax.swing.JComponent;
3748 -import javax.swing.plaf.ComponentUI;
3749 -import javax.swing.plaf.basic.BasicSeparatorUI;
3750 -
3751 -
3752 -/**
3753 - * The JGoodies Windows L&amp;F implementation of <code>SeparatorUI</code>.
3754 - * It differs from its superclass in that it uses a shared UI delegate.
3755 - *
3756 - * @author Andrej Golovnin
3757 - * @version $Revision: 1.5 $
3758 - */
3759 -public final class WindowsSeparatorUI extends BasicSeparatorUI {
3760 -
3761 - /** Shared UI object. */
3762 - private static ComponentUI separatorUI;
3763 -
3764 - public static ComponentUI createUI(JComponent c) {
3765 - if (separatorUI == null) {
3766 - separatorUI = new WindowsSeparatorUI();
3767 - }
3768 - return separatorUI;
3769 - }
3770 -
3771 -}
3772 --- a/src/core/com/jgoodies/looks/windows/WindowsSpinnerUI.java
3773 +++ /dev/null
3774 @@ -1,209 +0,0 @@
3775 -/*
3776 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3777 - *
3778 - * Redistribution and use in source and binary forms, with or without
3779 - * modification, are permitted provided that the following conditions are met:
3780 - *
3781 - * o Redistributions of source code must retain the above copyright notice,
3782 - * this list of conditions and the following disclaimer.
3783 - *
3784 - * o Redistributions in binary form must reproduce the above copyright notice,
3785 - * this list of conditions and the following disclaimer in the documentation
3786 - * and/or other materials provided with the distribution.
3787 - *
3788 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
3789 - * its contributors may be used to endorse or promote products derived
3790 - * from this software without specific prior written permission.
3791 - *
3792 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3793 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
3794 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3795 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3796 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3797 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3798 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
3799 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3800 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3801 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3802 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3803 - */
3804 -
3805 -package com.jgoodies.looks.windows;
3806 -
3807 -import java.awt.Component;
3808 -import java.awt.Insets;
3809 -import java.awt.LayoutManager;
3810 -
3811 -import javax.swing.*;
3812 -import javax.swing.border.EmptyBorder;
3813 -import javax.swing.plaf.ComponentUI;
3814 -
3815 -import com.jgoodies.looks.LookUtils;
3816 -import com.jgoodies.looks.common.ExtBasicArrowButtonHandler;
3817 -import com.jgoodies.looks.common.ExtBasicSpinnerLayout;
3818 -
3819 -/**
3820 - * The JGoodies Windows L&amp;F implementation of <code>SpinnerUI</code>.
3821 - * Configures the default editor to adjust font baselines and component
3822 - * bounds, by setting an empty border with the default text insets.
3823 - *
3824 - * @author Karsten Lentzsch
3825 - * @version $Revision: 1.6 $
3826 - */
3827 -public final class WindowsSpinnerUI extends com.sun.java.swing.plaf.windows.WindowsSpinnerUI {
3828 -
3829 -
3830 - public static ComponentUI createUI(JComponent b) {
3831 - return new WindowsSpinnerUI();
3832 - }
3833 -
3834 - /**
3835 - * The mouse/action listeners that are added to the spinner's arrow
3836 - * buttons. These listeners are shared by all spinner arrow buttons.
3837 - *
3838 - * @see #createNextButton
3839 - * @see #createPreviousButton
3840 - */
3841 - private static final ExtBasicArrowButtonHandler NEXT_BUTTON_HANDLER =
3842 - new ExtBasicArrowButtonHandler("increment", true);
3843 - private static final ExtBasicArrowButtonHandler PREVIOUS_BUTTON_HANDLER =
3844 - new ExtBasicArrowButtonHandler("decrement", false);
3845 -
3846 -
3847 - /**
3848 - * Create a component that will replace the spinner models value with the
3849 - * object returned by <code>spinner.getPreviousValue</code>. By default
3850 - * the <code>previousButton</code> is a JButton who's <code>ActionListener</code>
3851 - * updates it's <code>JSpinner</code> ancestors model. If a
3852 - * previousButton isn't needed (in a subclass) then override this method to
3853 - * return null.
3854 - *
3855 - * @return a component that will replace the spinners model with the next
3856 - * value in the sequence, or null
3857 - * @see #installUI
3858 - * @see #createNextButton
3859 - */
3860 - protected Component createPreviousButton() {
3861 - if (LookUtils.IS_LAF_WINDOWS_XP_ENABLED)
3862 - return super.createPreviousButton();
3863 -
3864 - JButton b = new WindowsArrowButton(SwingConstants.SOUTH);
3865 - b.addActionListener(PREVIOUS_BUTTON_HANDLER);
3866 - b.addMouseListener(PREVIOUS_BUTTON_HANDLER);
3867 - return b;
3868 - }
3869 -
3870 -
3871 - /**
3872 - * Create a component that will replace the spinner models value with the
3873 - * object returned by <code>spinner.getNextValue</code>. By default the
3874 - * <code>nextButton</code> is a JButton who's <code>ActionListener</code>
3875 - * updates it's <code>JSpinner</code> ancestors model. If a nextButton
3876 - * isn't needed (in a subclass) then override this method to return null.
3877 - *
3878 - * @return a component that will replace the spinners model with the next
3879 - * value in the sequence, or null
3880 - * @see #installUI
3881 - * @see #createPreviousButton
3882 - */
3883 - protected Component createNextButton() {
3884 - if (LookUtils.IS_LAF_WINDOWS_XP_ENABLED)
3885 - return super.createNextButton();
3886 -
3887 - JButton b = new WindowsArrowButton(SwingConstants.NORTH);
3888 - b.addActionListener(NEXT_BUTTON_HANDLER);
3889 - b.addMouseListener(NEXT_BUTTON_HANDLER);
3890 - return b;
3891 - }
3892 -
3893 -
3894 - /**
3895 - * This method is called by installUI to get the editor component of the
3896 - * <code>JSpinner</code>. By default it just returns <code>JSpinner.getEditor()</code>.
3897 - * Subclasses can override <code>createEditor</code> to return a
3898 - * component that contains the spinner's editor or null, if they're going
3899 - * to handle adding the editor to the <code>JSpinner</code> in an <code>installUI</code>
3900 - * override.
3901 - * <p>
3902 - * Typically this method would be overridden to wrap the editor with a
3903 - * container with a custom border, since one can't assume that the editors
3904 - * border can be set directly.
3905 - * <p>
3906 - * The <code>replaceEditor</code> method is called when the spinners
3907 - * editor is changed with <code>JSpinner.setEditor</code>. If you've
3908 - * overriden this method, then you'll probably want to override <code>replaceEditor</code>
3909 - * as well.
3910 - *
3911 - * @return the JSpinners editor JComponent, spinner.getEditor() by default
3912 - * @see #installUI
3913 - * @see #replaceEditor
3914 - * @see JSpinner#getEditor
3915 - */
3916 - protected JComponent createEditor() {
3917 - JComponent editor = spinner.getEditor();
3918 - configureEditorBorder(editor);
3919 - return editor;
3920 - }
3921 -
3922 -
3923 - /**
3924 - * Create a <code>LayoutManager</code> that manages the <code>editor</code>,
3925 - * <code>nextButton</code>, and <code>previousButton</code> children
3926 - * of the JSpinner. These three children must be added with a constraint
3927 - * that identifies their role: "Editor", "Next", and "Previous". The
3928 - * default layout manager can handle the absence of any of these children.
3929 - *
3930 - * @return a LayoutManager for the editor, next button, and previous
3931 - * button.
3932 - * @see #createNextButton
3933 - * @see #createPreviousButton
3934 - * @see #createEditor
3935 - */
3936 - protected LayoutManager createLayout() {
3937 - return new ExtBasicSpinnerLayout();
3938 - }
3939 -
3940 -
3941 - /**
3942 - * Called by the <code>PropertyChangeListener</code> when the <code>JSpinner</code>
3943 - * editor property changes. It's the responsibility of this method to
3944 - * remove the old editor and add the new one. By default this operation is
3945 - * just:
3946 - *
3947 - * <pre>
3948 - * spinner.remove(oldEditor); spinner.add(newEditor, "Editor");
3949 - * </pre>
3950 - *
3951 - *
3952 - * The implementation of <code>replaceEditor</code> should be coordinated
3953 - * with the <code>createEditor</code> method.
3954 - *
3955 - * @see #createEditor
3956 - * @see #createPropertyChangeListener
3957 - */
3958 - protected void replaceEditor(JComponent oldEditor, JComponent newEditor) {
3959 - spinner.remove(oldEditor);
3960 - configureEditorBorder(newEditor);
3961 - spinner.add(newEditor, "Editor");
3962 - }
3963 -
3964 -
3965 - /**
3966 - * Sets an empty border with consistent insets.
3967 - */
3968 - private void configureEditorBorder(JComponent editor) {
3969 - if ((editor instanceof JSpinner.DefaultEditor)) {
3970 - JSpinner.DefaultEditor defaultEditor = (JSpinner.DefaultEditor) editor;
3971 - JTextField editorField = defaultEditor.getTextField();
3972 - Insets insets = UIManager.getInsets("Spinner.defaultEditorInsets");
3973 - editorField.setBorder(new EmptyBorder(insets));
3974 - } else if ( (editor instanceof JPanel)
3975 - && (editor.getBorder() == null)
3976 - && (editor.getComponentCount() > 0)) {
3977 - JComponent editorField = (JComponent) editor.getComponent(0);
3978 - Insets insets = UIManager.getInsets("Spinner.defaultEditorInsets");
3979 - editorField.setBorder(new EmptyBorder(insets));
3980 - }
3981 - }
3982 -
3983 -}
3984 --- a/src/core/com/jgoodies/looks/windows/WindowsSplitPaneDivider.java
3985 +++ /dev/null
3986 @@ -1,347 +0,0 @@
3987 -/*
3988 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
3989 - *
3990 - * Redistribution and use in source and binary forms, with or without
3991 - * modification, are permitted provided that the following conditions are met:
3992 - *
3993 - * o Redistributions of source code must retain the above copyright notice,
3994 - * this list of conditions and the following disclaimer.
3995 - *
3996 - * o Redistributions in binary form must reproduce the above copyright notice,
3997 - * this list of conditions and the following disclaimer in the documentation
3998 - * and/or other materials provided with the distribution.
3999 - *
4000 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
4001 - * its contributors may be used to endorse or promote products derived
4002 - * from this software without specific prior written permission.
4003 - *
4004 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4005 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
4006 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4007 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
4008 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4009 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
4010 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
4011 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
4012 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
4013 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4014 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4015 - */
4016 -
4017 -package com.jgoodies.looks.windows;
4018 -
4019 -import java.awt.*;
4020 -
4021 -import javax.swing.JButton;
4022 -import javax.swing.JSplitPane;
4023 -import javax.swing.UIManager;
4024 -import javax.swing.border.Border;
4025 -import javax.swing.plaf.basic.BasicSplitPaneDivider;
4026 -import javax.swing.plaf.basic.BasicSplitPaneUI;
4027 -
4028 -/**
4029 - * Paints nicely rendered one touch triangles.
4030 - *
4031 - * @author Karsten Lentzsch
4032 - * @version $Revision: 1.6 $
4033 - *
4034 - * @see WindowsSplitPaneUI
4035 - */
4036 -final class WindowsSplitPaneDivider extends BasicSplitPaneDivider {
4037 -
4038 - private static final int EXT_ONE_TOUCH_SIZE = 5;
4039 - private static final int EXT_ONE_TOUCH_OFFSET = 2;
4040 - private static final int EXT_BLOCKSIZE = 6;
4041 -
4042 - /**
4043 - * Used to lay out a WindowsSplitPaneDivider. Layout for the divider
4044 - * involves appropriately moving the left/right buttons around.
4045 - * <p>
4046 - * This inner class is marked &quot;public&quot; due to a compiler bug.
4047 - * This class should be treated as a &quot;protected&quot; inner class.
4048 - * Instantiate it only within subclasses of MetalSplitPaneDivider.
4049 - */
4050 - public final class ExtWindowsDividerLayout implements LayoutManager {
4051 - public void layoutContainer(Container c) {
4052 - JButton theLeftButton = getLeftButtonFromSuper();
4053 - JButton theRightButton = getRightButtonFromSuper();
4054 - JSplitPane theSplitPane = getSplitPaneFromSuper();
4055 - int theOrientation = getOrientationFromSuper();
4056 - int oneTouchSize = getOneTouchSize();
4057 - int oneTouchOffset = getOneTouchOffset();
4058 - int blockSize = 5;
4059 - //getBlockSize(); //Math.min(getDividerSize(), oneTouchSize);
4060 -
4061 - // This layout differs from the one used in BasicSplitPaneDivider.
4062 - // It does not center justify the oneTouchExpadable buttons.
4063 - // This was necessary in order to meet the spec of the Metal
4064 - // splitpane divider.
4065 - if (theLeftButton != null
4066 - && theRightButton != null
4067 - && c == WindowsSplitPaneDivider.this) {
4068 - if (theSplitPane.isOneTouchExpandable()) {
4069 - if (theOrientation == JSplitPane.VERTICAL_SPLIT) {
4070 - theLeftButton.setBounds(
4071 - oneTouchOffset,
4072 - 0,
4073 - blockSize * 2,
4074 - blockSize);
4075 - theRightButton.setBounds(
4076 - oneTouchOffset + oneTouchSize * 2,
4077 - 0,
4078 - blockSize * 2,
4079 - blockSize);
4080 - } else {
4081 - theLeftButton.setBounds(
4082 - 0,
4083 - oneTouchOffset,
4084 - blockSize,
4085 - blockSize * 2);
4086 - theRightButton.setBounds(
4087 - 0,
4088 - oneTouchOffset + oneTouchSize * 2,
4089 - blockSize,
4090 - blockSize * 2);
4091 - }
4092 - } else {
4093 - theLeftButton.setBounds(-5, -5, 1, 1);
4094 - theRightButton.setBounds(-5, -5, 1, 1);
4095 - }
4096 - }
4097 - }
4098 -
4099 - public Dimension minimumLayoutSize(Container c) {
4100 - return new Dimension(0, 0);
4101 - }
4102 - public Dimension preferredLayoutSize(Container c) {
4103 - return new Dimension(0, 0);
4104 - }
4105 - public void removeLayoutComponent(Component c) {
4106 - // Unused method; implements LayoutManager.
4107 - }
4108 - public void addLayoutComponent(String string, Component c) {
4109 - // Unused method; implements LayoutManager.
4110 - }
4111 - }
4112 -
4113 - public WindowsSplitPaneDivider(BasicSplitPaneUI ui) {
4114 - super(ui);
4115 - setLayout(new ExtWindowsDividerLayout());
4116 - }
4117 -
4118 - /**
4119 - * Creates and return an instance of JButton that can be used to
4120 - * collapse the left component in the metal split pane.
4121 - */
4122 - protected JButton createLeftOneTouchButton() {
4123 - JButton b = new JButton() {
4124 - // Sprite buffer for the arrow image of the left button
4125 - int[][] buffer = { { 0, 0, 0, 2, 2, 0, 0, 0, 0 }, {
4126 - 0, 0, 2, 1, 1, 1, 0, 0, 0 }, {
4127 - 0, 2, 1, 1, 1, 1, 1, 0, 0 }, {
4128 - 2, 1, 1, 1, 1, 1, 1, 1, 0 }, {
4129 - 0, 3, 3, 3, 3, 3, 3, 3, 3 }
4130 - };
4131 -
4132 - public void setBorder(Border border) {
4133 - // Ignore borders
4134 - }
4135 -
4136 - public void paint(Graphics g) {
4137 - JSplitPane theSplitPane = getSplitPaneFromSuper();
4138 - if (theSplitPane != null) {
4139 - int theOrientation = getOrientationFromSuper();
4140 - int blockSize = buffer.length + 1;
4141 - //Math.min(getDividerSize(), oneTouchSize);
4142 -
4143 - // Initialize the color array
4144 - Color[] colors =
4145 - {
4146 - this.getBackground(),
4147 - UIManager.getColor("controlDkShadow"),
4148 - Color.black,
4149 - //UIManager.getColor(),
4150 - UIManager.getColor("controlLtHighlight")};
4151 -
4152 - // Fill the background first ...
4153 - g.setColor(this.getBackground());
4154 - g.fillRect(0, 0, this.getWidth(), this.getHeight());
4155 -
4156 - // ... then draw the arrow.
4157 - if (getModel().isPressed()) {
4158 - // Adjust color mapping for pressed button state
4159 - colors[1] = colors[2];
4160 - }
4161 - if (theOrientation == JSplitPane.VERTICAL_SPLIT) {
4162 - // Draw the image for a vertical split
4163 - for (int i = 1; i <= buffer[0].length; i++) {
4164 - for (int j = 1; j < blockSize; j++) {
4165 - if (buffer[j - 1][i - 1] == 0) {
4166 - continue;
4167 - }
4168 - g.setColor(colors[buffer[j - 1][i - 1]]);
4169 - g.drawLine(i - 1, j, i - 1, j);
4170 - }
4171 - }
4172 - } else {
4173 - // Draw the image for a horizontal split
4174 - // by simply swaping the i and j axis.
4175 - // Except the drawLine() call this code is
4176 - // identical to the code block above. This was done
4177 - // in order to remove the additional orientation
4178 - // check for each pixel.
4179 - for (int i = 1; i <= buffer[0].length; i++) {
4180 - for (int j = 1; j < blockSize; j++) {
4181 - if (buffer[j - 1][i - 1] == 0) {
4182 - // Nothing needs
4183 - // to be drawn
4184 - continue;
4185 - }
4186 - // Set the color from the
4187 - // color map
4188 - g.setColor(colors[buffer[j - 1][i - 1]]);
4189 - // Draw a pixel
4190 - g.drawLine(j - 1, i, j - 1, i);
4191 - }
4192 - }
4193 - }
4194 - }
4195 - }
4196 -
4197 - };
4198 - b.setFocusPainted(false);
4199 - b.setBorderPainted(false);
4200 - b.setFocusable(false);
4201 - b.setOpaque(false);
4202 - return b;
4203 - }
4204 -
4205 - /**
4206 - * Creates and return an instance of JButton that can be used to
4207 - * collapse the right component in the metal split pane.
4208 - */
4209 - protected JButton createRightOneTouchButton() {
4210 - JButton b = new JButton() {
4211 - // Sprite buffer for the arrow image of the right button
4212 - int[][] buffer = { { 2, 2, 2, 2, 2, 2, 2, 2 }, {
4213 - 0, 1, 1, 1, 1, 1, 1, 3 }, {
4214 - 0, 0, 1, 1, 1, 1, 3, 0 }, {
4215 - 0, 0, 0, 1, 1, 3, 0, 0 }, {
4216 - 0, 0, 0, 0, 3, 0, 0, 0 }
4217 - };
4218 -
4219 - public void setBorder(Border border) {
4220 - // Ignore borders
4221 - }
4222 -
4223 - public void paint(Graphics g) {
4224 - JSplitPane theSplitPane = getSplitPaneFromSuper();
4225 - if (theSplitPane != null) {
4226 - int theOrientation = getOrientationFromSuper();
4227 - int blockSize = buffer.length + 1;
4228 - //Math.min(getDividerSize(), oneTouchSize);
4229 -
4230 - // Initialize the color array
4231 - Color[] colors =
4232 - {
4233 - this.getBackground(),
4234 - UIManager.getColor("controlDkShadow"),
4235 - Color.black,
4236 - //UIManager.getColor("controlDkShadow"),
4237 - UIManager.getColor("controlLtHighlight")};
4238 -
4239 - // Fill the background first ...
4240 - g.setColor(this.getBackground());
4241 - g.fillRect(0, 0, this.getWidth(), this.getHeight());
4242 -
4243 - // ... then draw the arrow.
4244 - if (getModel().isPressed()) {
4245 - // Adjust color mapping for pressed button state
4246 - colors[1] = colors[2];
4247 - }
4248 - if (theOrientation == JSplitPane.VERTICAL_SPLIT) {
4249 - // Draw the image for a vertical split
4250 - for (int i = 1; i <= buffer[0].length; i++) {
4251 - for (int j = 1; j < blockSize; j++) {
4252 - if (buffer[j - 1][i - 1] == 0) {
4253 - continue;
4254 - }
4255 - g.setColor(colors[buffer[j - 1][i - 1]]);
4256 - g.drawLine(i, j, i, j);
4257 - }
4258 - }
4259 - } else {
4260 - // Draw the image for a horizontal split
4261 - // by simply swaping the i and j axis.
4262 - // Except the drawLine() call this code is
4263 - // identical to the code block above. This was done
4264 - // in order to remove the additional orientation
4265 - // check for each pixel.
4266 - for (int i = 1; i <= buffer[0].length; i++) {
4267 - for (int j = 1; j < blockSize; j++) {
4268 - if (buffer[j - 1][i - 1] == 0) {
4269 - // Nothing needs
4270 - // to be drawn
4271 - continue;
4272 - }
4273 - // Set the color from the
4274 - // color map
4275 - g.setColor(colors[buffer[j - 1][i - 1]]);
4276 - // Draw a pixel
4277 - g.drawLine(j - 1, i, j - 1, i);
4278 - }
4279 - }
4280 - }
4281 - }
4282 - }
4283 - };
4284 - b.setFocusPainted(false);
4285 - b.setBorderPainted(false);
4286 - b.setFocusable(false);
4287 - b.setOpaque(false);
4288 - return b;
4289 - }
4290 -
4291 - int getBlockSize() {
4292 - return EXT_BLOCKSIZE;
4293 - }
4294 -
4295 - int getOneTouchOffset() {
4296 - return EXT_ONE_TOUCH_OFFSET;
4297 - }
4298 -
4299 - int getOneTouchSize() {
4300 - return EXT_ONE_TOUCH_SIZE;
4301 - }
4302 -
4303 - int getOrientationFromSuper() {
4304 - return super.orientation;
4305 - }
4306 -
4307 - JButton getLeftButtonFromSuper() {
4308 - return super.leftButton;
4309 - }
4310 -
4311 - JButton getRightButtonFromSuper() {
4312 - return super.rightButton;
4313 - }
4314 -
4315 - JSplitPane getSplitPaneFromSuper() {
4316 - return super.splitPane;
4317 - }
4318 -
4319 - public void paint(Graphics g) {
4320 - if (splitPane.isOpaque()) {
4321 - Color bgColor = splitPane.hasFocus()
4322 - ? UIManager.getColor("SplitPane.shadow")
4323 - : getBackground();
4324 -
4325 - if (bgColor != null) {
4326 - g.setColor(bgColor);
4327 - g.fillRect(0, 0, getWidth(), getHeight());
4328 - }
4329 - }
4330 - super.paint(g);
4331 - }
4332 -
4333 -}
4334 \ No newline at end of file
4335 --- a/src/core/com/jgoodies/looks/windows/WindowsSplitPaneUI.java
4336 +++ /dev/null
4337 @@ -1,66 +0,0 @@
4338 -/*
4339 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
4340 - *
4341 - * Redistribution and use in source and binary forms, with or without
4342 - * modification, are permitted provided that the following conditions are met:
4343 - *
4344 - * o Redistributions of source code must retain the above copyright notice,
4345 - * this list of conditions and the following disclaimer.
4346 - *
4347 - * o Redistributions in binary form must reproduce the above copyright notice,
4348 - * this list of conditions and the following disclaimer in the documentation
4349 - * and/or other materials provided with the distribution.
4350 - *
4351 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
4352 - * its contributors may be used to endorse or promote products derived
4353 - * from this software without specific prior written permission.
4354 - *
4355 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4356 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
4357 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4358 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
4359 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4360 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
4361 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
4362 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
4363 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
4364 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4365 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4366 - */
4367 -
4368 -package com.jgoodies.looks.windows;
4369 -
4370 -import javax.swing.JComponent;
4371 -import javax.swing.plaf.ComponentUI;
4372 -import javax.swing.plaf.basic.BasicSplitPaneDivider;
4373 -
4374 -
4375 -/**
4376 - * The JGoodies Windows L&amp;F implementation of <code>SplitPaneUI</code>.
4377 - * Uses a special divider that paints modified one-touch buttons.
4378 - *
4379 - * @author Karsten Lentzsch
4380 - * @version $Revision: 1.5 $
4381 - *
4382 - * @see com.jgoodies.looks.windows.WindowsSplitPaneDivider
4383 - */
4384 -public final class WindowsSplitPaneUI extends com.sun.java.swing.plaf.windows.WindowsSplitPaneUI {
4385 -
4386 -
4387 - /**
4388 - * Creates and returns a <code>WindowsSplitPaneUI</code> instance.
4389 - */
4390 - public static ComponentUI createUI(JComponent x) {
4391 - return new WindowsSplitPaneUI();
4392 - }
4393 -
4394 -
4395 - /**
4396 - * Creates and returns the modified default divider.
4397 - */
4398 - public BasicSplitPaneDivider createDefaultDivider() {
4399 - return new WindowsSplitPaneDivider(this);
4400 - }
4401 -
4402 -
4403 -}
4404 \ No newline at end of file
4405 --- a/src/core/com/jgoodies/looks/windows/WindowsTabbedPaneUI.java
4406 +++ /dev/null
4407 @@ -1,583 +0,0 @@
4408 -/*
4409 - * Copyright (c) 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.
4410 - *
4411 - * Redistribution and use in source and binary forms, with or without
4412 - * modification, are permitted provided that the following conditions are met:
4413 - *
4414 - * o Redistributions of source code must retain the above copyright notice,
4415 - * this list of conditions and the following disclaimer.
4416 - *
4417 - * o Redistributions in binary form must reproduce the above copyright notice,
4418 - * this list of conditions and the following disclaimer in the documentation
4419 - * and/or other materials provided with the distribution.
4420 - *
4421 - * o Neither the name of JGoodies Karsten Lentzsch nor the names of
4422 - * its contributors may be used to endorse or promote products derived
4423 - * from this software without specific prior written permission.
4424 - *
4425 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4426 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
4427 - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4428 - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
4429 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4430 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
4431 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
4432 - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
4433 - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
4434 - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
4435 - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4436 - */
4437 -
4438 -package com.jgoodies.looks.windows;
4439 -
4440 -import java.awt.FontMetrics;
4441 -import java.awt.Graphics;
4442 -import java.awt.Insets;
4443 -import java.awt.Rectangle;
4444 -import java.beans.PropertyChangeEvent;
4445 -import java.beans.PropertyChangeListener;
4446 -
4447 -import javax.swing.Icon;
4448 -import javax.swing.JComponent;
4449 -import javax.swing.SwingConstants;
4450 -import javax.swing.SwingUtilities;
4451 -import javax.swing.plaf.ComponentUI;
4452 -import javax.swing.plaf.basic.BasicGraphicsUtils;
4453 -import javax.swing.plaf.basic.BasicTabbedPaneUI;
4454 -import javax.swing.text.View;
4455 -
4456 -import com.jgoodies.looks.LookUtils;
4457 -import com.jgoodies.looks.Options;
4458 -
4459 -/**
4460 - * The JGoodies Windows L&amp;F implementation of <code>TabbedPaneUI</code>.<p>
4461 - *
4462 - * The flat appearance is work in progress; currently it works only
4463 - * for a single line of tabs and paints distored tabs for multiple lines.
4464 - *
4465 - * @author Karsten Lentzsch
4466 - * @version $Revision: 1.7 $
4467 - */
4468 -public final class WindowsTabbedPaneUI extends com.sun.java.swing.plaf.windows.WindowsTabbedPaneUI {
4469 -
4470 - private static final boolean IS_XP_LAF_5_OR_LATER =
4471 - LookUtils.IS_JAVA_5_OR_LATER && LookUtils.IS_LAF_WINDOWS_XP_ENABLED;
4472 -
4473 - /** Insets used for the embedded style content border. */
4474 - private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
4475 -
4476 - /** Insets used if we paint no content border. */
4477 - private static final int INSET = IS_XP_LAF_5_OR_LATER ? -1 : 1;
4478 - private static final Insets NO_CONTENT_BORDER_NORTH_INSETS = new Insets(INSET, 0, 0, 0);
4479 - private static final Insets NO_CONTENT_BORDER_WEST_INSETS = new Insets(0, INSET, 0, 0);
4480 - private static final Insets NO_CONTENT_BORDER_SOUTH_INSETS = new Insets(0, 0, INSET, 0);
4481 - private static final Insets NO_CONTENT_BORDER_EAST_INSETS = new Insets(0, 0, 0, INSET);
4482 -
4483 - /** Insets used if we paint content border. */
4484 - private static final Insets CONTENT_BORDER_NORTH_INSETS = new Insets(0, 2, 4, 4);
4485 - private static final Insets CONTENT_BORDER_WEST_INSETS = new Insets(2, 0, 4, 4);
4486 - private static final Insets CONTENT_BORDER_SOUTH_INSETS = new Insets(4, 2, 0, 4);
4487 - private static final Insets CONTENT_BORDER_EAST_INSETS = new Insets(2, 4, 4, 0);
4488 -
4489 -
4490 - /**
4491 - * Describes if tabs are painted with or without icons.
4492 - */
4493 - private static boolean isTabIconsEnabled = Options.isTabIconsEnabled();
4494 -
4495 - /**
4496 - * Describes if we paint no content border or not; this is false by default.
4497 - * You can disable the content border by setting the client property
4498 - * Options.NO_CONTENT_BORDER_KEY to Boolean.TRUE;
4499 - */
4500 - private Boolean noContentBorder;
4501 -
4502 - /**
4503 - * Describes if we paint tabs in an embedded style that is with
4504 - * less decoration; this is false by default.
4505 - * You can enable the embedded tabs style by setting the client property
4506 - * Options.EMBEDDED_TABS_KEY to Boolean.TRUE.
4507 - */
4508 - private Boolean embeddedTabs;
4509 -
4510 - /**
4511 - * Creates and answers the <code>WindowsTabbedPaneUI</code>.
4512 - *
4513 - * @see javax.swing.plaf.ComponentUI#createUI(JComponent)
4514 - */
4515 - public static ComponentUI createUI(JComponent x) {
4516 - return new WindowsTabbedPaneUI();
4517 - }
4518 -
4519 -
4520 - /**
4521 - * Installs the UI.
4522 - *
4523 - * @see javax.swing.plaf.ComponentUI#installUI(JComponent)
4524 - */
4525 - public void installUI(JComponent c) {
4526 - super.installUI(c);
4527 - embeddedTabs = (Boolean) c.getClientProperty(Options.EMBEDDED_TABS_KEY);
4528 - noContentBorder = (Boolean) c.getClientProperty(Options.NO_CONTENT_BORDER_KEY);
4529 - }
4530 -
4531 -
4532 - /**
4533 - * Checks and answers if content border will be painted.
4534 - * This is controlled by the component's client property
4535 - * Options.NO_CONTENT_BORDER or Options.EMBEDDED.
4536 - */
4537 - private boolean hasNoContentBorder() {
4538 - return hasEmbeddedTabs() || Boolean.TRUE.equals(noContentBorder);
4539 - }
4540 -
4541 - /**
4542 - * Checks and answers if tabs are painted with minimal decoration.
4543 - */
4544 - private boolean hasEmbeddedTabs() {
4545 - return embeddedTabs == null
4546 - ? false
4547 - : embeddedTabs.booleanValue();
4548 - }
4549 -
4550 - /**
4551 - * Creates and answer a handler that listens to property changes.
4552 - * Unlike the superclass BasicTabbedPane, the PlasticTabbedPaneUI
4553 - * uses an extended Handler.
4554 - */
4555 - protected PropertyChangeListener createPropertyChangeListener() {
4556 - return new MyPropertyChangeHandler();
4557 - }
4558 -
4559 - private void doLayout() {
4560 - tabPane.revalidate();
4561 - tabPane.repaint();
4562 - }
4563 -
4564 - /**
4565 - * Updates the embedded tabs property. This message is sent by
4566 - * my PropertyChangeHandler whenever the embedded tabs property changes.
4567 - */
4568 - private void embeddedTabsPropertyChanged(Boolean newValue) {
4569 - embeddedTabs = newValue;
4570 - doLayout();
4571 - }
4572 -
4573 - /**
4574 - * Updates the no content border property. This message is sent
4575 - * by my PropertyChangeHandler whenever the noContentBorder
4576 - * property changes.
4577 - */
4578 - private void noContentBorderPropertyChanged(Boolean newValue) {
4579 - noContentBorder = newValue;
4580 - doLayout();
4581 - }
4582 -
4583 -
4584 -
4585 - /**
4586 - * Answers the icon for the tab with the specified index.
4587 - * In case, we have globally switched of the use tab icons,
4588 - * we answer <code>null</code> if and only if we have a title.
4589 - */
4590 - protected Icon getIconForTab(int tabIndex) {
4591 - String title = tabPane.getTitleAt(tabIndex);
4592 - boolean hasTitle = (title != null) && (title.length() > 0);
4593 - return !isTabIconsEnabled && hasTitle
4594 - ? null
4595 - : super.getIconForTab(tabIndex);
4596 - }
4597 -
4598 - protected Insets getContentBorderInsets(int tabPlacement) {
4599 - if (!hasNoContentBorder()) {
4600 - if (IS_XP_LAF_5_OR_LATER) {
4601 - switch (tabPlacement) {
4602 - case RIGHT :
4603 - return CONTENT_BORDER_EAST_INSETS;
4604 - case LEFT :
4605 - return CONTENT_BORDER_WEST_INSETS;
4606 - case TOP :
4607 - return CONTENT_BORDER_NORTH_INSETS;
4608 - case BOTTOM :
4609 - default :
4610 - return CONTENT_BORDER_SOUTH_INSETS;
4611 - }
4612 - }
4613 - return contentBorderInsets;
4614 - } else if (hasEmbeddedTabs()) {
4615 - return EMPTY_INSETS;
4616 - } else {
4617 - switch (tabPlacement) {
4618 - case RIGHT :
4619 - return NO_CONTENT_BORDER_EAST_INSETS;
4620 - case LEFT :
4621 - return NO_CONTENT_BORDER_WEST_INSETS;
4622 - case TOP :
4623 - return NO_CONTENT_BORDER_NORTH_INSETS;
4624 - case BOTTOM :
4625 - default :
4626 - return NO_CONTENT_BORDER_SOUTH_INSETS;
4627 - }
4628 - }
4629 - }
4630 -
4631 - protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) {
4632 - switch (tabPlacement) {
4633 - case RIGHT :
4634 - return isSelected ? 2 : 0;
4635 - case LEFT :
4636 - return isSelected ? -2 : 0;
4637 - case TOP :
4638 - case BOTTOM :
4639 - default :
4640 - return 0;
4641 - }
4642 - }
4643 -
4644 - protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) {
4645 - return 0;
4646 - }
4647 -
4648 - protected Insets getSelectedTabPadInsets(int tabPlacement) {
4649 - if (hasEmbeddedTabs()) {
4650 - return EMPTY_INSETS;
4651 - } else if (hasNoContentBorder()) {
4652 - int inset = IS_XP_LAF_5_OR_LATER ? 1 : 0;
4653 - switch (tabPlacement) {
4654 - case LEFT: return new Insets(1, 2, 1, inset);
4655 - case RIGHT: return new Insets(1, inset, 1, 2);
4656 - case TOP: return new Insets(2, 2, inset, 2);
4657 - case BOTTOM: return new Insets(inset, 2, 2, 2);
4658 - default: return EMPTY_INSETS;
4659 - }
4660 - } else {
4661 - Insets superInsets = super.getSelectedTabPadInsets(tabPlacement);
4662 - int equalized = superInsets.left + superInsets.right / 2;
4663 - superInsets.left = superInsets.right = equalized;
4664 - return superInsets;
4665 - }
4666 - }
4667 -
4668 -
4669 - protected Insets getTabAreaInsets(int tabPlacement) {
4670 - return hasEmbeddedTabs()
4671 - ? /*new Insets(1,1,1,1)*/EMPTY_INSETS
4672 - : super.getTabAreaInsets(tabPlacement);
4673 - }
4674 -
4675 - /**
4676 - * Paints the top edge of the pane's content border.
4677 - */
4678 - protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
4679 - int selectedIndex,
4680 - int x, int y, int w, int h) {
4681 - if (hasNoContentBorder() && tabPlacement != TOP) {
4682 - return;
4683 - }
4684 - Rectangle selRect = selectedIndex < 0
4685 - ? null
4686 - : getTabBounds(selectedIndex, calcRect);
4687 - if (tabPlacement != TOP || selectedIndex < 0 ||
4688 - (selRect.y + selRect.height + 1 < y) ||
4689 - (selRect.x < x || selRect.x > x + w)) {
4690 - // no special case, do the super thing
4691 - super.paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h);
4692 - } else {
4693 - g.setColor(lightHighlight);
4694 - g.fillRect(x, y, selRect.x + 1-x, 1);
4695 - g.fillRect(selRect.x + selRect.width, y,
4696 - x+w-2 -selRect.x-selRect.width, 1);
4697 - }
4698 - }
4699 -
4700 - /**
4701 - * Paints the bottom edge of the pane's content border.
4702 - */
4703 - protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
4704 - int selectedIndex,
4705 - int x, int y, int w, int h) {
4706 - if (!hasNoContentBorder()) {
4707 - Rectangle selRect = selectedIndex < 0 ? null :
4708 - getTabBounds(selectedIndex, calcRect);
4709 - if (tabPlacement != BOTTOM || selectedIndex < 0 ||
4710 - (selRect.y - 1 > h + y) ||
4711 - (selRect.x < x || selRect.x > x + w)) {
4712 - // no special case, do the super thing
4713 - super.paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h);
4714 - } else {
4715 - g.setColor(lightHighlight);
4716 - g.fillRect(x,y+h-1,1,1);
4717 - g.setColor(shadow);
4718 - g.fillRect(x+1, y+h-2, selRect.x - 1-x, 1);
4719 - g.fillRect(selRect.x + selRect.width, y+h-2, x+w-2-selRect.x-selRect.width, 1);
4720 - g.setColor(darkShadow);
4721 - g.fillRect(x, y+h-1, selRect.x - x, 1);
4722 - g.fillRect(selRect.x + selRect.width -1, y+h-1, x+w-selRect.x-selRect.width, 1);
4723 - }
4724 - } else if (!(tabPlacement == BOTTOM)) {
4725 - // no content border really means only one content border:
4726 - // the one edge that touches the tabs
4727 - } else {
4728 - g.setColor(shadow);
4729 - g.fillRect(x,y+h,w,1);
4730 - }
4731 - }
4732 -
4733 - /**
4734 - * Paints the left Edge of the pane's content border.
4735 - */
4736 - protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
4737 - int selectedIndex,
4738 - int x, int y, int w, int h) {
4739 - if (!hasNoContentBorder()) {
4740 - Rectangle selRect = selectedIndex < 0 ? null :
4741 - getTabBounds(selectedIndex, calcRect);
4742 - if (tabPlacement != LEFT || selectedIndex < 0 ||
4743 - (selRect.x + selRect.width + 1 < x) ||
4744 - (selRect.y < y || selRect.y > y + h)) {
4745 - // no special case, do the super thing
4746 - super.paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h);
4747 - } else {
4748 - g.setColor(lightHighlight);
4749 - g.fillRect(x, y, 1, selRect.y + 1 - y);
4750 - g.fillRect(x, selRect.y + selRect.height,
4751 - 1, y+h-1-selRect.y-selRect.height);
4752 -
4753 - }
4754 - } else if (!(tabPlacement == LEFT)) {
4755 - // no content border really means only one content border:
4756 - // the one edge that touches the tabs
4757 - } else {
4758 - g.setColor(shadow);
4759 - g.fillRect(x,y,1,h);
4760 - }
4761 - }
4762 -
4763 - /**
4764 - * Paints the right Edge of the pane's content border.
4765 - */
4766 - protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
4767 - int selectedIndex,
4768 - int x, int y, int w, int h) {
4769 - if (!hasNoContentBorder()) {
4770 - Rectangle selRect = selectedIndex < 0 ? null :
4771 - getTabBounds(selectedIndex, calcRect);
4772 - if (tabPlacement != RIGHT || selectedIndex < 0 ||
4773 - (selRect.x - 1 > x+w) ||
4774 - (selRect.y < y || selRect.y > y + h)) {
4775 - // no special case, do the super thing
4776 - super.paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h);
4777 - } else {
4778 - g.setColor(lightHighlight);
4779 - g.fillRect(x+w-1, y,1,1);
4780 - g.setColor(shadow);
4781 - g.fillRect(x+w-2, y+1, 1, selRect.y - 1-y);
4782 - g.fillRect(x+w-2, selRect.y + selRect.height,
4783 - 1, y+h-1-selRect.y- selRect.height);
4784 - g.setColor(darkShadow);
4785 - g.fillRect(x+w-1, y, 1, selRect.y - y);
4786 - g.fillRect(x+w-1, selRect.y + selRect.height-1,
4787 - 1, y+h-selRect.y-selRect.height);
4788 -
4789 - }
4790 - } else if (!(tabPlacement == RIGHT)) {
4791 - // no content border really means only one content border:
4792 - // the one edge that touches the tabs
4793 - } else {
4794 - g.setColor(shadow);
4795 -