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 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <locale> | 8 #include <locale> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 bool AutocompleteEditViewWin::IsEditingOrEmpty() const { | 622 bool AutocompleteEditViewWin::IsEditingOrEmpty() const { |
623 return model_->user_input_in_progress() || (GetTextLength() == 0); | 623 return model_->user_input_in_progress() || (GetTextLength() == 0); |
624 } | 624 } |
625 | 625 |
626 int AutocompleteEditViewWin::GetIcon() const { | 626 int AutocompleteEditViewWin::GetIcon() const { |
627 return IsEditingOrEmpty() ? | 627 return IsEditingOrEmpty() ? |
628 AutocompleteMatch::TypeToIcon(model_->CurrentTextType()) : | 628 AutocompleteMatch::TypeToIcon(model_->CurrentTextType()) : |
629 toolbar_model_->GetIcon(); | 629 toolbar_model_->GetIcon(); |
630 } | 630 } |
631 | 631 |
| 632 void AutocompleteEditViewWin::SetUserText(const std::wstring& text) { |
| 633 SetUserText(text, text, true); |
| 634 } |
| 635 |
632 void AutocompleteEditViewWin::SetUserText(const std::wstring& text, | 636 void AutocompleteEditViewWin::SetUserText(const std::wstring& text, |
633 const std::wstring& display_text, | 637 const std::wstring& display_text, |
634 bool update_popup) { | 638 bool update_popup) { |
635 ScopedFreeze freeze(this, GetTextObjectModel()); | 639 ScopedFreeze freeze(this, GetTextObjectModel()); |
636 model_->SetUserText(text); | 640 model_->SetUserText(text); |
637 saved_selection_for_focus_change_.cpMin = -1; | 641 saved_selection_for_focus_change_.cpMin = -1; |
638 SetWindowTextAndCaretPos(display_text, display_text.length()); | 642 SetWindowTextAndCaretPos(display_text, display_text.length()); |
639 if (update_popup) | 643 if (update_popup) |
640 UpdatePopup(); | 644 UpdatePopup(); |
641 TextChanged(); | 645 TextChanged(); |
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2541 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2538 } | 2542 } |
2539 | 2543 |
2540 int AutocompleteEditViewWin::WidthNeededToDisplay(const std::wstring& text) { | 2544 int AutocompleteEditViewWin::WidthNeededToDisplay(const std::wstring& text) { |
2541 // Use font_.GetStringWidth() instead of | 2545 // Use font_.GetStringWidth() instead of |
2542 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2546 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2543 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2547 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
2544 // PosFromChar(i) might return 0 when i is greater than 1. | 2548 // PosFromChar(i) might return 0 when i is greater than 1. |
2545 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2549 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2546 } | 2550 } |
OLD | NEW |