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

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: Simplify OmniboxResultView; Rename StyleBreak; cleanup. Created 7 years, 11 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) 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } else if (sender == clear_all_) { 80 } else if (sender == clear_all_) {
81 string16 empty; 81 string16 empty;
82 name_->SetText(empty); 82 name_->SetText(empty);
83 password_->SetText(empty); 83 password_->SetText(empty);
84 } else if (sender == append_) { 84 } else if (sender == append_) {
85 name_->AppendText(ASCIIToUTF16("[append]")); 85 name_->AppendText(ASCIIToUTF16("[append]"));
86 } else if (sender == set_) { 86 } else if (sender == set_) {
87 name_->SetText(ASCIIToUTF16("[set]")); 87 name_->SetText(ASCIIToUTF16("[set]"));
88 } else if (sender == set_style_) { 88 } else if (sender == set_style_) {
89 if (!name_->text().empty()) { 89 if (!name_->text().empty()) {
90 gfx::StyleRange color; 90 name_->SetColor(SK_ColorGREEN);
91 color.foreground = SK_ColorYELLOW; 91 name_->SetStyle(gfx::BOLD, true);
92 color.range = ui::Range(0, name_->text().length());
93 name_->ApplyStyleRange(color);
94 92
95 if (name_->text().length() >= 5) { 93 if (name_->text().length() >= 5) {
96 size_t fifth = name_->text().length() / 5; 94 size_t fifth = name_->text().length() / 5;
97 gfx::StyleRange underline; 95 const ui::Range big_range(1 * fifth, 4 * fifth);
98 underline.underline = true; 96 name_->ApplyStyle(gfx::BOLD, false, big_range);
99 underline.foreground = SK_ColorBLUE; 97 name_->ApplyStyle(gfx::UNDERLINE, true, big_range);
100 underline.range = ui::Range(1 * fifth, 4 * fifth); 98 name_->ApplyColor(SK_ColorBLUE, big_range);
101 name_->ApplyStyleRange(underline);
102 99
103 gfx::StyleRange strike; 100 const ui::Range small_range(2 * fifth, 3 * fifth);
104 strike.strike = true; 101 name_->ApplyStyle(gfx::ITALIC, true, small_range);
105 strike.foreground = SK_ColorRED; 102 name_->ApplyStyle(gfx::UNDERLINE, false, small_range);
106 strike.range = ui::Range(2 * fifth, 3 * fifth); 103 name_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, small_range);
107 name_->ApplyStyleRange(strike); 104 name_->ApplyColor(SK_ColorRED, small_range);
108 } 105 }
109 } 106 }
110 } 107 }
111 } 108 }
112 109
113 } // namespace examples 110 } // namespace examples
114 } // namespace views 111 } // namespace views
OLDNEW
« ui/views/controls/textfield/textfield.h ('K') | « ui/views/examples/text_example.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698