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

Side by Side Diff: chrome/browser/ui/views/extensions/shell_frame_win.cc

Issue 9254046: Custom frame UI for platform apps on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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
OLDNEW
(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);
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);
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) {
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698