| 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 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> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 virtual void SaveStateToTab(TabContents* tab); | 89 virtual void SaveStateToTab(TabContents* tab); |
| 90 | 90 |
| 91 virtual void Update(const TabContents* tab_for_state_restoring); | 91 virtual void Update(const TabContents* tab_for_state_restoring); |
| 92 | 92 |
| 93 virtual void OpenURL(const GURL& url, | 93 virtual void OpenURL(const GURL& url, |
| 94 WindowOpenDisposition disposition, | 94 WindowOpenDisposition disposition, |
| 95 PageTransition::Type transition, | 95 PageTransition::Type transition, |
| 96 const GURL& alternate_nav_url, | 96 const GURL& alternate_nav_url, |
| 97 size_t selected_line, | 97 size_t selected_line, |
| 98 const std::wstring& keyword); | 98 const string16& keyword); |
| 99 | 99 |
| 100 virtual std::wstring GetText() const; | 100 virtual string16 GetText() const; |
| 101 | 101 |
| 102 virtual bool IsEditingOrEmpty() const; | 102 virtual bool IsEditingOrEmpty() const; |
| 103 virtual int GetIcon() const; | 103 virtual int GetIcon() const; |
| 104 | 104 |
| 105 virtual void SetUserText(const std::wstring& text); | 105 virtual void SetUserText(const string16& text); |
| 106 virtual void SetUserText(const std::wstring& text, | 106 virtual void SetUserText(const string16& text, |
| 107 const std::wstring& display_text, | 107 const string16& display_text, |
| 108 bool update_popup); | 108 bool update_popup); |
| 109 | 109 |
| 110 virtual void SetWindowTextAndCaretPos(const std::wstring& text, | 110 virtual void SetWindowTextAndCaretPos(const string16& text, |
| 111 size_t caret_pos); | 111 size_t caret_pos); |
| 112 | 112 |
| 113 virtual void SetForcedQuery(); | 113 virtual void SetForcedQuery(); |
| 114 | 114 |
| 115 virtual bool IsSelectAll(); | 115 virtual bool IsSelectAll(); |
| 116 virtual bool DeleteAtEndPressed(); | 116 virtual bool DeleteAtEndPressed(); |
| 117 virtual void GetSelectionBounds(std::wstring::size_type* start, | 117 virtual void GetSelectionBounds(string16::size_type* start, |
| 118 std::wstring::size_type* end); | 118 string16::size_type* end); |
| 119 virtual void SelectAll(bool reversed); | 119 virtual void SelectAll(bool reversed); |
| 120 virtual void RevertAll(); | 120 virtual void RevertAll(); |
| 121 | 121 |
| 122 virtual void UpdatePopup(); | 122 virtual void UpdatePopup(); |
| 123 virtual void ClosePopup(); | 123 virtual void ClosePopup(); |
| 124 | 124 |
| 125 virtual void SetFocus(); | 125 virtual void SetFocus(); |
| 126 | 126 |
| 127 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, | 127 virtual void OnTemporaryTextMaybeChanged(const string16& display_text, |
| 128 bool save_original_selection); | 128 bool save_original_selection); |
| 129 virtual bool OnInlineAutocompleteTextMaybeChanged( | 129 virtual bool OnInlineAutocompleteTextMaybeChanged( |
| 130 const std::wstring& display_text, size_t user_text_length); | 130 const string16& display_text, size_t user_text_length); |
| 131 virtual void OnRevertTemporaryText(); | 131 virtual void OnRevertTemporaryText(); |
| 132 virtual void OnBeforePossibleChange(); | 132 virtual void OnBeforePossibleChange(); |
| 133 virtual bool OnAfterPossibleChange(); | 133 virtual bool OnAfterPossibleChange(); |
| 134 virtual gfx::NativeView GetNativeView() const; | 134 virtual gfx::NativeView GetNativeView() const; |
| 135 virtual CommandUpdater* GetCommandUpdater(); | 135 virtual CommandUpdater* GetCommandUpdater(); |
| 136 virtual void SetInstantSuggestion(const string16& suggestion); | 136 virtual void SetInstantSuggestion(const string16& suggestion); |
| 137 virtual int TextWidth() const; | 137 virtual int TextWidth() const; |
| 138 virtual bool IsImeComposing() const; | 138 virtual bool IsImeComposing() const; |
| 139 | 139 |
| 140 virtual views::View* AddToView(views::View* parent); | 140 virtual views::View* AddToView(views::View* parent); |
| 141 virtual bool CommitInstantSuggestion(const std::wstring& typed_text, | 141 virtual bool CommitInstantSuggestion(const string16& typed_text, |
| 142 const std::wstring& suggested_text); | 142 const string16& suggested_text); |
| 143 | 143 |
| 144 int GetPopupMaxYCoordinate(); | 144 int GetPopupMaxYCoordinate(); |
| 145 | 145 |
| 146 // Exposes custom IAccessible implementation to the overall MSAA hierarchy. | 146 // Exposes custom IAccessible implementation to the overall MSAA hierarchy. |
| 147 IAccessible* GetIAccessible(); | 147 IAccessible* GetIAccessible(); |
| 148 | 148 |
| 149 void SetDropHighlightPosition(int position); | 149 void SetDropHighlightPosition(int position); |
| 150 int drop_highlight_position() const { return drop_highlight_position_; } | 150 int drop_highlight_position() const { return drop_highlight_position_; } |
| 151 | 151 |
| 152 // Returns true if a drag a drop session was initiated by this edit. | 152 // Returns true if a drag a drop session was initiated by this edit. |
| 153 bool in_drag() const { return in_drag_; } | 153 bool in_drag() const { return in_drag_; } |
| 154 | 154 |
| 155 // Moves the selected text to the specified position. | 155 // Moves the selected text to the specified position. |
| 156 void MoveSelectedText(int new_position); | 156 void MoveSelectedText(int new_position); |
| 157 | 157 |
| 158 // Inserts the text at the specified position. | 158 // Inserts the text at the specified position. |
| 159 void InsertText(int position, const std::wstring& text); | 159 void InsertText(int position, const string16& text); |
| 160 | 160 |
| 161 // Invokes CanPasteAndGo with the specified text, and if successful navigates | 161 // Invokes CanPasteAndGo with the specified text, and if successful navigates |
| 162 // to the appropriate URL. The behavior of this is the same as if the user | 162 // to the appropriate URL. The behavior of this is the same as if the user |
| 163 // typed in the specified text and pressed enter. | 163 // typed in the specified text and pressed enter. |
| 164 void PasteAndGo(const std::wstring& text); | 164 void PasteAndGo(const string16& text); |
| 165 | 165 |
| 166 void set_force_hidden(bool force_hidden) { force_hidden_ = force_hidden; } | 166 void set_force_hidden(bool force_hidden) { force_hidden_ = force_hidden; } |
| 167 | 167 |
| 168 // Called before an accelerator is processed to give us a chance to override | 168 // Called before an accelerator is processed to give us a chance to override |
| 169 // it. | 169 // it. |
| 170 bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e); | 170 bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e); |
| 171 | 171 |
| 172 // Handler for external events passed in to us. The View that owns us may | 172 // Handler for external events passed in to us. The View that owns us may |
| 173 // send us events that we should treat as if they were events on us. | 173 // send us events that we should treat as if they were events on us. |
| 174 void HandleExternalMsg(UINT msg, UINT flags, const CPoint& screen_point); | 174 void HandleExternalMsg(UINT msg, UINT flags, const CPoint& screen_point); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging) | 206 MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging) |
| 207 DEFAULT_REFLECTION_HANDLER() // avoids black margin area | 207 DEFAULT_REFLECTION_HANDLER() // avoids black margin area |
| 208 END_MSG_MAP() | 208 END_MSG_MAP() |
| 209 | 209 |
| 210 // ui::SimpleMenuModel::Delegate | 210 // ui::SimpleMenuModel::Delegate |
| 211 virtual bool IsCommandIdChecked(int command_id) const; | 211 virtual bool IsCommandIdChecked(int command_id) const; |
| 212 virtual bool IsCommandIdEnabled(int command_id) const; | 212 virtual bool IsCommandIdEnabled(int command_id) const; |
| 213 virtual bool GetAcceleratorForCommandId(int command_id, | 213 virtual bool GetAcceleratorForCommandId(int command_id, |
| 214 ui::Accelerator* accelerator); | 214 ui::Accelerator* accelerator); |
| 215 virtual bool IsItemForCommandIdDynamic(int command_id) const; | 215 virtual bool IsItemForCommandIdDynamic(int command_id) const; |
| 216 virtual std::wstring GetLabelForCommandId(int command_id) const; | 216 virtual string16 GetLabelForCommandId(int command_id) const; |
| 217 virtual void ExecuteCommand(int command_id); | 217 virtual void ExecuteCommand(int command_id); |
| 218 | 218 |
| 219 private: | 219 private: |
| 220 enum MouseButton { | 220 enum MouseButton { |
| 221 kLeft = 0, | 221 kLeft = 0, |
| 222 kRight = 1, | 222 kRight = 1, |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 // This object freezes repainting of the edit until the object is destroyed. | 225 // This object freezes repainting of the edit until the object is destroyed. |
| 226 // Some methods of the CRichEditCtrl draw synchronously to the screen. If we | 226 // Some methods of the CRichEditCtrl draw synchronously to the screen. If we |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 bool OnKeyDownOnlyWritable(TCHAR key, UINT repeat_count, UINT flags); | 305 bool OnKeyDownOnlyWritable(TCHAR key, UINT repeat_count, UINT flags); |
| 306 bool OnKeyDownAllModes(TCHAR key, UINT repeat_count, UINT flags); | 306 bool OnKeyDownAllModes(TCHAR key, UINT repeat_count, UINT flags); |
| 307 | 307 |
| 308 // Like GetSel(), but returns a range where |cpMin| will be larger than | 308 // Like GetSel(), but returns a range where |cpMin| will be larger than |
| 309 // |cpMax| if the cursor is at the start rather than the end of the selection | 309 // |cpMax| if the cursor is at the start rather than the end of the selection |
| 310 // (in other words, tracks selection direction as well as offsets). | 310 // (in other words, tracks selection direction as well as offsets). |
| 311 // Note the non-Google-style "non-const-ref" argument, which matches GetSel(). | 311 // Note the non-Google-style "non-const-ref" argument, which matches GetSel(). |
| 312 void GetSelection(CHARRANGE& sel) const; | 312 void GetSelection(CHARRANGE& sel) const; |
| 313 | 313 |
| 314 // Returns the currently selected text of the edit control. | 314 // Returns the currently selected text of the edit control. |
| 315 std::wstring GetSelectedText() const; | 315 string16 GetSelectedText() const; |
| 316 | 316 |
| 317 // Like SetSel(), but respects the selection direction implied by |start| and | 317 // Like SetSel(), but respects the selection direction implied by |start| and |
| 318 // |end|: if |end| < |start|, the effective cursor will be placed at the | 318 // |end|: if |end| < |start|, the effective cursor will be placed at the |
| 319 // beginning of the selection. | 319 // beginning of the selection. |
| 320 void SetSelection(LONG start, LONG end); | 320 void SetSelection(LONG start, LONG end); |
| 321 | 321 |
| 322 // Like SetSelection(), but takes a CHARRANGE. | 322 // Like SetSelection(), but takes a CHARRANGE. |
| 323 void SetSelectionRange(const CHARRANGE& sel) { | 323 void SetSelectionRange(const CHARRANGE& sel) { |
| 324 SetSelection(sel.cpMin, sel.cpMax); | 324 SetSelection(sel.cpMin, sel.cpMax); |
| 325 } | 325 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 void DrawDropHighlight(HDC hdc, | 363 void DrawDropHighlight(HDC hdc, |
| 364 const CRect& client_rect, | 364 const CRect& client_rect, |
| 365 const CRect& paint_clip_rect); | 365 const CRect& paint_clip_rect); |
| 366 | 366 |
| 367 // Internally invoked whenever the text changes in some way. | 367 // Internally invoked whenever the text changes in some way. |
| 368 void TextChanged(); | 368 void TextChanged(); |
| 369 | 369 |
| 370 // Returns the current clipboard contents as a string that can be pasted in. | 370 // Returns the current clipboard contents as a string that can be pasted in. |
| 371 // In addition to just getting CF_UNICODETEXT out, this can also extract URLs | 371 // In addition to just getting CF_UNICODETEXT out, this can also extract URLs |
| 372 // from bookmarks on the clipboard. | 372 // from bookmarks on the clipboard. |
| 373 std::wstring GetClipboardText() const; | 373 string16 GetClipboardText() const; |
| 374 | 374 |
| 375 // Determines whether the user can "paste and go", given the specified text. | 375 // Determines whether the user can "paste and go", given the specified text. |
| 376 bool CanPasteAndGo(const std::wstring& text) const; | 376 bool CanPasteAndGo(const string16& text) const; |
| 377 | 377 |
| 378 // Getter for the text_object_model_. Note that the pointer returned here is | 378 // Getter for the text_object_model_. Note that the pointer returned here is |
| 379 // only valid as long as the AutocompleteEdit is still alive. Also, if the | 379 // only valid as long as the AutocompleteEdit is still alive. Also, if the |
| 380 // underlying call fails, this may return NULL. | 380 // underlying call fails, this may return NULL. |
| 381 ITextDocument* GetTextObjectModel() const; | 381 ITextDocument* GetTextObjectModel() const; |
| 382 | 382 |
| 383 // Invoked during a mouse move. As necessary starts a drag and drop session. | 383 // Invoked during a mouse move. As necessary starts a drag and drop session. |
| 384 void StartDragIfNecessary(const CPoint& point); | 384 void StartDragIfNecessary(const CPoint& point); |
| 385 | 385 |
| 386 // Invoked during a mouse down. If the mouse location is over the selection | 386 // Invoked during a mouse down. If the mouse location is over the selection |
| 387 // this sets possible_drag_ to true to indicate a drag should start if the | 387 // this sets possible_drag_ to true to indicate a drag should start if the |
| 388 // user moves the mouse far enough to start a drag. | 388 // user moves the mouse far enough to start a drag. |
| 389 void OnPossibleDrag(const CPoint& point); | 389 void OnPossibleDrag(const CPoint& point); |
| 390 | 390 |
| 391 // Redraws the necessary region for a drop highlight at the specified | 391 // Redraws the necessary region for a drop highlight at the specified |
| 392 // position. This does nothing if position is beyond the bounds of the | 392 // position. This does nothing if position is beyond the bounds of the |
| 393 // text. | 393 // text. |
| 394 void RepaintDropHighlight(int position); | 394 void RepaintDropHighlight(int position); |
| 395 | 395 |
| 396 // Generates the context menu for the edit field. | 396 // Generates the context menu for the edit field. |
| 397 void BuildContextMenu(); | 397 void BuildContextMenu(); |
| 398 | 398 |
| 399 void SelectAllIfNecessary(MouseButton button, const CPoint& point); | 399 void SelectAllIfNecessary(MouseButton button, const CPoint& point); |
| 400 void TrackMousePosition(MouseButton button, const CPoint& point); | 400 void TrackMousePosition(MouseButton button, const CPoint& point); |
| 401 | 401 |
| 402 // Returns the sum of the left and right margins. | 402 // Returns the sum of the left and right margins. |
| 403 int GetHorizontalMargin() const; | 403 int GetHorizontalMargin() const; |
| 404 | 404 |
| 405 // Returns the width in pixels needed to display |text|. | 405 // Returns the width in pixels needed to display |text|. |
| 406 int WidthNeededToDisplay(const std::wstring& text) const; | 406 int WidthNeededToDisplay(const string16& text) const; |
| 407 | 407 |
| 408 // Real implementation of OnAfterPossibleChange() method. | 408 // Real implementation of OnAfterPossibleChange() method. |
| 409 // If |force_text_changed| is true, then the text_changed code will always be | 409 // If |force_text_changed| is true, then the text_changed code will always be |
| 410 // triggerred no matter if the text is actually changed or not. | 410 // triggerred no matter if the text is actually changed or not. |
| 411 bool OnAfterPossibleChangeInternal(bool force_text_changed); | 411 bool OnAfterPossibleChangeInternal(bool force_text_changed); |
| 412 | 412 |
| 413 scoped_ptr<AutocompleteEditModel> model_; | 413 scoped_ptr<AutocompleteEditModel> model_; |
| 414 | 414 |
| 415 scoped_ptr<AutocompletePopupView> popup_view_; | 415 scoped_ptr<AutocompletePopupView> popup_view_; |
| 416 | 416 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 // Used to discard unnecessary WM_MOUSEMOVE events after the first such | 466 // Used to discard unnecessary WM_MOUSEMOVE events after the first such |
| 467 // unnecessary event. See detailed comments in OnMouseMove(). | 467 // unnecessary event. See detailed comments in OnMouseMove(). |
| 468 bool can_discard_mousemove_; | 468 bool can_discard_mousemove_; |
| 469 | 469 |
| 470 // Used to prevent IME message handling in the midst of updating the edit | 470 // Used to prevent IME message handling in the midst of updating the edit |
| 471 // text. See comments where this is used. | 471 // text. See comments where this is used. |
| 472 bool ignore_ime_messages_; | 472 bool ignore_ime_messages_; |
| 473 | 473 |
| 474 // Variables for tracking state before and after a possible change. | 474 // Variables for tracking state before and after a possible change. |
| 475 std::wstring text_before_change_; | 475 string16 text_before_change_; |
| 476 CHARRANGE sel_before_change_; | 476 CHARRANGE sel_before_change_; |
| 477 | 477 |
| 478 // Set at the same time the model's original_* members are set, and valid in | 478 // Set at the same time the model's original_* members are set, and valid in |
| 479 // the same cases. | 479 // the same cases. |
| 480 CHARRANGE original_selection_; | 480 CHARRANGE original_selection_; |
| 481 | 481 |
| 482 // Holds the user's selection across focus changes. cpMin holds -1 when | 482 // Holds the user's selection across focus changes. cpMin holds -1 when |
| 483 // there is no saved selection. | 483 // there is no saved selection. |
| 484 CHARRANGE saved_selection_for_focus_change_; | 484 CHARRANGE saved_selection_for_focus_change_; |
| 485 | 485 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // striken-out when displaying an insecure scheme. | 527 // striken-out when displaying an insecure scheme. |
| 528 url_parse::Component insecure_scheme_component_; | 528 url_parse::Component insecure_scheme_component_; |
| 529 | 529 |
| 530 // Instance of accessibility information and handling. | 530 // Instance of accessibility information and handling. |
| 531 mutable ScopedComPtr<IAccessible> autocomplete_accessibility_; | 531 mutable ScopedComPtr<IAccessible> autocomplete_accessibility_; |
| 532 | 532 |
| 533 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewWin); | 533 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewWin); |
| 534 }; | 534 }; |
| 535 | 535 |
| 536 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ | 536 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_WIN_H_ |
| OLD | NEW |