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

Side by Side Diff: ui/views/controls/textfield/textfield.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/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (native_wrapper_) 152 if (native_wrapper_)
153 native_wrapper_->UpdateText(); 153 native_wrapper_->UpdateText();
154 } 154 }
155 155
156 void Textfield::AppendText(const string16& text) { 156 void Textfield::AppendText(const string16& text) {
157 text_ += text; 157 text_ += text;
158 if (native_wrapper_) 158 if (native_wrapper_)
159 native_wrapper_->AppendText(text); 159 native_wrapper_->AppendText(text);
160 } 160 }
161 161
162 void Textfield::SelectAll() { 162 void Textfield::SelectAll(bool reversed) {
163 if (native_wrapper_) 163 if (native_wrapper_)
164 native_wrapper_->SelectAll(); 164 native_wrapper_->SelectAll(reversed);
165 } 165 }
166 166
167 string16 Textfield::GetSelectedText() const { 167 string16 Textfield::GetSelectedText() const {
168 if (native_wrapper_) 168 if (native_wrapper_)
169 return native_wrapper_->GetSelectedText(); 169 return native_wrapper_->GetSelectedText();
170 return string16(); 170 return string16();
171 } 171 }
172 172
173 void Textfield::ClearSelection() const { 173 void Textfield::ClearSelection() const {
174 if (native_wrapper_) 174 if (native_wrapper_)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // list might be different (in name or in size) from |font_|, so we need to 363 // list might be different (in name or in size) from |font_|, so we need to
364 // use GetFontHeight() to get the height of the first font in the list to 364 // use GetFontHeight() to get the height of the first font in the list to
365 // guide textfield's height. 365 // guide textfield's height.
366 const int font_height = native_wrapper_ ? native_wrapper_->GetFontHeight() : 366 const int font_height = native_wrapper_ ? native_wrapper_->GetFontHeight() :
367 font_.GetHeight(); 367 font_.GetHeight();
368 return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) + 368 return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) +
369 insets.width(), font_height + insets.height()); 369 insets.width(), font_height + insets.height());
370 } 370 }
371 371
372 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { 372 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) {
373 SelectAll(); 373 SelectAll(false);
374 } 374 }
375 375
376 bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { 376 bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
377 // TODO(hamaji): Figure out which keyboard combinations we need to add here, 377 // TODO(hamaji): Figure out which keyboard combinations we need to add here,
378 // similar to LocationBarView::SkipDefaultKeyEventProcessing. 378 // similar to LocationBarView::SkipDefaultKeyEventProcessing.
379 ui::KeyboardCode key = e.key_code(); 379 ui::KeyboardCode key = e.key_code();
380 if (key == ui::VKEY_BACK) 380 if (key == ui::VKEY_BACK)
381 return true; // We'll handle BackSpace ourselves. 381 return true; // We'll handle BackSpace ourselves.
382 382
383 #if defined(USE_AURA) 383 #if defined(USE_AURA)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 485 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
486 Textfield* field) { 486 Textfield* field) {
487 #if defined(OS_WIN) && !defined(USE_AURA) 487 #if defined(OS_WIN) && !defined(USE_AURA)
488 if (!UseNativeTextfieldViews()) 488 if (!UseNativeTextfieldViews())
489 return new NativeTextfieldWin(field); 489 return new NativeTextfieldWin(field);
490 #endif 490 #endif
491 return new NativeTextfieldViews(field); 491 return new NativeTextfieldViews(field);
492 } 492 }
493 493
494 } // namespace views 494 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/controls/textfield/textfield_views_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698