Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / views / border.h
blobebd291cb4456727ede02cca56fa8402796c7d413
1 // Copyright (c) 2012 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 UI_VIEWS_BORDER_H_
6 #define UI_VIEWS_BORDER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/geometry/insets.h"
12 #include "ui/views/views_export.h"
14 namespace gfx{
15 class Canvas;
16 class Size;
19 namespace views {
21 class Painter;
22 class View;
24 ////////////////////////////////////////////////////////////////////////////////
26 // Border class.
28 // The border class is used to display a border around a view.
29 // To set a border on a view, just call SetBorder on the view, for example:
30 // view->SetBorder(Border::CreateSolidBorder(1, SkColorSetRGB(25, 25, 112));
31 // Once set on a view, the border is owned by the view.
33 // IMPORTANT NOTE: not all views support borders at this point. In order to
34 // support the border, views should make sure to use bounds excluding the
35 // border (by calling View::GetLocalBoundsExcludingBorder) when doing layout and
36 // painting.
38 ////////////////////////////////////////////////////////////////////////////////
40 class VIEWS_EXPORT Border {
41 public:
42 Border();
43 virtual ~Border();
45 // Convenience for creating a scoped_ptr with no Border.
46 static scoped_ptr<Border> NullBorder();
48 // Creates a border that is a simple line of the specified thickness and
49 // color.
50 static scoped_ptr<Border> CreateSolidBorder(int thickness, SkColor color);
52 // Creates a border for reserving space. The returned border does not
53 // paint anything.
54 static scoped_ptr<Border> CreateEmptyBorder(int top,
55 int left,
56 int bottom,
57 int right);
59 // Creates a border of the specified color, and specified thickness on each
60 // side.
61 static scoped_ptr<Border> CreateSolidSidedBorder(int top,
62 int left,
63 int bottom,
64 int right,
65 SkColor color);
67 // Creates a Border from the specified Painter. The border owns the painter,
68 // thus the painter is deleted when the Border is deleted.
69 // |insets| define size of an area allocated for a Border.
70 static scoped_ptr<Border> CreateBorderPainter(Painter* painter,
71 const gfx::Insets& insets);
73 // Renders the border for the specified view.
74 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0;
76 // Returns the border insets.
77 virtual gfx::Insets GetInsets() const = 0;
79 // Returns the minimum size this border requires. Note that this may not be
80 // the same as the insets. For example, a Border may paint images to draw
81 // some graphical border around a view, and this would return the minimum size
82 // such that these images would not be clipped or overlapping -- but the
83 // insets may be larger or smaller, depending on how the view wanted its
84 // content laid out relative to these images.
85 virtual gfx::Size GetMinimumSize() const = 0;
87 private:
88 DISALLOW_COPY_AND_ASSIGN(Border);
91 } // namespace views
93 #endif // UI_VIEWS_BORDER_H_