1 /* 2 * Copyright (c) 1996, 2010, 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 #ifndef AWT_TEXTCOMPONENT_H 27 #define AWT_TEXTCOMPONENT_H 28 29 #include "awt_Component.h" 30 31 #include "java_awt_TextComponent.h" 32 #include "sun_awt_windows_WTextComponentPeer.h" 33 34 #include <ole2.h> 35 #include <richedit.h> 36 #include <richole.h> 37 38 39 /************************************************************************ 40 * AwtTextComponent class 41 */ 42 43 class AwtTextComponent : public AwtComponent { 44 public: 45 /* java.awt.TextComponent canAccessClipboard field ID */ 46 static jfieldID canAccessClipboardID; 47 48 AwtTextComponent(); 49 50 virtual LPCTSTR GetClassName(); 51 52 int RemoveCR(WCHAR *pStr); 53 54 virtual LONG getJavaSelPos(LONG orgPos); 55 virtual LONG getWin32SelPos(LONG orgPos); 56 57 void CheckLineSeparator(WCHAR *pStr); 58 59 virtual void SetSelRange(LONG start, LONG end); 60 61 INLINE void SetText(LPCTSTR text) { 62 ::SetWindowText(GetHWnd(), text); 63 } 64 65 INLINE virtual int GetText(LPTSTR buffer, int size) { 66 return ::GetWindowText(GetHWnd(), buffer, size); 67 } 68 69 // called on Toolkit thread from JNI 70 static jstring _GetText(void *param); 71 72 void SetFont(AwtFont* font); 73 74 /* 75 * Windows message handler functions 76 */ 77 MsgRouting WmNotify(UINT notifyCode); 78 MsgRouting HandleEvent(MSG *msg, BOOL synthetic); 79 MsgRouting WmPaste(); 80 81 virtual BOOL IsFocusingMouseMessage(MSG *pMsg); 82 83 /* To be fully implemented in a future release 84 85 MsgRouting WmKeyDown(UINT wkey, UINT repCnt, 86 UINT flags, BOOL system); // accessibility support 87 */ 88 89 90 //im --- for over the spot composition 91 void SetCompositionWindow(RECT& rect); 92 93 INLINE HWND GetDBCSEditHandle() { return GetHWnd(); } 94 95 BOOL m_isLFonly; 96 BOOL m_EOLchecked; 97 98 // some methods invoked on Toolkit thread 99 static void _SetText(void *param); 100 static jint _GetSelectionStart(void *param); 101 static jint _GetSelectionEnd(void *param); 102 static void _Select(void *param); 103 static void _EnableEditing(void *param); 104 105 protected: 106 INLINE LONG GetStartSelectionPos() { return m_lStartPos; } 107 INLINE LONG GetEndSelectionPos() { return m_lEndPos; } 108 INLINE LONG GetLastSelectionPos() { return m_lLastPos; } 109 INLINE VOID SetStartSelectionPos(LONG lPos) { m_lStartPos = lPos; } 110 INLINE VOID SetEndSelectionPos(LONG lPos) { m_lEndPos = lPos; } 111 INLINE VOID SetLastSelectionPos(LONG lPos) { m_lLastPos = lPos; } 112 113 // Used to prevent untrusted code from synthesizing a WM_PASTE message 114 // by posting a <CTRL>-V KeyEvent 115 BOOL m_synthetic; 116 virtual LONG EditGetCharFromPos(POINT& pt) = 0; 117 118 private: 119 120 // Fields to track the selection state while the left mouse button is 121 // pressed. They are used to simulate autoscrolling. 122 LONG m_lStartPos; 123 LONG m_lEndPos; 124 LONG m_lLastPos; 125 126 HFONT m_hFont; 127 //im --- end 128 129 130 // 131 // Accessibility support 132 // 133 //public: 134 // jlong javaEventsMask; 135 }; 136 137 #endif /* AWT_TEXTCOMPONENT_H */