2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
package com.sun.java.swing.plaf.windows;
|
|
27 |
|
|
28 |
import java.awt.*;
|
|
29 |
|
|
30 |
import javax.swing.AbstractButton;
|
|
31 |
import javax.swing.JComponent;
|
|
32 |
import javax.swing.JToggleButton;
|
|
33 |
import javax.swing.UIDefaults;
|
|
34 |
import javax.swing.UIManager;
|
|
35 |
|
|
36 |
import javax.swing.border.Border;
|
|
37 |
import javax.swing.border.CompoundBorder;
|
|
38 |
import javax.swing.border.EmptyBorder;
|
|
39 |
|
|
40 |
import javax.swing.plaf.*;
|
|
41 |
|
|
42 |
import javax.swing.plaf.basic.BasicBorders;
|
|
43 |
import javax.swing.plaf.basic.BasicToolBarUI;
|
|
44 |
|
|
45 |
import static com.sun.java.swing.plaf.windows.TMSchema.Part;
|
|
46 |
|
|
47 |
|
|
48 |
public class WindowsToolBarUI extends BasicToolBarUI {
|
|
49 |
|
|
50 |
public static ComponentUI createUI(JComponent c) {
|
|
51 |
return new WindowsToolBarUI();
|
|
52 |
}
|
|
53 |
|
|
54 |
protected void installDefaults() {
|
|
55 |
if (XPStyle.getXP() != null) {
|
|
56 |
setRolloverBorders(true);
|
|
57 |
}
|
|
58 |
super.installDefaults();
|
|
59 |
}
|
|
60 |
|
|
61 |
protected Border createRolloverBorder() {
|
|
62 |
if (XPStyle.getXP() != null) {
|
|
63 |
return new EmptyBorder(3, 3, 3, 3);
|
|
64 |
} else {
|
|
65 |
return super.createRolloverBorder();
|
|
66 |
}
|
|
67 |
}
|
|
68 |
|
|
69 |
protected Border createNonRolloverBorder() {
|
|
70 |
if (XPStyle.getXP() != null) {
|
|
71 |
return new EmptyBorder(3, 3, 3, 3);
|
|
72 |
} else {
|
|
73 |
return super.createNonRolloverBorder();
|
|
74 |
}
|
|
75 |
}
|
|
76 |
|
|
77 |
public void paint(Graphics g, JComponent c) {
|
|
78 |
XPStyle xp = XPStyle.getXP();
|
|
79 |
if (xp != null) {
|
|
80 |
xp.getSkin(c, Part.TP_TOOLBAR).paintSkin(g, 0, 0,
|
|
81 |
c.getWidth(), c.getHeight(), null, true);
|
|
82 |
} else {
|
|
83 |
super.paint(g, c);
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* {@inheritDoc}
|
|
89 |
* @since 1.6
|
|
90 |
*/
|
|
91 |
protected Border getRolloverBorder(AbstractButton b) {
|
|
92 |
XPStyle xp = XPStyle.getXP();
|
|
93 |
if (xp != null) {
|
|
94 |
return xp.getBorder(b, WindowsButtonUI.getXPButtonType(b));
|
|
95 |
} else {
|
|
96 |
return super.getRolloverBorder(b);
|
|
97 |
}
|
|
98 |
}
|
|
99 |
}
|