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

Side by Side Diff: ui/views/examples/multiline_example.cc

Issue 117983002: Prefix string16 with base:: in ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years 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
« no previous file with comments | « ui/views/examples/multiline_example.h ('k') | ui/views/examples/tabbed_pane_example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/examples/multiline_example.h" 5 #include "ui/views/examples/multiline_example.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/gfx/render_text.h" 9 #include "ui/gfx/render_text.h"
10 #include "ui/views/background.h" 10 #include "ui/views/background.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return View::GetHeightForWidth(w); 49 return View::GetHeightForWidth(w);
50 const gfx::Rect old_rect = render_text_->display_rect(); 50 const gfx::Rect old_rect = render_text_->display_rect();
51 gfx::Rect rect = old_rect; 51 gfx::Rect rect = old_rect;
52 rect.set_width(w - GetInsets().width()); 52 rect.set_width(w - GetInsets().width());
53 render_text_->SetDisplayRect(rect); 53 render_text_->SetDisplayRect(rect);
54 int height = render_text_->GetStringSize().height() + GetInsets().height(); 54 int height = render_text_->GetStringSize().height() + GetInsets().height();
55 render_text_->SetDisplayRect(old_rect); 55 render_text_->SetDisplayRect(old_rect);
56 return height; 56 return height;
57 } 57 }
58 58
59 void SetText(const string16& new_contents) { 59 void SetText(const base::string16& new_contents) {
60 // Color and style the text inside |test_range| to test colors and styles. 60 // Color and style the text inside |test_range| to test colors and styles.
61 gfx::Range test_range(1, 21); 61 gfx::Range test_range(1, 21);
62 test_range.set_start(std::min(test_range.start(), new_contents.length())); 62 test_range.set_start(std::min(test_range.start(), new_contents.length()));
63 test_range.set_end(std::min(test_range.end(), new_contents.length())); 63 test_range.set_end(std::min(test_range.end(), new_contents.length()));
64 64
65 render_text_->SetText(new_contents); 65 render_text_->SetText(new_contents);
66 render_text_->SetColor(SK_ColorBLACK); 66 render_text_->SetColor(SK_ColorBLACK);
67 render_text_->ApplyColor(0xFFFF0000, test_range); 67 render_text_->ApplyColor(0xFFFF0000, test_range);
68 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false); 68 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false);
69 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, test_range); 69 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, test_range);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 layout->StartRow(0, 0); 132 layout->StartRow(0, 0);
133 layout->AddView(label_checkbox_); 133 layout->AddView(label_checkbox_);
134 layout->AddView(label_); 134 layout->AddView(label_);
135 135
136 layout->StartRow(0, 0); 136 layout->StartRow(0, 0);
137 layout->AddView(new Label(ASCIIToUTF16("Sample Text:"))); 137 layout->AddView(new Label(ASCIIToUTF16("Sample Text:")));
138 layout->AddView(textfield_); 138 layout->AddView(textfield_);
139 } 139 }
140 140
141 void MultilineExample::ContentsChanged(Textfield* sender, 141 void MultilineExample::ContentsChanged(Textfield* sender,
142 const string16& new_contents) { 142 const base::string16& new_contents) {
143 render_text_view_->SetText(new_contents); 143 render_text_view_->SetText(new_contents);
144 if (label_checkbox_->checked()) 144 if (label_checkbox_->checked())
145 label_->SetText(new_contents); 145 label_->SetText(new_contents);
146 container()->Layout(); 146 container()->Layout();
147 container()->SchedulePaint(); 147 container()->SchedulePaint();
148 } 148 }
149 149
150 bool MultilineExample::HandleKeyEvent(Textfield* sender, 150 bool MultilineExample::HandleKeyEvent(Textfield* sender,
151 const ui::KeyEvent& key_event) { 151 const ui::KeyEvent& key_event) {
152 return false; 152 return false;
153 } 153 }
154 154
155 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) { 155 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) {
156 DCHECK_EQ(sender, label_checkbox_); 156 DCHECK_EQ(sender, label_checkbox_);
157 label_->SetText(label_checkbox_->checked() ? textfield_->text() : string16()); 157 label_->SetText(label_checkbox_->checked() ? textfield_->text() :
158 base::string16());
158 container()->Layout(); 159 container()->Layout();
159 container()->SchedulePaint(); 160 container()->SchedulePaint();
160 } 161 }
161 162
162 } // namespace examples 163 } // namespace examples
163 } // namespace views 164 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/multiline_example.h ('k') | ui/views/examples/tabbed_pane_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698