summaryrefslogtreecommitdiffstats
path: root/views/widget/widget_win.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 23:42:23 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 23:42:23 +0000
commit6479c267dd32aab3f043aa2d3b2f808505c031ef (patch)
treeb4c1f5aa25fb119ed28338626e947a7f296a02e3 /views/widget/widget_win.cc
parentb44f5db5391f9865d5950fe88f77dd80e7661ab2 (diff)
downloadchromium_src-6479c267dd32aab3f043aa2d3b2f808505c031ef.zip
chromium_src-6479c267dd32aab3f043aa2d3b2f808505c031ef.tar.gz
chromium_src-6479c267dd32aab3f043aa2d3b2f808505c031ef.tar.bz2
Removes WidgetWin dependency from StatusBubbleViews so that it can compile on Linux.
Requires: - making SetOpacity a cross platform method on Widget, replacing SetLayeredAlpha. - moving Window::SetBounds to Widget - replacing usage of MoveWindow in StatusBubbleViews with call to new SetBounds method. BUG=none TEST=make sure transparency still works for floating widgets like - status bubble, full screen exit bubble, dragged tabs Review URL: http://codereview.chromium.org/113846 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/widget_win.cc')
-rw-r--r--views/widget/widget_win.cc102
1 files changed, 52 insertions, 50 deletions
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index fdb6252..039ab36 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -253,6 +253,54 @@ void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const {
crect.Width(), crect.Height());
}
+void WidgetWin::SetBounds(const gfx::Rect& bounds) {
+ SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(),
+ SWP_NOACTIVATE);
+}
+
+void WidgetWin::Close() {
+ if (!IsWindow())
+ return; // No need to do anything.
+
+ // Let's hide ourselves right away.
+ Hide();
+ if (close_widget_factory_.empty()) {
+ // And we delay the close so that if we are called from an ATL callback,
+ // we don't destroy the window before the callback returned (as the caller
+ // may delete ourselves on destroy and the ATL callback would still
+ // dereference us when the callback returns).
+ MessageLoop::current()->PostTask(FROM_HERE,
+ close_widget_factory_.NewRunnableMethod(
+ &WidgetWin::CloseNow));
+ }
+}
+
+void WidgetWin::CloseNow() {
+ // We may already have been destroyed if the selection resulted in a tab
+ // switch which will have reactivated the browser window and closed us, so
+ // we need to check to see if we're still a window before trying to destroy
+ // ourself.
+ if (IsWindow())
+ DestroyWindow();
+}
+
+void WidgetWin::Show() {
+ if (IsWindow())
+ ShowWindow(SW_SHOWNOACTIVATE);
+}
+
+void WidgetWin::Hide() {
+ if (IsWindow()) {
+ // NOTE: Be careful not to activate any windows here (for example, calling
+ // ShowWindow(SW_HIDE) will automatically activate another window). This
+ // code can be called while a window is being deactivated, and activating
+ // another window will screw up the activation that is already in progress.
+ SetWindowPos(NULL, 0, 0, 0, 0,
+ SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
+ SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+ }
+}
+
gfx::NativeView WidgetWin::GetNativeView() const {
return hwnd_;
}
@@ -316,6 +364,10 @@ void WidgetWin::PaintNow(const gfx::Rect& update_rect) {
}
}
+void WidgetWin::SetOpacity(unsigned char opacity) {
+ layered_alpha_ = static_cast<BYTE>(opacity);
+}
+
RootView* WidgetWin::GetRootView() {
if (!root_view_.get()) {
// First time the root view is being asked for, create it now.
@@ -359,13 +411,6 @@ const Window* WidgetWin::GetWindow() const {
return GetWindowImpl(hwnd_);
}
-void WidgetWin::SetLayeredAlpha(BYTE layered_alpha) {
- layered_alpha_ = layered_alpha;
-
-// if (hwnd_)
-// UpdateWindowFromContents(contents_->getTopPlatformDevice().getBitmapDC());
-}
-
void WidgetWin::SetUseLayeredBuffer(bool use_layered_buffer) {
if (use_layered_buffer_ == use_layered_buffer)
return;
@@ -407,49 +452,6 @@ RootView* WidgetWin::FindRootView(HWND hwnd) {
return root_view;
}
-void WidgetWin::Close() {
- if (!IsWindow())
- return; // No need to do anything.
-
- // Let's hide ourselves right away.
- Hide();
- if (close_widget_factory_.empty()) {
- // And we delay the close so that if we are called from an ATL callback,
- // we don't destroy the window before the callback returned (as the caller
- // may delete ourselves on destroy and the ATL callback would still
- // dereference us when the callback returns).
- MessageLoop::current()->PostTask(FROM_HERE,
- close_widget_factory_.NewRunnableMethod(
- &WidgetWin::CloseNow));
- }
-}
-
-void WidgetWin::Hide() {
- if (IsWindow()) {
- // NOTE: Be careful not to activate any windows here (for example, calling
- // ShowWindow(SW_HIDE) will automatically activate another window). This
- // code can be called while a window is being deactivated, and activating
- // another window will screw up the activation that is already in progress.
- SetWindowPos(NULL, 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
- SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
- }
-}
-
-void WidgetWin::Show() {
- if (IsWindow())
- ShowWindow(SW_SHOWNOACTIVATE);
-}
-
-void WidgetWin::CloseNow() {
- // We may already have been destroyed if the selection resulted in a tab
- // switch which will have reactivated the browser window and closed us, so
- // we need to check to see if we're still a window before trying to destroy
- // ourself.
- if (IsWindow())
- DestroyWindow();
-}
-
///////////////////////////////////////////////////////////////////////////////
// MessageLoop::Observer