OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_win.h" | 5 #include "views/controls/menu/menu_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (data != NULL) { | 105 if (data != NULL) { |
106 gfx::Font font; | 106 gfx::Font font; |
107 lpmis->itemWidth = font.GetStringWidth(data->label) + kIconWidth + | 107 lpmis->itemWidth = font.GetStringWidth(data->label) + kIconWidth + |
108 kItemLeftMargin + kItemRightMargin - | 108 kItemLeftMargin + kItemRightMargin - |
109 GetSystemMetrics(SM_CXMENUCHECK); | 109 GetSystemMetrics(SM_CXMENUCHECK); |
110 if (data->submenu) | 110 if (data->submenu) |
111 lpmis->itemWidth += kArrowWidth; | 111 lpmis->itemWidth += kArrowWidth; |
112 // If the label contains an accelerator, make room for tab. | 112 // If the label contains an accelerator, make room for tab. |
113 if (data->label.find(L'\t') != std::wstring::npos) | 113 if (data->label.find(L'\t') != std::wstring::npos) |
114 lpmis->itemWidth += font.GetStringWidth(L" "); | 114 lpmis->itemWidth += font.GetStringWidth(L" "); |
115 lpmis->itemHeight = font.height() + kItemBottomMargin + kItemTopMargin; | 115 lpmis->itemHeight = font.GetHeight() + kItemBottomMargin + kItemTopMargin; |
116 } else { | 116 } else { |
117 // Measure separator size. | 117 // Measure separator size. |
118 lpmis->itemHeight = GetSystemMetrics(SM_CYMENU) / 2; | 118 lpmis->itemHeight = GetSystemMetrics(SM_CYMENU) / 2; |
119 lpmis->itemWidth = 0; | 119 lpmis->itemWidth = 0; |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 void OnDrawItem(UINT wParam, DRAWITEMSTRUCT* lpdis) { | 123 void OnDrawItem(UINT wParam, DRAWITEMSTRUCT* lpdis) { |
124 HDC hDC = lpdis->hDC; | 124 HDC hDC = lpdis->hDC; |
125 COLORREF prev_bg_color, prev_text_color; | 125 COLORREF prev_bg_color, prev_text_color; |
(...skipping 25 matching lines...) Expand all Loading... |
151 // Should we add kIconWidth only when icon.width() != 0 ? | 151 // Should we add kIconWidth only when icon.width() != 0 ? |
152 rect.left += kItemLeftMargin + kIconWidth; | 152 rect.left += kItemLeftMargin + kIconWidth; |
153 rect.right -= kItemRightMargin; | 153 rect.right -= kItemRightMargin; |
154 UINT format = DT_TOP | DT_SINGLELINE; | 154 UINT format = DT_TOP | DT_SINGLELINE; |
155 // Check whether the mnemonics should be underlined. | 155 // Check whether the mnemonics should be underlined. |
156 BOOL underline_mnemonics; | 156 BOOL underline_mnemonics; |
157 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &underline_mnemonics, 0); | 157 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &underline_mnemonics, 0); |
158 if (!underline_mnemonics) | 158 if (!underline_mnemonics) |
159 format |= DT_HIDEPREFIX; | 159 format |= DT_HIDEPREFIX; |
160 gfx::Font font; | 160 gfx::Font font; |
161 HGDIOBJ old_font = static_cast<HFONT>(SelectObject(hDC, font.hfont())); | 161 HGDIOBJ old_font = |
162 int fontsize = font.FontSize(); | 162 static_cast<HFONT>(SelectObject(hDC, font.GetNativeFont())); |
| 163 int fontsize = font.GetFontSize(); |
163 | 164 |
164 // If an accelerator is specified (with a tab delimiting the rest of the | 165 // If an accelerator is specified (with a tab delimiting the rest of the |
165 // label from the accelerator), we have to justify the fist part on the | 166 // label from the accelerator), we have to justify the fist part on the |
166 // left and the accelerator on the right. | 167 // left and the accelerator on the right. |
167 // TODO(jungshik): This will break in RTL UI. Currently, he/ar use the | 168 // TODO(jungshik): This will break in RTL UI. Currently, he/ar use the |
168 // window system UI font and will not hit here. | 169 // window system UI font and will not hit here. |
169 std::wstring label = data->label; | 170 std::wstring label = data->label; |
170 std::wstring accel; | 171 std::wstring accel; |
171 std::wstring::size_type tab_pos = label.find(L'\t'); | 172 std::wstring::size_type tab_pos = label.find(L'\t'); |
172 if (tab_pos != std::wstring::npos) { | 173 if (tab_pos != std::wstring::npos) { |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 break; | 566 break; |
566 | 567 |
567 default: | 568 default: |
568 NOTREACHED(); | 569 NOTREACHED(); |
569 return 0; | 570 return 0; |
570 } | 571 } |
571 return align_flags; | 572 return align_flags; |
572 } | 573 } |
573 | 574 |
574 } // namespace views | 575 } // namespace views |
OLD | NEW |