1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 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.
24 */
25
26
27 package sun.awt.windows;
28
29 import java.awt.*;
30 import java.awt.peer.*;
31 import java.awt.event.*;
32 import java.awt.im.*;
33 import java.awt.im.spi.InputMethodContext;
34 import java.awt.font.*;
35 import java.text.*;
36 import java.text.AttributedCharacterIterator.Attribute;
37 import java.lang.Character.Subset;
38 import java.lang.Character.UnicodeBlock;
39 import java.util.Collections;
40 import java.util.HashMap;
41 import java.util.Locale;
42 import java.util.Map;
43 import sun.awt.im.InputMethodAdapter;
44
45 final class WInputMethod extends InputMethodAdapter
46 {
47 /**
48 * The input method context, which is used to dispatch input method
49 * events to the client component and to request information from
50 * the client component.
51 */
52 private InputMethodContext inputContext;
53
54 private Component awtFocussedComponent;
55 private WComponentPeer awtFocussedComponentPeer = null;
56 private WComponentPeer lastFocussedComponentPeer = null;
57 private boolean isLastFocussedActiveClient = false;
58 private boolean isActive;
59 private int context;
60 private boolean open; //default open status;
61 private int cmode; //default conversion mode;
62 private Locale currentLocale;
589 Rectangle rc = inputContext.getTextLocation(TextHitInfo.leading(0));
590 x = rc.x;
591 y = rc.y + rc.height;
592 } else {
593 Point pt = client.getLocationOnScreen();
594 Dimension size = client.getSize();
595 x = pt.x;
596 y = pt.y + size.height;
597 }
598 }
599
600 openCandidateWindow(awtFocussedComponentPeer, x, y);
601 }
602 };
603 WToolkit.postEvent(WToolkit.targetToAppContext(source),
604 new InvocationEvent(source, r));
605 }
606
607 // java.awt.Toolkit#getNativeContainer() is not available
608 // from this package
609 @SuppressWarnings("deprecation")
610 private WComponentPeer getNearestNativePeer(Component comp)
611 {
612 if (comp==null) return null;
613
614 ComponentPeer peer = comp.getPeer();
615 if (peer==null) return null;
616
617 while (peer instanceof java.awt.peer.LightweightPeer) {
618 comp = comp.getParent();
619 if (comp==null) return null;
620 peer = comp.getPeer();
621 if (peer==null) return null;
622 }
623
624 if (peer instanceof WComponentPeer)
625 return (WComponentPeer)peer;
626 else
627 return null;
628
629 }
630
631 private native int createNativeContext();
632 private native void destroyNativeContext(int context);
633 private native void enableNativeIME(WComponentPeer peer, int context, boolean useNativeCompWindow);
634 private native void disableNativeIME(WComponentPeer peer);
635 private native void handleNativeIMEEvent(WComponentPeer peer, AWTEvent e);
636 private native void endCompositionNative(int context, boolean flag);
637 private native void setConversionStatus(int context, int cmode);
638 private native int getConversionStatus(int context);
639 private native void setOpenStatus(int context, boolean flag);
640 private native boolean getOpenStatus(int context);
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 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.
24 */
25
26
27 package sun.awt.windows;
28
29 import java.awt.*;
30 import java.awt.peer.*;
31 import java.awt.event.*;
32 import java.awt.im.*;
33 import java.awt.im.spi.InputMethodContext;
34 import java.awt.font.*;
35 import java.text.*;
36 import java.text.AttributedCharacterIterator.Attribute;
37 import java.lang.Character.Subset;
38 import java.lang.Character.UnicodeBlock;
39 import java.util.Collections;
40 import java.util.HashMap;
41 import java.util.Locale;
42 import java.util.Map;
43
44 import sun.awt.AWTAccessor;
45 import sun.awt.AWTAccessor.ComponentAccessor;
46 import sun.awt.im.InputMethodAdapter;
47
48 final class WInputMethod extends InputMethodAdapter
49 {
50 /**
51 * The input method context, which is used to dispatch input method
52 * events to the client component and to request information from
53 * the client component.
54 */
55 private InputMethodContext inputContext;
56
57 private Component awtFocussedComponent;
58 private WComponentPeer awtFocussedComponentPeer = null;
59 private WComponentPeer lastFocussedComponentPeer = null;
60 private boolean isLastFocussedActiveClient = false;
61 private boolean isActive;
62 private int context;
63 private boolean open; //default open status;
64 private int cmode; //default conversion mode;
65 private Locale currentLocale;
592 Rectangle rc = inputContext.getTextLocation(TextHitInfo.leading(0));
593 x = rc.x;
594 y = rc.y + rc.height;
595 } else {
596 Point pt = client.getLocationOnScreen();
597 Dimension size = client.getSize();
598 x = pt.x;
599 y = pt.y + size.height;
600 }
601 }
602
603 openCandidateWindow(awtFocussedComponentPeer, x, y);
604 }
605 };
606 WToolkit.postEvent(WToolkit.targetToAppContext(source),
607 new InvocationEvent(source, r));
608 }
609
610 // java.awt.Toolkit#getNativeContainer() is not available
611 // from this package
612 private WComponentPeer getNearestNativePeer(Component comp)
613 {
614 if (comp==null) return null;
615 final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
616 ComponentPeer peer = acc.getPeer(comp);
617 if (peer==null) return null;
618
619 while (peer instanceof java.awt.peer.LightweightPeer) {
620 comp = comp.getParent();
621 if (comp==null) return null;
622 peer = acc.getPeer(comp);
623 if (peer==null) return null;
624 }
625
626 if (peer instanceof WComponentPeer)
627 return (WComponentPeer)peer;
628 else
629 return null;
630
631 }
632
633 private native int createNativeContext();
634 private native void destroyNativeContext(int context);
635 private native void enableNativeIME(WComponentPeer peer, int context, boolean useNativeCompWindow);
636 private native void disableNativeIME(WComponentPeer peer);
637 private native void handleNativeIMEEvent(WComponentPeer peer, AWTEvent e);
638 private native void endCompositionNative(int context, boolean flag);
639 private native void setConversionStatus(int context, int cmode);
640 private native int getConversionStatus(int context);
641 private native void setOpenStatus(int context, boolean flag);
642 private native boolean getOpenStatus(int context);
|