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

Side by Side Diff: views/controls/tabbed_pane/native_tabbed_pane_win.cc

Issue 7349021: Convert some more view methods to the ui/views style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
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/tabbed_pane/native_tabbed_pane_win.h" 5 #include "views/controls/tabbed_pane/native_tabbed_pane_win.h"
6 6
7 #include <vssym32.h> 7 #include <vssym32.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 }; 50 };
51 51
52 // Custom layout manager that takes care of sizing and displaying the tab pages. 52 // Custom layout manager that takes care of sizing and displaying the tab pages.
53 class TabLayout : public LayoutManager { 53 class TabLayout : public LayoutManager {
54 public: 54 public:
55 TabLayout() {} 55 TabLayout() {}
56 56
57 // Switches to the tab page identified by the given index. 57 // Switches to the tab page identified by the given index.
58 void SwitchToPage(View* host, View* page) { 58 void SwitchToPage(View* host, View* page) {
59 for (int i = 0; i < host->child_count(); ++i) { 59 for (int i = 0; i < host->child_count(); ++i) {
60 View* child = host->GetChildViewAt(i); 60 View* child = host->child_at(i);
61 // The child might not have been laid out yet. 61 // The child might not have been laid out yet.
62 if (child == page) 62 if (child == page)
63 child->SetBoundsRect(host->GetContentsBounds()); 63 child->SetBoundsRect(host->GetContentsBounds());
64 child->SetVisible(child == page); 64 child->SetVisible(child == page);
65 } 65 }
66 66
67 FocusManager* focus_manager = page->GetFocusManager(); 67 FocusManager* focus_manager = page->GetFocusManager();
68 DCHECK(focus_manager); 68 DCHECK(focus_manager);
69 View* focused_view = focus_manager->GetFocusedView(); 69 View* focused_view = focus_manager->GetFocusedView();
70 if (focused_view && host->Contains(focused_view) && 70 if (focused_view && host->Contains(focused_view) &&
71 !page->Contains(focused_view)) 71 !page->Contains(focused_view))
72 focus_manager->SetFocusedView(page); 72 focus_manager->SetFocusedView(page);
73 } 73 }
74 74
75 private: 75 private:
76 // LayoutManager overrides: 76 // LayoutManager overrides:
77 virtual void Layout(View* host) { 77 virtual void Layout(View* host) {
78 gfx::Rect bounds(host->GetContentsBounds()); 78 gfx::Rect bounds(host->GetContentsBounds());
79 for (int i = 0; i < host->child_count(); ++i) { 79 for (int i = 0; i < host->child_count(); ++i) {
80 View* child = host->GetChildViewAt(i); 80 View* child = host->child_at(i);
81 // We only layout visible children, since it may be expensive. 81 // We only layout visible children, since it may be expensive.
82 if (child->IsVisible() && child->bounds() != bounds) 82 if (child->IsVisible() && child->bounds() != bounds)
83 child->SetBoundsRect(bounds); 83 child->SetBoundsRect(bounds);
84 } 84 }
85 } 85 }
86 86
87 virtual gfx::Size GetPreferredSize(View* host) { 87 virtual gfx::Size GetPreferredSize(View* host) {
88 // First, query the preferred sizes to determine a good width. 88 // First, query the preferred sizes to determine a good width.
89 int width = 0; 89 int width = 0;
90 for (int i = 0; i < host->child_count(); ++i) { 90 for (int i = 0; i < host->child_count(); ++i) {
91 View* page = host->GetChildViewAt(i); 91 View* page = host->child_at(i);
92 width = std::max(width, page->GetPreferredSize().width()); 92 width = std::max(width, page->GetPreferredSize().width());
93 } 93 }
94 // After we know the width, decide on the height. 94 // After we know the width, decide on the height.
95 return gfx::Size(width, GetPreferredHeightForWidth(host, width)); 95 return gfx::Size(width, GetPreferredHeightForWidth(host, width));
96 } 96 }
97 97
98 virtual int GetPreferredHeightForWidth(View* host, int width) { 98 virtual int GetPreferredHeightForWidth(View* host, int width) {
99 int height = 0; 99 int height = 0;
100 for (int i = 0; i < host->child_count(); ++i) { 100 for (int i = 0; i < host->child_count(); ++i) {
101 View* page = host->GetChildViewAt(i); 101 View* page = host->child_at(i);
102 height = std::max(height, page->GetHeightForWidth(width)); 102 height = std::max(height, page->GetHeightForWidth(width));
103 } 103 }
104 return height; 104 return height;
105 } 105 }
106 106
107 DISALLOW_COPY_AND_ASSIGN(TabLayout); 107 DISALLOW_COPY_AND_ASSIGN(TabLayout);
108 }; 108 };
109 109
110 //////////////////////////////////////////////////////////////////////////////// 110 ////////////////////////////////////////////////////////////////////////////////
111 // NativeTabbedPaneWin, public: 111 // NativeTabbedPaneWin, public:
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 //////////////////////////////////////////////////////////////////////////////// 398 ////////////////////////////////////////////////////////////////////////////////
399 // NativeTabbedPaneWrapper, public: 399 // NativeTabbedPaneWrapper, public:
400 400
401 // static 401 // static
402 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper( 402 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper(
403 TabbedPane* tabbed_pane) { 403 TabbedPane* tabbed_pane) {
404 return new NativeTabbedPaneWin(tabbed_pane); 404 return new NativeTabbedPaneWin(tabbed_pane);
405 } 405 }
406 406
407 } // namespace views 407 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/tabbed_pane/native_tabbed_pane_gtk.cc ('k') | views/controls/textfield/native_textfield_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698