| OLD | NEW |
| 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 CHROME_VIEWS_IMAGE_VIEW_H__ | 5 #ifndef CHROME_VIEWS_IMAGE_VIEW_H__ |
| 6 #define CHROME_VIEWS_IMAGE_VIEW_H__ | 6 #define CHROME_VIEWS_IMAGE_VIEW_H__ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "chrome/views/view.h" | 10 #include "chrome/views/view.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Set the bitmap that should be displayed from a pointer. Reset the image | 41 // Set the bitmap that should be displayed from a pointer. Reset the image |
| 42 // if the pointer is NULL. The pointer contents is copied in the receiver's | 42 // if the pointer is NULL. The pointer contents is copied in the receiver's |
| 43 // bitmap. | 43 // bitmap. |
| 44 void SetImage(SkBitmap* bm); | 44 void SetImage(SkBitmap* bm); |
| 45 | 45 |
| 46 // Returns the bitmap currently displayed or NULL of none is currently set. | 46 // Returns the bitmap currently displayed or NULL of none is currently set. |
| 47 // The returned bitmap is still owned by the ImageView. | 47 // The returned bitmap is still owned by the ImageView. |
| 48 const SkBitmap& GetImage(); | 48 const SkBitmap& GetImage(); |
| 49 | 49 |
| 50 // Set the desired image size for the receiving ImageView. | 50 // Set the desired image size for the receiving ImageView. |
| 51 void SetImageSize(const CSize& image_size); | 51 void SetImageSize(const gfx::Size& image_size); |
| 52 | 52 |
| 53 // Return the preferred size for the receiving view. Returns false if the | 53 // Return the preferred size for the receiving view. Returns false if the |
| 54 // preferred size is not defined, which means that the view uses the image | 54 // preferred size is not defined, which means that the view uses the image |
| 55 // size. | 55 // size. |
| 56 bool GetImageSize(CSize* image_size); | 56 bool GetImageSize(gfx::Size* image_size); |
| 57 | 57 |
| 58 // Reset the image size to the current image dimensions. | 58 // Reset the image size to the current image dimensions. |
| 59 void ResetImageSize(); | 59 void ResetImageSize(); |
| 60 | 60 |
| 61 // Set / Get the horizontal alignment. | 61 // Set / Get the horizontal alignment. |
| 62 void SetHorizontalAlignment(Alignment ha); | 62 void SetHorizontalAlignment(Alignment ha); |
| 63 Alignment GetHorizontalAlignment(); | 63 Alignment GetHorizontalAlignment(); |
| 64 | 64 |
| 65 // Set / Get the vertical alignment. | 65 // Set / Get the vertical alignment. |
| 66 void SetVerticalAlignment(Alignment va); | 66 void SetVerticalAlignment(Alignment va); |
| 67 Alignment GetVerticalAlignment(); | 67 Alignment GetVerticalAlignment(); |
| 68 | 68 |
| 69 // Set / Get the tooltip text. | 69 // Set / Get the tooltip text. |
| 70 void SetTooltipText(const std::wstring& tooltip); | 70 void SetTooltipText(const std::wstring& tooltip); |
| 71 std::wstring GetTooltipText(); | 71 std::wstring GetTooltipText(); |
| 72 | 72 |
| 73 // Return whether the image should be centered inside the view. | 73 // Return whether the image should be centered inside the view. |
| 74 // Overriden from View | 74 // Overriden from View |
| 75 virtual void GetPreferredSize(CSize* out); | 75 virtual gfx::Size GetPreferredSize(); |
| 76 virtual void Paint(ChromeCanvas* canvas); | 76 virtual void Paint(ChromeCanvas* canvas); |
| 77 | 77 |
| 78 // Overriden from View. | 78 // Overriden from View. |
| 79 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); | 79 virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // Compute the image origin given the desired size and the receiver alignment | 82 // Compute the image origin given the desired size and the receiver alignment |
| 83 // properties. | 83 // properties. |
| 84 void ComputeImageOrigin(int image_width, int image_height, int *x, int *y); | 84 void ComputeImageOrigin(int image_width, int image_height, int *x, int *y); |
| 85 | 85 |
| 86 // Whether the image size is set. | 86 // Whether the image size is set. |
| 87 bool image_size_set_; | 87 bool image_size_set_; |
| 88 | 88 |
| 89 // The actual image size. | 89 // The actual image size. |
| 90 CSize image_size_; | 90 gfx::Size image_size_; |
| 91 | 91 |
| 92 // The underlying bitmap. | 92 // The underlying bitmap. |
| 93 SkBitmap image_; | 93 SkBitmap image_; |
| 94 | 94 |
| 95 // Horizontal alignment. | 95 // Horizontal alignment. |
| 96 Alignment horiz_alignment_; | 96 Alignment horiz_alignment_; |
| 97 | 97 |
| 98 // Vertical alignment. | 98 // Vertical alignment. |
| 99 Alignment vert_alignment_; | 99 Alignment vert_alignment_; |
| 100 | 100 |
| 101 // The current tooltip text. | 101 // The current tooltip text. |
| 102 std::wstring tooltip_text_; | 102 std::wstring tooltip_text_; |
| 103 | 103 |
| 104 DISALLOW_EVIL_CONSTRUCTORS(ImageView); | 104 DISALLOW_EVIL_CONSTRUCTORS(ImageView); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } | 107 } |
| 108 | 108 |
| 109 #endif // CHROME_VIEWS_IMAGE_VIEW_H__ | 109 #endif // CHROME_VIEWS_IMAGE_VIEW_H__ |
| 110 | 110 |
| OLD | NEW |