| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| 6 #define UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/image/image_skia.h" | 10 #include "ui/gfx/image/image_skia.h" |
| 11 #include "ui/views/controls/button/custom_button.h" | 11 #include "ui/views/controls/button/custom_button.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 | 14 |
| 15 // An image button. | 15 // An image button. |
| 16 | 16 |
| 17 // Note that this type of button is not focusable by default and will not be | 17 // Note that this type of button is not focusable by default and will not be |
| 18 // part of the focus chain. Call set_focusable(true) to make it part of the | 18 // part of the focus chain. Call set_focusable(true) to make it part of the |
| 19 // focus chain. | 19 // focus chain. |
| 20 | 20 |
| 21 class VIEWS_EXPORT ImageButton : public CustomButton { | 21 class VIEWS_EXPORT ImageButton : public CustomButton { |
| 22 public: | 22 public: |
| 23 static const char kViewClassName[]; |
| 24 |
| 23 enum HorizontalAlignment { | 25 enum HorizontalAlignment { |
| 24 ALIGN_LEFT = 0, | 26 ALIGN_LEFT = 0, |
| 25 ALIGN_CENTER, | 27 ALIGN_CENTER, |
| 26 ALIGN_RIGHT | 28 ALIGN_RIGHT |
| 27 }; | 29 }; |
| 28 | 30 |
| 29 enum VerticalAlignment { | 31 enum VerticalAlignment { |
| 30 ALIGN_TOP = 0, | 32 ALIGN_TOP = 0, |
| 31 ALIGN_MIDDLE, | 33 ALIGN_MIDDLE, |
| 32 ALIGN_BOTTOM | 34 ALIGN_BOTTOM |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 // Set an |image| to draw on top of the normal / hot / pushed image. | 51 // Set an |image| to draw on top of the normal / hot / pushed image. |
| 50 // Pass NULL for no image. | 52 // Pass NULL for no image. |
| 51 void SetOverlayImage(const gfx::ImageSkia* image); | 53 void SetOverlayImage(const gfx::ImageSkia* image); |
| 52 | 54 |
| 53 // Sets how the image is laid out within the button's bounds. | 55 // Sets how the image is laid out within the button's bounds. |
| 54 void SetImageAlignment(HorizontalAlignment h_align, | 56 void SetImageAlignment(HorizontalAlignment h_align, |
| 55 VerticalAlignment v_align); | 57 VerticalAlignment v_align); |
| 56 | 58 |
| 57 // Overridden from View: | 59 // Overridden from View: |
| 58 virtual gfx::Size GetPreferredSize() OVERRIDE; | 60 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 61 virtual const char* GetClassName() const OVERRIDE; |
| 59 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 62 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 60 | 63 |
| 61 // Sets preferred size, so it could be correctly positioned in layout even if | 64 // Sets preferred size, so it could be correctly positioned in layout even if |
| 62 // it is NULL. | 65 // it is NULL. |
| 63 void SetPreferredSize(const gfx::Size& preferred_size) { | 66 void SetPreferredSize(const gfx::Size& preferred_size) { |
| 64 preferred_size_ = preferred_size; | 67 preferred_size_ = preferred_size; |
| 65 } | 68 } |
| 66 | 69 |
| 67 protected: | 70 protected: |
| 68 // Returns the image to paint. This is invoked from paint and returns a value | 71 // Returns the image to paint. This is invoked from paint and returns a value |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // The parent class's tooltip_text_ is displayed when not toggled, and | 143 // The parent class's tooltip_text_ is displayed when not toggled, and |
| 141 // this one is shown when toggled. | 144 // this one is shown when toggled. |
| 142 string16 toggled_tooltip_text_; | 145 string16 toggled_tooltip_text_; |
| 143 | 146 |
| 144 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 147 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
| 145 }; | 148 }; |
| 146 | 149 |
| 147 } // namespace views | 150 } // namespace views |
| 148 | 151 |
| 149 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 152 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| OLD | NEW |