| 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "app/l10n_util_win.h" | 6 #include "app/l10n_util_win.h" |
| 7 #include "app/win_util.h" | 7 #include "app/win_util.h" |
| 8 #include "base/clipboard.h" | 8 #include "base/clipboard.h" |
| 9 #include "base/gfx/native_theme.h" | 9 #include "base/gfx/native_theme.h" |
| 10 #include "base/scoped_clipboard_writer.h" | 10 #include "base/scoped_clipboard_writer.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/win_util.h" | 12 #include "base/win_util.h" |
| 13 #include "grit/app_strings.h" | 13 #include "grit/app_strings.h" |
| 14 #include "skia/ext/skia_utils_win.h" | 14 #include "skia/ext/skia_utils_win.h" |
| 15 #include "views/controls/menu/menu_win.h" | 15 #include "views/controls/menu/menu_win.h" |
| 16 #include "views/controls/native/native_view_host.h" | 16 #include "views/controls/native/native_view_host.h" |
| 17 #include "views/controls/textfield/native_textfield_win.h" | 17 #include "views/controls/textfield/native_textfield_win.h" |
| 18 #include "views/controls/textfield/textfield.h" | 18 #include "views/controls/textfield/textfield.h" |
| 19 #include "views/focus/focus_manager.h" |
| 19 #include "views/focus/focus_util_win.h" | 20 #include "views/focus/focus_util_win.h" |
| 20 #include "views/views_delegate.h" | 21 #include "views/views_delegate.h" |
| 21 #include "views/widget/widget.h" | 22 #include "views/widget/widget.h" |
| 22 | 23 |
| 23 namespace views { | 24 namespace views { |
| 24 | 25 |
| 25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 26 // Helper classes | 27 // Helper classes |
| 27 | 28 |
| 28 NativeTextfieldWin::ScopedFreeze::ScopedFreeze(NativeTextfieldWin* edit, | 29 NativeTextfieldWin::ScopedFreeze::ScopedFreeze(NativeTextfieldWin* edit, |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 std::wstring collapsed(CollapseWhitespace(clipboard_str, false)); | 661 std::wstring collapsed(CollapseWhitespace(clipboard_str, false)); |
| 661 if (textfield_->style() & Textfield::STYLE_LOWERCASE) | 662 if (textfield_->style() & Textfield::STYLE_LOWERCASE) |
| 662 collapsed = l10n_util::ToLower(collapsed); | 663 collapsed = l10n_util::ToLower(collapsed); |
| 663 // Force a Paste operation to trigger OnContentsChanged, even if identical | 664 // Force a Paste operation to trigger OnContentsChanged, even if identical |
| 664 // contents are pasted into the text box. | 665 // contents are pasted into the text box. |
| 665 text_before_change_.clear(); | 666 text_before_change_.clear(); |
| 666 ReplaceSel(collapsed.c_str(), true); | 667 ReplaceSel(collapsed.c_str(), true); |
| 667 } | 668 } |
| 668 } | 669 } |
| 669 | 670 |
| 671 void NativeTextfieldWin::OnSetFocus(HWND hwnd) { |
| 672 SetMsgHandled(FALSE); // We still want the default processing of the message. |
| 673 |
| 674 views::FocusManager* focus_manager = |
| 675 views::FocusManager::GetFocusManager(m_hWnd); |
| 676 if (!focus_manager) { |
| 677 NOTREACHED(); |
| 678 return; |
| 679 } |
| 680 focus_manager->SetFocusedView(textfield_); |
| 681 } |
| 682 |
| 670 void NativeTextfieldWin::OnSysChar(TCHAR ch, UINT repeat_count, UINT flags) { | 683 void NativeTextfieldWin::OnSysChar(TCHAR ch, UINT repeat_count, UINT flags) { |
| 671 // Nearly all alt-<xxx> combos result in beeping rather than doing something | 684 // Nearly all alt-<xxx> combos result in beeping rather than doing something |
| 672 // useful, so we discard most. Exceptions: | 685 // useful, so we discard most. Exceptions: |
| 673 // * ctrl-alt-<xxx>, which is sometimes important, generates WM_CHAR instead | 686 // * ctrl-alt-<xxx>, which is sometimes important, generates WM_CHAR instead |
| 674 // of WM_SYSCHAR, so it doesn't need to be handled here. | 687 // of WM_SYSCHAR, so it doesn't need to be handled here. |
| 675 // * alt-space gets translated by the default WM_SYSCHAR handler to a | 688 // * alt-space gets translated by the default WM_SYSCHAR handler to a |
| 676 // WM_SYSCOMMAND to open the application context menu, so we need to allow | 689 // WM_SYSCOMMAND to open the application context menu, so we need to allow |
| 677 // it through. | 690 // it through. |
| 678 if (ch == VK_SPACE) | 691 if (ch == VK_SPACE) |
| 679 SetMsgHandled(false); | 692 SetMsgHandled(false); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 //////////////////////////////////////////////////////////////////////////////// | 840 //////////////////////////////////////////////////////////////////////////////// |
| 828 // NativeTextfieldWrapper, public: | 841 // NativeTextfieldWrapper, public: |
| 829 | 842 |
| 830 // static | 843 // static |
| 831 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 844 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| 832 Textfield* field) { | 845 Textfield* field) { |
| 833 return new NativeTextfieldWin(field); | 846 return new NativeTextfieldWin(field); |
| 834 } | 847 } |
| 835 | 848 |
| 836 } // namespace views | 849 } // namespace views |
| OLD | NEW |