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

Side by Side Diff: views/controls/menu/menu_win.cc

Issue 113441: ChromeFont->gfx::Font... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « views/controls/menu/chrome_menu.cc ('k') | views/controls/text_field.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "views/controls/menu/menu_win.h" 5 #include "views/controls/menu/menu_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlapp.h> 8 #include <atlapp.h>
9 #include <atlwin.h> 9 #include <atlwin.h>
10 #include <atlcrack.h> 10 #include <atlcrack.h>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void OnRButtonUp(UINT w_param, const CPoint& loc) { 100 void OnRButtonUp(UINT w_param, const CPoint& loc) {
101 int id; 101 int id;
102 if (menu_->delegate() && FindMenuIDByLocation(menu_, loc, &id)) 102 if (menu_->delegate() && FindMenuIDByLocation(menu_, loc, &id))
103 menu_->delegate()->ShowContextMenu(menu_, id, loc.x, loc.y, true); 103 menu_->delegate()->ShowContextMenu(menu_, id, loc.x, loc.y, true);
104 } 104 }
105 105
106 void OnMeasureItem(WPARAM w_param, MEASUREITEMSTRUCT* lpmis) { 106 void OnMeasureItem(WPARAM w_param, MEASUREITEMSTRUCT* lpmis) {
107 MenuWin::ItemData* data = 107 MenuWin::ItemData* data =
108 reinterpret_cast<MenuWin::ItemData*>(lpmis->itemData); 108 reinterpret_cast<MenuWin::ItemData*>(lpmis->itemData);
109 if (data != NULL) { 109 if (data != NULL) {
110 ChromeFont font; 110 gfx::Font font;
111 lpmis->itemWidth = font.GetStringWidth(data->label) + kIconWidth + 111 lpmis->itemWidth = font.GetStringWidth(data->label) + kIconWidth +
112 kItemLeftMargin + kItemRightMargin - 112 kItemLeftMargin + kItemRightMargin -
113 GetSystemMetrics(SM_CXMENUCHECK); 113 GetSystemMetrics(SM_CXMENUCHECK);
114 if (data->submenu) 114 if (data->submenu)
115 lpmis->itemWidth += kArrowWidth; 115 lpmis->itemWidth += kArrowWidth;
116 // If the label contains an accelerator, make room for tab. 116 // If the label contains an accelerator, make room for tab.
117 if (data->label.find(L'\t') != std::wstring::npos) 117 if (data->label.find(L'\t') != std::wstring::npos)
118 lpmis->itemWidth += font.GetStringWidth(L" "); 118 lpmis->itemWidth += font.GetStringWidth(L" ");
119 lpmis->itemHeight = font.height() + kItemBottomMargin + kItemTopMargin; 119 lpmis->itemHeight = font.height() + kItemBottomMargin + kItemTopMargin;
120 } else { 120 } else {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 rect.top += kItemTopMargin; 154 rect.top += kItemTopMargin;
155 // Should we add kIconWidth only when icon.width() != 0 ? 155 // Should we add kIconWidth only when icon.width() != 0 ?
156 rect.left += kItemLeftMargin + kIconWidth; 156 rect.left += kItemLeftMargin + kIconWidth;
157 rect.right -= kItemRightMargin; 157 rect.right -= kItemRightMargin;
158 UINT format = DT_TOP | DT_SINGLELINE; 158 UINT format = DT_TOP | DT_SINGLELINE;
159 // Check whether the mnemonics should be underlined. 159 // Check whether the mnemonics should be underlined.
160 BOOL underline_mnemonics; 160 BOOL underline_mnemonics;
161 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &underline_mnemonics, 0); 161 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &underline_mnemonics, 0);
162 if (!underline_mnemonics) 162 if (!underline_mnemonics)
163 format |= DT_HIDEPREFIX; 163 format |= DT_HIDEPREFIX;
164 ChromeFont font; 164 gfx::Font font;
165 HGDIOBJ old_font = static_cast<HFONT>(SelectObject(hDC, font.hfont())); 165 HGDIOBJ old_font = static_cast<HFONT>(SelectObject(hDC, font.hfont()));
166 int fontsize = font.FontSize(); 166 int fontsize = font.FontSize();
167 167
168 // If an accelerator is specified (with a tab delimiting the rest of the 168 // If an accelerator is specified (with a tab delimiting the rest of the
169 // label from the accelerator), we have to justify the fist part on the 169 // label from the accelerator), we have to justify the fist part on the
170 // left and the accelerator on the right. 170 // left and the accelerator on the right.
171 // TODO(jungshik): This will break in RTL UI. Currently, he/ar use the 171 // TODO(jungshik): This will break in RTL UI. Currently, he/ar use the
172 // window system UI font and will not hit here. 172 // window system UI font and will not hit here.
173 std::wstring label = data->label; 173 std::wstring label = data->label;
174 std::wstring accel; 174 std::wstring accel;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 break; 556 break;
557 557
558 default: 558 default:
559 NOTREACHED(); 559 NOTREACHED();
560 return 0; 560 return 0;
561 } 561 }
562 return align_flags; 562 return align_flags;
563 } 563 }
564 564
565 } // namespace views 565 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/chrome_menu.cc ('k') | views/controls/text_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698