Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: views/widget/native_widget_win.cc

Issue 7075019: Move a bunch of functions from Window onto Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/native_widget_win.h ('k') | views/widget/widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "views/widget/native_widget_win.h" 5 #include "views/widget/native_widget_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/system_monitor/system_monitor.h" 10 #include "base/system_monitor/system_monitor.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // NOTE: Be careful not to activate any windows here (for example, calling 387 // NOTE: Be careful not to activate any windows here (for example, calling
388 // ShowWindow(SW_HIDE) will automatically activate another window). This 388 // ShowWindow(SW_HIDE) will automatically activate another window). This
389 // code can be called while a window is being deactivated, and activating 389 // code can be called while a window is being deactivated, and activating
390 // another window will screw up the activation that is already in progress. 390 // another window will screw up the activation that is already in progress.
391 SetWindowPos(NULL, 0, 0, 0, 0, 391 SetWindowPos(NULL, 0, 0, 0, 0,
392 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | 392 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
393 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); 393 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
394 } 394 }
395 } 395 }
396 396
397 bool NativeWidgetWin::IsVisible() const {
398 return !!::IsWindowVisible(hwnd());
399 }
400
401 void NativeWidgetWin::Activate() {
402 if (IsMinimized())
403 ::ShowWindow(GetNativeView(), SW_RESTORE);
404 ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0,
405 SWP_NOSIZE | SWP_NOMOVE);
406 SetForegroundWindow(GetNativeView());
407 }
408
409 void NativeWidgetWin::Deactivate() {
410 HWND hwnd = ::GetNextWindow(GetNativeView(), GW_HWNDNEXT);
411 if (hwnd)
412 ::SetForegroundWindow(hwnd);
413 }
414
415 bool NativeWidgetWin::IsActive() const {
416 return IsWindowActive(hwnd());
417 }
418
419 void NativeWidgetWin::SetAlwaysOnTop(bool on_top) {
420 ::SetWindowPos(GetNativeView(), on_top ? HWND_TOPMOST : HWND_NOTOPMOST,
421 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
422 }
423
424 void NativeWidgetWin::Maximize() {
425 ExecuteSystemMenuCommand(SC_MAXIMIZE);
426 }
427
428 void NativeWidgetWin::Minimize() {
429 ExecuteSystemMenuCommand(SC_MINIMIZE);
430 }
431
432 bool NativeWidgetWin::IsMaximized() const {
433 return !!::IsZoomed(GetNativeView());
434 }
435
436 bool NativeWidgetWin::IsMinimized() const {
437 return !!::IsIconic(GetNativeView());
438 }
439
440 void NativeWidgetWin::Restore() {
441 ExecuteSystemMenuCommand(SC_RESTORE);
442 }
443
397 void NativeWidgetWin::SetOpacity(unsigned char opacity) { 444 void NativeWidgetWin::SetOpacity(unsigned char opacity) {
398 layered_alpha_ = static_cast<BYTE>(opacity); 445 layered_alpha_ = static_cast<BYTE>(opacity);
399 } 446 }
400 447
401 void NativeWidgetWin::SetAlwaysOnTop(bool on_top) {
402 if (on_top)
403 set_window_ex_style(window_ex_style() | WS_EX_TOPMOST);
404 else
405 set_window_ex_style(window_ex_style() & ~WS_EX_TOPMOST);
406 }
407
408 bool NativeWidgetWin::IsVisible() const {
409 return !!::IsWindowVisible(hwnd());
410 }
411
412 bool NativeWidgetWin::IsActive() const {
413 return IsWindowActive(hwnd());
414 }
415
416 bool NativeWidgetWin::IsAccessibleWidget() const { 448 bool NativeWidgetWin::IsAccessibleWidget() const {
417 return screen_reader_active_; 449 return screen_reader_active_;
418 } 450 }
419 451
420 bool NativeWidgetWin::ContainsNativeView(gfx::NativeView native_view) const { 452 bool NativeWidgetWin::ContainsNativeView(gfx::NativeView native_view) const {
421 return hwnd() == native_view || ::IsChild(hwnd(), native_view); 453 return hwnd() == native_view || ::IsChild(hwnd(), native_view);
422 } 454 }
423 455
424 void NativeWidgetWin::RunShellDrag(View* view, 456 void NativeWidgetWin::RunShellDrag(View* view,
425 const ui::OSExchangeData& data, 457 const ui::OSExchangeData& data,
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 } 1022 }
991 1023
992 void NativeWidgetWin::SetInitialFocus() { 1024 void NativeWidgetWin::SetInitialFocus() {
993 // TODO(beng): move to Widget. 1025 // TODO(beng): move to Widget.
994 View* v = GetWidget()->widget_delegate() ? 1026 View* v = GetWidget()->widget_delegate() ?
995 GetWidget()->widget_delegate()->GetInitiallyFocusedView() : NULL; 1027 GetWidget()->widget_delegate()->GetInitiallyFocusedView() : NULL;
996 if (v) 1028 if (v)
997 v->RequestFocus(); 1029 v->RequestFocus();
998 } 1030 }
999 1031
1032 void NativeWidgetWin::ExecuteSystemMenuCommand(int command) {
1033 if (command)
1034 SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
1035 }
1036
1000 //////////////////////////////////////////////////////////////////////////////// 1037 ////////////////////////////////////////////////////////////////////////////////
1001 // NativeWidgetWin, private: 1038 // NativeWidgetWin, private:
1002 1039
1003 // static 1040 // static
1004 Window* NativeWidgetWin::GetWindowImpl(HWND hwnd) { 1041 Window* NativeWidgetWin::GetWindowImpl(HWND hwnd) {
1005 // NOTE: we can't use GetAncestor here as constrained windows are a Window, 1042 // NOTE: we can't use GetAncestor here as constrained windows are a Window,
1006 // but not a top level window. 1043 // but not a top level window.
1007 HWND parent = hwnd; 1044 HWND parent = hwnd;
1008 while (parent) { 1045 while (parent) {
1009 NativeWidgetWin* widget = 1046 NativeWidgetWin* widget =
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 1333
1297 // And now, notify them that they have a brand new parent. 1334 // And now, notify them that they have a brand new parent.
1298 for (NativeWidgets::iterator it = widgets.begin(); 1335 for (NativeWidgets::iterator it = widgets.begin();
1299 it != widgets.end(); ++it) { 1336 it != widgets.end(); ++it) {
1300 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, 1337 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true,
1301 new_parent); 1338 new_parent);
1302 } 1339 }
1303 } 1340 }
1304 1341
1305 } // namespace views 1342 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/native_widget_win.h ('k') | views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698