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 #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 Loading... |
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), false); | 812 gfx::Canvas canvas(gfx::Size(kImageSize, kImageSize), ui::SCALE_FACTOR_100P, |
| 813 false); |
813 { | 814 { |
814 base::win::ScopedHICON empty_icon( | 815 base::win::ScopedHICON empty_icon(IconUtil::CreateHICONFromSkBitmap( |
815 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap())); | 816 canvas.ExtractImageRep().sk_bitmap())); |
816 ImageList_AddIcon(image_list, empty_icon); | 817 ImageList_AddIcon(image_list, empty_icon); |
817 ImageList_AddIcon(image_list, empty_icon); | 818 ImageList_AddIcon(image_list, empty_icon); |
818 } | 819 } |
819 ListView_SetImageList(list_view_, image_list, LVSIL_SMALL); | 820 ListView_SetImageList(list_view_, image_list, LVSIL_SMALL); |
820 } | 821 } |
821 | 822 |
822 if (!resizable_columns_) { | 823 if (!resizable_columns_) { |
823 // To disable the resizing of columns we'll filter the events happening on | 824 // To disable the resizing of columns we'll filter the events happening on |
824 // the header. We also need to intercept the HDM_LAYOUT to size the header | 825 // the header. We also need to intercept the HDM_LAYOUT to size the header |
825 // for the Chrome headers. | 826 // for the Chrome headers. |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 list_view_, static_cast<int>(i - visible_columns_.begin())); | 1148 list_view_, static_cast<int>(i - visible_columns_.begin())); |
1148 } | 1149 } |
1149 | 1150 |
1150 void TableView::PaintAltText() { | 1151 void TableView::PaintAltText() { |
1151 if (alt_text_.empty()) | 1152 if (alt_text_.empty()) |
1152 return; | 1153 return; |
1153 | 1154 |
1154 HDC dc = GetDC(GetNativeControlHWND()); | 1155 HDC dc = GetDC(GetNativeControlHWND()); |
1155 gfx::Font font = GetAltTextFont(); | 1156 gfx::Font font = GetAltTextFont(); |
1156 gfx::Rect bounds = GetAltTextBounds(); | 1157 gfx::Rect bounds = GetAltTextBounds(); |
1157 gfx::Canvas canvas(bounds.size(), false); | 1158 gfx::Canvas canvas(bounds.size(), ui::SCALE_FACTOR_100P, false); |
1158 // Pad by 1 for halo. | 1159 // Pad by 1 for halo. |
1159 canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1, | 1160 canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1, |
1160 1, bounds.width() - 2, bounds.height() - 2, | 1161 1, bounds.width() - 2, bounds.height() - 2, |
1161 gfx::Canvas::DefaultCanvasTextAlignment()); | 1162 gfx::Canvas::DefaultCanvasTextAlignment()); |
1162 skia::DrawToNativeContext( | 1163 skia::DrawToNativeContext( |
1163 canvas.sk_canvas(), dc, bounds.x(), bounds.y(), NULL); | 1164 canvas.sk_canvas(), dc, bounds.x(), bounds.y(), NULL); |
1164 ReleaseDC(GetNativeControlHWND(), dc); | 1165 ReleaseDC(GetNativeControlHWND(), dc); |
1165 } | 1166 } |
1166 | 1167 |
1167 LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { | 1168 LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 LVIR_ICON) && | 1234 LVIR_ICON) && |
1234 GetClientRect(list_view_, &client_rect)) { | 1235 GetClientRect(list_view_, &client_rect)) { |
1235 RECT intersection; | 1236 RECT intersection; |
1236 // Client rect includes the header but we need to make sure we don't | 1237 // Client rect includes the header but we need to make sure we don't |
1237 // paint into it. | 1238 // paint into it. |
1238 client_rect.top += content_offset_; | 1239 client_rect.top += content_offset_; |
1239 // Make sure the region need to paint is visible. | 1240 // Make sure the region need to paint is visible. |
1240 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { | 1241 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { |
1241 gfx::Canvas canvas(gfx::Size(icon_rect.right - icon_rect.left, | 1242 gfx::Canvas canvas(gfx::Size(icon_rect.right - icon_rect.left, |
1242 icon_rect.bottom - icon_rect.top), | 1243 icon_rect.bottom - icon_rect.top), |
| 1244 ui::SCALE_FACTOR_100P, |
1243 false); | 1245 false); |
1244 | 1246 |
1245 // It seems the state in nmcd.uItemState is not correct. | 1247 // It seems the state in nmcd.uItemState is not correct. |
1246 // We'll retrieve it explicitly. | 1248 // We'll retrieve it explicitly. |
1247 int selected = ListView_GetItemState( | 1249 int selected = ListView_GetItemState( |
1248 list_view_, view_index, LVIS_SELECTED | LVIS_DROPHILITED); | 1250 list_view_, view_index, LVIS_SELECTED | LVIS_DROPHILITED); |
1249 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); | 1251 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); |
1250 int bg_color_index; | 1252 int bg_color_index; |
1251 if (!enabled()) | 1253 if (!enabled()) |
1252 bg_color_index = COLOR_3DFACE; | 1254 bg_color_index = COLOR_3DFACE; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 } | 1641 } |
1640 | 1642 |
1641 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { | 1643 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { |
1642 if (view_index_ == -1) | 1644 if (view_index_ == -1) |
1643 model_index_ = -1; | 1645 model_index_ = -1; |
1644 else | 1646 else |
1645 model_index_ = table_view_->ViewToModel(view_index_); | 1647 model_index_ = table_view_->ViewToModel(view_index_); |
1646 } | 1648 } |
1647 | 1649 |
1648 } // namespace views | 1650 } // namespace views |
OLD | NEW |