Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: ui/views/win/hwnd_message_handler.h

Issue 10827454: Move more methods from NWW to HWNDMessageHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/win/DEPS ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ 5 #ifndef UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ 6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlapp.h> 9 #include <atlapp.h>
10 #include <atlmisc.h> 10 #include <atlmisc.h>
11 #include <windows.h> 11 #include <windows.h>
12 12
13 #include <set>
14
13 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/compiler_specific.h"
17 #include "ui/views/ime/input_method_delegate.h"
14 #include "ui/views/views_export.h" 18 #include "ui/views/views_export.h"
15 19
16 namespace views { 20 namespace views {
17 21
18 class HWNDMessageHandlerDelegate; 22 class HWNDMessageHandlerDelegate;
23 class InputMethod;
24
25 VIEWS_EXPORT bool IsAeroGlassEnabled();
19 26
20 // An object that handles messages for a HWND that implements the views 27 // An object that handles messages for a HWND that implements the views
21 // "Custom Frame" look. The purpose of this class is to isolate the windows- 28 // "Custom Frame" look. The purpose of this class is to isolate the windows-
22 // specific message handling from the code that wraps it. It is intended to be 29 // specific message handling from the code that wraps it. It is intended to be
23 // used by both a views::NativeWidget and an aura::RootWindowHost 30 // used by both a views::NativeWidget and an aura::RootWindowHost
24 // implementation. 31 // implementation.
25 // TODO(beng): This object should eventually *become* the WindowImpl. 32 // TODO(beng): This object should eventually *become* the WindowImpl.
26 class VIEWS_EXPORT HWNDMessageHandler { 33 class VIEWS_EXPORT HWNDMessageHandler : public internal::InputMethodDelegate {
27 public: 34 public:
28 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate); 35 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate);
29 ~HWNDMessageHandler(); 36 ~HWNDMessageHandler();
30 37
38 bool IsVisible() const;
31 bool IsActive() const; 39 bool IsActive() const;
32 bool IsVisible() const; 40 bool IsMinimized() const;
41 bool IsMaximized() const;
33 42
34 // Tells the HWND its client area has changed. 43 // Tells the HWND its client area has changed.
35 void SendFrameChanged(); 44 void SendFrameChanged();
36 45
46 void SetCapture();
47 void ReleaseCapture();
48 bool HasCapture() const;
49
50 InputMethod* CreateInputMethod();
51
37 // Message Handlers. 52 // Message Handlers.
38 void OnActivate(UINT action, BOOL minimized, HWND window); 53 void OnActivate(UINT action, BOOL minimized, HWND window);
39 // TODO(beng): Once this object becomes the WindowImpl, these methods can 54 // TODO(beng): Once this object becomes the WindowImpl, these methods can
40 // be made private. 55 // be made private.
41 void OnActivateApp(BOOL active, DWORD thread_id); 56 void OnActivateApp(BOOL active, DWORD thread_id);
42 // TODO(beng): return BOOL is temporary until this object becomes a 57 // TODO(beng): return BOOL is temporary until this object becomes a
43 // WindowImpl. 58 // WindowImpl.
44 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate); 59 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate);
45 void OnCancelMode(); 60 void OnCancelMode();
46 void OnCaptureChanged(HWND window); 61 void OnCaptureChanged(HWND window);
(...skipping 11 matching lines...) Expand all
58 void OnHScroll(int scroll_type, short position, HWND scrollbar); 73 void OnHScroll(int scroll_type, short position, HWND scrollbar);
59 void OnGetMinMaxInfo(MINMAXINFO* minmax_info); 74 void OnGetMinMaxInfo(MINMAXINFO* minmax_info);
60 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param); 75 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param);
61 LRESULT OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param); 76 LRESULT OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param);
62 void OnInitMenu(HMENU menu); 77 void OnInitMenu(HMENU menu);
63 void OnInitMenuPopup(); 78 void OnInitMenuPopup();
64 void OnInputLangChange(DWORD character_set, HKL input_language_id); 79 void OnInputLangChange(DWORD character_set, HKL input_language_id);
65 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param); 80 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param);
66 void OnKillFocus(HWND focused_window); 81 void OnKillFocus(HWND focused_window);
67 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); 82 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
83 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
68 void OnMove(const CPoint& point); 84 void OnMove(const CPoint& point);
69 void OnMoving(UINT param, const RECT* new_bounds); 85 void OnMoving(UINT param, const RECT* new_bounds);
70 LRESULT OnNCActivate(BOOL active); 86 LRESULT OnNCActivate(BOOL active);
71 LRESULT OnNCHitTest(const CPoint& point); 87 LRESULT OnNCHitTest(const CPoint& point);
72 LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param); 88 LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param);
73 LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param); 89 LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param);
74 LRESULT OnNotify(int w_param, NMHDR* l_param); 90 LRESULT OnNotify(int w_param, NMHDR* l_param);
75 LRESULT OnPowerBroadcast(DWORD power_event, DWORD data); 91 LRESULT OnPowerBroadcast(DWORD power_event, DWORD data);
76 LRESULT OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param); 92 LRESULT OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param);
77 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); 93 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
78 void OnSetFocus(HWND last_focused_window); 94 void OnSetFocus(HWND last_focused_window);
79 LRESULT OnSetIcon(UINT size_type, HICON new_icon); 95 LRESULT OnSetIcon(UINT size_type, HICON new_icon);
80 LRESULT OnSetText(const wchar_t* text); 96 LRESULT OnSetText(const wchar_t* text);
81 void OnSettingChange(UINT flags, const wchar_t* section); 97 void OnSettingChange(UINT flags, const wchar_t* section);
82 void OnSize(UINT param, const CSize& size); 98 void OnSize(UINT param, const CSize& size);
83 void OnThemeChanged(); 99 void OnThemeChanged();
100 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param);
84 void OnVScroll(int scroll_type, short position, HWND scrollbar); 101 void OnVScroll(int scroll_type, short position, HWND scrollbar);
102 void OnWindowPosChanged(WINDOWPOS* window_pos);
85 103
86 // TODO(beng): Can be removed once this object becomes the WindowImpl. 104 // TODO(beng): Can be removed once this object becomes the WindowImpl.
87 bool remove_standard_frame() const { return remove_standard_frame_; } 105 bool remove_standard_frame() const { return remove_standard_frame_; }
88 void set_remove_standard_frame(bool remove_standard_frame) { 106 void set_remove_standard_frame(bool remove_standard_frame) {
89 remove_standard_frame_ = remove_standard_frame; 107 remove_standard_frame_ = remove_standard_frame;
90 } 108 }
91 109
92 // Resets the window region for the current widget bounds if necessary. 110 // Resets the window region for the current widget bounds if necessary.
93 // If |force| is true, the window region is reset to NULL even for native 111 // If |force| is true, the window region is reset to NULL even for native
94 // frame windows. 112 // frame windows.
95 void ResetWindowRegion(bool force); 113 void ResetWindowRegion(bool force);
96 114
97 private: 115 private:
116 typedef std::set<DWORD> TouchIDs;
117
118 // TODO(beng): remove once this is the WindowImpl.
119 friend class NativeWidgetWin;
120
121 // Overridden from internal::InputMethodDelegate
122 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
123
124 // Start tracking all mouse events so that this window gets sent mouse leave
125 // messages too.
126 void TrackMouseEvents(DWORD mouse_tracking_flags);
127
128 // Responds to the client area changing size, either at window creation time
129 // or subsequently.
130 void ClientAreaSizeChanged();
131
132 // Calls DefWindowProc, safely wrapping the call in a ScopedRedrawLock to
133 // prevent frame flicker. DefWindowProc handling can otherwise render the
134 // classic-look window title bar directly.
135 LRESULT DefWindowProcWithRedrawLock(UINT message,
136 WPARAM w_param,
137 LPARAM l_param);
138
139 // Lock or unlock the window from being able to redraw itself in response to
140 // updates to its invalid region.
141 class ScopedRedrawLock;
142 void LockUpdates(bool force);
143 void UnlockUpdates(bool force);
144
98 // TODO(beng): This won't be a style violation once this object becomes the 145 // TODO(beng): This won't be a style violation once this object becomes the
99 // WindowImpl. 146 // WindowImpl.
100 HWND hwnd(); 147 HWND hwnd();
101 HWND hwnd() const; 148 HWND hwnd() const;
102 149
103 // TODO(beng): Remove once this class becomes the WindowImpl. 150 // TODO(beng): Remove once this class becomes the WindowImpl.
104 LRESULT DefWindowProcWithRedrawLock(UINT message,
105 WPARAM w_param,
106 LPARAM l_param);
107
108 // TODO(beng): Remove once this class becomes the WindowImpl.
109 void SetMsgHandled(BOOL handled); 151 void SetMsgHandled(BOOL handled);
110 152
111 HWNDMessageHandlerDelegate* delegate_; 153 HWNDMessageHandlerDelegate* delegate_;
112 154
113 bool remove_standard_frame_; 155 bool remove_standard_frame_;
114 156
157 // The flags currently being used with TrackMouseEvent to track mouse
158 // messages. 0 if there is no active tracking. The value of this member is
159 // used when tracking is canceled.
160 DWORD active_mouse_tracking_flags_;
161
162 // Set to true when the user presses the right mouse button on the caption
163 // area. We need this so we can correctly show the context menu on mouse-up.
164 bool is_right_mouse_pressed_on_caption_;
165
166 // The set of touch devices currently down.
167 TouchIDs touch_ids_;
168
169 // Represents the number of ScopedRedrawLocks active against this widget.
170 // If this is greater than zero, the widget should be locked against updates.
171 int lock_updates_count_;
172
173 // This flag can be initialized and checked after certain operations (such as
174 // DefWindowProc) to avoid stack-controlled functions (such as unlocking the
175 // Window with a ScopedRedrawLock) after destruction.
176 bool* destroyed_;
177
115 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); 178 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
116 }; 179 };
117 180
118 } // namespace views 181 } // namespace views
119 182
120 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ 183 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « ui/views/win/DEPS ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698