| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlapp.h> | 9 #include <atlapp.h> |
| 10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
| 11 #include <atlctrls.h> | 11 #include <atlctrls.h> |
| 12 #include <atlmisc.h> | 12 #include <atlmisc.h> |
| 13 #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl. | 13 #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl. |
| 14 | 14 |
| 15 #include "app/gfx/font.h" | 15 #include "app/gfx/font.h" |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete.h" | 17 #include "chrome/browser/autocomplete/autocomplete.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 18 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
| 19 #include "chrome/browser/toolbar_model.h" | 19 #include "chrome/browser/toolbar_model.h" |
| 20 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" | 20 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
| 21 #include "chrome/common/page_transition_types.h" | 21 #include "chrome/common/page_transition_types.h" |
| 22 #include "views/controls/menu/menu.h" | 22 #include "views/controls/menu/simple_menu_model.h" |
| 23 #include "webkit/glue/window_open_disposition.h" | 23 #include "webkit/glue/window_open_disposition.h" |
| 24 | 24 |
| 25 class AutocompletePopupModel; | 25 class AutocompletePopupModel; |
| 26 class CommandUpdater; | 26 class CommandUpdater; |
| 27 class Profile; | 27 class Profile; |
| 28 class TabContents; | 28 class TabContents; |
| 29 namespace views { | 29 namespace views { |
| 30 class View; | 30 class View; |
| 31 } | 31 } |
| 32 | 32 |
| 33 class AutocompleteEditController; | 33 class AutocompleteEditController; |
| 34 class AutocompleteEditModel; | 34 class AutocompleteEditModel; |
| 35 class AutocompleteEditView; | 35 class AutocompleteEditView; |
| 36 class AutocompletePopupView; | 36 class AutocompletePopupView; |
| 37 | 37 |
| 38 // Provides the implementation of an edit control with a drop-down | 38 // Provides the implementation of an edit control with a drop-down |
| 39 // autocomplete box. The box itself is implemented in autocomplete_popup.cc | 39 // autocomplete box. The box itself is implemented in autocomplete_popup.cc |
| 40 // This file implements the edit box and management for the popup. | 40 // This file implements the edit box and management for the popup. |
| 41 class AutocompleteEditViewWin | 41 class AutocompleteEditViewWin |
| 42 : public CWindowImpl<AutocompleteEditViewWin, | 42 : public CWindowImpl<AutocompleteEditViewWin, |
| 43 CRichEditCtrl, | 43 CRichEditCtrl, |
| 44 CWinTraits<WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | | 44 CWinTraits<WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | |
| 45 ES_NOHIDESEL> >, | 45 ES_NOHIDESEL> >, |
| 46 public CRichEditCommands<AutocompleteEditViewWin>, | 46 public CRichEditCommands<AutocompleteEditViewWin>, |
| 47 public views::Menu::Delegate, | 47 public views::SimpleMenuModel::Delegate, |
| 48 public AutocompleteEditView { | 48 public AutocompleteEditView { |
| 49 public: | 49 public: |
| 50 struct State { | 50 struct State { |
| 51 State(const CHARRANGE& selection, | 51 State(const CHARRANGE& selection, |
| 52 const CHARRANGE& saved_selection_for_focus_change) | 52 const CHARRANGE& saved_selection_for_focus_change) |
| 53 : selection(selection), | 53 : selection(selection), |
| 54 saved_selection_for_focus_change(saved_selection_for_focus_change) { | 54 saved_selection_for_focus_change(saved_selection_for_focus_change) { |
| 55 } | 55 } |
| 56 | 56 |
| 57 const CHARRANGE selection; | 57 const CHARRANGE selection; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 MSG_WM_RBUTTONDOWN(OnNonLButtonDown) | 172 MSG_WM_RBUTTONDOWN(OnNonLButtonDown) |
| 173 MSG_WM_RBUTTONUP(OnNonLButtonUp) | 173 MSG_WM_RBUTTONUP(OnNonLButtonUp) |
| 174 MSG_WM_SETFOCUS(OnSetFocus) | 174 MSG_WM_SETFOCUS(OnSetFocus) |
| 175 MSG_WM_SYSCHAR(OnSysChar) // WM_SYSxxx == WM_xxx with ALT down | 175 MSG_WM_SYSCHAR(OnSysChar) // WM_SYSxxx == WM_xxx with ALT down |
| 176 MSG_WM_SYSKEYDOWN(OnKeyDown) | 176 MSG_WM_SYSKEYDOWN(OnKeyDown) |
| 177 MSG_WM_SYSKEYUP(OnKeyUp) | 177 MSG_WM_SYSKEYUP(OnKeyUp) |
| 178 MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging) | 178 MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging) |
| 179 DEFAULT_REFLECTION_HANDLER() // avoids black margin area | 179 DEFAULT_REFLECTION_HANDLER() // avoids black margin area |
| 180 END_MSG_MAP() | 180 END_MSG_MAP() |
| 181 | 181 |
| 182 // Menu::Delegate | 182 // SimpleMenuModel::Delegate |
| 183 virtual bool IsCommandEnabled(int id) const; | 183 virtual bool IsCommandIdChecked(int command_id) const; |
| 184 virtual bool GetContextualLabel(int id, std::wstring* out) const; | 184 virtual bool IsCommandIdEnabled(int command_id) const; |
| 185 virtual void ExecuteCommand(int id); | 185 virtual bool GetAcceleratorForCommandId(int command_id, |
| 186 views::Accelerator* accelerator); |
| 187 virtual bool IsLabelForCommandIdDynamic(int command_id) const; |
| 188 virtual std::wstring GetLabelForCommandId(int command_id) const; |
| 189 virtual void ExecuteCommand(int command_id); |
| 186 | 190 |
| 187 private: | 191 private: |
| 188 // This object freezes repainting of the edit until the object is destroyed. | 192 // This object freezes repainting of the edit until the object is destroyed. |
| 189 // Some methods of the CRichEditCtrl draw synchronously to the screen. If we | 193 // Some methods of the CRichEditCtrl draw synchronously to the screen. If we |
| 190 // don't freeze, the user will see a rapid series of calls to these as | 194 // don't freeze, the user will see a rapid series of calls to these as |
| 191 // flickers. | 195 // flickers. |
| 192 // | 196 // |
| 193 // Freezing the control while it is already frozen is permitted; the control | 197 // Freezing the control while it is already frozen is permitted; the control |
| 194 // will unfreeze once both freezes are released (the freezes stack). | 198 // will unfreeze once both freezes are released (the freezes stack). |
| 195 class ScopedFreeze { | 199 class ScopedFreeze { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 354 |
| 351 // Invoked when a mouse button is released. If none of the buttons are still | 355 // Invoked when a mouse button is released. If none of the buttons are still |
| 352 // down, this sets possible_drag_ to false. | 356 // down, this sets possible_drag_ to false. |
| 353 void UpdateDragDone(UINT keys); | 357 void UpdateDragDone(UINT keys); |
| 354 | 358 |
| 355 // Redraws the necessary region for a drop highlight at the specified | 359 // Redraws the necessary region for a drop highlight at the specified |
| 356 // position. This does nothing if position is beyond the bounds of the | 360 // position. This does nothing if position is beyond the bounds of the |
| 357 // text. | 361 // text. |
| 358 void RepaintDropHighlight(int position); | 362 void RepaintDropHighlight(int position); |
| 359 | 363 |
| 364 // Generates the context menu for the edit field. |
| 365 void BuildContextMenu(); |
| 366 |
| 360 scoped_ptr<AutocompleteEditModel> model_; | 367 scoped_ptr<AutocompleteEditModel> model_; |
| 361 | 368 |
| 362 scoped_ptr<AutocompletePopupView> popup_view_; | 369 scoped_ptr<AutocompletePopupView> popup_view_; |
| 363 | 370 |
| 364 AutocompleteEditController* controller_; | 371 AutocompleteEditController* controller_; |
| 365 | 372 |
| 366 // The parent view for the edit, used to align the popup and for | 373 // The parent view for the edit, used to align the popup and for |
| 367 // accessibility. | 374 // accessibility. |
| 368 views::View* parent_view_; | 375 views::View* parent_view_; |
| 369 | 376 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 426 |
| 420 // Set at the same time the model's original_* members are set, and valid in | 427 // Set at the same time the model's original_* members are set, and valid in |
| 421 // the same cases. | 428 // the same cases. |
| 422 CHARRANGE original_selection_; | 429 CHARRANGE original_selection_; |
| 423 | 430 |
| 424 // Holds the user's selection across focus changes. cpMin holds -1 when | 431 // Holds the user's selection across focus changes. cpMin holds -1 when |
| 425 // there is no saved selection. | 432 // there is no saved selection. |
| 426 CHARRANGE saved_selection_for_focus_change_; | 433 CHARRANGE saved_selection_for_focus_change_; |
| 427 | 434 |
| 428 // The context menu for the edit. | 435 // The context menu for the edit. |
| 429 scoped_ptr<views::Menu> context_menu_; | 436 scoped_ptr<views::SimpleMenuModel> context_menu_contents_; |
| 437 scoped_ptr<views::Menu2> context_menu_; |
| 430 | 438 |
| 431 // Font we're using. We keep a reference to make sure the font supplied to | 439 // Font we're using. We keep a reference to make sure the font supplied to |
| 432 // the constructor doesn't go away before we do. | 440 // the constructor doesn't go away before we do. |
| 433 gfx::Font font_; | 441 gfx::Font font_; |
| 434 | 442 |
| 435 // Metrics about the font, which we keep so we don't need to recalculate them | 443 // Metrics about the font, which we keep so we don't need to recalculate them |
| 436 // every time we paint. |font_y_adjustment_| is the number of pixels we need | 444 // every time we paint. |font_y_adjustment_| is the number of pixels we need |
| 437 // to shift the font vertically in order to make its baseline be at our | 445 // to shift the font vertically in order to make its baseline be at our |
| 438 // desired baseline in the edit. | 446 // desired baseline in the edit. |
| 439 int font_ascent_; | 447 int font_ascent_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 467 // striken-out when displaying an insecure scheme. | 475 // striken-out when displaying an insecure scheme. |
| 468 url_parse::Component insecure_scheme_component_; | 476 url_parse::Component insecure_scheme_component_; |
| 469 | 477 |
| 470 // Instance of accessibility information and handling. | 478 // Instance of accessibility information and handling. |
| 471 mutable CComPtr<IAccessible> autocomplete_accessibility_; | 479 mutable CComPtr<IAccessible> autocomplete_accessibility_; |
| 472 | 480 |
| 473 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewWin); | 481 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewWin); |
| 474 }; | 482 }; |
| 475 | 483 |
| 476 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ | 484 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ |
| OLD | NEW |