| 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 "views/controls/tree/tree_view.h" | 5 #include "views/controls/tree/tree_view.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <vector> |
| 8 #include <atlapp.h> | |
| 9 #include <atlmisc.h> | |
| 10 | 8 |
| 11 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 12 #include "app/gfx/icon_util.h" | 10 #include "app/gfx/icon_util.h" |
| 13 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 14 #include "app/l10n_util_win.h" | 12 #include "app/l10n_util_win.h" |
| 15 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
| 14 #include "base/gfx/point.h" |
| 16 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
| 17 #include "base/win_util.h" | 16 #include "base/win_util.h" |
| 18 #include "grit/app_resources.h" | 17 #include "grit/app_resources.h" |
| 19 #include "views/focus/focus_manager.h" | 18 #include "views/focus/focus_manager.h" |
| 20 #include "views/widget/widget.h" | 19 #include "views/widget/widget.h" |
| 21 | 20 |
| 22 namespace views { | 21 namespace views { |
| 23 | 22 |
| 24 TreeView::TreeView() | 23 TreeView::TreeView() |
| 25 : tree_view_(NULL), | 24 : tree_view_(NULL), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 // as such only need to delete from one. | 45 // as such only need to delete from one. |
| 47 STLDeleteContainerPairSecondPointers(id_to_details_map_.begin(), | 46 STLDeleteContainerPairSecondPointers(id_to_details_map_.begin(), |
| 48 id_to_details_map_.end()); | 47 id_to_details_map_.end()); |
| 49 if (image_list_) | 48 if (image_list_) |
| 50 ImageList_Destroy(image_list_); | 49 ImageList_Destroy(image_list_); |
| 51 } | 50 } |
| 52 | 51 |
| 53 void TreeView::SetModel(TreeModel* model) { | 52 void TreeView::SetModel(TreeModel* model) { |
| 54 if (model == model_) | 53 if (model == model_) |
| 55 return; | 54 return; |
| 56 if(model_ && tree_view_) | 55 if (model_ && tree_view_) |
| 57 DeleteRootItems(); | 56 DeleteRootItems(); |
| 58 if (model_) | 57 if (model_) |
| 59 model_->SetObserver(NULL); | 58 model_->SetObserver(NULL); |
| 60 model_ = model; | 59 model_ = model; |
| 61 if (tree_view_ && model_) { | 60 if (tree_view_ && model_) { |
| 62 CreateRootItems(); | 61 CreateRootItems(); |
| 63 model_->SetObserver(this); | 62 model_->SetObserver(this); |
| 64 HIMAGELIST last_image_list = image_list_; | 63 HIMAGELIST last_image_list = image_list_; |
| 65 image_list_ = CreateImageList(); | 64 image_list_ = CreateImageList(); |
| 66 TreeView_SetImageList(tree_view_, image_list_, TVSIL_NORMAL); | 65 TreeView_SetImageList(tree_view_, image_list_, TVSIL_NORMAL); |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 // over we copy the right bits. | 719 // over we copy the right bits. |
| 721 SetViewportOrgEx(dc, 0, 0, NULL); | 720 SetViewportOrgEx(dc, 0, 0, NULL); |
| 722 } | 721 } |
| 723 canvas.endPlatformPaint(); | 722 canvas.endPlatformPaint(); |
| 724 return 0; | 723 return 0; |
| 725 } | 724 } |
| 726 | 725 |
| 727 case WM_RBUTTONDOWN: | 726 case WM_RBUTTONDOWN: |
| 728 if (tree->select_on_right_mouse_down_) { | 727 if (tree->select_on_right_mouse_down_) { |
| 729 TVHITTESTINFO hit_info; | 728 TVHITTESTINFO hit_info; |
| 730 hit_info.pt.x = GET_X_LPARAM(l_param); | 729 hit_info.pt = gfx::Point(l_param).ToPOINT(); |
| 731 hit_info.pt.y = GET_Y_LPARAM(l_param); | |
| 732 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info); | 730 HTREEITEM hit_item = TreeView_HitTest(window, &hit_info); |
| 733 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT | | 731 if (hit_item && (hit_info.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT | |
| 734 TVHT_ONITEMINDENT)) != 0) | 732 TVHT_ONITEMINDENT)) != 0) |
| 735 TreeView_SelectItem(tree->tree_view_, hit_item); | 733 TreeView_SelectItem(tree->tree_view_, hit_item); |
| 736 } | 734 } |
| 737 // Fall through and let the default handler process as well. | 735 // Fall through and let the default handler process as well. |
| 738 break; | 736 break; |
| 739 } | 737 } |
| 740 WNDPROC handler = tree->original_handler_; | 738 WNDPROC handler = tree->original_handler_; |
| 741 DCHECK(handler); | 739 DCHECK(handler); |
| 742 return CallWindowProc(handler, window, message, w_param, l_param); | 740 return CallWindowProc(handler, window, message, w_param, l_param); |
| 743 } | 741 } |
| 744 | 742 |
| 745 } // namespace views | 743 } // namespace views |
| OLD | NEW |