Home | History | Annotate | Download | only in views
      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.
      4 
      5 #include "ui/views/focus_border.h"
      6 
      7 #include "ui/gfx/canvas.h"
      8 #include "ui/gfx/rect.h"
      9 #include "ui/views/view.h"
     10 
     11 namespace views {
     12 namespace {
     13 class DashedFocusBorder : public FocusBorder {
     14  public:
     15   DashedFocusBorder(
     16       int left_inset, int top_inset, int right_inset, int bottom_inset)
     17       : left_inset_(left_inset),
     18         top_inset_(top_inset),
     19         right_inset_(right_inset),
     20         bottom_inset_(bottom_inset) {
     21   }
     22 
     23   virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE {
     24     gfx::Rect rect(view.GetLocalBounds());
     25     rect.Inset(left_inset_, top_inset_, right_inset_, bottom_inset_);
     26     canvas->DrawFocusRect(rect);
     27   }
     28 
     29  private:
     30   int left_inset_;
     31   int top_inset_;
     32   int right_inset_;
     33   int bottom_inset_;
     34 
     35   DISALLOW_COPY_AND_ASSIGN(DashedFocusBorder);
     36 };
     37 }  // namespace
     38 
     39 FocusBorder::~FocusBorder() {
     40 }
     41 
     42 // static
     43 FocusBorder* FocusBorder::CreateDashedFocusBorder() {
     44   return new DashedFocusBorder(0, 0, 0, 0);
     45 }
     46 
     47 // static
     48 FocusBorder* FocusBorder::CreateDashedFocusBorder(
     49     int left, int top, int right, int bottom) {
     50   return new DashedFocusBorder(left, top, right, bottom);
     51 }
     52 
     53 FocusBorder::FocusBorder() {
     54 }
     55 
     56 }  // namespace views
     57