Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: views/controls/table/native_table_win.cc

Issue 6879013: skia::PlatformCanvas is being deprecated. Going forward we will use gfx::Canvas wherever we need ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/progress_bar.cc ('k') | views/controls/table/table_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 10 #include "base/logging.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 if (table_->model()) 386 if (table_->model())
387 UpdateListViewCache(0, table_->model()->RowCount(), true); 387 UpdateListViewCache(0, table_->model()->RowCount(), true);
388 388
389 if (table_->type() == ICON_AND_TEXT) { 389 if (table_->type() == ICON_AND_TEXT) {
390 HIMAGELIST image_list = 390 HIMAGELIST image_list =
391 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2); 391 ImageList_Create(kImageSize, kImageSize, ILC_COLOR32, 2, 2);
392 // We create 2 phony images because we are going to switch images at every 392 // We create 2 phony images because we are going to switch images at every
393 // refresh in order to force a refresh of the icon area (somehow the clip 393 // refresh in order to force a refresh of the icon area (somehow the clip
394 // rect does not include the icon). 394 // rect does not include the icon).
395 gfx::CanvasSkia canvas(kImageSize, kImageSize, false); 395 gfx::CanvasSkia canvas;
396 canvas.Init(kImageSize, kImageSize, false);
396 // Make the background completely transparent. 397 // Make the background completely transparent.
397 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); 398 canvas.skia_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
398 HICON empty_icon = 399 HICON empty_icon =
399 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); 400 IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap());
400 ImageList_AddIcon(image_list, empty_icon); 401 ImageList_AddIcon(image_list, empty_icon);
401 ImageList_AddIcon(image_list, empty_icon); 402 ImageList_AddIcon(image_list, empty_icon);
402 DeleteObject(empty_icon); 403 DeleteObject(empty_icon);
403 ListView_SetImageList(native_view(), image_list, LVSIL_SMALL); 404 ListView_SetImageList(native_view(), image_list, LVSIL_SMALL);
404 } 405 }
405 406
406 if (!table_->resizable_columns()) { 407 if (!table_->resizable_columns()) {
407 // To disable the resizing of columns we'll filter the events happening on 408 // To disable the resizing of columns we'll filter the events happening on
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 RECT icon_rect, client_rect; 505 RECT icon_rect, client_rect;
505 if (ListView_GetItemRect(native_view(), view_index, &icon_rect, 506 if (ListView_GetItemRect(native_view(), view_index, &icon_rect,
506 LVIR_ICON) && 507 LVIR_ICON) &&
507 GetClientRect(native_view(), &client_rect)) { 508 GetClientRect(native_view(), &client_rect)) {
508 RECT intersection; 509 RECT intersection;
509 // Client rect includes the header but we need to make sure we don't 510 // Client rect includes the header but we need to make sure we don't
510 // paint into it. 511 // paint into it.
511 client_rect.top += content_offset_; 512 client_rect.top += content_offset_;
512 // Make sure the region need to paint is visible. 513 // Make sure the region need to paint is visible.
513 if (IntersectRect(&intersection, &icon_rect, &client_rect)) { 514 if (IntersectRect(&intersection, &icon_rect, &client_rect)) {
514 gfx::CanvasSkia canvas(icon_rect.right - icon_rect.left, 515 gfx::CanvasSkia canvas;
515 icon_rect.bottom - icon_rect.top, false); 516 canvas.Init(icon_rect.right - icon_rect.left,
517 icon_rect.bottom - icon_rect.top,
518 false);
516 519
517 // It seems the state in nmcd.uItemState is not correct. 520 // It seems the state in nmcd.uItemState is not correct.
518 // We'll retrieve it explicitly. 521 // We'll retrieve it explicitly.
519 int selected = ListView_GetItemState( 522 int selected = ListView_GetItemState(
520 native_view(), view_index, LVIS_SELECTED | LVIS_DROPHILITED); 523 native_view(), view_index, LVIS_SELECTED | LVIS_DROPHILITED);
521 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0); 524 bool drop_highlight = ((selected & LVIS_DROPHILITED) != 0);
522 int bg_color_index; 525 int bg_color_index;
523 if (!IsEnabled()) 526 if (!IsEnabled())
524 bg_color_index = COLOR_3DFACE; 527 bg_color_index = COLOR_3DFACE;
525 else if (drop_highlight) 528 else if (drop_highlight)
526 bg_color_index = COLOR_HIGHLIGHT; 529 bg_color_index = COLOR_HIGHLIGHT;
527 else if (selected) 530 else if (selected)
528 bg_color_index = HasFocus() ? COLOR_HIGHLIGHT : COLOR_3DFACE; 531 bg_color_index = HasFocus() ? COLOR_HIGHLIGHT : COLOR_3DFACE;
529 else 532 else
530 bg_color_index = COLOR_WINDOW; 533 bg_color_index = COLOR_WINDOW;
531 // NOTE: This may be invoked without the ListView filling in the 534 // NOTE: This may be invoked without the ListView filling in the
532 // background (or rather windows paints background, then invokes 535 // background (or rather windows paints background, then invokes
533 // this twice). As such, we always fill in the background. 536 // this twice). As such, we always fill in the background.
534 canvas.drawColor( 537 canvas.skia_canvas()->drawColor(
535 skia::COLORREFToSkColor(GetSysColor(bg_color_index)), 538 skia::COLORREFToSkColor(GetSysColor(bg_color_index)),
536 SkXfermode::kSrc_Mode); 539 SkXfermode::kSrc_Mode);
537 // + 1 for padding (we declared the image as 18x18 in the list- 540 // + 1 for padding (we declared the image as 18x18 in the list-
538 // view when they are 16x16 so we get an extra pixel of padding). 541 // view when they are 16x16 so we get an extra pixel of padding).
539 canvas.DrawBitmapInt(image, 0, 0, 542 canvas.DrawBitmapInt(image, 0, 0,
540 image.width(), image.height(), 543 image.width(), image.height(),
541 1, 1, kFaviconSize, kFaviconSize, true); 544 1, 1, kFaviconSize, kFaviconSize, true);
542 545
543 // Only paint the visible region of the icon. 546 // Only paint the visible region of the icon.
544 RECT to_draw = { intersection.left - icon_rect.left, 547 RECT to_draw = { intersection.left - icon_rect.left,
545 intersection.top - icon_rect.top, 548 intersection.top - icon_rect.top,
546 0, 0 }; 549 0, 0 };
547 to_draw.right = to_draw.left + 550 to_draw.right = to_draw.left +
548 (intersection.right - intersection.left); 551 (intersection.right - intersection.left);
549 to_draw.bottom = to_draw.top + 552 to_draw.bottom = to_draw.top +
550 (intersection.bottom - intersection.top); 553 (intersection.bottom - intersection.top);
551 canvas.getTopPlatformDevice().drawToHDC(draw_info->nmcd.hdc, 554 canvas.BlitToNativeContext(
552 intersection.left, 555 gfx::Rect(to_draw),
553 intersection.top, 556 gfx::Point(intersection.left, intersection.top),
554 &to_draw); 557 draw_info->nmcd.hdc);
555 r = CDRF_SKIPDEFAULT; 558 r = CDRF_SKIPDEFAULT;
556 } 559 }
557 } 560 }
558 } 561 }
559 } 562 }
560 return r; 563 return r;
561 } 564 }
562 default: 565 default:
563 return CDRF_DODEFAULT; 566 return CDRF_DODEFAULT;
564 } 567 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 906
904 //////////////////////////////////////////////////////////////////////////////// 907 ////////////////////////////////////////////////////////////////////////////////
905 // NativeButtonWrapper, public: 908 // NativeButtonWrapper, public:
906 909
907 // static 910 // static
908 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) { 911 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) {
909 return new NativeTableWin(table); 912 return new NativeTableWin(table);
910 } 913 }
911 914
912 } // namespace views 915 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/progress_bar.cc ('k') | views/controls/table/table_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698