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 VIEWS_WINDOW_CLIENT_VIEW_H_ | 5 #ifndef VIEWS_WINDOW_CLIENT_VIEW_H_ |
6 #define VIEWS_WINDOW_CLIENT_VIEW_H_ | 6 #define VIEWS_WINDOW_CLIENT_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "views/view.h" | 9 #include "views/view.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 | 12 |
13 class DialogClientView; | 13 class DialogClientView; |
14 class Window; | 14 class Widget; |
15 | 15 |
16 /////////////////////////////////////////////////////////////////////////////// | 16 /////////////////////////////////////////////////////////////////////////////// |
17 // ClientView | 17 // ClientView |
18 // | 18 // |
19 // A ClientView is a View subclass that is used to occupy the "client area" | 19 // A ClientView is a View subclass that is used to occupy the "client area" |
20 // of a window. It provides basic information to the window that contains it | 20 // of a widget. It provides basic information to the widget that contains it |
21 // such as non-client hit testing information, sizing etc. Sub-classes of | 21 // such as non-client hit testing information, sizing etc. Sub-classes of |
22 // ClientView are used to create more elaborate contents, e.g. | 22 // ClientView are used to create more elaborate contents, e.g. |
23 // "DialogClientView". | 23 // "DialogClientView". |
24 class ClientView : public View { | 24 class ClientView : public View { |
25 public: | 25 public: |
26 // Internal class name | 26 // Internal class name |
27 static const char kViewClassName[]; | 27 static const char kViewClassName[]; |
28 | 28 |
29 // Constructs a ClientView object for the specified window with the specified | 29 // Constructs a ClientView object for the specified widget with the specified |
30 // contents. Since this object is created during the process of creating | 30 // contents. Since this object is created during the process of creating |
31 // |window|, |contents_view| must be valid if you want the initial size of | 31 // |widget|, |contents_view| must be valid if you want the initial size of |
32 // the window to be based on |contents_view|'s preferred size. | 32 // the widget to be based on |contents_view|'s preferred size. |
33 ClientView(Window* window, View* contents_view); | 33 ClientView(Widget* widget, View* contents_view); |
34 virtual ~ClientView() {} | 34 virtual ~ClientView() {} |
35 | 35 |
36 // Manual RTTI ftw. | 36 // Manual RTTI ftw. |
37 virtual DialogClientView* AsDialogClientView(); | 37 virtual DialogClientView* AsDialogClientView(); |
38 | 38 |
39 // Returns true to signal that the Window can be closed. Specialized | 39 // Returns true to signal that the Widget can be closed. Specialized |
40 // ClientView subclasses can override this default behavior to allow the | 40 // ClientView subclasses can override this default behavior to allow the |
41 // close to be blocked until the user corrects mistakes, accepts a warning | 41 // close to be blocked until the user corrects mistakes, accepts a warning |
42 // dialog, etc. | 42 // dialog, etc. |
43 virtual bool CanClose(); | 43 virtual bool CanClose(); |
44 | 44 |
45 // Notification that the window is closing. The default implementation | 45 // Notification that the widget is closing. The default implementation |
46 // forwards the notification to the delegate. | 46 // forwards the notification to the delegate. |
47 virtual void WindowClosing(); | 47 virtual void WidgetClosing(); |
48 | 48 |
49 // Tests to see if the specified point (in view coordinates) is within the | 49 // Tests to see if the specified point (in view coordinates) is within the |
50 // bounds of this view. If so, it returns HTCLIENT in this default | 50 // bounds of this view. If so, it returns HTCLIENT in this default |
51 // implementation. If it is outside the bounds of this view, this must return | 51 // implementation. If it is outside the bounds of this view, this must return |
52 // HTNOWHERE to tell the caller to do further processing to determine where | 52 // HTNOWHERE to tell the caller to do further processing to determine where |
53 // in the non-client area it is (if it is). | 53 // in the non-client area it is (if it is). |
54 // Subclasses of ClientView can extend this logic by overriding this method | 54 // Subclasses of ClientView can extend this logic by overriding this method |
55 // to detect if regions within the client area count as parts of the "non- | 55 // to detect if regions within the client area count as parts of the "non- |
56 // client" area. A good example of this is the size box at the bottom right | 56 // client" area. A good example of this is the size box at the bottom right |
57 // corner of resizable dialog boxes. | 57 // corner of resizable dialog boxes. |
58 virtual int NonClientHitTest(const gfx::Point& point); | 58 virtual int NonClientHitTest(const gfx::Point& point); |
59 | 59 |
60 // Overridden from View: | 60 // Overridden from View: |
61 virtual gfx::Size GetPreferredSize() OVERRIDE; | 61 virtual gfx::Size GetPreferredSize() OVERRIDE; |
62 virtual void Layout() OVERRIDE; | 62 virtual void Layout() OVERRIDE; |
63 virtual std::string GetClassName() const OVERRIDE; | 63 virtual std::string GetClassName() const OVERRIDE; |
64 | 64 |
65 protected: | 65 protected: |
66 // Overridden from View: | 66 // Overridden from View: |
67 virtual void ViewHierarchyChanged( | 67 virtual void ViewHierarchyChanged( |
68 bool is_add, View* parent, View* child) OVERRIDE; | 68 bool is_add, View* parent, View* child) OVERRIDE; |
69 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 69 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
70 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 70 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
71 | 71 |
72 // Accessors for private data members. | 72 // Accessors for private data members. |
73 Window* window() const { return window_; } | |
74 void set_window(Window* window) { window_ = window; } | |
75 View* contents_view() const { return contents_view_; } | 73 View* contents_view() const { return contents_view_; } |
76 void set_contents_view(View* contents_view) { | 74 void set_contents_view(View* contents_view) { |
77 contents_view_ = contents_view; | 75 contents_view_ = contents_view; |
78 } | 76 } |
79 | 77 |
80 private: | 78 private: |
81 // The Window that hosts this ClientView. | 79 // The Widget that hosts this ClientView. |
82 Window* window_; | 80 Widget* widget_; |
83 | 81 |
84 // The View that this ClientView contains. | 82 // The View that this ClientView contains. |
85 View* contents_view_; | 83 View* contents_view_; |
86 }; | 84 }; |
87 | 85 |
88 } // namespace views | 86 } // namespace views |
89 | 87 |
90 #endif // #ifndef VIEWS_WINDOW_CLIENT_VIEW_H_ | 88 #endif // #ifndef VIEWS_WINDOW_CLIENT_VIEW_H_ |
OLD | NEW |