| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/tabbed_pane/tabbed_pane.h" | 5 #include "views/controls/tabbed_pane/tabbed_pane.h" |
| 6 | 6 |
| 7 #include "app/keyboard_codes.h" | 7 #include "base/keyboard_codes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "views/controls/native/native_view_host.h" | 9 #include "views/controls/native/native_view_host.h" |
| 10 #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" | 10 #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" |
| 11 | 11 |
| 12 namespace views { | 12 namespace views { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 const char TabbedPane::kViewClassName[] = "views/TabbedPane"; | 15 const char TabbedPane::kViewClassName[] = "views/TabbedPane"; |
| 16 | 16 |
| 17 TabbedPane::TabbedPane() : native_tabbed_pane_(NULL), listener_(NULL) { | 17 TabbedPane::TabbedPane() : native_tabbed_pane_(NULL), listener_(NULL) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (is_add && !native_tabbed_pane_) { | 75 if (is_add && !native_tabbed_pane_) { |
| 76 CreateWrapper(); | 76 CreateWrapper(); |
| 77 AddChildView(native_tabbed_pane_->GetView()); | 77 AddChildView(native_tabbed_pane_->GetView()); |
| 78 LoadAccelerators(); | 78 LoadAccelerators(); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool TabbedPane::AcceleratorPressed(const views::Accelerator& accelerator) { | 82 bool TabbedPane::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 83 // We only accept Ctrl+Tab keyboard events. | 83 // We only accept Ctrl+Tab keyboard events. |
| 84 DCHECK(accelerator.GetKeyCode() == | 84 DCHECK(accelerator.GetKeyCode() == |
| 85 app::VKEY_TAB && accelerator.IsCtrlDown()); | 85 base::VKEY_TAB && accelerator.IsCtrlDown()); |
| 86 | 86 |
| 87 int tab_count = GetTabCount(); | 87 int tab_count = GetTabCount(); |
| 88 if (tab_count <= 1) | 88 if (tab_count <= 1) |
| 89 return false; | 89 return false; |
| 90 int selected_tab_index = GetSelectedTabIndex(); | 90 int selected_tab_index = GetSelectedTabIndex(); |
| 91 int next_tab_index = accelerator.IsShiftDown() ? | 91 int next_tab_index = accelerator.IsShiftDown() ? |
| 92 (selected_tab_index - 1) % tab_count : | 92 (selected_tab_index - 1) % tab_count : |
| 93 (selected_tab_index + 1) % tab_count; | 93 (selected_tab_index + 1) % tab_count; |
| 94 // Wrap around. | 94 // Wrap around. |
| 95 if (next_tab_index < 0) | 95 if (next_tab_index < 0) |
| 96 next_tab_index += tab_count; | 96 next_tab_index += tab_count; |
| 97 SelectTabAt(next_tab_index); | 97 SelectTabAt(next_tab_index); |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void TabbedPane::LoadAccelerators() { | 101 void TabbedPane::LoadAccelerators() { |
| 102 // Ctrl+Shift+Tab | 102 // Ctrl+Shift+Tab |
| 103 AddAccelerator(views::Accelerator(app::VKEY_TAB, true, true, false)); | 103 AddAccelerator(views::Accelerator(base::VKEY_TAB, true, true, false)); |
| 104 // Ctrl+Tab | 104 // Ctrl+Tab |
| 105 AddAccelerator(views::Accelerator(app::VKEY_TAB, false, true, false)); | 105 AddAccelerator(views::Accelerator(base::VKEY_TAB, false, true, false)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void TabbedPane::Layout() { | 108 void TabbedPane::Layout() { |
| 109 if (native_tabbed_pane_) | 109 if (native_tabbed_pane_) |
| 110 native_tabbed_pane_->GetView()->SetBounds(0, 0, width(), height()); | 110 native_tabbed_pane_->GetView()->SetBounds(0, 0, width(), height()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void TabbedPane::Focus() { | 113 void TabbedPane::Focus() { |
| 114 // Forward the focus to the wrapper. | 114 // Forward the focus to the wrapper. |
| 115 if (native_tabbed_pane_) { | 115 if (native_tabbed_pane_) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 135 *role = AccessibilityTypes::ROLE_PAGETABLIST; | 135 *role = AccessibilityTypes::ROLE_PAGETABLIST; |
| 136 return true; | 136 return true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 gfx::Size TabbedPane::GetPreferredSize() { | 139 gfx::Size TabbedPane::GetPreferredSize() { |
| 140 return native_tabbed_pane_ ? | 140 return native_tabbed_pane_ ? |
| 141 native_tabbed_pane_->GetPreferredSize() : gfx::Size(); | 141 native_tabbed_pane_->GetPreferredSize() : gfx::Size(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace views | 144 } // namespace views |
| OLD | NEW |