OLD | NEW |
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/table/table_view2.h" | 5 #include "views/controls/table/table_view2.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/models/table_model.h" | 8 #include "ui/base/models/table_model.h" |
9 #include "views/controls/native/native_view_host.h" | 9 #include "views/controls/native/native_view_host.h" |
10 #include "views/controls/table/table_view_observer.h" | 10 #include "views/controls/table/table_view_observer.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 | 13 |
14 // TableView2 ------------------------------------------------------------------ | |
15 | |
16 TableView2::TableView2(ui::TableModel* model, | 14 TableView2::TableView2(ui::TableModel* model, |
17 const std::vector<ui::TableColumn>& columns, | 15 const std::vector<ui::TableColumn>& columns, |
18 TableTypes table_type, | 16 TableTypes table_type, |
19 int options) | 17 int options) |
20 : model_(model), | 18 : model_(model), |
21 table_type_(table_type), | 19 table_type_(table_type), |
22 table_view_observer_(NULL), | 20 table_view_observer_(NULL), |
23 visible_columns_(), | 21 visible_columns_(), |
24 all_columns_(), | 22 all_columns_(), |
25 column_count_(static_cast<int>(columns.size())), | 23 column_count_(static_cast<int>(columns.size())), |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 299 } |
302 | 300 |
303 size_t TableView2::GetVisibleColumnCount() { | 301 size_t TableView2::GetVisibleColumnCount() { |
304 return visible_columns_.size(); | 302 return visible_columns_.size(); |
305 } | 303 } |
306 | 304 |
307 void TableView2::ViewHierarchyChanged(bool is_add, View* parent, View* child) { | 305 void TableView2::ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
308 if (is_add && !native_wrapper_ && GetWidget()) { | 306 if (is_add && !native_wrapper_ && GetWidget()) { |
309 // The native wrapper's lifetime will be managed by the view hierarchy after | 307 // The native wrapper's lifetime will be managed by the view hierarchy after |
310 // we call AddChildView. | 308 // we call AddChildView. |
311 native_wrapper_ = CreateWrapper(); | 309 native_wrapper_ = NativeTableWrapper::CreateNativeWrapper(this); |
312 AddChildView(native_wrapper_->GetView()); | 310 AddChildView(native_wrapper_->GetView()); |
313 } | 311 } |
314 } | 312 } |
315 | 313 |
316 void TableView2::Init(const std::vector<ui::TableColumn>& columns) { | 314 void TableView2::Init(const std::vector<ui::TableColumn>& columns) { |
317 for (std::vector<ui::TableColumn>::const_iterator i = columns.begin(); | 315 for (std::vector<ui::TableColumn>::const_iterator i = columns.begin(); |
318 i != columns.end(); ++i) { | 316 i != columns.end(); ++i) { |
319 AddColumn(*i); | 317 AddColumn(*i); |
320 visible_columns_.push_back(i->id); | 318 visible_columns_.push_back(i->id); |
321 } | 319 } |
322 } | 320 } |
323 | 321 |
324 gfx::NativeView TableView2::GetTestingHandle() { | 322 gfx::NativeView TableView2::GetTestingHandle() { |
325 return native_wrapper_->GetTestingHandle(); | 323 return native_wrapper_->GetTestingHandle(); |
326 } | 324 } |
327 | 325 |
328 ui::TableColumn TableView2::GetVisibleColumnAt(int index) { | 326 ui::TableColumn TableView2::GetVisibleColumnAt(int index) { |
329 DCHECK(index < static_cast<int>(visible_columns_.size())); | 327 DCHECK(index < static_cast<int>(visible_columns_.size())); |
330 std::map<int, ui::TableColumn>::iterator iter = | 328 std::map<int, ui::TableColumn>::iterator iter = |
331 all_columns_.find(index); | 329 all_columns_.find(index); |
332 DCHECK(iter != all_columns_.end()); | 330 DCHECK(iter != all_columns_.end()); |
333 return iter->second; | 331 return iter->second; |
334 } | 332 } |
335 | 333 |
336 //////////////////////////////////////////////////////////////////////////////// | |
337 // NativeTable2, protected: | |
338 | |
339 NativeTableWrapper* TableView2::CreateWrapper() { | |
340 return NativeTableWrapper::CreateNativeWrapper(this); | |
341 } | |
342 | |
343 } // namespace views | 334 } // namespace views |
OLD | NEW |