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