Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: views/controls/button/image_button.h

Issue 2418003: Added const to image parameters for ImageButton class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | views/controls/button/image_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 7
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "views/controls/button/custom_button.h" 9 #include "views/controls/button/custom_button.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 // An image button. 13 // An image button.
14 14
15 // Note that this type of button is not focusable by default and will not be 15 // Note that this type of button is not focusable by default and will not be
16 // part of the focus chain. Call SetFocusable(true) to make it part of the 16 // part of the focus chain. Call SetFocusable(true) to make it part of the
17 // focus chain. 17 // focus chain.
18 18
19 class ImageButton : public CustomButton { 19 class ImageButton : public CustomButton {
20 public: 20 public:
21 explicit ImageButton(ButtonListener* listener); 21 explicit ImageButton(ButtonListener* listener);
22 virtual ~ImageButton(); 22 virtual ~ImageButton();
23 23
24 // Set the image the button should use for the provided state. 24 // Set the image the button should use for the provided state.
25 virtual void SetImage(ButtonState aState, SkBitmap* anImage); 25 virtual void SetImage(ButtonState aState, const SkBitmap* anImage);
26 26
27 // Set the background details. 27 // Set the background details.
28 virtual void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); 28 void SetBackground(SkColor color,
29 const SkBitmap* image,
30 const SkBitmap* mask);
29 31
30 enum HorizontalAlignment { ALIGN_LEFT = 0, 32 enum HorizontalAlignment { ALIGN_LEFT = 0,
31 ALIGN_CENTER, 33 ALIGN_CENTER,
32 ALIGN_RIGHT, }; 34 ALIGN_RIGHT, };
33 35
34 enum VerticalAlignment { ALIGN_TOP = 0, 36 enum VerticalAlignment { ALIGN_TOP = 0,
35 ALIGN_MIDDLE, 37 ALIGN_MIDDLE,
36 ALIGN_BOTTOM }; 38 ALIGN_BOTTOM };
37 39
38 // Sets how the image is laid out within the button's bounds. 40 // Sets how the image is laid out within the button's bounds.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // 72 //
71 //////////////////////////////////////////////////////////////////////////////// 73 ////////////////////////////////////////////////////////////////////////////////
72 class ToggleImageButton : public ImageButton { 74 class ToggleImageButton : public ImageButton {
73 public: 75 public:
74 explicit ToggleImageButton(ButtonListener* listener); 76 explicit ToggleImageButton(ButtonListener* listener);
75 virtual ~ToggleImageButton(); 77 virtual ~ToggleImageButton();
76 78
77 // Change the toggled state. 79 // Change the toggled state.
78 void SetToggled(bool toggled); 80 void SetToggled(bool toggled);
79 81
80 // Like Button::SetImage(), but to set the graphics used for the 82 // Like ImageButton::SetImage(), but to set the graphics used for the
81 // "has been toggled" state. Must be called for each button state 83 // "has been toggled" state. Must be called for each button state
82 // before the button is toggled. 84 // before the button is toggled.
83 void SetToggledImage(ButtonState state, SkBitmap* image); 85 void SetToggledImage(ButtonState state, const SkBitmap* image);
84 86
85 // Set the tooltip text displayed when the button is toggled. 87 // Set the tooltip text displayed when the button is toggled.
86 void SetToggledTooltipText(const std::wstring& tooltip); 88 void SetToggledTooltipText(const std::wstring& tooltip);
87 89
88 // Overridden from ImageButton: 90 // Overridden from ImageButton:
89 virtual void SetImage(ButtonState aState, SkBitmap* anImage); 91 virtual void SetImage(ButtonState aState, const SkBitmap* anImage);
90 92
91 // Overridden from View: 93 // Overridden from View:
92 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); 94 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip);
93 95
94 private: 96 private:
95 // The parent class's images_ member is used for the current images, 97 // The parent class's images_ member is used for the current images,
96 // and this array is used to hold the alternative images. 98 // and this array is used to hold the alternative images.
97 // We swap between the two when toggling. 99 // We swap between the two when toggling.
98 SkBitmap alternate_images_[BS_COUNT]; 100 SkBitmap alternate_images_[BS_COUNT];
99 101
100 // True if the button is currently toggled. 102 // True if the button is currently toggled.
101 bool toggled_; 103 bool toggled_;
102 104
103 // The parent class's tooltip_text_ is displayed when not toggled, and 105 // The parent class's tooltip_text_ is displayed when not toggled, and
104 // this one is shown when toggled. 106 // this one is shown when toggled.
105 std::wstring toggled_tooltip_text_; 107 std::wstring toggled_tooltip_text_;
106 108
107 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); 109 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton);
108 }; 110 };
109 111
110 } // namespace views 112 } // namespace views
111 113
112 #endif // VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ 114 #endif // VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | views/controls/button/image_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698