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

Side by Side Diff: views/border.cc

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | « views/border.h ('k') | views/controls/button/checkbox.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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/border.h" 5 #include "views/border.h"
6 6
7 #include "app/gfx/chrome_canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace views { 10 namespace views {
11 11
12 namespace { 12 namespace {
13 13
14 // A simple border with a fixed thickness and single color. 14 // A simple border with a fixed thickness and single color.
15 class SolidBorder : public Border { 15 class SolidBorder : public Border {
16 public: 16 public:
17 SolidBorder(int thickness, SkColor color); 17 SolidBorder(int thickness, SkColor color);
18 18
19 virtual void Paint(const View& view, ChromeCanvas* canvas) const; 19 virtual void Paint(const View& view, gfx::Canvas* canvas) const;
20 virtual void GetInsets(gfx::Insets* insets) const; 20 virtual void GetInsets(gfx::Insets* insets) const;
21 21
22 private: 22 private:
23 int thickness_; 23 int thickness_;
24 SkColor color_; 24 SkColor color_;
25 gfx::Insets insets_; 25 gfx::Insets insets_;
26 26
27 DISALLOW_EVIL_CONSTRUCTORS(SolidBorder); 27 DISALLOW_EVIL_CONSTRUCTORS(SolidBorder);
28 }; 28 };
29 29
30 SolidBorder::SolidBorder(int thickness, SkColor color) 30 SolidBorder::SolidBorder(int thickness, SkColor color)
31 : thickness_(thickness), 31 : thickness_(thickness),
32 color_(color), 32 color_(color),
33 insets_(thickness, thickness, thickness, thickness) { 33 insets_(thickness, thickness, thickness, thickness) {
34 } 34 }
35 35
36 void SolidBorder::Paint(const View& view, ChromeCanvas* canvas) const { 36 void SolidBorder::Paint(const View& view, gfx::Canvas* canvas) const {
37 gfx::Rect clip_rect; 37 gfx::Rect clip_rect;
38 if (!canvas->GetClipRect(&clip_rect)) 38 if (!canvas->GetClipRect(&clip_rect))
39 return; // Empty clip rectangle, nothing to paint. 39 return; // Empty clip rectangle, nothing to paint.
40 40
41 // Top border. 41 // Top border.
42 gfx::Rect border_bounds(0, 0, view.width(), insets_.top()); 42 gfx::Rect border_bounds(0, 0, view.width(), insets_.top());
43 if (clip_rect.Intersects(border_bounds)) 43 if (clip_rect.Intersects(border_bounds))
44 canvas->FillRectInt(color_, 0, 0, view.width(), insets_.top()); 44 canvas->FillRectInt(color_, 0, 0, view.width(), insets_.top());
45 // Left border. 45 // Left border.
46 border_bounds.SetRect(0, 0, insets_.left(), view.height()); 46 border_bounds.SetRect(0, 0, insets_.left(), view.height());
(...skipping 16 matching lines...) Expand all
63 void SolidBorder::GetInsets(gfx::Insets* insets) const { 63 void SolidBorder::GetInsets(gfx::Insets* insets) const {
64 DCHECK(insets); 64 DCHECK(insets);
65 insets->Set(insets_.top(), insets_.left(), insets_.bottom(), insets_.right()); 65 insets->Set(insets_.top(), insets_.left(), insets_.bottom(), insets_.right());
66 } 66 }
67 67
68 class EmptyBorder : public Border { 68 class EmptyBorder : public Border {
69 public: 69 public:
70 EmptyBorder(int top, int left, int bottom, int right) 70 EmptyBorder(int top, int left, int bottom, int right)
71 : top_(top), left_(left), bottom_(bottom), right_(right) {} 71 : top_(top), left_(left), bottom_(bottom), right_(right) {}
72 72
73 virtual void Paint(const View& view, ChromeCanvas* canvas) const {} 73 virtual void Paint(const View& view, gfx::Canvas* canvas) const {}
74 74
75 virtual void GetInsets(gfx::Insets* insets) const { 75 virtual void GetInsets(gfx::Insets* insets) const {
76 DCHECK(insets); 76 DCHECK(insets);
77 insets->Set(top_, left_, bottom_, right_); 77 insets->Set(top_, left_, bottom_, right_);
78 } 78 }
79 79
80 private: 80 private:
81 int top_; 81 int top_;
82 int left_; 82 int left_;
83 int bottom_; 83 int bottom_;
(...skipping 13 matching lines...) Expand all
97 Border* Border::CreateSolidBorder(int thickness, SkColor color) { 97 Border* Border::CreateSolidBorder(int thickness, SkColor color) {
98 return new SolidBorder(thickness, color); 98 return new SolidBorder(thickness, color);
99 } 99 }
100 100
101 // static 101 // static
102 Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) { 102 Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) {
103 return new EmptyBorder(top, left, bottom, right); 103 return new EmptyBorder(top, left, bottom, right);
104 } 104 }
105 105
106 } // namespace views 106 } // namespace views
OLDNEW
« no previous file with comments | « views/border.h ('k') | views/controls/button/checkbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698