Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Side by Side Diff: views/controls/table/group_table_view.cc

Issue 4987001: Implement new task manager mocks on windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated per review feedback Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/table/group_table_view.h ('k') | views/controls/table/table_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/group_table_view.h" 5 #include "views/controls/table/group_table_view.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/task.h" 9 #include "base/task.h"
10 #include "gfx/canvas.h" 10 #include "gfx/canvas.h"
11 11
12 namespace views { 12 namespace views {
13 13
14 static const COLORREF kSeparatorLineColor = RGB(208, 208, 208); 14 static const COLORREF kSeparatorLineColor = RGB(208, 208, 208);
15 static const int kSeparatorLineThickness = 1; 15 static const int kSeparatorLineThickness = 1;
16 16
17 const char GroupTableView::kViewClassName[] = "views/GroupTableView"; 17 const char GroupTableView::kViewClassName[] = "views/GroupTableView";
18 18
19 GroupTableView::GroupTableView(GroupTableModel* model, 19 GroupTableView::GroupTableView(GroupTableModel* model,
20 const std::vector<TableColumn>& columns, 20 const std::vector<TableColumn>& columns,
21 TableTypes table_type, 21 TableTypes table_type,
22 bool single_selection, 22 bool single_selection,
23 bool resizable_columns, 23 bool resizable_columns,
24 bool autosize_columns) 24 bool autosize_columns,
25 bool draw_group_separators)
25 : TableView(model, columns, table_type, false, resizable_columns, 26 : TableView(model, columns, table_type, false, resizable_columns,
26 autosize_columns), 27 autosize_columns),
27 model_(model), 28 model_(model),
29 draw_group_separators_(draw_group_separators),
28 ALLOW_THIS_IN_INITIALIZER_LIST(sync_selection_factory_(this)) { 30 ALLOW_THIS_IN_INITIALIZER_LIST(sync_selection_factory_(this)) {
29 } 31 }
30 32
31 GroupTableView::~GroupTableView() { 33 GroupTableView::~GroupTableView() {
32 } 34 }
33 35
34 void GroupTableView::SyncSelection() { 36 void GroupTableView::SyncSelection() {
35 int index = 0; 37 int index = 0;
36 int row_count = model_->RowCount(); 38 int row_count = model_->RowCount();
37 GroupRange group_range; 39 GroupRange group_range;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 MessageLoop::current()->PostTask(FROM_HERE, 163 MessageLoop::current()->PostTask(FROM_HERE,
162 sync_selection_factory_.NewRunnableMethod( 164 sync_selection_factory_.NewRunnableMethod(
163 &GroupTableView::SyncSelection)); 165 &GroupTableView::SyncSelection));
164 } 166 }
165 TableView::OnSelectedStateChanged(); 167 TableView::OnSelectedStateChanged();
166 } 168 }
167 169
168 // Draws the line separator betweens the groups. 170 // Draws the line separator betweens the groups.
169 void GroupTableView::PostPaint(int model_row, int column, bool selected, 171 void GroupTableView::PostPaint(int model_row, int column, bool selected,
170 const gfx::Rect& bounds, HDC hdc) { 172 const gfx::Rect& bounds, HDC hdc) {
173 if (!draw_group_separators_)
174 return;
175
171 GroupRange group_range; 176 GroupRange group_range;
172 model_->GetGroupRangeForItem(model_row, &group_range); 177 model_->GetGroupRangeForItem(model_row, &group_range);
173 178
174 // We always paint a vertical line at the end of the last cell. 179 // We always paint a vertical line at the end of the last cell.
175 HPEN hPen = CreatePen(PS_SOLID, kSeparatorLineThickness, kSeparatorLineColor); 180 HPEN hPen = CreatePen(PS_SOLID, kSeparatorLineThickness, kSeparatorLineColor);
176 HPEN hPenOld = (HPEN) SelectObject(hdc, hPen); 181 HPEN hPenOld = (HPEN) SelectObject(hdc, hPen);
177 int x = bounds.right() - kSeparatorLineThickness; 182 int x = bounds.right() - kSeparatorLineThickness;
178 MoveToEx(hdc, x, bounds.y(), NULL); 183 MoveToEx(hdc, x, bounds.y(), NULL);
179 LineTo(hdc, x, bounds.bottom()); 184 LineTo(hdc, x, bounds.bottom());
180 185
181 // We paint a separator line after the last item of a group. 186 // We paint a separator line after the last item of a group.
182 if (model_row == (group_range.start + group_range.length - 1)) { 187 if (model_row == (group_range.start + group_range.length - 1)) {
183 int y = bounds.bottom() - kSeparatorLineThickness; 188 int y = bounds.bottom() - kSeparatorLineThickness;
184 MoveToEx(hdc, 0, y, NULL); 189 MoveToEx(hdc, 0, y, NULL);
185 LineTo(hdc, bounds.width(), y); 190 LineTo(hdc, bounds.width(), y);
186 } 191 }
187 SelectObject(hdc, hPenOld); 192 SelectObject(hdc, hPenOld);
188 DeleteObject(hPen); 193 DeleteObject(hPen);
189 } 194 }
190 195
191 std::string GroupTableView::GetClassName() const { 196 std::string GroupTableView::GetClassName() const {
192 return kViewClassName; 197 return kViewClassName;
193 } 198 }
194 199
195 } // namespace views 200 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/table/group_table_view.h ('k') | views/controls/table/table_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698