| 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_VIEW_H_ | 5 #ifndef UI_VIEWS_VIEW_H_ |
| 6 #define UI_VIEWS_VIEW_H_ | 6 #define UI_VIEWS_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Override if your View's preferred height depends upon the width (such | 241 // Override if your View's preferred height depends upon the width (such |
| 242 // as with Labels). | 242 // as with Labels). |
| 243 virtual int GetHeightForWidth(int w); | 243 virtual int GetHeightForWidth(int w); |
| 244 | 244 |
| 245 // Set whether this view is visible. Painting is scheduled as needed. | 245 // Set whether this view is visible. Painting is scheduled as needed. |
| 246 virtual void SetVisible(bool visible); | 246 virtual void SetVisible(bool visible); |
| 247 | 247 |
| 248 // Return whether a view is visible | 248 // Return whether a view is visible |
| 249 bool visible() const { return visible_; } | 249 bool visible() const { return visible_; } |
| 250 | 250 |
| 251 // Return whether this view and its ancestors are visible. Returns true if the | 251 // Returns true if this view is drawn on screen. |
| 252 // path from this view to the root view is visible. | |
| 253 virtual bool IsDrawn() const; | 252 virtual bool IsDrawn() const; |
| 254 | 253 |
| 255 // Set whether this view is enabled. A disabled view does not receive keyboard | 254 // Set whether this view is enabled. A disabled view does not receive keyboard |
| 256 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint | 255 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint |
| 257 // is invoked. | 256 // is invoked. |
| 258 void SetEnabled(bool enabled); | 257 void SetEnabled(bool enabled); |
| 259 | 258 |
| 260 // Returns whether the view is enabled. | 259 // Returns whether the view is enabled. |
| 261 bool enabled() const { return enabled_; } | 260 bool enabled() const { return enabled_; } |
| 262 | 261 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 // Returns the view that should be selected next when pressing Shift-Tab. | 654 // Returns the view that should be selected next when pressing Shift-Tab. |
| 656 View* GetPreviousFocusableView(); | 655 View* GetPreviousFocusableView(); |
| 657 | 656 |
| 658 // Sets the component that should be selected next when pressing Tab, and | 657 // Sets the component that should be selected next when pressing Tab, and |
| 659 // makes the current view the precedent view of the specified one. | 658 // makes the current view the precedent view of the specified one. |
| 660 // Note that by default views are linked in the order they have been added to | 659 // Note that by default views are linked in the order they have been added to |
| 661 // their container. Use this method if you want to modify the order. | 660 // their container. Use this method if you want to modify the order. |
| 662 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. | 661 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. |
| 663 void SetNextFocusableView(View* view); | 662 void SetNextFocusableView(View* view); |
| 664 | 663 |
| 665 // Sets whether this view can accept the focus. | 664 // Sets whether this view is capable of taking focus. |
| 666 // Note that this is false by default so that a view used as a container does | 665 // Note that this is false by default so that a view used as a container does |
| 667 // not get the focus. | 666 // not get the focus. |
| 668 void set_focusable(bool focusable) { focusable_ = focusable; } | 667 void set_focusable(bool focusable) { focusable_ = focusable; } |
| 669 | 668 |
| 669 // Returns true if this view is capable of taking focus. |
| 670 bool focusable() const { return focusable_ && enabled_ && visible_; } |
| 671 |
| 670 // Returns true if the view is focusable (IsFocusable) and visible in the root | 672 // Returns true if the view is focusable (IsFocusable) and visible in the root |
| 671 // view. See also IsFocusable. | 673 // view. See also IsFocusable. |
| 672 bool IsFocusableInRootView() const; | 674 virtual bool IsFocusableInRootView() const; |
| 673 | 675 |
| 674 // Return whether this view is focusable when the user requires full keyboard | 676 // Return whether this view is focusable when the user requires full keyboard |
| 675 // access, even though it may not be normally focusable. | 677 // access, even though it may not be normally focusable. |
| 676 bool IsAccessibilityFocusableInRootView() const; | 678 bool IsAccessibilityFocusableInRootView() const; |
| 677 | 679 |
| 678 // Set whether this view can be made focusable if the user requires | 680 // Set whether this view can be made focusable if the user requires |
| 679 // full keyboard access, even though it's not normally focusable. | 681 // full keyboard access, even though it's not normally focusable. |
| 680 // Note that this is false by default. | 682 // Note that this is false by default. |
| 681 void set_accessibility_focusable(bool accessibility_focusable) { | 683 void set_accessibility_focusable(bool accessibility_focusable) { |
| 682 accessibility_focusable_ = accessibility_focusable; | 684 accessibility_focusable_ = accessibility_focusable; |
| 683 } | 685 } |
| 684 | 686 |
| 685 // Convenience method to retrieve the FocusManager associated with the | 687 // Convenience method to retrieve the FocusManager associated with the |
| 686 // Widget that contains this view. This can return NULL if this view is not | 688 // Widget that contains this view. This can return NULL if this view is not |
| 687 // part of a view hierarchy with a Widget. | 689 // part of a view hierarchy with a Widget. |
| 688 virtual FocusManager* GetFocusManager(); | 690 virtual FocusManager* GetFocusManager(); |
| 689 virtual const FocusManager* GetFocusManager() const; | 691 virtual const FocusManager* GetFocusManager() const; |
| 690 | 692 |
| 691 // Request the keyboard focus. The receiving view will become the | 693 // Request the keyboard focus. The receiving view will become the |
| 692 // focused view. | 694 // focused view. |
| 693 virtual void RequestFocus(); | 695 virtual void RequestFocus(); |
| 694 | 696 |
| 695 // Invoked when a view is about to be requested for focus due to the focus | 697 // Invoked when a view is about to be requested for focus due to the focus |
| 696 // traversal. Reverse is this request was generated going backward | 698 // traversal. Reverse is this request was generated going backward |
| 697 // (Shift-Tab). | 699 // (Shift-Tab). |
| 698 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) { } | 700 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) {} |
| 699 | 701 |
| 700 // Invoked when a key is pressed before the key event is processed (and | 702 // Invoked when a key is pressed before the key event is processed (and |
| 701 // potentially eaten) by the focus manager for tab traversal, accelerators and | 703 // potentially eaten) by the focus manager for tab traversal, accelerators and |
| 702 // other focus related actions. | 704 // other focus related actions. |
| 703 // The default implementation returns false, ensuring that tab traversal and | 705 // The default implementation returns false, ensuring that tab traversal and |
| 704 // accelerators processing is performed. | 706 // accelerators processing is performed. |
| 705 // Subclasses should return true if they want to process the key event and not | 707 // Subclasses should return true if they want to process the key event and not |
| 706 // have it processed as an accelerator (if any) or as a tab traversal (if the | 708 // have it processed as an accelerator (if any) or as a tab traversal (if the |
| 707 // key event is for the TAB key). In that case, OnKeyPressed will | 709 // key event is for the TAB key). In that case, OnKeyPressed will |
| 708 // subsequently be invoked for that event. | 710 // subsequently be invoked for that event. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 // Default value is false, in which case the View will hit-test against its | 1003 // Default value is false, in which case the View will hit-test against its |
| 1002 // bounds. | 1004 // bounds. |
| 1003 virtual bool HasHitTestMask() const; | 1005 virtual bool HasHitTestMask() const; |
| 1004 | 1006 |
| 1005 // Called by HitTest to retrieve a mask for hit-testing against. Subclasses | 1007 // Called by HitTest to retrieve a mask for hit-testing against. Subclasses |
| 1006 // override to provide custom shaped hit test regions. | 1008 // override to provide custom shaped hit test regions. |
| 1007 virtual void GetHitTestMask(gfx::Path* mask) const; | 1009 virtual void GetHitTestMask(gfx::Path* mask) const; |
| 1008 | 1010 |
| 1009 // Focus --------------------------------------------------------------------- | 1011 // Focus --------------------------------------------------------------------- |
| 1010 | 1012 |
| 1011 // Returns whether this view can accept focus. | |
| 1012 // A view can accept focus if it's enabled, focusable and visible. | |
| 1013 // This method is intended for views to use when calculating preferred size. | |
| 1014 // The FocusManager and other places use IsFocusableInRootView. | |
| 1015 virtual bool IsFocusable() const; | |
| 1016 | |
| 1017 // Override to be notified when focus has changed either to or from this View. | 1013 // Override to be notified when focus has changed either to or from this View. |
| 1018 virtual void OnFocus(); | 1014 virtual void OnFocus(); |
| 1019 virtual void OnBlur(); | 1015 virtual void OnBlur(); |
| 1020 | 1016 |
| 1021 // Handle view focus/blur events for this view. | 1017 // Handle view focus/blur events for this view. |
| 1022 void Focus(); | 1018 void Focus(); |
| 1023 void Blur(); | 1019 void Blur(); |
| 1024 | 1020 |
| 1025 // System events ------------------------------------------------------------- | 1021 // System events ------------------------------------------------------------- |
| 1026 | 1022 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 base::win::ScopedComPtr<NativeViewAccessibilityWin> | 1427 base::win::ScopedComPtr<NativeViewAccessibilityWin> |
| 1432 native_view_accessibility_win_; | 1428 native_view_accessibility_win_; |
| 1433 #endif | 1429 #endif |
| 1434 | 1430 |
| 1435 DISALLOW_COPY_AND_ASSIGN(View); | 1431 DISALLOW_COPY_AND_ASSIGN(View); |
| 1436 }; | 1432 }; |
| 1437 | 1433 |
| 1438 } // namespace views | 1434 } // namespace views |
| 1439 | 1435 |
| 1440 #endif // UI_VIEWS_VIEW_H_ | 1436 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |