| 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_IMAGE_VIEW_H_ | 5 #ifndef UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ |
| 6 #define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ | 6 #define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include "ui/gfx/image/image_skia.h" | 8 #include "ui/gfx/image/image_skia.h" |
| 9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 ///////////////////////////////////////////////////////////////////////////// | 28 ///////////////////////////////////////////////////////////////////////////// |
| 29 class VIEWS_EXPORT ImageView : public View { | 29 class VIEWS_EXPORT ImageView : public View { |
| 30 public: | 30 public: |
| 31 enum Alignment { | 31 enum Alignment { |
| 32 LEADING = 0, | 32 LEADING = 0, |
| 33 CENTER, | 33 CENTER, |
| 34 TRAILING | 34 TRAILING |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 ImageView(); | 37 ImageView(); |
| 38 virtual ~ImageView(); | 38 ~ImageView() override; |
| 39 | 39 |
| 40 // Set the image that should be displayed. | 40 // Set the image that should be displayed. |
| 41 void SetImage(const gfx::ImageSkia& img); | 41 void SetImage(const gfx::ImageSkia& img); |
| 42 | 42 |
| 43 // Set the image that should be displayed from a pointer. Reset the image | 43 // Set the image that should be displayed from a pointer. Reset the image |
| 44 // if the pointer is NULL. The pointer contents is copied in the receiver's | 44 // if the pointer is NULL. The pointer contents is copied in the receiver's |
| 45 // image. | 45 // image. |
| 46 void SetImage(const gfx::ImageSkia* image_skia); | 46 void SetImage(const gfx::ImageSkia* image_skia); |
| 47 | 47 |
| 48 // Returns the image currently displayed or NULL of none is currently set. | 48 // Returns the image currently displayed or NULL of none is currently set. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 // Set / Get the tooltip text. | 74 // Set / Get the tooltip text. |
| 75 void SetTooltipText(const base::string16& tooltip); | 75 void SetTooltipText(const base::string16& tooltip); |
| 76 base::string16 GetTooltipText() const; | 76 base::string16 GetTooltipText() const; |
| 77 | 77 |
| 78 void set_interactive(bool interactive) { interactive_ = interactive; } | 78 void set_interactive(bool interactive) { interactive_ = interactive; } |
| 79 | 79 |
| 80 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 80 void SetFocusPainter(scoped_ptr<Painter> focus_painter); |
| 81 | 81 |
| 82 // Overriden from View: | 82 // Overriden from View: |
| 83 virtual gfx::Size GetPreferredSize() const override; | 83 gfx::Size GetPreferredSize() const override; |
| 84 virtual void OnFocus() override; | 84 void OnFocus() override; |
| 85 virtual void OnBlur() override; | 85 void OnBlur() override; |
| 86 virtual void OnPaint(gfx::Canvas* canvas) override; | 86 void OnPaint(gfx::Canvas* canvas) override; |
| 87 virtual void GetAccessibleState(ui::AXViewState* state) override; | 87 void GetAccessibleState(ui::AXViewState* state) override; |
| 88 virtual bool GetTooltipText(const gfx::Point& p, | 88 bool GetTooltipText(const gfx::Point& p, |
| 89 base::string16* tooltip) const override; | 89 base::string16* tooltip) const override; |
| 90 virtual bool CanProcessEventsWithinSubtree() const override; | 90 bool CanProcessEventsWithinSubtree() const override; |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 void OnPaintImage(gfx::Canvas* canvas); | 93 void OnPaintImage(gfx::Canvas* canvas); |
| 94 | 94 |
| 95 // Returns true if |img| is the same as the last image we painted. This is | 95 // Returns true if |img| is the same as the last image we painted. This is |
| 96 // intended to be a quick check, not exhaustive. In other words it's possible | 96 // intended to be a quick check, not exhaustive. In other words it's possible |
| 97 // for this to return false even though the images are in fact equal. | 97 // for this to return false even though the images are in fact equal. |
| 98 bool IsImageEqual(const gfx::ImageSkia& img) const; | 98 bool IsImageEqual(const gfx::ImageSkia& img) const; |
| 99 | 99 |
| 100 // Compute the image origin given the desired size and the receiver alignment | 100 // Compute the image origin given the desired size and the receiver alignment |
| (...skipping 29 matching lines...) Expand all Loading... |
| 130 void* last_painted_bitmap_pixels_; | 130 void* last_painted_bitmap_pixels_; |
| 131 | 131 |
| 132 scoped_ptr<views::Painter> focus_painter_; | 132 scoped_ptr<views::Painter> focus_painter_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(ImageView); | 134 DISALLOW_COPY_AND_ASSIGN(ImageView); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace views | 137 } // namespace views |
| 138 | 138 |
| 139 #endif // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ | 139 #endif // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ |
| OLD | NEW |