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 #include "chrome/browser/drag_utils.h" | 5 #include "chrome/browser/drag_utils.h" |
6 | 6 |
7 #include <objidl.h> | 7 #include <objidl.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
10 | 10 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 // Create a button to render the drag image for us. | 142 // Create a button to render the drag image for us. |
143 ChromeViews::TextButton button( | 143 ChromeViews::TextButton button( |
144 title.empty() ? UTF8ToWide(url.spec()) : title); | 144 title.empty() ? UTF8ToWide(url.spec()) : title); |
145 button.set_max_width(BookmarkBarView::kMaxButtonWidth); | 145 button.set_max_width(BookmarkBarView::kMaxButtonWidth); |
146 if (icon.isNull()) { | 146 if (icon.isNull()) { |
147 button.SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | 147 button.SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( |
148 IDR_DEFAULT_FAVICON)); | 148 IDR_DEFAULT_FAVICON)); |
149 } else { | 149 } else { |
150 button.SetIcon(icon); | 150 button.SetIcon(icon); |
151 } | 151 } |
152 CSize pref; | 152 gfx::Size prefsize = button.GetPreferredSize(); |
153 button.GetPreferredSize(&pref); | 153 button.SetBounds(gfx::Point(), prefsize); |
154 button.SetBounds(0, 0, pref.cx, pref.cy); | |
155 | 154 |
156 // Render the image. | 155 // Render the image. |
157 ChromeCanvas canvas(pref.cx, pref.cy, false); | 156 ChromeCanvas canvas(prefsize.width(), prefsize.height(), false); |
Elliot Glaysher
2008/10/15 17:21:46
Can ChromeCanvas take a gfx::Size?
Ben Goodger (Google)
2008/10/15 17:37:32
I looked at the users of Canvas. Most of them aren
| |
158 button.Paint(&canvas, true); | 157 button.Paint(&canvas, true); |
159 SetDragImageOnDataObject(canvas, pref.cx, pref.cy, pref.cx / 2, pref.cy / 2, | 158 SetDragImageOnDataObject(canvas, prefsize.width(), prefsize.height(), |
159 prefsize.width() / 2, prefsize.height() / 2, | |
160 data); | 160 data); |
161 } | 161 } |
162 | 162 |
163 void CreateDragImageForFile(const std::wstring& file_name, | 163 void CreateDragImageForFile(const std::wstring& file_name, |
164 SkBitmap* icon, | 164 SkBitmap* icon, |
165 IDataObject* data_object) { | 165 IDataObject* data_object) { |
166 DCHECK(icon); | 166 DCHECK(icon); |
167 DCHECK(data_object); | 167 DCHECK(data_object); |
168 | 168 |
169 // Set up our text portion | 169 // Set up our text portion |
(...skipping 29 matching lines...) Expand all Loading... | |
199 | 199 |
200 // Attach 'bitmap' to the data_object. | 200 // Attach 'bitmap' to the data_object. |
201 SetDragImageOnDataObject(bitmap, width, height, | 201 SetDragImageOnDataObject(bitmap, width, height, |
202 cursor_x_offset, | 202 cursor_x_offset, |
203 cursor_y_offset, | 203 cursor_y_offset, |
204 data_object); | 204 data_object); |
205 } | 205 } |
206 | 206 |
207 } // namespace drag_utils | 207 } // namespace drag_utils |
208 | 208 |
OLD | NEW |