OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef VIEWS_FOCUS_FOCUS_MANAGER_H_ | 5 #ifndef VIEWS_FOCUS_FOCUS_MANAGER_H_ |
6 #define VIEWS_FOCUS_FOCUS_MANAGER_H_ | 6 #define VIEWS_FOCUS_FOCUS_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
14 #include "ui/base/models/accelerator.h" | 15 #include "ui/base/models/accelerator.h" |
15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
16 #include "views/views_export.h" | 17 #include "views/views_export.h" |
17 #include "views/events/event.h" | 18 #include "views/events/event.h" |
18 | 19 |
19 // The FocusManager class is used to handle focus traversal, store/restore | 20 // The FocusManager class is used to handle focus traversal, store/restore |
20 // focused views and handle keyboard accelerators. | 21 // focused views and handle keyboard accelerators. |
21 // | 22 // |
22 // There are 2 types of focus: | 23 // There are 2 types of focus: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // the parent view that directly contains the native window. This is needed | 65 // the parent view that directly contains the native window. This is needed |
65 // when traversing up from the nested RootView to know which view to start | 66 // when traversing up from the nested RootView to know which view to start |
66 // with when going to the next/previous view. | 67 // with when going to the next/previous view. |
67 // In our example: | 68 // In our example: |
68 // hwnd_view_container_->GetWidget()->SetFocusTraversableParent( | 69 // hwnd_view_container_->GetWidget()->SetFocusTraversableParent( |
69 // native_control); | 70 // native_control); |
70 // | 71 // |
71 // Note that FocusTraversable do not have to be RootViews: AccessibleToolbarView | 72 // Note that FocusTraversable do not have to be RootViews: AccessibleToolbarView |
72 // is FocusTraversable. | 73 // is FocusTraversable. |
73 | 74 |
| 75 namespace ui { |
| 76 class AcceleratorTarget; |
| 77 class AcceleratorManager; |
| 78 } |
| 79 |
74 namespace views { | 80 namespace views { |
75 | 81 |
76 class FocusSearch; | 82 class FocusSearch; |
77 class RootView; | 83 class RootView; |
78 class View; | 84 class View; |
79 class Widget; | 85 class Widget; |
80 | 86 |
81 // The FocusTraversable interface is used by components that want to process | 87 // The FocusTraversable interface is used by components that want to process |
82 // focus traversal events (due to Tab/Shift-Tab key events). | 88 // focus traversal events (due to Tab/Shift-Tab key events). |
83 class VIEWS_EXPORT FocusTraversable { | 89 class VIEWS_EXPORT FocusTraversable { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 View* FindFocusableView(FocusTraversable* focus_traversable, | 252 View* FindFocusableView(FocusTraversable* focus_traversable, |
247 View* starting_view, | 253 View* starting_view, |
248 bool reverse); | 254 bool reverse); |
249 | 255 |
250 // The top-level Widget this FocusManager is associated with. | 256 // The top-level Widget this FocusManager is associated with. |
251 Widget* widget_; | 257 Widget* widget_; |
252 | 258 |
253 // The view that currently is focused. | 259 // The view that currently is focused. |
254 View* focused_view_; | 260 View* focused_view_; |
255 | 261 |
| 262 // The AcceleratorManager this FocusManager is associated with. |
| 263 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; |
| 264 |
256 // The storage id used in the ViewStorage to store/restore the view that last | 265 // The storage id used in the ViewStorage to store/restore the view that last |
257 // had focus. | 266 // had focus. |
258 int stored_focused_view_storage_id_; | 267 int stored_focused_view_storage_id_; |
259 | 268 |
260 // The reason why the focus most recently changed. | 269 // The reason why the focus most recently changed. |
261 FocusChangeReason focus_change_reason_; | 270 FocusChangeReason focus_change_reason_; |
262 | 271 |
263 // The accelerators and associated targets. | |
264 typedef std::list<ui::AcceleratorTarget*> AcceleratorTargetList; | |
265 typedef std::map<ui::Accelerator, AcceleratorTargetList> AcceleratorMap; | |
266 AcceleratorMap accelerators_; | |
267 | |
268 // The list of registered FocusChange listeners. | 272 // The list of registered FocusChange listeners. |
269 ObserverList<FocusChangeListener, true> focus_change_listeners_; | 273 ObserverList<FocusChangeListener, true> focus_change_listeners_; |
270 | 274 |
271 // See description above getter. | 275 // See description above getter. |
272 bool is_changing_focus_; | 276 bool is_changing_focus_; |
273 | 277 |
274 DISALLOW_COPY_AND_ASSIGN(FocusManager); | 278 DISALLOW_COPY_AND_ASSIGN(FocusManager); |
275 }; | 279 }; |
276 | 280 |
277 } // namespace views | 281 } // namespace views |
278 | 282 |
279 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ | 283 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ |
OLD | NEW |