1 /*
2 * Copyright (c) 2002, 2012, 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
747 int buttonHeight = buttonDim.height;
748 if (button_border != null) {
749 buttonHeight += button_border.top + button_border.bottom;
750 }
751 int height = Math.max(buttonHeight, titleHeight);
752
753 return new Dimension(width, height);
754 }
755
756 public void layoutContainer(Container c) {
757 JComponent titlePane = (JComponent)c;
758 Container titlePaneParent = titlePane.getParent();
759 JInternalFrame frame;
760 if (titlePaneParent instanceof JInternalFrame) {
761 frame = (JInternalFrame)titlePaneParent;
762 } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) {
763 frame = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame();
764 } else {
765 return;
766 }
767 Map gm = getFrameGeometry();
768
769 int w = titlePane.getWidth();
770 int h = titlePane.getHeight();
771
772 JComponent menuButton = findChild(titlePane, "InternalFrameTitlePane.menuButton");
773 JComponent minimizeButton = findChild(titlePane, "InternalFrameTitlePane.iconifyButton");
774 JComponent maximizeButton = findChild(titlePane, "InternalFrameTitlePane.maximizeButton");
775 JComponent closeButton = findChild(titlePane, "InternalFrameTitlePane.closeButton");
776
777 Insets button_border = (Insets)gm.get("button_border");
778 Dimension buttonDim = calculateButtonSize(titlePane);
779
780 int y = (button_border != null) ? button_border.top : 0;
781 if (titlePaneParent.getComponentOrientation().isLeftToRight()) {
782 int x = getInt("left_titlebar_edge");
783
784 menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
785
786 x = w - buttonDim.width - getInt("right_titlebar_edge");
787 if (button_border != null) {
811 x += button_border.left;
812 }
813
814 if (frame.isClosable()) {
815 closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
816 x += buttonDim.width;
817 }
818
819 if (frame.isMaximizable()) {
820 maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
821 x += buttonDim.width;
822 }
823
824 if (frame.isIconifiable()) {
825 minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
826 }
827 }
828 }
829 } // end TitlePaneLayout
830
831 protected Map getFrameGeometry() {
832 return frameGeometry;
833 }
834
835 protected void setFrameGeometry(JComponent titlePane, Map gm) {
836 this.frameGeometry = gm;
837 if (getInt("top_height") == 0 && titlePane != null) {
838 gm.put("top_height", Integer.valueOf(titlePane.getHeight()));
839 }
840 }
841
842 protected int getInt(String key) {
843 Integer i = (Integer)frameGeometry.get(key);
844 if (i == null) {
845 i = variables.get(key);
846 }
847 return (i != null) ? i.intValue() : 0;
848 }
849
850 protected boolean getBoolean(String key, boolean fallback) {
851 Boolean b = (Boolean)frameGeometry.get(key);
852 return (b != null) ? b.booleanValue() : fallback;
853 }
854
855
1484 frame_style_set = getNode("frame_style_set",
1485 new String[] {"name", getStringAttr(window, "style_set")});
1486 }
1487
1488 if (frame_style_set == null) {
1489 frame_style_set = getNode("frame_style_set", new String[] {"name", "normal"});
1490 }
1491 }
1492
1493 if (frame_style_set != null) {
1494 Node frame = getNode(frame_style_set, "frame", new String[] {
1495 "focus", (jif.isSelected() ? "yes" : "no"),
1496 "state", (jif.isMaximum() ? "maximized" : "normal")
1497 });
1498
1499 if (frame != null) {
1500 Node frame_style = getNode("frame_style", new String[] {
1501 "name", getStringAttr(frame, "style")
1502 });
1503 if (frame_style != null) {
1504 Map gm = frameGeometries.get(getStringAttr(frame_style, "geometry"));
1505
1506 setFrameGeometry(titlePane, gm);
1507 }
1508 }
1509 }
1510 }
1511
1512
1513 protected static void logError(String themeName, Exception ex) {
1514 logError(themeName, ex.toString());
1515 }
1516
1517 protected static void logError(String themeName, String msg) {
1518 if (!errorLogged) {
1519 System.err.println("Exception in Metacity for theme \""+themeName+"\": "+msg);
1520 errorLogged = true;
1521 }
1522 }
1523
1524
|
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
747 int buttonHeight = buttonDim.height;
748 if (button_border != null) {
749 buttonHeight += button_border.top + button_border.bottom;
750 }
751 int height = Math.max(buttonHeight, titleHeight);
752
753 return new Dimension(width, height);
754 }
755
756 public void layoutContainer(Container c) {
757 JComponent titlePane = (JComponent)c;
758 Container titlePaneParent = titlePane.getParent();
759 JInternalFrame frame;
760 if (titlePaneParent instanceof JInternalFrame) {
761 frame = (JInternalFrame)titlePaneParent;
762 } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) {
763 frame = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame();
764 } else {
765 return;
766 }
767 Map<String, Object> gm = getFrameGeometry();
768
769 int w = titlePane.getWidth();
770 int h = titlePane.getHeight();
771
772 JComponent menuButton = findChild(titlePane, "InternalFrameTitlePane.menuButton");
773 JComponent minimizeButton = findChild(titlePane, "InternalFrameTitlePane.iconifyButton");
774 JComponent maximizeButton = findChild(titlePane, "InternalFrameTitlePane.maximizeButton");
775 JComponent closeButton = findChild(titlePane, "InternalFrameTitlePane.closeButton");
776
777 Insets button_border = (Insets)gm.get("button_border");
778 Dimension buttonDim = calculateButtonSize(titlePane);
779
780 int y = (button_border != null) ? button_border.top : 0;
781 if (titlePaneParent.getComponentOrientation().isLeftToRight()) {
782 int x = getInt("left_titlebar_edge");
783
784 menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
785
786 x = w - buttonDim.width - getInt("right_titlebar_edge");
787 if (button_border != null) {
811 x += button_border.left;
812 }
813
814 if (frame.isClosable()) {
815 closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
816 x += buttonDim.width;
817 }
818
819 if (frame.isMaximizable()) {
820 maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
821 x += buttonDim.width;
822 }
823
824 if (frame.isIconifiable()) {
825 minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
826 }
827 }
828 }
829 } // end TitlePaneLayout
830
831 protected Map<String, Object> getFrameGeometry() {
832 return frameGeometry;
833 }
834
835 protected void setFrameGeometry(JComponent titlePane, Map<String, Object> gm) {
836 this.frameGeometry = gm;
837 if (getInt("top_height") == 0 && titlePane != null) {
838 gm.put("top_height", Integer.valueOf(titlePane.getHeight()));
839 }
840 }
841
842 protected int getInt(String key) {
843 Integer i = (Integer)frameGeometry.get(key);
844 if (i == null) {
845 i = variables.get(key);
846 }
847 return (i != null) ? i.intValue() : 0;
848 }
849
850 protected boolean getBoolean(String key, boolean fallback) {
851 Boolean b = (Boolean)frameGeometry.get(key);
852 return (b != null) ? b.booleanValue() : fallback;
853 }
854
855
1484 frame_style_set = getNode("frame_style_set",
1485 new String[] {"name", getStringAttr(window, "style_set")});
1486 }
1487
1488 if (frame_style_set == null) {
1489 frame_style_set = getNode("frame_style_set", new String[] {"name", "normal"});
1490 }
1491 }
1492
1493 if (frame_style_set != null) {
1494 Node frame = getNode(frame_style_set, "frame", new String[] {
1495 "focus", (jif.isSelected() ? "yes" : "no"),
1496 "state", (jif.isMaximum() ? "maximized" : "normal")
1497 });
1498
1499 if (frame != null) {
1500 Node frame_style = getNode("frame_style", new String[] {
1501 "name", getStringAttr(frame, "style")
1502 });
1503 if (frame_style != null) {
1504 Map<String, Object> gm = frameGeometries.get(getStringAttr(frame_style, "geometry"));
1505
1506 setFrameGeometry(titlePane, gm);
1507 }
1508 }
1509 }
1510 }
1511
1512
1513 protected static void logError(String themeName, Exception ex) {
1514 logError(themeName, ex.toString());
1515 }
1516
1517 protected static void logError(String themeName, String msg) {
1518 if (!errorLogged) {
1519 System.err.println("Exception in Metacity for theme \""+themeName+"\": "+msg);
1520 errorLogged = true;
1521 }
1522 }
1523
1524
|