summaryrefslogtreecommitdiffstats
path: root/views/controls/hwnd_view.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 06:02:19 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 06:02:19 +0000
commit17dee5e7005a82e08d11be50d56477939124a6b7 (patch)
tree7133a5d7a086ce238057cb82e0e81d332dafba8f /views/controls/hwnd_view.cc
parentbf0136d62bfe02f57821ce026c04b6e8204eb482 (diff)
downloadchromium_src-17dee5e7005a82e08d11be50d56477939124a6b7.zip
chromium_src-17dee5e7005a82e08d11be50d56477939124a6b7.tar.gz
chromium_src-17dee5e7005a82e08d11be50d56477939124a6b7.tar.bz2
Refactors HWNDView, NativeViewHostGtk and NativeViewHost so that they match the NativeControl pattern established for NativeButtons. NativeViewHost is a platform-neutral class that clients instantiate. Behind the scenes the platform instantiates the appropriate NativeViewHostWrapper implementation, either NativeViewHostGtk (as before) or NativeViewHostWin (replaces HWNDView).
BUG=none TEST=none Review URL: http://codereview.chromium.org/114059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/hwnd_view.cc')
-rw-r--r--views/controls/hwnd_view.cc138
1 files changed, 0 insertions, 138 deletions
diff --git a/views/controls/hwnd_view.cc b/views/controls/hwnd_view.cc
deleted file mode 100644
index 77269f2..0000000
--- a/views/controls/hwnd_view.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "views/controls/hwnd_view.h"
-
-#include "app/gfx/canvas.h"
-#include "base/logging.h"
-#include "views/focus/focus_manager.h"
-#include "views/widget/widget.h"
-
-namespace views {
-
-static const char kViewClassName[] = "views/HWNDView";
-
-HWNDView::HWNDView() : NativeViewHost() {
-}
-
-HWNDView::~HWNDView() {
-}
-
-void HWNDView::Attach(HWND hwnd) {
- DCHECK(native_view() == NULL);
- DCHECK(hwnd) << "Impossible detatched tab case; See crbug.com/6316";
-
- set_native_view(hwnd);
-
- // First hide the new window. We don't want anything to draw (like sub-hwnd
- // borders), when we change the parent below.
- ShowWindow(hwnd, SW_HIDE);
-
- // Need to set the HWND's parent before changing its size to avoid flashing.
- ::SetParent(hwnd, GetWidget()->GetNativeView());
- Layout();
-
- // Register with the focus manager so the associated view is focused when the
- // native control gets the focus.
- FocusManager::InstallFocusSubclass(
- hwnd, associated_focus_view() ? associated_focus_view() : this);
-}
-
-void HWNDView::Detach() {
- DCHECK(native_view());
- FocusManager::UninstallFocusSubclass(native_view());
- set_native_view(NULL);
- set_installed_clip(false);
-}
-
-void HWNDView::Paint(gfx::Canvas* canvas) {
- // The area behind our window is black, so during a fast resize (where our
- // content doesn't draw over the full size of our HWND, and the HWND
- // background color doesn't show up), we need to cover that blackness with
- // something so that fast resizes don't result in black flash.
- //
- // It would be nice if this used some approximation of the page's
- // current background color.
- if (installed_clip())
- canvas->FillRectInt(SkColorSetRGB(255, 255, 255), 0, 0, width(), height());
-}
-
-std::string HWNDView::GetClassName() const {
- return kViewClassName;
-}
-
-void HWNDView::ViewHierarchyChanged(bool is_add, View *parent, View *child) {
- if (!native_view())
- return;
-
- Widget* widget = GetWidget();
- if (is_add && widget) {
- HWND parent_hwnd = ::GetParent(native_view());
- HWND widget_hwnd = widget->GetNativeView();
- if (parent_hwnd != widget_hwnd)
- ::SetParent(native_view(), widget_hwnd);
- if (IsVisibleInRootView())
- ::ShowWindow(native_view(), SW_SHOW);
- else
- ::ShowWindow(native_view(), SW_HIDE);
- Layout();
- } else if (!is_add) {
- ::ShowWindow(native_view(), SW_HIDE);
- ::SetParent(native_view(), NULL);
- }
-}
-
-void HWNDView::Focus() {
- ::SetFocus(native_view());
-}
-
-void HWNDView::InstallClip(int x, int y, int w, int h) {
- HRGN clip_region = CreateRectRgn(x, y, x + w, y + h);
- // NOTE: SetWindowRgn owns the region (as well as the deleting the
- // current region), as such we don't delete the old region.
- SetWindowRgn(native_view(), clip_region, FALSE);
-}
-
-void HWNDView::UninstallClip() {
- SetWindowRgn(native_view(), 0, FALSE);
-}
-
-void HWNDView::ShowWidget(int x, int y, int w, int h) {
- UINT swp_flags = SWP_DEFERERASE |
- SWP_NOACTIVATE |
- SWP_NOCOPYBITS |
- SWP_NOOWNERZORDER |
- SWP_NOZORDER;
- // Only send the SHOWWINDOW flag if we're invisible, to avoid flashing.
- if (!::IsWindowVisible(native_view()))
- swp_flags = (swp_flags | SWP_SHOWWINDOW) & ~SWP_NOREDRAW;
-
- if (fast_resize()) {
- // In a fast resize, we move the window and clip it with SetWindowRgn.
- RECT win_rect;
- GetWindowRect(native_view(), &win_rect);
- gfx::Rect rect(win_rect);
- ::SetWindowPos(native_view(), 0, x, y, rect.width(), rect.height(),
- swp_flags);
-
- HRGN clip_region = CreateRectRgn(0, 0, w, h);
- SetWindowRgn(native_view(), clip_region, FALSE);
- set_installed_clip(true);
- } else {
- ::SetWindowPos(native_view(), 0, x, y, w, h, swp_flags);
- }
-}
-
-void HWNDView::HideWidget() {
- if (!::IsWindowVisible(native_view()))
- return; // Currently not visible, nothing to do.
-
- // The window is currently visible, but its clipped by another view. Hide
- // it.
- ::SetWindowPos(native_view(), 0, 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
- SWP_NOREDRAW | SWP_NOOWNERZORDER);
-}
-
-} // namespace views