| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif | 10 #endif |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 class FocusManager { | 155 class FocusManager { |
| 156 public: | 156 public: |
| 157 #if defined(OS_WIN) | 157 #if defined(OS_WIN) |
| 158 // Creates a FocusManager for the specified window. Top level windows | 158 // Creates a FocusManager for the specified window. Top level windows |
| 159 // must invoked this when created. | 159 // must invoked this when created. |
| 160 // The RootView specified should be the top RootView of the window. | 160 // The RootView specified should be the top RootView of the window. |
| 161 // This also invokes InstallFocusSubclass. | 161 // This also invokes InstallFocusSubclass. |
| 162 static FocusManager* CreateFocusManager(HWND window, RootView* root_view); | 162 static FocusManager* CreateFocusManager(HWND window, RootView* root_view); |
| 163 | |
| 164 // Subclasses the specified window. The subclassed window procedure listens | |
| 165 // for WM_SETFOCUS notification and keeps the FocusManager's focus owner | |
| 166 // property in sync. | |
| 167 // It's not necessary to explicitly invoke Uninstall, it's automatically done | |
| 168 // when the window is destroyed and Uninstall wasn't invoked. | |
| 169 static void InstallFocusSubclass(HWND window, View* view); | |
| 170 | |
| 171 // Uninstalls the window subclass installed by InstallFocusSubclass. | |
| 172 static void UninstallFocusSubclass(HWND window); | |
| 173 #endif | 163 #endif |
| 174 | 164 |
| 175 static FocusManager* GetFocusManager(gfx::NativeView window); | 165 static FocusManager* GetFocusManager(gfx::NativeView window); |
| 176 | 166 |
| 177 #if defined(OS_WIN) | 167 #if defined(OS_WIN) |
| 178 // Message handlers (for messages received from registered windows). | 168 // Message handlers (for messages received from registered windows). |
| 179 // Should return true if the message should be forwarded to the window | 169 // Should return true if the message should be forwarded to the window |
| 180 // original proc function, false otherwise. | 170 // original proc function, false otherwise. |
| 181 bool OnSetFocus(HWND window); | 171 bool OnSetFocus(HWND window); |
| 182 bool OnNCDestroy(HWND window); | 172 bool OnNCDestroy(HWND window); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 const Accelerator& accelertor) const; | 277 const Accelerator& accelertor) const; |
| 288 | 278 |
| 289 // Convenience method that returns true if the passed |key_event| should | 279 // Convenience method that returns true if the passed |key_event| should |
| 290 // trigger tab traversal (if it is a TAB key press with or without SHIFT | 280 // trigger tab traversal (if it is a TAB key press with or without SHIFT |
| 291 // pressed). | 281 // pressed). |
| 292 static bool IsTabTraversalKeyEvent(const KeyEvent& key_event); | 282 static bool IsTabTraversalKeyEvent(const KeyEvent& key_event); |
| 293 | 283 |
| 294 private: | 284 private: |
| 295 #if defined(OS_WIN) | 285 #if defined(OS_WIN) |
| 296 explicit FocusManager(HWND root, RootView* root_view); | 286 explicit FocusManager(HWND root, RootView* root_view); |
| 287 |
| 288 // Subclasses the specified window. The subclassed window procedure listens |
| 289 // for WM_SETFOCUS notification and keeps the FocusManager's focus owner |
| 290 // property in sync. |
| 291 // It's not necessary to explicitly invoke Uninstall, it's automatically done |
| 292 // when the window is destroyed and Uninstall wasn't invoked. |
| 293 static void InstallFocusSubclass(HWND window, View* view); |
| 294 |
| 295 // Uninstalls the window subclass installed by InstallFocusSubclass. |
| 296 static void UninstallFocusSubclass(HWND window); |
| 297 #endif | 297 #endif |
| 298 ~FocusManager(); | 298 ~FocusManager(); |
| 299 | 299 |
| 300 // Returns the next focusable view. | 300 // Returns the next focusable view. |
| 301 View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop); | 301 View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop); |
| 302 | 302 |
| 303 // Returns the last view of the focus traversal hierarchy. | 303 // Returns the last view of the focus traversal hierarchy. |
| 304 View* FindLastFocusableView(); | 304 View* FindLastFocusableView(); |
| 305 | 305 |
| 306 // Returns the focusable view found in the FocusTraversable specified starting | 306 // Returns the focusable view found in the FocusTraversable specified starting |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 // The list of registered FocusChange listeners. | 341 // The list of registered FocusChange listeners. |
| 342 typedef std::vector<FocusChangeListener*> FocusChangeListenerList; | 342 typedef std::vector<FocusChangeListener*> FocusChangeListenerList; |
| 343 FocusChangeListenerList focus_change_listeners_; | 343 FocusChangeListenerList focus_change_listeners_; |
| 344 | 344 |
| 345 DISALLOW_COPY_AND_ASSIGN(FocusManager); | 345 DISALLOW_COPY_AND_ASSIGN(FocusManager); |
| 346 }; | 346 }; |
| 347 | 347 |
| 348 } // namespace views | 348 } // namespace views |
| 349 | 349 |
| 350 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ | 350 #endif // VIEWS_FOCUS_FOCUS_MANAGER_H_ |
| OLD | NEW |