OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "views/widget/root_view.h" | 5 #include "views/widget/root_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/drag_drop_types.h" | 9 #include "app/drag_drop_types.h" |
10 #include "app/gfx/canvas.h" | 10 #include "app/gfx/canvas.h" |
11 #if defined(OS_WIN) | |
12 #include "base/base_drag_source.h" | |
13 #endif | |
14 #include "base/logging.h" | 11 #include "base/logging.h" |
15 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "views/fill_layout.h" |
16 #include "views/focus/view_storage.h" | 14 #include "views/focus/view_storage.h" |
17 #if defined(OS_WIN) | |
18 #include "views/widget/root_view_drop_target.h" | |
19 #endif | |
20 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
21 #include "views/window/window.h" | 16 #include "views/window/window.h" |
22 | 17 |
| 18 #if defined(OS_WIN) |
| 19 #include "base/base_drag_source.h" |
| 20 #include "views/widget/root_view_drop_target.h" |
| 21 #endif |
| 22 |
23 namespace views { | 23 namespace views { |
24 | 24 |
25 ///////////////////////////////////////////////////////////////////////////// | 25 ///////////////////////////////////////////////////////////////////////////// |
26 // | 26 // |
27 // A Task to trigger non urgent painting. | 27 // A Task to trigger non urgent painting. |
28 // | 28 // |
29 ///////////////////////////////////////////////////////////////////////////// | 29 ///////////////////////////////////////////////////////////////////////////// |
30 class PaintTask : public Task { | 30 class PaintTask : public Task { |
31 public: | 31 public: |
32 explicit PaintTask(RootView* target) : root_view_(target) { | 32 explicit PaintTask(RootView* target) : root_view_(target) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 RootView::~RootView() { | 85 RootView::~RootView() { |
86 // If we have children remove them explicitly so to make sure a remove | 86 // If we have children remove them explicitly so to make sure a remove |
87 // notification is sent for each one of them. | 87 // notification is sent for each one of them. |
88 if (!child_views_.empty()) | 88 if (!child_views_.empty()) |
89 RemoveAllChildViews(true); | 89 RemoveAllChildViews(true); |
90 | 90 |
91 if (pending_paint_task_) | 91 if (pending_paint_task_) |
92 pending_paint_task_->Cancel(); // Ensure we're not called any more. | 92 pending_paint_task_->Cancel(); // Ensure we're not called any more. |
93 } | 93 } |
94 | 94 |
| 95 void RootView::SetContentsView(View* contents_view) { |
| 96 DCHECK(contents_view && GetWidget()->GetNativeView()) << |
| 97 "Can't be called until after the native view is created!"; |
| 98 // The ContentsView must be set up _after_ the window is created so that its |
| 99 // Widget pointer is valid. |
| 100 SetLayoutManager(new FillLayout); |
| 101 if (GetChildViewCount() != 0) |
| 102 RemoveAllChildViews(true); |
| 103 AddChildView(contents_view); |
| 104 |
| 105 // Force a layout now, since the attached hierarchy won't be ready for the |
| 106 // containing window's bounds. Note that we call Layout directly rather than |
| 107 // calling the widget's size changed handler, since the RootView's bounds may |
| 108 // not have changed, which will cause the Layout not to be done otherwise. |
| 109 Layout(); |
| 110 } |
| 111 |
95 ///////////////////////////////////////////////////////////////////////////// | 112 ///////////////////////////////////////////////////////////////////////////// |
96 // | 113 // |
97 // RootView - layout, painting | 114 // RootView - layout, painting |
98 // | 115 // |
99 ///////////////////////////////////////////////////////////////////////////// | 116 ///////////////////////////////////////////////////////////////////////////// |
100 | 117 |
101 void RootView::SchedulePaint(const gfx::Rect& r, bool urgent) { | 118 void RootView::SchedulePaint(const gfx::Rect& r, bool urgent) { |
102 // If there is an existing invalid rect, add the union of the scheduled | 119 // If there is an existing invalid rect, add the union of the scheduled |
103 // rect with the invalid rect. This could be optimized further if | 120 // rect with the invalid rect. This could be optimized further if |
104 // necessary. | 121 // necessary. |
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 gfx::NativeView native_view = GetWidget()->GetNativeView(); | 960 gfx::NativeView native_view = GetWidget()->GetNativeView(); |
944 if (!native_view) | 961 if (!native_view) |
945 return; | 962 return; |
946 gdk_window_set_cursor(native_view->window, cursor); | 963 gdk_window_set_cursor(native_view->window, cursor); |
947 if (cursor) | 964 if (cursor) |
948 gdk_cursor_destroy(cursor); | 965 gdk_cursor_destroy(cursor); |
949 #endif | 966 #endif |
950 } | 967 } |
951 | 968 |
952 } // namespace views | 969 } // namespace views |
OLD | NEW |