OLD | NEW |
1 // Copyright (c) 2006-2008 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/border.h" | 5 #include "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 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
(...skipping 16 matching lines...) Expand all Loading... |
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, gfx::Canvas* canvas) const { | 36 void SolidBorder::Paint(const View& view, gfx::Canvas* canvas) const { |
37 // Top border. | 37 // Top border. |
38 canvas->FillRectInt(color_, 0, 0, view.width(), insets_.top()); | 38 canvas->FillRect(color_, gfx::Rect(0, 0, view.width(), insets_.top())); |
39 // Left border. | 39 // Left border. |
40 canvas->FillRectInt(color_, 0, 0, insets_.left(), view.height()); | 40 canvas->FillRect(color_, gfx::Rect(0, 0, insets_.left(), view.height())); |
41 // Bottom border. | 41 // Bottom border. |
42 canvas->FillRectInt(color_, 0, view.height() - insets_.bottom(), | 42 canvas->FillRect(color_, gfx::Rect(0, view.height() - insets_.bottom(), |
43 view.width(), insets_.bottom()); | 43 view.width(), insets_.bottom())); |
44 // Right border. | 44 // Right border. |
45 canvas->FillRectInt(color_, view.width() - insets_.right(), 0, | 45 canvas->FillRect(color_, gfx::Rect(view.width() - insets_.right(), 0, |
46 insets_.right(), view.height()); | 46 insets_.right(), view.height())); |
47 } | 47 } |
48 | 48 |
49 void SolidBorder::GetInsets(gfx::Insets* insets) const { | 49 void SolidBorder::GetInsets(gfx::Insets* insets) const { |
50 DCHECK(insets); | 50 DCHECK(insets); |
51 insets->Set(insets_.top(), insets_.left(), insets_.bottom(), insets_.right()); | 51 insets->Set(insets_.top(), insets_.left(), insets_.bottom(), insets_.right()); |
52 } | 52 } |
53 | 53 |
54 class EmptyBorder : public Border { | 54 class EmptyBorder : public Border { |
55 public: | 55 public: |
56 EmptyBorder(int top, int left, int bottom, int right) | 56 EmptyBorder(int top, int left, int bottom, int right) |
(...skipping 26 matching lines...) Expand all Loading... |
83 Border* Border::CreateSolidBorder(int thickness, SkColor color) { | 83 Border* Border::CreateSolidBorder(int thickness, SkColor color) { |
84 return new SolidBorder(thickness, color); | 84 return new SolidBorder(thickness, color); |
85 } | 85 } |
86 | 86 |
87 // static | 87 // static |
88 Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) { | 88 Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) { |
89 return new EmptyBorder(top, left, bottom, right); | 89 return new EmptyBorder(top, left, bottom, right); |
90 } | 90 } |
91 | 91 |
92 } // namespace views | 92 } // namespace views |
OLD | NEW |