| OLD | NEW |
| 1 // Copyright (c) 2011 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 #ifndef VIEWS_PAINTER_H_ | 5 #ifndef VIEWS_PAINTER_H_ |
| 6 #define VIEWS_PAINTER_H_ | 6 #define VIEWS_PAINTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "views/views_api.h" | 11 #include "views/views_export.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class Canvas; | 14 class Canvas; |
| 15 class Insets; | 15 class Insets; |
| 16 } | 16 } |
| 17 class SkBitmap; | 17 class SkBitmap; |
| 18 | 18 |
| 19 namespace views { | 19 namespace views { |
| 20 | 20 |
| 21 // Painter, as the name implies, is responsible for painting in a particular | 21 // Painter, as the name implies, is responsible for painting in a particular |
| 22 // region. Think of Painter as a Border or Background that can be painted | 22 // region. Think of Painter as a Border or Background that can be painted |
| 23 // in any region of a View. | 23 // in any region of a View. |
| 24 class VIEWS_API Painter { | 24 class VIEWS_EXPORT Painter { |
| 25 public: | 25 public: |
| 26 // A convenience method for painting a Painter in a particular region. | 26 // A convenience method for painting a Painter in a particular region. |
| 27 // This translates the canvas to x/y and paints the painter. | 27 // This translates the canvas to x/y and paints the painter. |
| 28 static void PaintPainterAt(int x, int y, int w, int h, | 28 static void PaintPainterAt(int x, int y, int w, int h, |
| 29 gfx::Canvas* canvas, Painter* painter); | 29 gfx::Canvas* canvas, Painter* painter); |
| 30 | 30 |
| 31 // Creates a painter that draws a gradient between the two colors. | 31 // Creates a painter that draws a gradient between the two colors. |
| 32 static Painter* CreateHorizontalGradient(SkColor c1, SkColor c2); | 32 static Painter* CreateHorizontalGradient(SkColor c1, SkColor c2); |
| 33 static Painter* CreateVerticalGradient(SkColor c1, SkColor c2); | 33 static Painter* CreateVerticalGradient(SkColor c1, SkColor c2); |
| 34 | 34 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 virtual ~Painter() {} | 45 virtual ~Painter() {} |
| 46 | 46 |
| 47 // Paints the painter in the specified region. | 47 // Paints the painter in the specified region. |
| 48 virtual void Paint(int w, int h, gfx::Canvas* canvas) = 0; | 48 virtual void Paint(int w, int h, gfx::Canvas* canvas) = 0; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // HorizontalPainter paints 3 images into a box: left, center and right. The | 51 // HorizontalPainter paints 3 images into a box: left, center and right. The |
| 52 // left and right images are drawn to size at the left/right edges of the | 52 // left and right images are drawn to size at the left/right edges of the |
| 53 // region. The center is tiled in the remaining space. All images must have the | 53 // region. The center is tiled in the remaining space. All images must have the |
| 54 // same height. | 54 // same height. |
| 55 class VIEWS_API HorizontalPainter : public Painter { | 55 class VIEWS_EXPORT HorizontalPainter : public Painter { |
| 56 public: | 56 public: |
| 57 // Constructs a new HorizontalPainter loading the specified image names. | 57 // Constructs a new HorizontalPainter loading the specified image names. |
| 58 // The images must be in the order left, right and center. | 58 // The images must be in the order left, right and center. |
| 59 explicit HorizontalPainter(const int image_resource_names[]); | 59 explicit HorizontalPainter(const int image_resource_names[]); |
| 60 | 60 |
| 61 virtual ~HorizontalPainter() {} | 61 virtual ~HorizontalPainter() {} |
| 62 | 62 |
| 63 // Paints the images. | 63 // Paints the images. |
| 64 virtual void Paint(int w, int h, gfx::Canvas* canvas); | 64 virtual void Paint(int w, int h, gfx::Canvas* canvas); |
| 65 | 65 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 int height_; | 78 int height_; |
| 79 // NOTE: the images are owned by ResourceBundle. Don't free them. | 79 // NOTE: the images are owned by ResourceBundle. Don't free them. |
| 80 SkBitmap* images_[3]; | 80 SkBitmap* images_[3]; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(HorizontalPainter); | 82 DISALLOW_COPY_AND_ASSIGN(HorizontalPainter); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace views | 85 } // namespace views |
| 86 | 86 |
| 87 #endif // VIEWS_PAINTER_H_ | 87 #endif // VIEWS_PAINTER_H_ |
| OLD | NEW |