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 "ui/views/window/client_view.h" |
| 10 // TODO(tfarina): remove this file once all includes have been updated. |
10 | 11 |
11 namespace views { | 12 #endif // VIEWS_WINDOW_CLIENT_VIEW_H_ |
12 | |
13 class DialogClientView; | |
14 class Widget; | |
15 | |
16 /////////////////////////////////////////////////////////////////////////////// | |
17 // ClientView | |
18 // | |
19 // A ClientView is a View subclass that is used to occupy the "client area" | |
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 | |
22 // ClientView are used to create more elaborate contents, e.g. | |
23 // "DialogClientView". | |
24 class VIEWS_EXPORT ClientView : public View { | |
25 public: | |
26 // Internal class name | |
27 static const char kViewClassName[]; | |
28 | |
29 // Constructs a ClientView object for the specified widget with the specified | |
30 // contents. Since this object is created during the process of creating | |
31 // |widget|, |contents_view| must be valid if you want the initial size of | |
32 // the widget to be based on |contents_view|'s preferred size. | |
33 ClientView(Widget* widget, View* contents_view); | |
34 virtual ~ClientView() {} | |
35 | |
36 // Manual RTTI ftw. | |
37 virtual DialogClientView* AsDialogClientView(); | |
38 virtual const DialogClientView* AsDialogClientView() const; | |
39 | |
40 // Returns true to signal that the Widget can be closed. Specialized | |
41 // ClientView subclasses can override this default behavior to allow the | |
42 // close to be blocked until the user corrects mistakes, accepts a warning | |
43 // dialog, etc. | |
44 virtual bool CanClose(); | |
45 | |
46 // Notification that the widget is closing. | |
47 virtual void WidgetClosing(); | |
48 | |
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 | |
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 | |
53 // in the non-client area it is (if it is). | |
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- | |
56 // client" area. A good example of this is the size box at the bottom right | |
57 // corner of resizable dialog boxes. | |
58 virtual int NonClientHitTest(const gfx::Point& point); | |
59 | |
60 // Overridden from View: | |
61 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
62 virtual void Layout() OVERRIDE; | |
63 virtual std::string GetClassName() const OVERRIDE; | |
64 | |
65 protected: | |
66 // Overridden from View: | |
67 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | |
68 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | |
69 virtual void ViewHierarchyChanged(bool is_add, | |
70 View* parent, | |
71 View* child) OVERRIDE; | |
72 | |
73 // Accessors for private data members. | |
74 View* contents_view() const { return contents_view_; } | |
75 void set_contents_view(View* contents_view) { | |
76 contents_view_ = contents_view; | |
77 } | |
78 | |
79 private: | |
80 // The Widget that hosts this ClientView. | |
81 Widget* widget_; | |
82 | |
83 // The View that this ClientView contains. | |
84 View* contents_view_; | |
85 }; | |
86 | |
87 } // namespace views | |
88 | |
89 #endif // #ifndef VIEWS_WINDOW_CLIENT_VIEW_H_ | |
OLD | NEW |