jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 23632 cd7a34d12e8c
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.java.swing.plaf.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.plaf.basic.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.ComponentUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import static com.sun.java.swing.plaf.windows.TMSchema.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Windows rendition of the component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * future Swing releases.  The current serialization support is appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * for short term storage or RMI between applications running the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * version of Swing.  A future release of Swing will provide support for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * long term persistence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public class WindowsInternalFrameUI extends BasicInternalFrameUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    XPStyle xp = XPStyle.getXP();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    public void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        super.installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        if (xp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            frame.setBorder(new XPBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            frame.setBorder(UIManager.getBorder("InternalFrame.border"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public void installUI(JComponent c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        super.installUI(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        LookAndFeel.installProperty(c, "opaque",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                                    xp == null? Boolean.TRUE : Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        frame.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        super.uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public static ComponentUI createUI(JComponent b)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return new WindowsInternalFrameUI((JInternalFrame)b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public WindowsInternalFrameUI(JInternalFrame w){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        super(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    protected DesktopManager createDesktopManager(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        return new WindowsDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    protected JComponent createNorthPane(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        titlePane = new WindowsInternalFrameTitlePane(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        return titlePane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private class XPBorder extends AbstractBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        private Skin leftSkin   = xp.getSkin(frame, Part.WP_FRAMELEFT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        private Skin rightSkin  = xp.getSkin(frame, Part.WP_FRAMERIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        private Skin bottomSkin = xp.getSkin(frame, Part.WP_FRAMEBOTTOM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
         * @param x the x position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
         * @param y the y position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
         * @param width the width of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
         * @param height the height of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            State state = ((JInternalFrame)c).isSelected() ? State.ACTIVE : State.INACTIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            int topBorderHeight  = (titlePane != null) ? titlePane.getSize().height : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            bottomSkin.paintSkin(g, 0, height-bottomSkin.getHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                                 width, bottomSkin.getHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                 state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            leftSkin.paintSkin(g, 0, topBorderHeight-1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                               leftSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                               state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            rightSkin.paintSkin(g, width-rightSkin.getWidth(), topBorderHeight-1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                                rightSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                                state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            insets.top    = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            insets.left   = leftSkin.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            insets.right  = rightSkin.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            insets.bottom = bottomSkin.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        public boolean isBorderOpaque() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
}