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 #include "ui/base/dragdrop/drag_utils.h" | 5 #include "ui/base/dragdrop/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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // Overridden from gfx::CanvasImageSource. | 42 // Overridden from gfx::CanvasImageSource. |
43 virtual void Draw(gfx::Canvas* canvas) OVERRIDE { | 43 virtual void Draw(gfx::Canvas* canvas) OVERRIDE { |
44 // Set up our text portion | 44 // Set up our text portion |
45 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 45 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
46 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); | 46 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); |
47 | 47 |
48 // Paint the icon. | 48 // Paint the icon. |
49 canvas->DrawImageInt(icon_, (size().width() - icon_.width()) / 2, 0); | 49 canvas->DrawImageInt(icon_, (size().width() - icon_.width()) / 2, 0); |
50 | 50 |
51 string16 name = file_name_.BaseName().LossyDisplayName(); | 51 base::string16 name = file_name_.BaseName().LossyDisplayName(); |
52 const int flags = gfx::Canvas::TEXT_ALIGN_CENTER; | 52 const int flags = gfx::Canvas::TEXT_ALIGN_CENTER; |
53 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
54 // Paint the file name. We inset it one pixel to allow room for the halo. | 54 // Paint the file name. We inset it one pixel to allow room for the halo. |
55 canvas->DrawStringWithHalo(name, font, kFileDragImageTextColor, | 55 canvas->DrawStringWithHalo(name, font, kFileDragImageTextColor, |
56 SK_ColorWHITE, 1, | 56 SK_ColorWHITE, 1, |
57 icon_.height() + kLinkDragImageVPadding + 1, | 57 icon_.height() + kLinkDragImageVPadding + 1, |
58 size().width() - 2, font.GetHeight(), flags); | 58 size().width() - 2, font.GetHeight(), flags); |
59 #else | 59 #else |
60 // NO_SUBPIXEL_RENDERING is required when drawing to a non-opaque canvas. | 60 // NO_SUBPIXEL_RENDERING is required when drawing to a non-opaque canvas. |
61 canvas->DrawStringInt(name, font, kFileDragImageTextColor, | 61 canvas->DrawStringInt(name, font, kFileDragImageTextColor, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 void SetDragImageOnDataObject(const gfx::Canvas& canvas, | 101 void SetDragImageOnDataObject(const gfx::Canvas& canvas, |
102 const gfx::Size& size, | 102 const gfx::Size& size, |
103 const gfx::Vector2d& cursor_offset, | 103 const gfx::Vector2d& cursor_offset, |
104 ui::OSExchangeData* data_object) { | 104 ui::OSExchangeData* data_object) { |
105 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep()); | 105 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep()); |
106 SetDragImageOnDataObject(image, size, cursor_offset, data_object); | 106 SetDragImageOnDataObject(image, size, cursor_offset, data_object); |
107 } | 107 } |
108 | 108 |
109 } // namespace drag_utils | 109 } // namespace drag_utils |
OLD | NEW |