OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/views/rendering/border.h" |
| 6 |
| 7 #include "gfx/canvas.h" |
| 8 #include "ui/views/view.h" |
| 9 |
| 10 namespace ui { |
| 11 |
| 12 namespace internal { |
| 13 |
| 14 class SolidColorBorder : public Border { |
| 15 public: |
| 16 SolidColorBorder(int thickness, SkColor color) : color_(color) { |
| 17 set_insets(gfx::Insets(thickness, thickness, thickness, thickness)); |
| 18 } |
| 19 virtual ~SolidColorBorder() { |
| 20 } |
| 21 |
| 22 // Overridden from Border: |
| 23 virtual void Paint(const View* view, gfx::Canvas* canvas) const { |
| 24 canvas->FillRectInt(color_, 0, 0, view->width(), insets().top()); |
| 25 canvas->FillRectInt(color_, 0, 0, insets().left(), view->height()); |
| 26 canvas->FillRectInt(color_, 0, view->height() - insets().bottom(), |
| 27 view->width(), insets().bottom()); |
| 28 canvas->FillRectInt(color_, view->width() - insets().right(), 0, |
| 29 insets().right(), view->height()); |
| 30 } |
| 31 |
| 32 private: |
| 33 SkColor color_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(SolidColorBorder); |
| 36 }; |
| 37 |
| 38 } |
| 39 |
| 40 //////////////////////////////////////////////////////////////////////////////// |
| 41 // Border, public: |
| 42 |
| 43 Border::~Border() { |
| 44 } |
| 45 |
| 46 // static |
| 47 Border* Border::CreateSolidBorder(int thickness, SkColor color) { |
| 48 return new internal::SolidColorBorder(thickness, color); |
| 49 } |
| 50 |
| 51 // static |
| 52 Border* Border::CreateTransparentBorder(const gfx::Insets& insets) { |
| 53 Border* b = new Border; |
| 54 b->set_insets(insets); |
| 55 return b; |
| 56 } |
| 57 |
| 58 void Border::Paint(const View* view, gfx::Canvas* canvas) const { |
| 59 // Nothing to do. |
| 60 } |
| 61 |
| 62 //////////////////////////////////////////////////////////////////////////////// |
| 63 // Border, private: |
| 64 |
| 65 Border::Border() { |
| 66 } |
| 67 |
| 68 } // namespace ui |
| 69 |
OLD | NEW |