OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef VIEWS_WIDGET_WIDGET_WIN_H_ | 5 #ifndef VIEWS_WIDGET_WIDGET_WIN_H_ |
6 #define VIEWS_WIDGET_WIDGET_WIN_H_ | 6 #define VIEWS_WIDGET_WIDGET_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <atlbase.h> | 9 #include <atlbase.h> |
10 #include <atlapp.h> | 10 #include <atlapp.h> |
11 #include <atlcrack.h> | 11 #include <atlcrack.h> |
12 #include <atlmisc.h> | 12 #include <atlmisc.h> |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/scoped_ptr.h" | 18 #include "base/scoped_ptr.h" |
19 #include "base/scoped_vector.h" | 19 #include "base/scoped_vector.h" |
20 #include "base/win/scoped_comptr.h" | 20 #include "base/win/scoped_comptr.h" |
21 #include "ui/base/win/window_impl.h" | 21 #include "ui/base/win/window_impl.h" |
22 #include "views/focus/focus_manager.h" | 22 #include "views/focus/focus_manager.h" |
| 23 #include "views/ime/input_method_delegate.h" |
23 #include "views/layout/layout_manager.h" | 24 #include "views/layout/layout_manager.h" |
24 #include "views/widget/native_widget.h" | 25 #include "views/widget/native_widget.h" |
25 #include "views/widget/widget.h" | 26 #include "views/widget/widget.h" |
26 | 27 |
27 namespace ui { | 28 namespace ui { |
28 class ViewProp; | 29 class ViewProp; |
29 } | 30 } |
30 | 31 |
31 namespace gfx { | 32 namespace gfx { |
32 class CanvasSkia; | 33 class CanvasSkia; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // | 75 // |
75 // This Widget contains a RootView which owns the hierarchy of views within it. | 76 // This Widget contains a RootView which owns the hierarchy of views within it. |
76 // As long as views are part of this tree, they will be deleted automatically | 77 // As long as views are part of this tree, they will be deleted automatically |
77 // when the RootView is destroyed. If you remove a view from the tree, you are | 78 // when the RootView is destroyed. If you remove a view from the tree, you are |
78 // then responsible for cleaning up after it. | 79 // then responsible for cleaning up after it. |
79 // | 80 // |
80 /////////////////////////////////////////////////////////////////////////////// | 81 /////////////////////////////////////////////////////////////////////////////// |
81 class WidgetWin : public ui::WindowImpl, | 82 class WidgetWin : public ui::WindowImpl, |
82 public Widget, | 83 public Widget, |
83 public NativeWidget, | 84 public NativeWidget, |
84 public MessageLoopForUI::Observer { | 85 public MessageLoopForUI::Observer, |
| 86 public internal::InputMethodDelegate { |
85 public: | 87 public: |
86 WidgetWin(); | 88 WidgetWin(); |
87 virtual ~WidgetWin(); | 89 virtual ~WidgetWin(); |
88 | 90 |
89 // Returns the Widget associated with the specified HWND (if any). | 91 // Returns the Widget associated with the specified HWND (if any). |
90 static WidgetWin* GetWidget(HWND hwnd); | 92 static WidgetWin* GetWidget(HWND hwnd); |
91 | 93 |
92 // Returns true if we are on Windows Vista or greater and composition is | 94 // Returns true if we are on Windows Vista or greater and composition is |
93 // enabled. | 95 // enabled. |
94 static bool IsAeroGlassEnabled(); | 96 static bool IsAeroGlassEnabled(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 201 |
200 // Overridden from NativeWidget: | 202 // Overridden from NativeWidget: |
201 virtual Widget* GetWidget() OVERRIDE; | 203 virtual Widget* GetWidget() OVERRIDE; |
202 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; | 204 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; |
203 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; | 205 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; |
204 virtual TooltipManager* GetTooltipManager() const OVERRIDE; | 206 virtual TooltipManager* GetTooltipManager() const OVERRIDE; |
205 virtual bool IsScreenReaderActive() const OVERRIDE; | 207 virtual bool IsScreenReaderActive() const OVERRIDE; |
206 virtual void SetNativeCapture() OVERRIDE; | 208 virtual void SetNativeCapture() OVERRIDE; |
207 virtual void ReleaseNativeCapture() OVERRIDE; | 209 virtual void ReleaseNativeCapture() OVERRIDE; |
208 virtual bool HasNativeCapture() const OVERRIDE; | 210 virtual bool HasNativeCapture() const OVERRIDE; |
| 211 virtual InputMethod* GetInputMethodNative() OVERRIDE; |
| 212 virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE; |
209 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; | 213 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; |
210 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; | 214 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; |
211 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 215 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
212 virtual void MoveAbove(Widget* widget) OVERRIDE; | 216 virtual void MoveAbove(Widget* widget) OVERRIDE; |
213 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; | 217 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; |
214 virtual void Close() OVERRIDE; | 218 virtual void Close() OVERRIDE; |
215 virtual void CloseNow() OVERRIDE; | 219 virtual void CloseNow() OVERRIDE; |
216 virtual void Show() OVERRIDE; | 220 virtual void Show() OVERRIDE; |
217 virtual void Hide() OVERRIDE; | 221 virtual void Hide() OVERRIDE; |
218 virtual void SetOpacity(unsigned char opacity) OVERRIDE; | 222 virtual void SetOpacity(unsigned char opacity) OVERRIDE; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate) | 266 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate) |
263 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave) | 267 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave) |
264 MESSAGE_HANDLER_EX(WM_MOUSEMOVE, OnMouseMove) | 268 MESSAGE_HANDLER_EX(WM_MOUSEMOVE, OnMouseMove) |
265 MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, OnMouseWheel) | 269 MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, OnMouseWheel) |
266 MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnNCMouseLeave) | 270 MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnNCMouseLeave) |
267 MESSAGE_HANDLER_EX(WM_NCMOUSEMOVE, OnNCMouseMove) | 271 MESSAGE_HANDLER_EX(WM_NCMOUSEMOVE, OnNCMouseMove) |
268 | 272 |
269 // Key events. | 273 // Key events. |
270 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyDown) | 274 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyDown) |
271 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyUp) | 275 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyUp) |
272 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyDown); | 276 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyDown) |
273 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyUp); | 277 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyUp) |
| 278 |
| 279 // IME Events. |
| 280 MESSAGE_HANDLER_EX(WM_IME_SETCONTEXT, OnImeMessages) |
| 281 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeMessages) |
| 282 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeMessages) |
| 283 MESSAGE_HANDLER_EX(WM_IME_ENDCOMPOSITION, OnImeMessages) |
| 284 MESSAGE_HANDLER_EX(WM_CHAR, OnImeMessages) |
| 285 MESSAGE_HANDLER_EX(WM_SYSCHAR, OnImeMessages) |
| 286 MESSAGE_HANDLER_EX(WM_DEADCHAR, OnImeMessages) |
| 287 MESSAGE_HANDLER_EX(WM_SYSDEADCHAR, OnImeMessages) |
274 | 288 |
275 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. | 289 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. |
276 MSG_WM_ACTIVATE(OnActivate) | 290 MSG_WM_ACTIVATE(OnActivate) |
277 MSG_WM_ACTIVATEAPP(OnActivateApp) | 291 MSG_WM_ACTIVATEAPP(OnActivateApp) |
278 MSG_WM_APPCOMMAND(OnAppCommand) | 292 MSG_WM_APPCOMMAND(OnAppCommand) |
279 MSG_WM_CANCELMODE(OnCancelMode) | 293 MSG_WM_CANCELMODE(OnCancelMode) |
280 MSG_WM_CAPTURECHANGED(OnCaptureChanged) | 294 MSG_WM_CAPTURECHANGED(OnCaptureChanged) |
281 MSG_WM_CLOSE(OnClose) | 295 MSG_WM_CLOSE(OnClose) |
282 MSG_WM_COMMAND(OnCommand) | 296 MSG_WM_COMMAND(OnCommand) |
283 MSG_WM_CREATE(OnCreate) | 297 MSG_WM_CREATE(OnCreate) |
284 MSG_WM_DESTROY(OnDestroy) | 298 MSG_WM_DESTROY(OnDestroy) |
285 MSG_WM_DISPLAYCHANGE(OnDisplayChange) | 299 MSG_WM_DISPLAYCHANGE(OnDisplayChange) |
286 MSG_WM_ERASEBKGND(OnEraseBkgnd) | 300 MSG_WM_ERASEBKGND(OnEraseBkgnd) |
287 MSG_WM_ENDSESSION(OnEndSession) | 301 MSG_WM_ENDSESSION(OnEndSession) |
288 MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove) | 302 MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove) |
289 MSG_WM_EXITMENULOOP(OnExitMenuLoop) | 303 MSG_WM_EXITMENULOOP(OnExitMenuLoop) |
290 MSG_WM_EXITSIZEMOVE(OnExitSizeMove) | 304 MSG_WM_EXITSIZEMOVE(OnExitSizeMove) |
291 MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) | 305 MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) |
292 MSG_WM_HSCROLL(OnHScroll) | 306 MSG_WM_HSCROLL(OnHScroll) |
293 MSG_WM_INITMENU(OnInitMenu) | 307 MSG_WM_INITMENU(OnInitMenu) |
294 MSG_WM_INITMENUPOPUP(OnInitMenuPopup) | 308 MSG_WM_INITMENUPOPUP(OnInitMenuPopup) |
| 309 MSG_WM_INPUTLANGCHANGE(OnInputLangChange) |
295 MSG_WM_KILLFOCUS(OnKillFocus) | 310 MSG_WM_KILLFOCUS(OnKillFocus) |
296 MSG_WM_MOVE(OnMove) | 311 MSG_WM_MOVE(OnMove) |
297 MSG_WM_MOVING(OnMoving) | 312 MSG_WM_MOVING(OnMoving) |
298 MSG_WM_NCACTIVATE(OnNCActivate) | 313 MSG_WM_NCACTIVATE(OnNCActivate) |
299 MSG_WM_NCCALCSIZE(OnNCCalcSize) | 314 MSG_WM_NCCALCSIZE(OnNCCalcSize) |
300 MSG_WM_NCHITTEST(OnNCHitTest) | 315 MSG_WM_NCHITTEST(OnNCHitTest) |
301 MSG_WM_NCPAINT(OnNCPaint) | 316 MSG_WM_NCPAINT(OnNCPaint) |
302 MSG_WM_NOTIFY(OnNotify) | 317 MSG_WM_NOTIFY(OnNotify) |
303 MSG_WM_PAINT(OnPaint) | 318 MSG_WM_PAINT(OnPaint) |
304 MSG_WM_POWERBROADCAST(OnPowerBroadcast) | 319 MSG_WM_POWERBROADCAST(OnPowerBroadcast) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 WPARAM w_param, | 354 WPARAM w_param, |
340 LPARAM l_param); | 355 LPARAM l_param); |
341 virtual void OnEndSession(BOOL ending, UINT logoff); | 356 virtual void OnEndSession(BOOL ending, UINT logoff); |
342 virtual void OnEnterSizeMove(); | 357 virtual void OnEnterSizeMove(); |
343 virtual LRESULT OnEraseBkgnd(HDC dc); | 358 virtual LRESULT OnEraseBkgnd(HDC dc); |
344 virtual void OnExitMenuLoop(BOOL is_track_popup_menu); | 359 virtual void OnExitMenuLoop(BOOL is_track_popup_menu); |
345 virtual void OnExitSizeMove(); | 360 virtual void OnExitSizeMove(); |
346 virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param); | 361 virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param); |
347 virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info); | 362 virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info); |
348 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar); | 363 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar); |
| 364 virtual LRESULT OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param); |
349 virtual void OnInitMenu(HMENU menu); | 365 virtual void OnInitMenu(HMENU menu); |
350 virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); | 366 virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); |
| 367 virtual void OnInputLangChange(DWORD character_set, HKL input_language_id); |
351 virtual LRESULT OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param); | 368 virtual LRESULT OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param); |
352 virtual LRESULT OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param); | 369 virtual LRESULT OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param); |
353 virtual void OnKillFocus(HWND focused_window); | 370 virtual void OnKillFocus(HWND focused_window); |
354 virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); | 371 virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); |
355 virtual LRESULT OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param); | 372 virtual LRESULT OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param); |
356 virtual LRESULT OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param); | 373 virtual LRESULT OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param); |
357 virtual LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); | 374 virtual LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); |
358 virtual LRESULT OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param); | 375 virtual LRESULT OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param); |
359 virtual void OnMove(const CPoint& point); | 376 virtual void OnMove(const CPoint& point); |
360 virtual void OnMoving(UINT param, LPRECT new_bounds); | 377 virtual void OnMoving(UINT param, LPRECT new_bounds); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 // layered windows only. | 464 // layered windows only. |
448 void RedrawLayeredWindowContents(); | 465 void RedrawLayeredWindowContents(); |
449 | 466 |
450 // Responds to the client area changing size, either at window creation time | 467 // Responds to the client area changing size, either at window creation time |
451 // or subsequently. | 468 // or subsequently. |
452 void ClientAreaSizeChanged(); | 469 void ClientAreaSizeChanged(); |
453 | 470 |
454 // Overridden from NativeWidget. | 471 // Overridden from NativeWidget. |
455 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | 472 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
456 | 473 |
| 474 // Overridden from internal::InputMethodDelegate |
| 475 virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; |
| 476 |
457 // A delegate implementation that handles events received here. | 477 // A delegate implementation that handles events received here. |
458 internal::NativeWidgetDelegate* delegate_; | 478 internal::NativeWidgetDelegate* delegate_; |
459 | 479 |
460 // The following factory is used for calls to close the WidgetWin | 480 // The following factory is used for calls to close the WidgetWin |
461 // instance. | 481 // instance. |
462 ScopedRunnableMethodFactory<WidgetWin> close_widget_factory_; | 482 ScopedRunnableMethodFactory<WidgetWin> close_widget_factory_; |
463 | 483 |
464 // The flags currently being used with TrackMouseEvent to track mouse | 484 // The flags currently being used with TrackMouseEvent to track mouse |
465 // messages. 0 if there is no active tracking. The value of this member is | 485 // messages. 0 if there is no active tracking. The value of this member is |
466 // used when tracking is canceled. | 486 // used when tracking is canceled. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // The current position of the view events vector. When incrementing, | 552 // The current position of the view events vector. When incrementing, |
533 // we always mod this value with the max view events above . | 553 // we always mod this value with the max view events above . |
534 int accessibility_view_events_index_; | 554 int accessibility_view_events_index_; |
535 | 555 |
536 // The last cursor that was active before the current one was selected. Saved | 556 // The last cursor that was active before the current one was selected. Saved |
537 // so that we can restore it. | 557 // so that we can restore it. |
538 gfx::NativeCursor previous_cursor_; | 558 gfx::NativeCursor previous_cursor_; |
539 | 559 |
540 ViewProps props_; | 560 ViewProps props_; |
541 | 561 |
| 562 scoped_ptr<InputMethod> input_method_; |
| 563 |
| 564 // Indicates if the |input_method_| is an InputMethodWin instance. |
| 565 bool is_input_method_win_; |
| 566 |
542 DISALLOW_COPY_AND_ASSIGN(WidgetWin); | 567 DISALLOW_COPY_AND_ASSIGN(WidgetWin); |
543 }; | 568 }; |
544 | 569 |
545 } // namespace views | 570 } // namespace views |
546 | 571 |
547 #endif // VIEWS_WIDGET_WIDGET_WIN_H_ | 572 #endif // VIEWS_WIDGET_WIDGET_WIN_H_ |
OLD | NEW |