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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/extensions/shell_frame_win.cc
diff --git a/chrome/browser/ui/views/extensions/shell_frame_win.cc b/chrome/browser/ui/views/extensions/shell_frame_win.cc
new file mode 100755
index 0000000000000000000000000000000000000000..05a6329b7cf6d563a4f6b7fc2676da2ffce4301a
--- /dev/null
+++ b/chrome/browser/ui/views/extensions/shell_frame_win.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <dwmapi.h>
+
+#include "chrome/browser/ui/views/extensions/shell_frame_win.h"
+
+ShellFrameWin::ShellFrameWin(views::Widget* delegate)
+ : views::NativeWidgetWin(delegate) {
+}
+
+views::NativeWidget* ShellFrameWin::AsNativeWidget() {
+ return this;
+}
+const views::NativeWidget* ShellFrameWin::AsNativeWidget() const {
+ return this;
+}
+
+gfx::Insets ShellFrameWin::GetClientAreaInsets() const {
+ return gfx::Insets(0,0,0,0);
+}
+
+LRESULT ShellFrameWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
+ if (w_param) {
+ SetMsgHandled(TRUE);
+ MARGINS margins = {10,10,10,10};
+ DwmExtendFrameIntoClientArea(GetNativeView(), &margins);
Ben Goodger (Google) 2012/01/26 23:03:45 This is the kind of thing that can be done in the
+ return 0;
+ }
+ return views::NativeWidgetWin::OnNCCalcSize(w_param, l_param);
+}
+
+LRESULT ShellFrameWin::OnCreate(CREATESTRUCT* create_struct) {
+ RECT rc;
+ GetWindowRect(&rc);
+ SetWindowPos(NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
+ SWP_FRAMECHANGED);
Ben Goodger (Google) 2012/01/26 23:03:45 What are you attempting to do here?
+ return views::NativeWidgetWin::OnCreate(create_struct);
+}
+
+LRESULT ShellFrameWin::OnNCHitTest(const CPoint& point) {
+ SetMsgHandled(true);
+ RECT rc;
+ GetWindowRect(&rc);
+ int x = point.x - rc.left;
+ int y = point.y - rc.top;
+ int width = rc.right - rc.left;
+ int height = rc.bottom - rc.top;
+ if (x <= 5) {
+ if (y <= 5) {
+ return HTTOPLEFT;
+ } else if (y >= height - 5) {
Ben Goodger (Google) 2012/01/26 23:03:45 no else after return
+ return HTBOTTOMLEFT;
+ } else {
+ return HTLEFT;
+ }
+ } else if (x >= width - 5) {
+ if (y <= 5) {
+ return HTTOPRIGHT;
+ } else if (y >= height - 5) {
+ return HTBOTTOMRIGHT;
+ } else {
+ return HTRIGHT;
+ }
+ } else {
+ if (y <= 5) {
+ return HTTOP;
+ } else if (y >= height - 5) {
+ return HTBOTTOM;
+ } else {
+ return HTCAPTION;
+ }
+ }
+ NOTREACHED();
+}
+
+// static
+NativeShellFrame* NativeShellFrame::CreateNativeShellFrame(
+ views::Widget* container) {
+ return new ShellFrameWin(container);
+}

Powered by Google App Engine
This is Rietveld 408576698