diff --git a/view/public/nsIView.h b/view/public/nsIView.h index 2acc2703f5f5..14678fe98c4d 100644 --- a/view/public/nsIView.h +++ b/view/public/nsIView.h @@ -426,24 +426,31 @@ public: * event handling * @param aFlags flags to be added to view */ - NS_IMETHOD SetViewFlags(PRInt32 aFlags) = 0; - - /** - * Get pointer to temporary data storage used by - * the compositor. make no assumptions about the - * data returned by this method. - * @param aPoint out paramemter for nsPoint structure - * stored in view. - * @return error status - */ - NS_IMETHOD GetScratchPoint(nsPoint **aPoint) = 0; + NS_IMETHOD SetViewFlags(PRUint32 aFlags) = 0; /** * Remove flags from view to allow customization of view behavior during * event handling * @param aFlags flags to be removed from view */ - NS_IMETHOD ClearViewFlags(PRInt32 aFlags) = 0; + NS_IMETHOD ClearViewFlags(PRUint32 aFlags) = 0; + + /** + * Get flags on view to allow customization of view behavior during + * event handling + * @param aFlags out parameter for view flags + */ + NS_IMETHOD GetViewFlags(PRUint32 *aFlags) = 0; + + /** + * Get pointer to temporary data storage used by + * the compositor. make no assumptions about the + * data returned by this method. oh yeah, and it's a hack. + * @param aPoint out paramemter for nsPoint structure + * stored in view. + * @return error status + */ + NS_IMETHOD GetScratchPoint(nsPoint **aPoint) = 0; private: NS_IMETHOD_(nsrefcnt) AddRef(void) = 0; @@ -484,8 +491,21 @@ private: //of the world. #define NS_VIEW_FLAG_JUST_PAINT 0x0080 +//the following are public flags accessed through the *ViewFlags methods. + //Flag to determine whether the view will check if events can be handled //by its children or just handle the events itself -#define NS_VIEW_FLAG_DONT_CHECK_CHILDREN 0x0001 +#define NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN 0x0001 +//the view is dying. +#define NS_VIEW_PUBLIC_FLAG_DYING 0x0002 +//the view is transparent +#define NS_VIEW_PUBLIC_FLAG_TRANSPARENT 0x0004 +//indicates that a view should not zoom values to/from widgets +#define NS_VIEW_PUBLIC_FLAG_DONT_ZOOM 0x0008 + +#define ALL_VIEW_FLAGS (NS_VIEW_FLAG_DONT_CHECK_CHILDREN | \ + NS_VIEW_FLAG_DYING | \ + NS_VIEW_FLAG_TRANSPARENT | \ + NS_VIEW_FLAG_DONT_ZOOM) #endif diff --git a/view/src/nsScrollingView.cpp b/view/src/nsScrollingView.cpp index d6c4a199903e..ae682c73bc3a 100644 --- a/view/src/nsScrollingView.cpp +++ b/view/src/nsScrollingView.cpp @@ -56,8 +56,6 @@ public: ~ScrollBarView(); NS_IMETHOD HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags, nsEventStatus &aStatus); - NS_IMETHOD SetPosition(nscoord x, nscoord y); - NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE); public: nsScrollingView *mScrollingView; @@ -97,52 +95,6 @@ NS_IMETHODIMP ScrollBarView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFl return NS_OK; } -NS_IMETHODIMP ScrollBarView :: SetPosition(nscoord x, nscoord y) -{ - mBounds.MoveTo(x, y); - - if (nsnull != mWindow) - { - nsIDeviceContext *dx; - float twipToPix; - nscoord parx = 0, pary = 0; - nsIWidget *pwidget = nsnull; - - mViewManager->GetDeviceContext(dx); - dx->GetAppUnitsToDevUnits(twipToPix); - - GetOffsetFromWidget(&parx, &pary, pwidget); - NS_IF_RELEASE(pwidget); - - mWindow->Move(NSTwipsToIntPixels((x + parx), twipToPix), - NSTwipsToIntPixels((y + pary), twipToPix)); - - NS_RELEASE(dx); - } - return NS_OK; -} - -NS_IMETHODIMP ScrollBarView :: SetDimensions(nscoord width, nscoord height, PRBool aPaint) -{ - mBounds.SizeTo(width, height); - - if (nsnull != mWindow) - { - nsIDeviceContext *dx; - float t2p; - - mViewManager->GetDeviceContext(dx); - dx->GetAppUnitsToDevUnits(t2p); - - mWindow->Resize(NSTwipsToIntPixels(width, t2p), NSTwipsToIntPixels(height, t2p), - aPaint); - - NS_RELEASE(dx); - } - return NS_OK; -} - - class CornerView : public nsView { public: @@ -555,36 +507,6 @@ NS_IMETHODIMP nsScrollingView :: SetPosition(nscoord aX, nscoord aY) return NS_OK; } -#if 0 -NS_IMETHODIMP nsScrollingView :: Paint(nsIRenderingContext& rc, const nsRect& rect, - PRUint32 aPaintFlags, PRBool &aResult) -{ - PRBool clipres = PR_FALSE; - nsRect brect; - - rc.PushState(); - - GetBounds(brect); - - //don't clip if we have a widget - if ((mVis == nsViewVisibility_kShow) && (nsnull == mWindow)) - rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres); - - if (clipres == PR_FALSE) - { - nsView::Paint(rc, rect, aPaintFlags | NS_VIEW_FLAG_CLIP_SET, clipres); - } - - rc.PopState(clipres); - - if ((clipres == PR_FALSE) && (mVis == nsViewVisibility_kShow) && (nsnull == mWindow)) - rc.SetClipRect(brect, nsClipCombine_kSubtract, clipres); - - aResult = clipres; - return NS_OK; -} -#endif - void nsScrollingView :: HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags) { nsIView *scview = nsView::GetViewFor(aEvent->widget); diff --git a/view/src/nsScrollingView.h b/view/src/nsScrollingView.h index 459972ed72c3..bfe7af25b003 100644 --- a/view/src/nsScrollingView.h +++ b/view/src/nsScrollingView.h @@ -44,8 +44,6 @@ public: NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE); NS_IMETHOD SetPosition(nscoord aX, nscoord aY); NS_IMETHOD HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags, nsEventStatus &aStatus); -// NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect, -// PRUint32 aPaintFlags, PRBool &aResult); NS_IMETHOD SetWidget(nsIWidget *aWidget); //nsIScrollableView interface diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 8786a2ec6a31..9216be74069c 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -54,10 +54,11 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent) //printf(" %d %d %d (%d,%d) \n", aEvent->widget, aEvent->widgetSupports, // aEvent->message, aEvent->point.x, aEvent->point.y); nsEventStatus result = nsEventStatus_eIgnore; - - nsIView* view = nsView::GetViewFor(aEvent->widget); - if (nsnull != view) { - nsIViewManager* vm; + nsIView *view = nsView::GetViewFor(aEvent->widget); + + if (nsnull != view) + { + nsIViewManager *vm; view->GetViewManager(vm); vm->DispatchEvent(aEvent, result); @@ -71,14 +72,13 @@ nsView :: nsView() { mVis = nsViewVisibility_kShow; mXForm = nsnull; - mVFlags = ~ALL_VIEW_FLAGS; - mEventFlags = 0; + mVFlags = 0; mOpacity = 1.0f; } nsView :: ~nsView() { - mVFlags |= VIEW_FLAG_DYING; + mVFlags |= NS_VIEW_PUBLIC_FLAG_DYING; PRInt32 numKids; GetChildCount(numKids); @@ -777,7 +777,7 @@ NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags, PRBool handledByChild = PR_FALSE; //see if any of this view's children can process the event - if (aStatus == nsEventStatus_eIgnore && !(mVFlags & NS_VIEW_FLAG_DONT_CHECK_CHILDREN)) { + if (aStatus == nsEventStatus_eIgnore && !(mVFlags & NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN)) { PRInt32 numkids; nsRect trect; nscoord x, y; @@ -1149,16 +1149,16 @@ NS_IMETHODIMP nsView :: GetOpacity(float &aOpacity) NS_IMETHODIMP nsView :: HasTransparency(PRBool &aTransparent) const { - aTransparent = (mVFlags & VIEW_FLAG_TRANSPARENT) ? PR_TRUE : PR_FALSE; + aTransparent = (mVFlags & NS_VIEW_PUBLIC_FLAG_TRANSPARENT) ? PR_TRUE : PR_FALSE; return NS_OK; } NS_IMETHODIMP nsView :: SetContentTransparency(PRBool aTransparent) { if (aTransparent == PR_TRUE) - mVFlags |= VIEW_FLAG_TRANSPARENT; + mVFlags |= NS_VIEW_PUBLIC_FLAG_TRANSPARENT; else - mVFlags &= ~VIEW_FLAG_TRANSPARENT; + mVFlags &= ~NS_VIEW_PUBLIC_FLAG_TRANSPARENT; return NS_OK; } @@ -1300,18 +1300,24 @@ void nsView :: List(FILE* out, PRInt32 aIndent) const fputs(">\n", out); } -NS_IMETHODIMP nsView :: SetViewFlags(PRInt32 aFlags) +NS_IMETHODIMP nsView :: SetViewFlags(PRUint32 aFlags) { mVFlags |= aFlags; return NS_OK; } -NS_IMETHODIMP nsView :: ClearViewFlags(PRInt32 aFlags) +NS_IMETHODIMP nsView :: ClearViewFlags(PRUint32 aFlags) { mVFlags &= ~aFlags; return NS_OK; } +NS_IMETHODIMP nsView :: GetViewFlags(PRUint32 *aFlags) +{ + *aFlags = mVFlags; + return NS_OK; +} + NS_IMETHODIMP nsView :: GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget) { nsIView *ancestor; diff --git a/view/src/nsView.h b/view/src/nsView.h index 8ffe783409da..4ef2573dca37 100644 --- a/view/src/nsView.h +++ b/view/src/nsView.h @@ -93,9 +93,10 @@ public: NS_IMETHOD SetWidget(nsIWidget *aWidget); NS_IMETHOD GetWidget(nsIWidget *&aWidget); virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; - NS_IMETHOD SetViewFlags(PRInt32 aFlags); + NS_IMETHOD SetViewFlags(PRUint32 aFlags); + NS_IMETHOD ClearViewFlags(PRUint32 aFlags); + NS_IMETHOD GetViewFlags(PRUint32 *aFlags); NS_IMETHOD GetScratchPoint(nsPoint **aPoint); - NS_IMETHOD ClearViewFlags(PRInt32 aFlags); // Helper function to get the view that's associated with a widget static nsIView* GetViewFor(nsIWidget* aWidget); @@ -121,9 +122,8 @@ protected: nsViewClip mClip; nsTransform2D *mXForm; float mOpacity; - PRInt32 mVFlags; + PRUint32 mVFlags; nsIRegion* mDirtyRegion; - PRInt32 mEventFlags; nsPoint mScratchPoint; private: @@ -131,9 +131,4 @@ private: NS_IMETHOD_(nsrefcnt) Release(void); }; -#define VIEW_FLAG_DYING 0x0001 -#define VIEW_FLAG_TRANSPARENT 0x0002 - -#define ALL_VIEW_FLAGS (VIEW_FLAG_DYING | VIEW_FLAG_TRANSPARENT) - #endif diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index eb6814bc4213..82d130aa79a9 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -36,6 +36,7 @@ static NS_DEFINE_IID(kIRegionIID, NS_IREGION_IID); static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID); static NS_DEFINE_IID(kIClipViewIID, NS_ICLIPVIEW_IID); +static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); static const PRBool gsDebug = PR_FALSE; @@ -571,9 +572,7 @@ typedef enum #define TRANS_PROPERTY_TRANS 0 #define TRANS_PROPERTY_OPACITY 1 -#ifdef SHOW_RECTS static evenodd = 0; -#endif void nsViewManager :: RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect, PRBool &aResult) { @@ -1092,7 +1091,6 @@ void nsViewManager :: RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, case BACK_TO_FRONT_OPACITY: if (rgnrect > 0) { - if (state == BACK_TO_FRONT_OPACITY) { #ifdef SHOW_RECTS @@ -1281,10 +1279,11 @@ void nsViewManager :: UpdateDirtyViews(nsIView *aView, nsRect *aParentRect) cons { nsRect pardamage; nsRect bounds; + PRUint32 flags; aView->GetBounds(bounds); - //translate parent region into child coords. + //translate parent rect into child coords. if (nsnull != aParentRect) { @@ -1600,39 +1599,39 @@ NS_IMETHODIMP nsViewManager :: DispatchEvent(nsGUIEvent *aEvent, nsEventStatus & { // The rect is in device units, and it's in the coordinate space of its // associated window. - nsRect trect = *((nsPaintEvent*)aEvent)->rect; + nsRect damrect = *((nsPaintEvent*)aEvent)->rect; float p2t; mContext->GetDevUnitsToAppUnits(p2t); - trect.ScaleRoundOut(p2t); + damrect.ScaleRoundOut(p2t); // Do an immediate refresh if (nsnull != mContext) { - nsRect vrect; + nsRect viewrect; float varea; // Check that there's actually something to paint - view->GetBounds(vrect); - varea = (float)vrect.width * vrect.height; + view->GetBounds(viewrect); + varea = (float)viewrect.width * viewrect.height; if (varea > 0.0000001f) { - nsRect rrect = trect; + nsRect arearect; PRUint32 updateFlags = 0; // Auto double buffering logic. // See if the paint region is greater than .25 the area of our view. // If so, enable double buffered painting. - rrect.IntersectRect(rrect, vrect); + arearect.IntersectRect(damrect, viewrect); - if ((((float)rrect.width * rrect.height) / varea) > 0.25f) + if ((((float)arearect.width * arearect.height) / varea) > 0.25f) updateFlags |= NS_VMREFRESH_DOUBLE_BUFFER; //printf("refreshing: view: %x, %d, %d, %d, %d\n", view, trect.x, trect.y, trect.width, trect.height); // Refresh the view - Refresh(view, ((nsPaintEvent*)aEvent)->renderingContext, &trect, updateFlags); + Refresh(view, ((nsPaintEvent*)aEvent)->renderingContext, &damrect, updateFlags); } } @@ -2356,7 +2355,9 @@ NS_IMETHODIMP nsViewManager :: GetRootScrollableView(nsIScrollableView **aScroll NS_IMETHODIMP nsViewManager :: Display(nsIView* aView) { + nsRect wrect; nsIRenderingContext *localcx = nsnull; + nsDrawingSurface ds = nsnull; nsRect trect; if (PR_FALSE == mRefreshEnabled)