| 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 "grit/ui_resources.h" | 11 #include "grit/ui_resources.h" |
| 12 #include "ui/base/accessibility/accessible_view_state.h" | 12 #include "ui/base/accessibility/accessible_view_state.h" |
| 13 #include "ui/base/events/event.h" | 13 #include "ui/base/events/event.h" |
| 14 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 18 #include "ui/gfx/rect_conversions.h" | 18 #include "ui/gfx/rect_conversions.h" |
| 19 #include "ui/gfx/skia_util.h" | 19 #include "ui/gfx/skia_util.h" |
| 20 #include "ui/native_theme/native_theme.h" | 20 #include "ui/native_theme/native_theme.h" |
| 21 #include "ui/views/controls/prefix_selector.h" | 21 #include "ui/views/controls/prefix_selector.h" |
| 22 #include "ui/views/controls/scroll_view.h" | 22 #include "ui/views/controls/scroll_view.h" |
| 23 #include "ui/views/controls/textfield/textfield.h" | 23 #include "ui/views/controls/textfield/textfield.h" |
| 24 #include "ui/views/controls/tree/tree_view_controller.h" | 24 #include "ui/views/controls/tree/tree_view_controller.h" |
| 25 #include "ui/views/ime/input_method.h" | |
| 26 | 25 |
| 27 using ui::TreeModel; | 26 using ui::TreeModel; |
| 28 using ui::TreeModelNode; | 27 using ui::TreeModelNode; |
| 29 | 28 |
| 30 namespace views { | 29 namespace views { |
| 31 | 30 |
| 32 // Insets around the view. | 31 // Insets around the view. |
| 33 static const int kHorizontalInset = 2; | 32 static const int kHorizontalInset = 2; |
| 34 static const int kVerticalInset = 2; | 33 static const int kVerticalInset = 2; |
| 35 // Padding before/after the image. | 34 // Padding before/after the image. |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 int max_row = (max_y - kVerticalInset) / row_height_; | 592 int max_row = (max_y - kVerticalInset) / row_height_; |
| 594 if ((max_y - kVerticalInset) % row_height_ != 0) | 593 if ((max_y - kVerticalInset) % row_height_ != 0) |
| 595 max_row++; | 594 max_row++; |
| 596 int current_row = root_row(); | 595 int current_row = root_row(); |
| 597 PaintRows(canvas, min_row, max_row, &root_, root_depth(), ¤t_row); | 596 PaintRows(canvas, min_row, max_row, &root_, root_depth(), ¤t_row); |
| 598 } | 597 } |
| 599 | 598 |
| 600 void TreeView::OnFocus() { | 599 void TreeView::OnFocus() { |
| 601 View::OnFocus(); | 600 View::OnFocus(); |
| 602 SchedulePaintForNode(selected_node_); | 601 SchedulePaintForNode(selected_node_); |
| 603 | |
| 604 // Notify the InputMethod so that it knows to query the TextInputClient. | |
| 605 if (GetInputMethod()) | |
| 606 GetInputMethod()->OnCaretBoundsChanged(this); | |
| 607 } | 602 } |
| 608 | 603 |
| 609 void TreeView::OnBlur() { | 604 void TreeView::OnBlur() { |
| 605 View::OnBlur(); |
| 610 SchedulePaintForNode(selected_node_); | 606 SchedulePaintForNode(selected_node_); |
| 611 if (selector_) | 607 if (selector_) |
| 612 selector_->OnViewBlur(); | 608 selector_->OnViewBlur(); |
| 613 } | 609 } |
| 614 | 610 |
| 615 bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) { | 611 bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) { |
| 616 CommitEdit(); | 612 CommitEdit(); |
| 617 RequestFocus(); | 613 RequestFocus(); |
| 618 | 614 |
| 619 int row = (event.y() - kVerticalInset) / row_height_; | 615 int row = (event.y() - kVerticalInset) / row_height_; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 if (!is_expanded_) | 1008 if (!is_expanded_) |
| 1013 return max_width; | 1009 return max_width; |
| 1014 for (int i = 0; i < child_count(); ++i) { | 1010 for (int i = 0; i < child_count(); ++i) { |
| 1015 max_width = std::max(max_width, | 1011 max_width = std::max(max_width, |
| 1016 GetChild(i)->GetMaxWidth(indent, depth + 1)); | 1012 GetChild(i)->GetMaxWidth(indent, depth + 1)); |
| 1017 } | 1013 } |
| 1018 return max_width; | 1014 return max_width; |
| 1019 } | 1015 } |
| 1020 | 1016 |
| 1021 } // namespace views | 1017 } // namespace views |
| OLD | NEW |