From cb8af6e9dd9cd4df7ca53ad609ca6b9a916dc464 Mon Sep 17 00:00:00 2001 From: "spider%netscape.com" Date: Wed, 9 Sep 1998 16:12:03 +0000 Subject: [PATCH] WIP: API change on OnResize for ViewManager support. --- .../modules/shell/src/nsCalendarContainer.cpp | 21 ++++++-------- .../ui/canvas/inc/nsCalCommandCanvas.h | 2 +- .../ui/canvas/src/nsCalCommandCanvas.cpp | 7 +++-- .../inc/nsCalMonthContextController.h | 2 +- .../src/nsCalMonthContextController.cpp | 4 +-- xpfc/canvas/inc/nsXPFCCanvas.h | 2 +- xpfc/canvas/inc/nsXPFCHTMLCanvas.h | 2 +- xpfc/canvas/public/nsIXPFCCanvas.h | 2 +- xpfc/canvas/src/nsXPFCCanvas.cpp | 28 +++++++++++++------ xpfc/canvas/src/nsXPFCCanvasManager.cpp | 4 +++ xpfc/canvas/src/nsXPFCHTMLCanvas.cpp | 4 +-- 11 files changed, 45 insertions(+), 33 deletions(-) diff --git a/calendar/modules/shell/src/nsCalendarContainer.cpp b/calendar/modules/shell/src/nsCalendarContainer.cpp index b2d2c5f38ad..bce9d10a30f 100644 --- a/calendar/modules/shell/src/nsCalendarContainer.cpp +++ b/calendar/modules/shell/src/nsCalendarContainer.cpp @@ -173,7 +173,7 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent, mRootUI->Init(); } - mRootUI->Init(aParent, aBounds,(((nsCalendarShell *)aCalendarShell)->mShellInstance->GetShellEventCallback())); + mRootUI->Init(aParent, aBounds,(((nsCalendarShell *)aCalendarShell)->mShellInstance->GetShellEventCallback())); widget_parent = mRootUI->GetWidget(); @@ -190,18 +190,21 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent, if (res != NS_OK) return res; + static NS_DEFINE_IID(kCWidgetCID, NS_CHILD_CID); + view->Init(mViewManager, aBounds, nsnull, + nsnull,//&kCWidgetCID, nsnull, - nsnull, - widget_parent->GetNativeData(NS_NATIVE_WIDGET)); + aParent->GetNativeData(NS_NATIVE_WIDGET)); mViewManager->SetRootView(view); - mViewManager->DisableRefresh(); mViewManager->SetWindowDimensions(aBounds.width, aBounds.height); + //view->GetWidget(widget_parent); + gXPFCToolkit->GetCanvasManager()->Register(mRootUI,view); } @@ -531,12 +534,13 @@ nsEventStatus nsCalendarContainer::HandleEvent(nsGUIEvent *aEvent) /* * find the canvas this event is associated with! */ - res = aEvent->widget->QueryInterface(kIXPFCCanvasIID,(void**)&canvas); if (res == NS_OK) { es = canvas->HandleEvent(aEvent); + + //mViewManager->DispatchEvent(aEvent, es); NS_RELEASE(canvas); @@ -545,13 +549,6 @@ nsEventStatus nsCalendarContainer::HandleEvent(nsGUIEvent *aEvent) if (aEvent->message == NS_SIZE) mRootUI->SetBounds(*(((nsSizeEvent*)aEvent)->windowSize)); -#if 0 - mRootUI->GetWidget()->Resize(((nsSizeEvent*)aEvent)->windowSize->x, - ((nsSizeEvent*)aEvent)->windowSize->y, - ((nsSizeEvent*)aEvent)->windowSize->width, - ((nsSizeEvent*)aEvent)->windowSize->height, - PR_FALSE); -#endif return (mRootUI->HandleEvent(aEvent)); } diff --git a/calendar/modules/ui/canvas/inc/nsCalCommandCanvas.h b/calendar/modules/ui/canvas/inc/nsCalCommandCanvas.h index 3a1dbe4eaa2..8398dacf748 100644 --- a/calendar/modules/ui/canvas/inc/nsCalCommandCanvas.h +++ b/calendar/modules/ui/canvas/inc/nsCalCommandCanvas.h @@ -40,7 +40,7 @@ public: NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent); NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); - NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); NS_IMETHOD GetClassPreferredSize(nsSize& aSize); diff --git a/calendar/modules/ui/canvas/src/nsCalCommandCanvas.cpp b/calendar/modules/ui/canvas/src/nsCalCommandCanvas.cpp index 496f2f10424..a2fb398b404 100644 --- a/calendar/modules/ui/canvas/src/nsCalCommandCanvas.cpp +++ b/calendar/modules/ui/canvas/src/nsCalCommandCanvas.cpp @@ -190,10 +190,11 @@ nsEventStatus PR_CALLBACK HandleEventTextField(nsGUIEvent *aEvent) return nsEventStatus_eIgnore; } -nsEventStatus nsCalCommandCanvas :: OnResize(nsGUIEvent *aEvent) +nsEventStatus nsCalCommandCanvas :: OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { - SetBounds(*((nsSizeEvent*)aEvent)->windowSize); - return (nsXPFCCanvas::OnResize(aEvent)); + nsRect rect(aX, aY, aWidth, aHeight); + SetBounds(rect); + return (nsXPFCCanvas::OnResize(aX, aY, aWidth, aHeight)); } nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds) diff --git a/calendar/modules/ui/controller/inc/nsCalMonthContextController.h b/calendar/modules/ui/controller/inc/nsCalMonthContextController.h index f7fa79f910a..c73d81b49a4 100644 --- a/calendar/modules/ui/controller/inc/nsCalMonthContextController.h +++ b/calendar/modules/ui/controller/inc/nsCalMonthContextController.h @@ -238,7 +238,7 @@ protected: public: NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); - NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); NS_IMETHOD_(nsEventStatus) OnLeftButtonDown(nsGUIEvent *aEvent); NS_IMETHOD_(nsEventStatus) OnLeftButtonUp(nsGUIEvent *aEvent); NS_IMETHOD_(nsEventStatus) OnMouseMove(nsGUIEvent *aEvent); diff --git a/calendar/modules/ui/controller/src/nsCalMonthContextController.cpp b/calendar/modules/ui/controller/src/nsCalMonthContextController.cpp index 26c64d02811..bd24d05e30c 100644 --- a/calendar/modules/ui/controller/src/nsCalMonthContextController.cpp +++ b/calendar/modules/ui/controller/src/nsCalMonthContextController.cpp @@ -1628,9 +1628,9 @@ nsEventStatus nsCalMonthContextController :: OnPaint(nsIRenderingContext& aRende return nsEventStatus_eConsumeNoDefault; } -nsEventStatus nsCalMonthContextController::OnResize(nsGUIEvent *aEvent) +nsEventStatus nsCalMonthContextController :: OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { - GetWidget()->Resize(0,0,((nsSizeEvent*)aEvent)->windowSize->width,((nsSizeEvent*)aEvent)->windowSize->height, PR_TRUE); + GetWidget()->Resize(0,0,aWidth,aHeight, PR_TRUE); return nsEventStatus_eConsumeNoDefault; } diff --git a/xpfc/canvas/inc/nsXPFCCanvas.h b/xpfc/canvas/inc/nsXPFCCanvas.h index e2681437180..219d81d19d2 100644 --- a/xpfc/canvas/inc/nsXPFCCanvas.h +++ b/xpfc/canvas/inc/nsXPFCCanvas.h @@ -77,7 +77,7 @@ public: NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); - NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); NS_IMETHOD_(nsEventStatus) OnMove(nsGUIEvent *aEvent); NS_IMETHOD_(nsEventStatus) OnGotFocus(nsGUIEvent *aEvent); diff --git a/xpfc/canvas/inc/nsXPFCHTMLCanvas.h b/xpfc/canvas/inc/nsXPFCHTMLCanvas.h index c39ea758eeb..b4b0c2be488 100644 --- a/xpfc/canvas/inc/nsXPFCHTMLCanvas.h +++ b/xpfc/canvas/inc/nsXPFCHTMLCanvas.h @@ -41,7 +41,7 @@ public: NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); - NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); NS_IMETHOD GetClassPreferredSize(nsSize& aSize); protected: diff --git a/xpfc/canvas/public/nsIXPFCCanvas.h b/xpfc/canvas/public/nsIXPFCCanvas.h index ac34854174e..a9b6311017c 100644 --- a/xpfc/canvas/public/nsIXPFCCanvas.h +++ b/xpfc/canvas/public/nsIXPFCCanvas.h @@ -136,7 +136,7 @@ public: * @param aEvent The GUI Event to be handled * @result nsEventStatus, status of OnResize event processing */ - NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent) = 0; + NS_IMETHOD_(nsEventStatus) OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0; /** * Handle an OnMove Message diff --git a/xpfc/canvas/src/nsXPFCCanvas.cpp b/xpfc/canvas/src/nsXPFCCanvas.cpp index d601e30dc49..dfc680244fb 100644 --- a/xpfc/canvas/src/nsXPFCCanvas.cpp +++ b/xpfc/canvas/src/nsXPFCCanvas.cpp @@ -834,7 +834,7 @@ nsEventStatus nsXPFCCanvas :: OnPaint(nsIRenderingContext& aRenderingContext, } -nsEventStatus nsXPFCCanvas :: OnResize(nsGUIEvent *aEvent) +nsEventStatus nsXPFCCanvas :: OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { //SetBounds(*((nsSizeEvent*)aEvent)->windowSize); @@ -844,15 +844,15 @@ nsEventStatus nsXPFCCanvas :: OnResize(nsGUIEvent *aEvent) mBounds.x = 0 ; mBounds.y = 0 ; } else { - mBounds.x = ((nsSizeEvent*)aEvent)->windowSize->x ; - mBounds.y = ((nsSizeEvent*)aEvent)->windowSize->y ; + mBounds.x = aX ; + mBounds.y = aY ; } - mBounds.width = ((nsSizeEvent*)aEvent)->windowSize->width ; - mBounds.height = ((nsSizeEvent*)aEvent)->windowSize->height ; + mBounds.width = aWidth ; + mBounds.height = aHeight ; mLayout->Layout(); - return (DefaultProcessing(aEvent)); + return (DefaultProcessing(nsnull)); } nsEventStatus nsXPFCCanvas :: OnLeftButtonDown(nsGUIEvent *aEvent) @@ -1228,7 +1228,12 @@ nsEventStatus nsXPFCCanvas :: ResizeChildWidgets(nsGUIEvent *aEvent) { widget = (nsIXPFCCanvas *) iterator->CurrentItem(); - widget->OnResize(aEvent); + nscoord x = ((nsSizeEvent*)aEvent)->windowSize->x; + nscoord y = ((nsSizeEvent*)aEvent)->windowSize->y; + nscoord w = ((nsSizeEvent*)aEvent)->windowSize->width; + nscoord h = ((nsSizeEvent*)aEvent)->windowSize->height; + + widget->OnResize(x,y,w,h); iterator->Next(); } @@ -1290,7 +1295,7 @@ nsEventStatus nsXPFCCanvas :: HandleEvent(nsGUIEvent *aEvent) canvas = (nsXPFCCanvas *) iterator->CurrentItem(); if (canvas->mWidget != nsnull) - mWidget->Invalidate(PR_FALSE); + canvas->mWidget->Invalidate(PR_FALSE); iterator->Next(); } @@ -1306,7 +1311,12 @@ nsEventStatus nsXPFCCanvas :: HandleEvent(nsGUIEvent *aEvent) case NS_SIZE: { - OnResize(aEvent); + nscoord x = ((nsSizeEvent*)aEvent)->windowSize->x; + nscoord y = ((nsSizeEvent*)aEvent)->windowSize->y; + nscoord w = ((nsSizeEvent*)aEvent)->windowSize->width; + nscoord h = ((nsSizeEvent*)aEvent)->windowSize->height; + + OnResize(x,y,w,h); } break; diff --git a/xpfc/canvas/src/nsXPFCCanvasManager.cpp b/xpfc/canvas/src/nsXPFCCanvasManager.cpp index 8cfab4ebe6b..31ce3a9bd1d 100644 --- a/xpfc/canvas/src/nsXPFCCanvasManager.cpp +++ b/xpfc/canvas/src/nsXPFCCanvasManager.cpp @@ -246,6 +246,8 @@ nsresult nsXPFCCanvasManager::HandleEvent(nsIView * aView, if (canvas == nsnull) return NS_OK; + aEventStatus = canvas->HandleEvent(aEvent); + return NS_OK; } @@ -268,6 +270,8 @@ nsresult nsXPFCCanvasManager::ResizeReflow(nsIView * aView, if (canvas == nsnull) return NS_OK; + canvas->OnResize(0,0,aWidth,aHeight); + return NS_OK; } diff --git a/xpfc/canvas/src/nsXPFCHTMLCanvas.cpp b/xpfc/canvas/src/nsXPFCHTMLCanvas.cpp index 4da2496fcd8..2fbab9cf01f 100644 --- a/xpfc/canvas/src/nsXPFCHTMLCanvas.cpp +++ b/xpfc/canvas/src/nsXPFCHTMLCanvas.cpp @@ -98,9 +98,9 @@ nsresult nsXPFCHTMLCanvas :: Init() return NS_OK; } -nsEventStatus nsXPFCHTMLCanvas :: OnResize(nsGUIEvent *aEvent) +nsEventStatus nsXPFCHTMLCanvas :: OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { - return (nsXPFCCanvas::OnResize(aEvent)); + return (nsXPFCCanvas::OnResize(aX, aY, aWidth, aHeight)); } nsresult nsXPFCHTMLCanvas :: SetBounds(const nsRect &aBounds)