view no longer shows a scrollbar when we can't scroll.

added GetScrolledView().
This commit is contained in:
michaelp 1998-04-23 21:51:43 +00:00
Родитель bf7e14549f
Коммит cbfb8c143d
4 изменённых файлов: 66 добавлений и 45 удалений

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

@ -53,6 +53,13 @@ public:
* @result coordinate in twips
*/
virtual PRInt32 GetVisibleOffset(void) = 0;
/**
* Get the view that we are scrolling within the
* scrolling view.
* @result child view
*/
virtual nsIView * GetScrolledView(void) = 0;
};
#endif

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

@ -47,6 +47,16 @@ ScrollBarView :: ~ScrollBarView()
void ScrollBarView :: SetDimensions(nscoord width, nscoord height)
{
mBounds.SizeTo(width, height);
if (nsnull != mWindow)
{
nsIPresContext *px = mViewManager->GetPresContext();
float t2p = px->GetTwipsToPixels();
mWindow->Resize(NS_TO_INT_ROUND(t2p * width), NS_TO_INT_ROUND(t2p * height));
NS_RELEASE(px);
}
}
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
@ -140,8 +150,6 @@ void nsScrollingView :: SetPosition(nscoord x, nscoord y)
void nsScrollingView :: SetDimensions(nscoord width, nscoord height)
{
PRInt32 owidth, oheight;
nsIWidget *win;
nsRect trect;
nsIPresContext *cx;
nsIDeviceContext *dx;
@ -153,32 +161,19 @@ void nsScrollingView :: SetDimensions(nscoord width, nscoord height)
cx = mViewManager->GetPresContext();
dx = cx->GetDeviceContext();
mScrollBarView->GetDimensions(&owidth, &oheight);
mScrollBarView->SetDimensions(owidth, height);
mScrollBarView->GetDimensions(&trect.width, &trect.height);
mScrollBarView->SetPosition(width - NS_TO_INT_ROUND(dx->GetScrollBarWidth()), 0);
trect.height = height;
trect.x = width - NS_TO_INT_ROUND(dx->GetScrollBarWidth());
trect.y = 0;
win = mScrollBarView->GetWidget();
mScrollBarView->SetBounds(trect);
if (nsnull != win)
{
nsRect trect;
win->GetBounds(trect);
//compute new bounds
trect.x = NS_TO_INT_ROUND((width - NS_TO_INT_ROUND(dx->GetScrollBarWidth())) * cx->GetTwipsToPixels());
trect.y = 0;
trect.height = NS_TO_INT_ROUND(height * cx->GetTwipsToPixels());
win->Resize(trect.x, trect.y, trect.width, trect.height);
NS_RELEASE(win);
}
//this will fix the size of the thumb when we resize the root window
SetContainerSize(mSize);
//this will fix the size of the thumb when we resize the root window,
//but unfortunately it will also cause scrollbar flashing. so long as
//all resize operations happen through the viewmanager, this is not
//an issue. we'll see. MMP
// SetContainerSize(mSize);
NS_RELEASE(dx);
NS_RELEASE(cx);
@ -281,7 +276,7 @@ void nsScrollingView :: SetContainerSize(nscoord aSize)
//we need to be able to scroll
scroll->Enable(PR_TRUE);
mScrollBarView->SetVisibility(nsViewVisibility_kShow);
//now update the scroller position for the new size
@ -298,7 +293,7 @@ void nsScrollingView :: SetContainerSize(nscoord aSize)
NS_RELEASE(px);
}
else
scroll->Enable(PR_FALSE);
mScrollBarView->SetVisibility(nsViewVisibility_kHide);
scroll->Release();
}
@ -348,3 +343,23 @@ void nsScrollingView :: AdjustChildWidgets(nscoord aDx, nscoord aDy)
}
}
}
nsIView * nsScrollingView :: GetScrolledView(void)
{
PRInt32 numkids;
nsIView *retview = nsnull;
numkids = GetChildCount();
for (PRInt32 cnt = 0; cnt < numkids; cnt++)
{
retview = GetChild(cnt);
if (retview != mScrollBarView)
break;
else
retview = nsnull;
}
return retview;
}

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

@ -59,6 +59,8 @@ public:
virtual void SetVisibleOffset(PRInt32 aOffset);
virtual PRInt32 GetVisibleOffset();
virtual nsIView * GetScrolledView(void);
protected:
PRInt32 mSize;
PRInt32 mOffset;

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

@ -30,6 +30,7 @@
#include "nsRepository.h"
#include "nsIRenderingContext.h"
#include "nsTransform2D.h"
#include "nsIScrollableView.h"
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
@ -478,35 +479,31 @@ void nsView :: GetPosition(nscoord *x, nscoord *y)
*y = mBounds.y;
}
#include "nsScrollingView.h"
void nsView :: SetDimensions(nscoord width, nscoord height)
{
mBounds.SizeTo(width, height);
//XXX this is a hack. pretend you don't see it.
//it will go away soon, i promise. MMP
if (nsnull != mParent)
{
nsScrollingView *root = (nsScrollingView *)mViewManager->GetRootView();
nsIScrollableView *scroller;
if (mParent == root)
static NS_DEFINE_IID(kscroller, NS_ISCROLLABLEVIEW_IID);
if (NS_OK == mParent->QueryInterface(kscroller, (void **)&scroller))
{
root->SetContainerSize(mBounds.height);
scroller->SetContainerSize(mBounds.height);
NS_RELEASE(scroller);
}
}
if (nsnull != mWindow)
{
nsIPresContext *px = mViewManager->GetPresContext();
float t2p = px->GetTwipsToPixels();
mWindow->Resize(NS_TO_INT_ROUND(t2p * width), NS_TO_INT_ROUND(t2p * height));
if (nsnull != mWindow)
{
nsIPresContext *px = mViewManager->GetPresContext();
float t2p = px->GetTwipsToPixels();
mWindow->Resize(NS_TO_INT_ROUND(t2p * width), NS_TO_INT_ROUND(t2p * height));
NS_RELEASE(px);
}
NS_RELEASE(root);
NS_RELEASE(px);
}
}