author | anthony |
Fri, 27 Nov 2009 16:07:32 +0300 | |
changeset 4366 | 4446f3b8a9b4 |
parent 2643 | ea218b1a2000 |
child 4371 | dc9dcb8b0ae7 |
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.*; |
|
28 |
import java.awt.*; |
|
29 |
import java.awt.peer.*; |
|
30 |
||
31 |
import sun.awt.*; |
|
32 |
import sun.awt.im.*; |
|
33 |
||
34 |
class WDialogPeer extends WWindowPeer implements DialogPeer { |
|
35 |
// Toolkit & peer internals |
|
36 |
||
37 |
// Platform default background for dialogs. Gets set on target if |
|
38 |
// target has none explicitly specified. |
|
39 |
final static Color defaultBackground = SystemColor.control; |
|
40 |
||
41 |
// If target doesn't have its background color set, we set its |
|
42 |
// background to platform default. |
|
43 |
boolean needDefaultBackground; |
|
44 |
||
45 |
WDialogPeer(Dialog target) { |
|
46 |
super(target); |
|
47 |
||
48 |
InputMethodManager imm = InputMethodManager.getInstance(); |
|
49 |
String menuString = imm.getTriggerMenuString(); |
|
50 |
if (menuString != null) |
|
51 |
{ |
|
52 |
pSetIMMOption(menuString); |
|
53 |
} |
|
54 |
} |
|
55 |
||
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
56 |
native void createAwtDialog(WComponentPeer parent); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
57 |
void create(WComponentPeer parent) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
58 |
preCreate(parent); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
59 |
createAwtDialog(parent); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
60 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
2643
diff
changeset
|
61 |
|
2 | 62 |
native void showModal(); |
63 |
native void endModal(); |
|
64 |
||
65 |
void initialize() { |
|
66 |
Dialog target = (Dialog)this.target; |
|
67 |
// Need to set target's background to default _before_ a call |
|
68 |
// to super.initialize. |
|
69 |
if (needDefaultBackground) { |
|
70 |
target.setBackground(defaultBackground); |
|
71 |
} |
|
72 |
||
73 |
super.initialize(); |
|
74 |
||
75 |
if (target.getTitle() != null) { |
|
76 |
setTitle(target.getTitle()); |
|
77 |
} |
|
78 |
setResizable(target.isResizable()); |
|
79 |
} |
|
80 |
||
81 |
protected void realShow() { |
|
82 |
Dialog dlg = (Dialog)target; |
|
83 |
if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) { |
|
84 |
showModal(); |
|
85 |
} else { |
|
86 |
super.realShow(); |
|
87 |
} |
|
88 |
} |
|
89 |
||
90 |
public void hide() { |
|
91 |
Dialog dlg = (Dialog)target; |
|
92 |
if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) { |
|
93 |
endModal(); |
|
94 |
} else { |
|
95 |
super.hide(); |
|
96 |
} |
|
97 |
} |
|
98 |
||
99 |
public void blockWindows(java.util.List<Window> toBlock) { |
|
100 |
for (Window w : toBlock) { |
|
101 |
WWindowPeer wp = (WWindowPeer)ComponentAccessor.getPeer(w); |
|
102 |
if (wp != null) { |
|
103 |
wp.setModalBlocked((Dialog)target, true); |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
public Dimension getMinimumSize() { |
|
109 |
if (((Dialog)target).isUndecorated()) { |
|
110 |
return super.getMinimumSize(); |
|
111 |
} else { |
|
112 |
return new Dimension(getSysMinWidth(), getSysMinHeight()); |
|
113 |
} |
|
114 |
} |
|
115 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
116 |
@Override |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
117 |
boolean isTargetUndecorated() { |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
118 |
return ((Dialog)target).isUndecorated(); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
119 |
} |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
2
diff
changeset
|
120 |
|
2 | 121 |
public void reshape(int x, int y, int width, int height) { |
122 |
if (((Dialog)target).isUndecorated()) { |
|
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
715
diff
changeset
|
123 |
super.reshape(x, y, width, height); |
2 | 124 |
} else { |
2643
ea218b1a2000
6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents:
715
diff
changeset
|
125 |
reshapeFrame(x, y, width, height); |
2 | 126 |
} |
127 |
} |
|
128 |
||
129 |
/* Native create() peeks at target's background and if it's null |
|
130 |
* calls this method to arrage for default background to be set on |
|
131 |
* target. Can't make the check in Java, since getBackground will |
|
132 |
* return owner's background if target has none set. |
|
133 |
*/ |
|
134 |
private void setDefaultColor() { |
|
135 |
// Can't call target.setBackground directly, since we are |
|
136 |
// called on toolkit thread. Can't schedule a Runnable on the |
|
137 |
// EventHandlerThread because of the race condition. So just |
|
138 |
// set a flag and call target.setBackground in initialize. |
|
139 |
needDefaultBackground = true; |
|
140 |
} |
|
141 |
||
142 |
native void pSetIMMOption(String option); |
|
143 |
void notifyIMMOptionChange(){ |
|
144 |
InputMethodManager.getInstance().notifyChangeRequest((Component)target); |
|
145 |
} |
|
146 |
} |