Added capability to view manager to offset its coordinate space b=32161 r=attanasi@netscape.com

git-svn-id: svn://10.0.0.236/trunk@63930 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
kmcclusk%netscape.com 2000-03-23 23:49:18 +00:00
parent ffd6d2464c
commit c62cc9846a
7 changed files with 89 additions and 7 deletions

View File

@ -58,9 +58,11 @@ public:
* Note: this instance does not hold a reference to the viewobserver
* because it holds a reference to this instance.
* @param aContext the device context to use.
* @param aX X offset of the view manager's coordinate space in twips
* @param aY Y offset of the view manager's coordinate space in twips
* @result The result of the initialization, NS_OK if no errors
*/
NS_IMETHOD Init(nsIDeviceContext* aContext) = 0;
NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0) = 0;
/**
* Get the root of the view tree.
@ -461,6 +463,16 @@ public:
NS_IMETHOD ForceUpdate() = 0;
/**
* Get view manager offset specified in nsIViewManager::Init
* @param aX x offset in twips
* @param aY y offset in twips
* @result error status
*/
NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY) = 0;
};

View File

@ -825,8 +825,20 @@ NS_IMETHODIMP nsView :: IgnoreSetPosition(PRBool aShouldIgnore)
}
// XXX End Temporary fix for Bug #19416
NS_IMETHODIMP nsView :: SetPosition(nscoord x, nscoord y)
NS_IMETHODIMP nsView :: SetPosition(nscoord aX, nscoord aY)
{
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;
}
mBounds.MoveTo(x, y);
// XXX Start Temporary fix for Bug #19416
@ -858,6 +870,7 @@ NS_IMETHODIMP nsView :: SetPosition(nscoord x, nscoord y)
NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const
{
nsIView *rootView;
mViewManager->GetRootView(rootView);
@ -866,10 +879,13 @@ NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const
*x = *y = 0;
else
{
*x = mBounds.x;
*y = mBounds.y;
}
return NS_OK;
}
@ -1511,3 +1527,16 @@ NS_IMETHODIMP nsView :: GetExtents(nsRect *aExtents)
return NS_OK;
}
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;
}

View File

@ -116,6 +116,9 @@ public:
// Helper function to get the view that's associated with a widget
static nsIView* GetViewFor(nsIWidget* aWidget);
// Helper function to determine if the view instance is the root view
PRBool IsRoot();
protected:
virtual ~nsView();
//

View File

@ -120,6 +120,8 @@ nsViewManager :: nsViewManager()
mVMCount++;
mUpdateBatchCnt = 0;
mCompositeListeners = nsnull;
mX = 0;
mY = 0;
}
nsViewManager :: ~nsViewManager()
@ -256,7 +258,7 @@ static nsresult CreateRegion(nsIComponentManager* componentManager, nsIRegion* *
// We don't hold a reference to the presentation context because it
// holds a reference to us.
NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext)
NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext, nscoord aX, nscoord aY)
{
nsresult rv;
@ -294,6 +296,9 @@ NS_IMETHODIMP nsViewManager :: Init(nsIDeviceContext* aContext)
rv = CreateRegion(componentManager, &mTRgn);
rv = CreateRegion(componentManager, &mRCRgn);
}
mX = aX;
mY = aY;
return rv;
}
@ -2547,6 +2552,15 @@ NS_IMETHODIMP nsViewManager::ForceUpdate()
return NS_OK;
}
NS_IMETHODIMP nsViewManager::GetOffset(nscoord *aX, nscoord *aY)
{
NS_ASSERTION(aX != nsnull, "aX pointer is null");
NS_ASSERTION(aY != nsnull, "aY pointer is null");
*aX = mX;
*aY = mY;
return NS_OK;
}
PRBool nsViewManager :: CreateDisplayList(nsIView *aView, PRInt32 *aIndex,
nscoord aOriginX, nscoord aOriginY, nsIView *aRealView,

View File

@ -51,7 +51,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext);
NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0);
NS_IMETHOD GetRootView(nsIView *&aView);
NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget=nsnull);
@ -138,7 +138,8 @@ public:
NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget);
NS_IMETHOD GetWidget(nsIWidget **aWidget);
NS_IMETHOD ForceUpdate();
NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY);
protected:
virtual ~nsViewManager();
@ -266,6 +267,10 @@ public:
nsIView *mRootView;
PRUint32 mFrameRate;
PRUint32 mTrueFrameRate;
protected:
nscoord mX;
nscoord mY;
};
#endif

View File

@ -122,6 +122,8 @@ nsViewManager2::nsViewManager2()
mVMCount++;
// NOTE: we use a zeroing operator new, so all data members are
// assumed to be cleared here.
mX = 0;
mY = 0;
}
nsViewManager2::~nsViewManager2()
@ -253,7 +255,7 @@ static nsresult CreateRegion(nsIComponentManager* componentManager, nsIRegion* *
// We don't hold a reference to the presentation context because it
// holds a reference to us.
NS_IMETHODIMP nsViewManager2::Init(nsIDeviceContext* aContext)
NS_IMETHODIMP nsViewManager2::Init(nsIDeviceContext* aContext, nscoord aX, nscoord aY)
{
nsresult rv;
@ -294,6 +296,9 @@ NS_IMETHODIMP nsViewManager2::Init(nsIDeviceContext* aContext)
rv = CreateRegion(componentManager, &mTRgn);
rv = CreateRegion(componentManager, &mRCRgn);
}
mX = aX;
mY = aY;
return rv;
}
@ -2121,6 +2126,15 @@ NS_IMETHODIMP nsViewManager2::ForceUpdate()
return NS_OK;
}
NS_IMETHODIMP nsViewManager2::GetOffset(nscoord *aX, nscoord *aY)
{
NS_ASSERTION(aX != nsnull, "aX pointer is null");
NS_ASSERTION(aY != nsnull, "aY pointer is null");
*aX = mX;
*aY = mY;
return NS_OK;
}
PRBool nsViewManager2::CreateDisplayList(nsIView *aView, PRInt32 *aIndex,
nscoord aOriginX, nscoord aOriginY, nsIView *aRealView,

View File

@ -53,7 +53,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext);
NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0);
NS_IMETHOD GetRootView(nsIView *&aView);
NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget=nsnull);
@ -140,6 +140,7 @@ public:
NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget);
NS_IMETHOD GetWidget(nsIWidget **aWidget);
NS_IMETHOD ForceUpdate();
NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY);
protected:
virtual ~nsViewManager2();
@ -287,6 +288,10 @@ public:
nsIView *mRootView;
PRUint32 mFrameRate;
PRUint32 mTrueFrameRate;
protected:
nscoord mX;
nscoord mY;
};
#endif /* nsViewManager2_h___ */