| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "views/window/client_view.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "ui/base/accessibility/accessible_view_state.h" | |
| 9 #include "ui/base/hit_test.h" | |
| 10 #include "views/widget/widget.h" | |
| 11 #include "views/widget/widget_delegate.h" | |
| 12 | |
| 13 namespace views { | |
| 14 | |
| 15 // static | |
| 16 const char ClientView::kViewClassName[] = | |
| 17 "views/window/ClientView"; | |
| 18 | |
| 19 /////////////////////////////////////////////////////////////////////////////// | |
| 20 // ClientView, public: | |
| 21 | |
| 22 ClientView::ClientView(Widget* widget, View* contents_view) | |
| 23 : widget_(widget), | |
| 24 contents_view_(contents_view) { | |
| 25 } | |
| 26 | |
| 27 int ClientView::NonClientHitTest(const gfx::Point& point) { | |
| 28 return bounds().Contains(point) ? HTCLIENT : HTNOWHERE; | |
| 29 } | |
| 30 | |
| 31 DialogClientView* ClientView::AsDialogClientView() { | |
| 32 return NULL; | |
| 33 } | |
| 34 | |
| 35 const DialogClientView* ClientView::AsDialogClientView() const { | |
| 36 return NULL; | |
| 37 } | |
| 38 | |
| 39 bool ClientView::CanClose() { | |
| 40 return true; | |
| 41 } | |
| 42 | |
| 43 void ClientView::WidgetClosing() { | |
| 44 } | |
| 45 | |
| 46 /////////////////////////////////////////////////////////////////////////////// | |
| 47 // ClientView, View overrides: | |
| 48 | |
| 49 gfx::Size ClientView::GetPreferredSize() { | |
| 50 // |contents_view_| is allowed to be NULL up until the point where this view | |
| 51 // is attached to a Container. | |
| 52 if (contents_view_) | |
| 53 return contents_view_->GetPreferredSize(); | |
| 54 return gfx::Size(); | |
| 55 } | |
| 56 | |
| 57 void ClientView::Layout() { | |
| 58 // |contents_view_| is allowed to be NULL up until the point where this view | |
| 59 // is attached to a Container. | |
| 60 if (contents_view_) | |
| 61 contents_view_->SetBounds(0, 0, width(), height()); | |
| 62 } | |
| 63 | |
| 64 std::string ClientView::GetClassName() const { | |
| 65 return kViewClassName; | |
| 66 } | |
| 67 | |
| 68 void ClientView::GetAccessibleState(ui::AccessibleViewState* state) { | |
| 69 state->role = ui::AccessibilityTypes::ROLE_CLIENT; | |
| 70 } | |
| 71 | |
| 72 void ClientView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | |
| 73 // Overridden to do nothing. The NonClientView manually calls Layout on the | |
| 74 // ClientView when it is itself laid out, see comment in | |
| 75 // NonClientView::Layout. | |
| 76 } | |
| 77 | |
| 78 void ClientView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { | |
| 79 if (is_add && child == this) { | |
| 80 DCHECK(GetWidget()); | |
| 81 DCHECK(contents_view_); // |contents_view_| must be valid now! | |
| 82 // Insert |contents_view_| at index 0 so it is first in the focus chain. | |
| 83 // (the OK/Cancel buttons are inserted before contents_view_) | |
| 84 AddChildViewAt(contents_view_, 0); | |
| 85 } | |
| 86 } | |
| 87 | |
| 88 } // namespace views | |
| OLD | NEW |