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 "chrome/browser/views/wrench_menu.h" | 5 #include "chrome/browser/views/wrench_menu.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 root_.reset(new MenuItemView(this)); | 552 root_.reset(new MenuItemView(this)); |
553 root_->set_has_icons(true); // We have checks, radios and icons, set this | 553 root_->set_has_icons(true); // We have checks, radios and icons, set this |
554 // so we get the taller menu style. | 554 // so we get the taller menu style. |
555 int next_id = 1; | 555 int next_id = 1; |
556 PopulateMenu(root_.get(), model, &next_id); | 556 PopulateMenu(root_.get(), model, &next_id); |
557 } | 557 } |
558 | 558 |
559 void WrenchMenu::RunMenu(views::MenuButton* host) { | 559 void WrenchMenu::RunMenu(views::MenuButton* host) { |
560 gfx::Point screen_loc; | 560 gfx::Point screen_loc; |
561 views::View::ConvertPointToScreen(host, &screen_loc); | 561 views::View::ConvertPointToScreen(host, &screen_loc); |
562 // Subtract 1 from the height to make the popup flush with the button border. | 562 gfx::Rect bounds(screen_loc, host->size()); |
563 gfx::Rect bounds(screen_loc.x(), screen_loc.y(), host->width(), | |
564 host->height() - 1); | |
565 root_->RunMenuAt(host->GetWindow()->GetNativeWindow(), host, bounds, | 563 root_->RunMenuAt(host->GetWindow()->GetNativeWindow(), host, bounds, |
566 base::i18n::IsRTL() ? MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT, | 564 base::i18n::IsRTL() ? MenuItemView::TOPLEFT : MenuItemView::TOPRIGHT, |
567 true); | 565 true); |
568 if (selected_menu_model_) | 566 if (selected_menu_model_) |
569 selected_menu_model_->ActivatedAt(selected_index_); | 567 selected_menu_model_->ActivatedAt(selected_index_); |
570 } | 568 } |
571 | 569 |
572 bool WrenchMenu::IsItemChecked(int id) const { | 570 bool WrenchMenu::IsItemChecked(int id) const { |
573 const Entry& entry = id_to_entry_.find(id)->second; | 571 const Entry& entry = id_to_entry_.find(id)->second; |
574 return entry.first->IsItemCheckedAt(entry.second); | 572 return entry.first->IsItemCheckedAt(entry.second); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 } | 698 } |
701 | 699 |
702 return menu_item; | 700 return menu_item; |
703 } | 701 } |
704 | 702 |
705 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { | 703 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { |
706 selected_menu_model_ = model; | 704 selected_menu_model_ = model; |
707 selected_index_ = index; | 705 selected_index_ = index; |
708 root_->Cancel(); | 706 root_->Cancel(); |
709 } | 707 } |
OLD | NEW |