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(); }
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 */
|
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 static AwtTextComponent* Create(jobject self, jobject parent, BOOL isMultiline);
51
52 virtual LPCTSTR GetClassName();
53
54 int RemoveCR(WCHAR *pStr);
55
56 virtual LONG getJavaSelPos(LONG orgPos);
57 virtual LONG getWin32SelPos(LONG orgPos);
58
59 void CheckLineSeparator(WCHAR *pStr);
60
61 virtual void SetSelRange(LONG start, LONG end);
62
63 INLINE void SetText(LPCTSTR text) {
64 ::SetWindowText(GetHWnd(), text);
65 }
66
67 INLINE virtual int GetText(LPTSTR buffer, int size) {
68 return ::GetWindowText(GetHWnd(), buffer, size);
69 }
70
71 // called on Toolkit thread from JNI
72 static jstring _GetText(void *param);
73
74 void SetFont(AwtFont* font);
75
76 virtual void Enable(BOOL bEnable);
77 virtual void SetColor(COLORREF c);
78 virtual void SetBackgroundColor(COLORREF c);
79
80 /*
81 * Windows message handler functions
82 */
83 MsgRouting WmNotify(UINT notifyCode);
84 MsgRouting HandleEvent(MSG *msg, BOOL synthetic);
85 MsgRouting WmPaste();
86
87 virtual BOOL IsFocusingMouseMessage(MSG *pMsg);
88
89 /* To be fully implemented in a future release
90
91 MsgRouting WmKeyDown(UINT wkey, UINT repCnt,
92 UINT flags, BOOL system); // accessibility support
93 */
94
95
96 //im --- for over the spot composition
97 void SetCompositionWindow(RECT& rect);
98
99 INLINE HWND GetDBCSEditHandle() { return GetHWnd(); }
102 BOOL m_EOLchecked;
103
104 // some methods invoked on Toolkit thread
105 static void _SetText(void *param);
106 static jint _GetSelectionStart(void *param);
107 static jint _GetSelectionEnd(void *param);
108 static void _Select(void *param);
109 static void _EnableEditing(void *param);
110
111 protected:
112 INLINE LONG GetStartSelectionPos() { return m_lStartPos; }
113 INLINE LONG GetEndSelectionPos() { return m_lEndPos; }
114 INLINE LONG GetLastSelectionPos() { return m_lLastPos; }
115 INLINE VOID SetStartSelectionPos(LONG lPos) { m_lStartPos = lPos; }
116 INLINE VOID SetEndSelectionPos(LONG lPos) { m_lEndPos = lPos; }
117 INLINE VOID SetLastSelectionPos(LONG lPos) { m_lLastPos = lPos; }
118
119 // Used to prevent untrusted code from synthesizing a WM_PASTE message
120 // by posting a <CTRL>-V KeyEvent
121 BOOL m_synthetic;
122 LONG EditGetCharFromPos(POINT& pt);
123
124 /*****************************************************************
125 * Inner class OleCallback declaration.
126 */
127 class OleCallback : public IRichEditOleCallback {
128 public:
129 OleCallback();
130
131 STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
132 STDMETHODIMP_(ULONG) AddRef();
133 STDMETHODIMP_(ULONG) Release();
134 STDMETHODIMP GetNewStorage(LPSTORAGE FAR * ppstg);
135 STDMETHODIMP GetInPlaceContext(LPOLEINPLACEFRAME FAR * ppipframe,
136 LPOLEINPLACEUIWINDOW FAR* ppipuiDoc,
137 LPOLEINPLACEFRAMEINFO pipfinfo);
138 STDMETHODIMP ShowContainerUI(BOOL fShow);
139 STDMETHODIMP QueryInsertObject(LPCLSID pclsid, LPSTORAGE pstg, LONG cp);
140 STDMETHODIMP DeleteObject(LPOLEOBJECT poleobj);
141 STDMETHODIMP QueryAcceptData(LPDATAOBJECT pdataobj, CLIPFORMAT *pcfFormat,
142 DWORD reco, BOOL fReally, HGLOBAL hMetaPict);
143 STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
144 STDMETHODIMP GetClipboardData(CHARRANGE *pchrg, DWORD reco,
145 LPDATAOBJECT *ppdataobj);
146 STDMETHODIMP GetDragDropEffect(BOOL fDrag, DWORD grfKeyState,
147 LPDWORD pdwEffect);
148 STDMETHODIMP GetContextMenu(WORD seltype, LPOLEOBJECT poleobj,
149 CHARRANGE FAR * pchrg, HMENU FAR * phmenu);
150 private:
151 ULONG m_refs; // Reference count
152 };//OleCallback class
153
154 INLINE static OleCallback& GetOleCallback() { return sm_oleCallback; }
155
156
157 private:
158
159 // Fields to track the selection state while the left mouse button is
160 // pressed. They are used to simulate autoscrolling.
161 LONG m_lStartPos;
162 LONG m_lEndPos;
163 LONG m_lLastPos;
164
165 HFONT m_hFont;
166 //im --- end
167
168 static OleCallback sm_oleCallback;
169
170 //
171 // Accessibility support
172 //
173 //public:
174 // jlong javaEventsMask;
175 };
176
177 #endif /* AWT_TEXTCOMPONENT_H */
|