mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 10:54:33 +00:00
More changes to nsIDeviceContext interface
This commit is contained in:
parent
f138b8254d
commit
cfeab4e543
@ -198,8 +198,10 @@ nsresult nsRenderingContextMac :: CommonInit()
|
||||
//((nsDeviceContextMac *)mContext)->InstallColormap();
|
||||
|
||||
mFontCache = mContext->GetFontCache();
|
||||
mP2T = mContext->GetDevUnitsToAppUnits();
|
||||
mTMatrix->AddScale(mContext->GetAppUnitsToDevUnits(),mContext->GetAppUnitsToDevUnits());
|
||||
mContext->GetDevUnitsToAppUnits(mP2T);
|
||||
float app2dev;
|
||||
mContext->GetAppUnitsToDevUnits(app2dev);
|
||||
mTMatrix->AddScale(app2dev, app2dev);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,9 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX)
|
||||
char * nsFontMetricsUnix::PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired)
|
||||
{
|
||||
int idx;
|
||||
PRInt32 desiredpix = NSToIntRound(mContext->GetAppUnitsToDevUnits() * desired);
|
||||
float app2dev;
|
||||
mContext->GetAppUnitsToDevUnits(app2dev);
|
||||
PRInt32 desiredpix = NSToIntRound(app2dev * desired);
|
||||
XFontStruct *curfont;
|
||||
PRInt32 closestmin = -1, minidx;
|
||||
|
||||
@ -239,7 +241,8 @@ void nsFontMetricsUnix::RealizeFont()
|
||||
mContext->GetNativeWidget(widget);
|
||||
mFontInfo = ::XQueryFont(XtDisplay((Widget)widget), mFontHandle);
|
||||
|
||||
float f = mContext->GetDevUnitsToAppUnits();
|
||||
float f;
|
||||
mContext->GetDevUnitsToAppUnits(f);
|
||||
|
||||
mAscent = nscoord(mFontInfo->ascent * f);
|
||||
mDescent = nscoord(mFontInfo->descent * f);
|
||||
@ -289,7 +292,9 @@ nscoord nsFontMetricsUnix :: GetWidth(const char *aString)
|
||||
|
||||
rc = (PRInt32) ::XTextWidth(mFontInfo, aString, nsCRT::strlen(aString));
|
||||
|
||||
return (nscoord(rc * mContext->GetDevUnitsToAppUnits()));
|
||||
float dev2app;
|
||||
mContext->GetDevUnitsToAppUnits(dev2app);
|
||||
return nscoord(rc * dev2app);
|
||||
}
|
||||
|
||||
nscoord nsFontMetricsUnix :: GetWidth(const PRUnichar *aString, PRUint32 aLength)
|
||||
@ -321,7 +326,9 @@ nscoord nsFontMetricsUnix :: GetWidth(const PRUnichar *aString, PRUint32 aLength
|
||||
|
||||
width = ::XTextWidth16(mFontInfo, mXstring, aLength);
|
||||
|
||||
return (nscoord(width * mContext->GetDevUnitsToAppUnits()));
|
||||
float dev2app;
|
||||
mContext->GetDevUnitsToAppUnits(dev2app);
|
||||
return nscoord(width * dev2app);
|
||||
}
|
||||
|
||||
// XXX this needs to be implemented
|
||||
|
@ -199,9 +199,10 @@ nsresult nsRenderingContextUnix :: CommonInit()
|
||||
((nsDeviceContextUnix *)mContext)->InstallColormap();
|
||||
|
||||
mFontCache = mContext->GetFontCache();
|
||||
mP2T = mContext->GetDevUnitsToAppUnits();
|
||||
mTMatrix->AddScale(mContext->GetAppUnitsToDevUnits(),
|
||||
mContext->GetAppUnitsToDevUnits());
|
||||
mContext->GetDevUnitsToAppUnits(mP2T);
|
||||
float app2dev;
|
||||
mContext->GetAppUnitsToDevUnits(app2dev);
|
||||
mTMatrix->AddScale(app2dev, app2dev);
|
||||
|
||||
#ifdef MITSHM
|
||||
|
||||
|
@ -105,24 +105,28 @@ NS_IMETHODIMP DeviceContextImpl :: GetDevUnitsToTwips(float &aDevUnitsToTwips) c
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void DeviceContextImpl :: SetAppUnitsToDevUnits(float aAppUnits)
|
||||
NS_IMETHODIMP DeviceContextImpl :: SetAppUnitsToDevUnits(float aAppUnits)
|
||||
{
|
||||
mAppUnitsToDevUnits = aAppUnits;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void DeviceContextImpl :: SetDevUnitsToAppUnits(float aDevUnits)
|
||||
NS_IMETHODIMP DeviceContextImpl :: SetDevUnitsToAppUnits(float aDevUnits)
|
||||
{
|
||||
mDevUnitsToAppUnits = aDevUnits;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
float DeviceContextImpl :: GetAppUnitsToDevUnits() const
|
||||
NS_IMETHODIMP DeviceContextImpl :: GetAppUnitsToDevUnits(float &aAppUnits) const
|
||||
{
|
||||
return mAppUnitsToDevUnits;
|
||||
aAppUnits = mAppUnitsToDevUnits;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
float DeviceContextImpl :: GetDevUnitsToAppUnits() const
|
||||
NS_IMETHODIMP DeviceContextImpl :: GetDevUnitsToAppUnits(float &aDevUnits) const
|
||||
{
|
||||
return mDevUnitsToAppUnits;
|
||||
aDevUnits = mDevUnitsToAppUnits;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeviceContextImpl :: CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext)
|
||||
|
@ -40,11 +40,11 @@ public:
|
||||
NS_IMETHOD GetDevUnitsToTwips(float &aDevUnitsToTwips) const;
|
||||
NS_IMETHOD GetTwipsToDevUnits(float &aTwipsToDevUnits) const;
|
||||
|
||||
virtual void SetAppUnitsToDevUnits(float aAppUnits);
|
||||
virtual void SetDevUnitsToAppUnits(float aDevUnits);
|
||||
NS_IMETHOD SetAppUnitsToDevUnits(float aAppUnits);
|
||||
NS_IMETHOD SetDevUnitsToAppUnits(float aDevUnits);
|
||||
|
||||
virtual float GetAppUnitsToDevUnits() const;
|
||||
virtual float GetDevUnitsToAppUnits() const;
|
||||
NS_IMETHOD GetAppUnitsToDevUnits(float &aAppUnits) const;
|
||||
NS_IMETHOD GetDevUnitsToAppUnits(float &aDevUnits) const;
|
||||
|
||||
NS_IMETHOD GetFontCache(nsIFontCache *&aCache);
|
||||
NS_IMETHOD FlushFontCache();
|
||||
|
@ -80,13 +80,13 @@ public:
|
||||
//device context to define what the scale is
|
||||
//between the units used by the app and the
|
||||
//device units
|
||||
virtual void SetAppUnitsToDevUnits(float aAppUnits) = 0;
|
||||
virtual void SetDevUnitsToAppUnits(float aDevUnits) = 0;
|
||||
NS_IMETHOD SetAppUnitsToDevUnits(float aAppUnits) = 0;
|
||||
NS_IMETHOD SetDevUnitsToAppUnits(float aDevUnits) = 0;
|
||||
|
||||
//these are used to query the scale values defined
|
||||
//by the above Set*() methods
|
||||
virtual float GetAppUnitsToDevUnits() const = 0;
|
||||
virtual float GetDevUnitsToAppUnits() const = 0;
|
||||
NS_IMETHOD GetAppUnitsToDevUnits(float &aAppUnits) const = 0;
|
||||
NS_IMETHOD GetDevUnitsToAppUnits(float &aDevUnits) const = 0;
|
||||
|
||||
//returns the scrollbar dimensions in app units
|
||||
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const = 0;
|
||||
|
@ -95,7 +95,6 @@ int CALLBACK fontcallback(ENUMLOGFONT FAR *lpelf, NEWTEXTMETRIC FAR *lpntm,
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
nsNativeWidget widget;
|
||||
HWND hwnd = (HWND)mWidget;
|
||||
HDC hdc = ::GetDC(hwnd);
|
||||
PRBool isthere = PR_FALSE;
|
||||
|
@ -174,7 +174,8 @@ void nsFontMetricsWin::RealizeFont(nsIDeviceContext *aContext)
|
||||
? FW_BOLD : FW_NORMAL;
|
||||
logFont.lfItalic = (mFont->style & NS_FONT_STYLE_ITALIC)
|
||||
? TRUE : FALSE;
|
||||
float app2dev = aContext->GetAppUnitsToDevUnits();
|
||||
float app2dev;
|
||||
aContext->GetAppUnitsToDevUnits(app2dev);
|
||||
float app2twip;
|
||||
aContext->GetDevUnitsToTwips(app2twip);
|
||||
app2twip *= app2dev;
|
||||
@ -205,7 +206,8 @@ void nsFontMetricsWin::RealizeFont(nsIDeviceContext *aContext)
|
||||
HFONT oldfont = ::SelectObject(dc, (HGDIOBJ) mFontHandle);
|
||||
|
||||
// Get font metrics
|
||||
float dev2app = aContext->GetDevUnitsToAppUnits();
|
||||
float dev2app;
|
||||
aContext->GetDevUnitsToAppUnits(dev2app);
|
||||
TEXTMETRIC metrics;
|
||||
::GetTextMetrics(dc, &metrics);
|
||||
mHeight = nscoord(metrics.tmHeight * dev2app);
|
||||
@ -285,7 +287,8 @@ nscoord nsFontMetricsWin :: GetWidth(nsIDeviceContext *aContext, const nsString&
|
||||
::ReleaseDC(win, hdc);
|
||||
|
||||
|
||||
float app2dev = aContext->GetAppUnitsToDevUnits();
|
||||
float app2dev;
|
||||
aContext->GetAppUnitsToDevUnits(app2dev);
|
||||
float dev2twip;
|
||||
aContext->GetDevUnitsToTwips(dev2twip);
|
||||
float app2twip = dev2twip * app2dev;
|
||||
|
@ -456,9 +456,10 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC)
|
||||
|
||||
nsresult nsRenderingContextWin :: CommonInit(void)
|
||||
{
|
||||
mTMatrix->AddScale(mContext->GetAppUnitsToDevUnits(),
|
||||
mContext->GetAppUnitsToDevUnits());
|
||||
mP2T = mContext->GetDevUnitsToAppUnits();
|
||||
float app2dev;
|
||||
mContext->GetAppUnitsToDevUnits(app2dev);
|
||||
mTMatrix->AddScale(app2dev, app2dev);
|
||||
mContext->GetDevUnitsToAppUnits(mP2T);
|
||||
mContext->GetFontCache(mFontCache);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -320,7 +320,9 @@ float
|
||||
nsPresContext::GetPixelsToTwips() const
|
||||
{
|
||||
if (nsnull != mDeviceContext) {
|
||||
return mDeviceContext->GetDevUnitsToAppUnits();
|
||||
float p2t;
|
||||
mDeviceContext->GetDevUnitsToAppUnits(p2t);
|
||||
return p2t;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
@ -329,7 +331,9 @@ float
|
||||
nsPresContext::GetTwipsToPixels() const
|
||||
{
|
||||
if (nsnull != mDeviceContext) {
|
||||
return mDeviceContext->GetAppUnitsToDevUnits();
|
||||
float app2dev;
|
||||
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
||||
return app2dev;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
@ -357,8 +361,9 @@ nsPresContext::GetImageGroup(nsIImageGroup*& aGroupResult)
|
||||
rootFrame = mShell->GetRootFrame();
|
||||
rootFrame->GetWindow(window);
|
||||
nsIRenderingContext* drawCtx = window->GetRenderingContext();
|
||||
drawCtx->Scale(mDeviceContext->GetAppUnitsToDevUnits(),
|
||||
mDeviceContext->GetAppUnitsToDevUnits());
|
||||
float app2dev;
|
||||
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
||||
drawCtx->Scale(app2dev, app2dev);
|
||||
NS_RELEASE(drawCtx);
|
||||
nsIDeviceContext* deviceCtx = window->GetDeviceContext();
|
||||
rv = mImageGroup->Init(deviceCtx);
|
||||
|
@ -320,7 +320,9 @@ float
|
||||
nsPresContext::GetPixelsToTwips() const
|
||||
{
|
||||
if (nsnull != mDeviceContext) {
|
||||
return mDeviceContext->GetDevUnitsToAppUnits();
|
||||
float p2t;
|
||||
mDeviceContext->GetDevUnitsToAppUnits(p2t);
|
||||
return p2t;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
@ -329,7 +331,9 @@ float
|
||||
nsPresContext::GetTwipsToPixels() const
|
||||
{
|
||||
if (nsnull != mDeviceContext) {
|
||||
return mDeviceContext->GetAppUnitsToDevUnits();
|
||||
float app2dev;
|
||||
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
||||
return app2dev;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
@ -357,8 +361,9 @@ nsPresContext::GetImageGroup(nsIImageGroup*& aGroupResult)
|
||||
rootFrame = mShell->GetRootFrame();
|
||||
rootFrame->GetWindow(window);
|
||||
nsIRenderingContext* drawCtx = window->GetRenderingContext();
|
||||
drawCtx->Scale(mDeviceContext->GetAppUnitsToDevUnits(),
|
||||
mDeviceContext->GetAppUnitsToDevUnits());
|
||||
float app2dev;
|
||||
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
||||
drawCtx->Scale(app2dev, app2dev);
|
||||
NS_RELEASE(drawCtx);
|
||||
nsIDeviceContext* deviceCtx = window->GetDeviceContext();
|
||||
rv = mImageGroup->Init(deviceCtx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user