blob: 8b5a66b53941e8586ba2a3be1610d010bd28efef [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
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
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
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 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package com.sun.java.swing.plaf.windows;
27
28import java.awt.*;
29
30import javax.swing.AbstractButton;
31import javax.swing.JComponent;
32import javax.swing.JToggleButton;
33import javax.swing.UIDefaults;
34import javax.swing.UIManager;
35
36import javax.swing.border.Border;
37import javax.swing.border.CompoundBorder;
38import javax.swing.border.EmptyBorder;
39
40import javax.swing.plaf.*;
41
42import javax.swing.plaf.basic.BasicBorders;
43import javax.swing.plaf.basic.BasicToolBarUI;
44
45import static com.sun.java.swing.plaf.windows.TMSchema.Part;
46
47
48public 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}