| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 // children. For each of these views, a notification is sent to the | 1095 // children. For each of these views, a notification is sent to the |
| 1096 // view and all parents. | 1096 // view and all parents. |
| 1097 // | 1097 // |
| 1098 // When a view is added, a notification is sent to the view, all its | 1098 // When a view is added, a notification is sent to the view, all its |
| 1099 // parents, and all its children (and grand children) | 1099 // parents, and all its children (and grand children) |
| 1100 // | 1100 // |
| 1101 // Default implementation does nothing. Override to perform operations | 1101 // Default implementation does nothing. Override to perform operations |
| 1102 // required when a view is added or removed from a view hierarchy | 1102 // required when a view is added or removed from a view hierarchy |
| 1103 // | 1103 // |
| 1104 // Refer to comments in struct |ViewHierarchyChangedDetails| for |details|. | 1104 // Refer to comments in struct |ViewHierarchyChangedDetails| for |details|. |
| 1105 // |
| 1106 // See also AddedToWidget() and RemovedFromWidget() for detecting when the |
| 1107 // view is added to/removed from a widget. |
| 1105 virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details); | 1108 virtual void ViewHierarchyChanged(const ViewHierarchyChangedDetails& details); |
| 1106 | 1109 |
| 1107 // When SetVisible() changes the visibility of a view, this method is | 1110 // When SetVisible() changes the visibility of a view, this method is |
| 1108 // invoked for that view as well as all the children recursively. | 1111 // invoked for that view as well as all the children recursively. |
| 1109 virtual void VisibilityChanged(View* starting_from, bool is_visible); | 1112 virtual void VisibilityChanged(View* starting_from, bool is_visible); |
| 1110 | 1113 |
| 1111 // This method is invoked when the parent NativeView of the widget that the | 1114 // This method is invoked when the parent NativeView of the widget that the |
| 1112 // view is attached to has changed and the view hierarchy has not changed. | 1115 // view is attached to has changed and the view hierarchy has not changed. |
| 1113 // ViewHierarchyChanged() is called when the parent NativeView of the widget | 1116 // ViewHierarchyChanged() is called when the parent NativeView of the widget |
| 1114 // that the view is attached to is changed as a result of changing the view | 1117 // that the view is attached to is changed as a result of changing the view |
| 1115 // hierarchy. Overriding this method is useful for tracking which | 1118 // hierarchy. Overriding this method is useful for tracking which |
| 1116 // FocusManager manages this view. | 1119 // FocusManager manages this view. |
| 1117 virtual void NativeViewHierarchyChanged(); | 1120 virtual void NativeViewHierarchyChanged(); |
| 1118 | 1121 |
| 1122 // This method is invoked for a view when it is attached to a hierarchy with |
| 1123 // a widget, i.e. GetWidget() starts returning a non-null result. |
| 1124 // It is also called when the view is moved to a different widget. |
| 1125 virtual void AddedToWidget(); |
| 1126 |
| 1127 // This method is invoked for a view when it is removed from a hierarchy with |
| 1128 // a widget or moved to a different widget. |
| 1129 virtual void RemovedFromWidget(); |
| 1130 |
| 1119 // Painting ------------------------------------------------------------------ | 1131 // Painting ------------------------------------------------------------------ |
| 1120 | 1132 |
| 1121 // Responsible for calling Paint() on child Views. Override to control the | 1133 // Responsible for calling Paint() on child Views. Override to control the |
| 1122 // order child Views are painted. | 1134 // order child Views are painted. |
| 1123 virtual void PaintChildren(const ui::PaintContext& context); | 1135 virtual void PaintChildren(const ui::PaintContext& context); |
| 1124 | 1136 |
| 1125 // Override to provide rendering in any part of the View's bounds. Typically | 1137 // Override to provide rendering in any part of the View's bounds. Typically |
| 1126 // this is the "contents" of the view. If you override this method you will | 1138 // this is the "contents" of the view. If you override this method you will |
| 1127 // have to call the subsequent OnPaint*() methods manually. | 1139 // have to call the subsequent OnPaint*() methods manually. |
| 1128 virtual void OnPaint(gfx::Canvas* canvas); | 1140 virtual void OnPaint(gfx::Canvas* canvas); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 void DoRemoveChildView(View* view, | 1303 void DoRemoveChildView(View* view, |
| 1292 bool update_focus_cycle, | 1304 bool update_focus_cycle, |
| 1293 bool update_tool_tip, | 1305 bool update_tool_tip, |
| 1294 bool delete_removed_view, | 1306 bool delete_removed_view, |
| 1295 View* new_parent); | 1307 View* new_parent); |
| 1296 | 1308 |
| 1297 // Call ViewHierarchyChanged() for all child views and all parents. | 1309 // Call ViewHierarchyChanged() for all child views and all parents. |
| 1298 // |old_parent| is the original parent of the View that was removed. | 1310 // |old_parent| is the original parent of the View that was removed. |
| 1299 // If |new_parent| is not NULL, the View that was removed will be reparented | 1311 // If |new_parent| is not NULL, the View that was removed will be reparented |
| 1300 // to |new_parent| after the remove operation. | 1312 // to |new_parent| after the remove operation. |
| 1301 void PropagateRemoveNotifications(View* old_parent, View* new_parent); | 1313 // If is_removed_from_widget is true, calls RemovedFromWidget for all |
| 1314 // children. |
| 1315 void PropagateRemoveNotifications(View* old_parent, |
| 1316 View* new_parent, |
| 1317 bool is_removed_from_widget); |
| 1302 | 1318 |
| 1303 // Call ViewHierarchyChanged() for all children. | 1319 // Call ViewHierarchyChanged() for all children. |
| 1304 void PropagateAddNotifications(const ViewHierarchyChangedDetails& details); | 1320 // If is_added_to_widget is true, calls AddedToWidget for all children. |
| 1321 void PropagateAddNotifications(const ViewHierarchyChangedDetails& details, |
| 1322 bool is_added_to_widget); |
| 1305 | 1323 |
| 1306 // Propagates NativeViewHierarchyChanged() notification through all the | 1324 // Propagates NativeViewHierarchyChanged() notification through all the |
| 1307 // children. | 1325 // children. |
| 1308 void PropagateNativeViewHierarchyChanged(); | 1326 void PropagateNativeViewHierarchyChanged(); |
| 1309 | 1327 |
| 1310 // Takes care of registering/unregistering accelerators if | 1328 // Takes care of registering/unregistering accelerators if |
| 1311 // |register_accelerators| true and calls ViewHierarchyChanged(). | 1329 // |register_accelerators| true and calls ViewHierarchyChanged(). |
| 1312 void ViewHierarchyChangedImpl(bool register_accelerators, | 1330 void ViewHierarchyChangedImpl(bool register_accelerators, |
| 1313 const ViewHierarchyChangedDetails& details); | 1331 const ViewHierarchyChangedDetails& details); |
| 1314 | 1332 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 // Observers ------------------------------------------------------------- | 1641 // Observers ------------------------------------------------------------- |
| 1624 | 1642 |
| 1625 base::ObserverList<ViewObserver> observers_; | 1643 base::ObserverList<ViewObserver> observers_; |
| 1626 | 1644 |
| 1627 DISALLOW_COPY_AND_ASSIGN(View); | 1645 DISALLOW_COPY_AND_ASSIGN(View); |
| 1628 }; | 1646 }; |
| 1629 | 1647 |
| 1630 } // namespace views | 1648 } // namespace views |
| 1631 | 1649 |
| 1632 #endif // UI_VIEWS_VIEW_H_ | 1650 #endif // UI_VIEWS_VIEW_H_ |
| OLD | NEW |