| OLD | NEW |
| 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/views/tabbed_pane.h" | 5 #include "chrome/views/tabbed_pane.h" |
| 6 | 6 |
| 7 #include <vssym32.h> | 7 #include <vssym32.h> |
| 8 | 8 |
| 9 #include "base/gfx/native_theme.h" | 9 #include "base/gfx/native_theme.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 return removed_tab; | 126 return removed_tab; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void TabbedPane::SelectTabAt(int index) { | 129 void TabbedPane::SelectTabAt(int index) { |
| 130 DCHECK(index < static_cast<int>(tab_views_.size())); | 130 DCHECK(index < static_cast<int>(tab_views_.size())); |
| 131 TabCtrl_SetCurSel(tab_control_, index); | 131 TabCtrl_SetCurSel(tab_control_, index); |
| 132 DoSelectTabAt(index); | 132 DoSelectTabAt(index); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void TabbedPane::SelectTabForContents(const View* contents) { |
| 136 int index = GetIndexOfTab(contents); |
| 137 if (index != -1) |
| 138 SelectTabAt(index); |
| 139 } |
| 140 |
| 135 int TabbedPane::GetTabCount() { | 141 int TabbedPane::GetTabCount() { |
| 136 return TabCtrl_GetItemCount(tab_control_); | 142 return TabCtrl_GetItemCount(tab_control_); |
| 137 } | 143 } |
| 138 | 144 |
| 139 HWND TabbedPane::CreateNativeControl(HWND parent_container) { | 145 HWND TabbedPane::CreateNativeControl(HWND parent_container) { |
| 140 // Create the tab control. | 146 // Create the tab control. |
| 141 // | 147 // |
| 142 // Note that we don't follow the common convention for NativeControl | 148 // Note that we don't follow the common convention for NativeControl |
| 143 // subclasses and we don't pass the value returned from | 149 // subclasses and we don't pass the value returned from |
| 144 // NativeControl::GetAdditionalExStyle() as the dwExStyle parameter. Here is | 150 // NativeControl::GetAdditionalExStyle() as the dwExStyle parameter. Here is |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (focused_view && content_root->IsParentOf(focused_view)) | 215 if (focused_view && content_root->IsParentOf(focused_view)) |
| 210 focus_manager->ClearFocus(); | 216 focus_manager->ClearFocus(); |
| 211 | 217 |
| 212 content_root->RemoveAllChildViews(false); | 218 content_root->RemoveAllChildViews(false); |
| 213 content_root->AddChildView(tab_views_[index]); | 219 content_root->AddChildView(tab_views_[index]); |
| 214 content_root->Layout(); | 220 content_root->Layout(); |
| 215 if (listener_) | 221 if (listener_) |
| 216 listener_->TabSelectedAt(index); | 222 listener_->TabSelectedAt(index); |
| 217 } | 223 } |
| 218 | 224 |
| 225 int TabbedPane::GetIndexOfTab(const View* contents) const { |
| 226 DCHECK(contents); |
| 227 std::vector<View*>::const_iterator i = std::find(tab_views_.begin(), |
| 228 tab_views_.end(), contents); |
| 229 if (i != tab_views_.end()) |
| 230 return static_cast<int>(i - tab_views_.begin()); |
| 231 return -1; |
| 232 } |
| 233 |
| 219 void TabbedPane::Layout() { | 234 void TabbedPane::Layout() { |
| 220 NativeControl::Layout(); | 235 NativeControl::Layout(); |
| 221 ResizeContents(GetNativeControlHWND()); | 236 ResizeContents(GetNativeControlHWND()); |
| 222 } | 237 } |
| 223 | 238 |
| 224 RootView* TabbedPane::GetContentsRootView() { | 239 RootView* TabbedPane::GetContentsRootView() { |
| 225 return content_window_->GetRootView(); | 240 return content_window_->GetRootView(); |
| 226 } | 241 } |
| 227 | 242 |
| 228 FocusTraversable* TabbedPane::GetFocusTraversable() { | 243 FocusTraversable* TabbedPane::GetFocusTraversable() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 245 if (!GetClientRect(tab_control, &content_bounds)) | 260 if (!GetClientRect(tab_control, &content_bounds)) |
| 246 return; | 261 return; |
| 247 TabCtrl_AdjustRect(tab_control, FALSE, &content_bounds); | 262 TabCtrl_AdjustRect(tab_control, FALSE, &content_bounds); |
| 248 content_window_->MoveWindow(content_bounds.left, content_bounds.top, | 263 content_window_->MoveWindow(content_bounds.left, content_bounds.top, |
| 249 content_bounds.Width(), content_bounds.Height(), | 264 content_bounds.Width(), content_bounds.Height(), |
| 250 TRUE); | 265 TRUE); |
| 251 } | 266 } |
| 252 | 267 |
| 253 } // namespace views | 268 } // namespace views |
| 254 | 269 |
| OLD | NEW |