| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "views/drag_utils.h" | 5 #include "views/drag_utils.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 const int width = kFileDragImageMaxWidth; | 68 const int width = kFileDragImageMaxWidth; |
| 69 // Add +2 here to allow room for the halo. | 69 // Add +2 here to allow room for the halo. |
| 70 const int height = font.GetHeight() + icon->height() + | 70 const int height = font.GetHeight() + icon->height() + |
| 71 kLinkDragImageVPadding + 2; | 71 kLinkDragImageVPadding + 2; |
| 72 gfx::CanvasSkia canvas(width, height, false /* translucent */); | 72 gfx::CanvasSkia canvas(width, height, false /* translucent */); |
| 73 | 73 |
| 74 // Paint the icon. | 74 // Paint the icon. |
| 75 canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0); | 75 canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0); |
| 76 | 76 |
| 77 std::wstring name = UTF16ToWide(file_name.BaseName().LossyDisplayName()); | 77 string16 name = file_name.BaseName().LossyDisplayName(); |
| 78 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
| 79 // Paint the file name. We inset it one pixel to allow room for the halo. | 79 // Paint the file name. We inset it one pixel to allow room for the halo. |
| 80 canvas.DrawStringWithHalo(name, font, kFileDragImageTextColor, SK_ColorWHITE, | 80 canvas.DrawStringWithHalo(name, font, kFileDragImageTextColor, SK_ColorWHITE, |
| 81 1, icon->height() + kLinkDragImageVPadding + 1, | 81 1, icon->height() + kLinkDragImageVPadding + 1, |
| 82 width - 2, font.GetHeight(), | 82 width - 2, font.GetHeight(), |
| 83 gfx::Canvas::TEXT_ALIGN_CENTER); | 83 gfx::Canvas::TEXT_ALIGN_CENTER); |
| 84 #else | 84 #else |
| 85 canvas.DrawStringInt(WideToUTF16Hack(name), font, kFileDragImageTextColor, | 85 canvas.DrawStringInt(name, font, kFileDragImageTextColor, |
| 86 0, icon->height() + kLinkDragImageVPadding, | 86 0, icon->height() + kLinkDragImageVPadding, |
| 87 width, font.GetHeight(), gfx::Canvas::TEXT_ALIGN_CENTER); | 87 width, font.GetHeight(), gfx::Canvas::TEXT_ALIGN_CENTER); |
| 88 #endif | 88 #endif |
| 89 | 89 |
| 90 SetDragImageOnDataObject(canvas, gfx::Size(width, height), | 90 SetDragImageOnDataObject(canvas, gfx::Size(width, height), |
| 91 gfx::Point(width / 2, kLinkDragImageVPadding), | 91 gfx::Point(width / 2, kLinkDragImageVPadding), |
| 92 data_object); | 92 data_object); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void SetDragImageOnDataObject(const gfx::Canvas& canvas, | 95 void SetDragImageOnDataObject(const gfx::Canvas& canvas, |
| 96 const gfx::Size& size, | 96 const gfx::Size& size, |
| 97 const gfx::Point& cursor_offset, | 97 const gfx::Point& cursor_offset, |
| 98 OSExchangeData* data_object) { | 98 OSExchangeData* data_object) { |
| 99 SetDragImageOnDataObject( | 99 SetDragImageOnDataObject( |
| 100 canvas.AsCanvasSkia()->ExtractBitmap(), size, cursor_offset, data_object); | 100 canvas.AsCanvasSkia()->ExtractBitmap(), size, cursor_offset, data_object); |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace drag_utils | 103 } // namespace drag_utils |
| OLD | NEW |