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 "views/widget/widget_win.h" | 5 #include "views/widget/widget_win.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/native_theme_win.h" | 8 #include "app/gfx/native_theme_win.h" |
| 9 #include "app/gfx/path.h" | 9 #include "app/gfx/path.h" |
| 10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 ClientToScreen(hwnd(), &p); | 130 ClientToScreen(hwnd(), &p); |
| 131 out->SetRect(crect.left + p.x, crect.top + p.y, | 131 out->SetRect(crect.left + p.x, crect.top + p.y, |
| 132 crect.Width(), crect.Height()); | 132 crect.Width(), crect.Height()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void WidgetWin::SetBounds(const gfx::Rect& bounds) { | 135 void WidgetWin::SetBounds(const gfx::Rect& bounds) { |
| 136 SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(), | 136 SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(), |
| 137 SWP_NOACTIVATE | SWP_NOZORDER); | 137 SWP_NOACTIVATE | SWP_NOZORDER); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void WidgetWin::MoveAbove(Widget* widget) { | |
| 141 WidgetWin* other = static_cast<WidgetWin*>(widget); | |
|
Ben Goodger (Google)
2009/10/26 18:10:13
How about just other->GetNativeView()... then you
| |
| 142 gfx::Rect bounds; | |
| 143 GetBounds(&bounds, false); | |
| 144 SetWindowPos(other->hwnd(), bounds.x(), bounds.y(), | |
| 145 bounds.width(), bounds.height(), | |
| 146 SWP_NOACTIVATE); | |
| 147 } | |
| 148 | |
| 140 void WidgetWin::SetShape(const gfx::Path& shape) { | 149 void WidgetWin::SetShape(const gfx::Path& shape) { |
| 141 SetWindowRgn(shape.CreateHRGN(), TRUE); | 150 SetWindowRgn(shape.CreateHRGN(), TRUE); |
| 142 } | 151 } |
| 143 | 152 |
| 144 void WidgetWin::Close() { | 153 void WidgetWin::Close() { |
| 145 if (!IsWindow()) | 154 if (!IsWindow()) |
| 146 return; // No need to do anything. | 155 return; // No need to do anything. |
| 147 | 156 |
| 148 // Let's hide ourselves right away. | 157 // Let's hide ourselves right away. |
| 149 Hide(); | 158 Hide(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 // event). For this reason we tell RootView it doesn't need to paint | 254 // event). For this reason we tell RootView it doesn't need to paint |
| 246 // here. | 255 // here. |
| 247 root_view_->ClearPaintRect(); | 256 root_view_->ClearPaintRect(); |
| 248 } | 257 } |
| 249 } | 258 } |
| 250 | 259 |
| 251 void WidgetWin::SetOpacity(unsigned char opacity) { | 260 void WidgetWin::SetOpacity(unsigned char opacity) { |
| 252 layered_alpha_ = static_cast<BYTE>(opacity); | 261 layered_alpha_ = static_cast<BYTE>(opacity); |
| 253 } | 262 } |
| 254 | 263 |
| 264 void WidgetWin::SetAlwaysOnTop(bool on_top) { | |
| 265 if (on_top) | |
| 266 set_window_ex_style(window_ex_style() | WS_EX_TOPMOST); | |
| 267 else | |
| 268 set_window_ex_style(window_ex_style() & ~WS_EX_TOPMOST); | |
| 269 } | |
| 270 | |
| 255 RootView* WidgetWin::GetRootView() { | 271 RootView* WidgetWin::GetRootView() { |
| 256 if (!root_view_.get()) { | 272 if (!root_view_.get()) { |
| 257 // First time the root view is being asked for, create it now. | 273 // First time the root view is being asked for, create it now. |
| 258 root_view_.reset(CreateRootView()); | 274 root_view_.reset(CreateRootView()); |
| 259 } | 275 } |
| 260 return root_view_.get(); | 276 return root_view_.get(); |
| 261 } | 277 } |
| 262 | 278 |
| 263 Widget* WidgetWin::GetRootWidget() const { | 279 Widget* WidgetWin::GetRootWidget() const { |
| 264 return reinterpret_cast<WidgetWin*>( | 280 return reinterpret_cast<WidgetWin*>( |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1143 return; | 1159 return; |
| 1144 } | 1160 } |
| 1145 widget->focus_manager_->RestoreFocusedView(); | 1161 widget->focus_manager_->RestoreFocusedView(); |
| 1146 } | 1162 } |
| 1147 } | 1163 } |
| 1148 | 1164 |
| 1149 //////////////////////////////////////////////////////////////////////////////// | 1165 //////////////////////////////////////////////////////////////////////////////// |
| 1150 // Widget, public: | 1166 // Widget, public: |
| 1151 | 1167 |
| 1152 // static | 1168 // static |
| 1153 Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { | 1169 Widget* Widget::CreatePopupWidget(TransparencyParam transparent, |
| 1170 EventsParam accept_events, | |
| 1171 DeleteParam delete_on_destroy) { | |
| 1154 WidgetWin* popup = new WidgetWin; | 1172 WidgetWin* popup = new WidgetWin; |
| 1173 DWORD ex_style = WS_EX_TOOLWINDOW | l10n_util::GetExtendedTooltipStyles(); | |
| 1174 if (transparent == Transparent) | |
| 1175 ex_style |= WS_EX_LAYERED; | |
| 1176 if (accept_events != AcceptEvents) | |
| 1177 ex_style |= WS_EX_TRANSPARENT; | |
| 1155 popup->set_window_style(WS_POPUP); | 1178 popup->set_window_style(WS_POPUP); |
| 1156 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | | 1179 popup->set_window_ex_style(ex_style); |
| 1157 WS_EX_TRANSPARENT | | 1180 popup->set_delete_on_destroy(delete_on_destroy == DeleteOnDestroy); |
| 1158 l10n_util::GetExtendedTooltipStyles()); | |
| 1159 popup->set_delete_on_destroy(delete_on_destroy); | |
| 1160 return popup; | 1181 return popup; |
| 1161 } | 1182 } |
| 1162 | 1183 |
| 1163 } // namespace views | 1184 } // namespace views |
| OLD | NEW |