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