зеркало из https://github.com/mozilla/gecko-dev.git
view no longer shows a scrollbar when we can't scroll.
added GetScrolledView().
This commit is contained in:
Родитель
bf7e14549f
Коммит
cbfb8c143d
|
@ -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);
|
||||
|
||||
win = mScrollBarView->GetWidget();
|
||||
|
||||
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.height = height;
|
||||
trect.x = width - NS_TO_INT_ROUND(dx->GetScrollBarWidth());
|
||||
trect.y = 0;
|
||||
trect.height = NS_TO_INT_ROUND(height * cx->GetTwipsToPixels());
|
||||
|
||||
win->Resize(trect.x, trect.y, trect.width, trect.height);
|
||||
mScrollBarView->SetBounds(trect);
|
||||
|
||||
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,22 +479,21 @@ 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)
|
||||
|
@ -505,9 +505,6 @@ void nsView :: SetDimensions(nscoord width, nscoord height)
|
|||
|
||||
NS_RELEASE(px);
|
||||
}
|
||||
|
||||
NS_RELEASE(root);
|
||||
}
|
||||
}
|
||||
|
||||
void nsView :: GetDimensions(nscoord *width, nscoord *height)
|
||||
|
|
Загрузка…
Ссылка в новой задаче