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