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

Side by Side Diff: ui/views/border.cc

Issue 10358013: views: Mark single-argument constructors as explicit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « no previous file | ui/views/bubble/bubble_frame_view_unittest.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 (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/border.h" 5 #include "ui/views/border.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/gfx/canvas.h" 8 #include "ui/gfx/canvas.h"
9 #include "ui/views/painter.h" 9 #include "ui/views/painter.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 namespace { 13 namespace {
14 14
15 // A simple border with different thicknesses on each side and single color. 15 // A simple border with different thicknesses on each side and single color.
16 class SidedSolidBorder : public Border { 16 class SidedSolidBorder : public Border {
17 public: 17 public:
18 SidedSolidBorder(int top, int left, int bottom, int right, SkColor color); 18 SidedSolidBorder(int top, int left, int bottom, int right, SkColor color);
19 19
20 virtual void Paint(const View& view, gfx::Canvas* canvas) const; 20 // Overridden from Border:
21 virtual void GetInsets(gfx::Insets* insets) const; 21 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE;
22 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE;
22 23
23 private: 24 private:
24 int top_, left_, bottom_, right_; 25 int top_, left_, bottom_, right_;
25 SkColor color_; 26 SkColor color_;
26 gfx::Insets insets_; 27 gfx::Insets insets_;
27 28
28 DISALLOW_COPY_AND_ASSIGN(SidedSolidBorder); 29 DISALLOW_COPY_AND_ASSIGN(SidedSolidBorder);
29 }; 30 };
30 31
31 SidedSolidBorder::SidedSolidBorder(int top, int left, int bottom, int right, 32 SidedSolidBorder::SidedSolidBorder(int top, int left, int bottom, int right,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 66
66 private: 67 private:
67 DISALLOW_COPY_AND_ASSIGN(SolidBorder); 68 DISALLOW_COPY_AND_ASSIGN(SolidBorder);
68 }; 69 };
69 70
70 class EmptyBorder : public Border { 71 class EmptyBorder : public Border {
71 public: 72 public:
72 EmptyBorder(int top, int left, int bottom, int right) 73 EmptyBorder(int top, int left, int bottom, int right)
73 : top_(top), left_(left), bottom_(bottom), right_(right) {} 74 : top_(top), left_(left), bottom_(bottom), right_(right) {}
74 75
75 virtual void Paint(const View& view, gfx::Canvas* canvas) const {} 76 // Overridden from Border:
77 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {}
76 78
77 virtual void GetInsets(gfx::Insets* insets) const { 79 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
78 DCHECK(insets); 80 DCHECK(insets);
79 insets->Set(top_, left_, bottom_, right_); 81 insets->Set(top_, left_, bottom_, right_);
80 } 82 }
81 83
82 private: 84 private:
83 int top_; 85 int top_;
84 int left_; 86 int left_;
85 int bottom_; 87 int bottom_;
86 int right_; 88 int right_;
87 89
88 DISALLOW_COPY_AND_ASSIGN(EmptyBorder); 90 DISALLOW_COPY_AND_ASSIGN(EmptyBorder);
89 }; 91 };
90 92
91 class BorderPainter : public Border { 93 class BorderPainter : public Border {
92 public: 94 public:
93 BorderPainter(Painter* painter) 95 explicit BorderPainter(Painter* painter)
94 : painter_(painter) { 96 : painter_(painter) {
95 DCHECK(painter); 97 DCHECK(painter);
96 } 98 }
97 99
98 virtual ~BorderPainter() { 100 virtual ~BorderPainter() {
99 delete painter_; 101 delete painter_;
102 painter_ = NULL;
100 } 103 }
101 104
102 void Paint(const View& view, gfx::Canvas* canvas) const { 105 // Overridden from Border:
106 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
103 Painter::PaintPainterAt(canvas, painter_, view.GetLocalBounds()); 107 Painter::PaintPainterAt(canvas, painter_, view.GetLocalBounds());
104 } 108 }
105 109
106 virtual void GetInsets(gfx::Insets* insets) const { 110 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
107 DCHECK(insets); 111 DCHECK(insets);
108 insets->Set(0, 0, 0, 0); 112 insets->Set(0, 0, 0, 0);
109 } 113 }
110 114
111 private: 115 private:
112 Painter* painter_; 116 Painter* painter_;
113 117
114 DISALLOW_COPY_AND_ASSIGN(BorderPainter); 118 DISALLOW_COPY_AND_ASSIGN(BorderPainter);
115 }; 119 };
116 120
(...skipping 21 matching lines...) Expand all
138 SkColor color) { 142 SkColor color) {
139 return new SidedSolidBorder(top, left, bottom, right, color); 143 return new SidedSolidBorder(top, left, bottom, right, color);
140 } 144 }
141 145
142 //static 146 //static
143 Border* Border::CreateBorderPainter(Painter* painter) { 147 Border* Border::CreateBorderPainter(Painter* painter) {
144 return new BorderPainter(painter); 148 return new BorderPainter(painter);
145 } 149 }
146 150
147 } // namespace views 151 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/bubble/bubble_frame_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698