roll skia 1111->1115
[chromium-blink-merge.git] / views / border.h
blob15d94b037ebd9a110c7f0f81d79e7fc00187bbdc
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
3 // found in the LICENSE file.
5 #ifndef VIEWS_BORDER_H_
6 #define VIEWS_BORDER_H_
7 #pragma once
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/gfx/insets.h"
11 #include "views/view.h"
13 namespace gfx{
14 class Canvas;
17 namespace views {
19 class View;
21 ////////////////////////////////////////////////////////////////////////////////
23 // Border class.
25 // The border class is used to display a border around a view.
26 // To set a border on a view, just call SetBorder on the view, for example:
27 // view->set_border(Border::CreateSolidBorder(1, SkColorSetRGB(25, 25, 112));
28 // Once set on a view, the border is owned by the view.
30 // IMPORTANT NOTE: not all views support borders at this point. In order to
31 // support the border, views should make sure to use bounds excluding the
32 // border (by calling View::GetLocalBoundsExcludingBorder) when doing layout and
33 // painting.
35 ////////////////////////////////////////////////////////////////////////////////
37 class Border {
38 public:
39 Border();
40 virtual ~Border();
42 // Creates a border that is a simple line of the specified thickness and
43 // color.
44 static Border* CreateSolidBorder(int thickness, SkColor color);
46 // Creates a border for reserving space. The returned border does not
47 // paint anything.
48 static Border* CreateEmptyBorder(int top, int left, int bottom, int right);
50 // Renders the border for the specified view.
51 virtual void Paint(const View& view, gfx::Canvas* canvas) const = 0;
53 // Sets the specified insets to the the border insets.
54 virtual void GetInsets(gfx::Insets* insets) const = 0;
56 private:
57 DISALLOW_COPY_AND_ASSIGN(Border);
60 } // namespace views
62 #endif // VIEWS_BORDER_H_