blob: f57bbc8d499eed8f7e7f022b4270d256fdb8fa98 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
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
26package sun.awt.X11;
27
28import sun.awt.EmbeddedFrame;
29import java.awt.*;
30import java.awt.AWTKeyStroke;
31
32public class XEmbeddedFrame extends EmbeddedFrame {
33
34 long handle;
35 public XEmbeddedFrame() {
36 }
37
38 // handle should be a valid X Window.
39 public XEmbeddedFrame(long handle) {
40 this(handle, false);
41 }
42
43 // Handle is the valid X window
44 public XEmbeddedFrame(long handle, boolean supportsXEmbed, boolean isTrayIconWindow) {
45 super(handle, supportsXEmbed);
46
47 if (isTrayIconWindow) {
48 XTrayIconPeer.suppressWarningString(this);
49 }
50
51 this.handle = handle;
52 if (handle != 0) { // Has actual parent
53 addNotify();
54 if (!isTrayIconWindow) {
55 show();
56 }
57 }
58 }
59
60 public void addNotify()
61 {
62 if (getPeer() == null) {
63 XToolkit toolkit = (XToolkit)Toolkit.getDefaultToolkit();
64 setPeer(toolkit.createEmbeddedFrame(this));
65 }
66 super.addNotify();
67 }
68
69 public XEmbeddedFrame(long handle, boolean supportsXEmbed) {
70 this(handle, supportsXEmbed, false);
71 }
72
73 protected boolean traverseOut(boolean direction) {
74 XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
75 if (direction == FORWARD) {
76 xefp.traverseOutForward();
77 }
78 else {
79 xefp.traverseOutBackward();
80 }
81 return true;
82 }
83
84 public void registerAccelerator(AWTKeyStroke stroke) {
85 XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
86 if (xefp != null) {
87 xefp.registerAccelerator(stroke);
88 }
89 }
90 public void unregisterAccelerator(AWTKeyStroke stroke) {
91 XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
92 if (xefp != null) {
93 xefp.unregisterAccelerator(stroke);
94 }
95 }
96}