From 0277af7788a808bc462d838fbbf7cc8c5f638b33 Mon Sep 17 00:00:00 2001 From: "joshmoz%gmail.com" Date: Wed, 17 May 2006 18:53:58 +0000 Subject: [PATCH] Add nsPIWidgetCocoa interface to top-level window Cocoa widgets. This is part of bug 330587, sheet support. r=mento --- widget/src/cocoa/Makefile.in | 1 + widget/src/cocoa/nsCocoaWindow.h | 6 +-- widget/src/cocoa/nsCocoaWindow.mm | 54 +++++++++++++++++----- widget/src/cocoa/nsPIWidgetCocoa.idl | 69 ++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 15 deletions(-) create mode 100644 widget/src/cocoa/nsPIWidgetCocoa.idl diff --git a/widget/src/cocoa/Makefile.in b/widget/src/cocoa/Makefile.in index 52adc8bbf811..839cde98f029 100644 --- a/widget/src/cocoa/Makefile.in +++ b/widget/src/cocoa/Makefile.in @@ -138,6 +138,7 @@ XPIDLSRCS += \ nsIChangeManager.idl \ nsIMenuCommandDispatcher.idl \ nsIDragHelperService.idl \ + nsPIWidgetCocoa.idl \ $(NULL) GFX_CPPSRCS := $(addprefix $(topsrcdir)/gfx/src/mac/,$(GFX_LCPPSRCS)) diff --git a/widget/src/cocoa/nsCocoaWindow.h b/widget/src/cocoa/nsCocoaWindow.h index 42106caacfa4..d3f0df35c6e4 100644 --- a/widget/src/cocoa/nsCocoaWindow.h +++ b/widget/src/cocoa/nsCocoaWindow.h @@ -43,6 +43,7 @@ #import #include "nsBaseWidget.h" +#include "nsPIWidgetCocoa.h" class nsCocoaWindow; @@ -58,7 +59,7 @@ class nsCocoaWindow; @end -class nsCocoaWindow : public nsBaseWidget +class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa { private: typedef nsBaseWidget Inherited; @@ -71,6 +72,7 @@ public: virtual ~nsCocoaWindow(); NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSPIWIDGETCOCOA NS_IMETHOD Create(nsNativeWidget aParent, const nsRect &aRect, @@ -153,8 +155,6 @@ public: void StartResizing () { mIsResizing = PR_TRUE; } void StopResizing () { mIsResizing = PR_FALSE; } - void ComeToFront(); - // nsIKBStateControl interface NS_IMETHOD ResetInputState(); diff --git a/widget/src/cocoa/nsCocoaWindow.mm b/widget/src/cocoa/nsCocoaWindow.mm index 9d9f4e3006e0..bc9d56b920aa 100644 --- a/widget/src/cocoa/nsCocoaWindow.mm +++ b/widget/src/cocoa/nsCocoaWindow.mm @@ -69,7 +69,7 @@ extern BOOL gSomeMenuBarPainted; // call getHiddenWindowNativeMenu, don't use this directly static nsIMenuBar* gHiddenWindowMenuBar; -NS_IMPL_ISUPPORTS_INHERITED0(nsCocoaWindow, Inherited) +NS_IMPL_ISUPPORTS_INHERITED1(nsCocoaWindow, Inherited, nsPIWidgetCocoa) // get the highest point on any screen @@ -357,8 +357,8 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent, backing:NSBackingStoreBuffered defer:NO]; if (mWindowType == eWindowType_popup) { - [mWindow setLevel:NSPopUpMenuWindowLevel]; - [mWindow setHasShadow:YES]; + [mWindow setLevel:NSPopUpMenuWindowLevel]; + [mWindow setHasShadow:YES]; } [mWindow setReleasedWhenClosed:NO]; @@ -506,7 +506,7 @@ NS_IMETHODIMP nsCocoaWindow::Move(PRInt32 aX, PRInt32 aY) mParent->WidgetToScreen(localRect,globalRect); aX=globalRect.x; aY=globalRect.y; - } + } } NSPoint coord = {aX, aY}; @@ -634,20 +634,50 @@ PRBool nsCocoaWindow::DragEvent ( unsigned int aMessage, Point aMouseGlobal, UIn return PR_FALSE; } -//------------------------------------------------------------------------- -// -// Like ::BringToFront, but constrains the window to its z-level -// -//------------------------------------------------------------------------- -void nsCocoaWindow::ComeToFront() -{ +// Like ::BringToFront, but constrains the window to its z-level +NS_IMETHODIMP nsCocoaWindow::ComeToFront() +{ +/* + nsZLevelEvent event(PR_TRUE, NS_SETZLEVEL, this); + + event.refPoint.x = mBounds.x; + event.refPoint.y = mBounds.y; + event.time = PR_IntervalNow(); + + event.mImmediate = PR_TRUE; + + nsEventStatus status = nsEventStatus_eIgnore; + DispatchEvent(&event, status); +*/ + + return NS_OK; +} + + +NS_IMETHODIMP nsCocoaWindow::GetChildSheet(PRBool aShown, nsCocoaWindow** _retval) +{ + *_retval = nsnull; + return NS_OK; +} + + +NS_IMETHODIMP nsCocoaWindow::GetMenuBar(nsIMenuBar** menuBar) +{ + *menuBar = mMenuBar; + return NS_OK; +} + + +NS_IMETHODIMP nsCocoaWindow::GetIsSheet(PRBool* isSheet) +{ + *isSheet = mIsSheet; + return NS_OK; } NS_IMETHODIMP nsCocoaWindow::ResetInputState() { -// return mMacEventHandler->ResetInputState(); return NS_OK; } diff --git a/widget/src/cocoa/nsPIWidgetCocoa.idl b/widget/src/cocoa/nsPIWidgetCocoa.idl new file mode 100644 index 000000000000..bfb9c413d8ac --- /dev/null +++ b/widget/src/cocoa/nsPIWidgetCocoa.idl @@ -0,0 +1,69 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Mike Pinkerton + * Josh Aas + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIMenuBar; +interface nsCocoaWindow; + +// +// nsPIWidgetCocoa +// +// A private interface (unfrozen, private to the widget implementation) that +// gives us access to some extra features on a widget/window. +// +[scriptable, uuid(97e466b1-967f-40fd-81d1-577eaa2ac4d3)] +interface nsPIWidgetCocoa : nsISupports +{ + // Like OS ::BringToFront, but constrains the window to its z-level + void ComeToFront(); + + // Obtain the menubar for a window + nsIMenuBar GetMenuBar(); + + // Find the displayed child sheet (if aShown) or a child sheet that + // wants to be displayed (if !aShown) + nsCocoaWindow GetChildSheet(in boolean aShown); + + // True if window is a sheet + readonly attribute boolean isSheet; + +}; // nsPIWidgetCocoa +