views::Background

来源:互联网 发布:windows ad域组策略 编辑:程序博客网 时间:2024/04/20 12:58

 class Background {
 public:
  Background();
  virtual ~Background();

  // Creates a background that fills the canvas in the specified color.
  static Background* CreateSolidBackground(const SkColor& color);

  // Creates a background that fills the canvas in the specified color.
  static Background* CreateSolidBackground(int r, int g, int b) {
    return CreateSolidBackground(SkColorSetRGB(r, g, b));
  }

  // Creates a background that fills the canvas in the specified color.
  static Background* CreateSolidBackground(int r, int g, int b, int a) {
    return CreateSolidBackground(SkColorSetARGB(a, r, g, b));
  }

  // Creates a background that contains a vertical gradient that varies
  // from |color1| to |color2|
  static Background* CreateVerticalGradientBackground(const SkColor& color1,
                                                      const SkColor& color2);

  // Creates Chrome's standard panel background
  static Background* CreateStandardPanelBackground();

  // Creates a Background from the specified Painter. If owns_painter is
  // true, the Painter is deleted when the Border is deleted.
  static Background* CreateBackgroundPainter(bool owns_painter,
                                             Painter* painter);

  // Render the background for the provided view
  virtual void Paint(gfx::Canvas* canvas, View* view) const = 0;

  // Set a solid, opaque color to be used when drawing backgrounds of native
  // controls.  Unfortunately alpha=0 is not an option.
  void SetNativeControlColor(SkColor color);

#if defined(OS_WIN)
  // TODO(port): Make GetNativeControlBrush portable (currently uses HBRUSH).

  // Get the brush that was specified by SetNativeControlColor
  HBRUSH GetNativeControlBrush() const { return native_control_brush_; };
#endif  // defined(OS_WIN)

 private:
#if defined(OS_WIN)
  // TODO(port): Create portable replacement for HBRUSH.
  HBRUSH native_control_brush_;
#endif  // defined(OS_WIN)
  DISALLOW_COPY_AND_ASSIGN(Background);
};

 

提代了很多static函数来创建Background,Background本身一个抽象类,有两个实现类分别是SolidBackground、BackgroundPainter,主要的实现接口是:virtual void Paint(gfx::Canvas* canvas, View* view) const

 

因此,此类的功能是画View的背景。

原创粉丝点击