| 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/browser/views/info_bubble.h" | 5 #include "chrome/browser/views/info_bubble.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/path.h" | 8 #include "app/gfx/path.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 SetUseLayeredBuffer(false); | 126 SetUseLayeredBuffer(false); |
| 127 set_initial_class_style( | 127 set_initial_class_style( |
| 128 (win_util::GetWinVersion() < win_util::WINVERSION_XP) ? | 128 (win_util::GetWinVersion() < win_util::WINVERSION_XP) ? |
| 129 0 : CS_DROPSHADOW); | 129 0 : CS_DROPSHADOW); |
| 130 #endif | 130 #endif |
| 131 content_view_ = CreateContentView(content); | 131 content_view_ = CreateContentView(content); |
| 132 gfx::Rect bounds = | 132 gfx::Rect bounds = |
| 133 content_view_->CalculateWindowBoundsAndAjust(position_relative_to); | 133 content_view_->CalculateWindowBoundsAndAjust(position_relative_to); |
| 134 | 134 |
| 135 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
| 136 WidgetWin::Init(parent->GetNativeWindow(), bounds, true); | 136 WidgetWin::Init(parent->GetNativeWindow(), bounds); |
| 137 #else | 137 #else |
| 138 WidgetGtk::Init(GTK_WIDGET(parent->GetNativeWindow()), bounds, true); | 138 WidgetGtk::Init(GTK_WIDGET(parent->GetNativeWindow()), bounds, true); |
| 139 #endif | 139 #endif |
| 140 SetContentsView(content_view_); | 140 SetContentsView(content_view_); |
| 141 // The preferred size may differ when parented. Ask for the bounds again | 141 // The preferred size may differ when parented. Ask for the bounds again |
| 142 // and if they differ reset the bounds. | 142 // and if they differ reset the bounds. |
| 143 gfx::Rect parented_bounds = | 143 gfx::Rect parented_bounds = |
| 144 content_view_->CalculateWindowBoundsAndAjust(position_relative_to); | 144 content_view_->CalculateWindowBoundsAndAjust(position_relative_to); |
| 145 | 145 |
| 146 if (bounds != parented_bounds) { | 146 if (bounds != parented_bounds) { |
| 147 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
| 148 SetWindowPos(NULL, parented_bounds.x(), parented_bounds.y(), | 148 SetWindowPos(NULL, parented_bounds.x(), parented_bounds.y(), |
| 149 parented_bounds.width(), parented_bounds.height(), | 149 parented_bounds.width(), parented_bounds.height(), |
| 150 SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOZORDER); | 150 SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOZORDER); |
| 151 // Invoke ChangeSize, otherwise layered window isn't updated correctly. | 151 // Invoke ChangeSize, otherwise layered window isn't updated correctly. |
| 152 ChangeSize(0, CSize(parented_bounds.width(), parented_bounds.height())); | 152 ChangeSize(0, CSize(parented_bounds.width(), parented_bounds.height())); |
| 153 #endif | 153 #endif |
| 154 } | 154 } |
| 155 | 155 |
| 156 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
| 157 // Register the Escape accelerator for closing. | 157 // Register the Escape accelerator for closing. |
| 158 views::FocusManager* focus_manager = | 158 GetFocusManager()->RegisterAccelerator(views::Accelerator(VK_ESCAPE, false, |
| 159 views::FocusManager::GetFocusManager(GetNativeView()); | 159 false, false), |
| 160 focus_manager->RegisterAccelerator(views::Accelerator(VK_ESCAPE, false, | 160 this); |
| 161 false, false), | |
| 162 this); | |
| 163 // Set initial alpha value of the layered window. | 161 // Set initial alpha value of the layered window. |
| 164 SetLayeredWindowAttributes(GetNativeView(), | 162 SetLayeredWindowAttributes(GetNativeView(), |
| 165 RGB(0xFF, 0xFF, 0xFF), | 163 RGB(0xFF, 0xFF, 0xFF), |
| 166 kMinimumAlpha, | 164 kMinimumAlpha, |
| 167 LWA_ALPHA); | 165 LWA_ALPHA); |
| 168 #endif | 166 #endif |
| 169 | 167 |
| 170 NotificationService::current()->Notify( | 168 NotificationService::current()->Notify( |
| 171 NotificationType::INFO_BUBBLE_CREATED, | 169 NotificationType::INFO_BUBBLE_CREATED, |
| 172 Source<InfoBubble>(this), | 170 Source<InfoBubble>(this), |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 x -= kArrowXOffset; | 447 x -= kArrowXOffset; |
| 450 else | 448 else |
| 451 x = x + kArrowXOffset - pref.width(); | 449 x = x + kArrowXOffset - pref.width(); |
| 452 if (IsTop()) { | 450 if (IsTop()) { |
| 453 y = position_relative_to.bottom() + kArrowToContentPadding; | 451 y = position_relative_to.bottom() + kArrowToContentPadding; |
| 454 } else { | 452 } else { |
| 455 y = position_relative_to.y() - kArrowToContentPadding - pref.height(); | 453 y = position_relative_to.y() - kArrowToContentPadding - pref.height(); |
| 456 } | 454 } |
| 457 return gfx::Rect(x, y, pref.width(), pref.height()); | 455 return gfx::Rect(x, y, pref.width(), pref.height()); |
| 458 } | 456 } |
| OLD | NEW |