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

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

Issue 11535014: Replace StyleRange with BreakList; update RenderText, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 10 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
« no previous file with comments | « ui/views/examples/text_example.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/examples/textfield_example.h" 5 #include "ui/views/examples/textfield_example.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "ui/base/events/event.h" 8 #include "ui/base/events/event.h"
9 #include "ui/base/range/range.h" 9 #include "ui/base/range/range.h"
10 #include "ui/gfx/render_text.h" 10 #include "ui/gfx/render_text.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } else if (sender == clear_all_) { 86 } else if (sender == clear_all_) {
87 string16 empty; 87 string16 empty;
88 name_->SetText(empty); 88 name_->SetText(empty);
89 password_->SetText(empty); 89 password_->SetText(empty);
90 } else if (sender == append_) { 90 } else if (sender == append_) {
91 name_->AppendText(ASCIIToUTF16("[append]")); 91 name_->AppendText(ASCIIToUTF16("[append]"));
92 } else if (sender == set_) { 92 } else if (sender == set_) {
93 name_->SetText(ASCIIToUTF16("[set]")); 93 name_->SetText(ASCIIToUTF16("[set]"));
94 } else if (sender == set_style_) { 94 } else if (sender == set_style_) {
95 if (!name_->text().empty()) { 95 if (!name_->text().empty()) {
96 gfx::StyleRange color; 96 name_->SetColor(SK_ColorGREEN);
97 color.foreground = SK_ColorYELLOW; 97 name_->SetStyle(gfx::BOLD, true);
98 color.range = ui::Range(0, name_->text().length());
99 name_->ApplyStyleRange(color);
100 98
101 if (name_->text().length() >= 5) { 99 if (name_->text().length() >= 5) {
102 size_t fifth = name_->text().length() / 5; 100 size_t fifth = name_->text().length() / 5;
103 gfx::StyleRange underline; 101 const ui::Range big_range(1 * fifth, 4 * fifth);
104 underline.underline = true; 102 name_->ApplyStyle(gfx::BOLD, false, big_range);
105 underline.foreground = SK_ColorBLUE; 103 name_->ApplyStyle(gfx::UNDERLINE, true, big_range);
106 underline.range = ui::Range(1 * fifth, 4 * fifth); 104 name_->ApplyColor(SK_ColorBLUE, big_range);
107 name_->ApplyStyleRange(underline);
108 105
109 gfx::StyleRange strike; 106 const ui::Range small_range(2 * fifth, 3 * fifth);
110 strike.strike = true; 107 name_->ApplyStyle(gfx::ITALIC, true, small_range);
111 strike.foreground = SK_ColorRED; 108 name_->ApplyStyle(gfx::UNDERLINE, false, small_range);
112 strike.range = ui::Range(2 * fifth, 3 * fifth); 109 name_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, small_range);
113 name_->ApplyStyleRange(strike); 110 name_->ApplyColor(SK_ColorRED, small_range);
114 } 111 }
115 } 112 }
116 } 113 }
117 } 114 }
118 115
119 } // namespace examples 116 } // namespace examples
120 } // namespace views 117 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/text_example.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698