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

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

Issue 10693160: Add and specify Views::Textfield::SelectAll |reversed| flag, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove redundant comments. Created 8 years, 5 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) 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 string16 NativeTextfieldWin::GetSelectedText() const { 213 string16 NativeTextfieldWin::GetSelectedText() const {
214 CHARRANGE sel; 214 CHARRANGE sel;
215 GetSel(sel); 215 GetSel(sel);
216 string16 str; 216 string16 str;
217 if (sel.cpMin != sel.cpMax) 217 if (sel.cpMin != sel.cpMax)
218 GetSelText(WriteInto(&str, sel.cpMax - sel.cpMin + 1)); 218 GetSelText(WriteInto(&str, sel.cpMax - sel.cpMin + 1));
219 return str; 219 return str;
220 } 220 }
221 221
222 void NativeTextfieldWin::SelectAll() { 222 void NativeTextfieldWin::SelectAll(bool reversed) {
223 // Select from the end to the front so that the first part of the text is 223 if (reversed)
224 // always visible. 224 SetSel(GetTextLength(), 0);
225 SetSel(GetTextLength(), 0); 225 else
226 SetSel(0, GetTextLength());
226 } 227 }
227 228
228 void NativeTextfieldWin::ClearSelection() { 229 void NativeTextfieldWin::ClearSelection() {
229 SetSel(GetTextLength(), GetTextLength()); 230 SetSel(GetTextLength(), GetTextLength());
230 } 231 }
231 232
232 void NativeTextfieldWin::UpdateBorder() { 233 void NativeTextfieldWin::UpdateBorder() {
233 SetWindowPos(NULL, 0, 0, 0, 0, 234 SetWindowPos(NULL, 0, 0, 0, 0,
234 SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | 235 SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE |
235 SWP_NOOWNERZORDER | SWP_NOSIZE); 236 SWP_NOOWNERZORDER | SWP_NOSIZE);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 *accelerator = ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN); 443 *accelerator = ui::Accelerator(ui::VKEY_V, ui::EF_CONTROL_DOWN);
443 return true; 444 return true;
444 } 445 }
445 return container_view_->GetWidget()->GetAccelerator(command_id, accelerator); 446 return container_view_->GetWidget()->GetAccelerator(command_id, accelerator);
446 } 447 }
447 448
448 void NativeTextfieldWin::ExecuteCommand(int command_id) { 449 void NativeTextfieldWin::ExecuteCommand(int command_id) {
449 ScopedFreeze freeze(this, GetTextObjectModel()); 450 ScopedFreeze freeze(this, GetTextObjectModel());
450 OnBeforePossibleChange(); 451 OnBeforePossibleChange();
451 switch (command_id) { 452 switch (command_id) {
452 case IDS_APP_UNDO: Undo(); break; 453 case IDS_APP_UNDO: Undo(); break;
453 case IDS_APP_CUT: Cut(); break; 454 case IDS_APP_CUT: Cut(); break;
454 case IDS_APP_COPY: Copy(); break; 455 case IDS_APP_COPY: Copy(); break;
455 case IDS_APP_PASTE: Paste(); break; 456 case IDS_APP_PASTE: Paste(); break;
456 case IDS_APP_SELECT_ALL: SelectAll(); break; 457 case IDS_APP_SELECT_ALL: SelectAll(false); break;
457 default: NOTREACHED(); break; 458 default: NOTREACHED(); break;
458 } 459 }
459 OnAfterPossibleChange(true); 460 OnAfterPossibleChange(true);
460 } 461 }
461 462
462 void NativeTextfieldWin::InitializeAccessibilityInfo() { 463 void NativeTextfieldWin::InitializeAccessibilityInfo() {
463 // Set the accessible state. 464 // Set the accessible state.
464 accessibility_state_ = 0; 465 accessibility_state_ = 0;
465 466
466 base::win::ScopedComPtr<IAccPropServices> pAccPropServices; 467 base::win::ScopedComPtr<IAccPropServices> pAccPropServices;
467 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, 468 HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER,
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 } 1089 }
1089 textfield_->SyncText(); 1090 textfield_->SyncText();
1090 UpdateAccessibleValue(textfield_->text()); 1091 UpdateAccessibleValue(textfield_->text());
1091 1092
1092 if (should_redraw_text) { 1093 if (should_redraw_text) {
1093 CHARRANGE original_sel; 1094 CHARRANGE original_sel;
1094 GetSel(original_sel); 1095 GetSel(original_sel);
1095 string16 text(GetText()); 1096 string16 text(GetText());
1096 ScopedSuspendUndo suspend_undo(GetTextObjectModel()); 1097 ScopedSuspendUndo suspend_undo(GetTextObjectModel());
1097 1098
1098 SelectAll(); 1099 SelectAll(true);
1099 ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true); 1100 ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true);
1100 SetSel(original_sel); 1101 SetSel(original_sel);
1101 } 1102 }
1102 } 1103 }
1103 } 1104 }
1104 1105
1105 LONG NativeTextfieldWin::ClipXCoordToVisibleText(LONG x, 1106 LONG NativeTextfieldWin::ClipXCoordToVisibleText(LONG x,
1106 bool is_triple_click) const { 1107 bool is_triple_click) const {
1107 // Clip the X coordinate to the left edge of the text. Careful: 1108 // Clip the X coordinate to the left edge of the text. Careful:
1108 // PosFromChar(0) may return a negative X coordinate if the beginning of the 1109 // PosFromChar(0) may return a negative X coordinate if the beginning of the
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 context_menu_contents_->AddSeparator(); 1199 context_menu_contents_->AddSeparator();
1199 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); 1200 context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT);
1200 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); 1201 context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
1201 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); 1202 context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE);
1202 context_menu_contents_->AddSeparator(); 1203 context_menu_contents_->AddSeparator();
1203 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, 1204 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL,
1204 IDS_APP_SELECT_ALL); 1205 IDS_APP_SELECT_ALL);
1205 } 1206 }
1206 1207
1207 } // namespace views 1208 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_win.h ('k') | ui/views/controls/textfield/native_textfield_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698