when a view is the root, it's position will now always be 0, 0.

This commit is contained in:
michaelp 1998-07-07 21:51:57 +00:00
Родитель bcb4633b7a
Коммит f1f586a80e
5 изменённых файлов: 77 добавлений и 41 удалений

Просмотреть файл

@ -198,7 +198,7 @@ public:
* Called to get the dimensions and position of the view.
* @param aBounds out parameter for bounds
*/
virtual void GetBounds(nsRect &aBounds) = 0;
virtual void GetBounds(nsRect &aBounds) const = 0;
/**
* Called to indicate that the clip of the view has been changed.

Просмотреть файл

@ -207,18 +207,21 @@ PRBool CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
if (mVis == nsViewVisibility_kShow)
{
nscoord xoff, yoff;
nsRect brect;
rc.PushState();
GetScrollOffset(&xoff, &yoff);
rc.Translate(xoff, yoff);
clipres = rc.SetClipRect(mBounds, nsClipCombine_kIntersect);
GetBounds(brect);
clipres = rc.SetClipRect(brect, nsClipCombine_kIntersect);
if (clipres == PR_FALSE)
{
rc.SetColor(NS_RGB(192, 192, 192));
rc.FillRect(mBounds);
rc.FillRect(brect);
if (PR_TRUE == mShowQuality)
{
@ -226,14 +229,14 @@ PRBool CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
//display quality indicator
rc.Translate(mBounds.x, mBounds.y);
rc.Translate(brect.x, brect.y);
rc.SetColor(NS_RGB(0, 0, 0));
rc.FillEllipse(nscoord(mBounds.width * 0.15f),
nscoord(mBounds.height * 0.15f),
NS_TO_INT_ROUND(mBounds.width * 0.7f),
NS_TO_INT_ROUND(mBounds.height * 0.7f));
rc.FillEllipse(nscoord(brect.width * 0.15f),
nscoord(brect.height * 0.15f),
NS_TO_INT_ROUND(brect.width * 0.7f),
NS_TO_INT_ROUND(brect.height * 0.7f));
if (mQuality == nsContentQuality_kGood)
rc.SetColor(NS_RGB(0, 255, 0));
@ -246,10 +249,10 @@ PRBool CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
//something funny happens on windows when the *right* numbers are
//used. MMP
rc.FillEllipse(NS_TO_INT_ROUND(mBounds.width * 0.23f),
NS_TO_INT_ROUND(mBounds.height * 0.23f),
nscoord(mBounds.width * 0.46f),
nscoord(mBounds.height * 0.46f));
rc.FillEllipse(NS_TO_INT_ROUND(brect.width * 0.23f),
NS_TO_INT_ROUND(brect.height * 0.23f),
nscoord(brect.width * 0.46f),
nscoord(brect.height * 0.46f));
bcolor = tcolor = rc.GetColor();
@ -261,10 +264,10 @@ PRBool CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
rc.SetColor(tcolor);
rc.FillEllipse(NS_TO_INT_ROUND(mBounds.width * 0.34f),
NS_TO_INT_ROUND(mBounds.height * 0.34f),
nscoord(mBounds.width * 0.28f),
nscoord(mBounds.height * 0.28f));
rc.FillEllipse(NS_TO_INT_ROUND(brect.width * 0.34f),
NS_TO_INT_ROUND(brect.height * 0.34f),
nscoord(brect.width * 0.28f),
nscoord(brect.height * 0.28f));
tcolor = NS_RGB((int)min(NS_GET_R(bcolor) + 120, 255),
(int)min(NS_GET_G(bcolor) + 120, 255),
@ -272,10 +275,10 @@ PRBool CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
rc.SetColor(tcolor);
rc.FillEllipse(NS_TO_INT_ROUND(mBounds.width * 0.32f),
NS_TO_INT_ROUND(mBounds.height * 0.32f),
nscoord(mBounds.width * 0.17f),
nscoord(mBounds.height * 0.17f));
rc.FillEllipse(NS_TO_INT_ROUND(brect.width * 0.32f),
NS_TO_INT_ROUND(brect.height * 0.32f),
nscoord(brect.width * 0.17f),
nscoord(brect.height * 0.17f));
}
}
@ -283,7 +286,7 @@ PRBool CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
if (clipres == PR_FALSE)
{
nsRect xrect = mBounds;
nsRect xrect = brect;
xrect.x += xoff;
xrect.y += yoff;
@ -532,11 +535,14 @@ PRBool nsScrollingView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
PRUint32 aPaintFlags, nsIView *aBackstop)
{
PRBool clipres = PR_FALSE;
nsRect brect;
rc.PushState();
GetBounds(brect);
if (mVis == nsViewVisibility_kShow)
clipres = rc.SetClipRect(mBounds, nsClipCombine_kIntersect);
clipres = rc.SetClipRect(brect, nsClipCombine_kIntersect);
if (clipres == PR_FALSE)
{
@ -547,7 +553,7 @@ PRBool nsScrollingView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
clipres = rc.PopState();
if ((clipres == PR_FALSE) && (mVis == nsViewVisibility_kShow) && (nsnull == mWindow))
clipres = rc.SetClipRect(mBounds, nsClipCombine_kSubtract);
clipres = rc.SetClipRect(brect, nsClipCombine_kSubtract);
return clipres;
}

Просмотреть файл

@ -289,8 +289,6 @@ nsresult nsView :: Init(nsIViewManager* aManager,
NS_ADDREF(aManager);
mBounds = aBounds;
if (aClip != nsnull)
mClip = *aClip;
else
@ -307,6 +305,8 @@ nsresult nsView :: Init(nsIViewManager* aManager,
// assign the parent view
SetParent(aParent);
SetBounds(aBounds);
// check if a real window has to be created
if (aWindowCIID)
{
@ -371,19 +371,23 @@ PRBool nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
}
else if (mVis == nsViewVisibility_kShow)
{
nsRect brect;
GetBounds(brect);
if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom))
{
nsRect crect;
crect.x = mClip.mLeft + mBounds.x;
crect.y = mClip.mTop + mBounds.y;
crect.x = mClip.mLeft + brect.x;
crect.y = mClip.mTop + brect.y;
crect.width = mClip.mRight - mClip.mLeft;
crect.height = mClip.mBottom - mClip.mTop;
clipres = rc.SetClipRect(crect, nsClipCombine_kIntersect);
}
else if (this != pRoot)
clipres = rc.SetClipRect(mBounds, nsClipCombine_kIntersect);
clipres = rc.SetClipRect(brect, nsClipCombine_kIntersect);
}
if (nsnull != mXForm)
@ -394,7 +398,11 @@ PRBool nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
if (clipres == PR_FALSE)
{
rc.Translate(mBounds.x, mBounds.y);
nscoord posx, posy;
GetPosition(&posx, &posy);
rc.Translate(posx, posy);
PRInt32 numkids = GetChildCount();
@ -506,8 +514,8 @@ PRBool nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
else
{
x = y = 0;
w = mBounds.width;
h = mBounds.height;
GetDimensions(&w, &h);
if (nsnull != mWindow)
rc.SetColor(NS_RGB(0, 255, 0));
@ -537,19 +545,23 @@ PRBool nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
// if ((clipres == PR_FALSE) && (mVis == nsViewVisibility_kShow))
if (!clipwasset && (clipres == PR_FALSE) && (mVis == nsViewVisibility_kShow) && (nsnull == mWindow))
{
nsRect brect;
GetBounds(brect);
if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom))
{
nsRect crect;
crect.x = mClip.mLeft + mBounds.x;
crect.y = mClip.mTop + mBounds.y;
crect.x = mClip.mLeft + brect.x;
crect.y = mClip.mTop + brect.y;
crect.width = mClip.mRight - mClip.mLeft;
crect.height = mClip.mBottom - mClip.mTop;
clipres = rc.SetClipRect(crect, nsClipCombine_kSubtract);
}
else if (this != pRoot)
clipres = rc.SetClipRect(mBounds, nsClipCombine_kSubtract);
clipres = rc.SetClipRect(brect, nsClipCombine_kSubtract);
}
NS_RELEASE(pRoot);
@ -570,7 +582,6 @@ nsEventStatus nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags)
{
//printf(" %d %d %d %d (%d,%d) \n", this, event->widget, event->widgetSupports,
// event->message, event->point.x, event->point.y);
nsIScrollbar *scroll;
nsEventStatus retval = nsEventStatus_eIgnore;
//see if any of this view's children can process the event
@ -699,8 +710,17 @@ void nsView :: SetPosition(nscoord x, nscoord y)
void nsView :: GetPosition(nscoord *x, nscoord *y)
{
*x = mBounds.x;
*y = mBounds.y;
nsIView *rootView = mViewManager->GetRootView();
if (this == rootView)
*x = *y = 0;
else
{
*x = mBounds.x;
*y = mBounds.y;
}
NS_IF_RELEASE(rootView);
}
void nsView :: SetDimensions(nscoord width, nscoord height)
@ -750,9 +770,16 @@ void nsView :: SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight
SetDimensions(aWidth, aHeight);
}
void nsView :: GetBounds(nsRect &aBounds)
void nsView :: GetBounds(nsRect &aBounds) const
{
nsIView *rootView = mViewManager->GetRootView();
aBounds = mBounds;
if ((nsIView *)this == rootView)
aBounds.x = aBounds.y = 0;
NS_IF_RELEASE(rootView);
}
void nsView :: SetClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom)
@ -987,7 +1014,9 @@ void nsView :: List(FILE* out, PRInt32 aIndent) const
windowBounds.x, windowBounds.y,
windowBounds.width, windowBounds.height);
}
out << mBounds;
nsRect brect;
GetBounds(brect);
out << brect;
fprintf(out, " z=%d vis=%d opc=%1.3f <\n", mZindex, mVis, mOpacity);
nsIView* kid = mFirstChild;
while (nsnull != kid) {

Просмотреть файл

@ -65,7 +65,7 @@ public:
virtual void GetDimensions(nscoord *width, nscoord *height);
virtual void SetBounds(const nsRect &aBounds);
virtual void SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void GetBounds(nsRect &aBounds);
virtual void GetBounds(nsRect &aBounds) const;
virtual void SetClip(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual PRBool GetClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom);
virtual void SetVisibility(nsViewVisibility visibility);

Просмотреть файл

@ -100,7 +100,8 @@ static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
#undef VIEWER_UI
//#undef VIEWER_UI
#define VIEWER_UI
#undef INSET_WEBWIDGET
#ifdef VIEWER_UI