OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/controls/menu/menu_separator.h" | 5 #include "views/controls/menu/menu_separator.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <uxtheme.h> | 8 #include <uxtheme.h> |
9 #include <Vssym32.h> | 9 #include <Vssym32.h> |
10 | 10 |
11 #include "gfx/canvas_skia.h" | 11 #include "gfx/canvas.h" |
12 #include "gfx/native_theme_win.h" | 12 #include "gfx/native_theme_win.h" |
13 #include "views/controls/menu/menu_config.h" | 13 #include "views/controls/menu/menu_config.h" |
14 #include "views/controls/menu/menu_item_view.h" | 14 #include "views/controls/menu/menu_item_view.h" |
15 | 15 |
16 namespace views { | 16 namespace views { |
17 | 17 |
18 void MenuSeparator::Paint(gfx::Canvas* canvas) { | 18 void MenuSeparator::Paint(gfx::Canvas* canvas) { |
19 const MenuConfig& config = MenuConfig::instance(); | 19 const MenuConfig& config = MenuConfig::instance(); |
20 // The gutter is rendered before the background. | 20 // The gutter is rendered before the background. |
21 int start_x = 0; | 21 int start_x = 0; |
22 int start_y = height() / 3; | 22 int start_y = height() / 3; |
23 HDC dc = canvas->AsCanvasSkia()->beginPlatformPaint(); | 23 HDC dc = canvas->beginPlatformPaint(); |
24 if (config.render_gutter) { | 24 if (config.render_gutter) { |
25 // If render_gutter is true, we're on Vista and need to render the | 25 // If render_gutter is true, we're on Vista and need to render the |
26 // gutter, then indent the separator from the gutter. | 26 // gutter, then indent the separator from the gutter. |
27 RECT gutter_bounds = { MenuItemView::label_start() - | 27 RECT gutter_bounds = { MenuItemView::label_start() - |
28 config.gutter_to_label - config.gutter_width, 0, 0, | 28 config.gutter_to_label - config.gutter_width, 0, 0, |
29 height() }; | 29 height() }; |
30 gutter_bounds.right = gutter_bounds.left + config.gutter_width; | 30 gutter_bounds.right = gutter_bounds.left + config.gutter_width; |
31 gfx::NativeTheme::instance()->PaintMenuGutter(dc, MENU_POPUPGUTTER, | 31 gfx::NativeTheme::instance()->PaintMenuGutter(dc, MENU_POPUPGUTTER, |
32 MPI_NORMAL, &gutter_bounds); | 32 MPI_NORMAL, &gutter_bounds); |
33 start_x = gutter_bounds.left + config.gutter_width; | 33 start_x = gutter_bounds.left + config.gutter_width; |
34 start_y = 0; | 34 start_y = 0; |
35 } | 35 } |
36 RECT separator_bounds = { start_x, start_y, width(), height() }; | 36 RECT separator_bounds = { start_x, start_y, width(), height() }; |
37 gfx::NativeTheme::instance()->PaintMenuSeparator( | 37 gfx::NativeTheme::instance()->PaintMenuSeparator( |
38 dc, MENU_POPUPSEPARATOR, MPI_NORMAL, &separator_bounds); | 38 dc, MENU_POPUPSEPARATOR, MPI_NORMAL, &separator_bounds); |
39 canvas->AsCanvasSkia()->endPlatformPaint(); | 39 canvas->endPlatformPaint(); |
40 } | 40 } |
41 | 41 |
42 gfx::Size MenuSeparator::GetPreferredSize() { | 42 gfx::Size MenuSeparator::GetPreferredSize() { |
43 return gfx::Size(10, // Just in case we're the only item in a menu. | 43 return gfx::Size(10, // Just in case we're the only item in a menu. |
44 MenuConfig::instance().separator_height); | 44 MenuConfig::instance().separator_height); |
45 } | 45 } |
46 | 46 |
47 } // namespace views | 47 } // namespace views |
OLD | NEW |