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

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

Issue 7491083: Implemented nicer battery status (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unitialized ivars Created 9 years, 4 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
OLDNEW
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 MenuItemView::~MenuItemView() { 103 MenuItemView::~MenuItemView() {
104 // TODO(sky): ownership is bit wrong now. In particular if a nested message 104 // TODO(sky): ownership is bit wrong now. In particular if a nested message
105 // loop is running deletion can't be done, otherwise the stack gets 105 // loop is running deletion can't be done, otherwise the stack gets
106 // thoroughly screwed. The destructor should be made private, and 106 // thoroughly screwed. The destructor should be made private, and
107 // MenuController should be the only place handling deletion of the menu. 107 // MenuController should be the only place handling deletion of the menu.
108 // (57890). 108 // (57890).
109 delete submenu_; 109 delete submenu_;
110 STLDeleteElements(&removed_items_); 110 STLDeleteElements(&removed_items_);
111 } 111 }
112 112
113 void MenuItemView::ChildPreferredSizeChanged(View* child) {
114 pref_size_.SetSize(0, 0);
115 PreferredSizeChanged();
116 }
117
113 bool MenuItemView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { 118 bool MenuItemView::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
114 *tooltip = UTF16ToWideHack(tooltip_); 119 *tooltip = UTF16ToWideHack(tooltip_);
115 if (!tooltip->empty()) 120 if (!tooltip->empty())
116 return true; 121 return true;
117 122
118 if (GetType() == SEPARATOR) 123 if (GetType() == SEPARATOR)
119 return false; 124 return false;
120 125
121 MenuController* controller = GetMenuController(); 126 MenuController* controller = GetMenuController();
122 if (!controller || controller->exit_type() != MenuController::EXIT_NONE) { 127 if (!controller || controller->exit_type() != MenuController::EXIT_NONE) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 495
491 void MenuItemView::Layout() { 496 void MenuItemView::Layout() {
492 if (!has_children()) 497 if (!has_children())
493 return; 498 return;
494 499
495 if (child_count() == 1 && GetTitle().size() == 0) { 500 if (child_count() == 1 && GetTitle().size() == 0) {
496 // We only have one child and no title so let the view take over all the 501 // We only have one child and no title so let the view take over all the
497 // space. 502 // space.
498 View* child = child_at(0); 503 View* child = child_at(0);
499 gfx::Size size = child->GetPreferredSize(); 504 gfx::Size size = child->GetPreferredSize();
500 child->SetBounds(label_start_, GetTopMargin(), size.width(), size.height()); 505 child->SetBounds(0, GetTopMargin(), size.width(), size.height());
501 } else { 506 } else {
502 // Child views are laid out right aligned and given the full height. To 507 // Child views are laid out right aligned and given the full height. To
503 // right align start with the last view and progress to the first. 508 // right align start with the last view and progress to the first.
504 for (int i = child_count() - 1, x = width() - item_right_margin_; i >= 0; 509 for (int i = child_count() - 1, x = width() - item_right_margin_; i >= 0;
505 --i) { 510 --i) {
506 View* child = child_at(i); 511 View* child = child_at(i);
507 int width = child->GetPreferredSize().width(); 512 int width = child->GetPreferredSize().width();
508 child->SetBounds(x - width, 0, width, height()); 513 child->SetBounds(x - width, 0, width, height());
509 x -= width - kChildXPadding; 514 x -= width - kChildXPadding;
510 } 515 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 return string16(); 787 return string16();
783 } 788 }
784 789
785 Accelerator accelerator; 790 Accelerator accelerator;
786 return (GetDelegate() && 791 return (GetDelegate() &&
787 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? 792 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ?
788 accelerator.GetShortcutText() : string16(); 793 accelerator.GetShortcutText() : string16();
789 } 794 }
790 795
791 } // namespace views 796 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698