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

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

Issue 7027014: Remove unused multiline attribute in textfield (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing unused multiline attribute in Textfield Created 9 years, 6 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) 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 "views/controls/textfield/textfield.h" 5 #include "views/controls/textfield/textfield.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #endif 9 #endif
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 : native_wrapper_(NULL), 44 : native_wrapper_(NULL),
45 controller_(NULL), 45 controller_(NULL),
46 style_(STYLE_DEFAULT), 46 style_(STYLE_DEFAULT),
47 read_only_(false), 47 read_only_(false),
48 default_width_in_chars_(0), 48 default_width_in_chars_(0),
49 draw_border_(true), 49 draw_border_(true),
50 text_color_(SK_ColorBLACK), 50 text_color_(SK_ColorBLACK),
51 use_default_text_color_(true), 51 use_default_text_color_(true),
52 background_color_(SK_ColorWHITE), 52 background_color_(SK_ColorWHITE),
53 use_default_background_color_(true), 53 use_default_background_color_(true),
54 num_lines_(1),
55 initialized_(false), 54 initialized_(false),
56 horizontal_margins_were_set_(false), 55 horizontal_margins_were_set_(false),
57 vertical_margins_were_set_(false) { 56 vertical_margins_were_set_(false) {
58 SetFocusable(true); 57 SetFocusable(true);
59 } 58 }
60 59
61 Textfield::Textfield(StyleFlags style) 60 Textfield::Textfield(StyleFlags style)
62 : native_wrapper_(NULL), 61 : native_wrapper_(NULL),
63 controller_(NULL), 62 controller_(NULL),
64 style_(style), 63 style_(style),
65 read_only_(false), 64 read_only_(false),
66 default_width_in_chars_(0), 65 default_width_in_chars_(0),
67 draw_border_(true), 66 draw_border_(true),
68 text_color_(SK_ColorBLACK), 67 text_color_(SK_ColorBLACK),
69 use_default_text_color_(true), 68 use_default_text_color_(true),
70 background_color_(SK_ColorWHITE), 69 background_color_(SK_ColorWHITE),
71 use_default_background_color_(true), 70 use_default_background_color_(true),
72 num_lines_(1),
73 initialized_(false), 71 initialized_(false),
74 horizontal_margins_were_set_(false), 72 horizontal_margins_were_set_(false),
75 vertical_margins_were_set_(false) { 73 vertical_margins_were_set_(false) {
76 SetFocusable(true); 74 SetFocusable(true);
77 } 75 }
78 76
79 Textfield::~Textfield() { 77 Textfield::~Textfield() {
80 } 78 }
81 79
82 void Textfield::SetController(TextfieldController* controller) { 80 void Textfield::SetController(TextfieldController* controller) {
(...skipping 19 matching lines...) Expand all
102 100
103 void Textfield::SetPassword(bool password) { 101 void Textfield::SetPassword(bool password) {
104 if (password) 102 if (password)
105 style_ = static_cast<StyleFlags>(style_ | STYLE_PASSWORD); 103 style_ = static_cast<StyleFlags>(style_ | STYLE_PASSWORD);
106 else 104 else
107 style_ = static_cast<StyleFlags>(style_ & ~STYLE_PASSWORD); 105 style_ = static_cast<StyleFlags>(style_ & ~STYLE_PASSWORD);
108 if (native_wrapper_) 106 if (native_wrapper_)
109 native_wrapper_->UpdateIsPassword(); 107 native_wrapper_->UpdateIsPassword();
110 } 108 }
111 109
112 bool Textfield::IsMultiLine() const {
113 return !!(style_ & STYLE_MULTILINE);
114 }
115
116 void Textfield::SetText(const string16& text) { 110 void Textfield::SetText(const string16& text) {
117 text_ = text; 111 text_ = text;
118 if (native_wrapper_) 112 if (native_wrapper_)
119 native_wrapper_->UpdateText(); 113 native_wrapper_->UpdateText();
120 } 114 }
121 115
122 void Textfield::AppendText(const string16& text) { 116 void Textfield::AppendText(const string16& text) {
123 text_ += text; 117 text_ += text;
124 if (native_wrapper_) 118 if (native_wrapper_)
125 native_wrapper_->AppendText(text); 119 native_wrapper_->AppendText(text);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 184 }
191 185
192 void Textfield::SetVerticalMargins(int top, int bottom) { 186 void Textfield::SetVerticalMargins(int top, int bottom) {
193 margins_.Set(top, margins_.left(), bottom, margins_.right()); 187 margins_.Set(top, margins_.left(), bottom, margins_.right());
194 vertical_margins_were_set_ = true; 188 vertical_margins_were_set_ = true;
195 if (native_wrapper_) 189 if (native_wrapper_)
196 native_wrapper_->UpdateVerticalMargins(); 190 native_wrapper_->UpdateVerticalMargins();
197 PreferredSizeChanged(); 191 PreferredSizeChanged();
198 } 192 }
199 193
200 void Textfield::SetHeightInLines(int num_lines) {
201 DCHECK(IsMultiLine());
202 num_lines_ = num_lines;
203 PreferredSizeChanged();
204 }
205
206 void Textfield::RemoveBorder() { 194 void Textfield::RemoveBorder() {
207 if (!draw_border_) 195 if (!draw_border_)
208 return; 196 return;
209 197
210 draw_border_ = false; 198 draw_border_ = false;
211 if (native_wrapper_) 199 if (native_wrapper_)
212 native_wrapper_->UpdateBorder(); 200 native_wrapper_->UpdateBorder();
213 } 201 }
214 202
215 bool Textfield::GetHorizontalMargins(int* left, int* right) { 203 bool Textfield::GetHorizontalMargins(int* left, int* right) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 native_wrapper_->GetView()->SetBoundsRect(GetLocalBounds()); 273 native_wrapper_->GetView()->SetBoundsRect(GetLocalBounds());
286 native_wrapper_->GetView()->Layout(); 274 native_wrapper_->GetView()->Layout();
287 } 275 }
288 } 276 }
289 277
290 gfx::Size Textfield::GetPreferredSize() { 278 gfx::Size Textfield::GetPreferredSize() {
291 gfx::Insets insets; 279 gfx::Insets insets;
292 if (draw_border_ && native_wrapper_) 280 if (draw_border_ && native_wrapper_)
293 insets = native_wrapper_->CalculateInsets(); 281 insets = native_wrapper_->CalculateInsets();
294 return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) + 282 return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) +
295 insets.width(), 283 insets.width(), font_.GetHeight() + insets.height());
296 num_lines_ * font_.GetHeight() + insets.height());
297 } 284 }
298 285
299 bool Textfield::IsFocusable() const { 286 bool Textfield::IsFocusable() const {
300 return View::IsFocusable() && !read_only_; 287 return View::IsFocusable() && !read_only_;
301 } 288 }
302 289
303 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { 290 void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) {
304 SelectAll(); 291 SelectAll();
305 } 292 }
306 293
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 394 }
408 #endif 395 #endif
409 } 396 }
410 } 397 }
411 398
412 std::string Textfield::GetClassName() const { 399 std::string Textfield::GetClassName() const {
413 return kViewClassName; 400 return kViewClassName;
414 } 401 }
415 402
416 } // namespace views 403 } // namespace views
OLDNEW
« views/controls/textfield/native_textfield_views.h ('K') | « views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698