| 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 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // The button's class name. | 45 // The button's class name. |
| 46 static const char kViewClassName[]; | 46 static const char kViewClassName[]; |
| 47 | 47 |
| 48 enum StyleFlags { | 48 enum StyleFlags { |
| 49 STYLE_DEFAULT = 0, | 49 STYLE_DEFAULT = 0, |
| 50 STYLE_OBSCURED = 1 << 0, | 50 STYLE_OBSCURED = 1 << 0, |
| 51 STYLE_LOWERCASE = 1 << 1 | 51 STYLE_LOWERCASE = 1 << 1 |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 Textfield(); | 54 Textfield(); |
| 55 |
| 56 // The initial text input type is set to TEXT_INPUT_TYPE_PASSWORD |
| 57 // if STYLE_OBSCURED is set in |style|. Otherwise it is set to |
| 58 // TEXT_INPUT_TYPE_TEXT. |
| 55 explicit Textfield(StyleFlags style); | 59 explicit Textfield(StyleFlags style); |
| 60 |
| 56 virtual ~Textfield(); | 61 virtual ~Textfield(); |
| 57 | 62 |
| 58 // TextfieldController accessors | 63 // TextfieldController accessors |
| 59 void SetController(TextfieldController* controller); | 64 void SetController(TextfieldController* controller); |
| 60 TextfieldController* GetController() const; | 65 TextfieldController* GetController() const; |
| 61 | 66 |
| 62 // Gets/Sets whether or not the Textfield is read-only. | 67 // Gets/Sets whether or not the Textfield is read-only. |
| 63 bool read_only() const { return read_only_; } | 68 bool read_only() const { return read_only_; } |
| 64 void SetReadOnly(bool read_only); | 69 void SetReadOnly(bool read_only); |
| 65 | 70 |
| 66 // Gets/sets the STYLE_OBSCURED bit, controlling whether characters in this | 71 // Gets/sets the STYLE_OBSCURED bit, controlling whether characters in this |
| 67 // Textfield are displayed as asterisks/bullets. | 72 // Textfield are displayed as asterisks/bullets. This does not affect the |
| 73 // text input type. |
| 68 // TODO(bryeung): Currently SetObscured is only used in | 74 // TODO(bryeung): Currently SetObscured is only used in |
| 69 // chrome/browser/chromeos/options/wifi_config_view.cc, which is being | 75 // chrome/browser/chromeos/options/wifi_config_view.cc, which is being |
| 70 // converted to WebUI. Please remove it when that happens. | 76 // converted to WebUI. Please remove it when that happens. |
| 71 bool IsObscured() const; | 77 bool IsObscured() const; |
| 72 void SetObscured(bool obscured); | 78 void SetObscured(bool obscured); |
| 73 | 79 |
| 74 // Gets/Sets the input type of this textfield. | 80 // Gets/Sets the input type of this textfield. TEXT_INPUT_TYPE_PASSWORD |
| 81 // disables the IME, but does not hide the text (use STYLE_OBSCURED for that). |
| 75 ui::TextInputType GetTextInputType() const; | 82 ui::TextInputType GetTextInputType() const; |
| 76 void SetTextInputType(ui::TextInputType type); | 83 void SetTextInputType(ui::TextInputType type); |
| 77 | 84 |
| 78 // Gets/Sets the text currently displayed in the Textfield. | 85 // Gets/Sets the text currently displayed in the Textfield. |
| 79 const string16& text() const { return text_; } | 86 const string16& text() const { return text_; } |
| 80 | 87 |
| 81 // Sets the text currently displayed in the Textfield. This doesn't | 88 // Sets the text currently displayed in the Textfield. This doesn't |
| 82 // change the cursor position if the current cursor is within the | 89 // change the cursor position if the current cursor is within the |
| 83 // new text's range, or moves the cursor to the end if the cursor is | 90 // new text's range, or moves the cursor to the end if the cursor is |
| 84 // out of the new text's range. | 91 // out of the new text's range. |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 313 |
| 307 // The input type of this text field. | 314 // The input type of this text field. |
| 308 ui::TextInputType text_input_type_; | 315 ui::TextInputType text_input_type_; |
| 309 | 316 |
| 310 DISALLOW_COPY_AND_ASSIGN(Textfield); | 317 DISALLOW_COPY_AND_ASSIGN(Textfield); |
| 311 }; | 318 }; |
| 312 | 319 |
| 313 } // namespace views | 320 } // namespace views |
| 314 | 321 |
| 315 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 322 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| OLD | NEW |