| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/tree/tree_view.h" | 5 #include "ui/views/controls/tree/tree_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
| 12 #include "ui/base/ime/input_method.h" | 12 #include "ui/base/ime/input_method.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 15 #include "ui/events/keycodes/keyboard_codes.h" | 15 #include "ui/events/keycodes/keyboard_codes.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/geometry/rect_conversions.h" | 18 #include "ui/gfx/geometry/rect_conversions.h" |
| 19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/skia_util.h" | 20 #include "ui/gfx/skia_util.h" |
| 21 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
| 22 #include "ui/resources/grit/ui_resources.h" | 22 #include "ui/resources/grit/ui_resources.h" |
| 23 #include "ui/views/controls/prefix_selector.h" | 23 #include "ui/views/controls/prefix_selector.h" |
| 24 #include "ui/views/controls/scroll_view.h" | 24 #include "ui/views/controls/scroll_view.h" |
| 25 #include "ui/views/controls/textfield/textfield.h" | 25 #include "ui/views/controls/textfield/textfield.h" |
| 26 #include "ui/views/controls/tree/tree_view_controller.h" | 26 #include "ui/views/controls/tree/tree_view_controller.h" |
| 27 #include "ui/views/resources/grit/views_resources.h" | 27 #include "ui/views/resources/grit/views_resources.h" |
| 28 #include "ui/views/style/platform_style.h" |
| 28 | 29 |
| 29 using ui::TreeModel; | 30 using ui::TreeModel; |
| 30 using ui::TreeModelNode; | 31 using ui::TreeModelNode; |
| 31 | 32 |
| 32 namespace views { | 33 namespace views { |
| 33 | 34 |
| 34 // Insets around the view. | 35 // Insets around the view. |
| 35 static const int kHorizontalInset = 2; | 36 static const int kHorizontalInset = 2; |
| 36 static const int kVerticalInset = 2; | 37 static const int kVerticalInset = 2; |
| 37 // Padding before/after the image. | 38 // Padding before/after the image. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 : model_(NULL), | 75 : model_(NULL), |
| 75 selected_node_(NULL), | 76 selected_node_(NULL), |
| 76 editing_(false), | 77 editing_(false), |
| 77 editor_(NULL), | 78 editor_(NULL), |
| 78 focus_manager_(NULL), | 79 focus_manager_(NULL), |
| 79 auto_expand_children_(false), | 80 auto_expand_children_(false), |
| 80 editable_(true), | 81 editable_(true), |
| 81 controller_(NULL), | 82 controller_(NULL), |
| 82 root_shown_(true), | 83 root_shown_(true), |
| 83 row_height_(font_list_.GetHeight() + kTextVerticalPadding * 2) { | 84 row_height_(font_list_.GetHeight() + kTextVerticalPadding * 2) { |
| 84 SetFocusable(true); | 85 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::TREE_VIEW, this); |
| 85 closed_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 86 closed_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 86 (base::i18n::IsRTL() ? IDR_FOLDER_CLOSED_RTL | 87 (base::i18n::IsRTL() ? IDR_FOLDER_CLOSED_RTL |
| 87 : IDR_FOLDER_CLOSED)).ToImageSkia(); | 88 : IDR_FOLDER_CLOSED)).ToImageSkia(); |
| 88 open_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 89 open_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 89 (base::i18n::IsRTL() ? IDR_FOLDER_OPEN_RTL | 90 (base::i18n::IsRTL() ? IDR_FOLDER_OPEN_RTL |
| 90 : IDR_FOLDER_OPEN)).ToImageSkia(); | 91 : IDR_FOLDER_OPEN)).ToImageSkia(); |
| 91 text_offset_ = closed_icon_.width() + kImagePadding + kImagePadding + | 92 text_offset_ = closed_icon_.width() + kImagePadding + kImagePadding + |
| 92 kArrowRegionSize; | 93 kArrowRegionSize; |
| 93 } | 94 } |
| 94 | 95 |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 if (!is_expanded_) | 1044 if (!is_expanded_) |
| 1044 return max_width; | 1045 return max_width; |
| 1045 for (int i = 0; i < child_count(); ++i) { | 1046 for (int i = 0; i < child_count(); ++i) { |
| 1046 max_width = std::max(max_width, | 1047 max_width = std::max(max_width, |
| 1047 GetChild(i)->GetMaxWidth(indent, depth + 1)); | 1048 GetChild(i)->GetMaxWidth(indent, depth + 1)); |
| 1048 } | 1049 } |
| 1049 return max_width; | 1050 return max_width; |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1052 } // namespace views | 1053 } // namespace views |
| OLD | NEW |