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

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: Created 9 years, 9 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 // composed by an IME. We remove the composition string from this search 1010 // composed by an IME. We remove the composition string from this search
1009 // string. 1011 // string.
1010 new_text.erase(ime_composition_start_, ime_composition_length_); 1012 new_text.erase(ime_composition_start_, ime_composition_length_);
1011 ime_composition_start_ = 0; 1013 ime_composition_start_ = 0;
1012 ime_composition_length_ = 0; 1014 ime_composition_length_ = 0;
1013 if (new_text.empty()) 1015 if (new_text.empty())
1014 return; 1016 return;
1015 } 1017 }
1016 textfield_->SyncText(); 1018 textfield_->SyncText();
1017 UpdateAccessibleValue(textfield_->text()); 1019 UpdateAccessibleValue(textfield_->text());
1018 if (textfield_->GetController())
1019 textfield_->GetController()->ContentsChanged(textfield_, new_text);
1020 1020
1021 if (should_redraw_text) { 1021 if (should_redraw_text) {
1022 CHARRANGE original_sel; 1022 CHARRANGE original_sel;
1023 GetSel(original_sel); 1023 GetSel(original_sel);
1024 std::wstring text = GetText(); 1024 std::wstring text = GetText();
1025 ScopedSuspendUndo suspend_undo(GetTextObjectModel()); 1025 ScopedSuspendUndo suspend_undo(GetTextObjectModel());
1026 1026
1027 SelectAll(); 1027 SelectAll();
1028 ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true); 1028 ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true);
1029 SetSel(original_sel); 1029 SetSel(original_sel);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1141 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1142 Textfield* field) { 1142 Textfield* field) {
1143 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) { 1143 if (NativeTextfieldViews::IsTextfieldViewsEnabled()) {
1144 return new NativeTextfieldViews(field); 1144 return new NativeTextfieldViews(field);
1145 } else { 1145 } else {
1146 return new NativeTextfieldWin(field); 1146 return new NativeTextfieldWin(field);
1147 } 1147 }
1148 } 1148 }
1149 1149
1150 } // namespace views 1150 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698