author | serb |
Wed, 18 Apr 2018 14:07:41 -0700 | |
changeset 49998 | 9070717a16a1 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
49998
9070717a16a1
8187392: Deprecated methods in the peers can be removed
serb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package sun.awt.X11; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
import java.awt.peer.*; |
|
29 |
||
30469 | 30 |
import sun.awt.AWTAccessor; |
31 |
import sun.awt.AWTAccessor.ComponentAccessor; |
|
2 | 32 |
import sun.awt.SunGraphicsCallback; |
33 |
||
34 |
public class XPanelPeer extends XCanvasPeer implements PanelPeer { |
|
35 |
||
36 |
XEmbeddingContainer embedder = null; //new XEmbeddingContainer(); |
|
37 |
/** |
|
38 |
* Embeds the given window into container using XEmbed protocol |
|
39 |
*/ |
|
40 |
public void xembed(long window) { |
|
41 |
if (embedder != null) { |
|
42 |
embedder.add(window); |
|
43 |
} |
|
44 |
} |
|
45 |
XPanelPeer() {} |
|
46 |
||
47 |
XPanelPeer(XCreateWindowParams params) { |
|
48 |
super(params); |
|
49 |
} |
|
50 |
||
51 |
XPanelPeer(Component target) { |
|
52 |
super(target); |
|
53 |
} |
|
54 |
||
55 |
void postInit(XCreateWindowParams params) { |
|
56 |
super.postInit(params); |
|
57 |
if (embedder != null) { |
|
58 |
embedder.install(this); |
|
59 |
} |
|
60 |
} |
|
61 |
||
62 |
public Insets getInsets() { |
|
63 |
return new Insets(0, 0, 0, 0); |
|
64 |
} |
|
65 |
public void paint(Graphics g) { |
|
66 |
super.paint(g); |
|
10096
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
5506
diff
changeset
|
67 |
SunGraphicsCallback.PaintHeavyweightComponentsCallback.getInstance(). |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
5506
diff
changeset
|
68 |
runComponents(((Container)target).getComponents(), g, |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
5506
diff
changeset
|
69 |
SunGraphicsCallback.LIGHTWEIGHTS | |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
5506
diff
changeset
|
70 |
SunGraphicsCallback.HEAVYWEIGHTS); |
f9ac9a52952d
6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents:
5506
diff
changeset
|
71 |
} |
2 | 72 |
public void print(Graphics g) { |
73 |
super.print(g); |
|
74 |
SunGraphicsCallback.PrintHeavyweightComponentsCallback.getInstance(). |
|
75 |
runComponents(((Container)target).getComponents(), g, |
|
76 |
SunGraphicsCallback.LIGHTWEIGHTS | |
|
77 |
SunGraphicsCallback.HEAVYWEIGHTS); |
|
78 |
||
79 |
} |
|
80 |
||
81 |
public void setBackground(Color c) { |
|
82 |
Component comp; |
|
83 |
int i; |
|
84 |
||
85 |
Container cont = (Container) target; |
|
30469 | 86 |
final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); |
2 | 87 |
synchronized(target.getTreeLock()) { |
88 |
int n = cont.getComponentCount(); |
|
89 |
for(i=0; i < n; i++) { |
|
90 |
comp = cont.getComponent(i); |
|
30469 | 91 |
ComponentPeer peer = acc.getPeer(comp); |
2 | 92 |
if (peer != null) { |
93 |
Color color = comp.getBackground(); |
|
94 |
if (color == null || color.equals(c)) { |
|
95 |
peer.setBackground(c); |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
} |
|
100 |
super.setBackground(c); |
|
101 |
} |
|
102 |
||
103 |
public void setForeground(Color c) { |
|
104 |
setForegroundForHierarchy((Container) target, c); |
|
105 |
} |
|
106 |
||
107 |
private void setForegroundForHierarchy(Container cont, Color c) { |
|
108 |
synchronized(target.getTreeLock()) { |
|
30469 | 109 |
final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); |
2 | 110 |
int n = cont.getComponentCount(); |
111 |
for(int i=0; i < n; i++) { |
|
112 |
Component comp = cont.getComponent(i); |
|
113 |
Color color = comp.getForeground(); |
|
114 |
if (color == null || color.equals(c)) { |
|
30469 | 115 |
ComponentPeer cpeer = acc.getPeer(comp); |
2 | 116 |
if (cpeer != null) { |
117 |
cpeer.setForeground(c); |
|
118 |
} |
|
119 |
if (cpeer instanceof LightweightPeer |
|
120 |
&& comp instanceof Container) |
|
121 |
{ |
|
122 |
setForegroundForHierarchy((Container) comp, c); |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
} |
|
127 |
} |
|
128 |
||
129 |
public void dispose() { |
|
130 |
if (embedder != null) { |
|
131 |
embedder.deinstall(); |
|
132 |
} |
|
133 |
super.dispose(); |
|
134 |
} |
|
135 |
||
136 |
protected boolean shouldFocusOnClick() { |
|
137 |
// Return false if this container has children so in that case it won't |
|
138 |
// be focused. Return true otherwise. |
|
139 |
return ((Container)target).getComponentCount() == 0; |
|
140 |
} |
|
141 |
} |