| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 5 #ifndef VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| 6 #define VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 6 #define VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "views/controls/button/custom_button.h" | 10 #include "views/controls/button/custom_button.h" |
| 11 | 11 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 enum VerticalAlignment { ALIGN_TOP = 0, | 37 enum VerticalAlignment { ALIGN_TOP = 0, |
| 38 ALIGN_MIDDLE, | 38 ALIGN_MIDDLE, |
| 39 ALIGN_BOTTOM }; | 39 ALIGN_BOTTOM }; |
| 40 | 40 |
| 41 // Sets how the image is laid out within the button's bounds. | 41 // Sets how the image is laid out within the button's bounds. |
| 42 void SetImageAlignment(HorizontalAlignment h_align, | 42 void SetImageAlignment(HorizontalAlignment h_align, |
| 43 VerticalAlignment v_align); | 43 VerticalAlignment v_align); |
| 44 | 44 |
| 45 // Overridden from View: | 45 // Overridden from View: |
| 46 virtual gfx::Size GetPreferredSize(); | 46 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 47 virtual void OnPaint(gfx::Canvas* canvas); | |
| 48 | 47 |
| 49 // Sets preferred size, so it could be correctly positioned in layout even if | 48 // Sets preferred size, so it could be correctly positioned in layout even if |
| 50 // it is NULL. | 49 // it is NULL. |
| 51 void SetPreferredSize(const gfx::Size& preferred_size) { | 50 void SetPreferredSize(const gfx::Size& preferred_size) { |
| 52 preferred_size_ = preferred_size; | 51 preferred_size_ = preferred_size; |
| 53 } | 52 } |
| 54 | 53 |
| 55 protected: | 54 protected: |
| 56 // Returns the image to paint. This is invoked from paint and returns a value | 55 // Returns the image to paint. This is invoked from paint and returns a value |
| 57 // from images. | 56 // from images. |
| 58 virtual SkBitmap GetImageToPaint(); | 57 virtual SkBitmap GetImageToPaint(); |
| 59 | 58 |
| 59 // Overridden from View: |
| 60 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 61 |
| 60 // The images used to render the different states of this button. | 62 // The images used to render the different states of this button. |
| 61 SkBitmap images_[BS_COUNT]; | 63 SkBitmap images_[BS_COUNT]; |
| 62 | 64 |
| 63 // The background image. | 65 // The background image. |
| 64 SkBitmap background_image_; | 66 SkBitmap background_image_; |
| 65 | 67 |
| 66 private: | 68 private: |
| 67 // Image alignment. | 69 // Image alignment. |
| 68 HorizontalAlignment h_alignment_; | 70 HorizontalAlignment h_alignment_; |
| 69 VerticalAlignment v_alignment_; | 71 VerticalAlignment v_alignment_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // The parent class's tooltip_text_ is displayed when not toggled, and | 115 // The parent class's tooltip_text_ is displayed when not toggled, and |
| 114 // this one is shown when toggled. | 116 // this one is shown when toggled. |
| 115 string16 toggled_tooltip_text_; | 117 string16 toggled_tooltip_text_; |
| 116 | 118 |
| 117 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 119 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 } // namespace views | 122 } // namespace views |
| 121 | 123 |
| 122 #endif // VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 124 #endif // VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| OLD | NEW |