| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/textfield/native_textfield_win.h" | 5 #include "ui/views/controls/textfield/native_textfield_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ui/base/win/mouse_wheel_util.h" | 26 #include "ui/base/win/mouse_wheel_util.h" |
| 27 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
| 28 #include "ui/views/controls/menu/menu_item_view.h" | 28 #include "ui/views/controls/menu/menu_item_view.h" |
| 29 #include "ui/views/controls/menu/menu_model_adapter.h" | 29 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 30 #include "ui/views/controls/menu/menu_runner.h" | 30 #include "ui/views/controls/menu/menu_runner.h" |
| 31 #include "ui/views/controls/native/native_view_host.h" | 31 #include "ui/views/controls/native/native_view_host.h" |
| 32 #include "ui/views/controls/textfield/textfield.h" | 32 #include "ui/views/controls/textfield/textfield.h" |
| 33 #include "ui/views/controls/textfield/textfield_controller.h" | 33 #include "ui/views/controls/textfield/textfield_controller.h" |
| 34 #include "ui/views/focus/focus_manager.h" | 34 #include "ui/views/focus/focus_manager.h" |
| 35 #include "ui/views/metrics.h" | 35 #include "ui/views/metrics.h" |
| 36 #include "ui/views/views_delegate.h" | |
| 37 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 38 | 37 |
| 39 namespace views { | 38 namespace views { |
| 40 | 39 |
| 41 /////////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////////// |
| 42 // Helper classes | 41 // Helper classes |
| 43 | 42 |
| 44 NativeTextfieldWin::ScopedFreeze::ScopedFreeze(NativeTextfieldWin* edit, | 43 NativeTextfieldWin::ScopedFreeze::ScopedFreeze(NativeTextfieldWin* edit, |
| 45 ITextDocument* text_object_model) | 44 ITextDocument* text_object_model) |
| 46 : edit_(edit), | 45 : edit_(edit), |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 ignore_result(context_menu_runner_->RunMenuAt(textfield_->GetWidget(), NULL, | 552 ignore_result(context_menu_runner_->RunMenuAt(textfield_->GetWidget(), NULL, |
| 554 gfx::Rect(gfx::Point(p), gfx::Size()), MenuItemView::TOPLEFT, | 553 gfx::Rect(gfx::Point(p), gfx::Size()), MenuItemView::TOPLEFT, |
| 555 MenuRunner::HAS_MNEMONICS)); | 554 MenuRunner::HAS_MNEMONICS)); |
| 556 } | 555 } |
| 557 | 556 |
| 558 void NativeTextfieldWin::OnCopy() { | 557 void NativeTextfieldWin::OnCopy() { |
| 559 if (textfield_->IsObscured()) | 558 if (textfield_->IsObscured()) |
| 560 return; | 559 return; |
| 561 | 560 |
| 562 const string16 text(GetSelectedText()); | 561 const string16 text(GetSelectedText()); |
| 563 if (!text.empty() && ViewsDelegate::views_delegate) { | 562 if (!text.empty()) { |
| 564 ui::ScopedClipboardWriter scw( | 563 ui::ScopedClipboardWriter scw( |
| 565 ViewsDelegate::views_delegate->GetClipboard(), | 564 ui::Clipboard::GetForCurrentThread(), |
| 566 ui::Clipboard::BUFFER_STANDARD); | 565 ui::Clipboard::BUFFER_STANDARD); |
| 567 scw.WriteText(text); | 566 scw.WriteText(text); |
| 568 } | 567 } |
| 569 } | 568 } |
| 570 | 569 |
| 571 LRESULT NativeTextfieldWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { | 570 LRESULT NativeTextfieldWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { |
| 572 if (base::win::IsTsfAwareRequired()) { | 571 if (base::win::IsTsfAwareRequired()) { |
| 573 // Enable TSF support of RichEdit. | 572 // Enable TSF support of RichEdit. |
| 574 SetEditStyle(SES_USECTF, SES_USECTF); | 573 SetEditStyle(SES_USECTF, SES_USECTF); |
| 575 } | 574 } |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 | 967 |
| 969 void NativeTextfieldWin::OnNonLButtonDown(UINT keys, const CPoint& point) { | 968 void NativeTextfieldWin::OnNonLButtonDown(UINT keys, const CPoint& point) { |
| 970 // Interestingly, the edit doesn't seem to cancel triple clicking when the | 969 // Interestingly, the edit doesn't seem to cancel triple clicking when the |
| 971 // x-buttons (which usually means "thumb buttons") are pressed, so we only | 970 // x-buttons (which usually means "thumb buttons") are pressed, so we only |
| 972 // call this for M and R down. | 971 // call this for M and R down. |
| 973 tracking_double_click_ = false; | 972 tracking_double_click_ = false; |
| 974 SetMsgHandled(false); | 973 SetMsgHandled(false); |
| 975 } | 974 } |
| 976 | 975 |
| 977 void NativeTextfieldWin::OnPaste() { | 976 void NativeTextfieldWin::OnPaste() { |
| 978 if (textfield_->read_only() || !ViewsDelegate::views_delegate) | 977 if (textfield_->read_only()) |
| 979 return; | 978 return; |
| 980 | 979 |
| 981 ui::Clipboard* clipboard = ViewsDelegate::views_delegate->GetClipboard(); | 980 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
| 982 if (!clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), | 981 if (!clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), |
| 983 ui::Clipboard::BUFFER_STANDARD)) | 982 ui::Clipboard::BUFFER_STANDARD)) |
| 984 return; | 983 return; |
| 985 | 984 |
| 986 string16 clipboard_str; | 985 string16 clipboard_str; |
| 987 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_str); | 986 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_str); |
| 988 if (!clipboard_str.empty()) { | 987 if (!clipboard_str.empty()) { |
| 989 string16 collapsed(CollapseWhitespace(clipboard_str, false)); | 988 string16 collapsed(CollapseWhitespace(clipboard_str, false)); |
| 990 if (textfield_->style() & Textfield::STYLE_LOWERCASE) | 989 if (textfield_->style() & Textfield::STYLE_LOWERCASE) |
| 991 collapsed = base::i18n::ToLower(collapsed); | 990 collapsed = base::i18n::ToLower(collapsed); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); | 1211 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1213 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); | 1212 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); |
| 1214 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); | 1213 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); |
| 1215 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); | 1214 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); |
| 1216 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); | 1215 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1217 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, | 1216 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, |
| 1218 IDS_APP_SELECT_ALL); | 1217 IDS_APP_SELECT_ALL); |
| 1219 } | 1218 } |
| 1220 | 1219 |
| 1221 } // namespace views | 1220 } // namespace views |
| OLD | NEW |