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

Side by Side Diff: chrome/browser/views/bookmark_table_view.cc

Issue 126184: Move TableModel out of views/ and into app/.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: addressed comments, build fixes Created 11 years, 6 months 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 | « chrome/browser/task_manager_win.cc ('k') | chrome/browser/views/hung_renderer_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 "chrome/browser/views/bookmark_table_view.h" 5 #include "chrome/browser/views/bookmark_table_view.h"
6 6
7 #include <commctrl.h> 7 #include <commctrl.h>
8 8
9 #include "app/drag_drop_types.h" 9 #include "app/drag_drop_types.h"
10 #include "app/gfx/canvas.h" 10 #include "app/gfx/canvas.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/pref_service.h" 21 #include "chrome/common/pref_service.h"
22 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
23 #include "views/controls/table/table_view_observer.h" 23 #include "views/controls/table/table_view_observer.h"
24 #include "views/view_constants.h" 24 #include "views/view_constants.h"
25 25
26 namespace { 26 namespace {
27 27
28 // Height of the drop indicator used when dropping between rows. 28 // Height of the drop indicator used when dropping between rows.
29 const int kDropHighlightHeight = 2; 29 const int kDropHighlightHeight = 2;
30 30
31 int GetWidthOfColumn(const std::vector<views::TableColumn>& columns, 31 int GetWidthOfColumn(const std::vector<TableColumn>& columns,
32 const std::vector<int> widths, 32 const std::vector<int> widths,
33 int column_id) { 33 int column_id) {
34 for (size_t i = 0; i < columns.size(); ++i) { 34 for (size_t i = 0; i < columns.size(); ++i) {
35 if (columns[i].id == column_id) 35 if (columns[i].id == column_id)
36 return widths[i]; 36 return widths[i];
37 } 37 }
38 NOTREACHED(); 38 NOTREACHED();
39 return -1; 39 return -1;
40 } 40 }
41 41
42 } // namespace 42 } // namespace
43 43
44 void BookmarkTableView::DropInfo::Scrolled() { 44 void BookmarkTableView::DropInfo::Scrolled() {
45 view_->UpdateDropInfo(); 45 view_->UpdateDropInfo();
46 } 46 }
47 47
48 BookmarkTableView::BookmarkTableView(Profile* profile, 48 BookmarkTableView::BookmarkTableView(Profile* profile,
49 BookmarkTableModel* model) 49 BookmarkTableModel* model)
50 : views::TableView(model, std::vector<views::TableColumn>(), 50 : views::TableView(model, std::vector<TableColumn>(),
51 views::ICON_AND_TEXT, false, true, true), 51 views::ICON_AND_TEXT, false, true, true),
52 profile_(profile), 52 profile_(profile),
53 show_path_column_(false) { 53 show_path_column_(false) {
54 UpdateColumns(); 54 UpdateColumns();
55 } 55 }
56 56
57 bool BookmarkTableView::CanDrop(const OSExchangeData& data) { 57 bool BookmarkTableView::CanDrop(const OSExchangeData& data) {
58 if (!parent_node_ || !profile_->GetBookmarkModel()->IsLoaded()) 58 if (!parent_node_ || !profile_->GetBookmarkModel()->IsLoaded())
59 return false; 59 return false;
60 60
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } else { 355 } else {
356 ListView_GetItemRect(GetNativeControlHWND(), index, &bounds, LVIR_BOUNDS); 356 ListView_GetItemRect(GetNativeControlHWND(), index, &bounds, LVIR_BOUNDS);
357 bounds.top -= kDropHighlightHeight / 2; 357 bounds.top -= kDropHighlightHeight / 2;
358 } 358 }
359 bounds.bottom = bounds.top + kDropHighlightHeight; 359 bounds.bottom = bounds.top + kDropHighlightHeight;
360 return bounds; 360 return bounds;
361 } 361 }
362 362
363 void BookmarkTableView::UpdateColumns() { 363 void BookmarkTableView::UpdateColumns() {
364 PrefService* prefs = profile_->GetPrefs(); 364 PrefService* prefs = profile_->GetPrefs();
365 views::TableColumn name_column = 365 TableColumn name_column =
366 views::TableColumn(IDS_BOOKMARK_TABLE_TITLE, views::TableColumn::LEFT, 366 TableColumn(IDS_BOOKMARK_TABLE_TITLE, TableColumn::LEFT, -1);
367 -1); 367 TableColumn url_column =
368 views::TableColumn url_column = 368 TableColumn(IDS_BOOKMARK_TABLE_URL, TableColumn::LEFT, -1);
369 views::TableColumn(IDS_BOOKMARK_TABLE_URL, views::TableColumn::LEFT, -1); 369 TableColumn path_column =
370 views::TableColumn path_column = 370 TableColumn(IDS_BOOKMARK_TABLE_PATH, TableColumn::LEFT, -1);
371 views::TableColumn(IDS_BOOKMARK_TABLE_PATH, views::TableColumn::LEFT, -1);
372 371
373 std::vector<views::TableColumn> columns; 372 std::vector<TableColumn> columns;
374 if (show_path_column_) { 373 if (show_path_column_) {
375 int name_width = -1; 374 int name_width = -1;
376 int url_width = -1; 375 int url_width = -1;
377 int path_width = -1; 376 int path_width = -1;
378 if (prefs) { 377 if (prefs) {
379 name_width = prefs->GetInteger(prefs::kBookmarkTableNameWidth2); 378 name_width = prefs->GetInteger(prefs::kBookmarkTableNameWidth2);
380 url_width = prefs->GetInteger(prefs::kBookmarkTableURLWidth2); 379 url_width = prefs->GetInteger(prefs::kBookmarkTableURLWidth2);
381 path_width = prefs->GetInteger(prefs::kBookmarkTablePathWidth); 380 path_width = prefs->GetInteger(prefs::kBookmarkTablePathWidth);
382 } 381 }
383 if (name_width != -1 && url_width != -1 && path_width != -1) { 382 if (name_width != -1 && url_width != -1 && path_width != -1) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 gfx::Rect client_rect(client_rect_rect); 438 gfx::Rect client_rect(client_rect_rect);
440 gfx::Font font = GetAltTextFont(); 439 gfx::Font font = GetAltTextFont();
441 // Pad height by 2 for halo. 440 // Pad height by 2 for halo.
442 return gfx::Rect(kXOffset, content_offset(), client_rect.width() - kXOffset, 441 return gfx::Rect(kXOffset, content_offset(), client_rect.width() - kXOffset,
443 std::max(kImageSize, font.height() + 2)); 442 std::max(kImageSize, font.height() + 2));
444 } 443 }
445 444
446 gfx::Font BookmarkTableView::GetAltTextFont() { 445 gfx::Font BookmarkTableView::GetAltTextFont() {
447 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); 446 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
448 } 447 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager_win.cc ('k') | chrome/browser/views/hung_renderer_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698