Chromium Code Reviews| Index: ui/views/controls/button/button_border.h |
| diff --git a/ui/views/controls/button/button_border.h b/ui/views/controls/button/button_border.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bd23bd22f6ff5604a7aae60ebe3c63ec90f0cc65 |
| --- /dev/null |
| +++ b/ui/views/controls/button/button_border.h |
| @@ -0,0 +1,68 @@ |
| +// 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. |
| + |
| +#ifndef UI_VIEWS_CONTROLS_BUTTON_BUTTON_BORDER_H_ |
| +#define UI_VIEWS_CONTROLS_BUTTON_BUTTON_BORDER_H_ |
| + |
| +#include "ui/gfx/image/image_skia.h" |
| +#include "ui/views/border.h" |
| +#include "ui/views/controls/button/custom_button.h" |
| + |
| +namespace views { |
| + |
| +class NativeThemeDelegate; |
| + |
| +// A Border that paints a LabelButton's background frame. |
| +class VIEWS_EXPORT ButtonBorder : public Border { |
|
sky
2012/10/11 19:32:01
Should this be named LabelButtonBorder?
msw
2012/10/11 20:27:01
Done.
|
| + public: |
| + explicit ButtonBorder(NativeThemeDelegate* delegate); |
| + virtual ~ButtonBorder(); |
| + |
| + bool native_theme() const { return native_theme_; } |
| + void set_native_theme(bool native_theme) { native_theme_ = native_theme; } |
| + |
| + protected: |
| + struct BorderImages { |
| + BorderImages(); |
| + // |image_ids| must contain 9 image ids. |
| + explicit BorderImages(const int image_ids[]); |
| + ~BorderImages(); |
| + |
| + gfx::ImageSkia top_left; |
| + gfx::ImageSkia top; |
| + gfx::ImageSkia top_right; |
| + gfx::ImageSkia left; |
| + gfx::ImageSkia center; |
| + gfx::ImageSkia right; |
| + gfx::ImageSkia bottom_left; |
| + gfx::ImageSkia bottom; |
| + gfx::ImageSkia bottom_right; |
| + }; |
| + |
| + // Set the image set shown for the specified button state. |
| + void SetImages(CustomButton::ButtonState state, const BorderImages& images); |
| + |
| + private: |
| + // Overridden from Border: |
| + virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE; |
| + virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; |
| + |
| + void PaintImages(const View& view, |
| + gfx::Canvas* canvas, |
| + CustomButton::ButtonState state) const; |
| + void PaintNativeTheme(const View& view, gfx::Canvas* canvas) const; |
| + |
| + // The images shown for each button state. |
| + BorderImages images_[CustomButton::BS_COUNT]; |
| + |
| + // A delegate and flag controlling the native/Views theme styling. |
| + NativeThemeDelegate* native_theme_delegate_; |
| + bool native_theme_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ButtonBorder); |
| +}; |
| + |
| +} // namespace views |
| + |
| +#endif // UI_VIEWS_CONTROLS_BUTTON_BUTTON_BORDER_H_ |