| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/gfx/canvas.h" |
| 9 #include "app/gfx/canvas_paint.h" | 10 #include "app/gfx/canvas_paint.h" |
| 11 #include "app/gfx/favicon_size.h" |
| 10 #include "app/gfx/icon_util.h" | 12 #include "app/gfx/icon_util.h" |
| 11 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
| 12 #include "app/l10n_util_win.h" | 14 #include "app/l10n_util_win.h" |
| 13 #include "app/resource_bundle.h" | 15 #include "app/resource_bundle.h" |
| 14 #include "base/gfx/point.h" | 16 #include "base/gfx/point.h" |
| 15 #include "base/keyboard_codes.h" | 17 #include "base/keyboard_codes.h" |
| 16 #include "base/stl_util-inl.h" | 18 #include "base/stl_util-inl.h" |
| 17 #include "base/win_util.h" | 19 #include "base/win_util.h" |
| 18 #include "grit/app_resources.h" | 20 #include "grit/app_resources.h" |
| 19 #include "views/focus/focus_manager.h" | 21 #include "views/focus/focus_manager.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 // image index when adding items to the tree. If you change the | 648 // image index when adding items to the tree. If you change the |
| 647 // order you'll undoubtedly need to update itemex.iSelectedImage | 649 // order you'll undoubtedly need to update itemex.iSelectedImage |
| 648 // when the item is added. | 650 // when the item is added. |
| 649 HICON h_closed_icon = IconUtil::CreateHICONFromSkBitmap(*closed_icon); | 651 HICON h_closed_icon = IconUtil::CreateHICONFromSkBitmap(*closed_icon); |
| 650 HICON h_opened_icon = IconUtil::CreateHICONFromSkBitmap(*opened_icon); | 652 HICON h_opened_icon = IconUtil::CreateHICONFromSkBitmap(*opened_icon); |
| 651 ImageList_AddIcon(image_list, h_closed_icon); | 653 ImageList_AddIcon(image_list, h_closed_icon); |
| 652 ImageList_AddIcon(image_list, h_opened_icon); | 654 ImageList_AddIcon(image_list, h_opened_icon); |
| 653 DestroyIcon(h_closed_icon); | 655 DestroyIcon(h_closed_icon); |
| 654 DestroyIcon(h_opened_icon); | 656 DestroyIcon(h_opened_icon); |
| 655 for (size_t i = 0; i < model_images.size(); ++i) { | 657 for (size_t i = 0; i < model_images.size(); ++i) { |
| 656 HICON model_icon = IconUtil::CreateHICONFromSkBitmap(model_images[i]); | 658 HICON model_icon; |
| 659 |
| 660 // Need to resize the provided icons to be the same size as |
| 661 // IDR_FOLDER_CLOSED if they aren't already. |
| 662 if (model_images[i].width() != width || |
| 663 model_images[i].height() != height) { |
| 664 gfx::Canvas canvas(width, height, false); |
| 665 // Make the background completely transparent. |
| 666 canvas.drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
| 667 |
| 668 // Draw our icons into this canvas. |
| 669 int height_offset = (height - model_images[i].height()) / 2; |
| 670 int width_offset = (width - model_images[i].width()) / 2; |
| 671 canvas.DrawBitmapInt(model_images[i], width_offset, height_offset); |
| 672 model_icon = IconUtil::CreateHICONFromSkBitmap(canvas.ExtractBitmap()); |
| 673 } else { |
| 674 model_icon = IconUtil::CreateHICONFromSkBitmap(model_images[i]); |
| 675 } |
| 657 ImageList_AddIcon(image_list, model_icon); | 676 ImageList_AddIcon(image_list, model_icon); |
| 658 DestroyIcon(model_icon); | 677 DestroyIcon(model_icon); |
| 659 } | 678 } |
| 660 } | 679 } |
| 661 return image_list; | 680 return image_list; |
| 662 } | 681 } |
| 663 | 682 |
| 664 HTREEITEM TreeView::GetTreeItemForNodeDuringMutation(TreeModelNode* node) { | 683 HTREEITEM TreeView::GetTreeItemForNodeDuringMutation(TreeModelNode* node) { |
| 665 if (node_to_details_map_.find(node) == node_to_details_map_.end()) { | 684 if (node_to_details_map_.find(node) == node_to_details_map_.end()) { |
| 666 // User hasn't navigated to this entry yet. Ignore the change. | 685 // User hasn't navigated to this entry yet. Ignore the change. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 } | 765 } |
| 747 // Fall through and let the default handler process as well. | 766 // Fall through and let the default handler process as well. |
| 748 break; | 767 break; |
| 749 } | 768 } |
| 750 WNDPROC handler = tree->original_handler_; | 769 WNDPROC handler = tree->original_handler_; |
| 751 DCHECK(handler); | 770 DCHECK(handler); |
| 752 return CallWindowProc(handler, window, message, w_param, l_param); | 771 return CallWindowProc(handler, window, message, w_param, l_param); |
| 753 } | 772 } |
| 754 | 773 |
| 755 } // namespace views | 774 } // namespace views |
| OLD | NEW |