001: /*
002: * Copyright 2005 Patrick Gotthardt
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package com.pagosoft.plaf;
017:
018: import javax.swing.*;
019: import javax.swing.plaf.metal.*;
020: import java.awt.*;
021: import java.util.HashMap;
022:
023: public class PlafOptions {
024: private static boolean vistaStyle;
025:
026: private PlafOptions() {
027: }
028:
029: // --------------------------------------------------------
030: // Global things
031: public static void setAsLookAndFeel() {
032: PgsLookAndFeel.setAsLookAndFeel();
033: }
034:
035: public static void setCurrentTheme(MetalTheme t) {
036: PgsLookAndFeel.setCurrentTheme(t);
037: }
038:
039: public static void updateAllUIs() {
040: PgsLookAndFeel.updateAllUIs();
041: }
042:
043: private static Dimension defIconSize = new Dimension(10, 10);
044:
045: public static void setDefaultMenuItemIconSize(Dimension dim) {
046: defIconSize = dim;
047: }
048:
049: public static Dimension getDefaultMenuItemIconSize() {
050: return defIconSize;
051: }
052:
053: // --------------------------------------------------------
054: // Narrows
055: private static boolean useExtraMargin = true;
056:
057: public static boolean useExtraMargin() {
058: return useExtraMargin;
059: }
060:
061: public static void useExtraMargin(boolean use) {
062: useExtraMargin = use;
063: }
064:
065: // --------------------------------------------------------
066: // Use bold fonts?
067: private static boolean useBoldFonts = false;
068: private static boolean useBoldMenuFonts = true;
069:
070: public static boolean useBoldFonts() {
071: return useBoldFonts;
072: }
073:
074: public static void useBoldFonts(boolean use) {
075: useBoldFonts = use;
076: UIManager.put("swing.boldMetal", Boolean.valueOf(use));
077: }
078:
079: public static boolean useBoldMenuFonts() {
080: return useBoldMenuFonts;
081: }
082:
083: public static void useBoldMenuFonts(boolean use) {
084: useBoldMenuFonts = use;
085: }
086:
087: // --------------------------------------------------------
088: // Component options
089: private static boolean useShadowBorder = false;
090:
091: public static void useShadowBorder(boolean use) {
092: useShadowBorder = use;
093: }
094:
095: public static boolean isShadowBorderUsed() {
096: return useShadowBorder;
097: }
098:
099: private static boolean useToolBarIcon = true;
100:
101: public static void useToolBarIcon(boolean use) {
102: useToolBarIcon = use;
103: }
104:
105: public static boolean isToolBarIconUsed() {
106: return useToolBarIcon;
107: }
108:
109: private static boolean useDisabledIcon = true;
110:
111: public static void useDisabledIcon(boolean use) {
112: useDisabledIcon = use;
113: }
114:
115: public static boolean isDisabledIconUsed() {
116: return useDisabledIcon;
117: }
118:
119: private static boolean aaText = false;
120:
121: public static void setAntialiasingEnabled(boolean use) {
122: aaText = use;
123: }
124:
125: public static boolean isAntialiasingEnabled() {
126: return aaText;
127: }
128:
129: private static boolean isClearBorderEnabled = false;
130:
131: public static void setClearBorderEnabled(boolean enabled) {
132: PgsUtils.regenerateBorderStroke();
133: isClearBorderEnabled = enabled;
134: }
135:
136: public static boolean isClearBorderEnabled() {
137: return isClearBorderEnabled;
138: }
139:
140: private static boolean fixHtmlDisplay = true;
141:
142: public static boolean isHtmlDisplayFixEnabled() {
143: return fixHtmlDisplay;
144: }
145:
146: public static void setFixHtmlDisplayEnabled(
147: boolean aFixHtmlDisplayEnabled) {
148: fixHtmlDisplay = aFixHtmlDisplayEnabled;
149: }
150:
151: private static boolean wheelTabbedPaneEnabled = true;
152:
153: public static boolean isWheelTabbedPaneEnabled() {
154: return wheelTabbedPaneEnabled;
155: }
156:
157: public static void setWheelTabbedPaneEnabled(boolean enabled) {
158: wheelTabbedPaneEnabled = enabled;
159: }
160:
161: private static boolean tabbedPaneRightClickSelectionEnabled = false;
162:
163: public static boolean isTabbedPaneRightClickSelectionEnabled() {
164: return tabbedPaneRightClickSelectionEnabled;
165: }
166:
167: public static void setTabbedPaneRightClickSelectionEnabled(
168: boolean enabled) {
169: tabbedPaneRightClickSelectionEnabled = enabled;
170: }
171:
172: private static boolean tabReorderingEnabled = false;
173:
174: public static boolean isTabReorderingEnabled() {
175: return tabReorderingEnabled;
176: }
177:
178: public static void setTabReorderingEnabled(boolean enabled) {
179: tabReorderingEnabled = enabled;
180: }
181:
182: private static boolean paintRolloverButtonBorder = true;
183:
184: public static boolean isPaintRolloverButtonBorder() {
185: return paintRolloverButtonBorder;
186: }
187:
188: public static void setPaintRolloverButtonBorder(
189: boolean paintRolloverButtonBorder) {
190: PlafOptions.paintRolloverButtonBorder = paintRolloverButtonBorder;
191: }
192:
193: private static boolean officeScrollBarEnabled = false;
194:
195: public static boolean isOfficeScrollBarEnabled() {
196: return officeScrollBarEnabled;
197: }
198:
199: public static void setOfficeScrollBarEnabled(
200: boolean officeScrollBarEnabled) {
201: PlafOptions.officeScrollBarEnabled = officeScrollBarEnabled;
202: }
203:
204: // --------------------------------------------------------
205: // Style
206: public static final int FLAT_STYLE = 0;
207: public static final int GRADIENT_STYLE = 1;
208: private static int defStyle = GRADIENT_STYLE;
209:
210: public static final String MENU_ITEM = "MenuItem";
211: public static final String TOOLBAR = "ToolBar";
212: public static final String BUTTON = "Button";
213: public static final String TOOLBARBUTTON = "ToolBarButton";
214: public static final String MENUBAR = "MenuBar";
215: public static final String MENUBARMENU = "MenuBarMenu";
216:
217: private static HashMap styles = new HashMap();
218:
219: static {
220: // Initialize some styles per default
221: setStyle(MENU_ITEM, FLAT_STYLE);
222: setStyle(MENUBAR, FLAT_STYLE);
223: setStyle(MENUBARMENU, FLAT_STYLE);
224:
225: setStyle(TOOLBAR, GRADIENT_STYLE);
226: setStyle(TOOLBARBUTTON, GRADIENT_STYLE);
227: }
228:
229: public static void setDefaultStyle(int s) {
230: if (s == FLAT_STYLE || s == GRADIENT_STYLE) {
231: defStyle = s;
232: } else {
233: throw new IllegalArgumentException(
234: "The Style must be flat or gradient");
235: }
236: }
237:
238: public static void setStyle(String key, int s) {
239: if (s == FLAT_STYLE || s == GRADIENT_STYLE) {
240: styles.put(key, new Integer(s));
241: } else {
242: throw new IllegalArgumentException(
243: "The Style must be flat or gradient");
244: }
245: }
246:
247: public static int getStyle(String key) {
248: if (styles.containsKey(key)) {
249: return ((Integer) styles.get(key)).intValue();
250: }
251: return defStyle;
252: }
253:
254: public static Boolean isFlat(String key) {
255: return getStyle(key) == FLAT_STYLE ? Boolean.TRUE
256: : Boolean.FALSE;
257: }
258:
259: // Jide-stuff
260: private static boolean fastGradient = false;
261:
262: public static void enableJideFastGradient() {
263: // verify usage of jidesoft's SwingUtilities
264: com.jidesoft.utils.Lm.verifyLicense("Patrick Gotthardt",
265: "PgsLookAndFeel", "aW6dEcgCQMkW4e:OGYJCDdPATGYEiLo2");
266:
267: fastGradient = true;
268: }
269:
270: public static boolean isJideFastGradientEnabled() {
271: return fastGradient;
272: }
273:
274: public static boolean isVistaStyle() {
275: return vistaStyle;
276: }
277:
278: public static void setVistaStyle(boolean vistaStyle) {
279: PlafOptions.vistaStyle = vistaStyle;
280: }
281: }
|