GNU Classpath (0.18) | ||
Frames | No Frames |
1: /* MetalInternalFrameTitlePane.java 2: Copyright (C) 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package javax.swing.plaf.metal; 40: 41: import java.awt.Container; 42: import java.awt.Dimension; 43: import java.awt.Graphics; 44: import java.awt.LayoutManager; 45: 46: import javax.swing.Icon; 47: import javax.swing.JInternalFrame; 48: import javax.swing.JMenu; 49: import javax.swing.plaf.basic.BasicInternalFrameTitlePane; 50: 51: /** 52: * The title pane for a {@link JInternalFrame}. 53: */ 54: public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane 55: { 56: 57: protected boolean isPalette; 58: 59: protected Icon paletteCloseIcon = MetalIconFactory.getInternalFrameCloseIcon(16); 60: 61: protected int paletteTitleHeight = 12; 62: 63: /** 64: * Creates a new title pane. 65: * 66: * @param f the internal frame. 67: */ 68: public MetalInternalFrameTitlePane(JInternalFrame f) 69: { 70: super(f); 71: isPalette = false; 72: } 73: 74: /** 75: * Fetches the colors used in the title pane. 76: */ 77: protected void installDefaults() 78: { 79: super.installDefaults(); 80: selectedTextColor = MetalLookAndFeel.getControlTextColor(); 81: selectedTitleColor = MetalLookAndFeel.getWindowTitleBackground(); 82: notSelectedTextColor = MetalLookAndFeel.getInactiveControlTextColor(); 83: notSelectedTitleColor = MetalLookAndFeel.getWindowTitleInactiveBackground(); 84: } 85: 86: /** 87: * Clears the colors used for the title pane. 88: */ 89: protected void uninstallDefaults() 90: { 91: super.uninstallDefaults(); 92: selectedTextColor = null; 93: selectedTitleColor = null; 94: notSelectedTextColor = null; 95: notSelectedTitleColor = null; 96: } 97: 98: /** 99: * Calls the super class to create the buttons, then calls 100: * <code>setBorderPainted(false)</code> and 101: * <code>setContentAreaFilled(false)</code> for each button. 102: */ 103: protected void createButtons() 104: { 105: super.createButtons(); 106: closeButton.setBorderPainted(false); 107: closeButton.setContentAreaFilled(false); 108: iconButton.setBorderPainted(false); 109: iconButton.setContentAreaFilled(false); 110: maxButton.setBorderPainted(false); 111: maxButton.setContentAreaFilled(false); 112: } 113: 114: /** 115: * Overridden to do nothing. 116: */ 117: protected void addSystemMenuItems(JMenu systemMenu) 118: { 119: // do nothing 120: } 121: 122: /** 123: * Overridden to do nothing. 124: */ 125: protected void showSystemMenu() 126: { 127: // do nothing 128: } 129: 130: /** 131: * Creates a layout manager for the components in the title pane. 132: * 133: * @return A layout manager. 134: */ 135: protected LayoutManager createLayout() 136: { 137: return new TitlePaneLayout() 138: { 139: public Dimension preferredLayoutSize(Container c) 140: { 141: return new Dimension(24, 24); 142: } 143: }; 144: } 145: 146: public void paintPalette(Graphics g) 147: { 148: // FIXME: needs implementing 149: // most likely this is equivalent to paintComponent(g) when the isPalette 150: // flag is true 151: } 152: 153: public void paintComponent(Graphics g) 154: { 155: // probably need to check the isPalette flag here, if true pass over to 156: // paintPalette(Graphics) 157: super.paintComponent(g); 158: Dimension d = getSize(); 159: if (frame.isSelected()) 160: g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); 161: else 162: g.setColor(MetalLookAndFeel.getControlDarkShadow()); 163: g.drawLine(0, d.height - 1, d.width - 1, d.height - 1); 164: } 165: 166: public void setPalette(boolean b) 167: { 168: isPalette = b; 169: } 170: }
GNU Classpath (0.18) |