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

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

Issue 150061: Rework a loop in the native menu code to iterate over the vector of items we ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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 | « no previous file | no next file » | 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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "views/controls/menu/native_menu_win.h" 5 #include "views/controls/menu/native_menu_win.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/font.h" 8 #include "app/gfx/font.h"
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/l10n_util_win.h" 10 #include "app/l10n_util_win.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 int model_index = menu_index - first_item_index_; 339 int model_index = menu_index - first_item_index_;
340 if (model_->GetTypeAt(model_index) == Menu2Model::TYPE_SEPARATOR) 340 if (model_->GetTypeAt(model_index) == Menu2Model::TYPE_SEPARATOR)
341 AddSeparatorItemAt(menu_index, model_index); 341 AddSeparatorItemAt(menu_index, model_index);
342 else 342 else
343 AddMenuItemAt(menu_index, model_index); 343 AddMenuItemAt(menu_index, model_index);
344 } 344 }
345 } 345 }
346 346
347 void NativeMenuWin::UpdateStates() { 347 void NativeMenuWin::UpdateStates() {
348 // A depth-first walk of the menu items, updating states. 348 // A depth-first walk of the menu items, updating states.
349 for (int menu_index = first_item_index_; 349 int model_index = 0;
350 menu_index < first_item_index_ + model_->GetItemCount(); ++menu_index) { 350 std::vector<ItemData*>::const_iterator it;
351 int model_index = menu_index - first_item_index_; 351 for (it = items_.begin(); it != items_.end(); ++it, ++model_index) {
352 int menu_index = model_index + first_item_index_;
352 SetMenuItemState(menu_index, model_->IsEnabledAt(model_index), 353 SetMenuItemState(menu_index, model_->IsEnabledAt(model_index),
353 model_->IsItemCheckedAt(model_index), false); 354 model_->IsItemCheckedAt(model_index), false);
354 if (model_->IsLabelDynamicAt(model_index)) { 355 if (model_->IsLabelDynamicAt(model_index)) {
355 SetMenuItemLabel(menu_index, model_index, 356 SetMenuItemLabel(menu_index, model_index,
356 model_->GetLabelAt(model_index)); 357 model_->GetLabelAt(model_index));
sky 2009/06/29 21:40:06 nit: align with (
357 } 358 }
358 Menu2* submenu = items_[model_index]->submenu.get(); 359 Menu2* submenu = (*it)->submenu.get();
359 if (submenu) 360 if (submenu)
360 submenu->UpdateStates(); 361 submenu->UpdateStates();
361 } 362 }
362 } 363 }
363 364
364 gfx::NativeMenu NativeMenuWin::GetNativeMenu() const { 365 gfx::NativeMenu NativeMenuWin::GetNativeMenu() const {
365 return menu_; 366 return menu_;
366 } 367 }
367 368
368 //////////////////////////////////////////////////////////////////////////////// 369 ////////////////////////////////////////////////////////////////////////////////
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 533
533 //////////////////////////////////////////////////////////////////////////////// 534 ////////////////////////////////////////////////////////////////////////////////
534 // MenuWrapper, public: 535 // MenuWrapper, public:
535 536
536 // static 537 // static
537 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { 538 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) {
538 return new NativeMenuWin(menu->model(), NULL); 539 return new NativeMenuWin(menu->model(), NULL);
539 } 540 }
540 541
541 } // namespace views 542 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698