OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/tree_view.h" | 5 #include "chrome/views/tree_view.h" |
6 | 6 |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 | 8 |
9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
10 #include "chrome/app/theme/theme_resources.h" | 10 #include "chrome/app/theme/theme_resources.h" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 // flickering during resize. | 635 // flickering during resize. |
636 switch (message) { | 636 switch (message) { |
637 case WM_ERASEBKGND: | 637 case WM_ERASEBKGND: |
638 return 1; | 638 return 1; |
639 | 639 |
640 case WM_PAINT: { | 640 case WM_PAINT: { |
641 ChromeCanvasPaint canvas(window); | 641 ChromeCanvasPaint canvas(window); |
642 if (canvas.isEmpty()) | 642 if (canvas.isEmpty()) |
643 return 0; | 643 return 0; |
644 | 644 |
645 HDC dc = canvas.beginPlatformPaint(); | 645 HDC dc = canvas.beginPlatformPaint(); |
646 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 646 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { |
647 // ChromeCanvas ends up configuring the DC with a mode of GM_ADVANCED. | 647 // ChromeCanvas ends up configuring the DC with a mode of GM_ADVANCED. |
648 // For some reason a graphics mode of ADVANCED triggers all the text | 648 // For some reason a graphics mode of ADVANCED triggers all the text |
649 // to be mirrored when RTL. Set the mode back to COMPATIBLE and | 649 // to be mirrored when RTL. Set the mode back to COMPATIBLE and |
650 // explicitly set the layout. | 650 // explicitly set the layout. Additionally SetWorldTransform and |
| 651 // COMPATIBLE don't play nicely together. We need to use |
| 652 // SetViewportOrgEx when using a mode of COMPATIBLE. |
| 653 // |
| 654 // Reset the transform to the identify transform. Even though |
| 655 // SetWorldTransform and COMPATIBLE don't play nicely, bits of the |
| 656 // transform still carry over when we set the mode. |
| 657 XFORM xform = {0}; |
| 658 xform.eM11 = xform.eM22 = 1; |
| 659 SetWorldTransform(dc, &xform); |
| 660 |
| 661 // Set the mode and layout. |
651 SetGraphicsMode(dc, GM_COMPATIBLE); | 662 SetGraphicsMode(dc, GM_COMPATIBLE); |
652 SetLayout(dc, LAYOUT_RTL); | 663 SetLayout(dc, LAYOUT_RTL); |
| 664 |
| 665 // Transform the viewport such that the origin of the dc is that of |
| 666 // the dirty region. This way when we invoke WM_PRINTCLIENT tree-view |
| 667 // draws the dirty region at the origin of the DC so that when we |
| 668 // copy the bits everything lines up nicely. Without this we end up |
| 669 // copying the upper-left corner to the redraw region. |
| 670 SetViewportOrgEx(dc, -canvas.paintStruct().rcPaint.left, |
| 671 -canvas.paintStruct().rcPaint.top, NULL); |
653 } | 672 } |
654 SendMessage(window, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(dc), 0); | 673 SendMessage(window, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(dc), 0); |
| 674 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { |
| 675 // Reset the origin of the dc back to 0. This way when we copy the bits |
| 676 // over we copy the right bits. |
| 677 SetViewportOrgEx(dc, 0, 0, NULL); |
| 678 } |
655 canvas.endPlatformPaint(); | 679 canvas.endPlatformPaint(); |
656 return 0; | 680 return 0; |
657 } | 681 } |
658 | 682 |
659 case WM_RBUTTONDOWN: | 683 case WM_RBUTTONDOWN: |
660 if (tree->select_on_right_mouse_down_) { | 684 if (tree->select_on_right_mouse_down_) { |
661 TVHITTESTINFO hit_info; | 685 TVHITTESTINFO hit_info; |
662 hit_info.pt.x = GET_X_LPARAM(l_param); | 686 hit_info.pt.x = GET_X_LPARAM(l_param); |
663 hit_info.pt.y = GET_Y_LPARAM(l_param); | 687 hit_info.pt.y = GET_Y_LPARAM(l_param); |
664 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info); | 688 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info); |
665 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT | | 689 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT | |
666 TVHT_ONITEMINDENT)) != 0) | 690 TVHT_ONITEMINDENT)) != 0) |
667 TreeView_SelectItem(tree->tree_view_, hit_item); | 691 TreeView_SelectItem(tree->tree_view_, hit_item); |
668 } | 692 } |
669 // Fall through and let the default handler process as well. | 693 // Fall through and let the default handler process as well. |
670 break; | 694 break; |
671 } | 695 } |
672 WNDPROC handler = tree->original_handler_; | 696 WNDPROC handler = tree->original_handler_; |
673 DCHECK(handler); | 697 DCHECK(handler); |
674 return CallWindowProc(handler, window, message, w_param, l_param); | 698 return CallWindowProc(handler, window, message, w_param, l_param); |
675 } | 699 } |
676 | 700 |
677 } // namespace views | 701 } // namespace views |
OLD | NEW |