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