Combined GetScrollBarWidth/GetScrollBarHeight into one function

GetScrollBarDimensions
This commit is contained in:
troy%netscape.com 1998-08-27 18:30:55 +00:00
Родитель 3528975f0e
Коммит 361707b894
14 изменённых файлов: 31 добавлений и 64 удалений

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

@ -77,18 +77,12 @@ NS_IMETHODIMP nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
//------------------------------------------------------------------------
float nsDeviceContextMac :: GetScrollBarWidth() const
NS_IMETHODIMP nsDeviceContextMac :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
// XXX Should we push this to widget library
return 240.0;
}
//------------------------------------------------------------------------
float nsDeviceContextMac :: GetScrollBarHeight() const
{
// XXX Should we push this to widget library
return 240.0;
aWidth = 240.0;
aHeight = 240.0;
return NS_OK;
}
//------------------------------------------------------------------------

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

@ -35,8 +35,7 @@ public:
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
virtual float GetScrollBarWidth() const;
virtual float GetScrollBarHeight() const;
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
void SetDrawingSurface(nsDrawingSurface aSurface) { mSurface = aSurface; }
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext);

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

@ -91,21 +91,14 @@ NS_IMETHODIMP nsDeviceContextUnix :: Init(nsNativeWidget aNativeWidget)
}
NS_IMETHODIMP nsDeviceContextUnix :: GetScrollBarWidth(float &aWidth) const
NS_IMETHODIMP nsDeviceContextUnix :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
// XXX Should we push this to widget library
aWidth = 240.0;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextUnix :: GetScrollBarHeight(float &aHeight) const
{
// XXX Should we push this to widget library
aHeight = 240.0;
return NS_OK;
}
nsDrawingSurface nsDeviceContextUnix :: GetDrawingSurface(nsIRenderingContext &aContext)
{
return aContext.CreateDrawingSurface(nsnull);

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

@ -67,8 +67,7 @@ public:
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD GetScrollBarWidth(float &aWidth) const;
NS_IMETHOD GetScrollBarHeight(float &aHeight) const;
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext);

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

@ -88,8 +88,8 @@ public:
virtual float GetAppUnitsToDevUnits() const = 0;
virtual float GetDevUnitsToAppUnits() const = 0;
NS_IMETHOD GetScrollBarWidth(float &aWidth) const = 0;
NS_IMETHOD GetScrollBarHeight(float &aHeight) const = 0;
//returns the scrollbar dimensions in app units
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const = 0;
//be sure to Relase() after you are done with the Get()
virtual nsIFontCache * GetFontCache() = 0;

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

@ -67,14 +67,9 @@ NS_IMETHODIMP nsDeviceContextWin::Init(nsNativeWidget aWidget)
return DeviceContextImpl::Init(aWidget);
}
NS_IMETHODIMP nsDeviceContextWin :: GetScrollBarWidth(float &aWidth) const
NS_IMETHODIMP nsDeviceContextWin :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
aWidth = ::GetSystemMetrics(SM_CXVSCROLL) * mDevUnitsToAppUnits;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin :: GetScrollBarHeight(float &aHeight) const
{
aHeight = ::GetSystemMetrics(SM_CXHSCROLL) * mDevUnitsToAppUnits;
return NS_OK;
}

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

@ -29,8 +29,7 @@ public:
NS_IMETHOD Init(nsNativeWidget aWidget);
NS_IMETHOD GetScrollBarWidth(float &aWidth) const;
NS_IMETHOD GetScrollBarHeight(float &aHeight) const;
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
//get a low level drawing surface for rendering. the rendering context
//that is passed in is used to create the drawing surface if there isn't

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

@ -55,8 +55,8 @@ nscoord PrintPreviewContext::GetPageWidth()
#else
// For testing purposes make the page width smaller than the visible
// area
float sbWidth;
mDeviceContext->GetScrollBarWidth(sbWidth);
float sbWidth, sbHeight;
mDeviceContext->GetScrollBarDimensions(sbWidth, sbHeight);
nscoord sbar = NSToCoordRound(sbWidth);
return mVisibleArea.width - sbar - 2*100;
#endif

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

@ -498,17 +498,16 @@ nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext,
aBorderPadding.right;
if (! aPresContext->IsPaginated()) {
nsIDeviceContext* dc = aPresContext->GetDeviceContext();
float sbWidth;
float sbWidth, sbHeight;
dc->GetScrollBarWidth(sbWidth);
dc->GetScrollBarDimensions(sbWidth, sbHeight);
result.width -= NSToCoordRound(sbWidth);
NS_RELEASE(dc);
}
}
// If our height is constrained then subtract for the border/padding
if (aMaxSize.height != NS_UNCONSTRAINEDSIZE) {
result.height -= aBorderPadding.top +
aBorderPadding.bottom;
result.height -= aBorderPadding.top + aBorderPadding.bottom;
}
}

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

@ -353,8 +353,8 @@ NS_METHOD RootContentFrame::Reflow(nsIPresContext& aPresContext,
nsSize pageSize(aPresContext.GetPageWidth(),
aPresContext.GetPageHeight());
nsIDeviceContext *dx = aPresContext.GetDeviceContext();
float sbWidth;
dx->GetScrollBarWidth(sbWidth);
float sbWidth, sbHeight;
dx->GetScrollBarDimensions(sbWidth, sbHeight);
PRInt32 extra = aReflowState.maxSize.width - PAGE_SPACING_TWIPS*2 -
pageSize.width - NSToCoordRound(sbWidth);
NS_RELEASE(dx);

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

@ -167,8 +167,8 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext,
// Place and size the page. If the page is narrower than our
// max width then center it horizontally
nsIDeviceContext *dx = aPresContext.GetDeviceContext();
float sbWidth;
dx->GetScrollBarWidth(sbWidth);
float sbWidth, sbHeight;
dx->GetScrollBarDimensions(sbWidth, sbHeight);
nscoord extra = aReflowState.maxSize.width - kidSize.width -
NSToCoordRound(sbWidth);
NS_RELEASE(dx);
@ -380,8 +380,8 @@ nsScrollInnerFrame::Reflow(nsIPresContext& aPresContext,
// scroll bar width), and as high as it wants to be.
nsSize maxSize;
nsIDeviceContext* dc = aPresContext.GetDeviceContext();
float sbWidth;
dc->GetScrollBarWidth(sbWidth);
float sbWidth, sbHeight;
dc->GetScrollBarDimensions(sbWidth, sbHeight);
maxSize.width = aReflowState.maxSize.width - NSToCoordRound(sbWidth);
NS_RELEASE(dc);
maxSize.height = NS_UNCONSTRAINEDSIZE;

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

@ -408,8 +408,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
nsRect trect;
float sbWidth, sbHeight;
dx->GetScrollBarWidth(sbWidth);
dx->GetScrollBarHeight(sbHeight);
dx->GetScrollBarDimensions(sbWidth, sbHeight);
trect.width = NSToCoordRound(sbWidth);
trect.x = aBounds.x + aBounds.XMost() - trect.width;
trect.height = NSToCoordRound(sbHeight);
@ -429,8 +428,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
nsRect trect = aBounds;
float sbWidth, sbHeight;
dx->GetScrollBarWidth(sbWidth);
dx->GetScrollBarHeight(sbHeight);
dx->GetScrollBarDimensions(sbWidth, sbHeight);
trect.width = NSToCoordRound(sbWidth);
trect.x += aBounds.XMost() - trect.width;
trect.height -= NSToCoordRound(sbHeight);
@ -451,8 +449,7 @@ nsresult nsScrollingView :: Init(nsIViewManager* aManager,
nsRect trect = aBounds;
float sbWidth, sbHeight;
dx->GetScrollBarWidth(sbWidth);
dx->GetScrollBarHeight(sbHeight);
dx->GetScrollBarDimensions(sbWidth, sbHeight);
trect.height = NSToCoordRound(sbHeight);
trect.y += aBounds.YMost() - trect.height;
trect.width -= NSToCoordRound(sbWidth);
@ -478,8 +475,7 @@ void nsScrollingView :: SetDimensions(nscoord width, nscoord height, PRBool aPai
nsIDeviceContext *dx = cx->GetDeviceContext();
nscoord showHorz = 0, showVert = 0;
float scrollWidthFloat, scrollHeightFloat;
dx->GetScrollBarWidth(scrollWidthFloat);
dx->GetScrollBarHeight(scrollHeightFloat);
dx->GetScrollBarDimensions(scrollWidthFloat, scrollHeightFloat);
nscoord scrollWidth = NSToCoordRound(scrollWidthFloat);
nscoord scrollHeight = NSToCoordRound(scrollHeightFloat);

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

@ -77,18 +77,12 @@ NS_IMETHODIMP nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
//------------------------------------------------------------------------
float nsDeviceContextMac :: GetScrollBarWidth() const
NS_IMETHODIMP nsDeviceContextMac :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
// XXX Should we push this to widget library
return 240.0;
}
//------------------------------------------------------------------------
float nsDeviceContextMac :: GetScrollBarHeight() const
{
// XXX Should we push this to widget library
return 240.0;
aWidth = 240.0;
aHeight = 240.0;
return NS_OK;
}
//------------------------------------------------------------------------

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

@ -35,8 +35,7 @@ public:
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
virtual float GetScrollBarWidth() const;
virtual float GetScrollBarHeight() const;
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
void SetDrawingSurface(nsDrawingSurface aSurface) { mSurface = aSurface; }
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext);