Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: views/controls/textfield/native_textfield_win.cc

Issue 6675005: Integrate the new input method API for Views into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows build. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/textfield/native_textfield_win.h" 5 #include "views/controls/textfield/native_textfield_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 bool NativeTextfieldWin::HandleKeyReleased(const views::KeyEvent& event) { 359 bool NativeTextfieldWin::HandleKeyReleased(const views::KeyEvent& event) {
360 return false; 360 return false;
361 } 361 }
362 362
363 void NativeTextfieldWin::HandleFocus() { 363 void NativeTextfieldWin::HandleFocus() {
364 } 364 }
365 365
366 void NativeTextfieldWin::HandleBlur() { 366 void NativeTextfieldWin::HandleBlur() {
367 } 367 }
368 368
369 TextInputClient* NativeTextfieldWin::GetTextInputClient() {
370 return NULL;
371 }
372
369 //////////////////////////////////////////////////////////////////////////////// 373 ////////////////////////////////////////////////////////////////////////////////
370 // NativeTextfieldWin, ui::SimpleMenuModel::Delegate implementation: 374 // NativeTextfieldWin, ui::SimpleMenuModel::Delegate implementation:
371 375
372 bool NativeTextfieldWin::IsCommandIdChecked(int command_id) const { 376 bool NativeTextfieldWin::IsCommandIdChecked(int command_id) const {
373 return false; 377 return false;
374 } 378 }
375 379
376 bool NativeTextfieldWin::IsCommandIdEnabled(int command_id) const { 380 bool NativeTextfieldWin::IsCommandIdEnabled(int command_id) const {
377 switch (command_id) { 381 switch (command_id) {
378 case IDS_APP_UNDO: return !textfield_->read_only() && !!CanUndo(); 382 case IDS_APP_UNDO: return !textfield_->read_only() && !!CanUndo();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 599
596 LRESULT NativeTextfieldWin::OnImeEndComposition(UINT message, 600 LRESULT NativeTextfieldWin::OnImeEndComposition(UINT message,
597 WPARAM wparam, 601 WPARAM wparam,
598 LPARAM lparam) { 602 LPARAM lparam) {
599 // Bug 11863: Korean IMEs send a WM_IME_ENDCOMPOSITION message without 603 // Bug 11863: Korean IMEs send a WM_IME_ENDCOMPOSITION message without
600 // sending any WM_IME_COMPOSITION messages when a user deletes all 604 // sending any WM_IME_COMPOSITION messages when a user deletes all
601 // composition characters, i.e. a composition string becomes empty. To handle 605 // composition characters, i.e. a composition string becomes empty. To handle
602 // this case, we need to update the find results when a composition is 606 // this case, we need to update the find results when a composition is
603 // finished or canceled. 607 // finished or canceled.
604 textfield_->SyncText(); 608 textfield_->SyncText();
605 if (textfield_->GetController())
606 textfield_->GetController()->ContentsChanged(textfield_, GetText());
607 return DefWindowProc(message, wparam, lparam); 609 return DefWindowProc(message, wparam, lparam);
608 } 610 }
609 611
610 void NativeTextfieldWin::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) { 612 void NativeTextfieldWin::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) {
611 // NOTE: Annoyingly, ctrl-alt-<key> generates WM_KEYDOWN rather than 613 // NOTE: Annoyingly, ctrl-alt-<key> generates WM_KEYDOWN rather than
612 // WM_SYSKEYDOWN, so we need to check (flags & KF_ALTDOWN) in various places 614 // WM_SYSKEYDOWN, so we need to check (flags & KF_ALTDOWN) in various places
613 // in this function even with a WM_SYSKEYDOWN handler. 615 // in this function even with a WM_SYSKEYDOWN handler.
614 616
615 switch (key) { 617 switch (key) {
616 case VK_RETURN: 618 case VK_RETURN:
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // composed by an IME. We remove the composition string from this search 1011 // composed by an IME. We remove the composition string from this search
1010 // string. 1012 // string.
1011 new_text.erase(ime_composition_start_, ime_composition_length_); 1013 new_text.erase(ime_composition_start_, ime_composition_length_);
1012 ime_composition_start_ = 0; 1014 ime_composition_start_ = 0;
1013 ime_composition_length_ = 0; 1015 ime_composition_length_ = 0;
1014 if (new_text.empty()) 1016 if (new_text.empty())
1015 return; 1017 return;
1016 } 1018 }
1017 textfield_->SyncText(); 1019 textfield_->SyncText();
1018 UpdateAccessibleValue(textfield_->text()); 1020 UpdateAccessibleValue(textfield_->text());
1019 if (textfield_->GetController())
1020 textfield_->GetController()->ContentsChanged(textfield_, new_text);
1021 1021
1022 if (should_redraw_text) { 1022 if (should_redraw_text) {
1023 CHARRANGE original_sel; 1023 CHARRANGE original_sel;
1024 GetSel(original_sel); 1024 GetSel(original_sel);
1025 std::wstring text = GetText(); 1025 std::wstring text = GetText();
1026 ScopedSuspendUndo suspend_undo(GetTextObjectModel()); 1026 ScopedSuspendUndo suspend_undo(GetTextObjectModel());
1027 1027
1028 SelectAll(); 1028 SelectAll();
1029 ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true); 1029 ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true);
1030 SetSel(original_sel); 1030 SetSel(original_sel);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1142 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1143 Textfield* field) { 1143 Textfield* field) {
1144 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { 1144 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) {
1145 return new NativeTextfieldViews(field); 1145 return new NativeTextfieldViews(field);
1146 } else { 1146 } else {
1147 return new NativeTextfieldWin(field); 1147 return new NativeTextfieldWin(field);
1148 } 1148 }
1149 } 1149 }
1150 1150
1151 } // namespace views 1151 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/textfield/native_textfield_win.h ('k') | views/controls/textfield/native_textfield_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698