author | tdv |
Tue, 22 Jul 2008 11:24:32 -0700 | |
changeset 888 | c7009cf0001f |
parent 887 | 0aab8d3fa11a |
child 889 | 6549643c008c |
permissions | -rw-r--r-- |
2 | 1 |
/* |
888
c7009cf0001f
6728492: typo in copyrights in some files touched by the d3d pipeline port
tdv
parents:
887
diff
changeset
|
2 |
* Copyright 1996-2008 Sun Microsystems, Inc. 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 |
|
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 |
||
26 |
#ifndef AWT_COMPONENT_H |
|
27 |
#define AWT_COMPONENT_H |
|
28 |
||
29 |
#include "awtmsg.h" |
|
30 |
#include "awt_Object.h" |
|
31 |
#include "awt_Font.h" |
|
32 |
#include "awt_Brush.h" |
|
33 |
#include "awt_Pen.h" |
|
34 |
#include "awt_Win32GraphicsDevice.h" |
|
887 | 35 |
#include "GDIWindowSurfaceData.h" |
2 | 36 |
|
37 |
#include "java_awt_Component.h" |
|
38 |
#include "sun_awt_windows_WComponentPeer.h" |
|
39 |
#include "java_awt_event_KeyEvent.h" |
|
40 |
#include "java_awt_event_FocusEvent.h" |
|
41 |
#include "java_awt_event_MouseEvent.h" |
|
42 |
#include "java_awt_event_WindowEvent.h" |
|
43 |
#include "java_awt_Dimension.h" |
|
44 |
||
45 |
extern LPCTSTR szAwtComponentClassName; |
|
46 |
||
47 |
static LPCTSTR DrawingStateProp = TEXT("SunAwtDrawingStateProp"); |
|
48 |
||
49 |
const UINT IGNORE_KEY = (UINT)-1; |
|
50 |
const UINT MAX_ACP_STR_LEN = 7; // ANSI CP identifiers are no longer than this |
|
51 |
||
52 |
#define LEFT_BUTTON 1 |
|
53 |
#define MIDDLE_BUTTON 2 |
|
54 |
#define RIGHT_BUTTON 4 |
|
55 |
#define DBL_CLICK 8 |
|
56 |
||
57 |
// Whether to check for embedded frame and adjust location |
|
58 |
#define CHECK_EMBEDDED 0 |
|
59 |
#define DONT_CHECK_EMBEDDED 1 |
|
60 |
||
61 |
class AwtPopupMenu; |
|
62 |
||
63 |
class AwtDropTarget; |
|
64 |
||
65 |
struct WmComponentSetFocusData; |
|
66 |
||
67 |
/* |
|
68 |
* Message routing codes |
|
69 |
*/ |
|
70 |
enum MsgRouting { |
|
71 |
mrPassAlong, /* pass along to next in chain */ |
|
72 |
mrDoDefault, /* skip right to underlying default behavior */ |
|
73 |
mrConsume, /* consume msg & terminate routing immediatly, |
|
74 |
* don't pass anywhere |
|
75 |
*/ |
|
76 |
}; |
|
77 |
||
78 |
/************************************************************************ |
|
79 |
* AwtComponent class |
|
80 |
*/ |
|
81 |
||
82 |
class AwtComponent : public AwtObject { |
|
83 |
public: |
|
84 |
enum { |
|
85 |
// combination of all mouse button flags |
|
86 |
ALL_MK_BUTTONS = MK_LBUTTON|MK_MBUTTON|MK_RBUTTON |
|
87 |
}; |
|
88 |
||
89 |
/* java.awt.Component fields and method IDs */ |
|
90 |
static jfieldID peerID; |
|
91 |
static jfieldID xID; |
|
92 |
static jfieldID yID; |
|
93 |
static jfieldID widthID; |
|
94 |
static jfieldID heightID; |
|
95 |
static jfieldID visibleID; |
|
96 |
static jfieldID backgroundID; |
|
97 |
static jfieldID foregroundID; |
|
98 |
static jfieldID enabledID; |
|
99 |
static jfieldID parentID; |
|
100 |
static jfieldID cursorID; |
|
101 |
static jfieldID graphicsConfigID; |
|
102 |
static jfieldID peerGCID; |
|
103 |
static jfieldID focusableID; |
|
104 |
static jfieldID appContextID; |
|
105 |
static jfieldID hwndID; |
|
106 |
||
107 |
static jmethodID getFontMID; |
|
108 |
static jmethodID getToolkitMID; |
|
109 |
static jmethodID isEnabledMID; |
|
110 |
static jmethodID getLocationOnScreenMID; |
|
111 |
static jmethodID replaceSurfaceDataMID; |
|
112 |
static jmethodID replaceSurfaceDataLaterMID; |
|
113 |
||
114 |
static const UINT WmAwtIsComponent; |
|
115 |
AwtComponent(); |
|
116 |
virtual ~AwtComponent(); |
|
117 |
||
118 |
/* |
|
119 |
* Dynamic class registration & creation |
|
120 |
*/ |
|
121 |
virtual LPCTSTR GetClassName() = 0; |
|
122 |
/* |
|
123 |
* Fix for 4964237: Win XP: Changing theme changes java dialogs title icon |
|
124 |
* WNDCLASS structure has been superseded by the WNDCLASSEX in Win32 |
|
125 |
*/ |
|
126 |
virtual void FillClassInfo(WNDCLASSEX *lpwc); |
|
127 |
virtual void RegisterClass(); |
|
128 |
virtual void UnregisterClass(); |
|
129 |
||
130 |
void CreateHWnd(JNIEnv *env, LPCWSTR title, |
|
131 |
DWORD windowStyle, DWORD windowExStyle, |
|
132 |
int x, int y, int w, int h, |
|
133 |
HWND hWndParent, HMENU hMenu, |
|
134 |
COLORREF colorForeground, COLORREF colorBackground, |
|
135 |
jobject peer); |
|
136 |
void InitPeerGraphicsConfig(JNIEnv *env, jobject peer); |
|
137 |
||
138 |
virtual void Dispose(); |
|
139 |
||
140 |
void UpdateBackground(JNIEnv *env, jobject target); |
|
141 |
||
142 |
virtual void SubclassHWND(); |
|
143 |
virtual void UnsubclassHWND(); |
|
144 |
||
145 |
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, |
|
146 |
WPARAM wParam, LPARAM lParam); |
|
147 |
||
148 |
/* |
|
149 |
* Access to the various objects of this aggregate component |
|
150 |
*/ |
|
151 |
INLINE HWND GetHWnd() { return m_hwnd; } |
|
152 |
INLINE void SetHWnd(HWND hwnd) { m_hwnd = hwnd; } |
|
153 |
||
154 |
static AwtComponent* GetComponent(HWND hWnd); |
|
155 |
||
156 |
/* |
|
157 |
* Access to the properties of the component |
|
158 |
*/ |
|
159 |
INLINE COLORREF GetColor() { return m_colorForeground; } |
|
160 |
virtual void SetColor(COLORREF c); |
|
161 |
HPEN GetForegroundPen(); |
|
162 |
||
163 |
COLORREF GetBackgroundColor(); |
|
164 |
virtual void SetBackgroundColor(COLORREF c); |
|
165 |
HBRUSH GetBackgroundBrush(); |
|
166 |
INLINE BOOL IsBackgroundColorSet() { return m_backgroundColorSet; } |
|
167 |
||
168 |
virtual void SetFont(AwtFont *pFont); |
|
169 |
||
170 |
INLINE void SetText(LPCTSTR text) { ::SetWindowText(GetHWnd(), text); } |
|
171 |
INLINE int GetText(LPTSTR buffer, int size) { |
|
172 |
return ::GetWindowText(GetHWnd(), buffer, size); |
|
173 |
} |
|
174 |
INLINE int GetTextLength() { return ::GetWindowTextLength(GetHWnd()); } |
|
175 |
||
176 |
virtual void GetInsets(RECT* rect) { |
|
177 |
VERIFY(::SetRectEmpty(rect)); |
|
178 |
} |
|
179 |
||
180 |
BOOL IsVisible() { return m_visible;}; |
|
181 |
||
182 |
HDC GetDCFromComponent(); |
|
183 |
||
184 |
/* |
|
185 |
* Enable/disable component |
|
186 |
*/ |
|
187 |
virtual void Enable(BOOL bEnable); |
|
188 |
||
189 |
/* |
|
190 |
* Validate and call handleExpose on rects of UpdateRgn |
|
191 |
*/ |
|
192 |
void PaintUpdateRgn(const RECT *insets); |
|
193 |
||
194 |
static HWND GetTopLevelParentForWindow(HWND hwndDescendant); |
|
195 |
||
196 |
static jobject FindHeavyweightUnderCursor(BOOL useCache); |
|
197 |
||
198 |
/* |
|
199 |
* Returns the parent component. If no parent window, or the |
|
200 |
* parent window isn't an AwtComponent, returns NULL. |
|
201 |
*/ |
|
202 |
AwtComponent* GetParent(); |
|
203 |
||
887 | 204 |
/* Get the component's immediate container. Note: may return NULL while |
205 |
the component is being reparented in full-screen mode by Direct3D */ |
|
2 | 206 |
class AwtWindow* GetContainer(); |
207 |
||
208 |
/* Is a component a container? Used by above method */ |
|
209 |
virtual BOOL IsContainer() { return FALSE;} // Plain components can't |
|
210 |
||
211 |
/** |
|
212 |
* Perform some actions which by default are being performed by Default Window procedure of |
|
213 |
* this window class |
|
214 |
* For detailed comments see implementation in awt_Component.cpp |
|
215 |
*/ |
|
216 |
virtual BOOL ActMouseMessage(MSG * pMsg); |
|
217 |
/** |
|
218 |
* Returns TRUE if this message will this component to become focused. Returns FALSE otherwise. |
|
219 |
*/ |
|
220 |
inline BOOL IsFocusingMessage(UINT message) { |
|
221 |
return message == WM_LBUTTONDOWN || message == WM_LBUTTONUP || message == WM_LBUTTONDBLCLK; |
|
222 |
} |
|
223 |
||
224 |
BOOL IsFocusable(); |
|
225 |
||
226 |
/* |
|
227 |
* Returns an increasing unsigned value used for child control IDs. |
|
228 |
* There is no attempt to reclaim command ID's. |
|
229 |
*/ |
|
230 |
INLINE UINT CreateControlID() { return m_nextControlID++; } |
|
231 |
||
232 |
// returns the current keyboard layout |
|
233 |
INLINE static HKL GetKeyboardLayout() { |
|
234 |
return m_hkl; |
|
235 |
} |
|
236 |
||
237 |
// returns the current code page that should be used in |
|
238 |
// all MultiByteToWideChar and WideCharToMultiByte calls. |
|
239 |
// This code page should also be use in IsDBCSLeadByteEx. |
|
240 |
INLINE static UINT GetCodePage() |
|
241 |
{ |
|
242 |
return m_CodePage; |
|
243 |
} |
|
244 |
||
245 |
// Added by waleed for BIDI Support |
|
246 |
// returns the right to left status |
|
247 |
INLINE static BOOL GetRTLReadingOrder() { |
|
248 |
return sm_rtlReadingOrder; |
|
249 |
} |
|
250 |
// returns the right to left status |
|
251 |
INLINE static BOOL GetRTL() { |
|
252 |
return sm_rtl; |
|
253 |
} |
|
254 |
// returns the current sub language |
|
255 |
INLINE static LANGID GetSubLanguage() { |
|
256 |
return SUBLANGID(m_idLang); |
|
257 |
} |
|
258 |
// end waleed |
|
259 |
||
260 |
// returns the current input language |
|
261 |
INLINE static LANGID GetInputLanguage() |
|
262 |
{ |
|
263 |
return m_idLang; |
|
264 |
} |
|
265 |
// Convert Language ID to CodePage |
|
266 |
static UINT LangToCodePage(LANGID idLang); |
|
267 |
||
268 |
/* |
|
269 |
* methods on this component |
|
270 |
*/ |
|
271 |
virtual void Show(); |
|
272 |
virtual void Hide(); |
|
273 |
virtual void Reshape(int x, int y, int w, int h); |
|
274 |
||
275 |
/* |
|
276 |
* Fix for 4046446. |
|
277 |
* Component size/position helper, for the values above the short int limit. |
|
278 |
*/ |
|
279 |
static BOOL SetWindowPos(HWND wnd, HWND after, |
|
280 |
int x, int y, int w, int h, UINT flags); |
|
281 |
||
282 |
/* |
|
283 |
* Sets the scrollbar values. 'bar' can be either SB_VERT or |
|
284 |
* SB_HORZ. 'min', 'value', and 'max' can have the value INT_MAX |
|
285 |
* which means that the value should not be changed. |
|
286 |
*/ |
|
287 |
void SetScrollValues(UINT bar, int min, int value, int max); |
|
288 |
||
289 |
INLINE LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0) { |
|
290 |
DASSERT(GetHWnd()); |
|
291 |
return ::SendMessage(GetHWnd(), msg, wParam, lParam); |
|
292 |
} |
|
293 |
||
294 |
void PostUngrabEvent(); |
|
295 |
||
296 |
INLINE virtual LONG GetStyle() { |
|
297 |
DASSERT(GetHWnd()); |
|
298 |
return ::GetWindowLong(GetHWnd(), GWL_STYLE); |
|
299 |
} |
|
300 |
INLINE virtual void SetStyle(LONG style) { |
|
301 |
DASSERT(GetHWnd()); |
|
302 |
// SetWindowLong() error handling as recommended by Win32 API doc. |
|
303 |
::SetLastError(0); |
|
304 |
DWORD ret = ::SetWindowLong(GetHWnd(), GWL_STYLE, style); |
|
305 |
DASSERT(ret != 0 || ::GetLastError() == 0); |
|
306 |
} |
|
307 |
INLINE virtual LONG GetStyleEx() { |
|
308 |
DASSERT(GetHWnd()); |
|
309 |
return ::GetWindowLong(GetHWnd(), GWL_EXSTYLE); |
|
310 |
} |
|
311 |
INLINE virtual void SetStyleEx(LONG style) { |
|
312 |
DASSERT(GetHWnd()); |
|
313 |
// SetWindowLong() error handling as recommended by Win32 API doc. |
|
314 |
::SetLastError(0); |
|
315 |
DWORD ret = ::SetWindowLong(GetHWnd(), GWL_EXSTYLE, style); |
|
316 |
DASSERT(ret != 0 || ::GetLastError() == 0); |
|
317 |
} |
|
318 |
||
319 |
virtual BOOL NeedDblClick() { return FALSE; } |
|
320 |
||
321 |
/* for multifont component */ |
|
322 |
static void DrawWindowText(HDC hDC, jobject font, jstring text, |
|
323 |
int x, int y); |
|
324 |
static void DrawGrayText(HDC hDC, jobject font, jstring text, |
|
325 |
int x, int y); |
|
326 |
||
327 |
void DrawListItem(JNIEnv *env, DRAWITEMSTRUCT &drawInfo); |
|
328 |
||
329 |
void MeasureListItem(JNIEnv *env, MEASUREITEMSTRUCT &measureInfo); |
|
330 |
||
331 |
jstring GetItemString(JNIEnv *env, jobject target, jint index); |
|
332 |
||
333 |
jint GetFontHeight(JNIEnv *env); |
|
334 |
||
335 |
virtual jobject PreferredItemSize(JNIEnv *env) {DASSERT(FALSE); return NULL; } |
|
336 |
||
337 |
INLINE BOOL isEnabled() { |
|
338 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
339 |
if (env->EnsureLocalCapacity(2) < 0) { |
|
340 |
return NULL; |
|
341 |
} |
|
342 |
jobject self = GetPeer(env); |
|
343 |
jobject target = env->GetObjectField(self, AwtObject::targetID); |
|
344 |
BOOL e = env->CallBooleanMethod(target, AwtComponent::isEnabledMID); |
|
345 |
DASSERT(!safe_ExceptionOccurred(env)); |
|
346 |
||
347 |
env->DeleteLocalRef(target); |
|
348 |
||
349 |
return e; |
|
350 |
} |
|
351 |
||
352 |
INLINE BOOL isRecursivelyEnabled() { |
|
353 |
AwtComponent* p = this; |
|
354 |
do { |
|
355 |
if (!p->isEnabled()) { |
|
356 |
return FALSE; |
|
357 |
} |
|
358 |
} while (!p->IsTopLevel() && |
|
359 |
(p = p->GetParent()) != NULL); |
|
360 |
return TRUE; |
|
361 |
} |
|
362 |
||
363 |
void SendKeyEventToFocusOwner(jint id, jlong when, jint raw, jint cooked, |
|
364 |
jint modifiers, jint keyLocation, |
|
365 |
MSG *msg = NULL); |
|
366 |
/* |
|
367 |
* Allocate and initialize a new java.awt.event.KeyEvent, and |
|
368 |
* post it to the peer's target object. No response is expected |
|
369 |
* from the target. |
|
370 |
*/ |
|
371 |
void SendKeyEvent(jint id, jlong when, jint raw, jint cooked, |
|
372 |
jint modifiers, jint keyLocation, |
|
373 |
MSG *msg = NULL); |
|
374 |
||
375 |
/* |
|
376 |
* Allocate and initialize a new java.awt.event.MouseEvent, and |
|
377 |
* post it to the peer's target object. No response is expected |
|
378 |
* from the target. |
|
379 |
*/ |
|
380 |
void SendMouseEvent(jint id, jlong when, jint x, jint y, |
|
381 |
jint modifiers, jint clickCount, |
|
382 |
jboolean popupTrigger, jint button = 0, |
|
383 |
MSG *msg = NULL); |
|
384 |
||
385 |
/* |
|
386 |
* Allocate and initialize a new java.awt.event.MouseWheelEvent, and |
|
387 |
* post it to the peer's target object. No response is expected |
|
388 |
* from the target. |
|
389 |
*/ |
|
390 |
void SendMouseWheelEvent(jint id, jlong when, jint x, jint y, |
|
391 |
jint modifiers, jint clickCount, |
|
392 |
jboolean popupTrigger, jint scrollType, |
|
393 |
jint scrollAmount, jint wheelRotation, |
|
121 | 394 |
jdouble preciseWheelRotation, MSG *msg = NULL); |
2 | 395 |
|
396 |
/* |
|
397 |
* Allocate and initialize a new java.awt.event.FocusEvent, and |
|
398 |
* post it to the peer's target object. No response is expected |
|
399 |
* from the target. |
|
400 |
*/ |
|
401 |
void SendFocusEvent(jint id, HWND opposite); |
|
402 |
||
403 |
/* Forward a filtered event directly to the subclassed window. |
|
404 |
synthetic should be TRUE iff the message was generated because |
|
405 |
of a synthetic Java event, rather than a native event. */ |
|
406 |
virtual MsgRouting HandleEvent(MSG *msg, BOOL synthetic); |
|
407 |
||
408 |
/* Post a WM_AWT_HANDLE_EVENT message which invokes HandleEvent |
|
409 |
on the toolkit thread. This method may pre-filter the messages. */ |
|
410 |
virtual BOOL PostHandleEventMessage(MSG *msg, BOOL synthetic); |
|
411 |
||
412 |
/* Event->message synthesizer methods. */ |
|
413 |
void SynthesizeKeyMessage(JNIEnv *env, jobject keyEvent); |
|
414 |
void SynthesizeMouseMessage(JNIEnv *env, jobject mouseEvent); |
|
415 |
||
416 |
/* Components which inherit native mouse wheel behavior will |
|
417 |
* return TRUE. These are TextArea, Choice, FileDialog, and |
|
418 |
* List. All other Components return FALSE. |
|
419 |
*/ |
|
420 |
virtual BOOL InheritsNativeMouseWheelBehavior(); |
|
421 |
||
422 |
/* Functions for MouseWheel support on Windows95 |
|
423 |
* These should only be called if running on 95 |
|
424 |
*/ |
|
425 |
static void Wheel95Init(); |
|
426 |
INLINE static UINT Wheel95GetMsg() {return sm_95WheelMessage;} |
|
427 |
static UINT Wheel95GetScrLines(); |
|
428 |
||
429 |
/* Determines whether the component is obscured by another window */ |
|
430 |
// Called on Toolkit thread |
|
431 |
static jboolean _IsObscured(void *param); |
|
432 |
||
433 |
/* Invalidate the specified rectangle. */ |
|
434 |
virtual void Invalidate(RECT* r); |
|
435 |
||
436 |
/* Begin and end deferred window positioning. */ |
|
437 |
virtual void BeginValidate(); |
|
438 |
virtual void EndValidate(); |
|
439 |
||
440 |
/* Keyboard conversion routines. */ |
|
441 |
static void InitDynamicKeyMapTable(); |
|
442 |
static void BuildDynamicKeyMapTable(); |
|
443 |
static jint GetJavaModifiers(); |
|
444 |
static jint GetButton(int mouseButton); |
|
445 |
static UINT GetButtonMK(int mouseButton); |
|
446 |
static UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers); |
|
447 |
static void JavaKeyToWindowsKey(UINT javaKey, UINT *windowsKey, UINT *modifiers, UINT originalWindowsKey); |
|
448 |
||
449 |
INLINE static void AwtComponent::JavaKeyToWindowsKey(UINT javaKey, |
|
450 |
UINT *windowsKey, UINT *modifiers) |
|
451 |
{ |
|
452 |
JavaKeyToWindowsKey(javaKey, windowsKey, modifiers, IGNORE_KEY); |
|
453 |
} |
|
454 |
||
455 |
enum TransOps {NONE, LOAD, SAVE}; |
|
456 |
||
457 |
UINT WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops); |
|
458 |
||
459 |
/* routines used for input method support */ |
|
460 |
void SetInputMethod(jobject im, BOOL useNativeCompWindow); |
|
461 |
void SendInputMethodEvent(jint id, jstring text, int cClause, |
|
462 |
int *rgClauseBoundary, jstring *rgClauseReading, |
|
463 |
int cAttrBlock, int *rgAttrBoundary, |
|
464 |
BYTE *rgAttrValue, int commitedTextLength, |
|
465 |
int caretPos, int visiblePos); |
|
466 |
void InquireCandidatePosition(); |
|
467 |
INLINE LPARAM GetCandidateType() { return m_bitsCandType; } |
|
468 |
HIMC ImmGetContext(); |
|
469 |
HIMC ImmAssociateContext(HIMC himc); |
|
470 |
HWND GetProxyFocusOwner(); |
|
471 |
void CallProxyDefWindowProc(UINT message, |
|
472 |
WPARAM wParam, |
|
473 |
LPARAM lParam, |
|
474 |
LRESULT &retVal, |
|
475 |
MsgRouting &mr); |
|
476 |
||
477 |
/* |
|
478 |
* Windows message handler functions |
|
479 |
*/ |
|
480 |
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); |
|
481 |
virtual LRESULT DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam); |
|
482 |
||
483 |
/* return true if msg is processed */ |
|
484 |
virtual MsgRouting PreProcessMsg(MSG& msg); |
|
485 |
||
486 |
virtual MsgRouting WmCreate() {return mrDoDefault;} |
|
487 |
virtual MsgRouting WmClose() {return mrDoDefault;} |
|
488 |
virtual MsgRouting WmDestroy(); |
|
489 |
||
490 |
virtual MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite) |
|
491 |
{ |
|
492 |
return mrDoDefault; |
|
493 |
} |
|
494 |
||
495 |
virtual MsgRouting WmEraseBkgnd(HDC hDC, BOOL& didErase) |
|
496 |
{ |
|
497 |
return mrDoDefault; |
|
498 |
} |
|
499 |
||
500 |
virtual MsgRouting WmPaint(HDC hDC); |
|
501 |
virtual MsgRouting WmGetMinMaxInfo(LPMINMAXINFO lpmmi); |
|
502 |
virtual MsgRouting WmMove(int x, int y); |
|
503 |
virtual MsgRouting WmSize(UINT type, int w, int h); |
|
504 |
virtual MsgRouting WmSizing(); |
|
505 |
virtual MsgRouting WmShowWindow(BOOL show, UINT status); |
|
506 |
virtual MsgRouting WmSetFocus(HWND hWndLost); |
|
507 |
virtual MsgRouting WmKillFocus(HWND hWndGot); |
|
508 |
jboolean WmComponentSetFocus(WmComponentSetFocusData *data); |
|
509 |
// Use instead of ::SetFocus to maintain special focusing semantics for |
|
510 |
// Windows which are not Frames/Dialogs. |
|
511 |
BOOL AwtSetFocus(); |
|
512 |
||
513 |
virtual MsgRouting WmCtlColor(HDC hDC, HWND hCtrl, |
|
514 |
UINT ctlColor, HBRUSH& retBrush); |
|
515 |
virtual MsgRouting WmHScroll(UINT scrollCode, UINT pos, HWND hScrollBar); |
|
516 |
virtual MsgRouting WmVScroll(UINT scrollCode, UINT pos, HWND hScrollBar); |
|
517 |
||
518 |
virtual MsgRouting WmMouseEnter(UINT flags, int x, int y); |
|
519 |
virtual MsgRouting WmMouseDown(UINT flags, int x, int y, int button); |
|
520 |
virtual MsgRouting WmMouseUp(UINT flags, int x, int y, int button); |
|
521 |
virtual MsgRouting WmMouseMove(UINT flags, int x, int y); |
|
522 |
virtual MsgRouting WmMouseExit(UINT flags, int x, int y); |
|
523 |
virtual MsgRouting WmMouseWheel(UINT flags, int x, int y, |
|
524 |
int wheelRotation); |
|
525 |
virtual MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button); |
|
526 |
virtual MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button); |
|
527 |
virtual MsgRouting WmWindowPosChanging(LPARAM windowPos); |
|
528 |
virtual MsgRouting WmWindowPosChanged(LPARAM windowPos); |
|
529 |
||
530 |
// NB: 64-bit: vkey is wParam of the message, but other API's take |
|
531 |
// vkey parameters of type UINT, so we do the cast before dispatching. |
|
532 |
virtual MsgRouting WmKeyDown(UINT vkey, UINT repCnt, UINT flags, BOOL system); |
|
533 |
virtual MsgRouting WmKeyUp(UINT vkey, UINT repCnt, UINT flags, BOOL system); |
|
534 |
||
535 |
virtual MsgRouting WmChar(UINT character, UINT repCnt, UINT flags, BOOL system); |
|
536 |
virtual MsgRouting WmIMEChar(UINT character, UINT repCnt, UINT flags, BOOL system); |
|
537 |
virtual MsgRouting WmInputLangChange(UINT charset, HKL hKeyBoardLayout); |
|
538 |
virtual MsgRouting WmForwardChar(WCHAR character, LPARAM lParam, |
|
539 |
BOOL synthethic); |
|
540 |
virtual MsgRouting WmPaste(); |
|
541 |
||
542 |
virtual void SetCompositionWindow(RECT &r); |
|
543 |
virtual void OpenCandidateWindow(int x, int y); |
|
544 |
virtual void SetCandidateWindow(int iCandType, int x, int y); |
|
545 |
virtual MsgRouting WmImeSetContext(BOOL fSet, LPARAM *lplParam); |
|
546 |
virtual MsgRouting WmImeNotify(WPARAM subMsg, LPARAM bitsCandType); |
|
547 |
virtual MsgRouting WmImeStartComposition(); |
|
548 |
virtual MsgRouting WmImeEndComposition(); |
|
549 |
virtual MsgRouting WmImeComposition(WORD wChar, LPARAM flags); |
|
550 |
||
551 |
virtual MsgRouting WmTimer(UINT_PTR timerID) {return mrDoDefault;} |
|
552 |
||
553 |
virtual MsgRouting WmCommand(UINT id, HWND hWndCtrl, UINT notifyCode); |
|
554 |
||
555 |
/* reflected WmCommand from parent */ |
|
556 |
virtual MsgRouting WmNotify(UINT notifyCode); |
|
557 |
||
558 |
virtual MsgRouting WmCompareItem(UINT /*ctrlId*/, |
|
559 |
COMPAREITEMSTRUCT &compareInfo, |
|
560 |
LRESULT &result); |
|
561 |
virtual MsgRouting WmDeleteItem(UINT /*ctrlId*/, |
|
562 |
DELETEITEMSTRUCT &deleteInfo); |
|
563 |
virtual MsgRouting WmDrawItem(UINT ctrlId, |
|
564 |
DRAWITEMSTRUCT &drawInfo); |
|
565 |
virtual MsgRouting WmMeasureItem(UINT ctrlId, |
|
566 |
MEASUREITEMSTRUCT &measureInfo); |
|
567 |
/* Fix 4181790 & 4223341 : These functions get overridden in owner-drawn |
|
568 |
* components instead of the Wm... versions. |
|
569 |
*/ |
|
570 |
virtual MsgRouting OwnerDrawItem(UINT ctrlId, |
|
571 |
DRAWITEMSTRUCT &drawInfo); |
|
572 |
virtual MsgRouting OwnerMeasureItem(UINT ctrlId, |
|
573 |
MEASUREITEMSTRUCT &measureInfo); |
|
574 |
||
575 |
virtual MsgRouting WmPrint(HDC hDC, LPARAM flags); |
|
576 |
virtual MsgRouting WmPrintClient(HDC hDC, LPARAM flags); |
|
577 |
||
578 |
virtual MsgRouting WmNcCalcSize(BOOL fCalcValidRects, |
|
579 |
LPNCCALCSIZE_PARAMS lpncsp, |
|
580 |
LRESULT &retVal); |
|
581 |
virtual MsgRouting WmNcPaint(HRGN hrgn); |
|
582 |
virtual MsgRouting WmNcHitTest(UINT x, UINT y, LRESULT &retVal); |
|
583 |
virtual MsgRouting WmSysCommand(UINT uCmdType, int xPos, int yPos); |
|
584 |
virtual MsgRouting WmExitSizeMove(); |
|
585 |
virtual MsgRouting WmEnterMenuLoop(BOOL isTrackPopupMenu); |
|
586 |
virtual MsgRouting WmExitMenuLoop(BOOL isTrackPopupMenu); |
|
587 |
||
588 |
virtual MsgRouting WmQueryNewPalette(LRESULT &retVal); |
|
589 |
virtual MsgRouting WmPaletteChanged(HWND hwndPalChg); |
|
590 |
virtual MsgRouting WmPaletteIsChanging(HWND hwndPalChg); |
|
591 |
virtual MsgRouting WmStyleChanged(int wStyleType, LPSTYLESTRUCT lpss); |
|
592 |
virtual MsgRouting WmSettingChange(UINT wFlag, LPCTSTR pszSection); |
|
593 |
||
594 |
virtual MsgRouting WmContextMenu(HWND hCtrl, UINT xPos, UINT yPos) { |
|
595 |
return mrDoDefault; |
|
596 |
} |
|
597 |
||
598 |
void UpdateColorModel(); |
|
599 |
||
600 |
jintArray CreatePrintedPixels(SIZE &loc, SIZE &size); |
|
601 |
||
602 |
static void * GetNativeFocusOwner(); |
|
603 |
static void * GetNativeFocusedWindow(); |
|
604 |
static void ClearGlobalFocusOwner(); |
|
605 |
||
606 |
/* |
|
607 |
* HWND, AwtComponent and Java Peer interaction |
|
608 |
* |
|
609 |
* Link the C++, Java peer, and HWNDs together. |
|
610 |
*/ |
|
611 |
void LinkObjects(JNIEnv *env, jobject peer); |
|
612 |
||
613 |
void UnlinkObjects(); |
|
614 |
||
615 |
static BOOL QueryNewPaletteCalled() { return m_QueryNewPaletteCalled; } |
|
616 |
||
617 |
#ifdef DEBUG |
|
618 |
virtual void VerifyState(); /* verify component and peer are in sync. */ |
|
619 |
#else |
|
620 |
void VerifyState() {} /* no-op */ |
|
621 |
#endif |
|
622 |
||
623 |
virtual AwtDropTarget* CreateDropTarget(JNIEnv* env); |
|
624 |
virtual void DestroyDropTarget(); |
|
625 |
||
626 |
INLINE virtual HWND GetDBCSEditHandle() { return NULL; } |
|
627 |
// State for native drawing API |
|
628 |
INLINE jint GetDrawState() { return GetDrawState(m_hwnd); } |
|
629 |
INLINE void SetDrawState(jint state) { SetDrawState(m_hwnd, state); } // State for native drawing API |
|
630 |
||
631 |
INLINE virtual BOOL IsTopLevel() { return FALSE; } |
|
632 |
INLINE virtual BOOL IsEmbeddedFrame() { return FALSE; } |
|
633 |
INLINE virtual BOOL IsScrollbar() { return FALSE; } |
|
634 |
||
635 |
static INLINE BOOL IsTopLevelHWnd(HWND hwnd) { |
|
636 |
AwtComponent *comp = AwtComponent::GetComponent(hwnd); |
|
637 |
return (comp != NULL && comp->IsTopLevel()); |
|
638 |
} |
|
639 |
static INLINE BOOL IsEmbeddedFrameHWnd(HWND hwnd) { |
|
640 |
AwtComponent *comp = AwtComponent::GetComponent(hwnd); |
|
641 |
return (comp != NULL && comp->IsEmbeddedFrame()); |
|
642 |
} |
|
643 |
||
644 |
static jint GetDrawState(HWND hwnd); |
|
645 |
static void SetDrawState(HWND hwnd, jint state); |
|
646 |
||
647 |
static HWND GetHWnd(JNIEnv* env, jobject target); |
|
648 |
||
649 |
static MSG* CreateMessage(UINT message, WPARAM wParam, LPARAM lParam, int x, int y); |
|
650 |
static void InitMessage(MSG* msg, UINT message, WPARAM wParam, LPARAM lParam, int x, int y); |
|
651 |
||
652 |
// Some methods to be called on Toolkit thread via Toolkit.InvokeFunction() |
|
653 |
static void _Show(void *param); |
|
654 |
static void _Hide(void *param); |
|
655 |
static void _Enable(void *param); |
|
656 |
static void _Disable(void *param); |
|
657 |
static jobject _GetLocationOnScreen(void *param); |
|
658 |
static void _Reshape(void *param); |
|
659 |
static void _ReshapeNoCheck(void *param); |
|
660 |
static void _NativeHandleEvent(void *param); |
|
661 |
static void _SetForeground(void *param); |
|
662 |
static void _SetBackground(void *param); |
|
663 |
static void _SetFont(void *param); |
|
664 |
static jboolean _RequestFocus(void *param); |
|
665 |
static void _Start(void *param); |
|
666 |
static void _BeginValidate(void *param); |
|
667 |
static void _EndValidate(void *param); |
|
668 |
static void _UpdateWindow(void *param); |
|
669 |
static jlong _AddNativeDropTarget(void *param); |
|
670 |
static void _RemoveNativeDropTarget(void *param); |
|
671 |
static jintArray _CreatePrintedPixels(void *param); |
|
672 |
static jboolean _NativeHandlesWheelScrolling(void *param); |
|
673 |
static void _SetRectangularShape(void *param); |
|
674 |
||
675 |
static HWND sm_focusOwner; |
|
676 |
static HWND sm_focusedWindow; |
|
677 |
||
678 |
static BOOL m_isWin95; |
|
679 |
static BOOL m_isWin2000; |
|
680 |
static BOOL m_isWinNT; |
|
681 |
||
682 |
static BOOL sm_bMenuLoop; |
|
683 |
static INLINE BOOL isMenuLoopActive() { |
|
684 |
return sm_bMenuLoop; |
|
685 |
} |
|
686 |
||
687 |
// when this component is being destroyed, this method is called |
|
688 |
// to find out if there are any messages being processed, and if |
|
689 |
// there are some then disposal of this component is postponed |
|
690 |
virtual BOOL CanBeDeleted() { |
|
691 |
return m_MessagesProcessing == 0; |
|
692 |
} |
|
693 |
||
694 |
protected: |
|
695 |
static AwtComponent* GetComponentImpl(HWND hWnd); |
|
696 |
||
697 |
static int GetClickCount(); |
|
698 |
||
699 |
HWND m_hwnd; |
|
700 |
UINT m_myControlID; /* its own ID from the view point of parent */ |
|
701 |
BOOL m_backgroundColorSet; |
|
702 |
BOOL m_visible; /* copy of Component.visible */ |
|
703 |
||
704 |
static BOOL sm_suppressFocusAndActivation; |
|
705 |
static HWND sm_realFocusOpposite; |
|
706 |
||
707 |
virtual void SetDragCapture(UINT flags); |
|
708 |
virtual void ReleaseDragCapture(UINT flags); |
|
709 |
||
710 |
// 95 support for mouse wheel |
|
711 |
static UINT sm_95WheelMessage; |
|
712 |
static UINT sm_95WheelSupport; |
|
713 |
||
714 |
private: |
|
447
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
715 |
/* A bitmask keeps the button's numbers as MK_LBUTTON, MK_MBUTTON, MK_RBUTTON |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
716 |
* which are allowed to |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
717 |
* generate the CLICK event after the RELEASE has happened. |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
718 |
* There are conditions that must be true for that sending CLICK event: |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
719 |
* 1) button was initially PRESSED |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
720 |
* 2) no movement or drag has happened until RELEASE |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
721 |
*/ |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
722 |
UINT m_mouseButtonClickAllowed; |
0fb5f354ad70
6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents:
121
diff
changeset
|
723 |
|
2 | 724 |
BOOL m_bSubclassed; |
725 |
||
726 |
COLORREF m_colorForeground; |
|
727 |
COLORREF m_colorBackground; |
|
728 |
||
729 |
AwtPen* m_penForeground; |
|
730 |
AwtBrush* m_brushBackground; |
|
731 |
||
732 |
WNDPROC m_DefWindowProc; |
|
733 |
// counter for messages being processed by this component |
|
734 |
UINT m_MessagesProcessing; |
|
735 |
||
736 |
// provides a unique ID for child controls |
|
737 |
UINT m_nextControlID; |
|
738 |
||
739 |
// DeferWindowPos handle for batched-up window positioning |
|
740 |
HDWP m_hdwp; |
|
741 |
// Counter to handle nested calls to Begin/EndValidate |
|
742 |
UINT m_validationNestCount; |
|
743 |
||
744 |
AwtDropTarget* m_dropTarget; // associated DropTarget object |
|
745 |
||
746 |
// When we process WM_INPUTLANGCHANGE we remember the keyboard |
|
747 |
// layout handle and associated input language and codepage. |
|
748 |
// We also invalidate VK translation table for VK_OEM_* codes |
|
749 |
static HKL m_hkl; |
|
750 |
static UINT m_CodePage; |
|
751 |
static LANGID m_idLang; |
|
752 |
||
753 |
static BOOL sm_rtl; |
|
754 |
static BOOL sm_rtlReadingOrder; |
|
755 |
||
756 |
jobject m_InputMethod; |
|
757 |
BOOL m_useNativeCompWindow; |
|
758 |
LPARAM m_bitsCandType; |
|
759 |
UINT m_PendingLeadByte; |
|
760 |
||
761 |
void SetComponentInHWND(); |
|
762 |
||
763 |
// Determines whether a given virtual key is on the numpad |
|
764 |
static BOOL IsNumPadKey(UINT vkey, BOOL extended); |
|
765 |
||
766 |
// Determines the keyLocation of a given key |
|
767 |
static jint GetKeyLocation(UINT wkey, UINT flags); |
|
768 |
static jint GetShiftKeyLocation(UINT wkey, UINT flags); |
|
769 |
||
770 |
// Cache for FindComponent |
|
771 |
static HWND sm_cursorOn; |
|
772 |
||
773 |
static BOOL m_QueryNewPaletteCalled; |
|
774 |
||
775 |
BOOL m_skipNextSetFocus; |
|
776 |
||
777 |
static AwtComponent* sm_getComponentCache; // a cache for the GetComponent(..) method. |
|
778 |
||
779 |
int windowMoveLockPosX; |
|
780 |
int windowMoveLockPosY; |
|
781 |
int windowMoveLockPosCX; |
|
782 |
int windowMoveLockPosCY; |
|
783 |
||
121 | 784 |
// 6524352: support finer-resolution |
785 |
static int sm_wheelRotationAmount; |
|
786 |
||
2 | 787 |
/* |
788 |
* The association list of children's IDs and corresponding components. |
|
789 |
* Some components like Choice or List are required their sizes while |
|
790 |
* the creations of themselfs are in progress. |
|
791 |
*/ |
|
792 |
class ChildListItem { |
|
793 |
public: |
|
794 |
ChildListItem(UINT id, AwtComponent* component) { |
|
795 |
m_ID = id; |
|
796 |
m_Component = component; |
|
797 |
m_next = NULL; |
|
798 |
} |
|
799 |
~ChildListItem() { |
|
800 |
if (m_next != NULL) |
|
801 |
delete m_next; |
|
802 |
} |
|
803 |
||
804 |
UINT m_ID; |
|
805 |
AwtComponent* m_Component; |
|
806 |
ChildListItem* m_next; |
|
807 |
}; |
|
808 |
||
809 |
public: |
|
810 |
INLINE void PushChild(UINT id, AwtComponent* component) { |
|
811 |
ChildListItem* child = new ChildListItem(id, component); |
|
812 |
child->m_next = m_childList; |
|
813 |
m_childList = child; |
|
814 |
} |
|
815 |
||
816 |
static void SetParent(void * param); |
|
817 |
private: |
|
818 |
AwtComponent* SearchChild(UINT id); |
|
819 |
void RemoveChild(UINT id) ; |
|
820 |
||
821 |
ChildListItem* m_childList; |
|
822 |
||
823 |
HCURSOR m_hCursorCache; // the latest cursor which has been active within the heavyweight component |
|
824 |
public: |
|
825 |
inline void setCursorCache(HCURSOR hCursor) { |
|
826 |
m_hCursorCache = hCursor; |
|
827 |
} |
|
828 |
inline HCURSOR getCursorCache() { |
|
829 |
return m_hCursorCache; |
|
830 |
} |
|
831 |
}; |
|
832 |
||
833 |
class CounterHelper { |
|
834 |
private: |
|
835 |
UINT *m_counter; |
|
836 |
public: |
|
837 |
explicit CounterHelper(UINT *counter) { |
|
838 |
m_counter = counter; |
|
839 |
(*m_counter)++; |
|
840 |
} |
|
841 |
~CounterHelper() { |
|
842 |
(*m_counter)--; |
|
843 |
m_counter = NULL; |
|
844 |
} |
|
845 |
}; |
|
846 |
||
847 |
// DC management objects; these classes are used to track the list of |
|
848 |
// DC's associated with a given Component. Then DC's can be released |
|
849 |
// appropriately on demand or on window destruction to avoid resource |
|
850 |
// leakage. |
|
851 |
class DCItem { |
|
852 |
public: |
|
853 |
HDC hDC; |
|
854 |
HWND hWnd; |
|
855 |
DCItem *next; |
|
856 |
}; |
|
857 |
class DCList { |
|
858 |
DCItem *head; |
|
859 |
CriticalSection listLock; |
|
860 |
public: |
|
861 |
DCList() { head = NULL; } |
|
862 |
||
863 |
void AddDC(HDC hDC, HWND hWnd); |
|
864 |
void AddDCItem(DCItem *newItem); |
|
865 |
DCItem *RemoveDC(HDC hDC); |
|
866 |
DCItem *RemoveAllDCs(HWND hWnd); |
|
867 |
void RealizePalettes(int screen); |
|
868 |
}; |
|
869 |
||
870 |
struct WmComponentSetFocusData { |
|
871 |
jobject lightweightChild; |
|
872 |
jboolean temporary; |
|
873 |
jboolean focusedWindowChangeAllowed; |
|
874 |
jlong time; |
|
875 |
jobject cause; |
|
876 |
}; |
|
877 |
||
878 |
void ReleaseDCList(HWND hwnd, DCList &list); |
|
879 |
void MoveDCToPassiveList(HDC hDC); |
|
880 |
||
881 |
namespace TimeHelper{ |
|
882 |
jlong getMessageTimeUTC(); |
|
883 |
jlong windowsToUTC(DWORD event_offset); |
|
884 |
} |
|
885 |
||
886 |
#include "ObjectList.h" |
|
887 |
||
888 |
#endif /* AWT_COMPONENT_H */ |