| 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_item_view.h" | 5 #include "views/controls/menu/menu_item_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "gfx/canvas.h" | 8 #include "gfx/canvas.h" |
| 9 #include "grit/app_strings.h" | 9 #include "grit/app_strings.h" |
| 10 #include "views/controls/button/text_button.h" | 10 #include "views/controls/button/text_button.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 int MenuItemView::label_start_; | 60 int MenuItemView::label_start_; |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 int MenuItemView::item_right_margin_; | 63 int MenuItemView::item_right_margin_; |
| 64 | 64 |
| 65 // static | 65 // static |
| 66 int MenuItemView::pref_menu_height_; | 66 int MenuItemView::pref_menu_height_; |
| 67 | 67 |
| 68 // static |
| 69 const char MenuItemView::kViewClassName[] = "views/MenuItemView"; |
| 70 |
| 68 MenuItemView::MenuItemView(MenuDelegate* delegate) | 71 MenuItemView::MenuItemView(MenuDelegate* delegate) |
| 69 : delegate_(delegate), | 72 : delegate_(delegate), |
| 70 controller_(NULL), | 73 controller_(NULL), |
| 71 canceled_(false), | 74 canceled_(false), |
| 72 parent_menu_item_(NULL), | 75 parent_menu_item_(NULL), |
| 73 type_(SUBMENU), | 76 type_(SUBMENU), |
| 74 selected_(false), | 77 selected_(false), |
| 75 command_(0), | 78 command_(0), |
| 76 submenu_(NULL), | 79 submenu_(NULL), |
| 77 has_mnemonics_(false), | 80 has_mnemonics_(false), |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 type_(type), | 396 type_(type), |
| 394 selected_(false), | 397 selected_(false), |
| 395 command_(command), | 398 command_(command), |
| 396 submenu_(NULL), | 399 submenu_(NULL), |
| 397 has_mnemonics_(false), | 400 has_mnemonics_(false), |
| 398 show_mnemonics_(false), | 401 show_mnemonics_(false), |
| 399 has_icons_(false) { | 402 has_icons_(false) { |
| 400 Init(parent, command, type, NULL); | 403 Init(parent, command, type, NULL); |
| 401 } | 404 } |
| 402 | 405 |
| 406 std::string MenuItemView::GetClassName() const { |
| 407 return kViewClassName; |
| 408 } |
| 409 |
| 403 // Calculates all sizes that we can from the OS. | 410 // Calculates all sizes that we can from the OS. |
| 404 // | 411 // |
| 405 // This is invoked prior to Running a menu. | 412 // This is invoked prior to Running a menu. |
| 406 void MenuItemView::UpdateMenuPartSizes(bool has_icons) { | 413 void MenuItemView::UpdateMenuPartSizes(bool has_icons) { |
| 407 MenuConfig::Reset(); | 414 MenuConfig::Reset(); |
| 408 const MenuConfig& config = MenuConfig::instance(); | 415 const MenuConfig& config = MenuConfig::instance(); |
| 409 | 416 |
| 410 item_right_margin_ = config.label_to_arrow_padding + config.arrow_width + | 417 item_right_margin_ = config.label_to_arrow_padding + config.arrow_width + |
| 411 config.arrow_to_edge_padding; | 418 config.arrow_to_edge_padding; |
| 412 | 419 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 } | 610 } |
| 604 | 611 |
| 605 std::wstring MenuItemView::GetAcceleratorText() { | 612 std::wstring MenuItemView::GetAcceleratorText() { |
| 606 Accelerator accelerator; | 613 Accelerator accelerator; |
| 607 return (GetDelegate() && | 614 return (GetDelegate() && |
| 608 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? | 615 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? |
| 609 accelerator.GetShortcutText() : std::wstring(); | 616 accelerator.GetShortcutText() : std::wstring(); |
| 610 } | 617 } |
| 611 | 618 |
| 612 } // namespace views | 619 } // namespace views |
| OLD | NEW |