1 /* 2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 /* 27 * <p>These classes are designed to be used while the 28 * corresponding <code>LookAndFeel</code> class has been installed 29 * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>). 30 * Using them while a different <code>LookAndFeel</code> is installed 31 * may produce unexpected results, including exceptions. 32 * Additionally, changing the <code>LookAndFeel</code> 33 * maintained by the <code>UIManager</code> without updating the 34 * corresponding <code>ComponentUI</code> of any 35 * <code>JComponent</code>s may also produce unexpected results, 36 * such as the wrong colors showing up, and is generally not 37 * encouraged. 38 * 39 */ 40 41 package com.sun.java.swing.plaf.windows; 42 43 import java.awt.*; 44 import java.awt.image.*; 45 import java.security.AccessController; 46 import java.util.*; 47 48 import javax.swing.*; 49 import javax.swing.border.*; 50 import javax.swing.plaf.*; 51 import javax.swing.text.JTextComponent; 52 53 import sun.awt.image.SunWritableRaster; 54 import sun.awt.windows.ThemeReader; 55 import sun.security.action.GetPropertyAction; 56 import sun.swing.CachedPainter; 57 58 import static com.sun.java.swing.plaf.windows.TMSchema.*; 59 60 61 /** 62 * Implements Windows XP Styles for the Windows Look and Feel. 63 * 64 * @author Leif Samuelsson 65 */ 66 class XPStyle { 67 // Singleton instance of this class 68 private static XPStyle xp; 69 70 // Singleton instance of SkinPainter 71 private static SkinPainter skinPainter = new SkinPainter(); 72 73 private static Boolean themeActive = null; 74 75 private HashMap<String, Border> borderMap; 76 private HashMap<String, Color> colorMap; 77 78 private boolean flatMenus; 79 80 static { 81 invalidateStyle(); 82 } 83 84 /** Static method for clearing the hashmap and loading the 85 * current XP style and theme 86 */ 87 static synchronized void invalidateStyle() { 88 xp = null; 89 themeActive = null; 90 skinPainter.flush(); 91 } 92 93 /** Get the singleton instance of this class 94 * 95 * @return the singleton instance of this class or null if XP styles 96 * are not active or if this is not Windows XP 97 */ 98 static synchronized XPStyle getXP() { 99 if (themeActive == null) { 100 Toolkit toolkit = Toolkit.getDefaultToolkit(); 101 themeActive = 102 (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive"); 103 if (themeActive == null) { 104 themeActive = Boolean.FALSE; 105 } 106 if (themeActive.booleanValue()) { 107 GetPropertyAction propertyAction = 108 new GetPropertyAction("swing.noxp"); 109 if (AccessController.doPrivileged(propertyAction) == null && 110 ThemeReader.isThemed() && 111 !(UIManager.getLookAndFeel() 112 instanceof WindowsClassicLookAndFeel)) { 113 114 xp = new XPStyle(); 115 } 116 } 117 } 118 return xp; 119 } 120 121 static boolean isVista() { 122 XPStyle xp = XPStyle.getXP(); 123 return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT)); 124 } 125 126 /** Get a named <code>String</code> value from the current style 127 * 128 * @param part a <code>Part</code> 129 * @param state a <code>String</code> 130 * @param attributeKey a <code>String</code> 131 * @return a <code>String</code> or null if key is not found 132 * in the current style 133 * 134 * This is currently only used by WindowsInternalFrameTitlePane for painting 135 * title foregound and can be removed when no longer needed 136 */ 137 String getString(Component c, Part part, State state, Prop prop) { 138 return getTypeEnumName(c, part, state, prop); 139 } 140 141 TypeEnum getTypeEnum(Component c, Part part, State state, Prop prop) { 142 int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(), 143 State.getValue(part, state), 144 prop.getValue()); 145 return TypeEnum.getTypeEnum(prop, enumValue); 146 } 147 148 private static String getTypeEnumName(Component c, Part part, State state, Prop prop) { 149 int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(), 150 State.getValue(part, state), 151 prop.getValue()); 152 if (enumValue == -1) { 153 return null; 154 } 155 return TypeEnum.getTypeEnum(prop, enumValue).getName(); 156 } 157 158 159 160 161 /** Get a named <code>int</code> value from the current style 162 * 163 * @param part a <code>Part</code> 164 * @return an <code>int</code> or null if key is not found 165 * in the current style 166 */ 167 int getInt(Component c, Part part, State state, Prop prop, int fallback) { 168 return ThemeReader.getInt(part.getControlName(c), part.getValue(), 169 State.getValue(part, state), 170 prop.getValue()); 171 } 172 173 /** Get a named <code>Dimension</code> value from the current style 174 * 175 * @param key a <code>String</code> 176 * @return a <code>Dimension</code> or null if key is not found 177 * in the current style 178 * 179 * This is currently only used by WindowsProgressBarUI and the value 180 * should probably be cached there instead of here. 181 */ 182 Dimension getDimension(Component c, Part part, State state, Prop prop) { 183 return ThemeReader.getPosition(part.getControlName(c), part.getValue(), 184 State.getValue(part, state), 185 prop.getValue()); 186 } 187 188 /** Get a named <code>Point</code> (e.g. a location or an offset) value 189 * from the current style 190 * 191 * @param key a <code>String</code> 192 * @return a <code>Point</code> or null if key is not found 193 * in the current style 194 * 195 * This is currently only used by WindowsInternalFrameTitlePane for painting 196 * title foregound and can be removed when no longer needed 197 */ 198 Point getPoint(Component c, Part part, State state, Prop prop) { 199 Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), 200 State.getValue(part, state), 201 prop.getValue()); 202 if (d != null) { 203 return new Point(d.width, d.height); 204 } else { 205 return null; 206 } 207 } 208 209 /** Get a named <code>Insets</code> value from the current style 210 * 211 * @param key a <code>String</code> 212 * @return an <code>Insets</code> object or null if key is not found 213 * in the current style 214 * 215 * This is currently only used to create borders and by 216 * WindowsInternalFrameTitlePane for painting title foregound. 217 * The return value is already cached in those places. 218 */ 219 Insets getMargin(Component c, Part part, State state, Prop prop) { 220 return ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(), 221 State.getValue(part, state), 222 prop.getValue()); 223 } 224 225 226 /** Get a named <code>Color</code> value from the current style 227 * 228 * @param part a <code>Part</code> 229 * @return a <code>Color</code> or null if key is not found 230 * in the current style 231 */ 232 synchronized Color getColor(Skin skin, Prop prop, Color fallback) { 233 String key = skin.toString() + "." + prop.name(); 234 Part part = skin.part; 235 Color color = colorMap.get(key); 236 if (color == null) { 237 color = ThemeReader.getColor(part.getControlName(null), part.getValue(), 238 State.getValue(part, skin.state), 239 prop.getValue()); 240 if (color != null) { 241 color = new ColorUIResource(color); 242 colorMap.put(key, color); 243 } 244 } 245 return (color != null) ? color : fallback; 246 } 247 248 Color getColor(Component c, Part part, State state, Prop prop, Color fallback) { 249 return getColor(new Skin(c, part, state), prop, fallback); 250 } 251 252 253 254 /** Get a named <code>Border</code> value from the current style 255 * 256 * @param part a <code>Part</code> 257 * @return a <code>Border</code> or null if key is not found 258 * in the current style or if the style for the particular 259 * part is not defined as "borderfill". 260 */ 261 synchronized Border getBorder(Component c, Part part) { 262 if (part == Part.MENU) { 263 // Special case because XP has no skin for menus 264 if (flatMenus) { 265 // TODO: The classic border uses this color, but we should 266 // create a new UI property called "PopupMenu.borderColor" 267 // instead. 268 return new XPFillBorder(UIManager.getColor("InternalFrame.borderShadow"), 269 1); 270 } else { 271 return null; // Will cause L&F to use classic border 272 } 273 } 274 Skin skin = new Skin(c, part, null); 275 Border border = borderMap.get(skin.string); 276 if (border == null) { 277 String bgType = getTypeEnumName(c, part, null, Prop.BGTYPE); 278 if ("borderfill".equalsIgnoreCase(bgType)) { 279 int thickness = getInt(c, part, null, Prop.BORDERSIZE, 1); 280 Color color = getColor(skin, Prop.BORDERCOLOR, Color.black); 281 border = new XPFillBorder(color, thickness); 282 if (part == Part.CP_COMBOBOX) { 283 border = new XPStatefulFillBorder(color, thickness, part, Prop.BORDERCOLOR); 284 } 285 } else if ("imagefile".equalsIgnoreCase(bgType)) { 286 Insets m = getMargin(c, part, null, Prop.SIZINGMARGINS); 287 if (m != null) { 288 if (getBoolean(c, part, null, Prop.BORDERONLY)) { 289 border = new XPImageBorder(c, part); 290 } else if (part == Part.CP_COMBOBOX) { 291 border = new EmptyBorder(1, 1, 1, 1); 292 } else { 293 if(part == Part.TP_BUTTON) { 294 border = new XPEmptyBorder(new Insets(3,3,3,3)); 295 } else { 296 border = new XPEmptyBorder(m); 297 } 298 } 299 } 300 } 301 if (border != null) { 302 borderMap.put(skin.string, border); 303 } 304 } 305 return border; 306 } 307 308 @SuppressWarnings("serial") // Superclass is not serializable across versions 309 private class XPFillBorder extends LineBorder implements UIResource { 310 XPFillBorder(Color color, int thickness) { 311 super(color, thickness); 312 } 313 314 public Insets getBorderInsets(Component c, Insets insets) { 315 Insets margin = null; 316 // 317 // Ideally we'd have an interface defined for classes which 318 // support margins (to avoid this hackery), but we've 319 // decided against it for simplicity 320 // 321 if (c instanceof AbstractButton) { 322 margin = ((AbstractButton)c).getMargin(); 323 } else if (c instanceof JToolBar) { 324 margin = ((JToolBar)c).getMargin(); 325 } else if (c instanceof JTextComponent) { 326 margin = ((JTextComponent)c).getMargin(); 327 } 328 insets.top = (margin != null? margin.top : 0) + thickness; 329 insets.left = (margin != null? margin.left : 0) + thickness; 330 insets.bottom = (margin != null? margin.bottom : 0) + thickness; 331 insets.right = (margin != null? margin.right : 0) + thickness; 332 333 return insets; 334 } 335 } 336 337 @SuppressWarnings("serial") // Superclass is not serializable across versions 338 private class XPStatefulFillBorder extends XPFillBorder { 339 private final Part part; 340 private final Prop prop; 341 XPStatefulFillBorder(Color color, int thickness, Part part, Prop prop) { 342 super(color, thickness); 343 this.part = part; 344 this.prop = prop; 345 } 346 347 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { 348 State state = State.NORMAL; 349 // special casing for comboboxes. 350 // there may be more special cases in the future 351 if(c instanceof JComboBox) { 352 JComboBox<?> cb = (JComboBox)c; 353 // note. in the future this should be replaced with a call 354 // to BasicLookAndFeel.getUIOfType() 355 if(cb.getUI() instanceof WindowsComboBoxUI) { 356 WindowsComboBoxUI wcb = (WindowsComboBoxUI)cb.getUI(); 357 state = wcb.getXPComboBoxState(cb); 358 } 359 } 360 lineColor = getColor(c, part, state, prop, Color.black); 361 super.paintBorder(c, g, x, y, width, height); 362 } 363 } 364 365 @SuppressWarnings("serial") // Superclass is not serializable across versions 366 private class XPImageBorder extends AbstractBorder implements UIResource { 367 Skin skin; 368 369 XPImageBorder(Component c, Part part) { 370 this.skin = getSkin(c, part); 371 } 372 373 public void paintBorder(Component c, Graphics g, 374 int x, int y, int width, int height) { 375 skin.paintSkin(g, x, y, width, height, null); 376 } 377 378 public Insets getBorderInsets(Component c, Insets insets) { 379 Insets margin = null; 380 Insets borderInsets = skin.getContentMargin(); 381 if(borderInsets == null) { 382 borderInsets = new Insets(0, 0, 0, 0); 383 } 384 // 385 // Ideally we'd have an interface defined for classes which 386 // support margins (to avoid this hackery), but we've 387 // decided against it for simplicity 388 // 389 if (c instanceof AbstractButton) { 390 margin = ((AbstractButton)c).getMargin(); 391 } else if (c instanceof JToolBar) { 392 margin = ((JToolBar)c).getMargin(); 393 } else if (c instanceof JTextComponent) { 394 margin = ((JTextComponent)c).getMargin(); 395 } 396 insets.top = (margin != null? margin.top : 0) + borderInsets.top; 397 insets.left = (margin != null? margin.left : 0) + borderInsets.left; 398 insets.bottom = (margin != null? margin.bottom : 0) + borderInsets.bottom; 399 insets.right = (margin != null? margin.right : 0) + borderInsets.right; 400 401 return insets; 402 } 403 } 404 405 @SuppressWarnings("serial") // Superclass is not serializable across versions 406 private class XPEmptyBorder extends EmptyBorder implements UIResource { 407 XPEmptyBorder(Insets m) { 408 super(m.top+2, m.left+2, m.bottom+2, m.right+2); 409 } 410 411 public Insets getBorderInsets(Component c, Insets insets) { 412 insets = super.getBorderInsets(c, insets); 413 414 Insets margin = null; 415 if (c instanceof AbstractButton) { 416 Insets m = ((AbstractButton)c).getMargin(); 417 // if this is a toolbar button then ignore getMargin() 418 // and subtract the padding added by the constructor 419 if(c.getParent() instanceof JToolBar 420 && ! (c instanceof JRadioButton) 421 && ! (c instanceof JCheckBox) 422 && m instanceof InsetsUIResource) { 423 insets.top -= 2; 424 insets.left -= 2; 425 insets.bottom -= 2; 426 insets.right -= 2; 427 } else { 428 margin = m; 429 } 430 } else if (c instanceof JToolBar) { 431 margin = ((JToolBar)c).getMargin(); 432 } else if (c instanceof JTextComponent) { 433 margin = ((JTextComponent)c).getMargin(); 434 } 435 if (margin != null) { 436 insets.top = margin.top + 2; 437 insets.left = margin.left + 2; 438 insets.bottom = margin.bottom + 2; 439 insets.right = margin.right + 2; 440 } 441 return insets; 442 } 443 } 444 boolean isSkinDefined(Component c, Part part) { 445 return (part.getValue() == 0) 446 || ThemeReader.isThemePartDefined( 447 part.getControlName(c), part.getValue(), 0); 448 } 449 450 451 /** Get a <code>Skin</code> object from the current style 452 * for a named part (component type) 453 * 454 * @param part a <code>Part</code> 455 * @return a <code>Skin</code> object 456 */ 457 synchronized Skin getSkin(Component c, Part part) { 458 assert isSkinDefined(c, part) : "part " + part + " is not defined"; 459 return new Skin(c, part, null); 460 } 461 462 463 long getThemeTransitionDuration(Component c, Part part, State stateFrom, 464 State stateTo, Prop prop) { 465 return ThemeReader.getThemeTransitionDuration(part.getControlName(c), 466 part.getValue(), 467 State.getValue(part, stateFrom), 468 State.getValue(part, stateTo), 469 (prop != null) ? prop.getValue() : 0); 470 } 471 472 473 /** A class which encapsulates attributes for a given part 474 * (component type) and which provides methods for painting backgrounds 475 * and glyphs 476 */ 477 static class Skin { 478 final Component component; 479 final Part part; 480 final State state; 481 482 private final String string; 483 private Dimension size = null; 484 485 Skin(Component component, Part part) { 486 this(component, part, null); 487 } 488 489 Skin(Part part, State state) { 490 this(null, part, state); 491 } 492 493 Skin(Component component, Part part, State state) { 494 this.component = component; 495 this.part = part; 496 this.state = state; 497 498 String str = part.getControlName(component) +"." + part.name(); 499 if (state != null) { 500 str += "("+state.name()+")"; 501 } 502 string = str; 503 } 504 505 Insets getContentMargin() { 506 /* idk: it seems margins are the same for all 'big enough' 507 * bounding rectangles. 508 */ 509 int boundingWidth = 100; 510 int boundingHeight = 100; 511 512 return ThemeReader.getThemeBackgroundContentMargins( 513 part.getControlName(null), part.getValue(), 514 0, boundingWidth, boundingHeight); 515 } 516 517 private int getWidth(State state) { 518 if (size == null) { 519 size = getPartSize(part, state); 520 } 521 return size.width; 522 } 523 524 int getWidth() { 525 return getWidth((state != null) ? state : State.NORMAL); 526 } 527 528 private int getHeight(State state) { 529 if (size == null) { 530 size = getPartSize(part, state); 531 } 532 return size.height; 533 } 534 535 int getHeight() { 536 return getHeight((state != null) ? state : State.NORMAL); 537 } 538 539 public String toString() { 540 return string; 541 } 542 543 public boolean equals(Object obj) { 544 return (obj instanceof Skin && ((Skin)obj).string.equals(string)); 545 } 546 547 public int hashCode() { 548 return string.hashCode(); 549 } 550 551 /** Paint a skin at x, y. 552 * 553 * @param g the graphics context to use for painting 554 * @param dx the destination <i>x</i> coordinate 555 * @param dy the destination <i>y</i> coordinate 556 * @param state which state to paint 557 */ 558 void paintSkin(Graphics g, int dx, int dy, State state) { 559 if (state == null) { 560 state = this.state; 561 } 562 paintSkin(g, dx, dy, getWidth(state), getHeight(state), state); 563 } 564 565 /** Paint a skin in an area defined by a rectangle. 566 * 567 * @param g the graphics context to use for painting 568 * @param r a <code>Rectangle</code> defining the area to fill, 569 * may cause the image to be stretched or tiled 570 * @param state which state to paint 571 */ 572 void paintSkin(Graphics g, Rectangle r, State state) { 573 paintSkin(g, r.x, r.y, r.width, r.height, state); 574 } 575 576 /** Paint a skin at a defined position and size 577 * This method supports animation. 578 * 579 * @param g the graphics context to use for painting 580 * @param dx the destination <i>x</i> coordinate 581 * @param dy the destination <i>y</i> coordinate 582 * @param dw the width of the area to fill, may cause 583 * the image to be stretched or tiled 584 * @param dh the height of the area to fill, may cause 585 * the image to be stretched or tiled 586 * @param state which state to paint 587 */ 588 void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) { 589 if (ThemeReader.isGetThemeTransitionDurationDefined() 590 && component instanceof JComponent 591 && SwingUtilities.getAncestorOfClass(CellRendererPane.class, 592 component) == null) { 593 AnimationController.paintSkin((JComponent) component, this, 594 g, dx, dy, dw, dh, state); 595 } else { 596 paintSkinRaw(g, dx, dy, dw, dh, state); 597 } 598 } 599 600 /** Paint a skin at a defined position and size. This method 601 * does not trigger animation. It is needed for the animation 602 * support. 603 * 604 * @param g the graphics context to use for painting 605 * @param dx the destination <i>x</i> coordinate. 606 * @param dy the destination <i>y</i> coordinate. 607 * @param dw the width of the area to fill, may cause 608 * the image to be stretched or tiled 609 * @param dh the height of the area to fill, may cause 610 * the image to be stretched or tiled 611 * @param state which state to paint 612 */ 613 void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) { 614 skinPainter.paint(null, g, dx, dy, dw, dh, this, state); 615 } 616 617 /** Paint a skin at a defined position and size 618 * 619 * @param g the graphics context to use for painting 620 * @param dx the destination <i>x</i> coordinate 621 * @param dy the destination <i>y</i> coordinate 622 * @param dw the width of the area to fill, may cause 623 * the image to be stretched or tiled 624 * @param dh the height of the area to fill, may cause 625 * the image to be stretched or tiled 626 * @param state which state to paint 627 * @param borderFill should test if the component uses a border fill 628 and skip painting if it is 629 */ 630 void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state, 631 boolean borderFill) { 632 if(borderFill && "borderfill".equals(getTypeEnumName(component, part, 633 state, Prop.BGTYPE))) { 634 return; 635 } 636 skinPainter.paint(null, g, dx, dy, dw, dh, this, state); 637 } 638 } 639 640 private static class SkinPainter extends CachedPainter { 641 SkinPainter() { 642 super(30); 643 flush(); 644 } 645 646 public void flush() { 647 super.flush(); 648 } 649 650 protected void paintToImage(Component c, Image image, Graphics g, 651 int w, int h, Object[] args) { 652 boolean accEnabled = false; 653 Skin skin = (Skin)args[0]; 654 Part part = skin.part; 655 State state = (State)args[1]; 656 if (state == null) { 657 state = skin.state; 658 } 659 if (c == null) { 660 c = skin.component; 661 } 662 BufferedImage bi = (BufferedImage)image; 663 664 WritableRaster raster = bi.getRaster(); 665 DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer(); 666 // Note that stealData() requires a markDirty() afterwards 667 // since we modify the data in it. 668 ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0), 669 part.getControlName(c), part.getValue(), 670 State.getValue(part, state), 671 0, 0, w, h, w); 672 SunWritableRaster.markDirty(dbi); 673 } 674 675 protected Image createImage(Component c, int w, int h, 676 GraphicsConfiguration config, Object[] args) { 677 return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 678 } 679 } 680 681 @SuppressWarnings("serial") // Superclass is not serializable across versions 682 static class GlyphButton extends JButton { 683 private Skin skin; 684 685 public GlyphButton(Component parent, Part part) { 686 XPStyle xp = getXP(); 687 skin = xp.getSkin(parent, part); 688 setBorder(null); 689 setContentAreaFilled(false); 690 setMinimumSize(new Dimension(5, 5)); 691 setPreferredSize(new Dimension(16, 16)); 692 setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); 693 } 694 695 public boolean isFocusTraversable() { 696 return false; 697 } 698 699 protected State getState() { 700 State state = State.NORMAL; 701 if (!isEnabled()) { 702 state = State.DISABLED; 703 } else if (getModel().isPressed()) { 704 state = State.PRESSED; 705 } else if (getModel().isRollover()) { 706 state = State.HOT; 707 } 708 return state; 709 } 710 711 public void paintComponent(Graphics g) { 712 Dimension d = getSize(); 713 skin.paintSkin(g, 0, 0, d.width, d.height, getState()); 714 } 715 716 public void setPart(Component parent, Part part) { 717 XPStyle xp = getXP(); 718 skin = xp.getSkin(parent, part); 719 revalidate(); 720 repaint(); 721 } 722 723 protected void paintBorder(Graphics g) { 724 } 725 726 727 } 728 729 // Private constructor 730 private XPStyle() { 731 flatMenus = getSysBoolean(Prop.FLATMENUS); 732 733 colorMap = new HashMap<String, Color>(); 734 borderMap = new HashMap<String, Border>(); 735 // Note: All further access to the maps must be synchronized 736 } 737 738 739 private boolean getBoolean(Component c, Part part, State state, Prop prop) { 740 return ThemeReader.getBoolean(part.getControlName(c), part.getValue(), 741 State.getValue(part, state), 742 prop.getValue()); 743 } 744 745 746 747 static Dimension getPartSize(Part part, State state) { 748 return ThemeReader.getPartSize(part.getControlName(null), part.getValue(), 749 State.getValue(part, state)); 750 } 751 752 private static boolean getSysBoolean(Prop prop) { 753 // We can use any widget name here, I guess. 754 return ThemeReader.getSysBoolean("window", prop.getValue()); 755 } 756 }