| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_view.h" | 5 #include "views/controls/table/table_view.h" |
| 6 | 6 |
| 7 #include <commctrl.h> | 7 #include <commctrl.h> |
| 8 #include <windowsx.h> | 8 #include <windowsx.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 bool autosize_columns) | 57 bool autosize_columns) |
| 58 : model_(model), | 58 : model_(model), |
| 59 table_view_observer_(NULL), | 59 table_view_observer_(NULL), |
| 60 visible_columns_(), | 60 visible_columns_(), |
| 61 all_columns_(), | 61 all_columns_(), |
| 62 column_count_(static_cast<int>(columns.size())), | 62 column_count_(static_cast<int>(columns.size())), |
| 63 table_type_(table_type), | 63 table_type_(table_type), |
| 64 single_selection_(single_selection), | 64 single_selection_(single_selection), |
| 65 ignore_listview_change_(false), | 65 ignore_listview_change_(false), |
| 66 custom_colors_enabled_(false), | 66 custom_colors_enabled_(false), |
| 67 sized_columns_(false), | |
| 68 autosize_columns_(autosize_columns), | 67 autosize_columns_(autosize_columns), |
| 69 resizable_columns_(resizable_columns), | 68 resizable_columns_(resizable_columns), |
| 70 list_view_(NULL), | 69 list_view_(NULL), |
| 71 header_original_handler_(NULL), | 70 header_original_handler_(NULL), |
| 72 original_handler_(NULL), | 71 original_handler_(NULL), |
| 73 ALLOW_THIS_IN_INITIALIZER_LIST(table_view_wrapper_(this)), | 72 ALLOW_THIS_IN_INITIALIZER_LIST(table_view_wrapper_(this)), |
| 74 custom_cell_font_(NULL), | 73 custom_cell_font_(NULL), |
| 75 content_offset_(0) { | 74 content_offset_(0) { |
| 76 for (std::vector<TableColumn>::const_iterator i = columns.begin(); | 75 for (std::vector<TableColumn>::const_iterator i = columns.begin(); |
| 77 i != columns.end(); ++i) { | 76 i != columns.end(); ++i) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 125 |
| 127 SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); | 126 SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); |
| 128 } | 127 } |
| 129 | 128 |
| 130 void TableView::DidChangeBounds(const gfx::Rect& previous, | 129 void TableView::DidChangeBounds(const gfx::Rect& previous, |
| 131 const gfx::Rect& current) { | 130 const gfx::Rect& current) { |
| 132 if (!list_view_) | 131 if (!list_view_) |
| 133 return; | 132 return; |
| 134 SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(FALSE), 0); | 133 SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(FALSE), 0); |
| 135 Layout(); | 134 Layout(); |
| 136 if ((!sized_columns_ || autosize_columns_) && width() > 0) { | 135 if (autosize_columns_ && width() > 0) |
| 137 sized_columns_ = true; | |
| 138 ResetColumnSizes(); | 136 ResetColumnSizes(); |
| 139 } | |
| 140 UpdateContentOffset(); | 137 UpdateContentOffset(); |
| 141 SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); | 138 SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0); |
| 142 } | 139 } |
| 143 | 140 |
| 144 int TableView::RowCount() const { | 141 int TableView::RowCount() const { |
| 145 if (!list_view_) | 142 if (!list_view_) |
| 146 return 0; | 143 return 0; |
| 147 return ListView_GetItemCount(list_view_); | 144 return ListView_GetItemCount(list_view_); |
| 148 } | 145 } |
| 149 | 146 |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 gfx::Font font = GetAltTextFont(); | 1541 gfx::Font font = GetAltTextFont(); |
| 1545 // Pad height by 2 for halo. | 1542 // Pad height by 2 for halo. |
| 1546 return gfx::Rect(kXOffset, content_offset(), client_rect.width() - kXOffset, | 1543 return gfx::Rect(kXOffset, content_offset(), client_rect.width() - kXOffset, |
| 1547 std::max(kImageSize, font.height() + 2)); | 1544 std::max(kImageSize, font.height() + 2)); |
| 1548 } | 1545 } |
| 1549 | 1546 |
| 1550 gfx::Font TableView::GetAltTextFont() { | 1547 gfx::Font TableView::GetAltTextFont() { |
| 1551 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); | 1548 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); |
| 1552 } | 1549 } |
| 1553 | 1550 |
| 1551 void TableView::VisibilityChanged(View* starting_from, bool is_visible) { |
| 1552 // GetClientRect as used by ResetColumnSize to obtain the total width |
| 1553 // available to the columns only works when the native control is visible, so |
| 1554 // update the column sizes in case we become visible. This depends on |
| 1555 // VisibilityChanged() being called in post order on the view tree. |
| 1556 if (is_visible && autosize_columns_) |
| 1557 ResetColumnSizes(); |
| 1558 } |
| 1559 |
| 1554 | 1560 |
| 1555 // | 1561 // |
| 1556 // TableSelectionIterator | 1562 // TableSelectionIterator |
| 1557 // | 1563 // |
| 1558 TableSelectionIterator::TableSelectionIterator(TableView* view, | 1564 TableSelectionIterator::TableSelectionIterator(TableView* view, |
| 1559 int view_index) | 1565 int view_index) |
| 1560 : table_view_(view), | 1566 : table_view_(view), |
| 1561 view_index_(view_index) { | 1567 view_index_(view_index) { |
| 1562 UpdateModelIndexFromViewIndex(); | 1568 UpdateModelIndexFromViewIndex(); |
| 1563 } | 1569 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1588 } | 1594 } |
| 1589 | 1595 |
| 1590 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { | 1596 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { |
| 1591 if (view_index_ == -1) | 1597 if (view_index_ == -1) |
| 1592 model_index_ = -1; | 1598 model_index_ = -1; |
| 1593 else | 1599 else |
| 1594 model_index_ = table_view_->ViewToModel(view_index_); | 1600 model_index_ = table_view_->ViewToModel(view_index_); |
| 1595 } | 1601 } |
| 1596 | 1602 |
| 1597 } // namespace views | 1603 } // namespace views |
| OLD | NEW |