jdk/src/windows/classes/sun/awt/windows/WFramePeer.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 129 f995b9c9c5fa
child 2453 35e5fab82613
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 129
diff changeset
     2
 * Copyright 1996-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.awt.image.ImageRepresentation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.awt.image.IntegerComponentRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.awt.image.ToolkitImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.DataBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.image.DataBufferInt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.awt.im.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.awt.Win32GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
class WFramePeer extends WWindowPeer implements FramePeer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    // FramePeer implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    public native void setState(int state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    public native int getState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    // Convenience methods to save us from trouble of extracting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    // Rectangle fields in native code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private native void setMaximizedBounds(int x, int y, int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private native void clearMaximizedBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static final boolean keepOnMinimize = "true".equals(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        (String)java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            new sun.security.action.GetPropertyAction(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                "sun.awt.keepWorkingSetOnMinimize")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public void setMaximizedBounds(Rectangle b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        if (b == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            clearMaximizedBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            setMaximizedBounds(b.x, b.y, b.width, b.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    67
    @Override
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    68
    boolean isTargetUndecorated() {
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    69
        return ((Frame)target).isUndecorated();
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    70
    }
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    71
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public void reshape(int x, int y, int width, int height) {
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    73
        Rectangle newBounds = constrainBounds(x, y, width, height);
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    74
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (((Frame)target).isUndecorated()) {
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    76
            super.reshape(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        } else {
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
    78
            reshapeFrame(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public Dimension getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        Dimension d = new Dimension();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        if (!((Frame)target).isUndecorated()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            d.setSize(getSysMinWidth(), getSysMinHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (((Frame)target).getMenuBar() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            d.height += getSysMenuHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        return d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // Note: Because this method calls resize(), which may be overridden
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    // by client code, this method must not be executed on the toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    // thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public void setMenuBar(MenuBar mb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        WMenuBarPeer mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(mb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        setMenuBar0(mbPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        updateInsets(insets_);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    // Note: Because this method calls resize(), which may be overridden
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    // by client code, this method must not be executed on the toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    // thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private native void setMenuBar0(WMenuBarPeer mbPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    // Toolkit & peer internals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    WFramePeer(Frame target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        super(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        InputMethodManager imm = InputMethodManager.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        String menuString = imm.getTriggerMenuString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (menuString != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
          pSetIMMOption(menuString);
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
    native void createAwtFrame(WComponentPeer parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    void create(WComponentPeer parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        createAwtFrame(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    void initialize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        super.initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        Frame target = (Frame)this.target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        if (target.getTitle() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            setTitle(target.getTitle());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        setResizable(target.isResizable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        setState(target.getExtendedState());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    private native static int getSysMenuHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    native void pSetIMMOption(String option);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    void notifyIMMOptionChange(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
      InputMethodManager.getInstance().notifyChangeRequest((Component)target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public void setBoundsPrivate(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        setBounds(x, y, width, height, SET_BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public Rectangle getBoundsPrivate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
}