OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_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 <atlctrls.h> | 12 #include <atlctrls.h> |
13 #include <atlmisc.h> | 13 #include <atlmisc.h> |
14 #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl. | 14 #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl. |
15 | 15 |
16 #include "app/menus/simple_menu_model.h" | 16 #include "app/menus/simple_menu_model.h" |
17 #include "base/scoped_comptr_win.h" | 17 #include "base/scoped_comptr_win.h" |
18 #include "base/scoped_ptr.h" | 18 #include "base/scoped_ptr.h" |
19 #include "chrome/browser/autocomplete/autocomplete.h" | 19 #include "chrome/browser/autocomplete/autocomplete.h" |
20 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 20 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
21 #include "chrome/browser/toolbar_model.h" | 21 #include "chrome/browser/toolbar_model.h" |
22 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" | 22 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
23 #include "chrome/common/page_transition_types.h" | 23 #include "chrome/common/page_transition_types.h" |
24 #include "gfx/font.h" | 24 #include "gfx/font.h" |
| 25 #include "views/controls/menu/menu_2.h" |
| 26 #include "views/widget/child_window_message_processor.h" |
25 #include "webkit/glue/window_open_disposition.h" | 27 #include "webkit/glue/window_open_disposition.h" |
26 #include "views/controls/menu/menu_2.h" | |
27 | 28 |
28 class Profile; | 29 class Profile; |
29 class TabContents; | 30 class TabContents; |
30 namespace views { | 31 namespace views { |
31 class View; | 32 class View; |
32 } | 33 } |
33 | 34 |
| 35 namespace app { |
| 36 namespace win { |
| 37 class ScopedProp; |
| 38 } |
| 39 } |
| 40 |
34 class AutocompleteEditController; | 41 class AutocompleteEditController; |
35 class AutocompleteEditModel; | 42 class AutocompleteEditModel; |
36 class AutocompleteEditView; | 43 class AutocompleteEditView; |
37 class AutocompletePopupView; | 44 class AutocompletePopupView; |
38 | 45 |
39 // Provides the implementation of an edit control with a drop-down | 46 // Provides the implementation of an edit control with a drop-down |
40 // autocomplete box. The box itself is implemented in autocomplete_popup.cc | 47 // autocomplete box. The box itself is implemented in autocomplete_popup.cc |
41 // This file implements the edit box and management for the popup. | 48 // This file implements the edit box and management for the popup. |
42 class AutocompleteEditViewWin | 49 class AutocompleteEditViewWin |
43 : public CWindowImpl<AutocompleteEditViewWin, | 50 : public CWindowImpl<AutocompleteEditViewWin, |
44 CRichEditCtrl, | 51 CRichEditCtrl, |
45 CWinTraits<WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | | 52 CWinTraits<WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | |
46 ES_NOHIDESEL> >, | 53 ES_NOHIDESEL> >, |
47 public CRichEditCommands<AutocompleteEditViewWin>, | 54 public CRichEditCommands<AutocompleteEditViewWin>, |
48 public menus::SimpleMenuModel::Delegate, | 55 public menus::SimpleMenuModel::Delegate, |
| 56 public views::ChildWindowMessageProcessor, |
49 public AutocompleteEditView { | 57 public AutocompleteEditView { |
50 public: | 58 public: |
51 struct State { | 59 struct State { |
52 State(const CHARRANGE& selection, | 60 State(const CHARRANGE& selection, |
53 const CHARRANGE& saved_selection_for_focus_change) | 61 const CHARRANGE& saved_selection_for_focus_change) |
54 : selection(selection), | 62 : selection(selection), |
55 saved_selection_for_focus_change(saved_selection_for_focus_change) { | 63 saved_selection_for_focus_change(saved_selection_for_focus_change) { |
56 } | 64 } |
57 | 65 |
58 const CHARRANGE selection; | 66 const CHARRANGE selection; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Handler for external events passed in to us. The View that owns us may | 175 // Handler for external events passed in to us. The View that owns us may |
168 // send us events that we should treat as if they were events on us. | 176 // send us events that we should treat as if they were events on us. |
169 void HandleExternalMsg(UINT msg, UINT flags, const CPoint& screen_point); | 177 void HandleExternalMsg(UINT msg, UINT flags, const CPoint& screen_point); |
170 | 178 |
171 // CWindowImpl | 179 // CWindowImpl |
172 BEGIN_MSG_MAP(AutocompleteEdit) | 180 BEGIN_MSG_MAP(AutocompleteEdit) |
173 MSG_WM_CHAR(OnChar) | 181 MSG_WM_CHAR(OnChar) |
174 MSG_WM_CONTEXTMENU(OnContextMenu) | 182 MSG_WM_CONTEXTMENU(OnContextMenu) |
175 MSG_WM_COPY(OnCopy) | 183 MSG_WM_COPY(OnCopy) |
176 MSG_WM_CUT(OnCut) | 184 MSG_WM_CUT(OnCut) |
| 185 MSG_WM_DESTROY(OnDestroy) |
177 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) | 186 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) |
178 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) | 187 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) |
179 MESSAGE_HANDLER_EX(WM_IME_NOTIFY, OnImeNotify) | 188 MESSAGE_HANDLER_EX(WM_IME_NOTIFY, OnImeNotify) |
180 MSG_WM_KEYDOWN(OnKeyDown) | 189 MSG_WM_KEYDOWN(OnKeyDown) |
181 MSG_WM_KEYUP(OnKeyUp) | 190 MSG_WM_KEYUP(OnKeyUp) |
182 MSG_WM_KILLFOCUS(OnKillFocus) | 191 MSG_WM_KILLFOCUS(OnKillFocus) |
183 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) | 192 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) |
184 MSG_WM_LBUTTONDOWN(OnLButtonDown) | 193 MSG_WM_LBUTTONDOWN(OnLButtonDown) |
185 MSG_WM_LBUTTONUP(OnLButtonUp) | 194 MSG_WM_LBUTTONUP(OnLButtonUp) |
186 MSG_WM_MBUTTONDBLCLK(OnMButtonDblClk) | 195 MSG_WM_MBUTTONDBLCLK(OnMButtonDblClk) |
(...skipping 18 matching lines...) Expand all Loading... |
205 | 214 |
206 // menus::SimpleMenuModel::Delegate | 215 // menus::SimpleMenuModel::Delegate |
207 virtual bool IsCommandIdChecked(int command_id) const; | 216 virtual bool IsCommandIdChecked(int command_id) const; |
208 virtual bool IsCommandIdEnabled(int command_id) const; | 217 virtual bool IsCommandIdEnabled(int command_id) const; |
209 virtual bool GetAcceleratorForCommandId(int command_id, | 218 virtual bool GetAcceleratorForCommandId(int command_id, |
210 menus::Accelerator* accelerator); | 219 menus::Accelerator* accelerator); |
211 virtual bool IsLabelForCommandIdDynamic(int command_id) const; | 220 virtual bool IsLabelForCommandIdDynamic(int command_id) const; |
212 virtual std::wstring GetLabelForCommandId(int command_id) const; | 221 virtual std::wstring GetLabelForCommandId(int command_id) const; |
213 virtual void ExecuteCommand(int command_id); | 222 virtual void ExecuteCommand(int command_id); |
214 | 223 |
| 224 // views::ChildWindowMessageProcessor |
| 225 virtual bool ProcessMessage(UINT message, |
| 226 WPARAM w_param, |
| 227 LPARAM l_param, |
| 228 LRESULT* result); |
215 private: | 229 private: |
216 enum MouseButton { | 230 enum MouseButton { |
217 kLeft = 0, | 231 kLeft = 0, |
218 kRight = 1, | 232 kRight = 1, |
219 }; | 233 }; |
220 | 234 |
221 // This object freezes repainting of the edit until the object is destroyed. | 235 // This object freezes repainting of the edit until the object is destroyed. |
222 // Some methods of the CRichEditCtrl draw synchronously to the screen. If we | 236 // Some methods of the CRichEditCtrl draw synchronously to the screen. If we |
223 // don't freeze, the user will see a rapid series of calls to these as | 237 // don't freeze, the user will see a rapid series of calls to these as |
224 // flickers. | 238 // flickers. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 int action); | 274 int action); |
261 | 275 |
262 // Returns true if |edit_text| starting at |current_pos| is "://". | 276 // Returns true if |edit_text| starting at |current_pos| is "://". |
263 static bool SchemeEnd(LPTSTR edit_text, int current_pos, int length); | 277 static bool SchemeEnd(LPTSTR edit_text, int current_pos, int length); |
264 | 278 |
265 // Message handlers | 279 // Message handlers |
266 void OnChar(TCHAR ch, UINT repeat_count, UINT flags); | 280 void OnChar(TCHAR ch, UINT repeat_count, UINT flags); |
267 void OnContextMenu(HWND window, const CPoint& point); | 281 void OnContextMenu(HWND window, const CPoint& point); |
268 void OnCopy(); | 282 void OnCopy(); |
269 void OnCut(); | 283 void OnCut(); |
| 284 void OnDestroy(); |
270 LRESULT OnGetObject(UINT uMsg, WPARAM wparam, LPARAM lparam); | 285 LRESULT OnGetObject(UINT uMsg, WPARAM wparam, LPARAM lparam); |
271 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); | 286 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); |
272 LRESULT OnImeNotify(UINT message, WPARAM wparam, LPARAM lparam); | 287 LRESULT OnImeNotify(UINT message, WPARAM wparam, LPARAM lparam); |
273 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); | 288 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); |
274 void OnKeyUp(TCHAR key, UINT repeat_count, UINT flags); | 289 void OnKeyUp(TCHAR key, UINT repeat_count, UINT flags); |
275 void OnKillFocus(HWND focus_wnd); | 290 void OnKillFocus(HWND focus_wnd); |
276 void OnLButtonDblClk(UINT keys, const CPoint& point); | 291 void OnLButtonDblClk(UINT keys, const CPoint& point); |
277 void OnLButtonDown(UINT keys, const CPoint& point); | 292 void OnLButtonDown(UINT keys, const CPoint& point); |
278 void OnLButtonUp(UINT keys, const CPoint& point); | 293 void OnLButtonUp(UINT keys, const CPoint& point); |
279 void OnMButtonDblClk(UINT keys, const CPoint& point); | 294 void OnMButtonDblClk(UINT keys, const CPoint& point); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 // This interface is useful for accessing the CRichEditCtrl at a low level. | 527 // This interface is useful for accessing the CRichEditCtrl at a low level. |
513 mutable ITextDocument* text_object_model_; | 528 mutable ITextDocument* text_object_model_; |
514 | 529 |
515 // This contains the scheme char start and stop indexes that should be | 530 // This contains the scheme char start and stop indexes that should be |
516 // striken-out when displaying an insecure scheme. | 531 // striken-out when displaying an insecure scheme. |
517 url_parse::Component insecure_scheme_component_; | 532 url_parse::Component insecure_scheme_component_; |
518 | 533 |
519 // Instance of accessibility information and handling. | 534 // Instance of accessibility information and handling. |
520 mutable ScopedComPtr<IAccessible> autocomplete_accessibility_; | 535 mutable ScopedComPtr<IAccessible> autocomplete_accessibility_; |
521 | 536 |
| 537 // ScopedProp returned from registering as a ChildWindowMessageProcessor. |
| 538 scoped_ptr<app::win::ScopedProp> message_handler_prop_; |
| 539 |
522 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewWin); | 540 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewWin); |
523 }; | 541 }; |
524 | 542 |
525 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ | 543 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ |
OLD | NEW |