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

Side by Side Diff: ui/views/controls/table/table_view_win.cc

Issue 10790128: Revert 147915 - Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | « ui/views/controls/menu/native_menu_win.cc ('k') | ui/views/controls/tree/tree_view_win.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) 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 #include "ui/views/controls/table/table_view_win.h" 5 #include "ui/views/controls/table/table_view_win.h"
6 6
7 #include <commctrl.h> 7 #include <commctrl.h>
8 #include <windowsx.h> 8 #include <windowsx.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 // Set the # of rows. 802 // Set the # of rows.
803 if (model_) 803 if (model_)
804 UpdateListViewCache(0, model_->RowCount(), true); 804 UpdateListViewCache(0, model_->RowCount(), true);
805 805
806 if (table_type_ == ICON_AND_TEXT) { 806 if (table_type_ == ICON_AND_TEXT) {
807 HIMAGELIST image_list = 807 HIMAGELIST image_list =
808 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); 808 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2);
809 // We create 2 phony images because we are going to switch images at every 809 // We create 2 phony images because we are going to switch images at every
810 // refresh in order to force a refresh of the icon area (somehow the clip 810 // refresh in order to force a refresh of the icon area (somehow the clip
811 // rect does not include the icon). 811 // rect does not include the icon).
812 gfx::Canvas canvas(gfx::Size(kImageSize, kImageSize), ui::SCALE_FACTOR_100P, 812 gfx::Canvas canvas(gfx::Size(kImageSize, kImageSize), false);
813 false);
814 { 813 {
815 base::win::ScopedHICON empty_icon(IconUtil::CreateHICONFromSkBitmap( 814 base::win::ScopedHICON empty_icon(
816 canvas.ExtractImageRep().sk_bitmap())); 815 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()));
817 ImageList_AddIcon(image_list, empty_icon); 816 ImageList_AddIcon(image_list, empty_icon);
818 ImageList_AddIcon(image_list, empty_icon); 817 ImageList_AddIcon(image_list, empty_icon);
819 } 818 }
820 ListView_SetImageList(list_view_, image_list, LVSIL_SMALL); 819 ListView_SetImageList(list_view_, image_list, LVSIL_SMALL);
821 } 820 }
822 821
823 if (!resizable_columns_) { 822 if (!resizable_columns_) {
824 // To disable the resizing of columns we'll filter the events happening on 823 // To disable the resizing of columns we'll filter the events happening on
825 // the header. We also need to intercept the HDM_LAYOUT to size the header 824 // the header. We also need to intercept the HDM_LAYOUT to size the header
826 // for the Chrome headers. 825 // for the Chrome headers.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 list_view_, static_cast<int>(i - visible_columns_.begin())); 1147 list_view_, static_cast<int>(i - visible_columns_.begin()));
1149 } 1148 }
1150 1149
1151 void TableView::PaintAltText() { 1150 void TableView::PaintAltText() {
1152 if (alt_text_.empty()) 1151 if (alt_text_.empty())
1153 return; 1152 return;
1154 1153
1155 HDC dc = GetDC(GetNativeControlHWND()); 1154 HDC dc = GetDC(GetNativeControlHWND());
1156 gfx::Font font = GetAltTextFont(); 1155 gfx::Font font = GetAltTextFont();
1157 gfx::Rect bounds = GetAltTextBounds(); 1156 gfx::Rect bounds = GetAltTextBounds();
1158 gfx::Canvas canvas(bounds.size(), ui::SCALE_FACTOR_100P, false); 1157 gfx::Canvas canvas(bounds.size(), false);
1159 // Pad by 1 for halo. 1158 // Pad by 1 for halo.
1160 canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1, 1159 canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1,
1161 1, bounds.width() - 2, bounds.height() - 2, 1160 1, bounds.width() - 2, bounds.height() - 2,
1162 gfx::Canvas::DefaultCanvasTextAlignment()); 1161 gfx::Canvas::DefaultCanvasTextAlignment());
1163 skia::DrawToNativeContext( 1162 skia::DrawToNativeContext(
1164 canvas.sk_canvas(), dc, bounds.x(), bounds.y(), NULL); 1163 canvas.sk_canvas(), dc, bounds.x(), bounds.y(), NULL);
1165 ReleaseDC(GetNativeControlHWND(), dc); 1164 ReleaseDC(GetNativeControlHWND(), dc);
1166 } 1165 }
1167 1166
1168 LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { 1167 LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 LVIR_ICON) && 1233 LVIR_ICON) &&
1235 GetClientRect(list_view_, &client_rect)) { 1234 GetClientRect(list_view_, &client_rect)) {
1236 RECT intersection; 1235 RECT intersection;
1237 // Client rect includes the header but we need to make sure we don't 1236 // Client rect includes the header but we need to make sure we don't
1238 // paint into it. 1237 // paint into it.
1239 client_rect.top += content_offset_; 1238 client_rect.top += content_offset_;
1240 // Make sure the region need to paint is visible. 1239 // Make sure the region need to paint is visible.
1241 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { 1240 if (IntersectRect(&intersection, &icon_rect, &client_rect)) {
1242 gfx::Canvas canvas(gfx::Size(icon_rect.right - icon_rect.left, 1241 gfx::Canvas canvas(gfx::Size(icon_rect.right - icon_rect.left,
1243 icon_rect.bottom - icon_rect.top), 1242 icon_rect.bottom - icon_rect.top),
1244 ui::SCALE_FACTOR_100P,
1245 false); 1243 false);
1246 1244
1247 // It seems the state in nmcd.uItemState is not correct. 1245 // It seems the state in nmcd.uItemState is not correct.
1248 // We'll retrieve it explicitly. 1246 // We'll retrieve it explicitly.
1249 int selected = ListView_GetItemState( 1247 int selected = ListView_GetItemState(
1250 list_view_, view_index, LVIS_SELECTED | LVIS_DROPHILITED); 1248 list_view_, view_index, LVIS_SELECTED | LVIS_DROPHILITED);
1251 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); 1249 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0);
1252 int bg_color_index; 1250 int bg_color_index;
1253 if (!enabled()) 1251 if (!enabled())
1254 bg_color_index = COLOR_3DFACE; 1252 bg_color_index = COLOR_3DFACE;
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 } 1639 }
1642 1640
1643 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { 1641 void TableSelectionIterator::UpdateModelIndexFromViewIndex() {
1644 if (view_index_ == -1) 1642 if (view_index_ == -1)
1645 model_index_ = -1; 1643 model_index_ = -1;
1646 else 1644 else
1647 model_index_ = table_view_->ViewToModel(view_index_); 1645 model_index_ = table_view_->ViewToModel(view_index_);
1648 } 1646 }
1649 1647
1650 } // namespace views 1648 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/native_menu_win.cc ('k') | ui/views/controls/tree/tree_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698