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

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

Issue 6334152: Clean up RTL methods.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/button/text_button.cc ('k') | views/controls/menu/menu_item_view_gtk.cc » ('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) 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 "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "grit/app_strings.h" 8 #include "grit/app_strings.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/base/models/menu_model.h" 10 #include "ui/base/models/menu_model.h"
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 MenuItemView* menu_item = static_cast<MenuItemView*>(child); 603 MenuItemView* menu_item = static_cast<MenuItemView*>(child);
604 if (menu_item->HasSubmenu()) 604 if (menu_item->HasSubmenu())
605 menu_item->RemoveEmptyMenus(); 605 menu_item->RemoveEmptyMenus();
606 } else if (child->GetID() == EmptyMenuMenuItem::kEmptyMenuItemViewID) { 606 } else if (child->GetID() == EmptyMenuMenuItem::kEmptyMenuItemViewID) {
607 submenu_->RemoveChildView(child); 607 submenu_->RemoveChildView(child);
608 } 608 }
609 } 609 }
610 } 610 }
611 611
612 void MenuItemView::AdjustBoundsForRTLUI(gfx::Rect* rect) const { 612 void MenuItemView::AdjustBoundsForRTLUI(gfx::Rect* rect) const {
613 rect->set_x(MirroredLeftPointForRect(*rect)); 613 rect->set_x(GetMirroredXForRect(*rect));
614 } 614 }
615 615
616 void MenuItemView::PaintAccelerator(gfx::Canvas* canvas) { 616 void MenuItemView::PaintAccelerator(gfx::Canvas* canvas) {
617 string16 accel_text = GetAcceleratorText(); 617 string16 accel_text = GetAcceleratorText();
618 if (accel_text.empty()) 618 if (accel_text.empty())
619 return; 619 return;
620 620
621 const gfx::Font& font = MenuConfig::instance().font; 621 const gfx::Font& font = MenuConfig::instance().font;
622 int available_height = height() - GetTopMargin() - GetBottomMargin(); 622 int available_height = height() - GetTopMargin() - GetBottomMargin();
623 int max_accel_width = 623 int max_accel_width =
624 parent_menu_item_->GetSubmenu()->max_accelerator_width(); 624 parent_menu_item_->GetSubmenu()->max_accelerator_width();
625 gfx::Rect accel_bounds(width() - item_right_margin_ - max_accel_width, 625 gfx::Rect accel_bounds(width() - item_right_margin_ - max_accel_width,
626 GetTopMargin(), max_accel_width, available_height); 626 GetTopMargin(), max_accel_width, available_height);
627 accel_bounds.set_x(MirroredLeftPointForRect(accel_bounds)); 627 accel_bounds.set_x(GetMirroredXForRect(accel_bounds));
628 int flags = GetRootMenuItem()->GetDrawStringFlags() | 628 int flags = GetRootMenuItem()->GetDrawStringFlags() |
629 gfx::Canvas::TEXT_VALIGN_MIDDLE; 629 gfx::Canvas::TEXT_VALIGN_MIDDLE;
630 flags &= ~(gfx::Canvas::TEXT_ALIGN_RIGHT | gfx::Canvas::TEXT_ALIGN_LEFT); 630 flags &= ~(gfx::Canvas::TEXT_ALIGN_RIGHT | gfx::Canvas::TEXT_ALIGN_LEFT);
631 if (base::i18n::IsRTL()) 631 if (base::i18n::IsRTL())
632 flags |= gfx::Canvas::TEXT_ALIGN_LEFT; 632 flags |= gfx::Canvas::TEXT_ALIGN_LEFT;
633 else 633 else
634 flags |= gfx::Canvas::TEXT_ALIGN_RIGHT; 634 flags |= gfx::Canvas::TEXT_ALIGN_RIGHT;
635 canvas->DrawStringInt( 635 canvas->DrawStringInt(
636 accel_text, font, TextButton::kDisabledColor, 636 accel_text, font, TextButton::kDisabledColor,
637 accel_bounds.x(), accel_bounds.y(), accel_bounds.width(), 637 accel_bounds.x(), accel_bounds.y(), accel_bounds.width(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 } 678 }
679 679
680 string16 MenuItemView::GetAcceleratorText() { 680 string16 MenuItemView::GetAcceleratorText() {
681 Accelerator accelerator; 681 Accelerator accelerator;
682 return (GetDelegate() && 682 return (GetDelegate() &&
683 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? 683 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ?
684 accelerator.GetShortcutText() : string16(); 684 accelerator.GetShortcutText() : string16();
685 } 685 }
686 686
687 } // namespace views 687 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/text_button.cc ('k') | views/controls/menu/menu_item_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698