| 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 UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_ | 5 #ifndef UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_ |
| 6 #define UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_ | 6 #define UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "ui/base/accelerators/accelerator.h" | 11 #include "ui/base/accelerators/accelerator.h" |
| 12 #include "ui/views/focus/focus_manager.h" | 12 #include "ui/views/focus/focus_manager.h" |
| 13 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 class FocusSearch; | 16 class FocusSearch; |
| 17 | 17 |
| 18 // This class provides keyboard access to any view that extends it, typically | 18 // This class provides keyboard access to any view that extends it, typically |
| 19 // a toolbar. The user sets focus to a control in this view by pressing | 19 // a toolbar. The user sets focus to a control in this view by pressing |
| 20 // F6 to traverse all panes, or by pressing a shortcut that jumps directly | 20 // F6 to traverse all panes, or by pressing a shortcut that jumps directly |
| 21 // to this pane. | 21 // to this pane. |
| 22 class VIEWS_EXPORT AccessiblePaneView : public View, | 22 class VIEWS_EXPORT AccessiblePaneView : public View, |
| 23 public FocusChangeListener, | 23 public FocusChangeListener, |
| 24 public FocusTraversable { | 24 public FocusTraversable { |
| 25 public: | 25 public: |
| 26 AccessiblePaneView(); | 26 AccessiblePaneView(); |
| 27 virtual ~AccessiblePaneView(); | 27 ~AccessiblePaneView() override; |
| 28 | 28 |
| 29 // Set focus to the pane with complete keyboard access. | 29 // Set focus to the pane with complete keyboard access. |
| 30 // Focus will be restored to the last focused view if the user escapes. | 30 // Focus will be restored to the last focused view if the user escapes. |
| 31 // If |initial_focus| is not NULL, that control will get | 31 // If |initial_focus| is not NULL, that control will get |
| 32 // the initial focus, if it's enabled and focusable. Returns true if | 32 // the initial focus, if it's enabled and focusable. Returns true if |
| 33 // the pane was able to receive focus. | 33 // the pane was able to receive focus. |
| 34 virtual bool SetPaneFocus(View* initial_focus); | 34 virtual bool SetPaneFocus(View* initial_focus); |
| 35 | 35 |
| 36 // Set focus to the pane with complete keyboard access, with the | 36 // Set focus to the pane with complete keyboard access, with the |
| 37 // focus initially set to the default child. Focus will be restored | 37 // focus initially set to the default child. Focus will be restored |
| 38 // to the last focused view if the user escapes. | 38 // to the last focused view if the user escapes. |
| 39 // Returns true if the pane was able to receive focus. | 39 // Returns true if the pane was able to receive focus. |
| 40 virtual bool SetPaneFocusAndFocusDefault(); | 40 virtual bool SetPaneFocusAndFocusDefault(); |
| 41 | 41 |
| 42 // Overridden from View: | 42 // Overridden from View: |
| 43 virtual FocusTraversable* GetPaneFocusTraversable() override; | 43 FocusTraversable* GetPaneFocusTraversable() override; |
| 44 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) | 44 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 45 override; | 45 void SetVisible(bool flag) override; |
| 46 virtual void SetVisible(bool flag) override; | 46 void GetAccessibleState(ui::AXViewState* state) override; |
| 47 virtual void GetAccessibleState(ui::AXViewState* state) override; | 47 void RequestFocus() override; |
| 48 virtual void RequestFocus() override; | |
| 49 | 48 |
| 50 // Overridden from FocusChangeListener: | 49 // Overridden from FocusChangeListener: |
| 51 virtual void OnWillChangeFocus(View* focused_before, | 50 void OnWillChangeFocus(View* focused_before, View* focused_now) override; |
| 52 View* focused_now) override; | 51 void OnDidChangeFocus(View* focused_before, View* focused_now) override; |
| 53 virtual void OnDidChangeFocus(View* focused_before, | |
| 54 View* focused_now) override; | |
| 55 | 52 |
| 56 // Overridden from FocusTraversable: | 53 // Overridden from FocusTraversable: |
| 57 virtual FocusSearch* GetFocusSearch() override; | 54 FocusSearch* GetFocusSearch() override; |
| 58 virtual FocusTraversable* GetFocusTraversableParent() override; | 55 FocusTraversable* GetFocusTraversableParent() override; |
| 59 virtual View* GetFocusTraversableParentView() override; | 56 View* GetFocusTraversableParentView() override; |
| 60 | 57 |
| 61 // For testing only. | 58 // For testing only. |
| 62 const ui::Accelerator& home_key() const { return home_key_; } | 59 const ui::Accelerator& home_key() const { return home_key_; } |
| 63 const ui::Accelerator& end_key() const { return end_key_; } | 60 const ui::Accelerator& end_key() const { return end_key_; } |
| 64 const ui::Accelerator& escape_key() const { return escape_key_; } | 61 const ui::Accelerator& escape_key() const { return escape_key_; } |
| 65 const ui::Accelerator& left_key() const { return left_key_; } | 62 const ui::Accelerator& left_key() const { return left_key_; } |
| 66 const ui::Accelerator& right_key() const { return right_key_; } | 63 const ui::Accelerator& right_key() const { return right_key_; } |
| 67 | 64 |
| 68 protected: | 65 protected: |
| 69 // A subclass can override this to provide a default focusable child | 66 // A subclass can override this to provide a default focusable child |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 friend class AccessiblePaneViewFocusSearch; | 120 friend class AccessiblePaneViewFocusSearch; |
| 124 | 121 |
| 125 base::WeakPtrFactory<AccessiblePaneView> method_factory_; | 122 base::WeakPtrFactory<AccessiblePaneView> method_factory_; |
| 126 | 123 |
| 127 DISALLOW_COPY_AND_ASSIGN(AccessiblePaneView); | 124 DISALLOW_COPY_AND_ASSIGN(AccessiblePaneView); |
| 128 }; | 125 }; |
| 129 | 126 |
| 130 } // namespace views | 127 } // namespace views |
| 131 | 128 |
| 132 #endif // UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_ | 129 #endif // UI_VIEWS_ACCESSIBLE_PANE_VIEW_H_ |
| OLD | NEW |