KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > plaf > winclassic > WindowsLFCustoms


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.swing.plaf.winclassic;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Component JavaDoc;
24 import java.awt.Font JavaDoc;
25 import java.awt.Graphics JavaDoc;
26 import java.awt.Insets JavaDoc;
27 import javax.swing.BorderFactory JavaDoc;
28 import javax.swing.Icon JavaDoc;
29 import javax.swing.UIManager JavaDoc;
30 import javax.swing.border.EmptyBorder JavaDoc;
31 import org.netbeans.swing.plaf.LFCustoms;
32 import org.netbeans.swing.plaf.util.GuaranteedValue;
33 import org.netbeans.swing.plaf.util.RelativeColor;
34 import org.netbeans.swing.plaf.util.UIBootstrapValue;
35 import org.netbeans.swing.plaf.util.UIUtils;
36
37 /** Default system-provided customizer for Windows LF
38  * Public only to be accessible by ProxyLazyValue, please don't abuse.
39  */

40 public final class WindowsLFCustoms extends LFCustoms {
41
42     public Object JavaDoc[] createLookAndFeelCustomizationKeysAndValues() {
43         int fontsize = 11;
44         Integer JavaDoc in = (Integer JavaDoc) UIManager.get(CUSTOM_FONT_SIZE); //NOI18N
45
if (in != null) {
46             fontsize = in.intValue();
47         }
48         
49         return new Object JavaDoc[] {
50             //Workaround for help window selection color
51
"EditorPane.selectionBackground", new Color JavaDoc(157, 157, 255), //NOI18N
52

53             //Work around a bug in windows which sets the text area font to
54
//"MonoSpaced", causing all accessible dialogs to have monospaced text
55
"TextArea.font", new GuaranteedValue("Label.font", new Font JavaDoc("Dialog", Font.PLAIN, fontsize)), //NOI18N
56

57             EDITOR_ERRORSTRIPE_SCROLLBAR_INSETS, new Insets JavaDoc(17, 0, 17, 0),
58         };
59     }
60
61     public Object JavaDoc[] createApplicationSpecificKeysAndValues () {
62         Object JavaDoc propertySheetColorings = new WinClassicPropertySheetColorings();
63         Object JavaDoc[] result = {
64             DESKTOP_BORDER, new EmptyBorder JavaDoc(4, 2, 1, 2),
65             SCROLLPANE_BORDER, UIManager.get("ScrollPane.border"),
66             EXPLORER_STATUS_BORDER, new StatusLineBorder(StatusLineBorder.TOP),
67             EXPLORER_FOLDER_ICON , UIUtils.loadImage("org/netbeans/swing/plaf/resources/win-explorer-folder.gif"),
68             EXPLORER_FOLDER_OPENED_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/win-explorer-opened-folder.gif"),
69             EDITOR_STATUS_LEFT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.RIGHT),
70             EDITOR_STATUS_RIGHT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT),
71             EDITOR_STATUS_INNER_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT | StatusLineBorder.RIGHT),
72             EDITOR_TOOLBAR_BORDER, new EditorToolbarBorder(),
73             EDITOR_STATUS_ONLYONEBORDER, new StatusLineBorder(StatusLineBorder.TOP),
74
75             PROPERTYSHEET_BOOTSTRAP, propertySheetColorings,
76
77             EDITOR_TAB_CONTENT_BORDER, new WinClassicCompBorder(),
78             EDITOR_TAB_TABS_BORDER, new WinClassicTabBorder(),
79             VIEW_TAB_CONTENT_BORDER, new WinClassicCompBorder(),
80             VIEW_TAB_TABS_BORDER, new WinClassicTabBorder(),
81
82             DESKTOP_SPLITPANE_BORDER, BorderFactory.createEmptyBorder(4, 2, 1, 2),
83
84             //UI Delegates for the tab control
85
EDITOR_TAB_DISPLAYER_UI, "org.netbeans.swing.tabcontrol.plaf.WinClassicEditorTabDisplayerUI",
86             SLIDING_BUTTON_UI, "org.netbeans.swing.tabcontrol.plaf.WindowsSlidingButtonUI",
87             VIEW_TAB_DISPLAYER_UI, "org.netbeans.swing.tabcontrol.plaf.WinClassicViewTabDisplayerUI",
88
89             PROGRESS_CANCEL_BUTTON_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/cancel_task_win_classic.png"),
90                     
91             //XXX convert to derived colors
92
"tab_unsel_fill", UIUtils.adjustColor (
93                 new GuaranteedValue("InternalFrame.inactiveTitleGradient",
94                     Color.GRAY).getColor(),
95                 -12, -15, -22),
96
97             "tab_sel_fill", new GuaranteedValue("text", Color.WHITE),
98
99             "tab_bottom_border", UIUtils.adjustColor (
100                 new GuaranteedValue("InternalFrame.borderShadow",
101                     Color.GRAY).getColor(),
102                 20, 17, 12),
103
104
105              "winclassic_tab_sel_gradient",
106                 new RelativeColor (
107                     new Color JavaDoc(7, 28, 95),
108                     new Color JavaDoc(152, 177, 208),
109                     "InternalFrame.activeTitleBackground"),
110
111             // progress component related
112
"nbProgressBar.Foreground", new Color JavaDoc(49, 106, 197),
113             "nbProgressBar.Background", Color.WHITE,
114             "nbProgressBar.popupDynaText.foreground", new Color JavaDoc(141, 136, 122),
115             "nbProgressBar.popupText.background", new Color JavaDoc(249, 249, 249),
116             "nbProgressBar.popupText.foreground", UIManager.getColor("TextField.foreground"),
117             "nbProgressBar.popupText.selectBackground", UIManager.getColor("List.selectionBackground"),
118             "nbProgressBar.popupText.selectForeground", UIManager.getColor("List.selectionForeground"),
119         }; //NOI18N
120

121         return result;
122     }
123     
124     public Object JavaDoc[] createGuaranteedKeysAndValues() {
125         return new Object JavaDoc[] {
126              "InternalFrame.activeTitleBackground",
127                 new GuaranteedValue("InternalFrame.activeTitleBackground",
128                 Color.BLUE),
129                 
130             "InternalFrame.borderShadow",
131                 new GuaranteedValue("InternalFrame.borderShadow", Color.gray),
132
133             "InternalFrame.borderHighlight",
134                 new GuaranteedValue("InternalFrame.borderHighlight",
135                 Color.white),
136
137             "InternalFrame.borderDarkShadow",
138                 new GuaranteedValue("InternalFrame.borderDarkShadow",
139                 Color.darkGray),
140
141             "InternalFrame.borderLight",
142                 new GuaranteedValue("InternalFrame.borderLight",
143                 Color.lightGray),
144
145             "TabbedPane.background",
146                 new GuaranteedValue("TabbedPane.background", Color.LIGHT_GRAY),
147
148             "TabbedPane.focus",
149                 new GuaranteedValue("TabbedPane.focus", Color.GRAY),
150
151             "TabbedPane.highlight",
152                 new GuaranteedValue("TabbedPane.highlight", Color.WHITE) ,
153              
154             "Button.dashedRectGapX",
155                new GuaranteedValue("Button.dashedRectGapX", Integer.valueOf(5)),
156                
157             "Button.dashedRectGapY",
158                new GuaranteedValue("Button.dashedRectGapY", Integer.valueOf(4)),
159                
160             "Button.dashedRectGapWidth",
161                new GuaranteedValue("Button.dashedRectGapWidth", Integer.valueOf(10)),
162                
163             "Button.dashedRectGapHeight",
164                new GuaranteedValue("Button.dashedRectGapHeight", Integer.valueOf(8)),
165                      
166             "Tree.expandedIcon", new TreeIcon(false),
167             "Tree.collapsedIcon", new TreeIcon(true)
168         };
169     }
170
171     private static class TreeIcon implements Icon JavaDoc {
172         private static final int HALF_SIZE = 4;
173         private static final int SIZE = 9;
174
175         private boolean collapsed;
176         
177         public TreeIcon (boolean collapsed) {
178             this.collapsed = collapsed;
179         }
180         
181         public void paintIcon(Component JavaDoc c, Graphics JavaDoc g, int x, int y) {
182             g.setColor(Color.WHITE);
183             g.fillRect(x, y, SIZE-1, SIZE-1);
184             g.setColor(Color.GRAY);
185             g.drawRect(x, y, SIZE-1, SIZE-1);
186             g.setColor(Color.BLACK);
187             g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE);
188             if (collapsed) {
189                 g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
190             }
191         }
192         public int getIconWidth() { return SIZE; }
193         public int getIconHeight() { return SIZE; }
194     }
195
196     protected Object JavaDoc[] additionalKeys() {
197         Object JavaDoc[] kv = new WinClassicPropertySheetColorings().createKeysAndValues();
198         Object JavaDoc[] result = new Object JavaDoc[kv.length / 2];
199         int ct = 0;
200         for (int i=0; i < kv.length; i+=2) {
201             result[ct] = kv[i];
202             ct++;
203         }
204         return result;
205     }
206
207     private class WinClassicPropertySheetColorings extends UIBootstrapValue.Lazy {
208         public WinClassicPropertySheetColorings () {
209             super (null);
210         }
211
212         public Object JavaDoc[] createKeysAndValues() {
213             return new Object JavaDoc[] {
214             //Property sheet settings as defined by HIE
215
PROPSHEET_SELECTION_BACKGROUND, new Color JavaDoc(10,36,106),
216             PROPSHEET_SELECTION_FOREGROUND, Color.WHITE,
217             PROPSHEET_SET_BACKGROUND, new Color JavaDoc(237,233,225),
218             PROPSHEET_SET_FOREGROUND, Color.BLACK,
219             PROPSHEET_SELECTED_SET_BACKGROUND, new Color JavaDoc(10,36,106),
220             PROPSHEET_SELECTED_SET_FOREGROUND, Color.WHITE,
221             PROPSHEET_DISABLED_FOREGROUND, new Color JavaDoc(128,128,128),
222             PROPSHEET_BUTTON_COLOR, UIManager.getColor("control"),
223             };
224         }
225     }
226 }
227
Popular Tags