2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#include "nsView.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsIButton.h"
|
|
|
|
#include "nsIScrollbar.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsTransform2D.h"
|
1998-04-23 21:51:43 +00:00
|
|
|
#include "nsIScrollableView.h"
|
1998-10-11 01:00:59 +00:00
|
|
|
#include "nsVoidArray.h"
|
1998-10-23 17:58:44 +00:00
|
|
|
#include "nsGfxCIID.h"
|
1998-10-15 04:55:21 +00:00
|
|
|
#include "nsIRegion.h"
|
1999-04-16 19:53:53 +00:00
|
|
|
#include "nsIClipView.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-11-14 02:51:25 +00:00
|
|
|
static NS_DEFINE_IID(kRegionCID, NS_REGION_CID);
|
|
|
|
|
1998-11-23 23:50:17 +00:00
|
|
|
//mmptemp
|
|
|
|
|
1998-08-31 19:09:55 +00:00
|
|
|
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
|
|
|
|
|
|
|
|
1998-07-11 06:17:09 +00:00
|
|
|
//#define SHOW_VIEW_BORDERS
|
1998-06-16 17:05:42 +00:00
|
|
|
//#define HIDE_ALL_WIDGETS
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//
|
|
|
|
// Main events handler
|
|
|
|
//
|
|
|
|
nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf(" %d %d %d (%d,%d) \n", aEvent->widget, aEvent->widgetSupports,
|
1998-05-29 22:44:13 +00:00
|
|
|
// aEvent->message, aEvent->point.x, aEvent->point.y);
|
1998-08-08 04:23:33 +00:00
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
1999-04-16 04:23:43 +00:00
|
|
|
nsIView *view = nsView::GetViewFor(aEvent->widget);
|
|
|
|
|
|
|
|
if (nsnull != view)
|
|
|
|
{
|
|
|
|
nsIViewManager *vm;
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
view->GetViewManager(vm);
|
1999-11-24 06:03:10 +00:00
|
|
|
vm->DispatchEvent(aEvent, &result);
|
1998-08-19 05:35:20 +00:00
|
|
|
NS_RELEASE(vm);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-01-27 23:31:15 +00:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsView)
|
1999-10-05 14:52:53 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
nsView :: nsView()
|
|
|
|
{
|
1999-10-05 14:52:53 +00:00
|
|
|
MOZ_COUNT_CTOR(nsView);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
mVis = nsViewVisibility_kShow;
|
1999-04-16 04:23:43 +00:00
|
|
|
mVFlags = 0;
|
1998-11-03 06:36:36 +00:00
|
|
|
mOpacity = 1.0f;
|
1999-07-19 19:57:30 +00:00
|
|
|
mViewManager = nsnull;
|
2000-02-02 00:58:22 +00:00
|
|
|
mCompositorFlags = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsView :: ~nsView()
|
|
|
|
{
|
1999-10-05 14:52:53 +00:00
|
|
|
MOZ_COUNT_DTOR(nsView);
|
|
|
|
|
1999-04-16 04:23:43 +00:00
|
|
|
mVFlags |= NS_VIEW_PUBLIC_FLAG_DYING;
|
1998-06-01 22:02:02 +00:00
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
PRInt32 numKids;
|
|
|
|
GetChildCount(numKids);
|
|
|
|
if (numKids > 0)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
nsIView *kid;
|
|
|
|
|
|
|
|
//nuke the kids
|
1998-08-30 19:16:11 +00:00
|
|
|
do {
|
|
|
|
GetChild(0, kid);
|
|
|
|
if (nsnull != kid)
|
|
|
|
kid->Destroy();
|
|
|
|
} while (nsnull != kid);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != mViewManager)
|
|
|
|
{
|
1998-08-28 04:56:56 +00:00
|
|
|
nsIView *rootView;
|
|
|
|
mViewManager->GetRootView(rootView);
|
2000-06-01 00:38:57 +00:00
|
|
|
|
1998-05-01 03:13:34 +00:00
|
|
|
if (nsnull != rootView)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-05-01 03:13:34 +00:00
|
|
|
if (rootView == this)
|
|
|
|
{
|
1998-08-08 04:23:33 +00:00
|
|
|
// Inform the view manager that the root view has gone away...
|
|
|
|
mViewManager->SetRootView(nsnull);
|
1998-05-01 03:13:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (nsnull != mParent)
|
1998-08-08 04:23:33 +00:00
|
|
|
{
|
1998-05-01 03:13:34 +00:00
|
|
|
mViewManager->RemoveChild(mParent, this);
|
1998-08-08 04:23:33 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-08 04:23:33 +00:00
|
|
|
}
|
1998-05-01 03:13:34 +00:00
|
|
|
else if (nsnull != mParent)
|
1998-08-08 04:23:33 +00:00
|
|
|
{
|
1998-05-01 03:13:34 +00:00
|
|
|
mParent->RemoveChild(this);
|
1998-08-08 04:23:33 +00:00
|
|
|
}
|
1998-05-01 03:13:34 +00:00
|
|
|
|
2000-06-01 00:38:57 +00:00
|
|
|
nsIView* grabbingView; //check to see if we are capturing!!!
|
|
|
|
mViewManager->GetMouseEventGrabber(grabbingView);
|
|
|
|
if (grabbingView == this)
|
|
|
|
{
|
|
|
|
PRBool boolResult;//not used
|
|
|
|
mViewManager->GrabMouseEvents(nsnull,boolResult);
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
mViewManager = nsnull;
|
|
|
|
}
|
1998-05-01 03:13:34 +00:00
|
|
|
else if (nsnull != mParent)
|
1998-08-08 04:23:33 +00:00
|
|
|
{
|
1998-05-01 03:13:34 +00:00
|
|
|
mParent->RemoveChild(this);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-08 04:23:33 +00:00
|
|
|
|
2000-08-12 19:05:52 +00:00
|
|
|
if (nsnull != mZParent)
|
|
|
|
{
|
|
|
|
mZParent->RemoveChild(this);
|
|
|
|
mZParent->Destroy();
|
|
|
|
}
|
1998-11-03 06:36:36 +00:00
|
|
|
|
2000-08-12 19:05:52 +00:00
|
|
|
// Destroy and release the widget
|
1998-11-03 06:36:36 +00:00
|
|
|
if (nsnull != mWindow)
|
|
|
|
{
|
1998-08-08 04:23:33 +00:00
|
|
|
mWindow->SetClientData(nsnull);
|
|
|
|
mWindow->Destroy();
|
|
|
|
NS_RELEASE(mWindow);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-10-15 04:55:21 +00:00
|
|
|
NS_IF_RELEASE(mDirtyRegion);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-09-12 03:23:09 +00:00
|
|
|
nsresult nsView::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-08-10 00:56:40 +00:00
|
|
|
|
|
|
|
*aInstancePtr = nsnull;
|
|
|
|
|
1999-09-12 03:23:09 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIView)) || (aIID.Equals(NS_GET_IID(nsISupports)))) {
|
1998-04-13 20:24:54 +00:00
|
|
|
*aInstancePtr = (void*)(nsIView*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsView::AddRef()
|
|
|
|
{
|
1998-08-08 04:23:33 +00:00
|
|
|
NS_WARNING("not supported for views");
|
|
|
|
return 1;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsView::Release()
|
|
|
|
{
|
1998-08-08 04:23:33 +00:00
|
|
|
NS_WARNING("not supported for views");
|
|
|
|
return 1;
|
|
|
|
}
|
1998-05-01 03:13:34 +00:00
|
|
|
|
1998-08-08 04:23:33 +00:00
|
|
|
nsIView* nsView::GetViewFor(nsIWidget* aWidget)
|
|
|
|
{
|
|
|
|
nsIView* view = nsnull;
|
|
|
|
void* clientData;
|
1998-06-01 22:02:02 +00:00
|
|
|
|
1998-12-16 03:37:56 +00:00
|
|
|
NS_PRECONDITION(nsnull != aWidget, "null widget ptr");
|
|
|
|
|
1998-08-08 04:23:33 +00:00
|
|
|
// The widget's client data points back to the owning view
|
1999-01-08 21:31:56 +00:00
|
|
|
if (aWidget && NS_SUCCEEDED(aWidget->GetClientData(clientData))) {
|
1998-08-08 04:23:33 +00:00
|
|
|
view = (nsIView*)clientData;
|
2001-04-11 05:29:36 +00:00
|
|
|
|
|
|
|
nsISupports* data = (nsISupports*)clientData;
|
|
|
|
|
|
|
|
if (nsnull != data) {
|
|
|
|
if (NS_FAILED(data->QueryInterface(NS_GET_IID(nsIView), (void **)&view))) {
|
|
|
|
return nsnull; // return null if client data isn't a view
|
|
|
|
}
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-08 04:23:33 +00:00
|
|
|
return view;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
|
|
|
|
const nsRect &aBounds,
|
1998-10-27 03:36:49 +00:00
|
|
|
const nsIView *aParent,
|
1998-08-30 19:16:11 +00:00
|
|
|
nsViewVisibility aVisibilityFlag)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf(" \n callback=%d data=%d", aWidgetCreateCallback, aCallbackData);
|
1998-04-13 20:24:54 +00:00
|
|
|
NS_PRECONDITION(nsnull != aManager, "null ptr");
|
|
|
|
if (nsnull == aManager) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (nsnull != mViewManager) {
|
|
|
|
return NS_ERROR_ALREADY_INITIALIZED;
|
|
|
|
}
|
1998-08-08 04:23:33 +00:00
|
|
|
// we don't hold a reference to the view manager
|
1998-04-13 20:24:54 +00:00
|
|
|
mViewManager = aManager;
|
|
|
|
|
2000-04-25 04:43:11 +00:00
|
|
|
mChildClip.mLeft = 0;
|
|
|
|
mChildClip.mRight = 0;
|
|
|
|
mChildClip.mTop = 0;
|
|
|
|
mChildClip.mBottom = 0;
|
1998-04-28 19:16:24 +00:00
|
|
|
|
1998-07-07 21:51:57 +00:00
|
|
|
SetBounds(aBounds);
|
|
|
|
|
1998-10-27 03:36:49 +00:00
|
|
|
//temporarily set it...
|
|
|
|
SetParent((nsIView *)aParent);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
SetVisibility(aVisibilityFlag);
|
|
|
|
|
1998-10-27 05:57:18 +00:00
|
|
|
// XXX Don't clear this or we hork the scrolling view when creating the clip
|
|
|
|
// view's widget. It needs to stay set and later the view manager will reset it
|
|
|
|
// when the view is inserted into the view hierarchy...
|
|
|
|
#if 0
|
1998-10-27 03:36:49 +00:00
|
|
|
//clear this again...
|
|
|
|
SetParent(nsnull);
|
1998-10-27 05:57:18 +00:00
|
|
|
#endif
|
1998-10-27 03:36:49 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: Destroy()
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
delete this;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetViewManager(nsIViewManager *&aViewMgr) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mViewManager);
|
1998-08-30 19:16:11 +00:00
|
|
|
aViewMgr = mViewManager;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
|
1998-10-11 01:00:59 +00:00
|
|
|
PRUint32 aPaintFlags, PRBool &aResult)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-08-24 19:54:46 +00:00
|
|
|
NS_ASSERTION(aPaintFlags & NS_VIEW_FLAG_JUST_PAINT, "Only simple painting supported by nsView");
|
|
|
|
// Just paint, assume compositor knows what it's doing.
|
|
|
|
if (nsnull != mClientData) {
|
|
|
|
nsCOMPtr<nsIViewObserver> observer;
|
|
|
|
if (NS_OK == mViewManager->GetViewObserver(*getter_AddRefs(observer))) {
|
|
|
|
observer->Paint((nsIView *)this, rc, rect);
|
|
|
|
}
|
|
|
|
}
|
2000-01-25 01:53:34 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsIRegion& region,
|
|
|
|
PRUint32 aPaintFlags, PRBool &aResult)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
// XXX apply region to rc
|
|
|
|
// XXX get bounding rect from region
|
1998-08-28 03:05:23 +00:00
|
|
|
//if (nsnull != mClientData)
|
|
|
|
//{
|
|
|
|
// nsIViewObserver *obs;
|
|
|
|
//
|
|
|
|
// if (NS_OK == mViewManager->GetViewObserver(obs))
|
|
|
|
// {
|
|
|
|
// obs->Paint((nsIView *)this, rc, rect, aPaintFlags);
|
|
|
|
// NS_RELEASE(obs);
|
|
|
|
// }
|
|
|
|
//}
|
1998-08-30 19:16:11 +00:00
|
|
|
aResult = PR_FALSE;
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
nsEventStatus* aStatus, PRBool aForceHandle, PRBool& aHandled)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-11-24 06:03:10 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aStatus);
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf(" %d %d %d %d (%d,%d) \n", this, event->widget, event->widgetSupports,
|
1998-05-29 22:44:13 +00:00
|
|
|
// event->message, event->point.x, event->point.y);
|
1999-05-04 23:23:35 +00:00
|
|
|
|
|
|
|
// Hold a refcount to the observer. The continued existence of the observer will
|
|
|
|
// delay deletion of this view hierarchy should the event want to cause its
|
|
|
|
// destruction in, say, some JavaScript event handler.
|
2001-05-17 18:37:50 +00:00
|
|
|
nsCOMPtr<nsIViewObserver> obs;
|
|
|
|
mViewManager->GetViewObserver(*getter_AddRefs(obs));
|
1999-05-04 23:23:35 +00:00
|
|
|
|
2001-04-01 01:01:33 +00:00
|
|
|
// if accessible event pass directly to the view observer
|
2001-05-17 18:37:50 +00:00
|
|
|
if (event->eventStructType == NS_ACCESSIBLE_EVENT || event->message == NS_CONTEXTMENU_KEY) {
|
2001-04-01 01:01:33 +00:00
|
|
|
if (obs)
|
|
|
|
obs->HandleEvent((nsIView *)this, event, aStatus, aForceHandle, aHandled);
|
2001-05-17 18:37:50 +00:00
|
|
|
return NS_OK;
|
2001-04-01 01:01:33 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 06:03:10 +00:00
|
|
|
*aStatus = nsEventStatus_eIgnore;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//see if any of this view's children can process the event
|
2001-05-17 18:37:50 +00:00
|
|
|
if ( !(mVFlags & NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN) ) {
|
2000-08-31 02:31:17 +00:00
|
|
|
PRInt32 numkids;
|
1998-04-13 20:24:54 +00:00
|
|
|
nsRect trect;
|
|
|
|
nscoord x, y;
|
|
|
|
|
2000-08-31 02:31:17 +00:00
|
|
|
GetChildCount(numkids);
|
1998-04-13 20:24:54 +00:00
|
|
|
x = event->point.x;
|
|
|
|
y = event->point.y;
|
|
|
|
|
2000-08-31 02:31:17 +00:00
|
|
|
for (PRInt32 cnt = 0; cnt < numkids && !aHandled; cnt++)
|
|
|
|
{
|
|
|
|
nsIView *pKid;
|
|
|
|
GetChild(cnt, pKid);
|
|
|
|
if (!pKid) break;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
pKid->GetBounds(trect);
|
|
|
|
|
2000-04-13 21:56:27 +00:00
|
|
|
if (PointIsInside(*pKid, x, y))
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
//the x, y position of the event in question
|
|
|
|
//is inside this child view, so give it the
|
|
|
|
//opportunity to handle the event
|
|
|
|
|
|
|
|
event->point.x -= trect.x;
|
|
|
|
event->point.y -= trect.y;
|
|
|
|
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
pKid->HandleEvent(event, NS_VIEW_FLAG_CHECK_CHILDREN, aStatus, PR_FALSE, aHandled);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
event->point.x += trect.x;
|
|
|
|
event->point.y += trect.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-19 22:14:11 +00:00
|
|
|
// if the child handled the event(Ignore) or it handled the event but still wants
|
|
|
|
// default behavor(ConsumeDoDefault) and we are visible then pass the event down the view's
|
|
|
|
// frame hierarchy. -EDV
|
2000-01-19 22:34:47 +00:00
|
|
|
if (!aHandled && mVis == nsViewVisibility_kShow)
|
1999-05-19 22:14:11 +00:00
|
|
|
{
|
|
|
|
//if no child's bounds matched the event or we consumed but still want
|
|
|
|
//default behavior check the view itself. -EDV
|
|
|
|
if (nsnull != mClientData && nsnull != obs) {
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
obs->HandleEvent((nsIView *)this, event, aStatus, aForceHandle, aHandled);
|
1999-05-19 22:14:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* XXX Just some debug code to see what event are being thrown away because
|
|
|
|
we are not visible. -EDV
|
|
|
|
else if (mVis == nsViewVisibility_kHide) {
|
|
|
|
nsIFrame* frame = (nsIFrame*)mClientData;
|
|
|
|
printf("Throwing away=%d %d %d (%d,%d) \n", this, event->widget,
|
|
|
|
event->message, event->point.x, event->point.y);
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
1998-08-28 03:05:23 +00:00
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-12-14 22:21:58 +00:00
|
|
|
// XXX Start Temporary fix for Bug #19416
|
|
|
|
NS_IMETHODIMP nsView :: IgnoreSetPosition(PRBool aShouldIgnore)
|
|
|
|
{
|
|
|
|
mShouldIgnoreSetPosition = aShouldIgnore;
|
|
|
|
// resync here
|
|
|
|
if (!mShouldIgnoreSetPosition) {
|
|
|
|
SetPosition(mBounds.x, mBounds.y);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
// XXX End Temporary fix for Bug #19416
|
1999-05-19 22:14:11 +00:00
|
|
|
|
2000-03-23 23:49:18 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetPosition(nscoord aX, nscoord aY)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-03-23 23:49:18 +00:00
|
|
|
nscoord x = aX;
|
|
|
|
nscoord y = aY;
|
|
|
|
if (IsRoot()) {
|
|
|
|
// Add view manager's coordinate offset to the root view
|
|
|
|
// This allows the view manager to offset it's coordinate space
|
|
|
|
// while allowing layout to assume it's coordinate space origin is (0,0)
|
|
|
|
nscoord offsetX;
|
|
|
|
nscoord offsetY;
|
|
|
|
mViewManager->GetOffset(&offsetX, &offsetY);
|
|
|
|
x += offsetX;
|
|
|
|
y += offsetY;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
mBounds.MoveTo(x, y);
|
|
|
|
|
1999-12-14 22:21:58 +00:00
|
|
|
// XXX Start Temporary fix for Bug #19416
|
|
|
|
if (mShouldIgnoreSetPosition) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
// XXX End Temporary fix for Bug #19416
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != mWindow)
|
|
|
|
{
|
2000-04-03 03:55:38 +00:00
|
|
|
// see if we are caching our widget changes. Yes?
|
|
|
|
// mark us as changed. Later we will actually move the
|
|
|
|
// widget.
|
|
|
|
PRBool caching = PR_FALSE;
|
|
|
|
mViewManager->IsCachingWidgetChanges(&caching);
|
|
|
|
if (caching) {
|
|
|
|
mVFlags |= NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-28 04:56:56 +00:00
|
|
|
nsIDeviceContext *dx;
|
1998-08-28 03:05:23 +00:00
|
|
|
float scale;
|
|
|
|
nsIWidget *pwidget = nsnull;
|
1998-10-19 00:44:28 +00:00
|
|
|
nscoord parx = 0, pary = 0;
|
1998-06-04 02:02:08 +00:00
|
|
|
|
1998-08-28 04:56:56 +00:00
|
|
|
mViewManager->GetDeviceContext(dx);
|
1998-08-28 03:05:23 +00:00
|
|
|
dx->GetAppUnitsToDevUnits(scale);
|
1998-10-19 00:44:28 +00:00
|
|
|
NS_RELEASE(dx);
|
1998-06-04 02:02:08 +00:00
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
GetOffsetFromWidget(&parx, &pary, pwidget);
|
1998-06-16 17:05:42 +00:00
|
|
|
NS_IF_RELEASE(pwidget);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-10-19 00:44:28 +00:00
|
|
|
mWindow->Move(NSTwipsToIntPixels((x + parx), scale),
|
|
|
|
NSTwipsToIntPixels((y + pary), scale));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
NS_IMETHODIMP nsView :: SynchWidgetSizePosition()
|
|
|
|
{
|
2000-04-11 23:55:15 +00:00
|
|
|
// if the widget was moved or resized
|
2000-04-03 03:55:38 +00:00
|
|
|
if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED || mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED)
|
|
|
|
{
|
|
|
|
nsIDeviceContext *dx;
|
|
|
|
float t2p;
|
|
|
|
|
|
|
|
mViewManager->GetDeviceContext(dx);
|
|
|
|
dx->GetAppUnitsToDevUnits(t2p);
|
|
|
|
NS_RELEASE(dx);
|
2001-03-21 05:32:22 +00:00
|
|
|
#if 0
|
2000-04-25 07:10:48 +00:00
|
|
|
/* You would think that doing a move and resize all in one operation would
|
|
|
|
* be faster but its not. Something is really broken here. So I'm comenting
|
2000-05-26 06:42:29 +00:00
|
|
|
* this out for now
|
2001-03-21 05:32:22 +00:00
|
|
|
*/
|
2000-04-11 23:55:15 +00:00
|
|
|
// if we moved and resized do it all in one shot
|
|
|
|
if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED && mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED)
|
2000-04-03 03:55:38 +00:00
|
|
|
{
|
2000-05-26 06:42:29 +00:00
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
nscoord parx = 0, pary = 0;
|
|
|
|
nsIWidget *pwidget = nsnull;
|
|
|
|
|
|
|
|
GetOffsetFromWidget(&parx, &pary, pwidget);
|
|
|
|
NS_IF_RELEASE(pwidget);
|
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
PRInt32 x = NSTwipsToIntPixels(mBounds.x + parx, t2p);
|
|
|
|
PRInt32 y = NSTwipsToIntPixels(mBounds.y + pary, t2p);
|
|
|
|
PRInt32 width = NSTwipsToIntPixels(mBounds.width, t2p);
|
|
|
|
PRInt32 height = NSTwipsToIntPixels(mBounds.height, t2p);
|
|
|
|
|
|
|
|
nsRect bounds;
|
|
|
|
mWindow->GetBounds(bounds);
|
|
|
|
if (bounds.x == x && bounds.y == y )
|
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
|
|
|
|
else if (bounds.width == width && bounds.height == bounds.height)
|
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
|
|
|
|
else {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%d) SetBounds(%d,%d,%d,%d)\n", this, x, y, width, height);
|
2000-04-25 07:10:48 +00:00
|
|
|
mWindow->Resize(x,y,width,height, PR_TRUE);
|
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
|
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2001-03-21 05:32:22 +00:00
|
|
|
#endif
|
2000-04-25 07:10:48 +00:00
|
|
|
// if we just resized do it
|
|
|
|
if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED)
|
|
|
|
{
|
|
|
|
|
|
|
|
PRInt32 width = NSTwipsToIntPixels(mBounds.width, t2p);
|
|
|
|
PRInt32 height = NSTwipsToIntPixels(mBounds.height, t2p);
|
|
|
|
|
|
|
|
nsRect bounds;
|
|
|
|
mWindow->GetBounds(bounds);
|
|
|
|
|
2000-05-26 06:42:29 +00:00
|
|
|
if (bounds.width != width || bounds.height != bounds.height) {
|
2001-03-21 05:32:22 +00:00
|
|
|
#ifdef DEBUG_evaughan
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%d) Resize(%d,%d)\n", this, width, height);
|
2001-03-21 05:32:22 +00:00
|
|
|
#endif
|
2000-04-25 07:10:48 +00:00
|
|
|
mWindow->Resize(width,height, PR_TRUE);
|
2000-05-26 06:42:29 +00:00
|
|
|
}
|
2000-04-03 03:55:38 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
|
2000-04-25 07:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED) {
|
|
|
|
// if we just moved do it.
|
|
|
|
nscoord parx = 0, pary = 0;
|
|
|
|
nsIWidget *pwidget = nsnull;
|
|
|
|
|
|
|
|
GetOffsetFromWidget(&parx, &pary, pwidget);
|
|
|
|
NS_IF_RELEASE(pwidget);
|
|
|
|
|
|
|
|
PRInt32 x = NSTwipsToIntPixels(mBounds.x + parx, t2p);
|
|
|
|
PRInt32 y = NSTwipsToIntPixels(mBounds.y + pary, t2p);
|
|
|
|
|
|
|
|
nsRect bounds;
|
|
|
|
mWindow->GetBounds(bounds);
|
|
|
|
|
2000-05-26 06:42:29 +00:00
|
|
|
if (bounds.x != x || bounds.y != y) {
|
2001-03-21 05:32:22 +00:00
|
|
|
#ifdef DEBUG_evaughan
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%d) Move(%d,%d)\n", this, x, y);
|
2001-03-21 05:32:22 +00:00
|
|
|
#endif
|
2000-04-25 07:10:48 +00:00
|
|
|
mWindow->Move(x,y);
|
2000-05-26 06:42:29 +00:00
|
|
|
}
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
|
2000-04-25 07:10:48 +00:00
|
|
|
}
|
2000-04-03 03:55:38 +00:00
|
|
|
}
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-03-23 23:49:18 +00:00
|
|
|
|
1998-08-28 04:56:56 +00:00
|
|
|
nsIView *rootView;
|
1998-07-07 21:51:57 +00:00
|
|
|
|
1998-08-28 04:56:56 +00:00
|
|
|
mViewManager->GetRootView(rootView);
|
1998-10-11 01:00:59 +00:00
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
if (this == ((const nsView*)rootView))
|
1998-07-07 21:51:57 +00:00
|
|
|
*x = *y = 0;
|
|
|
|
else
|
|
|
|
{
|
2000-03-23 23:49:18 +00:00
|
|
|
|
1998-07-07 21:51:57 +00:00
|
|
|
*x = mBounds.x;
|
|
|
|
*y = mBounds.y;
|
2000-03-23 23:49:18 +00:00
|
|
|
|
1998-07-07 21:51:57 +00:00
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
2000-03-23 23:49:18 +00:00
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetDimensions(nscoord width, nscoord height, PRBool aPaint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-07-27 04:37:35 +00:00
|
|
|
if ((mBounds.width == width) &&
|
|
|
|
(mBounds.height == height))
|
|
|
|
return NS_OK;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
mBounds.SizeTo(width, height);
|
|
|
|
|
1999-02-16 00:57:06 +00:00
|
|
|
#if 0
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != mParent)
|
|
|
|
{
|
1998-04-23 21:51:43 +00:00
|
|
|
nsIScrollableView *scroller;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-23 21:51:43 +00:00
|
|
|
static NS_DEFINE_IID(kscroller, NS_ISCROLLABLEVIEW_IID);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-10-19 00:44:28 +00:00
|
|
|
// XXX The scrolled view is a child of the clip view which is a child of
|
|
|
|
// the scrolling view. It's kind of yucky the way this works. A parent
|
|
|
|
// notification that the child's size changed would be cleaner.
|
|
|
|
nsIView *grandParent;
|
|
|
|
mParent->GetParent(grandParent);
|
|
|
|
if ((nsnull != grandParent) &&
|
|
|
|
(NS_OK == grandParent->QueryInterface(kscroller, (void **)&scroller)))
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-04-23 23:21:37 +00:00
|
|
|
scroller->ComputeContainerSize();
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-04-23 21:51:43 +00:00
|
|
|
}
|
1999-02-16 00:57:06 +00:00
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-23 21:51:43 +00:00
|
|
|
if (nsnull != mWindow)
|
|
|
|
{
|
2000-04-03 03:55:38 +00:00
|
|
|
PRBool caching = PR_FALSE;
|
|
|
|
mViewManager->IsCachingWidgetChanges(&caching);
|
|
|
|
if (caching) {
|
|
|
|
mVFlags |= NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-28 04:56:56 +00:00
|
|
|
nsIDeviceContext *dx;
|
1998-08-28 03:05:23 +00:00
|
|
|
float t2p;
|
1998-04-23 21:51:43 +00:00
|
|
|
|
1998-08-28 04:56:56 +00:00
|
|
|
mViewManager->GetDeviceContext(dx);
|
1998-08-28 03:05:23 +00:00
|
|
|
dx->GetAppUnitsToDevUnits(t2p);
|
|
|
|
|
1998-07-31 23:34:45 +00:00
|
|
|
mWindow->Resize(NSTwipsToIntPixels(width, t2p), NSTwipsToIntPixels(height, t2p),
|
1998-08-26 21:24:58 +00:00
|
|
|
aPaint);
|
1998-04-23 21:51:43 +00:00
|
|
|
|
1998-08-28 03:05:23 +00:00
|
|
|
NS_RELEASE(dx);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetDimensions(nscoord *width, nscoord *height) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
*width = mBounds.width;
|
|
|
|
*height = mBounds.height;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetBounds(const nsRect &aBounds, PRBool aPaint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
SetPosition(aBounds.x, aBounds.y);
|
1998-08-26 21:24:58 +00:00
|
|
|
SetDimensions(aBounds.width, aBounds.height, aPaint);
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
SetPosition(aX, aY);
|
1998-08-26 21:24:58 +00:00
|
|
|
SetDimensions(aWidth, aHeight, aPaint);
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetBounds(nsRect &aBounds) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-07-19 19:57:30 +00:00
|
|
|
nsIView *rootView = nsnull;
|
|
|
|
|
|
|
|
NS_ASSERTION(mViewManager, "mViewManager is null!");
|
|
|
|
if (!mViewManager) {
|
|
|
|
aBounds.x = aBounds.y = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-07-07 21:51:57 +00:00
|
|
|
|
1998-08-28 04:56:56 +00:00
|
|
|
mViewManager->GetRootView(rootView);
|
1998-04-13 20:24:54 +00:00
|
|
|
aBounds = mBounds;
|
1998-07-07 21:51:57 +00:00
|
|
|
|
|
|
|
if ((nsIView *)this == rootView)
|
|
|
|
aBounds.x = aBounds.y = 0;
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-04-13 21:56:27 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetChildClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-02-05 04:11:55 +00:00
|
|
|
NS_PRECONDITION(aLeft <= aRight && aTop <= aBottom, "bad clip values");
|
2000-04-25 04:43:11 +00:00
|
|
|
mChildClip.mLeft = aLeft;
|
|
|
|
mChildClip.mTop = aTop;
|
|
|
|
mChildClip.mRight = aRight;
|
|
|
|
mChildClip.mBottom = aBottom;
|
2000-04-13 21:56:27 +00:00
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-04-13 21:56:27 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-04-25 04:43:11 +00:00
|
|
|
*aLeft = mChildClip.mLeft;
|
|
|
|
*aTop = mChildClip.mTop;
|
|
|
|
*aRight = mChildClip.mRight;
|
|
|
|
*aBottom = mChildClip.mBottom;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetVisibility(nsViewVisibility aVisibility)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-12-14 22:21:58 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
mVis = aVisibility;
|
|
|
|
|
2001-05-04 03:02:55 +00:00
|
|
|
if (aVisibility == nsViewVisibility_kHide)
|
|
|
|
{
|
|
|
|
nsIView* grabbingView; //check to see if we are grabbing events
|
|
|
|
mViewManager->GetMouseEventGrabber(grabbingView);
|
|
|
|
if (grabbingView == this)
|
|
|
|
{
|
|
|
|
//if yes then we must release them before we become hidden and can't get them
|
|
|
|
PRBool boolResult;//not used
|
|
|
|
mViewManager->GrabMouseEvents(nsnull,boolResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != mWindow)
|
|
|
|
{
|
1998-06-16 17:05:42 +00:00
|
|
|
#ifndef HIDE_ALL_WIDGETS
|
1998-04-13 20:24:54 +00:00
|
|
|
if (mVis == nsViewVisibility_kShow)
|
|
|
|
mWindow->Show(PR_TRUE);
|
|
|
|
else
|
1998-06-16 17:05:42 +00:00
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
mWindow->Show(PR_FALSE);
|
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetVisibility(nsViewVisibility &aVisibility) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aVisibility = mVis;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-12 19:05:52 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetZParent(nsIView *aZParent)
|
|
|
|
{
|
|
|
|
mZParent = aZParent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsView :: GetZParent(nsIView *&aZParent) const
|
|
|
|
{
|
|
|
|
aZParent = mZParent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-23 23:26:54 +00:00
|
|
|
NS_IMETHODIMP nsView::SetZIndex(PRInt32 aZIndex)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-09-23 23:26:54 +00:00
|
|
|
mZindex = aZIndex;
|
|
|
|
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
mWindow->SetZIndex(aZIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-09-23 23:26:54 +00:00
|
|
|
NS_IMETHODIMP nsView::GetZIndex(PRInt32 &aZIndex) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aZIndex = mZindex;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-09-23 23:26:54 +00:00
|
|
|
NS_IMETHODIMP nsView::SetAutoZIndex(PRBool aAutoZIndex)
|
|
|
|
{
|
|
|
|
if (aAutoZIndex)
|
|
|
|
mVFlags |= NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX;
|
|
|
|
else
|
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsView::GetAutoZIndex(PRBool &aAutoZIndex) const
|
|
|
|
{
|
|
|
|
aAutoZIndex = ((mVFlags & NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX) != 0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-25 01:53:34 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsView::SetFloating(PRBool aFloatingView)
|
|
|
|
{
|
|
|
|
if (aFloatingView)
|
|
|
|
mVFlags |= NS_VIEW_PUBLIC_FLAG_FLOATING;
|
|
|
|
else
|
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_FLOATING;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// recursively make all sub-views "floating" grr.
|
|
|
|
nsIView *child = mFirstChild;
|
|
|
|
while (nsnull != child) {
|
|
|
|
child->SetFloating(aFloatingView);
|
|
|
|
child->GetNextSibling(child);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsView::GetFloating(PRBool &aFloatingView) const
|
|
|
|
{
|
|
|
|
aFloatingView = ((mVFlags & NS_VIEW_PUBLIC_FLAG_FLOATING) != 0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetParent(nsIView *aParent)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
mParent = aParent;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetParent(nsIView *&aParent) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aParent = mParent;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetNextSibling(nsIView *&aNextSibling) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aNextSibling = mNextSibling;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView::SetNextSibling(nsIView* aView)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
mNextSibling = aView;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: InsertChild(nsIView *child, nsIView *sibling)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != child, "null ptr");
|
|
|
|
if (nsnull != child)
|
|
|
|
{
|
|
|
|
if (nsnull != sibling)
|
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIView* siblingParent;
|
|
|
|
sibling->GetParent(siblingParent);
|
|
|
|
NS_ASSERTION(siblingParent == this, "tried to insert view with invalid sibling");
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
//insert after sibling
|
1998-08-30 19:16:11 +00:00
|
|
|
nsIView* siblingNextSibling;
|
|
|
|
sibling->GetNextSibling(siblingNextSibling);
|
|
|
|
child->SetNextSibling(siblingNextSibling);
|
1998-04-13 20:24:54 +00:00
|
|
|
sibling->SetNextSibling(child);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child->SetNextSibling(mFirstChild);
|
|
|
|
mFirstChild = child;
|
|
|
|
}
|
|
|
|
child->SetParent(this);
|
|
|
|
mNumKids++;
|
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: RemoveChild(nsIView *child)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != child, "null ptr");
|
|
|
|
|
|
|
|
if (nsnull != child)
|
|
|
|
{
|
|
|
|
nsIView* prevKid = nsnull;
|
|
|
|
nsIView* kid = mFirstChild;
|
|
|
|
PRBool found = PR_FALSE;
|
|
|
|
while (nsnull != kid) {
|
|
|
|
if (kid == child) {
|
|
|
|
if (nsnull != prevKid) {
|
1998-08-30 19:16:11 +00:00
|
|
|
nsIView* kidNextSibling;
|
|
|
|
kid->GetNextSibling(kidNextSibling);
|
|
|
|
prevKid->SetNextSibling(kidNextSibling);
|
1998-04-13 20:24:54 +00:00
|
|
|
} else {
|
1998-08-30 19:16:11 +00:00
|
|
|
kid->GetNextSibling(mFirstChild);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
child->SetParent(nsnull);
|
|
|
|
mNumKids--;
|
|
|
|
found = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
1998-05-01 03:13:34 +00:00
|
|
|
prevKid = kid;
|
1998-08-30 19:16:11 +00:00
|
|
|
kid->GetNextSibling(kid);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
NS_ASSERTION(found, "tried to remove non child");
|
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetChildCount(PRInt32 &aCount) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aCount = mNumKids;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetChild(PRInt32 index, nsIView *&aChild) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(!(index > mNumKids), "bad index");
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
aChild = nsnull;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (index < mNumKids)
|
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aChild = mFirstChild;
|
|
|
|
for (PRInt32 cnt = 0; (cnt < index) && (nsnull != aChild); cnt++) {
|
|
|
|
aChild->GetNextSibling(aChild);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetOpacity(float opacity)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-04-28 19:16:24 +00:00
|
|
|
mOpacity = opacity;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetOpacity(float &aOpacity) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aOpacity = mOpacity;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-11 01:00:59 +00:00
|
|
|
NS_IMETHODIMP nsView :: HasTransparency(PRBool &aTransparent) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-04-16 04:23:43 +00:00
|
|
|
aTransparent = (mVFlags & NS_VIEW_PUBLIC_FLAG_TRANSPARENT) ? PR_TRUE : PR_FALSE;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-06-03 22:49:45 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetContentTransparency(PRBool aTransparent)
|
1998-06-03 22:49:45 +00:00
|
|
|
{
|
|
|
|
if (aTransparent == PR_TRUE)
|
1999-04-16 04:23:43 +00:00
|
|
|
mVFlags |= NS_VIEW_PUBLIC_FLAG_TRANSPARENT;
|
1998-06-03 22:49:45 +00:00
|
|
|
else
|
1999-04-16 04:23:43 +00:00
|
|
|
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_TRANSPARENT;
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetClientData(void *aData)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-28 03:05:23 +00:00
|
|
|
mClientData = aData;
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetClientData(void *&aData) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
aData = mClientData;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-11-04 04:14:10 +00:00
|
|
|
NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID,
|
|
|
|
nsWidgetInitData *aWidgetInitData,
|
1999-08-26 14:41:18 +00:00
|
|
|
nsNativeWidget aNative,
|
2001-10-31 05:06:31 +00:00
|
|
|
PRBool aEnableDragDrop,
|
|
|
|
PRBool aResetVisibility)
|
1998-11-04 04:14:10 +00:00
|
|
|
{
|
|
|
|
nsIDeviceContext *dx;
|
|
|
|
nsRect trect = mBounds;
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
NS_IF_RELEASE(mWindow);
|
|
|
|
|
|
|
|
mViewManager->GetDeviceContext(dx);
|
|
|
|
dx->GetAppUnitsToDevUnits(scale);
|
|
|
|
|
|
|
|
trect *= scale;
|
|
|
|
|
|
|
|
if (NS_OK == LoadWidget(aWindowIID))
|
|
|
|
{
|
1998-11-14 01:58:34 +00:00
|
|
|
PRBool usewidgets;
|
|
|
|
|
|
|
|
dx->SupportsNativeWidgets(usewidgets);
|
|
|
|
|
|
|
|
if (PR_TRUE == usewidgets)
|
1998-11-04 04:14:10 +00:00
|
|
|
{
|
1998-11-14 01:58:34 +00:00
|
|
|
if (aNative)
|
|
|
|
mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nsIWidget *parent;
|
|
|
|
GetOffsetFromWidget(nsnull, nsnull, parent);
|
|
|
|
mWindow->Create(parent, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
|
|
|
NS_IF_RELEASE(parent);
|
|
|
|
}
|
1999-08-26 14:41:18 +00:00
|
|
|
if (aEnableDragDrop) {
|
|
|
|
mWindow->EnableDragDrop(PR_TRUE);
|
|
|
|
}
|
1999-09-23 23:26:54 +00:00
|
|
|
|
|
|
|
// propagate the z-index to the widget.
|
|
|
|
mWindow->SetZIndex(mZindex);
|
1998-11-04 04:14:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//make sure visibility state is accurate
|
|
|
|
|
2001-10-31 05:06:31 +00:00
|
|
|
if (aResetVisibility) {
|
|
|
|
nsViewVisibility vis;
|
|
|
|
|
|
|
|
GetVisibility(vis);
|
|
|
|
SetVisibility(vis);
|
|
|
|
}
|
1998-11-04 04:14:10 +00:00
|
|
|
|
|
|
|
NS_RELEASE(dx);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsView :: SetWidget(nsIWidget *aWidget)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mWindow);
|
|
|
|
mWindow = aWidget;
|
|
|
|
|
|
|
|
if (nsnull != mWindow)
|
|
|
|
{
|
|
|
|
NS_ADDREF(mWindow);
|
|
|
|
mWindow->SetClientData((void *)this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetWidget(nsIWidget *&aWidget) const
|
1998-11-04 04:14:10 +00:00
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mWindow);
|
|
|
|
aWidget = mWindow;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-14 02:51:25 +00:00
|
|
|
NS_IMETHODIMP nsView::HasWidget(PRBool *aHasWidget) const
|
|
|
|
{
|
|
|
|
*aHasWidget = (mWindow != nsnull);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
//
|
|
|
|
// internal window creation functions
|
|
|
|
//
|
|
|
|
nsresult nsView :: LoadWidget(const nsCID &aClassIID)
|
|
|
|
{
|
1999-11-14 02:51:25 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(aClassIID, nsnull, NS_GET_IID(nsIWidget), (void**)&mWindow);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-11-14 02:51:25 +00:00
|
|
|
if (NS_OK == rv) {
|
1998-08-08 04:23:33 +00:00
|
|
|
// Set the widget's client data
|
|
|
|
mWindow->SetClientData((void*)this);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-11-14 02:51:25 +00:00
|
|
|
NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-05 09:02:52 +00:00
|
|
|
PRInt32 i;
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
1998-06-04 20:02:30 +00:00
|
|
|
fprintf(out, "%p ", this);
|
|
|
|
if (nsnull != mWindow) {
|
|
|
|
nsRect windowBounds;
|
1999-03-18 21:04:00 +00:00
|
|
|
nsRect nonclientBounds;
|
|
|
|
float p2t;
|
|
|
|
nsIDeviceContext *dx;
|
|
|
|
mViewManager->GetDeviceContext(dx);
|
|
|
|
dx->GetDevUnitsToAppUnits(p2t);
|
|
|
|
NS_RELEASE(dx);
|
1998-11-04 21:46:00 +00:00
|
|
|
mWindow->GetClientBounds(windowBounds);
|
1999-03-18 21:04:00 +00:00
|
|
|
windowBounds *= p2t;
|
|
|
|
mWindow->GetBounds(nonclientBounds);
|
|
|
|
nonclientBounds *= p2t;
|
1999-04-19 23:22:53 +00:00
|
|
|
nsrefcnt widgetRefCnt = mWindow->AddRef() - 1;
|
|
|
|
mWindow->Release();
|
|
|
|
fprintf(out, "(widget=%p[%d] pos={%d,%d,%d,%d}) ",
|
|
|
|
mWindow, widgetRefCnt,
|
1999-03-18 21:04:00 +00:00
|
|
|
nonclientBounds.x, nonclientBounds.y,
|
1998-06-04 20:02:30 +00:00
|
|
|
windowBounds.width, windowBounds.height);
|
|
|
|
}
|
1998-07-07 21:51:57 +00:00
|
|
|
nsRect brect;
|
|
|
|
GetBounds(brect);
|
1999-03-18 21:04:00 +00:00
|
|
|
fprintf(out, "{%d,%d,%d,%d}",
|
|
|
|
brect.x, brect.y, brect.width, brect.height);
|
1998-10-11 01:00:59 +00:00
|
|
|
PRBool hasTransparency;
|
|
|
|
HasTransparency(hasTransparency);
|
|
|
|
fprintf(out, " z=%d vis=%d opc=%1.3f tran=%d clientData=%p <\n", mZindex, mVis, mOpacity, hasTransparency, mClientData);
|
1998-04-13 20:24:54 +00:00
|
|
|
nsIView* kid = mFirstChild;
|
|
|
|
while (nsnull != kid) {
|
|
|
|
kid->List(out, aIndent + 1);
|
1998-08-30 19:16:11 +00:00
|
|
|
kid->GetNextSibling(kid);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-05 09:02:52 +00:00
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
1998-04-13 20:24:54 +00:00
|
|
|
fputs(">\n", out);
|
1999-11-14 02:51:25 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-04-16 04:23:43 +00:00
|
|
|
NS_IMETHODIMP nsView :: SetViewFlags(PRUint32 aFlags)
|
1999-02-01 22:45:59 +00:00
|
|
|
{
|
1999-03-02 22:43:26 +00:00
|
|
|
mVFlags |= aFlags;
|
1999-02-01 22:45:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-16 04:23:43 +00:00
|
|
|
NS_IMETHODIMP nsView :: ClearViewFlags(PRUint32 aFlags)
|
1999-03-03 01:59:50 +00:00
|
|
|
{
|
|
|
|
mVFlags &= ~aFlags;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-23 17:44:48 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetViewFlags(PRUint32 *aFlags) const
|
1999-04-16 04:23:43 +00:00
|
|
|
{
|
|
|
|
*aFlags = mVFlags;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHODIMP nsView :: GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
nsIView *ancestor;
|
2000-01-26 23:04:40 +00:00
|
|
|
aWidget = nsnull;
|
1998-08-30 19:16:11 +00:00
|
|
|
|
1998-10-15 04:55:21 +00:00
|
|
|
// XXX aDx and aDy are OUT parameters and so we should initialize them
|
|
|
|
// to 0 rather than relying on the caller to do so...
|
1998-08-30 19:16:11 +00:00
|
|
|
GetParent(ancestor);
|
1998-06-16 17:05:42 +00:00
|
|
|
while (nsnull != ancestor)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
ancestor->GetWidget(aWidget);
|
|
|
|
if (nsnull != aWidget)
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-06-16 17:05:42 +00:00
|
|
|
if ((nsnull != aDx) && (nsnull != aDy))
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-06-16 17:05:42 +00:00
|
|
|
nscoord offx, offy;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-06-16 17:05:42 +00:00
|
|
|
ancestor->GetPosition(&offx, &offy);
|
|
|
|
|
|
|
|
*aDx += offx;
|
|
|
|
*aDy += offy;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
ancestor->GetParent(ancestor);
|
1998-06-16 17:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-01-26 23:04:40 +00:00
|
|
|
|
|
|
|
if (nsnull == aWidget) {
|
|
|
|
// The root view doesn't have a widget
|
|
|
|
// but maybe the view manager does.
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
GetViewManager(*getter_AddRefs(vm));
|
|
|
|
vm->GetWidget(&aWidget);
|
|
|
|
}
|
|
|
|
|
1998-08-30 19:16:11 +00:00
|
|
|
return NS_OK;
|
1998-06-16 17:05:42 +00:00
|
|
|
}
|
|
|
|
|
1999-11-14 02:51:25 +00:00
|
|
|
NS_IMETHODIMP nsView::GetDirtyRegion(nsIRegion *&aRegion) const
|
1998-10-15 04:55:21 +00:00
|
|
|
{
|
1999-11-14 02:51:25 +00:00
|
|
|
if (nsnull == mDirtyRegion) {
|
|
|
|
// The view doesn't have a dirty region so create one
|
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kRegionCID,
|
|
|
|
nsnull,
|
|
|
|
NS_GET_IID(nsIRegion),
|
|
|
|
(void**) &mDirtyRegion);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
rv = mDirtyRegion->Init();
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
1998-10-15 04:55:21 +00:00
|
|
|
|
1999-11-14 02:51:25 +00:00
|
|
|
aRegion = mDirtyRegion;
|
|
|
|
NS_ADDREF(aRegion);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-10-15 04:55:21 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 22:10:31 +00:00
|
|
|
|
2000-02-02 00:58:22 +00:00
|
|
|
NS_IMETHODIMP nsView::SetCompositorFlags(PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
mCompositorFlags = aFlags;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-09 22:10:31 +00:00
|
|
|
|
2000-02-02 00:58:22 +00:00
|
|
|
NS_IMETHODIMP nsView::GetCompositorFlags(PRUint32 *aFlags)
|
|
|
|
{
|
|
|
|
NS_ASSERTION((aFlags != nsnull), "no flags");
|
|
|
|
*aFlags = mCompositorFlags;
|
|
|
|
return NS_OK;
|
1999-03-09 22:10:31 +00:00
|
|
|
}
|
1999-04-16 04:50:02 +00:00
|
|
|
|
|
|
|
static void calc_extents(nsIView *view, nsRect *extents, nscoord ox, nscoord oy)
|
|
|
|
{
|
1999-04-16 19:53:53 +00:00
|
|
|
nsIView *kid;
|
|
|
|
nsRect bounds;
|
|
|
|
nsIClipView *cview;
|
1999-04-16 04:50:02 +00:00
|
|
|
|
2000-08-24 19:54:46 +00:00
|
|
|
view->GetChild(0, kid);
|
|
|
|
while (nsnull != kid)
|
1999-04-16 04:50:02 +00:00
|
|
|
{
|
|
|
|
kid->GetBounds(bounds);
|
|
|
|
|
|
|
|
bounds.x += ox;
|
|
|
|
bounds.y += oy;
|
|
|
|
|
1999-04-16 05:19:45 +00:00
|
|
|
extents->UnionRect(*extents, bounds);
|
1999-04-16 04:50:02 +00:00
|
|
|
|
1999-04-16 19:53:53 +00:00
|
|
|
cview = nsnull;
|
|
|
|
|
1999-09-12 03:23:09 +00:00
|
|
|
kid->QueryInterface(NS_GET_IID(nsIClipView), (void **)&cview);
|
1999-04-16 19:53:53 +00:00
|
|
|
|
|
|
|
if (!cview)
|
|
|
|
calc_extents(kid, extents, bounds.x, bounds.y);
|
2000-08-24 19:54:46 +00:00
|
|
|
|
|
|
|
kid->GetNextSibling(kid);
|
1999-04-16 04:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsView :: GetExtents(nsRect *aExtents)
|
|
|
|
{
|
|
|
|
GetBounds(*aExtents);
|
|
|
|
|
|
|
|
aExtents->x = 0;
|
|
|
|
aExtents->y = 0;
|
|
|
|
|
|
|
|
calc_extents(this, aExtents, 0, 0);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-03-23 23:49:18 +00:00
|
|
|
|
|
|
|
PRBool nsView :: IsRoot()
|
|
|
|
{
|
|
|
|
nsIView *rootView;
|
|
|
|
|
|
|
|
NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()");
|
|
|
|
mViewManager->GetRootView(rootView);
|
|
|
|
if (rootView == this) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2000-04-13 21:56:27 +00:00
|
|
|
|
|
|
|
PRBool nsView::PointIsInside(nsIView& aView, nscoord x, nscoord y) const
|
|
|
|
{
|
|
|
|
nsRect clippedRect;
|
|
|
|
PRBool empty;
|
|
|
|
PRBool clipped;
|
|
|
|
aView.GetClippedRect(clippedRect, clipped, empty);
|
|
|
|
if (PR_TRUE == empty) {
|
|
|
|
// Rect is completely clipped out so point can not
|
|
|
|
// be inside it.
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check to see if the point is within the clipped rect.
|
|
|
|
if (clippedRect.Contains(x, y)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, PRBool& aEmpty) const
|
|
|
|
{
|
|
|
|
// Keep track of the view's offset
|
|
|
|
// from its ancestor.
|
|
|
|
nscoord ancestorX = 0;
|
|
|
|
nscoord ancestorY = 0;
|
|
|
|
|
|
|
|
aEmpty = PR_FALSE;
|
|
|
|
aIsClipped = PR_FALSE;
|
|
|
|
|
|
|
|
GetBounds(aClippedRect);
|
|
|
|
nsIView* parentView;
|
|
|
|
GetParent(parentView);
|
|
|
|
|
|
|
|
// Walk all of the way up the views to see if any
|
|
|
|
// ancestor sets the NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN
|
|
|
|
while (parentView) {
|
|
|
|
PRUint32 flags;
|
|
|
|
parentView->GetViewFlags(&flags);
|
|
|
|
if (flags & NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN) {
|
|
|
|
aIsClipped = PR_TRUE;
|
|
|
|
// Adjust for clip specified by ancestor
|
|
|
|
nscoord clipLeft;
|
|
|
|
nscoord clipTop;
|
|
|
|
nscoord clipRight;
|
|
|
|
nscoord clipBottom;
|
|
|
|
parentView->GetChildClip(&clipLeft, &clipTop, &clipRight, &clipBottom);
|
|
|
|
nsRect clipRect;
|
|
|
|
//Offset the cliprect by the amount the child offsets from the parent
|
|
|
|
clipRect.x = clipLeft + ancestorX;
|
|
|
|
clipRect.y = clipTop + ancestorY;
|
|
|
|
clipRect.width = clipRight - clipLeft;
|
|
|
|
clipRect.height = clipBottom - clipTop;
|
|
|
|
PRBool overlap = aClippedRect.IntersectRect(clipRect, aClippedRect);
|
|
|
|
if (!overlap) {
|
|
|
|
aEmpty = PR_TRUE; // Does not intersect so the rect is empty.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect bounds;
|
|
|
|
parentView->GetBounds(bounds);
|
|
|
|
ancestorX -= bounds.x;
|
|
|
|
ancestorY -= bounds.y;
|
|
|
|
|
|
|
|
parentView->GetParent(parentView);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|