Add ICU message format support
[chromium-blink-merge.git] / ui / views / controls / menu / menu_separator_win.cc
blobebbb38c882a587f354773fe8c517085fca794bd8
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
3 // found in the LICENSE file.
5 #include "ui/views/controls/menu/menu_separator.h"
7 #include <windows.h>
8 #include <uxtheme.h>
9 #include <Vssym32.h>
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/win/dpi.h"
14 #include "ui/native_theme/native_theme.h"
15 #include "ui/native_theme/native_theme_aura.h"
16 #include "ui/views/controls/menu/menu_config.h"
17 #include "ui/views/controls/menu/menu_item_view.h"
19 namespace views {
21 void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
22 const MenuConfig& config = parent_menu_item_->GetMenuConfig();
24 if (config.native_theme == ui::NativeThemeAura::instance()) {
25 OnPaintAura(canvas);
26 return;
29 gfx::Rect separator_bounds = GetPaintBounds();
32 // Hack to get the separator to display correctly on Windows where we may
33 // have fractional scales. We move the separator 1 pixel down to ensure that
34 // it falls within the clipping rect which is scaled up.
35 float device_scale = gfx::GetDPIScale();
36 bool is_fractional_scale =
37 (device_scale - static_cast<int>(device_scale) != 0);
38 if (is_fractional_scale && separator_bounds.y() == 0)
39 separator_bounds.set_y(1);
41 ui::NativeTheme::ExtraParams extra;
42 config.native_theme->Paint(
43 canvas->sk_canvas(), ui::NativeTheme::kMenuPopupSeparator,
44 ui::NativeTheme::kNormal, separator_bounds, extra);
47 } // namespace views