OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 10 #include <algorithm> |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 UpdateListViewCache(0, table_->model()->RowCount(), true); | 388 UpdateListViewCache(0, table_->model()->RowCount(), true); |
389 | 389 |
390 if (table_->type() == ICON_AND_TEXT) { | 390 if (table_->type() == ICON_AND_TEXT) { |
391 HIMAGELIST image_list = | 391 HIMAGELIST image_list = |
392 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); | 392 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); |
393 // We create 2 phony images because we are going to switch images at every | 393 // We create 2 phony images because we are going to switch images at every |
394 // refresh in order to force a refresh of the icon area (somehow the clip | 394 // refresh in order to force a refresh of the icon area (somehow the clip |
395 // rect does not include the icon). | 395 // rect does not include the icon). |
396 gfx::CanvasSkia canvas(kImageSize, kImageSize, false); | 396 gfx::CanvasSkia canvas(kImageSize, kImageSize, false); |
397 // Make the background completely transparent. | 397 // Make the background completely transparent. |
398 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); | 398 canvas.sk_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
399 { | 399 { |
400 base::win::ScopedHICON empty_icon( | 400 base::win::ScopedHICON empty_icon( |
401 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap())); | 401 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap())); |
402 ImageList_AddIcon(image_list, empty_icon); | 402 ImageList_AddIcon(image_list, empty_icon); |
403 ImageList_AddIcon(image_list, empty_icon); | 403 ImageList_AddIcon(image_list, empty_icon); |
404 } | 404 } |
405 ListView_SetImageList(native_view(), image_list, LVSIL_SMALL); | 405 ListView_SetImageList(native_view(), image_list, LVSIL_SMALL); |
406 } | 406 } |
407 | 407 |
408 if (!table_->resizable_columns()) { | 408 if (!table_->resizable_columns()) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 bg_color_index = COLOR_3DFACE; | 526 bg_color_index = COLOR_3DFACE; |
527 else if (drop_highlight) | 527 else if (drop_highlight) |
528 bg_color_index = COLOR_HIGHLIGHT; | 528 bg_color_index = COLOR_HIGHLIGHT; |
529 else if (selected) | 529 else if (selected) |
530 bg_color_index = HasFocus() ? COLOR_HIGHLIGHT : COLOR_3DFACE; | 530 bg_color_index = HasFocus() ? COLOR_HIGHLIGHT : COLOR_3DFACE; |
531 else | 531 else |
532 bg_color_index = COLOR_WINDOW; | 532 bg_color_index = COLOR_WINDOW; |
533 // NOTE: This may be invoked without the ListView filling in the | 533 // NOTE: This may be invoked without the ListView filling in the |
534 // background (or rather windows paints background, then invokes | 534 // background (or rather windows paints background, then invokes |
535 // this twice). As such, we always fill in the background. | 535 // this twice). As such, we always fill in the background. |
536 canvas.drawColor( | 536 canvas.sk_canvas()->drawColor( |
537 skia::COLORREFToSkColor(GetSysColor(bg_color_index)), | 537 skia::COLORREFToSkColor(GetSysColor(bg_color_index)), |
538 SkXfermode::kSrc_Mode); | 538 SkXfermode::kSrc_Mode); |
539 // + 1 for padding (we declared the image as 18x18 in the list- | 539 // + 1 for padding (we declared the image as 18x18 in the list- |
540 // view when they are 16x16 so we get an extra pixel of padding). | 540 // view when they are 16x16 so we get an extra pixel of padding). |
541 canvas.DrawBitmapInt(image, 0, 0, | 541 canvas.DrawBitmapInt(image, 0, 0, |
542 image.width(), image.height(), | 542 image.width(), image.height(), |
543 1, 1, | 543 1, 1, |
544 gfx::kFaviconSize, gfx::kFaviconSize, true); | 544 gfx::kFaviconSize, gfx::kFaviconSize, true); |
545 | 545 |
546 // Only paint the visible region of the icon. | 546 // Only paint the visible region of the icon. |
547 RECT to_draw = { intersection.left - icon_rect.left, | 547 RECT to_draw = { intersection.left - icon_rect.left, |
548 intersection.top - icon_rect.top, | 548 intersection.top - icon_rect.top, |
549 0, 0 }; | 549 0, 0 }; |
550 to_draw.right = to_draw.left + | 550 to_draw.right = to_draw.left + |
551 (intersection.right - intersection.left); | 551 (intersection.right - intersection.left); |
552 to_draw.bottom = to_draw.top + | 552 to_draw.bottom = to_draw.top + |
553 (intersection.bottom - intersection.top); | 553 (intersection.bottom - intersection.top); |
554 skia::DrawToNativeContext(&canvas, draw_info->nmcd.hdc, | 554 skia::DrawToNativeContext(canvas.sk_canvas(), draw_info->nmcd.hdc, |
555 intersection.left, intersection.top, | 555 intersection.left, intersection.top, |
556 &to_draw); | 556 &to_draw); |
557 r = CDRF_SKIPDEFAULT; | 557 r = CDRF_SKIPDEFAULT; |
558 } | 558 } |
559 } | 559 } |
560 } | 560 } |
561 } | 561 } |
562 return r; | 562 return r; |
563 } | 563 } |
564 default: | 564 default: |
565 return CDRF_DODEFAULT; | 565 return CDRF_DODEFAULT; |
566 } | 566 } |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 905 |
906 //////////////////////////////////////////////////////////////////////////////// | 906 //////////////////////////////////////////////////////////////////////////////// |
907 // NativeTableWrapper, public: | 907 // NativeTableWrapper, public: |
908 | 908 |
909 // static | 909 // static |
910 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) { | 910 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) { |
911 return new NativeTableWin(table); | 911 return new NativeTableWin(table); |
912 } | 912 } |
913 | 913 |
914 } // namespace views | 914 } // namespace views |
OLD | NEW |