jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
changeset 1299 027d966d5658
parent 715 f16baef3a20e
parent 1297 59aad2292413
child 1837 efd004b550b7
equal deleted inserted replaced
915:e1e2fc296618 1299:027d966d5658
   768             JComponent menuButton     = findChild(titlePane, "InternalFrameTitlePane.menuButton");
   768             JComponent menuButton     = findChild(titlePane, "InternalFrameTitlePane.menuButton");
   769             JComponent minimizeButton = findChild(titlePane, "InternalFrameTitlePane.iconifyButton");
   769             JComponent minimizeButton = findChild(titlePane, "InternalFrameTitlePane.iconifyButton");
   770             JComponent maximizeButton = findChild(titlePane, "InternalFrameTitlePane.maximizeButton");
   770             JComponent maximizeButton = findChild(titlePane, "InternalFrameTitlePane.maximizeButton");
   771             JComponent closeButton    = findChild(titlePane, "InternalFrameTitlePane.closeButton");
   771             JComponent closeButton    = findChild(titlePane, "InternalFrameTitlePane.closeButton");
   772 
   772 
   773             int buttonGap = 0;
       
   774 
       
   775             Insets button_border = (Insets)gm.get("button_border");
   773             Insets button_border = (Insets)gm.get("button_border");
   776             Dimension buttonDim = calculateButtonSize(titlePane);
   774             Dimension buttonDim = calculateButtonSize(titlePane);
   777 
   775 
   778             int x = getInt("left_titlebar_edge");
       
   779             int y = (button_border != null) ? button_border.top : 0;
   776             int y = (button_border != null) ? button_border.top : 0;
   780 
   777             if (titlePaneParent.getComponentOrientation().isLeftToRight()) {
   781             menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
   778                 int x = getInt("left_titlebar_edge");
   782 
   779 
   783             x = w - buttonDim.width - getInt("right_titlebar_edge");
   780                 menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
   784             if (button_border != null) {
   781 
   785                 x -= button_border.right;
   782                 x = w - buttonDim.width - getInt("right_titlebar_edge");
   786             }
   783                 if (button_border != null) {
   787 
   784                     x -= button_border.right;
   788             if (frame.isClosable()) {
   785                 }
   789                 closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
   786 
   790                 x -= (buttonDim.width + buttonGap);
   787                 if (frame.isClosable()) {
   791             }
   788                     closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
   792 
   789                     x -= buttonDim.width;
   793             if (frame.isMaximizable()) {
   790                 }
   794                 maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
   791 
   795                 x -= (buttonDim.width + buttonGap);
   792                 if (frame.isMaximizable()) {
   796             }
   793                     maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
   797 
   794                     x -= buttonDim.width;
   798             if (frame.isIconifiable()) {
   795                 }
   799                 minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
   796 
       
   797                 if (frame.isIconifiable()) {
       
   798                     minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
       
   799                 }
       
   800             } else {
       
   801                 int x = w - buttonDim.width - getInt("right_titlebar_edge");
       
   802 
       
   803                 menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
       
   804 
       
   805                 x = getInt("left_titlebar_edge");
       
   806                 if (button_border != null) {
       
   807                     x += button_border.left;
       
   808                 }
       
   809 
       
   810                 if (frame.isClosable()) {
       
   811                     closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
       
   812                     x += buttonDim.width;
       
   813                 }
       
   814 
       
   815                 if (frame.isMaximizable()) {
       
   816                     maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
       
   817                     x += buttonDim.width;
       
   818                 }
       
   819 
       
   820                 if (frame.isIconifiable()) {
       
   821                     minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
       
   822                 }
   800             }
   823             }
   801         }
   824         }
   802     } // end TitlePaneLayout
   825     } // end TitlePaneLayout
   803 
   826 
   804     protected Map getFrameGeometry() {
   827     protected Map getFrameGeometry() {
   971         int y = aee.evaluate(getStringAttr(attrs, "y"));
   994         int y = aee.evaluate(getStringAttr(attrs, "y"));
   972 
   995 
   973         String title = jif.getTitle();
   996         String title = jif.getTitle();
   974         if (title != null) {
   997         if (title != null) {
   975             FontMetrics fm = SwingUtilities2.getFontMetrics(jif, g);
   998             FontMetrics fm = SwingUtilities2.getFontMetrics(jif, g);
   976             if (jif.getComponentOrientation().isLeftToRight()) {
   999             title = SwingUtilities2.clipStringIfNecessary(jif, fm, title,
   977                 title = SwingUtilities2.clipStringIfNecessary(jif, fm, title,
  1000                          calculateTitleArea(jif).width);
   978                              calculateTitleTextWidth(g, jif));
       
   979             }
       
   980             g.setColor(color);
  1001             g.setColor(color);
   981             SwingUtilities2.drawString(jif, g, title, x, y + fm.getAscent());
  1002             SwingUtilities2.drawString(jif, g, title, x, y + fm.getAscent());
   982         }
  1003         }
   983     }
  1004     }
   984 
  1005 
  1008 
  1029 
  1009     protected Rectangle calculateTitleArea(JInternalFrame jif) {
  1030     protected Rectangle calculateTitleArea(JInternalFrame jif) {
  1010         JComponent titlePane = findChild(jif, "InternalFrame.northPane");
  1031         JComponent titlePane = findChild(jif, "InternalFrame.northPane");
  1011         Dimension buttonDim = calculateButtonSize(titlePane);
  1032         Dimension buttonDim = calculateButtonSize(titlePane);
  1012         Insets title_border = (Insets)frameGeometry.get("title_border");
  1033         Insets title_border = (Insets)frameGeometry.get("title_border");
       
  1034         Insets button_border = (Insets)getFrameGeometry().get("button_border");
       
  1035 
  1013         Rectangle r = new Rectangle();
  1036         Rectangle r = new Rectangle();
  1014 
  1037         r.x = getInt("left_titlebar_edge");
  1015         r.x = getInt("left_titlebar_edge") + buttonDim.width;
       
  1016         r.y = 0;
  1038         r.y = 0;
  1017         r.height = titlePane.getHeight();
  1039         r.height = titlePane.getHeight();
  1018         if (title_border != null) {
  1040         if (title_border != null) {
  1019             r.x += title_border.left;
  1041             r.x += title_border.left;
  1020             r.y += title_border.top;
  1042             r.y += title_border.top;
  1021             r.height -= (title_border.top + title_border.bottom);
  1043             r.height -= (title_border.top + title_border.bottom);
  1022         }
  1044         }
  1023 
  1045 
  1024         r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge");
  1046         if (titlePane.getParent().getComponentOrientation().isLeftToRight()) {
  1025         if (jif.isClosable()) {
  1047             r.x += buttonDim.width;
  1026             r.width -= buttonDim.width;
  1048             if (button_border != null) {
  1027         }
  1049                 r.x += button_border.left;
  1028         if (jif.isMaximizable()) {
  1050             }
  1029             r.width -= buttonDim.width;
  1051             r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge");
  1030         }
  1052             if (jif.isClosable()) {
  1031         if (jif.isIconifiable()) {
  1053                 r.width -= buttonDim.width;
  1032             r.width -= buttonDim.width;
  1054             }
       
  1055             if (jif.isMaximizable()) {
       
  1056                 r.width -= buttonDim.width;
       
  1057             }
       
  1058             if (jif.isIconifiable()) {
       
  1059                 r.width -= buttonDim.width;
       
  1060             }
       
  1061         } else {
       
  1062             if (jif.isClosable()) {
       
  1063                 r.x += buttonDim.width;
       
  1064             }
       
  1065             if (jif.isMaximizable()) {
       
  1066                 r.x += buttonDim.width;
       
  1067             }
       
  1068             if (jif.isIconifiable()) {
       
  1069                 r.x += buttonDim.width;
       
  1070             }
       
  1071             r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge")
       
  1072                     - buttonDim.width;
       
  1073             if (button_border != null) {
       
  1074                 r.x -= button_border.right;
       
  1075             }
  1033         }
  1076         }
  1034         if (title_border != null) {
  1077         if (title_border != null) {
  1035             r.width -= title_border.right;
  1078             r.width -= title_border.right;
  1036         }
  1079         }
  1037         return r;
  1080         return r;