Fix cookie searchbox bug.
[chromium-blink-merge.git] / ui / views / border.h
blob053c33f121b226bb79e949039feeee82222e5409
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 "third_party/skia/include/core/SkColor.h"
10 #include "ui/gfx/insets.h"
11 #include "ui/views/view.h"
12 #include "ui/views/views_export.h"
14 namespace gfx{
15 class Canvas;
18 namespace views {
20 class Painter;
21 class View;
23 ////////////////////////////////////////////////////////////////////////////////
25 // Border class.
27 // The border class is used to display a border around a view.
28 // To set a border on a view, just call SetBorder on the view, for example:
29 // view->set_border(Border::CreateSolidBorder(1, SkColorSetRGB(25, 25, 112));
30 // Once set on a view, the border is owned by the view.
32 // IMPORTANT NOTE: not all views support borders at this point. In order to
33 // support the border, views should make sure to use bounds excluding the
34 // border (by calling View::GetLocalBoundsExcludingBorder) when doing layout and
35 // painting.
37 ////////////////////////////////////////////////////////////////////////////////
39 class TextButtonBorder;
41 class VIEWS_EXPORT Border {
42 public:
43 Border();
44 virtual ~Border();
46 // Creates a border that is a simple line of the specified thickness and
47 // color.
48 static Border* CreateSolidBorder(int thickness, SkColor color);
50 // Creates a border for reserving space. The returned border does not
51 // paint anything.
52 static Border* CreateEmptyBorder(int top, int left, int bottom, int right);
54 // Creates a border of the specified color, and specified thickness on each
55 // side.
56 static Border* CreateSolidSidedBorder(int top,
57 int left,
58 int bottom,
59 int right,
60 SkColor color);
62 // Creates a Border from the specified Painter. The border owns the painter,
63 // thus the painter is deleted when the Border is deleted.
64 // |insets| define size of an area allocated for a Border.
65 static Border* CreateBorderPainter(Painter* painter,
66 const gfx::Insets& insets);
68 // Renders the border for the specified view.
69 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0;
71 // Sets the specified insets to the the border insets.
72 virtual gfx::Insets GetInsets() const = 0;
74 // Manual RTTI for text buttons.
75 virtual TextButtonBorder* AsTextButtonBorder();
76 virtual const TextButtonBorder* AsTextButtonBorder() const;
78 private:
79 DISALLOW_COPY_AND_ASSIGN(Border);
82 } // namespace views
84 #endif // UI_VIEWS_BORDER_H_