| 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/native_table_win.h" | 5 #include "views/controls/table/native_table_win.h" |
| 6 | 6 |
| 7 #include <commctrl.h> | 7 #include <commctrl.h> |
| 8 #include <windowsx.h> | 8 #include <windowsx.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "app/l10n_util_win.h" | 11 #include "app/l10n_util_win.h" |
| 12 #include "app/table_model.h" | 12 #include "app/table_model.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/win_util.h" | 14 #include "base/win_util.h" |
| 15 #include "gfx/canvas.h" | 15 #include "gfx/canvas_skia.h" |
| 16 #include "gfx/favicon_size.h" | 16 #include "gfx/favicon_size.h" |
| 17 #include "gfx/icon_util.h" | 17 #include "gfx/icon_util.h" |
| 18 #include "skia/ext/skia_utils_win.h" | 18 #include "skia/ext/skia_utils_win.h" |
| 19 #include "views/controls/table/table_view2.h" | 19 #include "views/controls/table/table_view2.h" |
| 20 #include "views/controls/table/table_view_observer.h" | 20 #include "views/controls/table/table_view_observer.h" |
| 21 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 | 24 |
| 25 // Added to column width to prevent truncation. | 25 // Added to column width to prevent truncation. |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 if (table_->model()) | 383 if (table_->model()) |
| 384 UpdateListViewCache(0, table_->model()->RowCount(), true); | 384 UpdateListViewCache(0, table_->model()->RowCount(), true); |
| 385 | 385 |
| 386 if (table_->type() == ICON_AND_TEXT) { | 386 if (table_->type() == ICON_AND_TEXT) { |
| 387 HIMAGELIST image_list = | 387 HIMAGELIST image_list = |
| 388 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); | 388 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); |
| 389 // We create 2 phony images because we are going to switch images at every | 389 // We create 2 phony images because we are going to switch images at every |
| 390 // refresh in order to force a refresh of the icon area (somehow the clip | 390 // refresh in order to force a refresh of the icon area (somehow the clip |
| 391 // rect does not include the icon). | 391 // rect does not include the icon). |
| 392 gfx::Canvas canvas(kImageSize, kImageSize, false); | 392 gfx::CanvasSkia canvas(kImageSize, kImageSize, false); |
| 393 // Make the background completely transparent. | 393 // Make the background completely transparent. |
| 394 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); | 394 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
| 395 HICON empty_icon = | 395 HICON empty_icon = |
| 396 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); | 396 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); |
| 397 ImageList_AddIcon(image_list, empty_icon); | 397 ImageList_AddIcon(image_list, empty_icon); |
| 398 ImageList_AddIcon(image_list, empty_icon); | 398 ImageList_AddIcon(image_list, empty_icon); |
| 399 DeleteObject(empty_icon); | 399 DeleteObject(empty_icon); |
| 400 ListView_SetImageList(native_view(), image_list, LVSIL_SMALL); | 400 ListView_SetImageList(native_view(), image_list, LVSIL_SMALL); |
| 401 } | 401 } |
| 402 | 402 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 RECT icon_rect, client_rect; | 501 RECT icon_rect, client_rect; |
| 502 if (ListView_GetItemRect(native_view(), view_index, &icon_rect, | 502 if (ListView_GetItemRect(native_view(), view_index, &icon_rect, |
| 503 LVIR_ICON) && | 503 LVIR_ICON) && |
| 504 GetClientRect(native_view(), &client_rect)) { | 504 GetClientRect(native_view(), &client_rect)) { |
| 505 RECT intersection; | 505 RECT intersection; |
| 506 // Client rect includes the header but we need to make sure we don't | 506 // Client rect includes the header but we need to make sure we don't |
| 507 // paint into it. | 507 // paint into it. |
| 508 client_rect.top += content_offset_; | 508 client_rect.top += content_offset_; |
| 509 // Make sure the region need to paint is visible. | 509 // Make sure the region need to paint is visible. |
| 510 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { | 510 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { |
| 511 gfx::Canvas canvas(icon_rect.right - icon_rect.left, | 511 gfx::CanvasSkia canvas(icon_rect.right - icon_rect.left, |
| 512 icon_rect.bottom - icon_rect.top, false); | 512 icon_rect.bottom - icon_rect.top, false); |
| 513 | 513 |
| 514 // It seems the state in nmcd.uItemState is not correct. | 514 // It seems the state in nmcd.uItemState is not correct. |
| 515 // We'll retrieve it explicitly. | 515 // We'll retrieve it explicitly. |
| 516 int selected = ListView_GetItemState( | 516 int selected = ListView_GetItemState( |
| 517 native_view(), view_index, LVIS_SELECTED | LVIS_DROPHILITED); | 517 native_view(), view_index, LVIS_SELECTED | LVIS_DROPHILITED); |
| 518 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); | 518 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); |
| 519 int bg_color_index; | 519 int bg_color_index; |
| 520 if (!IsEnabled()) | 520 if (!IsEnabled()) |
| 521 bg_color_index = COLOR_3DFACE; | 521 bg_color_index = COLOR_3DFACE; |
| 522 else if (drop_highlight) | 522 else if (drop_highlight) |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 900 |
| 901 //////////////////////////////////////////////////////////////////////////////// | 901 //////////////////////////////////////////////////////////////////////////////// |
| 902 // NativeButtonWrapper, public: | 902 // NativeButtonWrapper, public: |
| 903 | 903 |
| 904 // static | 904 // static |
| 905 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) { | 905 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) { |
| 906 return new NativeTableWin(table); | 906 return new NativeTableWin(table); |
| 907 } | 907 } |
| 908 | 908 |
| 909 } // namespace views | 909 } // namespace views |
| OLD | NEW |