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

Side by Side Diff: chrome/browser/task_manager.cc

Issue 7344: Convert GetPreferredSize from:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/task_manager.h" 5 #include "chrome/browser/task_manager.h"
6 6
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 #include "base/stats_table.h" 8 #include "base/stats_table.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 public ChromeViews::LinkController, 659 public ChromeViews::LinkController,
660 public ChromeViews::ContextMenuController, 660 public ChromeViews::ContextMenuController,
661 public Menu::Delegate { 661 public Menu::Delegate {
662 public: 662 public:
663 TaskManagerContents(TaskManager* task_manager, 663 TaskManagerContents(TaskManager* task_manager,
664 TaskManagerTableModel* table_model); 664 TaskManagerTableModel* table_model);
665 virtual ~TaskManagerContents(); 665 virtual ~TaskManagerContents();
666 666
667 void Init(TaskManagerTableModel* table_model); 667 void Init(TaskManagerTableModel* table_model);
668 virtual void Layout(); 668 virtual void Layout();
669 virtual void GetPreferredSize(CSize* out); 669 virtual gfx::Size GetPreferredSize();
670 virtual void DidChangeBounds(const CRect& previous, const CRect& current); 670 virtual void DidChangeBounds(const CRect& previous, const CRect& current);
671 virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, 671 virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
672 ChromeViews::View* child); 672 ChromeViews::View* child);
673 void GetSelection(std::vector<int>* selection); 673 void GetSelection(std::vector<int>* selection);
674 void GetFocused(std::vector<int>* focused); 674 void GetFocused(std::vector<int>* focused);
675 675
676 // NativeButton::Listener implementation. 676 // NativeButton::Listener implementation.
677 virtual void ButtonPressed(ChromeViews::NativeButton* sender); 677 virtual void ButtonPressed(ChromeViews::NativeButton* sender);
678 678
679 // ChromeViews::TableViewObserver implementation. 679 // ChromeViews::TableViewObserver implementation.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 837 }
838 838
839 void TaskManagerContents::Layout() { 839 void TaskManagerContents::Layout() {
840 // kPanelHorizMargin is too big. 840 // kPanelHorizMargin is too big.
841 const int kTableButtonSpacing = 12; 841 const int kTableButtonSpacing = 12;
842 CRect bounds; 842 CRect bounds;
843 GetLocalBounds(&bounds, true); 843 GetLocalBounds(&bounds, true);
844 int x = bounds.left; 844 int x = bounds.left;
845 int y = bounds.top; 845 int y = bounds.top;
846 846
847 CSize size; 847 gfx::Size size = kill_button_->GetPreferredSize();
848 kill_button_->GetPreferredSize(&size); 848 int prefered_width = size.width();
849 int prefered_width = size.cx; 849 int prefered_height = size.height();
850 int prefered_height = size.cy;
851 850
852 tab_table_->SetBounds( 851 tab_table_->SetBounds(
853 x + kPanelHorizMargin, 852 x + kPanelHorizMargin,
854 y + kPanelVertMargin, 853 y + kPanelVertMargin,
855 bounds.Width() - 2 * kPanelHorizMargin, 854 bounds.Width() - 2 * kPanelHorizMargin,
856 bounds.Height() - 2 * kPanelVertMargin - prefered_height); 855 bounds.Height() - 2 * kPanelVertMargin - prefered_height);
857 856
858 // y-coordinate of button top left. 857 // y-coordinate of button top left.
859 CRect parent_bounds; 858 CRect parent_bounds;
860 GetParent()->GetLocalBounds(&parent_bounds, false); 859 GetParent()->GetLocalBounds(&parent_bounds, false);
861 int y_buttons = parent_bounds.bottom - prefered_height - kButtonVEdgeMargin; 860 int y_buttons = parent_bounds.bottom - prefered_height - kButtonVEdgeMargin;
862 861
863 kill_button_->SetBounds( 862 kill_button_->SetBounds(
864 x + bounds.Width() - prefered_width - kPanelHorizMargin, 863 x + bounds.Width() - prefered_width - kPanelHorizMargin,
865 y_buttons, 864 y_buttons,
866 prefered_width, 865 prefered_width,
867 prefered_height); 866 prefered_height);
868 867
869 about_memory_link_->GetPreferredSize(&size); 868 size = about_memory_link_->GetPreferredSize();
870 int link_prefered_width = size.cx; 869 int link_prefered_width = size.width();
871 int link_prefered_height = size.cy; 870 int link_prefered_height = size.height();
872 // center between the two buttons horizontally, and line up with 871 // center between the two buttons horizontally, and line up with
873 // bottom of buttons vertically. 872 // bottom of buttons vertically.
874 int link_y_offset = std::max(0, prefered_height - link_prefered_height) / 2; 873 int link_y_offset = std::max(0, prefered_height - link_prefered_height) / 2;
875 about_memory_link_->SetBounds( 874 about_memory_link_->SetBounds(
876 x + kPanelHorizMargin, 875 x + kPanelHorizMargin,
877 y_buttons + prefered_height - link_prefered_height - link_y_offset, 876 y_buttons + prefered_height - link_prefered_height - link_y_offset,
878 link_prefered_width, 877 link_prefered_width,
879 link_prefered_height); 878 link_prefered_height);
880 } 879 }
881 880
882 void TaskManagerContents::GetPreferredSize(CSize* out) { 881 gfx::Size TaskManagerContents::GetPreferredSize() {
883 out->cx = kDefaultWidth; 882 return gfx::Size(kDefaultWidth, kDefaultHeight);
884 out->cy = kDefaultHeight;
885 } 883 }
886 884
887 void TaskManagerContents::GetSelection(std::vector<int>* selection) { 885 void TaskManagerContents::GetSelection(std::vector<int>* selection) {
888 DCHECK(selection); 886 DCHECK(selection);
889 for (ChromeViews::TableSelectionIterator iter = tab_table_->SelectionBegin(); 887 for (ChromeViews::TableSelectionIterator iter = tab_table_->SelectionBegin();
890 iter != tab_table_->SelectionEnd(); ++iter) { 888 iter != tab_table_->SelectionEnd(); ++iter) {
891 // The TableView returns the selection starting from the end. 889 // The TableView returns the selection starting from the end.
892 selection->insert(selection->begin(), *iter); 890 selection->insert(selection->begin(), *iter);
893 } 891 }
894 } 892 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1117
1120 ChromeViews::View* TaskManager::GetContentsView() { 1118 ChromeViews::View* TaskManager::GetContentsView() {
1121 return contents_.get(); 1119 return contents_.get();
1122 } 1120 }
1123 1121
1124 // static 1122 // static
1125 TaskManager* TaskManager::GetInstance() { 1123 TaskManager* TaskManager::GetInstance() {
1126 return Singleton<TaskManager>::get(); 1124 return Singleton<TaskManager>::get();
1127 } 1125 }
1128 1126
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698