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

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

Issue 119025: Add ability to theme our buttons.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 class ImageButton : public CustomButton { 14 class ImageButton : public CustomButton {
15 public: 15 public:
16 explicit ImageButton(ButtonListener* listener); 16 explicit ImageButton(ButtonListener* listener);
17 virtual ~ImageButton(); 17 virtual ~ImageButton();
18 18
19 // Set the image the button should use for the provided state. 19 // Set the image the button should use for the provided state.
20 virtual void SetImage(ButtonState aState, SkBitmap* anImage); 20 virtual void SetImage(ButtonState aState, SkBitmap* anImage);
21 21
22 // Set the background details.
23 virtual void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask);
24
22 enum HorizontalAlignment { ALIGN_LEFT = 0, 25 enum HorizontalAlignment { ALIGN_LEFT = 0,
23 ALIGN_CENTER, 26 ALIGN_CENTER,
24 ALIGN_RIGHT, }; 27 ALIGN_RIGHT, };
25 28
26 enum VerticalAlignment { ALIGN_TOP = 0, 29 enum VerticalAlignment { ALIGN_TOP = 0,
27 ALIGN_MIDDLE, 30 ALIGN_MIDDLE,
28 ALIGN_BOTTOM }; 31 ALIGN_BOTTOM };
29 32
30 // Sets how the image is laid out within the button's bounds. 33 // Sets how the image is laid out within the button's bounds.
31 void SetImageAlignment(HorizontalAlignment h_align, 34 void SetImageAlignment(HorizontalAlignment h_align,
32 VerticalAlignment v_align); 35 VerticalAlignment v_align);
33 36
34 // Overridden from View: 37 // Overridden from View:
35 virtual gfx::Size GetPreferredSize(); 38 virtual gfx::Size GetPreferredSize();
36 virtual void Paint(gfx::Canvas* canvas); 39 virtual void Paint(gfx::Canvas* canvas);
37 40
38 protected: 41 protected:
39 // Returns the image to paint. This is invoked from paint and returns a value 42 // Returns the image to paint. This is invoked from paint and returns a value
40 // from images. 43 // from images.
41 virtual SkBitmap GetImageToPaint(); 44 virtual SkBitmap GetImageToPaint();
42 45
43 // The images used to render the different states of this button. 46 // The images used to render the different states of this button.
44 SkBitmap images_[BS_COUNT]; 47 SkBitmap images_[BS_COUNT];
45 48
49 // The background image.
50 SkBitmap* background_image_;
51
46 private: 52 private:
47 // Image alignment. 53 // Image alignment.
48 HorizontalAlignment h_alignment_; 54 HorizontalAlignment h_alignment_;
49 VerticalAlignment v_alignment_; 55 VerticalAlignment v_alignment_;
50 56
51 DISALLOW_COPY_AND_ASSIGN(ImageButton); 57 DISALLOW_COPY_AND_ASSIGN(ImageButton);
52 }; 58 };
53 59
54 //////////////////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////////////////
55 // 61 //
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // The parent class's tooltip_text_ is displayed when not toggled, and 98 // The parent class's tooltip_text_ is displayed when not toggled, and
93 // this one is shown when toggled. 99 // this one is shown when toggled.
94 std::wstring toggled_tooltip_text_; 100 std::wstring toggled_tooltip_text_;
95 101
96 DISALLOW_EVIL_CONSTRUCTORS(ToggleImageButton); 102 DISALLOW_EVIL_CONSTRUCTORS(ToggleImageButton);
97 }; 103 };
98 104
99 } // namespace views 105 } // namespace views
100 106
101 #endif // VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ 107 #endif // VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698