PageRenderTime 25ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/o.n.swing.plaf/src/org/netbeans/swing/plaf/winclassic/WindowsLFCustoms.java

https://github.com/mark-moseley/Netbeans
Java | 255 lines | 162 code | 41 blank | 52 comment | 5 complexity | fd936035644b8afd4dc9ba9dce09cf89 MD5 | raw file
Possible License(s): 0BSD
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * The contents of this file are subject to the terms of either the GNU
  7. * General Public License Version 2 only ("GPL") or the Common
  8. * Development and Distribution License("CDDL") (collectively, the
  9. * "License"). You may not use this file except in compliance with the
  10. * License. You can obtain a copy of the License at
  11. * http://www.netbeans.org/cddl-gplv2.html
  12. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  13. * specific language governing permissions and limitations under the
  14. * License. When distributing the software, include this License Header
  15. * Notice in each file and include the License file at
  16. * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
  17. * particular file as subject to the "Classpath" exception as provided
  18. * by Sun in the GPL Version 2 section of the License file that
  19. * accompanied this code. If applicable, add the following below the
  20. * License Header, with the fields enclosed by brackets [] replaced by
  21. * your own identifying information:
  22. * "Portions Copyrighted [year] [name of copyright owner]"
  23. *
  24. * Contributor(s):
  25. *
  26. * The Original Software is NetBeans. The Initial Developer of the Original
  27. * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
  28. * Microsystems, Inc. All Rights Reserved.
  29. *
  30. * If you wish your version of this file to be governed by only the CDDL
  31. * or only the GPL Version 2, indicate your decision by adding
  32. * "[Contributor] elects to include this software in this distribution
  33. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  34. * single choice of license, a recipient has the option to distribute
  35. * your version of this file under either the CDDL, the GPL Version 2 or
  36. * to extend the choice of license to its licensees as provided above.
  37. * However, if you add GPL Version 2 code and therefore, elected the GPL
  38. * Version 2 license, then the option applies only if the new code is
  39. * made subject to such option by the copyright holder.
  40. */
  41. package org.netbeans.swing.plaf.winclassic;
  42. import java.awt.Color;
  43. import java.awt.Component;
  44. import java.awt.Font;
  45. import java.awt.Graphics;
  46. import java.awt.Insets;
  47. import javax.swing.BorderFactory;
  48. import javax.swing.Icon;
  49. import javax.swing.UIManager;
  50. import javax.swing.border.EmptyBorder;
  51. import org.netbeans.swing.plaf.LFCustoms;
  52. import org.netbeans.swing.plaf.util.GuaranteedValue;
  53. import org.netbeans.swing.plaf.util.RelativeColor;
  54. import org.netbeans.swing.plaf.util.UIBootstrapValue;
  55. import org.netbeans.swing.plaf.util.UIUtils;
  56. /** Default system-provided customizer for Windows LF
  57. * Public only to be accessible by ProxyLazyValue, please don't abuse.
  58. */
  59. public final class WindowsLFCustoms extends LFCustoms {
  60. public Object[] createLookAndFeelCustomizationKeysAndValues() {
  61. int fontsize = 11;
  62. Integer in = (Integer) UIManager.get(CUSTOM_FONT_SIZE); //NOI18N
  63. if (in != null) {
  64. fontsize = in.intValue();
  65. }
  66. String version = System.getProperty("java.version");
  67. if( version.startsWith("1.5") ) {
  68. //#112473 - wrong password text field height
  69. UIManager.put("PasswordField.font", UIManager.get("TextField.font") );
  70. }
  71. return new Object[] {
  72. //Workaround for help window selection color
  73. "EditorPane.selectionBackground", new Color(157, 157, 255), //NOI18N
  74. //Work around a bug in windows which sets the text area font to
  75. //"MonoSpaced", causing all accessible dialogs to have monospaced text
  76. "TextArea.font", new GuaranteedValue("Label.font", new Font("Dialog", Font.PLAIN, fontsize)), //NOI18N
  77. EDITOR_ERRORSTRIPE_SCROLLBAR_INSETS, new Insets(17, 0, 17, 0),
  78. };
  79. }
  80. public Object[] createApplicationSpecificKeysAndValues () {
  81. Object propertySheetColorings = new WinClassicPropertySheetColorings();
  82. Object[] result = {
  83. DESKTOP_BORDER, new EmptyBorder(4, 2, 1, 2),
  84. SCROLLPANE_BORDER, UIManager.get("ScrollPane.border"),
  85. EXPLORER_STATUS_BORDER, new StatusLineBorder(StatusLineBorder.TOP),
  86. EXPLORER_FOLDER_ICON , UIUtils.loadImage("org/netbeans/swing/plaf/resources/win-explorer-folder.gif"),
  87. EXPLORER_FOLDER_OPENED_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/win-explorer-opened-folder.gif"),
  88. EDITOR_STATUS_LEFT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.RIGHT),
  89. EDITOR_STATUS_RIGHT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT),
  90. EDITOR_STATUS_INNER_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT | StatusLineBorder.RIGHT),
  91. EDITOR_TOOLBAR_BORDER, new EditorToolbarBorder(),
  92. EDITOR_STATUS_ONLYONEBORDER, new StatusLineBorder(StatusLineBorder.TOP),
  93. PROPERTYSHEET_BOOTSTRAP, propertySheetColorings,
  94. EDITOR_TAB_CONTENT_BORDER, new WinClassicCompBorder(),
  95. EDITOR_TAB_TABS_BORDER, new WinClassicTabBorder(),
  96. VIEW_TAB_CONTENT_BORDER, new WinClassicCompBorder(),
  97. VIEW_TAB_TABS_BORDER, new WinClassicTabBorder(),
  98. DESKTOP_SPLITPANE_BORDER, BorderFactory.createEmptyBorder(4, 2, 1, 2),
  99. //UI Delegates for the tab control
  100. EDITOR_TAB_DISPLAYER_UI, "org.netbeans.swing.tabcontrol.plaf.WinClassicEditorTabDisplayerUI",
  101. SLIDING_BUTTON_UI, "org.netbeans.swing.tabcontrol.plaf.WindowsSlidingButtonUI",
  102. VIEW_TAB_DISPLAYER_UI, "org.netbeans.swing.tabcontrol.plaf.WinClassicViewTabDisplayerUI",
  103. PROGRESS_CANCEL_BUTTON_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/cancel_task_win_classic.png"),
  104. //XXX convert to derived colors
  105. "tab_unsel_fill", UIUtils.adjustColor (
  106. new GuaranteedValue("InternalFrame.inactiveTitleGradient",
  107. Color.GRAY).getColor(),
  108. -12, -15, -22),
  109. "tab_sel_fill", new GuaranteedValue("text", Color.WHITE),
  110. "tab_bottom_border", UIUtils.adjustColor (
  111. new GuaranteedValue("InternalFrame.borderShadow",
  112. Color.GRAY).getColor(),
  113. 20, 17, 12),
  114. "winclassic_tab_sel_gradient",
  115. new RelativeColor (
  116. new Color(7, 28, 95),
  117. new Color(152, 177, 208),
  118. "InternalFrame.activeTitleBackground"),
  119. // progress component related
  120. "nbProgressBar.Foreground", new Color(49, 106, 197),
  121. "nbProgressBar.Background", Color.WHITE,
  122. "nbProgressBar.popupDynaText.foreground", new Color(141, 136, 122),
  123. "nbProgressBar.popupText.background", new Color(249, 249, 249),
  124. "nbProgressBar.popupText.foreground", UIManager.getColor("TextField.foreground"),
  125. "nbProgressBar.popupText.selectBackground", UIManager.getColor("List.selectionBackground"),
  126. "nbProgressBar.popupText.selectForeground", UIManager.getColor("List.selectionForeground"),
  127. }; //NOI18N
  128. //#108517 - turn off ctrl+page_up and ctrl+page_down mapping
  129. return UIUtils.addInputMapsWithoutCtrlPageUpAndCtrlPageDown( result );
  130. }
  131. public Object[] createGuaranteedKeysAndValues() {
  132. return new Object[] {
  133. "InternalFrame.activeTitleBackground",
  134. new GuaranteedValue("InternalFrame.activeTitleBackground",
  135. Color.BLUE),
  136. "InternalFrame.borderShadow",
  137. new GuaranteedValue("InternalFrame.borderShadow", Color.gray),
  138. "InternalFrame.borderHighlight",
  139. new GuaranteedValue("InternalFrame.borderHighlight",
  140. Color.white),
  141. "InternalFrame.borderDarkShadow",
  142. new GuaranteedValue("InternalFrame.borderDarkShadow",
  143. Color.darkGray),
  144. "InternalFrame.borderLight",
  145. new GuaranteedValue("InternalFrame.borderLight",
  146. Color.lightGray),
  147. "TabbedPane.background",
  148. new GuaranteedValue("TabbedPane.background", Color.LIGHT_GRAY),
  149. "TabbedPane.focus",
  150. new GuaranteedValue("TabbedPane.focus", Color.GRAY),
  151. "TabbedPane.highlight",
  152. new GuaranteedValue("TabbedPane.highlight", Color.WHITE) ,
  153. "Button.dashedRectGapX",
  154. new GuaranteedValue("Button.dashedRectGapX", Integer.valueOf(5)),
  155. "Button.dashedRectGapY",
  156. new GuaranteedValue("Button.dashedRectGapY", Integer.valueOf(4)),
  157. "Button.dashedRectGapWidth",
  158. new GuaranteedValue("Button.dashedRectGapWidth", Integer.valueOf(10)),
  159. "Button.dashedRectGapHeight",
  160. new GuaranteedValue("Button.dashedRectGapHeight", Integer.valueOf(8)),
  161. "Tree.expandedIcon", new TreeIcon(false),
  162. "Tree.collapsedIcon", new TreeIcon(true)
  163. };
  164. }
  165. private static class TreeIcon implements Icon {
  166. private static final int HALF_SIZE = 4;
  167. private static final int SIZE = 9;
  168. private boolean collapsed;
  169. public TreeIcon (boolean collapsed) {
  170. this.collapsed = collapsed;
  171. }
  172. public void paintIcon(Component c, Graphics g, int x, int y) {
  173. g.setColor(Color.WHITE);
  174. g.fillRect(x, y, SIZE-1, SIZE-1);
  175. g.setColor(Color.GRAY);
  176. g.drawRect(x, y, SIZE-1, SIZE-1);
  177. g.setColor(Color.BLACK);
  178. g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE);
  179. if (collapsed) {
  180. g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
  181. }
  182. }
  183. public int getIconWidth() { return SIZE; }
  184. public int getIconHeight() { return SIZE; }
  185. }
  186. protected Object[] additionalKeys() {
  187. Object[] kv = new WinClassicPropertySheetColorings().createKeysAndValues();
  188. Object[] result = new Object[kv.length / 2];
  189. int ct = 0;
  190. for (int i=0; i < kv.length; i+=2) {
  191. result[ct] = kv[i];
  192. ct++;
  193. }
  194. return result;
  195. }
  196. private class WinClassicPropertySheetColorings extends UIBootstrapValue.Lazy {
  197. public WinClassicPropertySheetColorings () {
  198. super (null);
  199. }
  200. public Object[] createKeysAndValues() {
  201. return new Object[] {
  202. //Property sheet settings as defined by HIE
  203. PROPSHEET_SELECTION_BACKGROUND, new Color(10,36,106),
  204. PROPSHEET_SELECTION_FOREGROUND, Color.WHITE,
  205. PROPSHEET_SET_BACKGROUND, new Color(237,233,225),
  206. PROPSHEET_SET_FOREGROUND, Color.BLACK,
  207. PROPSHEET_SELECTED_SET_BACKGROUND, new Color(10,36,106),
  208. PROPSHEET_SELECTED_SET_FOREGROUND, Color.WHITE,
  209. PROPSHEET_DISABLED_FOREGROUND, new Color(128,128,128),
  210. PROPSHEET_BUTTON_COLOR, UIManager.getColor("control"),
  211. };
  212. }
  213. }
  214. }