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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_WINDOW_CLIENT_VIEW_H_
6 #define UI_VIEWS_WINDOW_CLIENT_VIEW_H_
8 #include "ui/views/view.h"
12 class DialogClientView
;
15 ///////////////////////////////////////////////////////////////////////////////
18 // A ClientView is a View subclass that is used to occupy the "client area"
19 // of a widget. It provides basic information to the widget that contains it
20 // such as non-client hit testing information, sizing etc. Sub-classes of
21 // ClientView are used to create more elaborate contents, e.g.
22 // "DialogClientView".
23 class VIEWS_EXPORT ClientView
: public View
{
25 // Internal class name
26 static const char kViewClassName
[];
28 // Constructs a ClientView object for the specified widget with the specified
29 // contents. Since this object is created during the process of creating
30 // |widget|, |contents_view| must be valid if you want the initial size of
31 // the widget to be based on |contents_view|'s preferred size.
32 ClientView(Widget
* widget
, View
* contents_view
);
33 virtual ~ClientView() {}
36 virtual DialogClientView
* AsDialogClientView();
37 virtual const DialogClientView
* AsDialogClientView() const;
39 // Returns true to signal that the Widget can be closed. Specialized
40 // ClientView subclasses can override this default behavior to allow the
41 // close to be blocked until the user corrects mistakes, accepts a warning
43 virtual bool CanClose();
45 // Notification that the widget is closing.
46 virtual void WidgetClosing();
48 // Tests to see if the specified point (in view coordinates) is within the
49 // bounds of this view. If so, it returns HTCLIENT in this default
50 // implementation. If it is outside the bounds of this view, this must return
51 // HTNOWHERE to tell the caller to do further processing to determine where
52 // in the non-client area it is (if it is).
53 // Subclasses of ClientView can extend this logic by overriding this method
54 // to detect if regions within the client area count as parts of the "non-
55 // client" area. A good example of this is the size box at the bottom right
56 // corner of resizable dialog boxes.
57 virtual int NonClientHitTest(const gfx::Point
& point
);
59 // Overridden from View:
60 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
61 virtual gfx::Size
GetMaximumSize() OVERRIDE
;
62 virtual gfx::Size
GetMinimumSize() OVERRIDE
;
63 virtual void Layout() OVERRIDE
;
64 virtual const char* GetClassName() const OVERRIDE
;
67 // Overridden from View:
68 virtual void GetAccessibleState(ui::AccessibleViewState
* state
) OVERRIDE
;
69 virtual void OnBoundsChanged(const gfx::Rect
& previous_bounds
) OVERRIDE
;
70 virtual void ViewHierarchyChanged(
71 const ViewHierarchyChangedDetails
& details
) OVERRIDE
;
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
;
80 // The View that this ClientView contains.
86 #endif // UI_VIEWS_WINDOW_CLIENT_VIEW_H_