1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/rendering/border.h"
#include "ui/gfx/canvas.h"
#include "ui/views/view.h"
namespace ui {
namespace internal {
class SolidColorBorder : public Border {
public:
SolidColorBorder(int thickness, SkColor color) : color_(color) {
set_insets(gfx::Insets(thickness, thickness, thickness, thickness));
}
virtual ~SolidColorBorder() {
}
// Overridden from Border:
virtual void Paint(const View* view, gfx::Canvas* canvas) const {
canvas->FillRectInt(color_, 0, 0, view->width(), insets().top());
canvas->FillRectInt(color_, 0, 0, insets().left(), view->height());
canvas->FillRectInt(color_, 0, view->height() - insets().bottom(),
view->width(), insets().bottom());
canvas->FillRectInt(color_, view->width() - insets().right(), 0,
insets().right(), view->height());
}
private:
SkColor color_;
DISALLOW_COPY_AND_ASSIGN(SolidColorBorder);
};
}
////////////////////////////////////////////////////////////////////////////////
// Border, public:
Border::~Border() {
}
// static
Border* Border::CreateSolidBorder(int thickness, SkColor color) {
return new internal::SolidColorBorder(thickness, color);
}
// static
Border* Border::CreateTransparentBorder(const gfx::Insets& insets) {
Border* b = new Border;
b->set_insets(insets);
return b;
}
void Border::Paint(const View* view, gfx::Canvas* canvas) const {
// Nothing to do.
}
////////////////////////////////////////////////////////////////////////////////
// Border, private:
Border::Border() {
}
} // namespace ui
|