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

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

Issue 623293004: replace OVERRIDE and FINAL with override and final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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
« no previous file with comments | « ui/views/examples/multiline_example.h ('k') | ui/views/examples/progress_bar_example.h » ('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 17 matching lines...) Expand all
28 return range; 28 return range;
29 } 29 }
30 30
31 // A Label with a clamped preferred width to demonstrate wrapping. 31 // A Label with a clamped preferred width to demonstrate wrapping.
32 class PreferredSizeLabel : public Label { 32 class PreferredSizeLabel : public Label {
33 public: 33 public:
34 PreferredSizeLabel() : Label() {} 34 PreferredSizeLabel() : Label() {}
35 virtual ~PreferredSizeLabel() {} 35 virtual ~PreferredSizeLabel() {}
36 36
37 // Label: 37 // Label:
38 virtual gfx::Size GetPreferredSize() const OVERRIDE { 38 virtual gfx::Size GetPreferredSize() const override {
39 return gfx::Size(50, Label::GetPreferredSize().height()); 39 return gfx::Size(50, Label::GetPreferredSize().height());
40 } 40 }
41 41
42 private: 42 private:
43 DISALLOW_COPY_AND_ASSIGN(PreferredSizeLabel); 43 DISALLOW_COPY_AND_ASSIGN(PreferredSizeLabel);
44 }; 44 };
45 45
46 } // namespace 46 } // namespace
47 47
48 // A simple View that hosts a RenderText object. 48 // A simple View that hosts a RenderText object.
49 class MultilineExample::RenderTextView : public View { 49 class MultilineExample::RenderTextView : public View {
50 public: 50 public:
51 RenderTextView() : render_text_(gfx::RenderText::CreateInstance()) { 51 RenderTextView() : render_text_(gfx::RenderText::CreateInstance()) {
52 render_text_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 52 render_text_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
53 render_text_->SetColor(SK_ColorBLACK); 53 render_text_->SetColor(SK_ColorBLACK);
54 render_text_->SetMultiline(true); 54 render_text_->SetMultiline(true);
55 SetBorder(Border::CreateSolidBorder(2, SK_ColorGRAY)); 55 SetBorder(Border::CreateSolidBorder(2, SK_ColorGRAY));
56 } 56 }
57 57
58 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 58 virtual void OnPaint(gfx::Canvas* canvas) override {
59 View::OnPaint(canvas); 59 View::OnPaint(canvas);
60 render_text_->Draw(canvas); 60 render_text_->Draw(canvas);
61 } 61 }
62 62
63 virtual gfx::Size GetPreferredSize() const OVERRIDE { 63 virtual gfx::Size GetPreferredSize() const override {
64 // Turn off multiline mode to get the single-line text size, which is the 64 // Turn off multiline mode to get the single-line text size, which is the
65 // preferred size for this view. 65 // preferred size for this view.
66 render_text_->SetMultiline(false); 66 render_text_->SetMultiline(false);
67 gfx::Size size(render_text_->GetContentWidth(), 67 gfx::Size size(render_text_->GetContentWidth(),
68 render_text_->GetStringSize().height()); 68 render_text_->GetStringSize().height());
69 size.Enlarge(GetInsets().width(), GetInsets().height()); 69 size.Enlarge(GetInsets().width(), GetInsets().height());
70 render_text_->SetMultiline(true); 70 render_text_->SetMultiline(true);
71 return size; 71 return size;
72 } 72 }
73 73
74 virtual int GetHeightForWidth(int w) const OVERRIDE { 74 virtual int GetHeightForWidth(int w) const override {
75 // TODO(ckocagil): Why does this happen? 75 // TODO(ckocagil): Why does this happen?
76 if (w == 0) 76 if (w == 0)
77 return View::GetHeightForWidth(w); 77 return View::GetHeightForWidth(w);
78 const gfx::Rect old_rect = render_text_->display_rect(); 78 const gfx::Rect old_rect = render_text_->display_rect();
79 gfx::Rect rect = old_rect; 79 gfx::Rect rect = old_rect;
80 rect.set_width(w - GetInsets().width()); 80 rect.set_width(w - GetInsets().width());
81 render_text_->SetDisplayRect(rect); 81 render_text_->SetDisplayRect(rect);
82 int height = render_text_->GetStringSize().height() + GetInsets().height(); 82 int height = render_text_->GetStringSize().height() + GetInsets().height();
83 render_text_->SetDisplayRect(old_rect); 83 render_text_->SetDisplayRect(old_rect);
84 return height; 84 return height;
(...skipping 12 matching lines...) Expand all
97 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false); 97 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false);
98 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, color_range); 98 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, color_range);
99 render_text_->SetStyle(gfx::UNDERLINE, false); 99 render_text_->SetStyle(gfx::UNDERLINE, false);
100 render_text_->ApplyStyle(gfx::UNDERLINE, true, color_range); 100 render_text_->ApplyStyle(gfx::UNDERLINE, true, color_range);
101 render_text_->ApplyStyle(gfx::BOLD, true, bold_range); 101 render_text_->ApplyStyle(gfx::BOLD, true, bold_range);
102 render_text_->ApplyStyle(gfx::ITALIC, true, italic_range); 102 render_text_->ApplyStyle(gfx::ITALIC, true, italic_range);
103 InvalidateLayout(); 103 InvalidateLayout();
104 } 104 }
105 105
106 private: 106 private:
107 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE { 107 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override {
108 gfx::Rect bounds = GetLocalBounds(); 108 gfx::Rect bounds = GetLocalBounds();
109 bounds.Inset(GetInsets()); 109 bounds.Inset(GetInsets());
110 render_text_->SetDisplayRect(bounds); 110 render_text_->SetDisplayRect(bounds);
111 } 111 }
112 112
113 scoped_ptr<gfx::RenderText> render_text_; 113 scoped_ptr<gfx::RenderText> render_text_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(RenderTextView); 115 DISALLOW_COPY_AND_ASSIGN(RenderTextView);
116 }; 116 };
117 117
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) { 182 void MultilineExample::ButtonPressed(Button* sender, const ui::Event& event) {
183 DCHECK_EQ(sender, label_checkbox_); 183 DCHECK_EQ(sender, label_checkbox_);
184 label_->SetText(label_checkbox_->checked() ? textfield_->text() : 184 label_->SetText(label_checkbox_->checked() ? textfield_->text() :
185 base::string16()); 185 base::string16());
186 container()->Layout(); 186 container()->Layout();
187 container()->SchedulePaint(); 187 container()->SchedulePaint();
188 } 188 }
189 189
190 } // namespace examples 190 } // namespace examples
191 } // namespace views 191 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/multiline_example.h ('k') | ui/views/examples/progress_bar_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698