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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void ReorderChildView(View* view, int index); | 185 void ReorderChildView(View* view, int index); |
186 | 186 |
187 // Removes |view| from this view. The view's parent will change to NULL. | 187 // Removes |view| from this view. The view's parent will change to NULL. |
188 void RemoveChildView(View* view); | 188 void RemoveChildView(View* view); |
189 | 189 |
190 // Removes all the children from this view. If |delete_children| is true, | 190 // Removes all the children from this view. If |delete_children| is true, |
191 // the views are deleted, unless marked as not parent owned. | 191 // the views are deleted, unless marked as not parent owned. |
192 void RemoveAllChildViews(bool delete_children); | 192 void RemoveAllChildViews(bool delete_children); |
193 | 193 |
194 int child_count() const { return static_cast<int>(children_.size()); } | 194 int child_count() const { return static_cast<int>(children_.size()); } |
| 195 // See also |GetChildrenInZOrder()| below that returns |children_| |
| 196 // in reverse z-order. |
195 bool has_children() const { return !children_.empty(); } | 197 bool has_children() const { return !children_.empty(); } |
196 | 198 |
197 // Returns the child view at |index|. | 199 // Returns the child view at |index|. |
198 const View* child_at(int index) const { | 200 const View* child_at(int index) const { |
199 DCHECK_GE(index, 0); | 201 DCHECK_GE(index, 0); |
200 DCHECK_LT(index, child_count()); | 202 DCHECK_LT(index, child_count()); |
201 return children_[index]; | 203 return children_[index]; |
202 } | 204 } |
203 View* child_at(int index) { | 205 View* child_at(int index) { |
204 return const_cast<View*>(const_cast<const View*>(this)->child_at(index)); | 206 return const_cast<View*>(const_cast<const View*>(this)->child_at(index)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 virtual bool IsDrawn() const; | 303 virtual bool IsDrawn() const; |
302 | 304 |
303 // Set whether this view is enabled. A disabled view does not receive keyboard | 305 // Set whether this view is enabled. A disabled view does not receive keyboard |
304 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint | 306 // or mouse inputs. If |enabled| differs from the current value, SchedulePaint |
305 // is invoked. Also, clears focus if the focused view is disabled. | 307 // is invoked. Also, clears focus if the focused view is disabled. |
306 void SetEnabled(bool enabled); | 308 void SetEnabled(bool enabled); |
307 | 309 |
308 // Returns whether the view is enabled. | 310 // Returns whether the view is enabled. |
309 bool enabled() const { return enabled_; } | 311 bool enabled() const { return enabled_; } |
310 | 312 |
| 313 // Returns the child views ordered in reverse z-order. That is, views later in |
| 314 // the returned vector have a higher z-order (are painted later) than those |
| 315 // early in the vector. The returned vector has exactly the same number of |
| 316 // Views as |children_|. The default implementation returns |children_|, |
| 317 // subclass if the paint order should differ from that of |children_|. |
| 318 // This order is taken into account by painting and targeting implementations. |
| 319 virtual View::Views GetChildrenInZOrder(); |
| 320 |
311 // Transformations ----------------------------------------------------------- | 321 // Transformations ----------------------------------------------------------- |
312 | 322 |
313 // Methods for setting transformations for a view (e.g. rotation, scaling). | 323 // Methods for setting transformations for a view (e.g. rotation, scaling). |
314 | 324 |
315 gfx::Transform GetTransform() const; | 325 gfx::Transform GetTransform() const; |
316 | 326 |
317 // Clipping is done relative to the view's local bounds. | 327 // Clipping is done relative to the view's local bounds. |
318 void set_clip_path(const gfx::Path& path) { clip_path_ = path; } | 328 void set_clip_path(const gfx::Path& path) { clip_path_ = path; } |
319 | 329 |
320 // Sets the transform to the supplied transform. | 330 // Sets the transform to the supplied transform. |
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 // Observers ------------------------------------------------------------- | 1601 // Observers ------------------------------------------------------------- |
1592 | 1602 |
1593 base::ObserverList<ViewObserver> observers_; | 1603 base::ObserverList<ViewObserver> observers_; |
1594 | 1604 |
1595 DISALLOW_COPY_AND_ASSIGN(View); | 1605 DISALLOW_COPY_AND_ASSIGN(View); |
1596 }; | 1606 }; |
1597 | 1607 |
1598 } // namespace views | 1608 } // namespace views |
1599 | 1609 |
1600 #endif // UI_VIEWS_VIEW_H_ | 1610 #endif // UI_VIEWS_VIEW_H_ |
OLD | NEW |