| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ |
| 6 #define UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ | 6 #define UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 #include <vector> | 8 #include <vector> |
| 10 | 9 |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 #include "ui/base/models/list_selection_model.h" | 11 #include "ui/base/models/list_selection_model.h" |
| 13 #include "ui/base/models/table_model.h" | 12 #include "ui/base/models/table_model.h" |
| 14 #include "ui/base/models/table_model_observer.h" | 13 #include "ui/base/models/table_model_observer.h" |
| 15 #include "ui/gfx/font_list.h" | 14 #include "ui/gfx/font_list.h" |
| 16 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
| 17 #include "ui/views/views_export.h" | 16 #include "ui/views/views_export.h" |
| 18 | 17 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 // convert to view coordinates use ModelToView(). | 29 // convert to view coordinates use ModelToView(). |
| 31 // | 30 // |
| 32 // Sorting is done by a locale sensitive string sort. You can customize the | 31 // Sorting is done by a locale sensitive string sort. You can customize the |
| 33 // sort by way of overriding TableModel::CompareValues(). | 32 // sort by way of overriding TableModel::CompareValues(). |
| 34 namespace views { | 33 namespace views { |
| 35 | 34 |
| 36 struct GroupRange; | 35 struct GroupRange; |
| 37 class TableGrouper; | 36 class TableGrouper; |
| 38 class TableHeader; | 37 class TableHeader; |
| 39 class TableViewObserver; | 38 class TableViewObserver; |
| 40 class TableViewRowBackgroundPainter; | |
| 41 class TableViewTestHelper; | 39 class TableViewTestHelper; |
| 42 | 40 |
| 43 // The cells in the first column of a table can contain: | 41 // The cells in the first column of a table can contain: |
| 44 // - only text | 42 // - only text |
| 45 // - a small icon (16x16) and some text | 43 // - a small icon (16x16) and some text |
| 46 // - a check box and some text | 44 // - a check box and some text |
| 47 enum TableTypes { | 45 enum TableTypes { |
| 48 TEXT_ONLY = 0, | 46 TEXT_ONLY = 0, |
| 49 ICON_AND_TEXT, | 47 ICON_AND_TEXT, |
| 50 }; | 48 }; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Assigns a new model to the table view, detaching the old one if present. | 97 // Assigns a new model to the table view, detaching the old one if present. |
| 100 // If |model| is NULL, the table view cannot be used after this call. This | 98 // If |model| is NULL, the table view cannot be used after this call. This |
| 101 // should be called in the containing view's destructor to avoid destruction | 99 // should be called in the containing view's destructor to avoid destruction |
| 102 // issues when the model needs to be deleted before the table. | 100 // issues when the model needs to be deleted before the table. |
| 103 void SetModel(ui::TableModel* model); | 101 void SetModel(ui::TableModel* model); |
| 104 ui::TableModel* model() const { return model_; } | 102 ui::TableModel* model() const { return model_; } |
| 105 | 103 |
| 106 // Returns a new ScrollView that contains the receiver. | 104 // Returns a new ScrollView that contains the receiver. |
| 107 View* CreateParentIfNecessary(); | 105 View* CreateParentIfNecessary(); |
| 108 | 106 |
| 109 void SetRowBackgroundPainter( | |
| 110 std::unique_ptr<TableViewRowBackgroundPainter> painter); | |
| 111 | |
| 112 // Sets the TableGrouper. TableView does not own |grouper| (common use case is | 107 // Sets the TableGrouper. TableView does not own |grouper| (common use case is |
| 113 // to have TableModel implement TableGrouper). | 108 // to have TableModel implement TableGrouper). |
| 114 void SetGrouper(TableGrouper* grouper); | 109 void SetGrouper(TableGrouper* grouper); |
| 115 | 110 |
| 116 // Returns the number of rows in the TableView. | 111 // Returns the number of rows in the TableView. |
| 117 int RowCount() const; | 112 int RowCount() const; |
| 118 | 113 |
| 119 // Selects the specified item, making sure it's visible. | 114 // Selects the specified item, making sure it's visible. |
| 120 void Select(int model_row); | 115 void Select(int model_row); |
| 121 | 116 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // The width we layout to. This may differ from |last_parent_width_|. | 335 // The width we layout to. This may differ from |last_parent_width_|. |
| 341 int layout_width_; | 336 int layout_width_; |
| 342 | 337 |
| 343 // Current sort. | 338 // Current sort. |
| 344 SortDescriptors sort_descriptors_; | 339 SortDescriptors sort_descriptors_; |
| 345 | 340 |
| 346 // Mappings used when sorted. | 341 // Mappings used when sorted. |
| 347 std::vector<int> view_to_model_; | 342 std::vector<int> view_to_model_; |
| 348 std::vector<int> model_to_view_; | 343 std::vector<int> model_to_view_; |
| 349 | 344 |
| 350 std::unique_ptr<TableViewRowBackgroundPainter> row_background_painter_; | |
| 351 | |
| 352 TableGrouper* grouper_; | 345 TableGrouper* grouper_; |
| 353 | 346 |
| 354 // True if in SetVisibleColumnWidth(). | 347 // True if in SetVisibleColumnWidth(). |
| 355 bool in_set_visible_column_width_; | 348 bool in_set_visible_column_width_; |
| 356 | 349 |
| 357 DISALLOW_COPY_AND_ASSIGN(TableView); | 350 DISALLOW_COPY_AND_ASSIGN(TableView); |
| 358 }; | 351 }; |
| 359 | 352 |
| 360 } // namespace views | 353 } // namespace views |
| 361 | 354 |
| 362 #endif // UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ | 355 #endif // UI_VIEWS_CONTROLS_TABLE_TABLE_VIEW_VIEWS_H_ |
| OLD | NEW |