| 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_views.h" | 5 #include "ui/views/controls/tree/tree_view_views.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.h" | 10 #include "base/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/event.h" |
| 13 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
| 14 #include "ui/base/native_theme/native_theme.h" | 15 #include "ui/base/native_theme/native_theme.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 18 #include "ui/gfx/skia_util.h" | 19 #include "ui/gfx/skia_util.h" |
| 19 #include "ui/views/background.h" | 20 #include "ui/views/background.h" |
| 20 #include "ui/views/border.h" | 21 #include "ui/views/border.h" |
| 21 #include "ui/views/controls/scroll_view.h" | 22 #include "ui/views/controls/scroll_view.h" |
| 22 #include "ui/views/controls/textfield/textfield.h" | 23 #include "ui/views/controls/textfield/textfield.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 (node != &root_ && IsExpanded(node->parent()->model_node())))) { | 419 (node != &root_ && IsExpanded(node->parent()->model_node())))) { |
| 419 DrawnNodesChanged(); | 420 DrawnNodesChanged(); |
| 420 } | 421 } |
| 421 } | 422 } |
| 422 | 423 |
| 423 void TreeView::ContentsChanged(Textfield* sender, | 424 void TreeView::ContentsChanged(Textfield* sender, |
| 424 const string16& new_contents) { | 425 const string16& new_contents) { |
| 425 } | 426 } |
| 426 | 427 |
| 427 bool TreeView::HandleKeyEvent(Textfield* sender, | 428 bool TreeView::HandleKeyEvent(Textfield* sender, |
| 428 const KeyEvent& key_event) { | 429 const ui::KeyEvent& key_event) { |
| 429 switch (key_event.key_code()) { | 430 switch (key_event.key_code()) { |
| 430 case ui::VKEY_RETURN: | 431 case ui::VKEY_RETURN: |
| 431 CommitEdit(); | 432 CommitEdit(); |
| 432 return true; | 433 return true; |
| 433 | 434 |
| 434 case ui::VKEY_ESCAPE: | 435 case ui::VKEY_ESCAPE: |
| 435 CancelEdit(); | 436 CancelEdit(); |
| 436 RequestFocus(); | 437 RequestFocus(); |
| 437 return true; | 438 return true; |
| 438 | 439 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 460 y = node_bounds.y(); | 461 y = node_bounds.y(); |
| 461 } | 462 } |
| 462 } | 463 } |
| 463 gfx::Point screen_loc(0, y); | 464 gfx::Point screen_loc(0, y); |
| 464 if (base::i18n::IsRTL()) | 465 if (base::i18n::IsRTL()) |
| 465 screen_loc.set_x(width()); | 466 screen_loc.set_x(width()); |
| 466 ConvertPointToScreen(this, &screen_loc); | 467 ConvertPointToScreen(this, &screen_loc); |
| 467 return screen_loc; | 468 return screen_loc; |
| 468 } | 469 } |
| 469 | 470 |
| 470 bool TreeView::OnKeyPressed(const KeyEvent& event) { | 471 bool TreeView::OnKeyPressed(const ui::KeyEvent& event) { |
| 471 if (!HasFocus()) | 472 if (!HasFocus()) |
| 472 return false; | 473 return false; |
| 473 | 474 |
| 474 switch (event.key_code()) { | 475 switch (event.key_code()) { |
| 475 case ui::VKEY_F2: | 476 case ui::VKEY_F2: |
| 476 if (!editor_) { | 477 if (!editor_) { |
| 477 TreeModelNode* selected_node = GetSelectedNode(); | 478 TreeModelNode* selected_node = GetSelectedNode(); |
| 478 if (selected_node && (!controller_ || | 479 if (selected_node && (!controller_ || |
| 479 controller_->CanEdit(this, selected_node))) { | 480 controller_->CanEdit(this, selected_node))) { |
| 480 StartEditing(selected_node); | 481 StartEditing(selected_node); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 if (!is_expanded_) | 902 if (!is_expanded_) |
| 902 return max_width; | 903 return max_width; |
| 903 for (int i = 0; i < child_count(); ++i) { | 904 for (int i = 0; i < child_count(); ++i) { |
| 904 max_width = std::max(max_width, | 905 max_width = std::max(max_width, |
| 905 GetChild(i)->GetMaxWidth(indent, depth + 1)); | 906 GetChild(i)->GetMaxWidth(indent, depth + 1)); |
| 906 } | 907 } |
| 907 return max_width; | 908 return max_width; |
| 908 } | 909 } |
| 909 | 910 |
| 910 } // namespace views | 911 } // namespace views |
| OLD | NEW |