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 #include "chrome/views/text_field.h" | 5 #include "chrome/views/text_field.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlapp.h> | 8 #include <atlapp.h> |
9 #include <atlcrack.h> | 9 #include <atlcrack.h> |
10 #include <atlctrls.h> | 10 #include <atlctrls.h> |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 GetLocalBounds(&lb, true); | 843 GetLocalBounds(&lb, true); |
844 native_view_->SetBounds(0, 0, lb.Width(), lb.Height()); | 844 native_view_->SetBounds(0, 0, lb.Width(), lb.Height()); |
845 native_view_->UpdateHWNDBounds(); | 845 native_view_->UpdateHWNDBounds(); |
846 } | 846 } |
847 } | 847 } |
848 | 848 |
849 void TextField::DidChangeBounds(const CRect& previous, const CRect& current) { | 849 void TextField::DidChangeBounds(const CRect& previous, const CRect& current) { |
850 Layout(); | 850 Layout(); |
851 } | 851 } |
852 | 852 |
853 void TextField::GetPreferredSize(CSize *out) { | 853 gfx::Size TextField::GetPreferredSize() { |
854 gfx::Insets insets; | 854 gfx::Insets insets; |
855 CalculateInsets(&insets); | 855 CalculateInsets(&insets); |
856 out->cx = default_width_in_chars_ * font_.ave_char_width() + insets.width(); | 856 return gfx::Size(default_width_in_chars_ * font_.ave_char_width() + |
857 out->cy = num_lines_ * font_.height() + insets.height(); | 857 insets.width(), |
| 858 num_lines_ * font_.height() + insets.height()); |
858 } | 859 } |
859 | 860 |
860 std::wstring TextField::GetText() const { | 861 std::wstring TextField::GetText() const { |
861 return text_; | 862 return text_; |
862 } | 863 } |
863 | 864 |
864 void TextField::SetText(const std::wstring& text) { | 865 void TextField::SetText(const std::wstring& text) { |
865 text_ = text; | 866 text_ = text; |
866 if (edit_) | 867 if (edit_) |
867 edit_->SetText(text); | 868 edit_->SetText(text); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 // entering special characters. | 997 // entering special characters. |
997 bool TextField::ShouldLookupAccelerators(const KeyEvent& e) { | 998 bool TextField::ShouldLookupAccelerators(const KeyEvent& e) { |
998 if (!e.IsAltDown()) | 999 if (!e.IsAltDown()) |
999 return true; | 1000 return true; |
1000 | 1001 |
1001 return !win_util::IsNumPadDigit(e.GetCharacter(), e.IsExtendedKey()); | 1002 return !win_util::IsNumPadDigit(e.GetCharacter(), e.IsExtendedKey()); |
1002 } | 1003 } |
1003 | 1004 |
1004 } // namespace ChromeViews | 1005 } // namespace ChromeViews |
1005 | 1006 |
OLD | NEW |