001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.swing.plaf.winclassic;
043:
044: import java.awt.Color;
045: import java.awt.Component;
046: import java.awt.Font;
047: import java.awt.Graphics;
048: import java.awt.Insets;
049: import javax.swing.BorderFactory;
050: import javax.swing.Icon;
051: import javax.swing.UIManager;
052: import javax.swing.border.EmptyBorder;
053: import org.netbeans.swing.plaf.LFCustoms;
054: import org.netbeans.swing.plaf.util.GuaranteedValue;
055: import org.netbeans.swing.plaf.util.RelativeColor;
056: import org.netbeans.swing.plaf.util.UIBootstrapValue;
057: import org.netbeans.swing.plaf.util.UIUtils;
058:
059: /** Default system-provided customizer for Windows LF
060: * Public only to be accessible by ProxyLazyValue, please don't abuse.
061: */
062: public final class WindowsLFCustoms extends LFCustoms {
063:
064: public Object[] createLookAndFeelCustomizationKeysAndValues() {
065: int fontsize = 11;
066: Integer in = (Integer) UIManager.get(CUSTOM_FONT_SIZE); //NOI18N
067: if (in != null) {
068: fontsize = in.intValue();
069: }
070:
071: String version = System.getProperty("java.version");
072: if (version.startsWith("1.5")) {
073: //#112473 - wrong password text field height
074: UIManager.put("PasswordField.font", UIManager
075: .get("TextField.font"));
076: }
077:
078: return new Object[] {
079: //Workaround for help window selection color
080: "EditorPane.selectionBackground",
081: new Color(157, 157, 255), //NOI18N
082:
083: //Work around a bug in windows which sets the text area font to
084: //"MonoSpaced", causing all accessible dialogs to have monospaced text
085: "TextArea.font",
086: new GuaranteedValue("Label.font", new Font("Dialog",
087: Font.PLAIN, fontsize)), //NOI18N
088:
089: EDITOR_ERRORSTRIPE_SCROLLBAR_INSETS,
090: new Insets(17, 0, 17, 0), };
091: }
092:
093: public Object[] createApplicationSpecificKeysAndValues() {
094: Object propertySheetColorings = new WinClassicPropertySheetColorings();
095: Object[] result = {
096: DESKTOP_BORDER,
097: new EmptyBorder(4, 2, 1, 2),
098: SCROLLPANE_BORDER,
099: UIManager.get("ScrollPane.border"),
100: EXPLORER_STATUS_BORDER,
101: new StatusLineBorder(StatusLineBorder.TOP),
102: EXPLORER_FOLDER_ICON,
103: UIUtils
104: .loadImage("org/netbeans/swing/plaf/resources/win-explorer-folder.gif"),
105: EXPLORER_FOLDER_OPENED_ICON,
106: UIUtils
107: .loadImage("org/netbeans/swing/plaf/resources/win-explorer-opened-folder.gif"),
108: EDITOR_STATUS_LEFT_BORDER,
109: new StatusLineBorder(StatusLineBorder.TOP
110: | StatusLineBorder.RIGHT),
111: EDITOR_STATUS_RIGHT_BORDER,
112: new StatusLineBorder(StatusLineBorder.TOP
113: | StatusLineBorder.LEFT),
114: EDITOR_STATUS_INNER_BORDER,
115: new StatusLineBorder(StatusLineBorder.TOP
116: | StatusLineBorder.LEFT
117: | StatusLineBorder.RIGHT),
118: EDITOR_TOOLBAR_BORDER,
119: new EditorToolbarBorder(),
120: EDITOR_STATUS_ONLYONEBORDER,
121: new StatusLineBorder(StatusLineBorder.TOP),
122:
123: PROPERTYSHEET_BOOTSTRAP,
124: propertySheetColorings,
125:
126: EDITOR_TAB_CONTENT_BORDER,
127: new WinClassicCompBorder(),
128: EDITOR_TAB_TABS_BORDER,
129: new WinClassicTabBorder(),
130: VIEW_TAB_CONTENT_BORDER,
131: new WinClassicCompBorder(),
132: VIEW_TAB_TABS_BORDER,
133: new WinClassicTabBorder(),
134:
135: DESKTOP_SPLITPANE_BORDER,
136: BorderFactory.createEmptyBorder(4, 2, 1, 2),
137:
138: //UI Delegates for the tab control
139: EDITOR_TAB_DISPLAYER_UI,
140: "org.netbeans.swing.tabcontrol.plaf.WinClassicEditorTabDisplayerUI",
141: SLIDING_BUTTON_UI,
142: "org.netbeans.swing.tabcontrol.plaf.WindowsSlidingButtonUI",
143: VIEW_TAB_DISPLAYER_UI,
144: "org.netbeans.swing.tabcontrol.plaf.WinClassicViewTabDisplayerUI",
145:
146: PROGRESS_CANCEL_BUTTON_ICON,
147: UIUtils
148: .loadImage("org/netbeans/swing/plaf/resources/cancel_task_win_classic.png"),
149:
150: //XXX convert to derived colors
151: "tab_unsel_fill",
152: UIUtils.adjustColor(new GuaranteedValue(
153: "InternalFrame.inactiveTitleGradient",
154: Color.GRAY).getColor(), -12, -15, -22),
155:
156: "tab_sel_fill",
157: new GuaranteedValue("text", Color.WHITE),
158:
159: "tab_bottom_border",
160: UIUtils.adjustColor(new GuaranteedValue(
161: "InternalFrame.borderShadow", Color.GRAY)
162: .getColor(), 20, 17, 12),
163:
164: "winclassic_tab_sel_gradient",
165: new RelativeColor(new Color(7, 28, 95), new Color(152,
166: 177, 208),
167: "InternalFrame.activeTitleBackground"),
168:
169: // progress component related
170: "nbProgressBar.Foreground", new Color(49, 106, 197),
171: "nbProgressBar.Background", Color.WHITE,
172: "nbProgressBar.popupDynaText.foreground",
173: new Color(141, 136, 122),
174: "nbProgressBar.popupText.background",
175: new Color(249, 249, 249),
176: "nbProgressBar.popupText.foreground",
177: UIManager.getColor("TextField.foreground"),
178: "nbProgressBar.popupText.selectBackground",
179: UIManager.getColor("List.selectionBackground"),
180: "nbProgressBar.popupText.selectForeground",
181: UIManager.getColor("List.selectionForeground"), }; //NOI18N
182:
183: //#108517 - turn off ctrl+page_up and ctrl+page_down mapping
184: return UIUtils
185: .addInputMapsWithoutCtrlPageUpAndCtrlPageDown(result);
186: }
187:
188: public Object[] createGuaranteedKeysAndValues() {
189: return new Object[] {
190: "InternalFrame.activeTitleBackground",
191: new GuaranteedValue(
192: "InternalFrame.activeTitleBackground",
193: Color.BLUE),
194:
195: "InternalFrame.borderShadow",
196: new GuaranteedValue("InternalFrame.borderShadow",
197: Color.gray),
198:
199: "InternalFrame.borderHighlight",
200: new GuaranteedValue("InternalFrame.borderHighlight",
201: Color.white),
202:
203: "InternalFrame.borderDarkShadow",
204: new GuaranteedValue("InternalFrame.borderDarkShadow",
205: Color.darkGray),
206:
207: "InternalFrame.borderLight",
208: new GuaranteedValue("InternalFrame.borderLight",
209: Color.lightGray),
210:
211: "TabbedPane.background",
212: new GuaranteedValue("TabbedPane.background",
213: Color.LIGHT_GRAY),
214:
215: "TabbedPane.focus",
216: new GuaranteedValue("TabbedPane.focus", Color.GRAY),
217:
218: "TabbedPane.highlight",
219: new GuaranteedValue("TabbedPane.highlight", Color.WHITE),
220:
221: "Button.dashedRectGapX",
222: new GuaranteedValue("Button.dashedRectGapX", Integer
223: .valueOf(5)),
224:
225: "Button.dashedRectGapY",
226: new GuaranteedValue("Button.dashedRectGapY", Integer
227: .valueOf(4)),
228:
229: "Button.dashedRectGapWidth",
230: new GuaranteedValue("Button.dashedRectGapWidth",
231: Integer.valueOf(10)),
232:
233: "Button.dashedRectGapHeight",
234: new GuaranteedValue("Button.dashedRectGapHeight",
235: Integer.valueOf(8)),
236:
237: "Tree.expandedIcon", new TreeIcon(false),
238: "Tree.collapsedIcon", new TreeIcon(true) };
239: }
240:
241: private static class TreeIcon implements Icon {
242: private static final int HALF_SIZE = 4;
243: private static final int SIZE = 9;
244:
245: private boolean collapsed;
246:
247: public TreeIcon(boolean collapsed) {
248: this .collapsed = collapsed;
249: }
250:
251: public void paintIcon(Component c, Graphics g, int x, int y) {
252: g.setColor(Color.WHITE);
253: g.fillRect(x, y, SIZE - 1, SIZE - 1);
254: g.setColor(Color.GRAY);
255: g.drawRect(x, y, SIZE - 1, SIZE - 1);
256: g.setColor(Color.BLACK);
257: g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y
258: + HALF_SIZE);
259: if (collapsed) {
260: g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y
261: + (SIZE - 3));
262: }
263: }
264:
265: public int getIconWidth() {
266: return SIZE;
267: }
268:
269: public int getIconHeight() {
270: return SIZE;
271: }
272: }
273:
274: protected Object[] additionalKeys() {
275: Object[] kv = new WinClassicPropertySheetColorings()
276: .createKeysAndValues();
277: Object[] result = new Object[kv.length / 2];
278: int ct = 0;
279: for (int i = 0; i < kv.length; i += 2) {
280: result[ct] = kv[i];
281: ct++;
282: }
283: return result;
284: }
285:
286: private class WinClassicPropertySheetColorings extends
287: UIBootstrapValue.Lazy {
288: public WinClassicPropertySheetColorings() {
289: super (null);
290: }
291:
292: public Object[] createKeysAndValues() {
293: return new Object[] {
294: //Property sheet settings as defined by HIE
295: PROPSHEET_SELECTION_BACKGROUND,
296: new Color(10, 36, 106),
297: PROPSHEET_SELECTION_FOREGROUND, Color.WHITE,
298: PROPSHEET_SET_BACKGROUND, new Color(237, 233, 225),
299: PROPSHEET_SET_FOREGROUND, Color.BLACK,
300: PROPSHEET_SELECTED_SET_BACKGROUND,
301: new Color(10, 36, 106),
302: PROPSHEET_SELECTED_SET_FOREGROUND, Color.WHITE,
303: PROPSHEET_DISABLED_FOREGROUND,
304: new Color(128, 128, 128), PROPSHEET_BUTTON_COLOR,
305: UIManager.getColor("control"), };
306: }
307: }
308: }
|