1 /*
2 * Copyright (c) 2001, 2013, 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
69
70 titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
71 buttonWidth = UIManager.getInt("InternalFrame.titleButtonWidth") - 4;
72 buttonHeight = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;
73
74 Object obj = UIManager.get("InternalFrame.titleButtonToolTipsOn");
75 hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
76
77
78 if (XPStyle.getXP() != null) {
79 // Fix for XP bug where sometimes these sizes aren't updated properly
80 // Assume for now that height is correct and derive width using the
81 // ratio from the uxtheme part
82 buttonWidth = buttonHeight;
83 Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
84 if (d != null && d.width != 0 && d.height != 0) {
85 buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
86 }
87 } else {
88 buttonWidth += 2;
89 selectedTitleGradientColor =
90 UIManager.getColor("InternalFrame.activeTitleGradient");
91 notSelectedTitleGradientColor =
92 UIManager.getColor("InternalFrame.inactiveTitleGradient");
93 Color activeBorderColor =
94 UIManager.getColor("InternalFrame.activeBorderColor");
95 setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
96 }
97 }
98
99 protected void uninstallListeners() {
100 // Get around protected method in superclass
101 super.uninstallListeners();
102 }
103
104 protected void createButtons() {
105 super.createButtons();
106 if (XPStyle.getXP() != null) {
107 iconButton.setContentAreaFilled(false);
108 maxButton.setContentAreaFilled(false);
109 closeButton.setContentAreaFilled(false);
110 }
111 }
112
113 protected void setButtonIcons() {
114 super.setButtonIcons();
115
116 if (!hotTrackingOn) {
371 getY() + getHeight() - dim.height);
372 } else {
373 systemPopupMenu.show(invoker,
374 getX() - dim.width,
375 getY() - systemPopupMenu.getPreferredSize().height -
376 dim.height);
377 }
378 }
379
380 protected PropertyChangeListener createPropertyChangeListener() {
381 return new WindowsPropertyChangeHandler();
382 }
383
384 protected LayoutManager createLayout() {
385 return new WindowsTitlePaneLayout();
386 }
387
388 public class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout {
389 private Insets captionMargin = null;
390 private Insets contentMargin = null;
391 private XPStyle xp = XPStyle.getXP();
392
393 WindowsTitlePaneLayout() {
394 if (xp != null) {
395 Component c = WindowsInternalFrameTitlePane.this;
396 captionMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CAPTIONMARGINS);
397 contentMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CONTENTMARGINS);
398 }
399 if (captionMargin == null) {
400 captionMargin = new Insets(0, 2, 0, 2);
401 }
402 if (contentMargin == null) {
403 contentMargin = new Insets(0, 0, 0, 0);
404 }
405 }
406
407 private int layoutButton(JComponent button, Part part,
408 int x, int y, int w, int h, int gap,
409 boolean leftToRight) {
410 if (!leftToRight) {
411 x -= w;
|
1 /*
2 * Copyright (c) 2001, 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
69
70 titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
71 buttonWidth = UIManager.getInt("InternalFrame.titleButtonWidth") - 4;
72 buttonHeight = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;
73
74 Object obj = UIManager.get("InternalFrame.titleButtonToolTipsOn");
75 hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
76
77
78 if (XPStyle.getXP() != null) {
79 // Fix for XP bug where sometimes these sizes aren't updated properly
80 // Assume for now that height is correct and derive width using the
81 // ratio from the uxtheme part
82 buttonWidth = buttonHeight;
83 Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
84 if (d != null && d.width != 0 && d.height != 0) {
85 buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
86 }
87 } else {
88 buttonWidth += 2;
89 Color activeBorderColor =
90 UIManager.getColor("InternalFrame.activeBorderColor");
91 setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
92 }
93 // JDK-8039383: initialize these colors because getXP() may return null when theme is changed
94 selectedTitleGradientColor =
95 UIManager.getColor("InternalFrame.activeTitleGradient");
96 notSelectedTitleGradientColor =
97 UIManager.getColor("InternalFrame.inactiveTitleGradient");
98 }
99
100 protected void uninstallListeners() {
101 // Get around protected method in superclass
102 super.uninstallListeners();
103 }
104
105 protected void createButtons() {
106 super.createButtons();
107 if (XPStyle.getXP() != null) {
108 iconButton.setContentAreaFilled(false);
109 maxButton.setContentAreaFilled(false);
110 closeButton.setContentAreaFilled(false);
111 }
112 }
113
114 protected void setButtonIcons() {
115 super.setButtonIcons();
116
117 if (!hotTrackingOn) {
372 getY() + getHeight() - dim.height);
373 } else {
374 systemPopupMenu.show(invoker,
375 getX() - dim.width,
376 getY() - systemPopupMenu.getPreferredSize().height -
377 dim.height);
378 }
379 }
380
381 protected PropertyChangeListener createPropertyChangeListener() {
382 return new WindowsPropertyChangeHandler();
383 }
384
385 protected LayoutManager createLayout() {
386 return new WindowsTitlePaneLayout();
387 }
388
389 public class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout {
390 private Insets captionMargin = null;
391 private Insets contentMargin = null;
392 private final XPStyle xp = XPStyle.getXP();
393
394 WindowsTitlePaneLayout() {
395 if (xp != null) {
396 Component c = WindowsInternalFrameTitlePane.this;
397 captionMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CAPTIONMARGINS);
398 contentMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CONTENTMARGINS);
399 }
400 if (captionMargin == null) {
401 captionMargin = new Insets(0, 2, 0, 2);
402 }
403 if (contentMargin == null) {
404 contentMargin = new Insets(0, 0, 0, 0);
405 }
406 }
407
408 private int layoutButton(JComponent button, Part part,
409 int x, int y, int w, int h, int gap,
410 boolean leftToRight) {
411 if (!leftToRight) {
412 x -= w;
|