Home | History | Annotate | Download | only in button
      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 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_
      6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/compiler_specific.h"
     10 #include "base/memory/scoped_ptr.h"
     11 #include "ui/gfx/insets.h"
     12 #include "ui/views/border.h"
     13 #include "ui/views/controls/button/button.h"
     14 #include "ui/views/painter.h"
     15 
     16 namespace views {
     17 
     18 // A Border that paints a LabelButton's background frame.
     19 class VIEWS_EXPORT LabelButtonBorder : public Border {
     20  public:
     21   explicit LabelButtonBorder(Button::ButtonStyle style);
     22   virtual ~LabelButtonBorder();
     23 
     24   Button::ButtonStyle style() const { return style_; }
     25 
     26   // Overridden from Border:
     27   virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE;
     28   virtual gfx::Insets GetInsets() const OVERRIDE;
     29 
     30   void set_insets(const gfx::Insets& insets) { insets_ = insets; }
     31 
     32   // Get or set the painter used for the specified |focused| button |state|.
     33   // LabelButtonBorder takes and retains ownership of |painter|.
     34   Painter* GetPainter(bool focused, Button::ButtonState state);
     35   void SetPainter(bool focused, Button::ButtonState state, Painter* painter);
     36 
     37  private:
     38   // The painters used for each unfocused or focused button state.
     39   scoped_ptr<Painter> painters_[2][Button::STATE_COUNT];
     40 
     41   // The button style supplied in part by this border.
     42   Button::ButtonStyle style_;
     43 
     44   gfx::Insets insets_;
     45 
     46   DISALLOW_COPY_AND_ASSIGN(LabelButtonBorder);
     47 };
     48 
     49 }  // namespace views
     50 
     51 #endif  // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_
     52