summaryrefslogtreecommitdiffstats
path: root/ui/views/focus_border.cc
blob: 68fd430750438c21f6cf2db37107f806965a5979 (plain)
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
// Copyright (c) 2012 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/focus_border.h"

#include "ui/gfx/canvas.h"
#include "ui/gfx/rect.h"
#include "ui/views/view.h"

namespace views {
namespace {
class DashedFocusBorder : public FocusBorder {
 public:
  DashedFocusBorder(
      int left_inset, int top_inset, int right_inset, int bottom_inset)
      : left_inset_(left_inset),
        top_inset_(top_inset),
        right_inset_(right_inset),
        bottom_inset_(bottom_inset) {
  }

  virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
    gfx::Rect rect(view.GetLocalBounds());
    rect.Inset(left_inset_, top_inset_, right_inset_, bottom_inset_);
    canvas->DrawFocusRect(rect);
  }

 private:
  int left_inset_;
  int top_inset_;
  int right_inset_;
  int bottom_inset_;

  DISALLOW_COPY_AND_ASSIGN(DashedFocusBorder);
};
}  // namespace

FocusBorder::~FocusBorder() {
}

// static
FocusBorder* FocusBorder::CreateDashedFocusBorder() {
  return new DashedFocusBorder(0, 0, 0, 0);
}

// static
FocusBorder* FocusBorder::CreateDashedFocusBorder(
    int left, int top, int right, int bottom) {
  return new DashedFocusBorder(left, top, right, bottom);
}

FocusBorder::FocusBorder() {
}

}  // namespace views