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 #ifndef APP_TABLE_MODEL_H_ | 5 #ifndef APP_TABLE_MODEL_H_ |
6 #define APP_TABLE_MODEL_H_ | 6 #define APP_TABLE_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
viettrungluu
2010/12/29 23:41:17
No longer needed?
Avi (use Gerrit)
2010/12/30 00:04:15
Done.
| |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/string16.h" | |
12 #include "unicode/coll.h" | 13 #include "unicode/coll.h" |
13 | 14 |
14 class SkBitmap; | 15 class SkBitmap; |
15 | 16 |
16 class TableModelObserver; | 17 class TableModelObserver; |
17 | 18 |
18 // The model driving the TableView. | 19 // The model driving the TableView. |
19 class TableModel { | 20 class TableModel { |
20 public: | 21 public: |
21 // See HasGroups, get GetGroupID for details as to how this is used. | 22 // See HasGroups, get GetGroupID for details as to how this is used. |
22 struct Group { | 23 struct Group { |
23 // The title text for the group. | 24 // The title text for the group. |
24 std::wstring title; | 25 string16 title; |
25 | 26 |
26 // Unique id for the group. | 27 // Unique id for the group. |
27 int id; | 28 int id; |
28 }; | 29 }; |
29 typedef std::vector<Group> Groups; | 30 typedef std::vector<Group> Groups; |
30 | 31 |
31 // Number of rows in the model. | 32 // Number of rows in the model. |
32 virtual int RowCount() = 0; | 33 virtual int RowCount() = 0; |
33 | 34 |
34 // Returns the value at a particular location in text. | 35 // Returns the value at a particular location in text. |
35 virtual std::wstring GetText(int row, int column_id) = 0; | 36 virtual string16 GetText(int row, int column_id) = 0; |
36 | 37 |
37 // Returns the small icon (16x16) that should be displayed in the first | 38 // Returns the small icon (16x16) that should be displayed in the first |
38 // column before the text. This is only used when the TableView was created | 39 // column before the text. This is only used when the TableView was created |
39 // with the ICON_AND_TEXT table type. Returns an isNull() bitmap if there is | 40 // with the ICON_AND_TEXT table type. Returns an isNull() bitmap if there is |
40 // no bitmap. | 41 // no bitmap. |
41 virtual SkBitmap GetIcon(int row); | 42 virtual SkBitmap GetIcon(int row); |
42 | 43 |
43 // Returns the tooltip, if any, to show for a particular row. If there are | 44 // Returns the tooltip, if any, to show for a particular row. If there are |
44 // multiple columns in the row, this will only be shown when hovering over | 45 // multiple columns in the row, this will only be shown when hovering over |
45 // column zero. | 46 // column zero. |
46 virtual std::wstring GetTooltip(int row); | 47 virtual string16 GetTooltip(int row); |
47 | 48 |
48 // If true, this row should be indented. | 49 // If true, this row should be indented. |
49 virtual bool ShouldIndent(int row); | 50 virtual bool ShouldIndent(int row); |
50 | 51 |
51 // Returns true if the TableView has groups. Groups provide a way to visually | 52 // Returns true if the TableView has groups. Groups provide a way to visually |
52 // delineate the rows in a table view. When groups are enabled table view | 53 // delineate the rows in a table view. When groups are enabled table view |
53 // shows a visual separator for each group, followed by all the rows in | 54 // shows a visual separator for each group, followed by all the rows in |
54 // the group. | 55 // the group. |
55 // | 56 // |
56 // On win2k a visual separator is not rendered for the group headers. | 57 // On win2k a visual separator is not rendered for the group headers. |
(...skipping 29 matching lines...) Expand all Loading... | |
86 icu::Collator* GetCollator(); | 87 icu::Collator* GetCollator(); |
87 }; | 88 }; |
88 | 89 |
89 // TableColumn specifies the title, alignment and size of a particular column. | 90 // TableColumn specifies the title, alignment and size of a particular column. |
90 struct TableColumn { | 91 struct TableColumn { |
91 enum Alignment { | 92 enum Alignment { |
92 LEFT, RIGHT, CENTER | 93 LEFT, RIGHT, CENTER |
93 }; | 94 }; |
94 | 95 |
95 TableColumn(); | 96 TableColumn(); |
96 TableColumn(int id, const std::wstring& title, | 97 TableColumn(int id, const string16& title, |
97 Alignment alignment, int width); | 98 Alignment alignment, int width); |
98 TableColumn(int id, const std::wstring& title, | 99 TableColumn(int id, const string16& title, |
99 Alignment alignment, int width, float percent); | 100 Alignment alignment, int width, float percent); |
100 | 101 |
101 // It's common (but not required) to use the title's IDS_* tag as the column | 102 // It's common (but not required) to use the title's IDS_* tag as the column |
102 // id. In this case, the provided conveniences look up the title string on | 103 // id. In this case, the provided conveniences look up the title string on |
103 // bahalf of the caller. | 104 // bahalf of the caller. |
104 TableColumn(int id, Alignment alignment, int width); | 105 TableColumn(int id, Alignment alignment, int width); |
105 TableColumn(int id, Alignment alignment, int width, float percent); | 106 TableColumn(int id, Alignment alignment, int width, float percent); |
106 | 107 |
107 // A unique identifier for the column. | 108 // A unique identifier for the column. |
108 int id; | 109 int id; |
109 | 110 |
110 // The title for the column. | 111 // The title for the column. |
111 std::wstring title; | 112 string16 title; |
112 | 113 |
113 // Alignment for the content. | 114 // Alignment for the content. |
114 Alignment alignment; | 115 Alignment alignment; |
115 | 116 |
116 // The size of a column may be specified in two ways: | 117 // The size of a column may be specified in two ways: |
117 // 1. A fixed width. Set the width field to a positive number and the | 118 // 1. A fixed width. Set the width field to a positive number and the |
118 // column will be given that width, in pixels. | 119 // column will be given that width, in pixels. |
119 // 2. As a percentage of the available width. If width is -1, and percent is | 120 // 2. As a percentage of the available width. If width is -1, and percent is |
120 // > 0, the column is given a width of | 121 // > 0, the column is given a width of |
121 // available_width * percent / total_percent. | 122 // available_width * percent / total_percent. |
(...skipping 10 matching lines...) Expand all Loading... | |
132 // The minimum width required for all items in this column | 133 // The minimum width required for all items in this column |
133 // (including the header) | 134 // (including the header) |
134 // to be visible. | 135 // to be visible. |
135 int min_visible_width; | 136 int min_visible_width; |
136 | 137 |
137 // Is this column sortable? Default is false | 138 // Is this column sortable? Default is false |
138 bool sortable; | 139 bool sortable; |
139 }; | 140 }; |
140 | 141 |
141 #endif // APP_TABLE_MODEL_H_ | 142 #endif // APP_TABLE_MODEL_H_ |
OLD | NEW |