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
3 // found in the LICENSE file.
5 #include "ui/views/window/native_frame_view.h"
7 #include "ui/views/widget/native_widget.h"
8 #include "ui/views/widget/widget.h"
11 #include "ui/views/win/hwnd_util.h"
16 ////////////////////////////////////////////////////////////////////////////////
17 // NativeFrameView, public:
20 const char NativeFrameView::kViewClassName
[] = "NativeFrameView";
22 NativeFrameView::NativeFrameView(Widget
* frame
)
23 : NonClientFrameView(),
27 NativeFrameView::~NativeFrameView() {
30 ////////////////////////////////////////////////////////////////////////////////
31 // NativeFrameView, NonClientFrameView overrides:
33 gfx::Rect
NativeFrameView::GetBoundsForClientView() const {
34 return gfx::Rect(0, 0, width(), height());
37 gfx::Rect
NativeFrameView::GetWindowBoundsForClientBounds(
38 const gfx::Rect
& client_bounds
) const {
40 return views::GetWindowBoundsForClientBounds(
41 static_cast<View
*>(const_cast<NativeFrameView
*>(this)), client_bounds
);
43 // Enforce minimum size (1, 1) in case that |client_bounds| is passed with
45 gfx::Rect window_bounds
= client_bounds
;
46 if (window_bounds
.IsEmpty())
47 window_bounds
.set_size(gfx::Size(1,1));
52 int NativeFrameView::NonClientHitTest(const gfx::Point
& point
) {
53 return frame_
->client_view()->NonClientHitTest(point
);
56 void NativeFrameView::GetWindowMask(const gfx::Size
& size
,
57 gfx::Path
* window_mask
) {
58 // Nothing to do, we use the default window mask.
61 void NativeFrameView::ResetWindowControls() {
65 void NativeFrameView::UpdateWindowIcon() {
69 void NativeFrameView::UpdateWindowTitle() {
73 void NativeFrameView::SizeConstraintsChanged() {
77 gfx::Size
NativeFrameView::GetPreferredSize() const {
78 gfx::Size client_preferred_size
= frame_
->client_view()->GetPreferredSize();
80 // Returns the client size. On Windows, this is the expected behavior for
81 // native frames (see |NativeWidgetWin::WidgetSizeIsClientSize()|), while
82 // other platforms currently always return client bounds from
83 // |GetWindowBoundsForClientBounds()|.
84 return client_preferred_size
;
86 return frame_
->non_client_view()->GetWindowBoundsForClientBounds(
87 gfx::Rect(client_preferred_size
)).size();
91 gfx::Size
NativeFrameView::GetMinimumSize() const {
92 return frame_
->client_view()->GetMinimumSize();
95 gfx::Size
NativeFrameView::GetMaximumSize() const {
96 return frame_
->client_view()->GetMaximumSize();
99 const char* NativeFrameView::GetClassName() const {
100 return kViewClassName
;