Index: views/view.h |
=================================================================== |
--- views/view.h (revision 86084) |
+++ views/view.h (working copy) |
@@ -184,23 +184,25 @@ |
View(); |
virtual ~View(); |
- // Set whether this view is owned by its parent. A view that is owned by its |
- // parent is automatically deleted when the parent is deleted. The default is |
- // true. Set to false if the view is owned by another object and should not |
- // be deleted by its parent. |
- void set_parent_owned(bool is_parent_owned) { |
- is_parent_owned_ = is_parent_owned; |
- } |
+ // By default a View is owned by its parent unless specified otherwise here. |
+ bool parent_owned() const { return parent_owned_; } |
+ void set_parent_owned(bool parent_owned) { parent_owned_ = parent_owned; } |
- // Return whether a view is owned by its parent. |
- bool IsParentOwned() const { return is_parent_owned_; } |
- |
// Tree operations ----------------------------------------------------------- |
// Get the Widget that hosts this View, if any. |
virtual const Widget* GetWidget() const; |
virtual Widget* GetWidget(); |
+ // Returns the containing Window. Although Window is a Widget subclass, this |
+ // function may not return the same value as GetWidget() above since this View |
+ // may be a child of a Widget nested within a Window. This function will |
+ // return the nearest containing Window in the Widget hierarchy. The View may |
+ // not be contained in a Window Widget, in which case this function will |
+ // return NULL. |
+ virtual const Window* GetWindow() const; |
+ virtual Window* GetWindow(); |
+ |
// Add a child View, optionally at |index|. |
void AddChildView(View* view); |
void AddChildViewAt(View* view, int index); |
@@ -232,14 +234,6 @@ |
// if the specified view is not a child of this view. |
int GetIndexOf(const View* view) const; |
- // TODO(beng): REMOVE (Views need not know about Window). |
- // Gets the Widget that most closely contains this View, if any. |
- // NOTE: almost all views displayed on screen have a Widget, but not |
- // necessarily a Window. This is due to widgets being able to create top |
- // level windows (as is done for popups, bubbles and menus). |
- virtual const Window* GetWindow() const; |
- virtual Window* GetWindow(); |
- |
// TODO(beng): REMOVE (TBD) |
// Returns true if the native view |native_view| is contained in the view |
// hierarchy beneath this view. |
@@ -297,6 +291,7 @@ |
// Returns the baseline of this view, or -1 if this view has no baseline. The |
// return value is relative to the preferred height. |
+ // TODO(beng): const |
virtual int GetBaseline(); |
// Get the size the View would like to be, if enough space were available. |
@@ -315,24 +310,6 @@ |
// as with Labels). |
virtual int GetHeightForWidth(int w); |
- // Set whether the receiving view is visible. Painting is scheduled as needed |
- virtual void SetVisible(bool flag); |
- |
- // Return whether a view is visible |
- virtual bool IsVisible() const; |
- |
- // Return whether a view and its ancestors are visible. Returns true if the |
- // path from this view to the root view is visible. |
- virtual bool IsVisibleInRootView() const; |
- |
- // Set whether this view is enabled. A disabled view does not receive keyboard |
- // or mouse inputs. If flag differs from the current value, SchedulePaint is |
- // invoked. |
- virtual void SetEnabled(bool flag); |
- |
- // Returns whether the view is enabled. |
- virtual bool IsEnabled() const; |
- |
// Transformations ----------------------------------------------------------- |
// Methods for setting transformations for a view (e.g. rotation, scaling). |
@@ -417,6 +394,26 @@ |
// Attributes ---------------------------------------------------------------- |
+ // If a View is not visible, it will not be painted, focusable, etc. |
+ bool visible() const { return visible_; } |
+ // TODO(beng): Should not be virtual. ExtensionView, AccessiblePaneView. |
+ virtual void SetVisible(bool flag); |
+ |
+ // Return whether a view and its ancestors are visible. Returns true if the |
+ // path from this view to the root view is visible. |
+ // TODO(beng): Consider replacing visible() with this, since it is a more |
+ // reliable test of View visibility. |
+ virtual bool IsVisibleInRootView() const; |
+ |
+ // Disabled Views will not receive mouse press or release events, and will not |
+ // be focused. |
+ // TODO(beng): This method should not be virtual and instead be a simple |
+ // accessor. |
+ virtual bool IsEnabled() const; |
+ // TODO(beng): This method should not be virtual. Those methods overriding |
+ // this should receive a state notification change instead. |
+ virtual void SetEnabled(bool enabled); |
+ |
// The view class name. |
static char kViewClassName[]; |
@@ -438,16 +435,15 @@ |
// Sets and gets the ID for this view. ID should be unique within the subtree |
// that you intend to search for it. 0 is the default ID for views. |
- void SetID(int id); |
- int GetID() const; |
+ int id() const { return id_; } |
+ void set_id(int id) { id_ = id; } |
- // A group id is used to tag views which are part of the same logical group. |
- // Focus can be moved between views with the same group using the arrow keys. |
- // Groups are currently used to implement radio button mutual exclusion. |
- // The group id is immutable once it's set. |
- void SetGroup(int gid); |
- // Returns the group id of the view, or -1 if the id is not set yet. |
- int GetGroup() const; |
+ // A group id is used to tag views which are part of the same logical control |
+ // group. Focus can be moved between views with the same group using the arrow |
+ // keys. Groups are currently used to implement radio button mutual exclusion. |
+ // The group id defaults to -1 for all Views and is immutable once set. |
+ int group() const { return group_; } |
+ void set_group(int group); |
// If this returns true, the views from the same group can each be focused |
// when moving focus with the Tab/Shift-Tab key. If this returns false, |
@@ -457,12 +453,12 @@ |
// Fills the provided vector with all the available views which belong to the |
// provided group. |
- void GetViewsWithGroup(int group_id, std::vector<View*>* out); |
+ void GetViewsInGroup(int group, std::vector<View*>* out); |
// Return the View that is currently selected in the specified group. |
// The default implementation simply returns the first View found for that |
// group. |
- virtual View* GetSelectedViewForGroup(int group_id); |
+ virtual View* GetSelectedViewForGroup(int group); |
// Coordinate conversion ----------------------------------------------------- |
@@ -723,7 +719,7 @@ |
// Sets whether this view can accept the focus. |
// Note that this is false by default so that a view used as a container does |
// not get the focus. |
- virtual void SetFocusable(bool focusable); |
+ void set_focusable(bool focusable) { focusable_ = focusable; } |
// Returns true if the view is focusable (IsFocusable) and visible in the root |
// view. See also IsFocusable. |
@@ -1165,10 +1161,6 @@ |
bool update_tool_tip, |
bool delete_removed_view); |
- // Sets the parent View. This is called automatically by AddChild and is |
- // thus private. |
- void SetParent(View* parent); |
- |
// Call ViewHierarchyChanged for all child views on all parents |
void PropagateRemoveNotifications(View* parent); |
@@ -1323,7 +1315,7 @@ |
// Creation and lifetime ----------------------------------------------------- |
// Whether this view is owned by its parent. |
- bool is_parent_owned_; |
+ bool parent_owned_; |
// Tree operations ----------------------------------------------------------- |
@@ -1340,7 +1332,7 @@ |
gfx::Rect bounds_; |
// Visible state |
- bool is_visible_; |
+ bool visible_; |
// Whether or not RegisterViewForVisibleBoundsNotification on the RootView |
// has been invoked. |