| 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 FileDragImageSource(const FilePath& file_name, const gfx::ImageSkia& icon) | 32 FileDragImageSource(const FilePath& file_name, const gfx::ImageSkia& icon) |
| 33 : CanvasImageSource(CalculateSize(icon), false), | 33 : CanvasImageSource(CalculateSize(icon), false), |
| 34 file_name_(file_name), | 34 file_name_(file_name), |
| 35 icon_(icon) { | 35 icon_(icon) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual ~FileDragImageSource() { | 38 virtual ~FileDragImageSource() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Overridden from gfx::CanvasImageSource. | 41 // Overridden from gfx::CanvasImageSource. |
| 42 void Draw(gfx::Canvas* canvas) OVERRIDE { | 42 virtual void Draw(gfx::Canvas* canvas) OVERRIDE { |
| 43 // Set up our text portion | 43 // Set up our text portion |
| 44 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 44 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 45 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); | 45 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); |
| 46 | 46 |
| 47 // Paint the icon. | 47 // Paint the icon. |
| 48 canvas->DrawImageInt(icon_, (size().width() - icon_.width()) / 2, 0); | 48 canvas->DrawImageInt(icon_, (size().width() - icon_.width()) / 2, 0); |
| 49 | 49 |
| 50 string16 name = file_name_.BaseName().LossyDisplayName(); | 50 string16 name = file_name_.BaseName().LossyDisplayName(); |
| 51 const int flags = gfx::Canvas::TEXT_ALIGN_CENTER; | 51 const int flags = gfx::Canvas::TEXT_ALIGN_CENTER; |
| 52 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
| (...skipping 47 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::Point& cursor_offset, | 103 const gfx::Point& 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 |