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> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 namespace views { | 73 namespace views { |
74 | 74 |
75 class FocusSearch; | 75 class FocusSearch; |
76 class RootView; | 76 class RootView; |
77 class View; | 77 class View; |
78 class Widget; | 78 class Widget; |
79 | 79 |
80 // The FocusTraversable interface is used by components that want to process | 80 // The FocusTraversable interface is used by components that want to process |
81 // focus traversal events (due to Tab/Shift-Tab key events). | 81 // focus traversal events (due to Tab/Shift-Tab key events). |
82 class VIEWS_API FocusTraversable { | 82 class VIEWS_EXPORT FocusTraversable { |
83 public: | 83 public: |
84 // Return a FocusSearch object that implements the algorithm to find | 84 // Return a FocusSearch object that implements the algorithm to find |
85 // the next or previous focusable view. | 85 // the next or previous focusable view. |
86 virtual FocusSearch* GetFocusSearch() = 0; | 86 virtual FocusSearch* GetFocusSearch() = 0; |
87 | 87 |
88 // Should return the parent FocusTraversable. | 88 // Should return the parent FocusTraversable. |
89 // The top RootView which is the top FocusTraversable returns NULL. | 89 // The top RootView which is the top FocusTraversable returns NULL. |
90 virtual FocusTraversable* GetFocusTraversableParent() = 0; | 90 virtual FocusTraversable* GetFocusTraversableParent() = 0; |
91 | 91 |
92 // This should return the View this FocusTraversable belongs to. | 92 // This should return the View this FocusTraversable belongs to. |
93 // It is used when walking up the view hierarchy tree to find which view | 93 // It is used when walking up the view hierarchy tree to find which view |
94 // should be used as the starting view for finding the next/previous view. | 94 // should be used as the starting view for finding the next/previous view. |
95 virtual View* GetFocusTraversableParentView() = 0; | 95 virtual View* GetFocusTraversableParentView() = 0; |
96 | 96 |
97 protected: | 97 protected: |
98 virtual ~FocusTraversable() {} | 98 virtual ~FocusTraversable() {} |
99 }; | 99 }; |
100 | 100 |
101 // This interface should be implemented by classes that want to be notified when | 101 // This interface should be implemented by classes that want to be notified when |
102 // the focus is about to change. See the Add/RemoveFocusChangeListener methods. | 102 // the focus is about to change. See the Add/RemoveFocusChangeListener methods. |
103 // No change to focus state has occurred yet when this function is called. | 103 // No change to focus state has occurred yet when this function is called. |
104 class VIEWS_API FocusChangeListener { | 104 class VIEWS_EXPORT FocusChangeListener { |
105 public: | 105 public: |
106 virtual void FocusWillChange(View* focused_before, View* focused_now) = 0; | 106 virtual void FocusWillChange(View* focused_before, View* focused_now) = 0; |
107 | 107 |
108 protected: | 108 protected: |
109 virtual ~FocusChangeListener() {} | 109 virtual ~FocusChangeListener() {} |
110 }; | 110 }; |
111 | 111 |
112 // This interface should be implemented by classes that want to be notified when | 112 // This interface should be implemented by classes that want to be notified when |
113 // the native focus is about to change. Listeners implementing this interface | 113 // the native focus is about to change. Listeners implementing this interface |
114 // will be invoked for all native focus changes across the entire Chrome | 114 // will be invoked for all native focus changes across the entire Chrome |
115 // application. FocusChangeListeners are only called for changes within the | 115 // application. FocusChangeListeners are only called for changes within the |
116 // children of a single top-level native-view. | 116 // children of a single top-level native-view. |
117 class WidgetFocusChangeListener { | 117 class WidgetFocusChangeListener { |
118 public: | 118 public: |
119 virtual void NativeFocusWillChange(gfx::NativeView focused_before, | 119 virtual void NativeFocusWillChange(gfx::NativeView focused_before, |
120 gfx::NativeView focused_now) = 0; | 120 gfx::NativeView focused_now) = 0; |
121 | 121 |
122 protected: | 122 protected: |
123 virtual ~WidgetFocusChangeListener() {} | 123 virtual ~WidgetFocusChangeListener() {} |
124 }; | 124 }; |
125 | 125 |
126 class VIEWS_API FocusManager { | 126 class VIEWS_EXPORT FocusManager { |
127 public: | 127 public: |
128 class VIEWS_API WidgetFocusManager { | 128 class VIEWS_EXPORT WidgetFocusManager { |
129 public: | 129 public: |
130 // Returns the singleton instance. | 130 // Returns the singleton instance. |
131 static WidgetFocusManager* GetInstance(); | 131 static WidgetFocusManager* GetInstance(); |
132 | 132 |
133 // Adds/removes a WidgetFocusChangeListener |listener| to the set of | 133 // Adds/removes a WidgetFocusChangeListener |listener| to the set of |
134 // active listeners. | 134 // active listeners. |
135 void AddFocusChangeListener(WidgetFocusChangeListener* listener); | 135 void AddFocusChangeListener(WidgetFocusChangeListener* listener); |
136 void RemoveFocusChangeListener(WidgetFocusChangeListener* listener); | 136 void RemoveFocusChangeListener(WidgetFocusChangeListener* listener); |
137 | 137 |
138 // To be called when native-focus shifts from |focused_before| to | 138 // To be called when native-focus shifts from |focused_before| to |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 ~AutoNativeNotificationDisabler() { | 327 ~AutoNativeNotificationDisabler() { |
328 FocusManager::GetWidgetFocusManager()->EnableNotifications(); | 328 FocusManager::GetWidgetFocusManager()->EnableNotifications(); |
329 } | 329 } |
330 private: | 330 private: |
331 DISALLOW_COPY_AND_ASSIGN(AutoNativeNotificationDisabler); | 331 DISALLOW_COPY_AND_ASSIGN(AutoNativeNotificationDisabler); |
332 }; | 332 }; |
333 | 333 |
334 } // namespace views | 334 } // namespace views |
335 | 335 |
336 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ | 336 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ |
OLD | NEW |