| 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 #include "views/controls/table/table_view.h" | 5 #include "views/controls/table/table_view.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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 // Set the # of rows. | 827 // Set the # of rows. |
| 828 if (model_) | 828 if (model_) |
| 829 UpdateListViewCache(0, model_->RowCount(), true); | 829 UpdateListViewCache(0, model_->RowCount(), true); |
| 830 | 830 |
| 831 if (table_type_ == ICON_AND_TEXT) { | 831 if (table_type_ == ICON_AND_TEXT) { |
| 832 HIMAGELIST image_list = | 832 HIMAGELIST image_list = |
| 833 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); | 833 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); |
| 834 // We create 2 phony images because we are going to switch images at every | 834 // We create 2 phony images because we are going to switch images at every |
| 835 // refresh in order to force a refresh of the icon area (somehow the clip | 835 // refresh in order to force a refresh of the icon area (somehow the clip |
| 836 // rect does not include the icon). | 836 // rect does not include the icon). |
| 837 gfx::Canvas canvas(kImageSize, kImageSize, false); | 837 gfx::CanvasSkia canvas(kImageSize, kImageSize, false); |
| 838 // Make the background completely transparent. | 838 // Make the background completely transparent. |
| 839 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); | 839 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
| 840 HICON empty_icon = | 840 HICON empty_icon = |
| 841 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); | 841 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); |
| 842 ImageList_AddIcon(image_list, empty_icon); | 842 ImageList_AddIcon(image_list, empty_icon); |
| 843 ImageList_AddIcon(image_list, empty_icon); | 843 ImageList_AddIcon(image_list, empty_icon); |
| 844 DeleteObject(empty_icon); | 844 DeleteObject(empty_icon); |
| 845 ListView_SetImageList(list_view_, image_list, LVSIL_SMALL); | 845 ListView_SetImageList(list_view_, image_list, LVSIL_SMALL); |
| 846 } | 846 } |
| 847 | 847 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 list_view_, static_cast<int>(i - visible_columns_.begin())); | 1146 list_view_, static_cast<int>(i - visible_columns_.begin())); |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 void TableView::PaintAltText() { | 1149 void TableView::PaintAltText() { |
| 1150 if (alt_text_.empty()) | 1150 if (alt_text_.empty()) |
| 1151 return; | 1151 return; |
| 1152 | 1152 |
| 1153 HDC dc = GetDC(GetNativeControlHWND()); | 1153 HDC dc = GetDC(GetNativeControlHWND()); |
| 1154 gfx::Font font = GetAltTextFont(); | 1154 gfx::Font font = GetAltTextFont(); |
| 1155 gfx::Rect bounds = GetAltTextBounds(); | 1155 gfx::Rect bounds = GetAltTextBounds(); |
| 1156 gfx::Canvas canvas(bounds.width(), bounds.height(), false); | 1156 gfx::CanvasSkia canvas(bounds.width(), bounds.height(), false); |
| 1157 // Pad by 1 for halo. | 1157 // Pad by 1 for halo. |
| 1158 canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1, | 1158 canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1, |
| 1159 1, bounds.width() - 2, bounds.height() - 2, | 1159 1, bounds.width() - 2, bounds.height() - 2, |
| 1160 gfx::Canvas::DefaultCanvasTextAlignment()); | 1160 gfx::Canvas::DefaultCanvasTextAlignment()); |
| 1161 canvas.getTopPlatformDevice().drawToHDC(dc, bounds.x(), bounds.y(), NULL); | 1161 canvas.getTopPlatformDevice().drawToHDC(dc, bounds.x(), bounds.y(), NULL); |
| 1162 ReleaseDC(GetNativeControlHWND(), dc); | 1162 ReleaseDC(GetNativeControlHWND(), dc); |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { | 1165 LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) { |
| 1166 switch (draw_info->nmcd.dwDrawStage) { | 1166 switch (draw_info->nmcd.dwDrawStage) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 RECT icon_rect, client_rect; | 1229 RECT icon_rect, client_rect; |
| 1230 if (ListView_GetItemRect(list_view_, view_index, &icon_rect, | 1230 if (ListView_GetItemRect(list_view_, view_index, &icon_rect, |
| 1231 LVIR_ICON) && | 1231 LVIR_ICON) && |
| 1232 GetClientRect(list_view_, &client_rect)) { | 1232 GetClientRect(list_view_, &client_rect)) { |
| 1233 RECT intersection; | 1233 RECT intersection; |
| 1234 // Client rect includes the header but we need to make sure we don't | 1234 // Client rect includes the header but we need to make sure we don't |
| 1235 // paint into it. | 1235 // paint into it. |
| 1236 client_rect.top += content_offset_; | 1236 client_rect.top += content_offset_; |
| 1237 // Make sure the region need to paint is visible. | 1237 // Make sure the region need to paint is visible. |
| 1238 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { | 1238 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { |
| 1239 gfx::Canvas canvas(icon_rect.right - icon_rect.left, | 1239 gfx::CanvasSkia canvas(icon_rect.right - icon_rect.left, |
| 1240 icon_rect.bottom - icon_rect.top, false); | 1240 icon_rect.bottom - icon_rect.top, false); |
| 1241 | 1241 |
| 1242 // It seems the state in nmcd.uItemState is not correct. | 1242 // It seems the state in nmcd.uItemState is not correct. |
| 1243 // We'll retrieve it explicitly. | 1243 // We'll retrieve it explicitly. |
| 1244 int selected = ListView_GetItemState( | 1244 int selected = ListView_GetItemState( |
| 1245 list_view_, view_index, LVIS_SELECTED | LVIS_DROPHILITED); | 1245 list_view_, view_index, LVIS_SELECTED | LVIS_DROPHILITED); |
| 1246 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); | 1246 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); |
| 1247 int bg_color_index; | 1247 int bg_color_index; |
| 1248 if (!IsEnabled()) | 1248 if (!IsEnabled()) |
| 1249 bg_color_index = COLOR_3DFACE; | 1249 bg_color_index = COLOR_3DFACE; |
| 1250 else if (drop_highlight) | 1250 else if (drop_highlight) |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 } | 1588 } |
| 1589 | 1589 |
| 1590 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { | 1590 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { |
| 1591 if (view_index_ == -1) | 1591 if (view_index_ == -1) |
| 1592 model_index_ = -1; | 1592 model_index_ = -1; |
| 1593 else | 1593 else |
| 1594 model_index_ = table_view_->ViewToModel(view_index_); | 1594 model_index_ = table_view_->ViewToModel(view_index_); |
| 1595 } | 1595 } |
| 1596 | 1596 |
| 1597 } // namespace views | 1597 } // namespace views |
| OLD | NEW |