| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class FocusTraversable; | 32 class FocusTraversable; |
| 33 class KeyEvent; | 33 class KeyEvent; |
| 34 class LayoutManager; | 34 class LayoutManager; |
| 35 class MouseEvent; | 35 class MouseEvent; |
| 36 class MouseWheelEvent; | 36 class MouseWheelEvent; |
| 37 class OSExchangeData; | 37 class OSExchangeData; |
| 38 class ThemeProvider; | 38 class ThemeProvider; |
| 39 class Widget; | 39 class Widget; |
| 40 | 40 |
| 41 //////////////////////////////////////////////////////////////////////////////// | 41 //////////////////////////////////////////////////////////////////////////////// |
| 42 // View class | 42 // View |
| 43 // | 43 // |
| 44 // View encapsulates rendering, layout and event handling for rectangles within | 44 // View encapsulates rendering, layout and event handling for rectangles within |
| 45 // a view hierarchy. | 45 // a view hierarchy. |
| 46 // | 46 // |
| 47 // Client code typically subclasses View and overrides virtual methods to | 47 // Client code typically subclasses View and overrides virtual methods to |
| 48 // handle painting, child view positioning and handle certain types of events. | 48 // handle painting, child view positioning and handle certain types of events. |
| 49 // | 49 // |
| 50 // Views are owned by their parent View unless specified otherwise. This means | 50 // Views are owned by their parent View unless specified otherwise. This means |
| 51 // that in most cases Views are automatically destroyed when the window that | 51 // that in most cases Views are automatically destroyed when the window that |
| 52 // contains them is destroyed. | 52 // contains them is destroyed. |
| 53 // | 53 // |
| 54 // TODO(beng): consider the visibility of many of these methods. | 54 // TODO(beng): consider the visibility of many of these methods. |
| 55 // consider making RootView a friend and making many private or | 55 // consider making RootView a friend and making many private or |
| 56 // protected. | 56 // protected. |
| 57 |
| 57 class View { | 58 class View { |
| 58 public: | 59 public: |
| 59 typedef std::vector<View*> ViewVector; | 60 typedef std::vector<View*> Views; |
| 60 | 61 |
| 61 // Creation and lifetime ----------------------------------------------------- | 62 // Creation and lifetime ----------------------------------------------------- |
| 62 View(); | 63 View(); |
| 63 virtual ~View(); | 64 virtual ~View(); |
| 64 | 65 |
| 65 // By default a View is owned by its parent unless specified otherwise here. | 66 // By default a View is owned by its parent unless specified otherwise here. |
| 66 bool parent_owned() const { return parent_owned_; } | 67 bool parent_owned() const { return parent_owned_; } |
| 67 void set_parent_owned(bool parent_owned) { parent_owned_ = parent_owned; } | 68 void set_parent_owned(bool parent_owned) { parent_owned_ = parent_owned; } |
| 68 | 69 |
| 69 void set_drag_controller(DragController* drag_controller) { | 70 void set_drag_controller(DragController* drag_controller) { |
| 70 drag_controller_ = drag_controller; | 71 drag_controller_ = drag_controller; |
| 71 } | 72 } |
| 72 | 73 |
| 73 // Size and disposition ------------------------------------------------------ | 74 // Size and disposition ------------------------------------------------------ |
| 74 | 75 |
| 75 void SetBounds(int x, int y, int width, int height); | |
| 76 void SetBoundsRect(const gfx::Rect& bounds); | |
| 77 void SetSize(const gfx::Size& size); | |
| 78 void SetPosition(const gfx::Point& position); | |
| 79 gfx::Rect bounds() const { return bounds_; } | 76 gfx::Rect bounds() const { return bounds_; } |
| 77 // Returns the portion of this view's bounds that are visible (i.e. not |
| 78 // clipped) in the RootView. |
| 80 gfx::Rect GetVisibleBounds() const; | 79 gfx::Rect GetVisibleBounds() const; |
| 81 int x() const { return bounds_.x(); } | |
| 82 int y() const { return bounds_.y(); } | |
| 83 int width() const { return bounds_.width(); } | |
| 84 int height() const { return bounds_.height(); } | |
| 85 | |
| 86 // Owned by the view. | |
| 87 void SetBorder(Border* border); | |
| 88 Border* border() { return border_.get(); } | |
| 89 | |
| 90 // Returns the bounds of the content area of the view, i.e. the rectangle | 80 // Returns the bounds of the content area of the view, i.e. the rectangle |
| 91 // enclosed by the view's border. | 81 // enclosed by the view's border. |
| 92 gfx::Rect GetContentsBounds() const; | 82 gfx::Rect GetContentsBounds() const; |
| 83 void SetBounds(const gfx::Rect& bounds); |
| 84 |
| 85 gfx::Point origin() const { return bounds().origin(); } |
| 86 int x() const { return bounds().x(); } |
| 87 int y() const { return bounds().y(); } |
| 88 void SetOrigin(const gfx::Point& origin); |
| 89 |
| 90 gfx::Size size() const { return bounds().size(); } |
| 91 int width() const { return bounds().width(); } |
| 92 int height() const { return bounds().height(); } |
| 93 void SetSize(const gfx::Size& size); |
| 94 |
| 95 // Owned by the view. |
| 96 Border* border() { return border_.get(); } |
| 97 void SetBorder(Border* border); |
| 93 | 98 |
| 94 // Override to be notified when the bounds of a view have changed. | 99 // Override to be notified when the bounds of a view have changed. |
| 95 virtual void OnBoundsChanged(); | 100 virtual void OnBoundsChanged(); |
| 96 | 101 |
| 97 virtual gfx::Size GetPreferredSize() const; | 102 virtual gfx::Size GetPreferredSize() const; |
| 98 virtual gfx::Size GetMinimumSize() const; | 103 virtual gfx::Size GetMinimumSize() const; |
| 99 | 104 |
| 100 void SetLayoutManager(LayoutManager* layout_manager); | 105 void SetLayoutManager(LayoutManager* layout_manager); |
| 101 virtual void Layout(); | 106 virtual void Layout(); |
| 102 | 107 |
| 103 // If a View is not visible, it will not be rendered, focused, etc. | 108 // If a View is not visible, it will not be rendered, focused, etc. |
| 104 bool visible() const { return visible_; } | 109 bool visible() const { return visible_; } |
| 105 void SetVisible(bool visible); | 110 void SetVisible(bool visible); |
| 106 | 111 |
| 107 // Disabled Views will not receive mouse press/release events, nor can they be | 112 // Disabled Views will not receive mouse press/release events, nor can they be |
| 108 // focused. | 113 // focused. |
| 109 bool enabled() const { return enabled_; } | 114 bool enabled() const { return enabled_; } |
| 110 void SetEnabled(bool enabled); | 115 void SetEnabled(bool enabled); |
| 111 | 116 |
| 112 // Attributes ---------------------------------------------------------------- | 117 // Attributes ---------------------------------------------------------------- |
| 113 | 118 |
| 114 int id() const { return id_; } | 119 int id() const { return id_; } |
| 115 void set_id(int id) { id_ = id; } | 120 void set_id(int id) { id_ = id; } |
| 116 int group() const { return group_; } | 121 int group() const { return group_; } |
| 117 void set_group(int group) { group_ = group; } | 122 void set_group(int group) { group_ = group; } |
| 118 | 123 |
| 119 // Returns the View within this View's hierarchy whose id matches that | 124 // Returns the View within this View's hierarchy whose id matches that |
| 120 // specified. | 125 // specified. |
| 121 View* GetViewById(int id) const; | 126 View* GetViewByID(int id); |
| 122 | 127 |
| 123 // Populates a ViewVector with the Views within this View's hierarchy that | 128 // Populates |vec| with the Views within this View's hierarchy that match the |
| 124 // match the specified group id. | 129 // specified group id. |
| 125 void GetViewsWithGroup(int group, ViewVector* vec) const; | 130 void GetViewsInGroup(int group, Views* vec); |
| 126 | 131 |
| 127 // TODO(beng): implementme | 132 // TODO(beng): implementme |
| 128 virtual View* GetSelectedViewForGroup(int group_id); | 133 virtual View* GetSelectedViewForGroup(int group_id); |
| 129 | 134 |
| 130 // Coordinate conversion ----------------------------------------------------- | 135 // Coordinate conversion ----------------------------------------------------- |
| 131 | 136 |
| 132 // Converts a point from the coordinate system of |source| to |target|. | 137 // Converts a point from the coordinate system of |source| to |target|. |
| 133 static void ConvertPointToView(View* source, View* target, gfx::Point* point); | 138 static void ConvertPointToView(const View& source, |
| 139 const View& target, |
| 140 gfx::Point* point); |
| 134 | 141 |
| 135 // Converts a point from the coordinate system of |source| to the screen. | 142 // Converts a point from the coordinate system of |source| to the screen. |
| 136 // If |source| is not attached to a Widget that is in screen space, |point| is | 143 // If |source| is not attached to a Widget that is in screen space, |point| is |
| 137 // not modified. | 144 // not modified. |
| 138 static void ConvertPointToScreen(View* source, gfx::Point* point); | 145 static void ConvertPointToScreen(const View& source, gfx::Point* point); |
| 139 | 146 |
| 140 // Converts a point from the coordinate system of |source| to the Widget that | 147 // Converts a point from the coordinate system of |source| to the Widget that |
| 141 // most closely contains it. | 148 // most closely contains it. |
| 142 static void ConvertPointToWidget(View* source, gfx::Point* point); | 149 static void ConvertPointToWidget(const View& source, gfx::Point* point); |
| 143 | 150 |
| 144 // Tree operations ----------------------------------------------------------- | 151 // Tree operations ----------------------------------------------------------- |
| 145 | 152 |
| 146 // Returns the Widget that contains this View, or NULL if it is not contained | 153 // Returns the Widget that contains this View, or NULL if it is not contained |
| 147 // within a Widget. | 154 // within a Widget. |
| 148 virtual Widget* GetWidget() const; | 155 Widget* GetWidget() { |
| 156 return const_cast<Widget*>(static_cast<const View*>(this)->GetWidget()); |
| 157 } |
| 158 virtual const Widget* GetWidget() const; |
| 149 | 159 |
| 150 // Adds a View as a child of this one, optionally at |index|. | 160 // Adds a View as a child of this one, optionally at |index|. |
| 151 void AddChildView(View* view); | 161 void AddChildView(View* view); |
| 152 void AddChildViewAt(View* view, size_t index); | 162 void AddChildViewAt(View* view, size_t index); |
| 153 | 163 |
| 154 // Removes a View as a child of this View. Does not delete the child. | 164 // If |view| is a child of this View, removes it and optionally deletes it. |
| 155 View* RemoveChildView(View* view); | 165 void RemoveChildView(View* view, bool delete_child); |
| 156 | 166 |
| 157 // Removes all View children of this View. Deletes the children if | 167 // Removes all View children of this View. Deletes the children if |
| 158 // |delete_children| is true. | 168 // |delete_children| is true. |
| 159 void RemoveAllChildViews(bool delete_children); | 169 void RemoveAllChildViews(bool delete_children); |
| 160 | 170 |
| 161 // Returns the View at the specified |index|. | 171 // STL-style accessors. |
| 162 View* GetChildViewAt(size_t index); | 172 Views::const_iterator children_begin() { return children_.begin(); } |
| 163 | 173 Views::const_iterator children_end() { return children_.end(); } |
| 164 // Returns the number of child views. | 174 Views::const_reverse_iterator children_rbegin() { return children_.rbegin(); } |
| 165 size_t child_count() const { return children_.size(); } | 175 Views::const_reverse_iterator children_rend() { return children_.rend(); } |
| 176 size_t children_size() const { return children_.size(); } |
| 177 bool children_empty() const { return children_.empty(); } |
| 178 View* child_at(size_t index) { |
| 179 DCHECK_LT(index, children_size()); |
| 180 return children_[index]; |
| 181 } |
| 166 | 182 |
| 167 // Returns the parent View, or NULL if this View has no parent. | 183 // Returns the parent View, or NULL if this View has no parent. |
| 168 View* parent() const { return parent_; } | 184 View* parent() { return parent_; } |
| 185 const View* parent() const { return parent_; } |
| 169 | 186 |
| 170 // Returns true if |child| is contained within this View's hierarchy, even as | 187 // Returns true if |child| is contained within this View's hierarchy, even as |
| 171 // an indirect descendant. Will return true if child is also this View. | 188 // an indirect descendant. Will return true if child is also this View. |
| 172 bool Contains(View* child); | 189 bool Contains(const View& child) const; |
| 173 | 190 |
| 174 // Painting ------------------------------------------------------------------ | 191 // Painting ------------------------------------------------------------------ |
| 175 | 192 |
| 176 // Add all or part of a View's bounds to the enclosing Widget's invalid | 193 // Add all or part of a View's bounds to the enclosing Widget's invalid |
| 177 // rectangle. This will result in those areas being re-painted on the next | 194 // rectangle. This will result in those areas being re-painted on the next |
| 178 // update. | 195 // update. |
| 179 void Invalidate(); | 196 void Invalidate(); |
| 180 virtual void InvalidateRect(const gfx::Rect& invalid_rect); | 197 virtual void InvalidateRect(const gfx::Rect& invalid_rect); |
| 181 | 198 |
| 182 // Input --------------------------------------------------------------------- | 199 // Input --------------------------------------------------------------------- |
| 183 | 200 |
| 184 // Returns true if the specified point is contained within this View or its | 201 // Returns true if the specified point is contained within this View or its |
| 185 // hit test mask. |point| is in this View's coordinates. | 202 // hit test mask. |point| is in this View's coordinates. |
| 186 bool HitTest(const gfx::Point& point) const; | 203 bool HitTest(const gfx::Point& point) const; |
| 187 | 204 |
| 188 // Accelerators -------------------------------------------------------------- | 205 // Accelerators -------------------------------------------------------------- |
| 189 | 206 |
| 190 // Accelerator Registration. | 207 // Accelerator Registration. |
| 191 void AddAccelerator(const Accelerator& accelerator); | 208 void AddAccelerator(const Accelerator& accelerator); |
| 192 void RemoveAccelerator(const Accelerator& accelerator); | 209 void RemoveAccelerator(const Accelerator& accelerator); |
| 193 void RemoveAllAccelerators(); | 210 void RemoveAllAccelerators(); |
| 194 | 211 |
| 195 // Focus --------------------------------------------------------------------- | 212 // Focus --------------------------------------------------------------------- |
| 196 | 213 |
| 197 // Manager. | 214 // Manager. |
| 198 FocusManager* GetFocusManager() const; | 215 FocusManager* GetFocusManager(); |
| 216 const FocusManager* GetFocusManager() const; |
| 199 | 217 |
| 200 // Traversal. | 218 // Traversal. |
| 201 virtual FocusTraversable* GetFocusTraversable() const; | 219 virtual FocusTraversable* GetFocusTraversable(); |
| 202 View* GetNextFocusableView() const; | 220 View* GetNextFocusableView(); |
| 203 View* GetPreviousFocusableView() const; | 221 View* GetPreviousFocusableView(); |
| 204 | 222 |
| 205 // Attributes. | 223 // Attributes. |
| 224 bool IsFocusable() const; |
| 206 void set_focusable(bool focusable) { focusable_ = focusable; } | 225 void set_focusable(bool focusable) { focusable_ = focusable; } |
| 207 bool IsFocusable() const; | |
| 208 | 226 |
| 209 bool HasFocus() const; | 227 bool HasFocus() const; |
| 210 void RequestFocus(); | 228 void RequestFocus(); |
| 211 | 229 |
| 212 // Context menus ------------------------------------------------------------- | 230 // Context menus ------------------------------------------------------------- |
| 213 | 231 |
| 214 void set_context_menu_controller( | 232 void set_context_menu_controller( |
| 215 ContextMenuController* context_menu_controller) { | 233 ContextMenuController* context_menu_controller) { |
| 216 context_menu_controller_ = context_menu_controller; | 234 context_menu_controller_ = context_menu_controller; |
| 217 } | 235 } |
| 218 | 236 |
| 219 // Resources ----------------------------------------------------------------- | 237 // Resources ----------------------------------------------------------------- |
| 220 | 238 |
| 221 ThemeProvider* GetThemeProvider() const; | 239 ThemeProvider* GetThemeProvider(); |
| 222 | 240 |
| 223 protected: | 241 protected: |
| 224 // Tree operations ----------------------------------------------------------- | 242 // Tree operations ----------------------------------------------------------- |
| 225 | 243 |
| 226 // Called on every view in the hierarchy when a view is added or removed. | 244 // Called on every view in |parent|'s and |child|'s hierarchies, as well as |
| 227 virtual void OnViewAdded(View* parent, View* child); | 245 // ancestors, when |child| is added to or removed from |parent|. |
| 228 virtual void OnViewRemoved(View* parent, View* child); | 246 virtual void OnViewAdded(const View& parent, const View& child); |
| 247 virtual void OnViewRemoved(const View& parent, const View& child); |
| 229 | 248 |
| 230 // Called on a View when it is added or removed from a Widget. | 249 // Called on a View when it is part of a hierarchy that has been added to or |
| 250 // removed from a Widget. |
| 231 virtual void OnViewAddedToWidget(); | 251 virtual void OnViewAddedToWidget(); |
| 232 virtual void OnViewRemovedFromWidget(); | 252 virtual void OnViewRemovedFromWidget(); |
| 233 | 253 |
| 234 // Painting ------------------------------------------------------------------ | 254 // Painting ------------------------------------------------------------------ |
| 235 | 255 |
| 236 // Responsible for calling Paint() on child Views. Override to control the | 256 // Responsible for calling Paint() on child Views. Override to control the |
| 237 // order child Views are painted. | 257 // order child Views are painted. |
| 238 virtual void PaintChildren(gfx::Canvas* canvas); | 258 virtual void PaintChildren(gfx::Canvas* canvas); |
| 239 | 259 |
| 240 // Override to provide rendering in any part of the View's bounds. Typically | 260 // Override to provide rendering in any part of the View's bounds. Typically |
| (...skipping 14 matching lines...) Expand all Loading... |
| 255 virtual void OnPaintFocusBorder(gfx::Canvas* canvas); | 275 virtual void OnPaintFocusBorder(gfx::Canvas* canvas); |
| 256 | 276 |
| 257 // Input --------------------------------------------------------------------- | 277 // Input --------------------------------------------------------------------- |
| 258 | 278 |
| 259 // Returns the visible View that would like to handle events occurring at the | 279 // Returns the visible View that would like to handle events occurring at the |
| 260 // specified |point|, in this View's coordinates. | 280 // specified |point|, in this View's coordinates. |
| 261 // This function is used by the event processing system in the Widget to | 281 // This function is used by the event processing system in the Widget to |
| 262 // locate views for event targeting. Override this function if you wish to | 282 // locate views for event targeting. Override this function if you wish to |
| 263 // specify a view other than the one most closely enclosing |point| to receive | 283 // specify a view other than the one most closely enclosing |point| to receive |
| 264 // notifications for events within it. | 284 // notifications for events within it. |
| 265 virtual View* GetEventHandlerForPoint(const gfx::Point& point) const; | 285 virtual View* GetEventHandlerForPoint(const gfx::Point& point); |
| 266 | 286 |
| 267 virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point); | 287 virtual gfx::NativeCursor GetCursorForPoint(const gfx::Point& point) const; |
| 268 | 288 |
| 269 virtual bool OnKeyPressed(const KeyEvent& event); | 289 virtual bool OnKeyPressed(const KeyEvent& event); |
| 270 virtual bool OnKeyReleased(const KeyEvent& event); | 290 virtual bool OnKeyReleased(const KeyEvent& event); |
| 271 virtual bool OnMouseWheel(const MouseWheelEvent& event); | 291 virtual bool OnMouseWheel(const MouseWheelEvent& event); |
| 272 // To receive OnMouseDragged() or OnMouseReleased() events, overriding classes | 292 // To receive OnMouseDragged() or OnMouseReleased() events, overriding classes |
| 273 // must return true from this function. | 293 // must return true from this function. |
| 274 virtual bool OnMousePressed(const MouseEvent& event); | 294 virtual bool OnMousePressed(const MouseEvent& event); |
| 275 virtual bool OnMouseDragged(const MouseEvent& event); | 295 virtual bool OnMouseDragged(const MouseEvent& event); |
| 276 virtual void OnMouseReleased(const MouseEvent& event); | 296 virtual void OnMouseReleased(const MouseEvent& event); |
| 277 virtual void OnMouseCaptureLost(); | 297 virtual void OnMouseCaptureLost(); |
| 278 virtual void OnMouseMoved(const MouseEvent& event); | 298 virtual void OnMouseMoved(const MouseEvent& event); |
| 279 virtual void OnMouseEntered(const MouseEvent& event); | 299 virtual void OnMouseEntered(const MouseEvent& event); |
| 280 virtual void OnMouseExited(const MouseEvent& event); | 300 virtual void OnMouseExited(const MouseEvent& event); |
| 281 | 301 |
| 282 // Accelerators -------------------------------------------------------------- | 302 // Accelerators -------------------------------------------------------------- |
| 283 | 303 |
| 284 virtual bool OnAcceleratorPressed(const Accelerator& accelerator); | 304 virtual bool OnAcceleratorPressed(const Accelerator& accelerator); |
| 285 | 305 |
| 286 // Focus --------------------------------------------------------------------- | 306 // Focus --------------------------------------------------------------------- |
| 287 | 307 |
| 288 virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& event) const; | 308 virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& event) const; |
| 289 virtual bool IsGroupFocusTraversable() const; | 309 virtual bool IsGroupFocusTraversable() const; |
| 290 // TODO(beng): kill these, move to focus manager. | 310 // TODO(beng): kill these, move to focus manager. |
| 291 virtual bool IsFocusableInRootView() const; | 311 virtual bool IsFocusableInRootView() const; |
| 292 virtual bool IsAccessibilityFocusableInRootView() const; | 312 virtual bool IsAccessibilityFocusableInRootView() const; |
| 293 virtual FocusTraversable* GetPaneFocusTraversable() const; | 313 virtual FocusTraversable* GetPaneFocusTraversable(); |
| 294 | 314 |
| 295 virtual void OnFocus(const FocusEvent& event); | 315 virtual void OnFocus(const FocusEvent& event); |
| 296 virtual void OnBlur(const FocusEvent& event); | 316 virtual void OnBlur(const FocusEvent& event); |
| 297 | 317 |
| 298 private: | 318 private: |
| 299 friend internal::RootView; | 319 friend internal::RootView; |
| 300 friend class FocusManager; | 320 friend class FocusManager; |
| 301 friend class FocusSearch; | 321 friend class FocusSearch; |
| 302 | 322 |
| 303 // State collected during a MousePressed event to detect possible drag | 323 // State collected during a MousePressed event to detect possible drag |
| 304 // operations. | 324 // operations. |
| 305 struct DragInfo { | 325 struct DragInfo { |
| 306 // Sets possible_drag to false and start_x/y to 0. This is invoked by | 326 // Sets possible_drag to false and start_x/y to 0. This is invoked by |
| 307 // RootView prior to invoke MousePressed(). | 327 // RootView prior to invoke MousePressed(). |
| 308 void Reset(); | 328 void Reset(); |
| 309 | 329 |
| 310 // Sets possible_drag to true and start_pt to the specified point. | 330 // Sets possible_drag to true and start_pt to the specified point. |
| 311 // This is invoked by the target view if it detects the press may generate | 331 // This is invoked by the target view if it detects the press may generate |
| 312 // a drag. | 332 // a drag. |
| 313 void PossibleDrag(const gfx::Point& point); | 333 void PossibleDrag(const gfx::Point& point); |
| 314 | 334 |
| 315 // Whether the press may generate a drag. | 335 // Whether the press may generate a drag. |
| 316 bool possible_drag; | 336 bool possible_drag; |
| 317 | 337 |
| 318 // Position of the mouse press in screen coordinates. | 338 // Position of the mouse press in screen coordinates. |
| 319 gfx::Point press_point; | 339 gfx::Point press_point; |
| 320 }; | 340 }; |
| 321 | 341 |
| 322 // Tree operations ----------------------------------------------------------- | 342 // Tree operations ----------------------------------------------------------- |
| 323 void NotifyHierarchyChanged(View* parent, View* child, bool is_add); | 343 |
| 324 void NotifyHierarchyChangedUp(View* parent, View* child, bool is_add); | 344 // Notifies all views in our and |child|'s hierarchies, as well as ancestors, |
| 325 void NotifyHierarchyChangedDown(View* parent, View* child, bool is_add, | 345 // that |child| was added to or removed from |this|. |
| 346 void NotifyHierarchyChanged(View* child, bool is_add); |
| 347 |
| 348 // Notifies all views in our hierarchy that |child| was added to or removed |
| 349 // from |this|. |has_widget| is true iff |this| is in a widget. |
| 350 void NotifyHierarchyChangedDown(const View& child, |
| 351 bool is_add, |
| 326 bool has_widget); | 352 bool has_widget); |
| 353 |
| 354 // Notifies |target| that |child| was added to or removed from |this|. |
| 355 // |has_widget| is true iff |this| is in a widget. |
| 327 void CallViewNotification(View* target, | 356 void CallViewNotification(View* target, |
| 328 View* parent, | 357 const View& child, |
| 329 View* child, | |
| 330 bool is_add, | 358 bool is_add, |
| 331 bool has_widget); | 359 bool has_widget); |
| 332 | 360 |
| 333 // Painting ------------------------------------------------------------------ | 361 // Painting ------------------------------------------------------------------ |
| 334 | 362 |
| 335 // Called by the framework to paint a View. Performs translation and clipping | 363 // Called by the framework to paint a View. Performs translation and clipping |
| 336 // for View coordinates and language direction as required, allows the View | 364 // for View coordinates and language direction as required, allows the View |
| 337 // to paint itself via the various OnPaint*() event handlers and then paints | 365 // to paint itself via the various OnPaint*() event handlers and then paints |
| 338 // the hierarchy beneath it. | 366 // the hierarchy beneath it. |
| 339 void Paint(gfx::Canvas* canvas); | 367 void Paint(gfx::Canvas* canvas); |
| 340 | 368 |
| 341 // Input -------------------------------------------------------------- | 369 // Input --------------------------------------------------------------------- |
| 370 |
| 342 // These methods are designed to be called by the RootView. The RootView | 371 // These methods are designed to be called by the RootView. The RootView |
| 343 // should limit its interaction with the View to these methods and the public | 372 // should limit its interaction with the View to these methods and the public |
| 344 // API. | 373 // API. |
| 345 bool MousePressed(const MouseEvent& event, DragInfo* drag_info); | 374 bool MousePressed(const MouseEvent& event, DragInfo* drag_info); |
| 346 bool MouseDragged(const MouseEvent& event, DragInfo* drag_info); | 375 bool MouseDragged(const MouseEvent& event, DragInfo* drag_info); |
| 347 void MouseReleased(const MouseEvent& event); | 376 void MouseReleased(const MouseEvent& event); |
| 348 | 377 |
| 349 // Focus --------------------------------------------------------------------- | 378 // Focus --------------------------------------------------------------------- |
| 350 | 379 |
| 351 // Called when |child| is inserted into this View's children_ at |index|. | 380 // Called when |child| is inserted into this View's children_ at |index|. |
| 352 // Sets up next/previous focus views | 381 // Sets up next/previous focus views |
| 353 // TODO(beng): Move this to FocusManager. | 382 // TODO(beng): Move this to FocusManager. |
| 354 void InitFocusSiblings(View* child, size_t index); | 383 void InitFocusSiblings(View* child, size_t index); |
| 355 | 384 |
| 356 // Drag & Drop --------------------------------------------------------------- | 385 // Drag & Drop --------------------------------------------------------------- |
| 386 |
| 357 int GetDragOperations(const gfx::Point& point); | 387 int GetDragOperations(const gfx::Point& point); |
| 358 void WriteDragData(const gfx::Point& point, OSExchangeData* data); | 388 void WriteDragData(const gfx::Point& point, OSExchangeData* data); |
| 359 void StartShellDrag(const MouseEvent& event, const gfx::Point& press_point); | 389 void StartShellDrag(const MouseEvent& event, const gfx::Point& press_point); |
| 360 | 390 |
| 361 ////////////////////////////////////////////////////////////////////////////// | 391 ////////////////////////////////////////////////////////////////////////////// |
| 362 | 392 |
| 363 // Creation and lifetime ----------------------------------------------------- | 393 // Creation and lifetime ----------------------------------------------------- |
| 364 | 394 |
| 365 // True if the hierarchy (i.e. the parent View) is responsible for deleting | 395 // True if the hierarchy (i.e. the parent View) is responsible for deleting |
| 366 // this View. Default is true. | 396 // this View. Default is true. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 392 // An identifier for a group of potentially related Views. | 422 // An identifier for a group of potentially related Views. |
| 393 int group_; | 423 int group_; |
| 394 | 424 |
| 395 // Tree operations ----------------------------------------------------------- | 425 // Tree operations ----------------------------------------------------------- |
| 396 | 426 |
| 397 // The View's parent view. This is set and reset when the View is added and | 427 // The View's parent view. This is set and reset when the View is added and |
| 398 // removed from a hierarchy. | 428 // removed from a hierarchy. |
| 399 View* parent_; | 429 View* parent_; |
| 400 | 430 |
| 401 // The View's children. | 431 // The View's children. |
| 402 ViewVector children_; | 432 Views children_; |
| 403 | 433 |
| 404 // Focus --------------------------------------------------------------------- | 434 // Focus --------------------------------------------------------------------- |
| 405 | 435 |
| 406 // True if this View is focusable by the FocusManager. | 436 // True if this View is focusable by the FocusManager. |
| 407 bool focusable_; | 437 bool focusable_; |
| 408 | 438 |
| 409 // Focus siblings for this View. | 439 // Focus siblings for this View. |
| 410 View* next_focusable_view_; | 440 View* next_focusable_view_; |
| 411 View* prev_focusable_view_; | 441 View* prev_focusable_view_; |
| 412 | 442 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 437 - rtl | 467 - rtl |
| 438 - l10n | 468 - l10n |
| 439 - mousewheel | 469 - mousewheel |
| 440 - more on painting | 470 - more on painting |
| 441 - layer stuff | 471 - layer stuff |
| 442 - investigate why assorted notifications are necessary | 472 - investigate why assorted notifications are necessary |
| 443 - native_widget_views | 473 - native_widget_views |
| 444 - native_widget_gtk | 474 - native_widget_gtk |
| 445 | 475 |
| 446 */ | 476 */ |
| OLD | NEW |