OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Gets the maximum size of the view. Currently only used for sizing shell | 270 // Gets the maximum size of the view. Currently only used for sizing shell |
271 // windows. | 271 // windows. |
272 virtual gfx::Size GetMaximumSize(); | 272 virtual gfx::Size GetMaximumSize(); |
273 | 273 |
274 // Return the height necessary to display this view with the provided width. | 274 // Return the height necessary to display this view with the provided width. |
275 // View's implementation returns the value from getPreferredSize.cy. | 275 // View's implementation returns the value from getPreferredSize.cy. |
276 // Override if your View's preferred height depends upon the width (such | 276 // Override if your View's preferred height depends upon the width (such |
277 // as with Labels). | 277 // as with Labels). |
278 virtual int GetHeightForWidth(int w); | 278 virtual int GetHeightForWidth(int w); |
279 | 279 |
280 // Set whether this view is visible. Painting is scheduled as needed. | 280 // Sets whether this view is visible. Painting is scheduled as needed. Also, |
| 281 // clears focus if the focused view or one of its ancestors is set to be |
| 282 // hidden. |
281 virtual void SetVisible(bool visible); | 283 virtual void SetVisible(bool visible); |
282 | 284 |
283 // Return whether a view is visible | 285 // Return whether a view is visible |
284 bool visible() const { return visible_; } | 286 bool visible() const { return visible_; } |
285 | 287 |
286 // Returns true if this view is drawn on screen. | 288 // Returns true if this view is drawn on screen. |
287 virtual bool IsDrawn() const; | 289 virtual bool IsDrawn() const; |
288 | 290 |
289 // Set whether this view is enabled. A disabled view does not receive keyboard | 291 // Set whether this view is enabled. A disabled view does not receive keyboard |
290 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint | 292 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint |
291 // is invoked. | 293 // is invoked. Also, clears focus if the focused view is disabled. |
292 void SetEnabled(bool enabled); | 294 void SetEnabled(bool enabled); |
293 | 295 |
294 // Returns whether the view is enabled. | 296 // Returns whether the view is enabled. |
295 bool enabled() const { return enabled_; } | 297 bool enabled() const { return enabled_; } |
296 | 298 |
297 // This indicates that the view completely fills its bounds in an opaque | 299 // This indicates that the view completely fills its bounds in an opaque |
298 // color. This doesn't affect compositing but is a hint to the compositor to | 300 // color. This doesn't affect compositing but is a hint to the compositor to |
299 // optimize painting. | 301 // optimize painting. |
300 // Note that this method does not implicitly create a layer if one does not | 302 // Note that this method does not implicitly create a layer if one does not |
301 // already exist for the View, but is a no-op in that case. | 303 // already exist for the View, but is a no-op in that case. |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // Returns the view that should be selected next when pressing Shift-Tab. | 760 // Returns the view that should be selected next when pressing Shift-Tab. |
759 View* GetPreviousFocusableView(); | 761 View* GetPreviousFocusableView(); |
760 | 762 |
761 // Sets the component that should be selected next when pressing Tab, and | 763 // Sets the component that should be selected next when pressing Tab, and |
762 // makes the current view the precedent view of the specified one. | 764 // makes the current view the precedent view of the specified one. |
763 // Note that by default views are linked in the order they have been added to | 765 // Note that by default views are linked in the order they have been added to |
764 // their container. Use this method if you want to modify the order. | 766 // their container. Use this method if you want to modify the order. |
765 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. | 767 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. |
766 void SetNextFocusableView(View* view); | 768 void SetNextFocusableView(View* view); |
767 | 769 |
768 // Sets whether this view is capable of taking focus. | 770 // Sets whether this view is capable of taking focus. It will clear focus if |
| 771 // the focused view is set to be non-focusable. |
769 // Note that this is false by default so that a view used as a container does | 772 // Note that this is false by default so that a view used as a container does |
770 // not get the focus. | 773 // not get the focus. |
771 void set_focusable(bool focusable) { focusable_ = focusable; } | 774 void SetFocusable(bool focusable); |
772 | 775 |
773 // Returns true if this view is capable of taking focus. | 776 // Returns true if this view is capable of taking focus. |
774 bool focusable() const { return focusable_ && enabled_ && visible_; } | 777 bool focusable() const { return focusable_ && enabled_ && visible_; } |
775 | 778 |
776 // Returns true if this view is |focusable_|, |enabled_| and drawn. | 779 // Returns true if this view is |focusable_|, |enabled_| and drawn. |
777 virtual bool IsFocusable() const; | 780 virtual bool IsFocusable() const; |
778 | 781 |
779 // Return whether this view is focusable when the user requires full keyboard | 782 // Return whether this view is focusable when the user requires full keyboard |
780 // access, even though it may not be normally focusable. | 783 // access, even though it may not be normally focusable. |
781 bool IsAccessibilityFocusable() const; | 784 bool IsAccessibilityFocusable() const; |
782 | 785 |
783 // Set whether this view can be made focusable if the user requires | 786 // Set whether this view can be made focusable if the user requires |
784 // full keyboard access, even though it's not normally focusable. | 787 // full keyboard access, even though it's not normally focusable. It will |
| 788 // clear focus if the focused view is set to be non-focusable. |
785 // Note that this is false by default. | 789 // Note that this is false by default. |
786 void set_accessibility_focusable(bool accessibility_focusable) { | 790 void SetAccessibilityFocusable(bool accessibility_focusable); |
787 accessibility_focusable_ = accessibility_focusable; | |
788 } | |
789 | 791 |
790 // Convenience method to retrieve the FocusManager associated with the | 792 // Convenience method to retrieve the FocusManager associated with the |
791 // Widget that contains this view. This can return NULL if this view is not | 793 // Widget that contains this view. This can return NULL if this view is not |
792 // part of a view hierarchy with a Widget. | 794 // part of a view hierarchy with a Widget. |
793 virtual FocusManager* GetFocusManager(); | 795 virtual FocusManager* GetFocusManager(); |
794 virtual const FocusManager* GetFocusManager() const; | 796 virtual const FocusManager* GetFocusManager() const; |
795 | 797 |
796 // Request keyboard focus. The receiving view will become the focused view. | 798 // Request keyboard focus. The receiving view will become the focused view. |
797 virtual void RequestFocus(); | 799 virtual void RequestFocus(); |
798 | 800 |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 // |leave_data_intact| if true does not remove data from accelerators_ array, | 1385 // |leave_data_intact| if true does not remove data from accelerators_ array, |
1384 // so it could be re-registered with other focus manager | 1386 // so it could be re-registered with other focus manager |
1385 void UnregisterAccelerators(bool leave_data_intact); | 1387 void UnregisterAccelerators(bool leave_data_intact); |
1386 | 1388 |
1387 // Focus --------------------------------------------------------------------- | 1389 // Focus --------------------------------------------------------------------- |
1388 | 1390 |
1389 // Initialize the previous/next focusable views of the specified view relative | 1391 // Initialize the previous/next focusable views of the specified view relative |
1390 // to the view at the specified index. | 1392 // to the view at the specified index. |
1391 void InitFocusSiblings(View* view, int index); | 1393 void InitFocusSiblings(View* view, int index); |
1392 | 1394 |
| 1395 // Helper function to revise the focused view, in case it has become |
| 1396 // unfocusable. |
| 1397 void ReviseFocusedView(); |
| 1398 |
1393 // System events ------------------------------------------------------------- | 1399 // System events ------------------------------------------------------------- |
1394 | 1400 |
1395 // Used to propagate theme changed notifications from the root view to all | 1401 // Used to propagate theme changed notifications from the root view to all |
1396 // views in the hierarchy. | 1402 // views in the hierarchy. |
1397 virtual void PropagateThemeChanged(); | 1403 virtual void PropagateThemeChanged(); |
1398 | 1404 |
1399 // Used to propagate locale changed notifications from the root view to all | 1405 // Used to propagate locale changed notifications from the root view to all |
1400 // views in the hierarchy. | 1406 // views in the hierarchy. |
1401 virtual void PropagateLocaleChanged(); | 1407 virtual void PropagateLocaleChanged(); |
1402 | 1408 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 // Belongs to this view, but it's reference-counted on some platforms | 1563 // Belongs to this view, but it's reference-counted on some platforms |
1558 // so we can't use a scoped_ptr. It's dereferenced in the destructor. | 1564 // so we can't use a scoped_ptr. It's dereferenced in the destructor. |
1559 NativeViewAccessibility* native_view_accessibility_; | 1565 NativeViewAccessibility* native_view_accessibility_; |
1560 | 1566 |
1561 DISALLOW_COPY_AND_ASSIGN(View); | 1567 DISALLOW_COPY_AND_ASSIGN(View); |
1562 }; | 1568 }; |
1563 | 1569 |
1564 } // namespace views | 1570 } // namespace views |
1565 | 1571 |
1566 #endif // UI_VIEWS_VIEW_H_ | 1572 #endif // UI_VIEWS_VIEW_H_ |
OLD | NEW |