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/tabbed_pane/tabbed_pane.h" | 5 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
9 #include "ui/base/keycodes/keyboard_codes.h" | 9 #include "ui/base/keycodes/keyboard_codes.h" |
10 #include "ui/views/controls/native/native_view_host.h" | 10 #include "ui/views/controls/native/native_view_host.h" |
| 11 #include "ui/views/controls/tabbed_pane/native_tabbed_pane_views.h" |
11 #include "ui/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" | 12 #include "ui/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" |
12 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" | 13 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" |
13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
14 | 15 |
| 16 // TODO(markusheintz): This should be removed once the native Windows tabbed |
| 17 // pane is not used anymore (http://crbug.com/138059). |
| 18 #if defined(OS_WIN) && !defined(USE_AURA) |
| 19 #include "ui/views/controls/tabbed_pane/native_tabbed_pane_win.h" |
| 20 #endif |
| 21 |
| 22 namespace { |
| 23 |
| 24 views::NativeTabbedPaneWrapper* CreateNativeWrapper( |
| 25 views::TabbedPane* tabbed_pane) { |
| 26 #if defined(OS_WIN) && !defined(USE_AURA) |
| 27 if (tabbed_pane->use_native_win_control()) |
| 28 return new views::NativeTabbedPaneWin(tabbed_pane); |
| 29 #endif |
| 30 return new views::NativeTabbedPaneViews(tabbed_pane); |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
15 namespace views { | 35 namespace views { |
16 | 36 |
17 // static | 37 // static |
18 const char TabbedPane::kViewClassName[] = "views/TabbedPane"; | 38 const char TabbedPane::kViewClassName[] = "views/TabbedPane"; |
19 | 39 |
20 TabbedPane::TabbedPane() : native_tabbed_pane_(NULL), listener_(NULL) { | 40 TabbedPane::TabbedPane() |
| 41 : native_tabbed_pane_(NULL), |
| 42 #if defined(OS_WIN) && !defined(USE_AURA) |
| 43 use_native_win_control_(false), |
| 44 #endif |
| 45 listener_(NULL) { |
21 set_focusable(true); | 46 set_focusable(true); |
22 } | 47 } |
23 | 48 |
24 TabbedPane::~TabbedPane() { | 49 TabbedPane::~TabbedPane() { |
25 } | 50 } |
26 | 51 |
27 int TabbedPane::GetTabCount() { | 52 int TabbedPane::GetTabCount() { |
28 return native_tabbed_pane_->GetTabCount(); | 53 return native_tabbed_pane_->GetTabCount(); |
29 } | 54 } |
30 | 55 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 104 |
80 void TabbedPane::Layout() { | 105 void TabbedPane::Layout() { |
81 if (native_tabbed_pane_) | 106 if (native_tabbed_pane_) |
82 native_tabbed_pane_->GetView()->SetBounds(0, 0, width(), height()); | 107 native_tabbed_pane_->GetView()->SetBounds(0, 0, width(), height()); |
83 } | 108 } |
84 | 109 |
85 void TabbedPane::ViewHierarchyChanged(bool is_add, View* parent, View* child) { | 110 void TabbedPane::ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
86 if (is_add && !native_tabbed_pane_) { | 111 if (is_add && !native_tabbed_pane_) { |
87 // The native wrapper's lifetime will be managed by the view hierarchy after | 112 // The native wrapper's lifetime will be managed by the view hierarchy after |
88 // we call AddChildView. | 113 // we call AddChildView. |
89 native_tabbed_pane_ = NativeTabbedPaneWrapper::CreateNativeWrapper(this); | 114 native_tabbed_pane_ = CreateNativeWrapper(this); |
90 AddChildView(native_tabbed_pane_->GetView()); | 115 AddChildView(native_tabbed_pane_->GetView()); |
91 LoadAccelerators(); | 116 LoadAccelerators(); |
92 } | 117 } |
93 } | 118 } |
94 | 119 |
95 bool TabbedPane::AcceleratorPressed(const ui::Accelerator& accelerator) { | 120 bool TabbedPane::AcceleratorPressed(const ui::Accelerator& accelerator) { |
96 // We only accept Ctrl+Tab keyboard events. | 121 // We only accept Ctrl+Tab keyboard events. |
97 DCHECK(accelerator.key_code() == ui::VKEY_TAB && accelerator.IsCtrlDown()); | 122 DCHECK(accelerator.key_code() == ui::VKEY_TAB && accelerator.IsCtrlDown()); |
98 | 123 |
99 int tab_count = GetTabCount(); | 124 int tab_count = GetTabCount(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 if (NativeViewHost::kRenderNativeControlFocus) | 159 if (NativeViewHost::kRenderNativeControlFocus) |
135 View::OnPaintFocusBorder(canvas); | 160 View::OnPaintFocusBorder(canvas); |
136 } | 161 } |
137 | 162 |
138 void TabbedPane::GetAccessibleState(ui::AccessibleViewState* state) { | 163 void TabbedPane::GetAccessibleState(ui::AccessibleViewState* state) { |
139 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; | 164 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; |
140 state->name = accessible_name_; | 165 state->name = accessible_name_; |
141 } | 166 } |
142 | 167 |
143 } // namespace views | 168 } // namespace views |
OLD | NEW |