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/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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return text_input_type_; | 156 return text_input_type_; |
157 } | 157 } |
158 | 158 |
159 void Textfield::SetTextInputType(ui::TextInputType type) { | 159 void Textfield::SetTextInputType(ui::TextInputType type) { |
160 text_input_type_ = type; | 160 text_input_type_ = type; |
161 bool should_be_obscured = type == ui::TEXT_INPUT_TYPE_PASSWORD; | 161 bool should_be_obscured = type == ui::TEXT_INPUT_TYPE_PASSWORD; |
162 if (IsObscured() != should_be_obscured) | 162 if (IsObscured() != should_be_obscured) |
163 SetObscured(should_be_obscured); | 163 SetObscured(should_be_obscured); |
164 } | 164 } |
165 | 165 |
166 void Textfield::SetText(const string16& text) { | 166 void Textfield::SetText(const base::string16& text) { |
167 text_ = text; | 167 text_ = text; |
168 if (native_wrapper_) | 168 if (native_wrapper_) |
169 native_wrapper_->UpdateText(); | 169 native_wrapper_->UpdateText(); |
170 } | 170 } |
171 | 171 |
172 void Textfield::AppendText(const string16& text) { | 172 void Textfield::AppendText(const base::string16& text) { |
173 text_ += text; | 173 text_ += text; |
174 if (native_wrapper_) | 174 if (native_wrapper_) |
175 native_wrapper_->AppendText(text); | 175 native_wrapper_->AppendText(text); |
176 } | 176 } |
177 | 177 |
178 void Textfield::InsertOrReplaceText(const string16& text) { | 178 void Textfield::InsertOrReplaceText(const base::string16& text) { |
179 if (native_wrapper_) { | 179 if (native_wrapper_) { |
180 native_wrapper_->InsertOrReplaceText(text); | 180 native_wrapper_->InsertOrReplaceText(text); |
181 text_ = native_wrapper_->GetText(); | 181 text_ = native_wrapper_->GetText(); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 base::i18n::TextDirection Textfield::GetTextDirection() const { | 185 base::i18n::TextDirection Textfield::GetTextDirection() const { |
186 return native_wrapper_ ? | 186 return native_wrapper_ ? |
187 native_wrapper_->GetTextDirection() : base::i18n::UNKNOWN_DIRECTION; | 187 native_wrapper_->GetTextDirection() : base::i18n::UNKNOWN_DIRECTION; |
188 } | 188 } |
189 | 189 |
190 void Textfield::SelectAll(bool reversed) { | 190 void Textfield::SelectAll(bool reversed) { |
191 if (native_wrapper_) | 191 if (native_wrapper_) |
192 native_wrapper_->SelectAll(reversed); | 192 native_wrapper_->SelectAll(reversed); |
193 } | 193 } |
194 | 194 |
195 string16 Textfield::GetSelectedText() const { | 195 base::string16 Textfield::GetSelectedText() const { |
196 return native_wrapper_ ? native_wrapper_->GetSelectedText() : string16(); | 196 return native_wrapper_ ? native_wrapper_->GetSelectedText() : |
| 197 base::string16(); |
197 } | 198 } |
198 | 199 |
199 void Textfield::ClearSelection() const { | 200 void Textfield::ClearSelection() const { |
200 if (native_wrapper_) | 201 if (native_wrapper_) |
201 native_wrapper_->ClearSelection(); | 202 native_wrapper_->ClearSelection(); |
202 } | 203 } |
203 | 204 |
204 bool Textfield::HasSelection() const { | 205 bool Textfield::HasSelection() const { |
205 return native_wrapper_ && !native_wrapper_->GetSelectedRange().is_empty(); | 206 return native_wrapper_ && !native_wrapper_->GetSelectedRange().is_empty(); |
206 } | 207 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 native_wrapper_->UpdateEnabled(); | 339 native_wrapper_->UpdateEnabled(); |
339 native_wrapper_->UpdateBorder(); | 340 native_wrapper_->UpdateBorder(); |
340 native_wrapper_->UpdateIsObscured(); | 341 native_wrapper_->UpdateIsObscured(); |
341 native_wrapper_->UpdateHorizontalMargins(); | 342 native_wrapper_->UpdateHorizontalMargins(); |
342 native_wrapper_->UpdateVerticalMargins(); | 343 native_wrapper_->UpdateVerticalMargins(); |
343 } | 344 } |
344 } | 345 } |
345 | 346 |
346 void Textfield::SyncText() { | 347 void Textfield::SyncText() { |
347 if (native_wrapper_) { | 348 if (native_wrapper_) { |
348 string16 new_text = native_wrapper_->GetText(); | 349 base::string16 new_text = native_wrapper_->GetText(); |
349 if (new_text != text_) { | 350 if (new_text != text_) { |
350 text_ = new_text; | 351 text_ = new_text; |
351 if (controller_) | 352 if (controller_) |
352 controller_->ContentsChanged(this, text_); | 353 controller_->ContentsChanged(this, text_); |
353 } | 354 } |
354 } | 355 } |
355 } | 356 } |
356 | 357 |
357 bool Textfield::IsIMEComposing() const { | 358 bool Textfield::IsIMEComposing() const { |
358 return native_wrapper_ && native_wrapper_->IsIMEComposing(); | 359 return native_wrapper_ && native_wrapper_->IsIMEComposing(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 void Textfield::ApplyStyle(gfx::TextStyle style, | 394 void Textfield::ApplyStyle(gfx::TextStyle style, |
394 bool value, | 395 bool value, |
395 const gfx::Range& range) { | 396 const gfx::Range& range) { |
396 return native_wrapper_->ApplyStyle(style, value, range); | 397 return native_wrapper_->ApplyStyle(style, value, range); |
397 } | 398 } |
398 | 399 |
399 void Textfield::ClearEditHistory() { | 400 void Textfield::ClearEditHistory() { |
400 native_wrapper_->ClearEditHistory(); | 401 native_wrapper_->ClearEditHistory(); |
401 } | 402 } |
402 | 403 |
403 void Textfield::SetAccessibleName(const string16& name) { | 404 void Textfield::SetAccessibleName(const base::string16& name) { |
404 accessible_name_ = name; | 405 accessible_name_ = name; |
405 } | 406 } |
406 | 407 |
407 void Textfield::ExecuteCommand(int command_id) { | 408 void Textfield::ExecuteCommand(int command_id) { |
408 native_wrapper_->ExecuteTextCommand(command_id); | 409 native_wrapper_->ExecuteTextCommand(command_id); |
409 } | 410 } |
410 | 411 |
411 void Textfield::SetFocusPainter(scoped_ptr<Painter> focus_painter) { | 412 void Textfield::SetFocusPainter(scoped_ptr<Painter> focus_painter) { |
412 focus_painter_ = focus_painter.Pass(); | 413 focus_painter_ = focus_painter.Pass(); |
413 } | 414 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 //////////////////////////////////////////////////////////////////////////////// | 553 //////////////////////////////////////////////////////////////////////////////// |
553 // Textfield, private: | 554 // Textfield, private: |
554 | 555 |
555 gfx::Insets Textfield::GetTextInsets() const { | 556 gfx::Insets Textfield::GetTextInsets() const { |
556 gfx::Insets insets = GetInsets(); | 557 gfx::Insets insets = GetInsets(); |
557 if (draw_border_ && native_wrapper_) | 558 if (draw_border_ && native_wrapper_) |
558 insets += native_wrapper_->CalculateInsets(); | 559 insets += native_wrapper_->CalculateInsets(); |
559 return insets; | 560 return insets; |
560 } | 561 } |
561 | 562 |
562 void Textfield::AccessibilitySetValue(const string16& new_value) { | 563 void Textfield::AccessibilitySetValue(const base::string16& new_value) { |
563 if (!read_only()) { | 564 if (!read_only()) { |
564 SetText(new_value); | 565 SetText(new_value); |
565 ClearSelection(); | 566 ClearSelection(); |
566 } | 567 } |
567 } | 568 } |
568 | 569 |
569 //////////////////////////////////////////////////////////////////////////////// | 570 //////////////////////////////////////////////////////////////////////////////// |
570 // NativeTextfieldWrapper, public: | 571 // NativeTextfieldWrapper, public: |
571 | 572 |
572 // static | 573 // static |
573 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 574 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
574 Textfield* field) { | 575 Textfield* field) { |
575 return new NativeTextfieldViews(field); | 576 return new NativeTextfieldViews(field); |
576 } | 577 } |
577 | 578 |
578 } // namespace views | 579 } // namespace views |
OLD | NEW |