Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser_bubble.h" | 5 #include "chrome/browser/views/browser_bubble.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_win.h" | 7 #include "app/l10n_util_win.h" |
| 8 #include "chrome/browser/views/frame/browser_view.h" | 8 #include "chrome/browser/views/frame/browser_view.h" |
| 9 #include "views/widget/root_view.h" | 9 #include "views/widget/root_view.h" |
| 10 #include "views/widget/widget_win.h" | 10 #include "views/widget/widget_win.h" |
| 11 #include "views/window/window.h" | 11 #include "views/window/window.h" |
| 12 | 12 |
| 13 class BubbleWidget : public views::WidgetWin { | 13 class BubbleWidget : public views::WidgetWin { |
| 14 public: | 14 public: |
| 15 explicit BubbleWidget(BrowserBubble* bubble) | 15 explicit BubbleWidget(BrowserBubble* bubble) |
| 16 : bubble_(bubble), closed_(false) { | 16 : bubble_(bubble), closed_(false) { |
| 17 set_window_style(WS_POPUP | WS_CLIPCHILDREN); | |
|
amit
2009/11/16 18:06:27
This will work but it sets the window style per in
| |
| 18 set_window_ex_style(WS_EX_TOOLWINDOW); | |
| 17 } | 19 } |
| 18 | 20 |
| 19 void Show(bool activate) { | 21 void Show(bool activate) { |
| 20 if (activate) | 22 if (activate) |
| 21 ShowWindow(SW_SHOW); | 23 ShowWindow(SW_SHOW); |
| 22 else | 24 else |
| 23 views::WidgetWin::Show(); | 25 views::WidgetWin::Show(); |
| 24 } | 26 } |
| 25 | 27 |
| 26 void Close() { | 28 void Close() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 | 65 |
| 64 private: | 66 private: |
| 65 bool closed_; | 67 bool closed_; |
| 66 BrowserBubble* bubble_; | 68 BrowserBubble* bubble_; |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 void BrowserBubble::InitPopup() { | 71 void BrowserBubble::InitPopup() { |
| 70 // popup_ is a Widget, but we need to do some WidgetWin stuff first, then | 72 // popup_ is a Widget, but we need to do some WidgetWin stuff first, then |
| 71 // we'll assign it into popup_. | 73 // we'll assign it into popup_. |
| 72 views::WidgetWin* pop = new BubbleWidget(this); | 74 views::WidgetWin* pop = new BubbleWidget(this); |
| 73 pop->set_window_style(WS_POPUP); | |
| 74 pop->Init(frame_native_view_, bounds_); | 75 pop->Init(frame_native_view_, bounds_); |
| 75 pop->SetContentsView(view_); | 76 pop->SetContentsView(view_); |
| 76 | 77 |
| 77 popup_ = pop; | 78 popup_ = pop; |
| 78 Reposition(); | 79 Reposition(); |
| 79 AttachToBrowser(); | 80 AttachToBrowser(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void BrowserBubble::MovePopup(int x, int y, int w, int h) { | 83 void BrowserBubble::MovePopup(int x, int y, int w, int h) { |
| 83 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); | 84 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); |
| 84 pop->MoveWindow(x, y, w, h); | 85 pop->SetBounds(gfx::Rect(x, y, w, h)); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void BrowserBubble::Show(bool activate) { | 88 void BrowserBubble::Show(bool activate) { |
| 88 if (visible_) | 89 if (visible_) |
| 89 return; | 90 return; |
| 90 BubbleWidget* pop = static_cast<BubbleWidget*>(popup_); | 91 BubbleWidget* pop = static_cast<BubbleWidget*>(popup_); |
| 91 pop->Show(activate); | 92 pop->Show(activate); |
| 92 visible_ = true; | 93 visible_ = true; |
| 93 } | 94 } |
| 94 | 95 |
| 95 void BrowserBubble::Hide() { | 96 void BrowserBubble::Hide() { |
| 96 if (!visible_) | 97 if (!visible_) |
| 97 return; | 98 return; |
| 98 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); | 99 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); |
| 99 pop->Hide(); | 100 pop->Hide(); |
| 100 visible_ = false; | 101 visible_ = false; |
| 101 } | 102 } |
| OLD | NEW |