| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 // Gets the maximum size of the view. Currently only used for sizing shell | 264 // Gets the maximum size of the view. Currently only used for sizing shell |
| 265 // windows. | 265 // windows. |
| 266 virtual gfx::Size GetMaximumSize() const; | 266 virtual gfx::Size GetMaximumSize() const; |
| 267 | 267 |
| 268 // Return the height necessary to display this view with the provided width. | 268 // Return the height necessary to display this view with the provided width. |
| 269 // View's implementation returns the value from getPreferredSize.cy. | 269 // View's implementation returns the value from getPreferredSize.cy. |
| 270 // Override if your View's preferred height depends upon the width (such | 270 // Override if your View's preferred height depends upon the width (such |
| 271 // as with Labels). | 271 // as with Labels). |
| 272 virtual int GetHeightForWidth(int w) const; | 272 virtual int GetHeightForWidth(int w) const; |
| 273 | 273 |
| 274 // Set whether this view is visible. Painting is scheduled as needed. | 274 // Sets whether this view is visible. Painting is scheduled as needed. Also, |
| 275 // clears focus if the focused view or one of its ancestors is set to be |
| 276 // hidden. |
| 275 virtual void SetVisible(bool visible); | 277 virtual void SetVisible(bool visible); |
| 276 | 278 |
| 277 // Return whether a view is visible | 279 // Return whether a view is visible |
| 278 bool visible() const { return visible_; } | 280 bool visible() const { return visible_; } |
| 279 | 281 |
| 280 // Returns true if this view is drawn on screen. | 282 // Returns true if this view is drawn on screen. |
| 281 virtual bool IsDrawn() const; | 283 virtual bool IsDrawn() const; |
| 282 | 284 |
| 283 // Set whether this view is enabled. A disabled view does not receive keyboard | 285 // Set whether this view is enabled. A disabled view does not receive keyboard |
| 284 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint | 286 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint |
| 285 // is invoked. | 287 // is invoked. Also, clears focus if the focused view is disabled. |
| 286 void SetEnabled(bool enabled); | 288 void SetEnabled(bool enabled); |
| 287 | 289 |
| 288 // Returns whether the view is enabled. | 290 // Returns whether the view is enabled. |
| 289 bool enabled() const { return enabled_; } | 291 bool enabled() const { return enabled_; } |
| 290 | 292 |
| 291 // This indicates that the view completely fills its bounds in an opaque | 293 // This indicates that the view completely fills its bounds in an opaque |
| 292 // color. This doesn't affect compositing but is a hint to the compositor to | 294 // color. This doesn't affect compositing but is a hint to the compositor to |
| 293 // optimize painting. | 295 // optimize painting. |
| 294 // Note that this method does not implicitly create a layer if one does not | 296 // Note that this method does not implicitly create a layer if one does not |
| 295 // already exist for the View, but is a no-op in that case. | 297 // already exist for the View, but is a no-op in that case. |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 // Returns the view that should be selected next when pressing Shift-Tab. | 763 // Returns the view that should be selected next when pressing Shift-Tab. |
| 762 View* GetPreviousFocusableView(); | 764 View* GetPreviousFocusableView(); |
| 763 | 765 |
| 764 // Sets the component that should be selected next when pressing Tab, and | 766 // Sets the component that should be selected next when pressing Tab, and |
| 765 // makes the current view the precedent view of the specified one. | 767 // makes the current view the precedent view of the specified one. |
| 766 // Note that by default views are linked in the order they have been added to | 768 // Note that by default views are linked in the order they have been added to |
| 767 // their container. Use this method if you want to modify the order. | 769 // their container. Use this method if you want to modify the order. |
| 768 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. | 770 // IMPORTANT NOTE: loops in the focus hierarchy are not supported. |
| 769 void SetNextFocusableView(View* view); | 771 void SetNextFocusableView(View* view); |
| 770 | 772 |
| 771 // Sets whether this view is capable of taking focus. | 773 // Sets whether this view is capable of taking focus. It will clear focus if |
| 774 // the focused view is set to be non-focusable. |
| 772 // Note that this is false by default so that a view used as a container does | 775 // Note that this is false by default so that a view used as a container does |
| 773 // not get the focus. | 776 // not get the focus. |
| 774 void SetFocusable(bool focusable); | 777 void SetFocusable(bool focusable); |
| 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 SetAccessibilityFocusable(bool accessibility_focusable); | 790 void SetAccessibilityFocusable(bool accessibility_focusable); |
| 787 | 791 |
| 788 // Convenience method to retrieve the FocusManager associated with the | 792 // Convenience method to retrieve the FocusManager associated with the |
| 789 // 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 |
| 790 // part of a view hierarchy with a Widget. | 794 // part of a view hierarchy with a Widget. |
| 791 virtual FocusManager* GetFocusManager(); | 795 virtual FocusManager* GetFocusManager(); |
| 792 virtual const FocusManager* GetFocusManager() const; | 796 virtual const FocusManager* GetFocusManager() const; |
| 793 | 797 |
| 794 // Request keyboard focus. The receiving view will become the focused view. | 798 // Request keyboard focus. The receiving view will become the focused view. |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 // |leave_data_intact| if true does not remove data from accelerators_ array, | 1409 // |leave_data_intact| if true does not remove data from accelerators_ array, |
| 1406 // so it could be re-registered with other focus manager | 1410 // so it could be re-registered with other focus manager |
| 1407 void UnregisterAccelerators(bool leave_data_intact); | 1411 void UnregisterAccelerators(bool leave_data_intact); |
| 1408 | 1412 |
| 1409 // Focus --------------------------------------------------------------------- | 1413 // Focus --------------------------------------------------------------------- |
| 1410 | 1414 |
| 1411 // Initialize the previous/next focusable views of the specified view relative | 1415 // Initialize the previous/next focusable views of the specified view relative |
| 1412 // to the view at the specified index. | 1416 // to the view at the specified index. |
| 1413 void InitFocusSiblings(View* view, int index); | 1417 void InitFocusSiblings(View* view, int index); |
| 1414 | 1418 |
| 1419 // Helper function to revise the focused view, in case it has become |
| 1420 // unfocusable. |
| 1421 void ReviseFocusedView(); |
| 1422 |
| 1415 // System events ------------------------------------------------------------- | 1423 // System events ------------------------------------------------------------- |
| 1416 | 1424 |
| 1417 // Used to propagate theme changed notifications from the root view to all | 1425 // Used to propagate theme changed notifications from the root view to all |
| 1418 // views in the hierarchy. | 1426 // views in the hierarchy. |
| 1419 virtual void PropagateThemeChanged(); | 1427 virtual void PropagateThemeChanged(); |
| 1420 | 1428 |
| 1421 // Used to propagate locale changed notifications from the root view to all | 1429 // Used to propagate locale changed notifications from the root view to all |
| 1422 // views in the hierarchy. | 1430 // views in the hierarchy. |
| 1423 virtual void PropagateLocaleChanged(); | 1431 virtual void PropagateLocaleChanged(); |
| 1424 | 1432 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 // Belongs to this view, but it's reference-counted on some platforms | 1599 // Belongs to this view, but it's reference-counted on some platforms |
| 1592 // so we can't use a scoped_ptr. It's dereferenced in the destructor. | 1600 // so we can't use a scoped_ptr. It's dereferenced in the destructor. |
| 1593 NativeViewAccessibility* native_view_accessibility_; | 1601 NativeViewAccessibility* native_view_accessibility_; |
| 1594 | 1602 |
| 1595 DISALLOW_COPY_AND_ASSIGN(View); | 1603 DISALLOW_COPY_AND_ASSIGN(View); |
| 1596 }; | 1604 }; |
| 1597 | 1605 |
| 1598 } // namespace views | 1606 } // namespace views |
| 1599 | 1607 |
| 1600 #endif // UI_VIEWS_VIEW_H_ | 1608 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |