| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/controls/text_field.h" | 5 #include "chrome/views/controls/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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 // it through. | 798 // it through. |
| 799 if (ch == VK_SPACE) | 799 if (ch == VK_SPACE) |
| 800 SetMsgHandled(false); | 800 SetMsgHandled(false); |
| 801 } | 801 } |
| 802 | 802 |
| 803 void TextField::Edit::HandleKeystroke(UINT message, | 803 void TextField::Edit::HandleKeystroke(UINT message, |
| 804 TCHAR key, | 804 TCHAR key, |
| 805 UINT repeat_count, | 805 UINT repeat_count, |
| 806 UINT flags) { | 806 UINT flags) { |
| 807 ScopedFreeze freeze(this, GetTextObjectModel()); | 807 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 808 OnBeforePossibleChange(); | |
| 809 DefWindowProc(message, key, MAKELPARAM(repeat_count, flags)); | |
| 810 OnAfterPossibleChange(); | |
| 811 | 808 |
| 812 TextField::Controller* controller = parent_->GetController(); | 809 TextField::Controller* controller = parent_->GetController(); |
| 813 if (controller) | 810 bool handled = false; |
| 814 controller->HandleKeystroke(parent_, message, key, repeat_count, flags); | 811 if (controller) { |
| 812 handled = |
| 813 controller->HandleKeystroke(parent_, message, key, repeat_count, flags); |
| 814 } |
| 815 |
| 816 if (!handled) { |
| 817 OnBeforePossibleChange(); |
| 818 DefWindowProc(message, key, MAKELPARAM(repeat_count, flags)); |
| 819 OnAfterPossibleChange(); |
| 820 } |
| 815 } | 821 } |
| 816 | 822 |
| 817 void TextField::Edit::OnBeforePossibleChange() { | 823 void TextField::Edit::OnBeforePossibleChange() { |
| 818 // Record our state. | 824 // Record our state. |
| 819 text_before_change_ = GetText(); | 825 text_before_change_ = GetText(); |
| 820 } | 826 } |
| 821 | 827 |
| 822 void TextField::Edit::OnAfterPossibleChange() { | 828 void TextField::Edit::OnAfterPossibleChange() { |
| 823 // Prevent the user from selecting the "phantom newline" at the end of the | 829 // Prevent the user from selecting the "phantom newline" at the end of the |
| 824 // edit. If they try, we just silently move the end of the selection back to | 830 // edit. If they try, we just silently move the end of the selection back to |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 | 1135 |
| 1130 COLORREF bg_color; | 1136 COLORREF bg_color; |
| 1131 if (!use_default_background_color_) | 1137 if (!use_default_background_color_) |
| 1132 bg_color = skia::SkColorToCOLORREF(background_color_); | 1138 bg_color = skia::SkColorToCOLORREF(background_color_); |
| 1133 else | 1139 else |
| 1134 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); | 1140 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); |
| 1135 edit_->SetBackgroundColor(bg_color); | 1141 edit_->SetBackgroundColor(bg_color); |
| 1136 } | 1142 } |
| 1137 | 1143 |
| 1138 } // namespace views | 1144 } // namespace views |
| OLD | NEW |