Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: ui/views/controls/menu/native_menu_win.cc

Issue 10437006: Converts ui/views/controls, ui/views/examples, ui/base/models to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/views/controls/menu/native_menu_win.h" 5 #include "ui/views/controls/menu/native_menu_win.h"
6 6
7 #include <Windowsx.h> 7 #include <Windowsx.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/win/wrapped_window_proc.h" 14 #include "base/win/wrapped_window_proc.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "ui/gfx/image/image_skia.h"
msw 2012/05/29 07:50:51 nit: alphabetize.
16 #include "ui/base/accelerators/accelerator.h" 16 #include "ui/base/accelerators/accelerator.h"
17 #include "ui/base/keycodes/keyboard_codes.h" 17 #include "ui/base/keycodes/keyboard_codes.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/l10n/l10n_util_win.h" 19 #include "ui/base/l10n/l10n_util_win.h"
20 #include "ui/base/models/menu_model.h" 20 #include "ui/base/models/menu_model.h"
21 #include "ui/base/win/hwnd_util.h" 21 #include "ui/base/win/hwnd_util.h"
22 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/font.h" 23 #include "ui/gfx/font.h"
24 #include "ui/base/native_theme/native_theme.h" 24 #include "ui/base/native_theme/native_theme.h"
25 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 DrawTextEx(dc, const_cast<wchar_t*>(accel.data()), 245 DrawTextEx(dc, const_cast<wchar_t*>(accel.data()),
246 static_cast<int>(accel.size()), &rect, 246 static_cast<int>(accel.size()), &rect,
247 format | DT_RIGHT, NULL); 247 format | DT_RIGHT, NULL);
248 SelectObject(dc, old_font); 248 SelectObject(dc, old_font);
249 249
250 ui::MenuModel::ItemType type = 250 ui::MenuModel::ItemType type =
251 data->native_menu_win->model_->GetTypeAt(data->model_index); 251 data->native_menu_win->model_->GetTypeAt(data->model_index);
252 252
253 // Draw the icon after the label, otherwise it would be covered 253 // Draw the icon after the label, otherwise it would be covered
254 // by the label. 254 // by the label.
255 SkBitmap icon; 255 gfx::ImageSkia icon;
256 if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) { 256 if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) {
257 // We currently don't support items with both icons and checkboxes. 257 // We currently don't support items with both icons and checkboxes.
258 DCHECK(type != ui::MenuModel::TYPE_CHECK); 258 DCHECK(type != ui::MenuModel::TYPE_CHECK);
259 gfx::Canvas canvas(icon, false); 259 gfx::Canvas canvas(icon, false);
260 skia::DrawToNativeContext( 260 skia::DrawToNativeContext(
261 canvas.sk_canvas(), dc, 261 canvas.sk_canvas(), dc,
262 draw_item_struct->rcItem.left + kItemLeftMargin, 262 draw_item_struct->rcItem.left + kItemLeftMargin,
263 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom - 263 draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
264 draw_item_struct->rcItem.top - icon.height()) / 2, NULL); 264 draw_item_struct->rcItem.top - icon.height()) / 2, NULL);
265 } else if (type == ui::MenuModel::TYPE_CHECK && 265 } else if (type == ui::MenuModel::TYPE_CHECK &&
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 748
749 //////////////////////////////////////////////////////////////////////////////// 749 ////////////////////////////////////////////////////////////////////////////////
750 // MenuWrapper, public: 750 // MenuWrapper, public:
751 751
752 // static 752 // static
753 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { 753 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) {
754 return new NativeMenuWin(model, NULL); 754 return new NativeMenuWin(model, NULL);
755 } 755 }
756 756
757 } // namespace views 757 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698