| 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 #include "ui/views/window/native_frame_view.h" | 5 #include "ui/views/window/native_frame_view.h" |
| 6 | 6 |
| 7 #include "ui/views/widget/native_widget.h" | 7 #include "ui/views/widget/native_widget.h" |
| 8 #include "ui/views/widget/widget.h" | 8 #include "ui/views/widget/widget.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 11 #include "ui/views/win/hwnd_util.h" | 11 #include "ui/views/win/hwnd_util.h" |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
| 17 // NativeFrameView, public: | 17 // NativeFrameView, public: |
| 18 | 18 |
| 19 // static |
| 20 const char NativeFrameView::kViewClassName[] = "NativeFrameView"; |
| 21 |
| 19 NativeFrameView::NativeFrameView(Widget* frame) | 22 NativeFrameView::NativeFrameView(Widget* frame) |
| 20 : NonClientFrameView(), | 23 : NonClientFrameView(), |
| 21 frame_(frame) { | 24 frame_(frame) { |
| 22 } | 25 } |
| 23 | 26 |
| 24 NativeFrameView::~NativeFrameView() { | 27 NativeFrameView::~NativeFrameView() { |
| 25 } | 28 } |
| 26 | 29 |
| 27 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 28 // NativeFrameView, NonClientFrameView overrides: | 31 // NativeFrameView, NonClientFrameView overrides: |
| 29 | 32 |
| 30 gfx::Rect NativeFrameView::GetBoundsForClientView() const { | 33 gfx::Rect NativeFrameView::GetBoundsForClientView() const { |
| 31 return gfx::Rect(0, 0, width(), height()); | 34 return gfx::Rect(0, 0, width(), height()); |
| 32 } | 35 } |
| 33 | 36 |
| 34 gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds( | 37 gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds( |
| 35 const gfx::Rect& client_bounds) const { | 38 const gfx::Rect& client_bounds) const { |
| 36 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 37 return views::GetWindowBoundsForClientBounds( | 40 return views::GetWindowBoundsForClientBounds( |
| 38 static_cast<View*>(const_cast<NativeFrameView*>(this)), client_bounds); | 41 static_cast<View*>(const_cast<NativeFrameView*>(this)), client_bounds); |
| 39 #else | 42 #else |
| 40 // TODO(sad): | 43 // Enforce minimum size (1, 1) in case that |client_bounds| is passed with |
| 41 return client_bounds; | 44 // empty size. |
| 45 gfx::Rect window_bounds = client_bounds; |
| 46 if (window_bounds.IsEmpty()) |
| 47 window_bounds.set_size(gfx::Size(1,1)); |
| 48 return window_bounds; |
| 42 #endif | 49 #endif |
| 43 } | 50 } |
| 44 | 51 |
| 45 int NativeFrameView::NonClientHitTest(const gfx::Point& point) { | 52 int NativeFrameView::NonClientHitTest(const gfx::Point& point) { |
| 46 return frame_->client_view()->NonClientHitTest(point); | 53 return frame_->client_view()->NonClientHitTest(point); |
| 47 } | 54 } |
| 48 | 55 |
| 49 void NativeFrameView::GetWindowMask(const gfx::Size& size, | 56 void NativeFrameView::GetWindowMask(const gfx::Size& size, |
| 50 gfx::Path* window_mask) { | 57 gfx::Path* window_mask) { |
| 51 // Nothing to do, we use the default window mask. | 58 // Nothing to do, we use the default window mask. |
| 52 } | 59 } |
| 53 | 60 |
| 54 void NativeFrameView::ResetWindowControls() { | 61 void NativeFrameView::ResetWindowControls() { |
| 55 // Nothing to do. | 62 // Nothing to do. |
| 56 } | 63 } |
| 57 | 64 |
| 58 void NativeFrameView::UpdateWindowIcon() { | 65 void NativeFrameView::UpdateWindowIcon() { |
| 59 // Nothing to do. | 66 // Nothing to do. |
| 60 } | 67 } |
| 61 | 68 |
| 62 void NativeFrameView::UpdateWindowTitle() { | 69 void NativeFrameView::UpdateWindowTitle() { |
| 63 // Nothing to do. | 70 // Nothing to do. |
| 64 } | 71 } |
| 65 | 72 |
| 66 // Returns the client size. On Windows, this is the expected behavior for | |
| 67 // native frames (see |NativeWidgetWin::WidgetSizeIsClientSize()|), while other | |
| 68 // platforms currently always return client bounds from | |
| 69 // |GetWindowBoundsForClientBounds()|. | |
| 70 gfx::Size NativeFrameView::GetPreferredSize() { | 73 gfx::Size NativeFrameView::GetPreferredSize() { |
| 71 return frame_->client_view()->GetPreferredSize(); | 74 gfx::Size client_preferred_size = frame_->client_view()->GetPreferredSize(); |
| 75 #if defined(OS_WIN) |
| 76 // Returns the client size. On Windows, this is the expected behavior for |
| 77 // native frames (see |NativeWidgetWin::WidgetSizeIsClientSize()|), while |
| 78 // other platforms currently always return client bounds from |
| 79 // |GetWindowBoundsForClientBounds()|. |
| 80 return client_preferred_size; |
| 81 #else |
| 82 return frame_->non_client_view()->GetWindowBoundsForClientBounds( |
| 83 gfx::Rect(client_preferred_size)).size(); |
| 84 #endif |
| 72 } | 85 } |
| 73 | 86 |
| 74 gfx::Size NativeFrameView::GetMinimumSize() { | 87 gfx::Size NativeFrameView::GetMinimumSize() { |
| 75 return frame_->client_view()->GetMinimumSize(); | 88 return frame_->client_view()->GetMinimumSize(); |
| 76 } | 89 } |
| 77 | 90 |
| 78 gfx::Size NativeFrameView::GetMaximumSize() { | 91 gfx::Size NativeFrameView::GetMaximumSize() { |
| 79 return frame_->client_view()->GetMaximumSize(); | 92 return frame_->client_view()->GetMaximumSize(); |
| 80 } | 93 } |
| 81 | 94 |
| 95 const char* NativeFrameView::GetClassName() const { |
| 96 return kViewClassName; |
| 97 } |
| 98 |
| 82 } // namespace views | 99 } // namespace views |
| OLD | NEW |