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

Side by Side Diff: views/controls/tree/tree_view.cc

Issue 1073005: Move RTL related functions from app/l10n_util to base/i18n/rtl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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/textfield/native_textfield_win.cc ('k') | views/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) 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/tree/tree_view.h" 5 #include "views/controls/tree/tree_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/canvas_paint.h" 10 #include "app/gfx/canvas_paint.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/l10n_util_win.h" 12 #include "app/l10n_util_win.h"
13 #include "app/resource_bundle.h" 13 #include "app/resource_bundle.h"
14 #include "base/i18n/rtl.h"
14 #include "base/keyboard_codes.h" 15 #include "base/keyboard_codes.h"
15 #include "base/stl_util-inl.h" 16 #include "base/stl_util-inl.h"
16 #include "base/win_util.h" 17 #include "base/win_util.h"
17 #include "gfx/favicon_size.h" 18 #include "gfx/favicon_size.h"
18 #include "gfx/icon_util.h" 19 #include "gfx/icon_util.h"
19 #include "gfx/point.h" 20 #include "gfx/point.h"
20 #include "grit/app_resources.h" 21 #include "grit/app_resources.h"
21 #include "views/focus/focus_manager.h" 22 #include "views/focus/focus_manager.h"
22 #include "views/widget/widget.h" 23 #include "views/widget/widget.h"
23 24
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 const NodeDetails* details = 393 const NodeDetails* details =
393 GetNodeDetailsByID(static_cast<int>(info->item.lParam)); 394 GetNodeDetailsByID(static_cast<int>(info->item.lParam));
394 if (info->item.mask & TVIF_CHILDREN) 395 if (info->item.mask & TVIF_CHILDREN)
395 info->item.cChildren = model_->GetChildCount(details->node); 396 info->item.cChildren = model_->GetChildCount(details->node);
396 if (info->item.mask & TVIF_TEXT) { 397 if (info->item.mask & TVIF_TEXT) {
397 std::wstring text = details->node->GetTitle(); 398 std::wstring text = details->node->GetTitle();
398 DCHECK(info->item.cchTextMax); 399 DCHECK(info->item.cchTextMax);
399 400
400 // Adjust the string direction if such adjustment is required. 401 // Adjust the string direction if such adjustment is required.
401 std::wstring localized_text; 402 std::wstring localized_text;
402 if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text)) 403 if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text))
403 text.swap(localized_text); 404 text.swap(localized_text);
404 405
405 wcsncpy_s(info->item.pszText, info->item.cchTextMax, text.c_str(), 406 wcsncpy_s(info->item.pszText, info->item.cchTextMax, text.c_str(),
406 _TRUNCATE); 407 _TRUNCATE);
407 } 408 }
408 // Instructs windows to cache the values for this node. 409 // Instructs windows to cache the values for this node.
409 info->item.mask |= TVIF_DI_SETITEM; 410 info->item.mask |= TVIF_DI_SETITEM;
410 // Return value ignored. 411 // Return value ignored.
411 return 0; 412 return 0;
412 } 413 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 switch (message) { 723 switch (message) {
723 case WM_ERASEBKGND: 724 case WM_ERASEBKGND:
724 return 1; 725 return 1;
725 726
726 case WM_PAINT: { 727 case WM_PAINT: {
727 gfx::CanvasPaint canvas(window); 728 gfx::CanvasPaint canvas(window);
728 if (canvas.isEmpty()) 729 if (canvas.isEmpty())
729 return 0; 730 return 0;
730 731
731 HDC dc = canvas.beginPlatformPaint(); 732 HDC dc = canvas.beginPlatformPaint();
732 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { 733 if (base::i18n::IsRTL()) {
733 // gfx::Canvas ends up configuring the DC with a mode of GM_ADVANCED. 734 // gfx::Canvas ends up configuring the DC with a mode of GM_ADVANCED.
734 // For some reason a graphics mode of ADVANCED triggers all the text 735 // For some reason a graphics mode of ADVANCED triggers all the text
735 // to be mirrored when RTL. Set the mode back to COMPATIBLE and 736 // to be mirrored when RTL. Set the mode back to COMPATIBLE and
736 // explicitly set the layout. Additionally SetWorldTransform and 737 // explicitly set the layout. Additionally SetWorldTransform and
737 // COMPATIBLE don't play nicely together. We need to use 738 // COMPATIBLE don't play nicely together. We need to use
738 // SetViewportOrgEx when using a mode of COMPATIBLE. 739 // SetViewportOrgEx when using a mode of COMPATIBLE.
739 // 740 //
740 // Reset the transform to the identify transform. Even though 741 // Reset the transform to the identify transform. Even though
741 // SetWorldTransform and COMPATIBLE don't play nicely, bits of the 742 // SetWorldTransform and COMPATIBLE don't play nicely, bits of the
742 // transform still carry over when we set the mode. 743 // transform still carry over when we set the mode.
743 XFORM xform = {0}; 744 XFORM xform = {0};
744 xform.eM11 = xform.eM22 = 1; 745 xform.eM11 = xform.eM22 = 1;
745 SetWorldTransform(dc, &xform); 746 SetWorldTransform(dc, &xform);
746 747
747 // Set the mode and layout. 748 // Set the mode and layout.
748 SetGraphicsMode(dc, GM_COMPATIBLE); 749 SetGraphicsMode(dc, GM_COMPATIBLE);
749 SetLayout(dc, LAYOUT_RTL); 750 SetLayout(dc, LAYOUT_RTL);
750 751
751 // Transform the viewport such that the origin of the dc is that of 752 // Transform the viewport such that the origin of the dc is that of
752 // the dirty region. This way when we invoke WM_PRINTCLIENT tree-view 753 // the dirty region. This way when we invoke WM_PRINTCLIENT tree-view
753 // draws the dirty region at the origin of the DC so that when we 754 // draws the dirty region at the origin of the DC so that when we
754 // copy the bits everything lines up nicely. Without this we end up 755 // copy the bits everything lines up nicely. Without this we end up
755 // copying the upper-left corner to the redraw region. 756 // copying the upper-left corner to the redraw region.
756 SetViewportOrgEx(dc, -canvas.paintStruct().rcPaint.left, 757 SetViewportOrgEx(dc, -canvas.paintStruct().rcPaint.left,
757 -canvas.paintStruct().rcPaint.top, NULL); 758 -canvas.paintStruct().rcPaint.top, NULL);
758 } 759 }
759 SendMessage(window, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(dc), 0); 760 SendMessage(window, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(dc), 0);
760 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { 761 if (base::i18n::IsRTL()) {
761 // Reset the origin of the dc back to 0. This way when we copy the bits 762 // Reset the origin of the dc back to 0. This way when we copy the bits
762 // over we copy the right bits. 763 // over we copy the right bits.
763 SetViewportOrgEx(dc, 0, 0, NULL); 764 SetViewportOrgEx(dc, 0, 0, NULL);
764 } 765 }
765 canvas.endPlatformPaint(); 766 canvas.endPlatformPaint();
766 return 0; 767 return 0;
767 } 768 }
768 769
769 case WM_RBUTTONDOWN: 770 case WM_RBUTTONDOWN:
770 if (tree->select_on_right_mouse_down_) { 771 if (tree->select_on_right_mouse_down_) {
771 TVHITTESTINFO hit_info; 772 TVHITTESTINFO hit_info;
772 hit_info.pt = gfx::Point(l_param).ToPOINT(); 773 hit_info.pt = gfx::Point(l_param).ToPOINT();
773 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info); 774 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info);
774 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT | 775 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT |
775 TVHT_ONITEMINDENT)) != 0) 776 TVHT_ONITEMINDENT)) != 0)
776 TreeView_SelectItem(tree->tree_view_, hit_item); 777 TreeView_SelectItem(tree->tree_view_, hit_item);
777 } 778 }
778 // Fall through and let the default handler process as well. 779 // Fall through and let the default handler process as well.
779 break; 780 break;
780 } 781 }
781 WNDPROC handler = tree->original_handler_; 782 WNDPROC handler = tree->original_handler_;
782 DCHECK(handler); 783 DCHECK(handler);
783 return CallWindowProc(handler, window, message, w_param, l_param); 784 return CallWindowProc(handler, window, message, w_param, l_param);
784 } 785 }
785 786
786 } // namespace views 787 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/textfield/native_textfield_win.cc ('k') | views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698