Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <dwmapi.h> | |
| 6 | |
| 7 #include "chrome/browser/ui/views/extensions/shell_frame_win.h" | |
| 8 | |
| 9 ShellFrameWin::ShellFrameWin(views::Widget* delegate) | |
| 10 : views::NativeWidgetWin(delegate) { | |
| 11 } | |
| 12 | |
| 13 views::NativeWidget* ShellFrameWin::AsNativeWidget() { | |
| 14 return this; | |
| 15 } | |
| 16 const views::NativeWidget* ShellFrameWin::AsNativeWidget() const { | |
| 17 return this; | |
| 18 } | |
| 19 | |
| 20 gfx::Insets ShellFrameWin::GetClientAreaInsets() const { | |
| 21 return gfx::Insets(0,0,0,0); | |
| 22 } | |
| 23 | |
| 24 LRESULT ShellFrameWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { | |
| 25 if (w_param) { | |
| 26 SetMsgHandled(TRUE); | |
| 27 MARGINS margins = {10,10,10,10}; | |
| 28 DwmExtendFrameIntoClientArea(GetNativeView(), &margins); | |
|
Ben Goodger (Google)
2012/01/26 23:03:45
This is the kind of thing that can be done in the
| |
| 29 return 0; | |
| 30 } | |
| 31 return views::NativeWidgetWin::OnNCCalcSize(w_param, l_param); | |
| 32 } | |
| 33 | |
| 34 LRESULT ShellFrameWin::OnCreate(CREATESTRUCT* create_struct) { | |
| 35 RECT rc; | |
| 36 GetWindowRect(&rc); | |
| 37 SetWindowPos(NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, | |
| 38 SWP_FRAMECHANGED); | |
|
Ben Goodger (Google)
2012/01/26 23:03:45
What are you attempting to do here?
| |
| 39 return views::NativeWidgetWin::OnCreate(create_struct); | |
| 40 } | |
| 41 | |
| 42 LRESULT ShellFrameWin::OnNCHitTest(const CPoint& point) { | |
| 43 SetMsgHandled(true); | |
| 44 RECT rc; | |
| 45 GetWindowRect(&rc); | |
| 46 int x = point.x - rc.left; | |
| 47 int y = point.y - rc.top; | |
| 48 int width = rc.right - rc.left; | |
| 49 int height = rc.bottom - rc.top; | |
| 50 if (x <= 5) { | |
| 51 if (y <= 5) { | |
| 52 return HTTOPLEFT; | |
| 53 } else if (y >= height - 5) { | |
|
Ben Goodger (Google)
2012/01/26 23:03:45
no else after return
| |
| 54 return HTBOTTOMLEFT; | |
| 55 } else { | |
| 56 return HTLEFT; | |
| 57 } | |
| 58 } else if (x >= width - 5) { | |
| 59 if (y <= 5) { | |
| 60 return HTTOPRIGHT; | |
| 61 } else if (y >= height - 5) { | |
| 62 return HTBOTTOMRIGHT; | |
| 63 } else { | |
| 64 return HTRIGHT; | |
| 65 } | |
| 66 } else { | |
| 67 if (y <= 5) { | |
| 68 return HTTOP; | |
| 69 } else if (y >= height - 5) { | |
| 70 return HTBOTTOM; | |
| 71 } else { | |
| 72 return HTCAPTION; | |
| 73 } | |
| 74 } | |
| 75 NOTREACHED(); | |
| 76 } | |
| 77 | |
| 78 // static | |
| 79 NativeShellFrame* NativeShellFrame::CreateNativeShellFrame( | |
| 80 views::Widget* container) { | |
| 81 return new ShellFrameWin(container); | |
| 82 } | |
| OLD | NEW |