| 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/views/custom_frame_window.h" | 5 #include "chrome/views/custom_frame_window.h" |
| 6 | 6 |
| 7 #include "base/gfx/point.h" | 7 #include "base/gfx/point.h" |
| 8 #include "base/gfx/size.h" | 8 #include "base/gfx/size.h" |
| 9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
| 10 #include "chrome/app/theme/theme_resources.h" | 10 #include "chrome/app/theme/theme_resources.h" |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 active_resources_ = new ActiveWindowResources; | 851 active_resources_ = new ActiveWindowResources; |
| 852 inactive_resources_ = new InactiveWindowResources; | 852 inactive_resources_ = new InactiveWindowResources; |
| 853 | 853 |
| 854 title_font_ = win_util::GetWindowTitleFont(); | 854 title_font_ = win_util::GetWindowTitleFont(); |
| 855 | 855 |
| 856 initialized = true; | 856 initialized = true; |
| 857 } | 857 } |
| 858 } | 858 } |
| 859 | 859 |
| 860 /////////////////////////////////////////////////////////////////////////////// | 860 /////////////////////////////////////////////////////////////////////////////// |
| 861 // NonClientViewLayout | |
| 862 | |
| 863 class NonClientViewLayout : public LayoutManager { | |
| 864 public: | |
| 865 // The size of the default window border and padding used by Windows Vista | |
| 866 // with DWM disabled when clipping the window for maximized display. | |
| 867 // TODO(beng): figure out how to get this programmatically, since it varies | |
| 868 // with adjustments to the Windows Border/Padding setting. | |
| 869 static const int kBorderAndPadding = 8; | |
| 870 | |
| 871 NonClientViewLayout(View* child, Window* window) | |
| 872 : child_(child), | |
| 873 window_(window) { | |
| 874 } | |
| 875 virtual ~NonClientViewLayout() {} | |
| 876 | |
| 877 // Overridden from LayoutManager: | |
| 878 virtual void Layout(View* host) { | |
| 879 int horizontal_border_width = | |
| 880 window_->IsMaximized() ? kBorderAndPadding : 0; | |
| 881 int vertical_border_height = | |
| 882 window_->IsMaximized() ? kBorderAndPadding : 0; | |
| 883 | |
| 884 child_->SetBounds(horizontal_border_width, vertical_border_height, | |
| 885 host->width() - (2 * horizontal_border_width), | |
| 886 host->height() - (2 * vertical_border_height)); | |
| 887 } | |
| 888 virtual gfx::Size GetPreferredSize(View* host) { | |
| 889 return child_->GetPreferredSize(); | |
| 890 } | |
| 891 | |
| 892 private: | |
| 893 View* child_; | |
| 894 Window* window_; | |
| 895 | |
| 896 DISALLOW_COPY_AND_ASSIGN(NonClientViewLayout); | |
| 897 }; | |
| 898 | |
| 899 /////////////////////////////////////////////////////////////////////////////// | |
| 900 // CustomFrameWindow, public: | 861 // CustomFrameWindow, public: |
| 901 | 862 |
| 902 CustomFrameWindow::CustomFrameWindow(WindowDelegate* window_delegate) | 863 CustomFrameWindow::CustomFrameWindow(WindowDelegate* window_delegate) |
| 903 : Window(window_delegate), | 864 : Window(window_delegate), |
| 904 is_active_(false), | 865 is_active_(false), |
| 905 lock_updates_(false), | 866 lock_updates_(false), |
| 906 saved_window_style_(0) { | 867 saved_window_style_(0) { |
| 907 InitClass(); | 868 InitClass(); |
| 908 non_client_view_ = new DefaultNonClientView(this); | 869 non_client_view_ = new DefaultNonClientView(this); |
| 909 } | 870 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 922 // CustomFrameWindow, Window overrides: | 883 // CustomFrameWindow, Window overrides: |
| 923 | 884 |
| 924 void CustomFrameWindow::Init(HWND parent, const gfx::Rect& bounds) { | 885 void CustomFrameWindow::Init(HWND parent, const gfx::Rect& bounds) { |
| 925 // TODO(beng): (Cleanup) Right now, the only way to specify a different | 886 // TODO(beng): (Cleanup) Right now, the only way to specify a different |
| 926 // non-client view is to subclass this object and provide one | 887 // non-client view is to subclass this object and provide one |
| 927 // by setting this member before calling Init. | 888 // by setting this member before calling Init. |
| 928 if (!non_client_view_) | 889 if (!non_client_view_) |
| 929 non_client_view_ = new DefaultNonClientView(this); | 890 non_client_view_ = new DefaultNonClientView(this); |
| 930 Window::Init(parent, bounds); | 891 Window::Init(parent, bounds); |
| 931 | 892 |
| 932 // Windows Vista non-Aero-glass does wacky things with maximized windows that | |
| 933 // require a special layout manager to compensate for. | |
| 934 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { | |
| 935 GetRootView()->SetLayoutManager( | |
| 936 new NonClientViewLayout(non_client_view_, this)); | |
| 937 } | |
| 938 | |
| 939 ResetWindowRegion(); | 893 ResetWindowRegion(); |
| 940 } | 894 } |
| 941 | 895 |
| 942 void CustomFrameWindow::SetClientView(ClientView* cv) { | 896 void CustomFrameWindow::SetClientView(ClientView* cv) { |
| 943 DCHECK(cv && !client_view() && GetHWND()); | 897 DCHECK(cv && !client_view() && GetHWND()); |
| 944 set_client_view(cv); | 898 set_client_view(cv); |
| 945 // For a CustomFrameWindow, the non-client view is the root. | 899 // For a CustomFrameWindow, the non-client view is the root. |
| 946 WidgetWin::SetContentsView(non_client_view_); | 900 WidgetWin::SetContentsView(non_client_view_); |
| 947 // When the non client view is added to the view hierarchy, it will cause the | 901 // When the non client view is added to the view hierarchy, it will cause the |
| 948 // client view to be added as well. | 902 // client view to be added as well. |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 if ((GetKeyState(VK_CONTROL) & 0x80) == 0x80) | 1321 if ((GetKeyState(VK_CONTROL) & 0x80) == 0x80) |
| 1368 message_flags |= MK_CONTROL; | 1322 message_flags |= MK_CONTROL; |
| 1369 if ((GetKeyState(VK_SHIFT) & 0x80) == 0x80) | 1323 if ((GetKeyState(VK_SHIFT) & 0x80) == 0x80) |
| 1370 message_flags |= MK_SHIFT; | 1324 message_flags |= MK_SHIFT; |
| 1371 message_flags |= flags; | 1325 message_flags |= flags; |
| 1372 ProcessMousePressed(temp, message_flags, false); | 1326 ProcessMousePressed(temp, message_flags, false); |
| 1373 } | 1327 } |
| 1374 | 1328 |
| 1375 } // namespace views | 1329 } // namespace views |
| 1376 | 1330 |
| OLD | NEW |