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

Side by Side Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (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 | « chrome/browser/ui/views/task_manager_view.cc ('k') | views/accessibility/view_accessibility.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) 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 "chrome/browser/ui/views/wrench_menu.h" 5 #include "chrome/browser/ui/views/wrench_menu.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // left/right of it SchedulePaint on the the button may not be enough, so this 228 // left/right of it SchedulePaint on the the button may not be enough, so this
229 // forces a paint all. 229 // forces a paint all.
230 class ScheduleAllView : public views::View { 230 class ScheduleAllView : public views::View {
231 public: 231 public:
232 ScheduleAllView() {} 232 ScheduleAllView() {}
233 233
234 virtual void SchedulePaint(const gfx::Rect& r, bool urgent) { 234 virtual void SchedulePaint(const gfx::Rect& r, bool urgent) {
235 if (!IsVisible()) 235 if (!IsVisible())
236 return; 236 return;
237 237
238 if (GetParent()) { 238 if (parent())
239 GetParent()->SchedulePaint(GetMirroredBounds(), urgent); 239 parent()->SchedulePaint(GetMirroredBounds(), urgent);
240 }
241 } 240 }
242 241
243 private: 242 private:
244 DISALLOW_COPY_AND_ASSIGN(ScheduleAllView); 243 DISALLOW_COPY_AND_ASSIGN(ScheduleAllView);
245 }; 244 };
246 245
247 string16 GetAccessibleNameForWrenchMenuItem( 246 string16 GetAccessibleNameForWrenchMenuItem(
248 MenuModel* model, int item_index, int accessible_string_id) { 247 MenuModel* model, int item_index, int accessible_string_id) {
249 string16 accessible_name = l10n_util::GetStringUTF16(accessible_string_id); 248 string16 accessible_name = l10n_util::GetStringUTF16(accessible_string_id);
250 string16 accelerator_text; 249 string16 accelerator_text;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 335
337 TextButton* paste = CreateAndConfigureButton( 336 TextButton* paste = CreateAndConfigureButton(
338 IDS_PASTE, MenuButtonBackground::RIGHT_BUTTON, paste_index, NULL); 337 IDS_PASTE, MenuButtonBackground::RIGHT_BUTTON, paste_index, NULL);
339 338
340 copy_background->SetOtherButtons(cut, paste); 339 copy_background->SetOtherButtons(cut, paste);
341 } 340 }
342 341
343 gfx::Size GetPreferredSize() { 342 gfx::Size GetPreferredSize() {
344 // Returned height doesn't matter as MenuItemView forces everything to the 343 // Returned height doesn't matter as MenuItemView forces everything to the
345 // height of the menuitemview. 344 // height of the menuitemview.
346 return gfx::Size(GetMaxChildViewPreferredWidth() * GetChildViewCount(), 0); 345 return gfx::Size(GetMaxChildViewPreferredWidth() * child_count(), 0);
347 } 346 }
348 347
349 void Layout() { 348 void Layout() {
350 // All buttons are given the same width. 349 // All buttons are given the same width.
351 int width = GetMaxChildViewPreferredWidth(); 350 int width = GetMaxChildViewPreferredWidth();
352 for (int i = 0; i < GetChildViewCount(); ++i) 351 for (int i = 0; i < child_count(); ++i)
353 GetChildViewAt(i)->SetBounds(i * width, 0, width, height()); 352 GetChildViewAt(i)->SetBounds(i * width, 0, width, height());
354 } 353 }
355 354
356 // ButtonListener 355 // ButtonListener
357 virtual void ButtonPressed(views::Button* sender, const views::Event& event) { 356 virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
358 menu_->CancelAndEvaluate(menu_model_, sender->tag()); 357 menu_->CancelAndEvaluate(menu_model_, sender->tag());
359 } 358 }
360 359
361 private: 360 private:
362 // Returns the max preferred width of all the children. 361 // Returns the max preferred width of all the children.
363 int GetMaxChildViewPreferredWidth() { 362 int GetMaxChildViewPreferredWidth() {
364 int width = 0; 363 int width = 0;
365 for (int i = 0; i < GetChildViewCount(); ++i) 364 for (int i = 0; i < child_count(); ++i)
366 width = std::max(width, GetChildViewAt(i)->GetPreferredSize().width()); 365 width = std::max(width, GetChildViewAt(i)->GetPreferredSize().width());
367 return width; 366 return width;
368 } 367 }
369 368
370 DISALLOW_COPY_AND_ASSIGN(CutCopyPasteView); 369 DISALLOW_COPY_AND_ASSIGN(CutCopyPasteView);
371 }; 370 };
372 371
373 // ZoomView -------------------------------------------------------------------- 372 // ZoomView --------------------------------------------------------------------
374 373
375 // Padding between the increment buttons and the reset button. 374 // Padding between the increment buttons and the reset button.
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 } 702 }
704 703
705 return menu_item; 704 return menu_item;
706 } 705 }
707 706
708 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { 707 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) {
709 selected_menu_model_ = model; 708 selected_menu_model_ = model;
710 selected_index_ = index; 709 selected_index_ = index;
711 root_->Cancel(); 710 root_->Cancel();
712 } 711 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/task_manager_view.cc ('k') | views/accessibility/view_accessibility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698