| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/browser/ui/views/bubble/border_widget_win.h" | 5 #include "chrome/browser/ui/views/bubble/border_widget_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/views/bubble/border_contents.h" | 9 #include "chrome/browser/ui/views/bubble/border_contents.h" |
| 10 | 10 |
| 11 BorderWidgetWin::BorderWidgetWin() | 11 BorderWidgetWin::BorderWidgetWin() |
| 12 : border_contents_(NULL) { | 12 : border_contents_(NULL) { |
| 13 set_window_style(WS_POPUP); | |
| 14 set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED); | |
| 15 } | 13 } |
| 16 | 14 |
| 17 void BorderWidgetWin::Init(BorderContents* border_contents, HWND owner) { | 15 void BorderWidgetWin::InitBorderWidgetWin(BorderContents* border_contents, |
| 16 HWND owner) { |
| 18 DCHECK(!border_contents_); | 17 DCHECK(!border_contents_); |
| 19 border_contents_ = border_contents; | 18 border_contents_ = border_contents; |
| 20 border_contents_->Init(); | 19 border_contents_->Init(); |
| 21 WidgetWin::Init(owner, gfx::Rect()); | 20 |
| 21 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); |
| 22 params.transparent = true; |
| 23 params.parent = owner; |
| 24 GetWidget()->Init(params); |
| 22 SetContentsView(border_contents_); | 25 SetContentsView(border_contents_); |
| 23 SetWindowPos(owner, 0, 0, 0, 0, | 26 SetWindowPos(owner, 0, 0, 0, 0, |
| 24 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOREDRAW); | 27 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOREDRAW); |
| 25 } | 28 } |
| 26 | 29 |
| 27 gfx::Rect BorderWidgetWin::SizeAndGetBounds( | 30 gfx::Rect BorderWidgetWin::SizeAndGetBounds( |
| 28 const gfx::Rect& position_relative_to, | 31 const gfx::Rect& position_relative_to, |
| 29 BubbleBorder::ArrowLocation arrow_location, | 32 BubbleBorder::ArrowLocation arrow_location, |
| 30 const gfx::Size& contents_size) { | 33 const gfx::Size& contents_size) { |
| 31 // Ask the border view to calculate our bounds (and our contents'). | 34 // Ask the border view to calculate our bounds (and our contents'). |
| 32 gfx::Rect contents_bounds; | 35 gfx::Rect contents_bounds; |
| 33 gfx::Rect window_bounds; | 36 gfx::Rect window_bounds; |
| 34 border_contents_->SizeAndGetBounds(position_relative_to, arrow_location, | 37 border_contents_->SizeAndGetBounds(position_relative_to, arrow_location, |
| 35 false, contents_size, &contents_bounds, | 38 false, contents_size, &contents_bounds, |
| 36 &window_bounds); | 39 &window_bounds); |
| 37 SetBounds(window_bounds); | 40 SetBounds(window_bounds); |
| 38 | 41 |
| 39 // Return |contents_bounds| in screen coordinates. | 42 // Return |contents_bounds| in screen coordinates. |
| 40 contents_bounds.Offset(window_bounds.origin()); | 43 contents_bounds.Offset(window_bounds.origin()); |
| 41 return contents_bounds; | 44 return contents_bounds; |
| 42 } | 45 } |
| 43 | 46 |
| 44 LRESULT BorderWidgetWin::OnMouseActivate(UINT message, | 47 LRESULT BorderWidgetWin::OnMouseActivate(UINT message, |
| 45 WPARAM w_param, | 48 WPARAM w_param, |
| 46 LPARAM l_param) { | 49 LPARAM l_param) { |
| 47 // Never activate. | 50 // Never activate. |
| 48 return MA_NOACTIVATE; | 51 return MA_NOACTIVATE; |
| 49 } | 52 } |
| OLD | NEW |