| 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 "chrome/views/hwnd_view.h" | 5 #include "chrome/views/hwnd_view.h" |
| 6 | 6 |
| 7 #include "chrome/common/gfx/chrome_canvas.h" | 7 #include "chrome/common/gfx/chrome_canvas.h" |
| 8 #include "chrome/common/win_util.h" | 8 #include "chrome/common/win_util.h" |
| 9 #include "chrome/views/focus_manager.h" | 9 #include "chrome/views/focus_manager.h" |
| 10 #include "chrome/views/scroll_view.h" | 10 #include "chrome/views/scroll_view.h" |
| 11 #include "chrome/views/view_container.h" | 11 #include "chrome/views/view_container.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 | 13 |
| 14 namespace ChromeViews { | 14 namespace ChromeViews { |
| 15 | 15 |
| 16 static const char kViewClassName[] = "chrome/views/HWNDView"; | 16 static const char kViewClassName[] = "chrome/views/HWNDView"; |
| 17 | 17 |
| 18 HWNDView::HWNDView() : | 18 HWNDView::HWNDView() : |
| 19 hwnd_(0), | 19 hwnd_(0), |
| 20 preferred_size_(0, 0), | |
| 21 installed_clip_(false), | 20 installed_clip_(false), |
| 22 fast_resize_(false), | 21 fast_resize_(false), |
| 23 focus_view_(NULL) { | 22 focus_view_(NULL) { |
| 24 // HWNDs are placed relative to the root. As such, we need to | 23 // HWNDs are placed relative to the root. As such, we need to |
| 25 // know when the position of any ancestor changes, or our visibility relative | 24 // know when the position of any ancestor changes, or our visibility relative |
| 26 // to other views changed as it'll effect our position relative to the root. | 25 // to other views changed as it'll effect our position relative to the root. |
| 27 SetNotifyWhenVisibleBoundsInRootChanges(true); | 26 SetNotifyWhenVisibleBoundsInRootChanges(true); |
| 28 } | 27 } |
| 29 | 28 |
| 30 HWNDView::~HWNDView() { | 29 HWNDView::~HWNDView() { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 137 } |
| 139 | 138 |
| 140 void HWNDView::VisibilityChanged(View* starting_from, bool is_visible) { | 139 void HWNDView::VisibilityChanged(View* starting_from, bool is_visible) { |
| 141 //UpdateHWNDBounds(); | 140 //UpdateHWNDBounds(); |
| 142 if (IsVisibleInRootView()) | 141 if (IsVisibleInRootView()) |
| 143 ::ShowWindow(hwnd_, SW_SHOW); | 142 ::ShowWindow(hwnd_, SW_SHOW); |
| 144 else | 143 else |
| 145 ::ShowWindow(hwnd_, SW_HIDE); | 144 ::ShowWindow(hwnd_, SW_HIDE); |
| 146 } | 145 } |
| 147 | 146 |
| 148 void HWNDView::GetPreferredSize(CSize *out) { | 147 gfx::Size HWNDView::GetPreferredSize() { |
| 149 out->cx = preferred_size_.cx; | 148 return preferred_size_; |
| 150 out->cy = preferred_size_.cy; | |
| 151 } | |
| 152 | |
| 153 void HWNDView::SetPreferredSize(const CSize& size) { | |
| 154 preferred_size_ = size; | |
| 155 } | 149 } |
| 156 | 150 |
| 157 void HWNDView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { | 151 void HWNDView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { |
| 158 if (hwnd_) { | 152 if (hwnd_) { |
| 159 ViewContainer* vc = GetViewContainer(); | 153 ViewContainer* vc = GetViewContainer(); |
| 160 if (is_add && vc) { | 154 if (is_add && vc) { |
| 161 HWND parent = ::GetParent(hwnd_); | 155 HWND parent = ::GetParent(hwnd_); |
| 162 HWND vc_hwnd = vc->GetHWND(); | 156 HWND vc_hwnd = vc->GetHWND(); |
| 163 if (parent != vc_hwnd) { | 157 if (parent != vc_hwnd) { |
| 164 ::SetParent(hwnd_, vc_hwnd); | 158 ::SetParent(hwnd_, vc_hwnd); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 192 canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, | 186 canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, |
| 193 bounds_.Width(), bounds_.Height()); | 187 bounds_.Width(), bounds_.Height()); |
| 194 } | 188 } |
| 195 | 189 |
| 196 std::string HWNDView::GetClassName() const { | 190 std::string HWNDView::GetClassName() const { |
| 197 return kViewClassName; | 191 return kViewClassName; |
| 198 } | 192 } |
| 199 | 193 |
| 200 } | 194 } |
| 201 | 195 |
| OLD | NEW |