OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_item_view.h" | 5 #include "views/controls/menu/menu_item_view.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 x -= width - kChildXPadding; | 501 x -= width - kChildXPadding; |
502 } | 502 } |
503 } | 503 } |
504 } | 504 } |
505 | 505 |
506 int MenuItemView::GetAcceleratorTextWidth() { | 506 int MenuItemView::GetAcceleratorTextWidth() { |
507 string16 text = GetAcceleratorText(); | 507 string16 text = GetAcceleratorText(); |
508 return text.empty() ? 0 : GetFont().GetStringWidth(text); | 508 return text.empty() ? 0 : GetFont().GetStringWidth(text); |
509 } | 509 } |
510 | 510 |
| 511 void MenuItemView::SetMargins(int top_margin, int bottom_margin) { |
| 512 top_margin_ = top_margin; |
| 513 bottom_margin_ = bottom_margin; |
| 514 |
| 515 // invalidate GetPreferredSize() cache |
| 516 pref_size_.SetSize(0,0); |
| 517 } |
| 518 |
511 MenuItemView::MenuItemView(MenuItemView* parent, | 519 MenuItemView::MenuItemView(MenuItemView* parent, |
512 int command, | 520 int command, |
513 MenuItemView::Type type) | 521 MenuItemView::Type type) |
514 : delegate_(NULL), | 522 : delegate_(NULL), |
515 controller_(NULL), | 523 controller_(NULL), |
516 canceled_(false), | 524 canceled_(false), |
517 parent_menu_item_(parent), | 525 parent_menu_item_(parent), |
518 type_(type), | 526 type_(type), |
519 selected_(false), | 527 selected_(false), |
520 command_(command), | 528 command_(command), |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 return string16(); | 774 return string16(); |
767 } | 775 } |
768 | 776 |
769 Accelerator accelerator; | 777 Accelerator accelerator; |
770 return (GetDelegate() && | 778 return (GetDelegate() && |
771 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? | 779 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? |
772 accelerator.GetShortcutText() : string16(); | 780 accelerator.GetShortcutText() : string16(); |
773 } | 781 } |
774 | 782 |
775 } // namespace views | 783 } // namespace views |
OLD | NEW |