Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/win/scoped_gdi_object.h" | 14 #include "base/win/scoped_gdi_object.h" |
| 15 #include "skia/ext/skia_utils_win.h" | 15 #include "skia/ext/skia_utils_win.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "ui/gfx/image/image_skia.h" |
|
msw
2012/05/29 07:50:51
nit: remove this include; it's duplicated below in
| |
| 17 #include "third_party/skia/include/core/SkColorFilter.h" | 17 #include "third_party/skia/include/core/SkColorFilter.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/l10n/l10n_util_win.h" | 19 #include "ui/base/l10n/l10n_util_win.h" |
| 20 #include "ui/base/models/table_model.h" | 20 #include "ui/base/models/table_model.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/base/win/hwnd_util.h" | 22 #include "ui/base/win/hwnd_util.h" |
| 23 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/favicon_size.h" | 24 #include "ui/gfx/favicon_size.h" |
| 25 #include "ui/gfx/font.h" | 25 #include "ui/gfx/font.h" |
| 26 #include "ui/gfx/icon_util.h" | 26 #include "ui/gfx/icon_util.h" |
| 27 #include "ui/gfx/image/image_skia.h" | |
| 27 #include "ui/views/controls/native/native_view_host.h" | 28 #include "ui/views/controls/native/native_view_host.h" |
| 28 #include "ui/views/controls/table/table_view_observer.h" | 29 #include "ui/views/controls/table/table_view_observer.h" |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 int GetViewIndexFromPoint(HWND window, const gfx::Point& p) { | 33 int GetViewIndexFromPoint(HWND window, const gfx::Point& p) { |
| 33 LVHITTESTINFO hit_info = {0}; | 34 LVHITTESTINFO hit_info = {0}; |
| 34 hit_info.pt.x = p.x(); | 35 hit_info.pt.x = p.x(); |
| 35 hit_info.pt.y = p.y(); | 36 hit_info.pt.y = p.y(); |
| 36 return ListView_HitTest(window, &hit_info); | 37 return ListView_HitTest(window, &hit_info); |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1218 case CDDS_ITEMPOSTPAINT: { | 1219 case CDDS_ITEMPOSTPAINT: { |
| 1219 DCHECK((table_type_ == ICON_AND_TEXT) || (ImplementPostPaint())); | 1220 DCHECK((table_type_ == ICON_AND_TEXT) || (ImplementPostPaint())); |
| 1220 int view_index = static_cast<int>(draw_info->nmcd.dwItemSpec); | 1221 int view_index = static_cast<int>(draw_info->nmcd.dwItemSpec); |
| 1221 // We get notifications for empty items, just ignore them. | 1222 // We get notifications for empty items, just ignore them. |
| 1222 if (view_index >= model_->RowCount()) | 1223 if (view_index >= model_->RowCount()) |
| 1223 return CDRF_DODEFAULT; | 1224 return CDRF_DODEFAULT; |
| 1224 int model_index = ViewToModel(view_index); | 1225 int model_index = ViewToModel(view_index); |
| 1225 LRESULT r = CDRF_DODEFAULT; | 1226 LRESULT r = CDRF_DODEFAULT; |
| 1226 // First let's take care of painting the right icon. | 1227 // First let's take care of painting the right icon. |
| 1227 if (table_type_ == ICON_AND_TEXT) { | 1228 if (table_type_ == ICON_AND_TEXT) { |
| 1228 SkBitmap image = model_->GetIcon(model_index); | 1229 gfx::ImageSkia image = model_->GetIcon(model_index); |
| 1229 if (!image.isNull()) { | 1230 if (!image.isNull()) { |
| 1230 // Get the rect that holds the icon. | 1231 // Get the rect that holds the icon. |
| 1231 RECT icon_rect, client_rect; | 1232 RECT icon_rect, client_rect; |
| 1232 if (ListView_GetItemRect(list_view_, view_index, &icon_rect, | 1233 if (ListView_GetItemRect(list_view_, view_index, &icon_rect, |
| 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_; |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1639 } | 1640 } |
| 1640 | 1641 |
| 1641 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { | 1642 void TableSelectionIterator::UpdateModelIndexFromViewIndex() { |
| 1642 if (view_index_ == -1) | 1643 if (view_index_ == -1) |
| 1643 model_index_ = -1; | 1644 model_index_ = -1; |
| 1644 else | 1645 else |
| 1645 model_index_ = table_view_->ViewToModel(view_index_); | 1646 model_index_ = table_view_->ViewToModel(view_index_); |
| 1646 } | 1647 } |
| 1647 | 1648 |
| 1648 } // namespace views | 1649 } // namespace views |
| OLD | NEW |