| OLD | NEW |
| 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 "ui/views/controls/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void Textfield::SetController(TextfieldController* controller) { | 85 void Textfield::SetController(TextfieldController* controller) { |
| 86 controller_ = controller; | 86 controller_ = controller; |
| 87 } | 87 } |
| 88 | 88 |
| 89 TextfieldController* Textfield::GetController() const { | 89 TextfieldController* Textfield::GetController() const { |
| 90 return controller_; | 90 return controller_; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void Textfield::SetReadOnly(bool read_only) { | 93 void Textfield::SetReadOnly(bool read_only) { |
| 94 read_only_ = read_only; | 94 read_only_ = read_only; |
| 95 set_focusable(!read_only); |
| 95 if (native_wrapper_) { | 96 if (native_wrapper_) { |
| 96 native_wrapper_->UpdateReadOnly(); | 97 native_wrapper_->UpdateReadOnly(); |
| 97 native_wrapper_->UpdateTextColor(); | 98 native_wrapper_->UpdateTextColor(); |
| 98 native_wrapper_->UpdateBackgroundColor(); | 99 native_wrapper_->UpdateBackgroundColor(); |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 | 102 |
| 102 bool Textfield::IsPassword() const { | 103 bool Textfield::IsPassword() const { |
| 103 return style_ & STYLE_PASSWORD; | 104 return style_ & STYLE_PASSWORD; |
| 104 } | 105 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 324 } |
| 324 | 325 |
| 325 gfx::Size Textfield::GetPreferredSize() { | 326 gfx::Size Textfield::GetPreferredSize() { |
| 326 gfx::Insets insets; | 327 gfx::Insets insets; |
| 327 if (draw_border_ && native_wrapper_) | 328 if (draw_border_ && native_wrapper_) |
| 328 insets = native_wrapper_->CalculateInsets(); | 329 insets = native_wrapper_->CalculateInsets(); |
| 329 return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) + | 330 return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) + |
| 330 insets.width(), font_.GetHeight() + insets.height()); | 331 insets.width(), font_.GetHeight() + insets.height()); |
| 331 } | 332 } |
| 332 | 333 |
| 333 bool Textfield::IsFocusable() const { | |
| 334 return View::IsFocusable() && !read_only_; | |
| 335 } | |
| 336 | |
| 337 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { | 334 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { |
| 338 SelectAll(); | 335 SelectAll(); |
| 339 } | 336 } |
| 340 | 337 |
| 341 bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { | 338 bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { |
| 342 // TODO(hamaji): Figure out which keyboard combinations we need to add here, | 339 // TODO(hamaji): Figure out which keyboard combinations we need to add here, |
| 343 // similar to LocationBarView::SkipDefaultKeyEventProcessing. | 340 // similar to LocationBarView::SkipDefaultKeyEventProcessing. |
| 344 ui::KeyboardCode key = e.key_code(); | 341 ui::KeyboardCode key = e.key_code(); |
| 345 if (key == ui::VKEY_BACK) | 342 if (key == ui::VKEY_BACK) |
| 346 return true; // We'll handle BackSpace ourselves. | 343 return true; // We'll handle BackSpace ourselves. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 441 } |
| 445 #endif | 442 #endif |
| 446 } | 443 } |
| 447 } | 444 } |
| 448 | 445 |
| 449 std::string Textfield::GetClassName() const { | 446 std::string Textfield::GetClassName() const { |
| 450 return kViewClassName; | 447 return kViewClassName; |
| 451 } | 448 } |
| 452 | 449 |
| 453 } // namespace views | 450 } // namespace views |
| OLD | NEW |