OLD | NEW |
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 "chrome/views/controls/menu/menu.h" | 5 #include "chrome/views/controls/menu/menu.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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 void Menu::EnableMenuItemByID(int item_id, bool enabled) { | 443 void Menu::EnableMenuItemByID(int item_id, bool enabled) { |
444 UINT enable_flags = enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED; | 444 UINT enable_flags = enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED; |
445 EnableMenuItem(menu_, item_id, MF_BYCOMMAND | enable_flags); | 445 EnableMenuItem(menu_, item_id, MF_BYCOMMAND | enable_flags); |
446 } | 446 } |
447 | 447 |
448 void Menu::EnableMenuItemAt(int index, bool enabled) { | 448 void Menu::EnableMenuItemAt(int index, bool enabled) { |
449 UINT enable_flags = enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED; | 449 UINT enable_flags = enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED; |
450 EnableMenuItem(menu_, index, MF_BYPOSITION | enable_flags); | 450 EnableMenuItem(menu_, index, MF_BYPOSITION | enable_flags); |
451 } | 451 } |
452 | 452 |
| 453 void Menu::SetMenuLabel(int item_id, const std::wstring& label) { |
| 454 MENUITEMINFO mii = {0}; |
| 455 mii.cbSize = sizeof(mii); |
| 456 mii.fMask = MIIM_STRING; |
| 457 mii.dwTypeData = const_cast<wchar_t*>(label.c_str()); |
| 458 mii.cch = static_cast<UINT>(label.size()); |
| 459 SetMenuItemInfo(menu_, item_id, false, &mii); |
| 460 } |
| 461 |
453 DWORD Menu::GetTPMAlignFlags() const { | 462 DWORD Menu::GetTPMAlignFlags() const { |
454 // The manner in which we handle the menu alignment depends on whether or not | 463 // The manner in which we handle the menu alignment depends on whether or not |
455 // the menu is displayed within a mirrored view. If the UI is mirrored, the | 464 // the menu is displayed within a mirrored view. If the UI is mirrored, the |
456 // alignment needs to be fliped so that instead of aligning the menu to the | 465 // alignment needs to be fliped so that instead of aligning the menu to the |
457 // right of the point, we align it to the left and vice versa. | 466 // right of the point, we align it to the left and vice versa. |
458 DWORD align_flags = TPM_TOPALIGN; | 467 DWORD align_flags = TPM_TOPALIGN; |
459 switch (anchor_) { | 468 switch (anchor_) { |
460 case TOPLEFT: | 469 case TOPLEFT: |
461 if (delegate_->IsRightToLeftUILayout()) { | 470 if (delegate_->IsRightToLeftUILayout()) { |
462 align_flags |= TPM_RIGHTALIGN; | 471 align_flags |= TPM_RIGHTALIGN; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 } | 617 } |
609 | 618 |
610 void Menu::Cancel() { | 619 void Menu::Cancel() { |
611 DCHECK(is_menu_visible_); | 620 DCHECK(is_menu_visible_); |
612 EndMenu(); | 621 EndMenu(); |
613 } | 622 } |
614 | 623 |
615 int Menu::ItemCount() { | 624 int Menu::ItemCount() { |
616 return GetMenuItemCount(menu_); | 625 return GetMenuItemCount(menu_); |
617 } | 626 } |
OLD | NEW |