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

Side by Side Diff: ui/views/controls/button/text_button.h

Issue 9562038: ui/gfx: Make gfx::Canvas inherit from gfx::CanvasSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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) 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_TEXT_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 SkBitmap* top_right; 49 SkBitmap* top_right;
50 SkBitmap* left; 50 SkBitmap* left;
51 SkBitmap* center; 51 SkBitmap* center;
52 SkBitmap* right; 52 SkBitmap* right;
53 SkBitmap* bottom_left; 53 SkBitmap* bottom_left;
54 SkBitmap* bottom; 54 SkBitmap* bottom;
55 SkBitmap* bottom_right; 55 SkBitmap* bottom_right;
56 }; 56 };
57 57
58 void Paint(const View& view, 58 void Paint(const View& view,
59 gfx::Canvas* canvas, 59 gfx::CanvasSkia* canvas,
60 const BorderImageSet& set) const; 60 const BorderImageSet& set) const;
61 61
62 void set_normal_set(const BorderImageSet& set) { normal_set_ = set; } 62 void set_normal_set(const BorderImageSet& set) { normal_set_ = set; }
63 void set_hot_set(const BorderImageSet& set) { hot_set_ = set; } 63 void set_hot_set(const BorderImageSet& set) { hot_set_ = set; }
64 void set_pushed_set(const BorderImageSet& set) { pushed_set_ = set; } 64 void set_pushed_set(const BorderImageSet& set) { pushed_set_ = set; }
65 void set_vertical_padding(int vertical_padding) { 65 void set_vertical_padding(int vertical_padding) {
66 vertical_padding_ = vertical_padding; 66 vertical_padding_ = vertical_padding;
67 } 67 }
68 68
69 private: 69 private:
70 // Border: 70 // Border:
71 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE; 71 virtual void Paint(const View& view, gfx::CanvasSkia* canvas) const OVERRIDE;
72 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; 72 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE;
73 73
74 BorderImageSet normal_set_; 74 BorderImageSet normal_set_;
75 BorderImageSet hot_set_; 75 BorderImageSet hot_set_;
76 BorderImageSet pushed_set_; 76 BorderImageSet pushed_set_;
77 77
78 int vertical_padding_; 78 int vertical_padding_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(TextButtonBorder); 80 DISALLOW_COPY_AND_ASSIGN(TextButtonBorder);
81 }; 81 };
82 82
83 83
84 //////////////////////////////////////////////////////////////////////////////// 84 ////////////////////////////////////////////////////////////////////////////////
85 // 85 //
86 // TextButtonNativeThemeBorder 86 // TextButtonNativeThemeBorder
87 // 87 //
88 // A Border subclass that paints a TextButton's background layer using the 88 // A Border subclass that paints a TextButton's background layer using the
89 // platform's native theme look. This handles normal/disabled/hot/pressed 89 // platform's native theme look. This handles normal/disabled/hot/pressed
90 // states, with possible animation between states. 90 // states, with possible animation between states.
91 // 91 //
92 //////////////////////////////////////////////////////////////////////////////// 92 ////////////////////////////////////////////////////////////////////////////////
93 class VIEWS_EXPORT TextButtonNativeThemeBorder : public Border { 93 class VIEWS_EXPORT TextButtonNativeThemeBorder : public Border {
94 public: 94 public:
95 TextButtonNativeThemeBorder(NativeThemeDelegate* delegate); 95 TextButtonNativeThemeBorder(NativeThemeDelegate* delegate);
96 virtual ~TextButtonNativeThemeBorder(); 96 virtual ~TextButtonNativeThemeBorder();
97 97
98 // Implementation of Border: 98 // Implementation of Border:
99 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE; 99 virtual void Paint(const View& view, gfx::CanvasSkia* canvas) const OVERRIDE;
100 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; 100 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE;
101 101
102 private: 102 private:
103 // The delegate the controls the appearance of this border. 103 // The delegate the controls the appearance of this border.
104 NativeThemeDelegate* delegate_; 104 NativeThemeDelegate* delegate_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(TextButtonNativeThemeBorder); 106 DISALLOW_COPY_AND_ASSIGN(TextButtonNativeThemeBorder);
107 }; 107 };
108 108
109 109
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // (if present) in addition to the normal state. Defaults to true. 191 // (if present) in addition to the normal state. Defaults to true.
192 bool show_multiple_icon_states() const { return show_multiple_icon_states_; } 192 bool show_multiple_icon_states() const { return show_multiple_icon_states_; }
193 void SetShowMultipleIconStates(bool show_multiple_icon_states); 193 void SetShowMultipleIconStates(bool show_multiple_icon_states);
194 194
195 // Clears halo and shadow settings. 195 // Clears halo and shadow settings.
196 void ClearEmbellishing(); 196 void ClearEmbellishing();
197 197
198 // Paint the button into the specified canvas. If |mode| is |PB_FOR_DRAG|, the 198 // Paint the button into the specified canvas. If |mode| is |PB_FOR_DRAG|, the
199 // function paints a drag image representation into the canvas. 199 // function paints a drag image representation into the canvas.
200 enum PaintButtonMode { PB_NORMAL, PB_FOR_DRAG }; 200 enum PaintButtonMode { PB_NORMAL, PB_FOR_DRAG };
201 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode); 201 virtual void PaintButton(gfx::CanvasSkia* canvas, PaintButtonMode mode);
202 202
203 // Overridden from View: 203 // Overridden from View:
204 virtual gfx::Size GetPreferredSize() OVERRIDE; 204 virtual gfx::Size GetPreferredSize() OVERRIDE;
205 virtual gfx::Size GetMinimumSize() OVERRIDE; 205 virtual gfx::Size GetMinimumSize() OVERRIDE;
206 virtual int GetHeightForWidth(int w) OVERRIDE; 206 virtual int GetHeightForWidth(int w) OVERRIDE;
207 virtual void OnEnabledChanged() OVERRIDE; 207 virtual void OnEnabledChanged() OVERRIDE;
208 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 208 virtual void OnPaint(gfx::CanvasSkia* canvas) OVERRIDE;
209 209
210 // Returns views/TextButton. 210 // Returns views/TextButton.
211 virtual std::string GetClassName() const OVERRIDE; 211 virtual std::string GetClassName() const OVERRIDE;
212 212
213 protected: 213 protected:
214 TextButtonBase(ButtonListener* listener, const string16& text); 214 TextButtonBase(ButtonListener* listener, const string16& text);
215 215
216 // Called when enabled or disabled state changes, or the colors for those 216 // Called when enabled or disabled state changes, or the colors for those
217 // states change. 217 // states change.
218 virtual void UpdateColor(); 218 virtual void UpdateColor();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 IconPlacement icon_placement() { return icon_placement_; } 336 IconPlacement icon_placement() { return icon_placement_; }
337 void set_icon_placement(IconPlacement icon_placement) { 337 void set_icon_placement(IconPlacement icon_placement) {
338 icon_placement_ = icon_placement; 338 icon_placement_ = icon_placement;
339 } 339 }
340 340
341 void set_ignore_minimum_size(bool ignore_minimum_size); 341 void set_ignore_minimum_size(bool ignore_minimum_size);
342 342
343 // Overridden from View: 343 // Overridden from View:
344 virtual gfx::Size GetPreferredSize() OVERRIDE; 344 virtual gfx::Size GetPreferredSize() OVERRIDE;
345 virtual std::string GetClassName() const OVERRIDE; 345 virtual std::string GetClassName() const OVERRIDE;
346 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; 346 virtual void OnPaintFocusBorder(gfx::CanvasSkia* canvas) OVERRIDE;
347 347
348 // Overridden from TextButtonBase: 348 // Overridden from TextButtonBase:
349 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE; 349 virtual void PaintButton(gfx::CanvasSkia* canvas,
350 PaintButtonMode mode) OVERRIDE;
350 351
351 protected: 352 protected:
352 SkBitmap icon() const { return icon_; } 353 SkBitmap icon() const { return icon_; }
353 354
354 virtual const SkBitmap& GetImageToPaint() const; 355 virtual const SkBitmap& GetImageToPaint() const;
355 356
356 // Overridden from NativeThemeDelegate: 357 // Overridden from NativeThemeDelegate:
357 virtual gfx::NativeTheme::Part GetThemePart() const OVERRIDE; 358 virtual gfx::NativeTheme::Part GetThemePart() const OVERRIDE;
358 359
359 // Overridden from TextButtonBase: 360 // Overridden from TextButtonBase:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 405
405 // Overridden from TextButton: 406 // Overridden from TextButton:
406 virtual gfx::Size GetMinimumSize() OVERRIDE; 407 virtual gfx::Size GetMinimumSize() OVERRIDE;
407 408
408 virtual std::string GetClassName() const OVERRIDE; 409 virtual std::string GetClassName() const OVERRIDE;
409 410
410 private: 411 private:
411 void Init(); 412 void Init();
412 413
413 // Overridden from View: 414 // Overridden from View:
414 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; 415 virtual void OnPaintFocusBorder(gfx::CanvasSkia* canvas) OVERRIDE;
415 416
416 // Overridden from TextButton: 417 // Overridden from TextButton:
417 virtual void GetExtraParams( 418 virtual void GetExtraParams(
418 gfx::NativeTheme::ExtraParams* params) const OVERRIDE; 419 gfx::NativeTheme::ExtraParams* params) const OVERRIDE;
419 420
420 DISALLOW_COPY_AND_ASSIGN(NativeTextButton); 421 DISALLOW_COPY_AND_ASSIGN(NativeTextButton);
421 }; 422 };
422 423
423 } // namespace views 424 } // namespace views
424 425
425 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 426 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698