| 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" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 int old_width = node->text_width(); | 475 int old_width = node->text_width(); |
| 476 UpdateNodeTextWidth(node); | 476 UpdateNodeTextWidth(node); |
| 477 if (old_width != node->text_width() && | 477 if (old_width != node->text_width() && |
| 478 ((node == &root_ && root_shown_) || | 478 ((node == &root_ && root_shown_) || |
| 479 (node != &root_ && IsExpanded(node->parent()->model_node())))) { | 479 (node != &root_ && IsExpanded(node->parent()->model_node())))) { |
| 480 DrawnNodesChanged(); | 480 DrawnNodesChanged(); |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 | 483 |
| 484 void TreeView::ContentsChanged(Textfield* sender, | 484 void TreeView::ContentsChanged(Textfield* sender, |
| 485 const string16& new_contents) { | 485 const base::string16& new_contents) { |
| 486 } | 486 } |
| 487 | 487 |
| 488 bool TreeView::HandleKeyEvent(Textfield* sender, | 488 bool TreeView::HandleKeyEvent(Textfield* sender, |
| 489 const ui::KeyEvent& key_event) { | 489 const ui::KeyEvent& key_event) { |
| 490 switch (key_event.key_code()) { | 490 switch (key_event.key_code()) { |
| 491 case ui::VKEY_RETURN: | 491 case ui::VKEY_RETURN: |
| 492 CommitEdit(); | 492 CommitEdit(); |
| 493 return true; | 493 return true; |
| 494 | 494 |
| 495 case ui::VKEY_ESCAPE: | 495 case ui::VKEY_ESCAPE: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 518 | 518 |
| 519 int TreeView::GetSelectedRow() { | 519 int TreeView::GetSelectedRow() { |
| 520 ui::TreeModelNode* model_node = GetSelectedNode(); | 520 ui::TreeModelNode* model_node = GetSelectedNode(); |
| 521 return model_node ? GetRowForNode(model_node) : -1; | 521 return model_node ? GetRowForNode(model_node) : -1; |
| 522 } | 522 } |
| 523 | 523 |
| 524 void TreeView::SetSelectedRow(int row) { | 524 void TreeView::SetSelectedRow(int row) { |
| 525 SetSelectedNode(GetNodeForRow(row)); | 525 SetSelectedNode(GetNodeForRow(row)); |
| 526 } | 526 } |
| 527 | 527 |
| 528 string16 TreeView::GetTextForRow(int row) { | 528 base::string16 TreeView::GetTextForRow(int row) { |
| 529 return GetNodeForRow(row)->GetTitle(); | 529 return GetNodeForRow(row)->GetTitle(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 gfx::Point TreeView::GetKeyboardContextMenuLocation() { | 532 gfx::Point TreeView::GetKeyboardContextMenuLocation() { |
| 533 int y = height() / 2; | 533 int y = height() / 2; |
| 534 if (selected_node_) { | 534 if (selected_node_) { |
| 535 gfx::Rect node_bounds(GetBoundsForNode(selected_node_)); | 535 gfx::Rect node_bounds(GetBoundsForNode(selected_node_)); |
| 536 gfx::Rect vis_bounds(GetVisibleBounds()); | 536 gfx::Rect vis_bounds(GetVisibleBounds()); |
| 537 if (node_bounds.y() >= vis_bounds.y() && | 537 if (node_bounds.y() >= vis_bounds.y() && |
| 538 node_bounds.y() < vis_bounds.bottom()) { | 538 node_bounds.y() < vis_bounds.bottom()) { |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 if (!is_expanded_) | 1033 if (!is_expanded_) |
| 1034 return max_width; | 1034 return max_width; |
| 1035 for (int i = 0; i < child_count(); ++i) { | 1035 for (int i = 0; i < child_count(); ++i) { |
| 1036 max_width = std::max(max_width, | 1036 max_width = std::max(max_width, |
| 1037 GetChild(i)->GetMaxWidth(indent, depth + 1)); | 1037 GetChild(i)->GetMaxWidth(indent, depth + 1)); |
| 1038 } | 1038 } |
| 1039 return max_width; | 1039 return max_width; |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 } // namespace views | 1042 } // namespace views |
| OLD | NEW |