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

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

Issue 7265011: RenderText API Outline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix permissions, export RenderText and StyleRange via UI_API. Created 9 years, 4 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/examples/textfield_example.h" 5 #include "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/range/range.h" 8 #include "ui/base/range/range.h"
9 #include "ui/gfx/render_text.h"
9 #include "views/controls/label.h" 10 #include "views/controls/label.h"
10 #include "views/controls/textfield/text_style.h"
11 #include "views/controls/textfield/textfield.h" 11 #include "views/controls/textfield/textfield.h"
12 #include "views/layout/grid_layout.h" 12 #include "views/layout/grid_layout.h"
13 #include "views/view.h" 13 #include "views/view.h"
14 14
15 namespace examples { 15 namespace examples {
16 16
17 TextfieldExample::TextfieldExample(ExamplesMain* main) 17 TextfieldExample::TextfieldExample(ExamplesMain* main)
18 : ExampleBase(main), 18 : ExampleBase(main) {
19 underline_(NULL),
20 strike_(NULL),
21 color_(NULL) {
22 } 19 }
23 20
24 TextfieldExample::~TextfieldExample() { 21 TextfieldExample::~TextfieldExample() {
25 } 22 }
26 23
27 std::wstring TextfieldExample::GetExampleTitle() { 24 std::wstring TextfieldExample::GetExampleTitle() {
28 return L"Textfield"; 25 return L"Textfield";
29 } 26 }
30 27
31 void TextfieldExample::CreateExampleView(views::View* container) { 28 void TextfieldExample::CreateExampleView(views::View* container) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 PrintStatus(L"Password [%ls]", UTF16ToWideHack(password_->text()).c_str()); 83 PrintStatus(L"Password [%ls]", UTF16ToWideHack(password_->text()).c_str());
87 } else if (sender == clear_all_) { 84 } else if (sender == clear_all_) {
88 string16 empty; 85 string16 empty;
89 name_->SetText(empty); 86 name_->SetText(empty);
90 password_->SetText(empty); 87 password_->SetText(empty);
91 } else if (sender == append_) { 88 } else if (sender == append_) {
92 name_->AppendText(WideToUTF16(L"[append]")); 89 name_->AppendText(WideToUTF16(L"[append]"));
93 } else if (sender == set_) { 90 } else if (sender == set_) {
94 name_->SetText(WideToUTF16(L"[set]")); 91 name_->SetText(WideToUTF16(L"[set]"));
95 } else if (sender == set_style_) { 92 } else if (sender == set_style_) {
96 if (!underline_) { 93 gfx::StyleRange color;
97 color_ = name_->CreateTextStyle(); 94 color.foreground = SK_ColorYELLOW;
98 color_->set_foreground(SK_ColorYELLOW); 95 color.range = ui::Range(0, 11);
99 underline_ = name_->CreateTextStyle(); 96 name_->ApplyStyleRange(color);
100 underline_->set_underline(true); 97
101 underline_->set_foreground(SK_ColorBLUE); 98 gfx::StyleRange underline;
102 strike_ = name_->CreateTextStyle(); 99 underline.underline = true;
103 strike_->set_strike(true); 100 underline.foreground = SK_ColorBLUE;
104 strike_->set_foreground(SK_ColorRED); 101 underline.range = ui::Range(1, 7);
105 name_->ApplyTextStyle(color_, ui::Range(0, 11)); 102 name_->ApplyStyleRange(underline);
106 name_->ApplyTextStyle(underline_, ui::Range(1, 7)); 103
107 name_->ApplyTextStyle(strike_, ui::Range(6, 9)); 104 gfx::StyleRange strike;
108 } 105 strike.strike = true;
106 strike.foreground = SK_ColorRED;
107 strike.range = ui::Range(6, 9);
108 name_->ApplyStyleRange(strike);
109 } 109 }
110 } 110 }
111 111
112 } // namespace examples 112 } // namespace examples
OLDNEW
« ui/ui.gyp ('K') | « views/examples/textfield_example.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698