Updated to the correct way the DeviceContext should work, added the twips calculation

This commit is contained in:
dcone%netscape.com 1998-08-21 17:11:15 +00:00
Родитель d745267dec
Коммит 125a0c023a
4 изменённых файлов: 42 добавлений и 30 удалений

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

@ -22,6 +22,7 @@
#include "math.h"
#include "nspr.h"
#include <FixMath.h>
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
@ -29,7 +30,20 @@ static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsDeviceContextMac :: nsDeviceContextMac()
{
GDHandle thegd;
PixMapHandle thepix;
double pix_inch;
NS_INIT_REFCNT();
// see IM Imaging with Quickdraw, chapter 5. This is an imcomplete implementation
thegd = ::GetMainDevice();
HLock((Handle)thegd);
thepix = (**thegd).gdPMap;
pix_inch = Fix2X((**thepix).hRes);
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f/mTwipsToPixels;
}
@ -46,6 +60,9 @@ nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
NS_ASSERTION(!(aNativeWidget == nsnull), "attempt to init devicecontext with null widget");
// this is a windowptr, or grafptr, native to macintosh only
mSurface = aNativeWidget;
return NS_OK;
}
@ -66,8 +83,7 @@ float nsDeviceContextMac :: GetScrollBarHeight() const
nsDrawingSurface nsDeviceContextMac :: GetDrawingSurface(nsIRenderingContext &aContext)
{
//return aContext.CreateDrawingSurface(nsnull);
return nsnull;
return aContext.CreateDrawingSurface(nsnull);
}

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

@ -26,15 +26,6 @@
#include "nsIView.h"
#include "nsIRenderingContext.h"
/* nsDrawingSurface is actually the following struct */
struct nsDrawingSurfaceMac {
/* Display *display ;
Drawable drawable ;
GC gc ;
Visual * visual ;
PRUint32 depth ; */
};
class nsDeviceContextMac : public DeviceContextImpl
{
public:
@ -59,10 +50,9 @@ protected:
virtual ~nsDeviceContextMac();
nsresult CreateFontCache();
nsIFontCache *mFontCache;
nsDrawingSurfaceMac * mSurface ;
PRUint32 mDepth;
nsIFontCache *mFontCache;
nsDrawingSurface mSurface ;
PRUint32 mDepth;
};

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

@ -22,6 +22,7 @@
#include "math.h"
#include "nspr.h"
#include <FixMath.h>
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
@ -29,7 +30,20 @@ static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsDeviceContextMac :: nsDeviceContextMac()
{
GDHandle thegd;
PixMapHandle thepix;
double pix_inch;
NS_INIT_REFCNT();
// see IM Imaging with Quickdraw, chapter 5. This is an imcomplete implementation
thegd = ::GetMainDevice();
HLock((Handle)thegd);
thepix = (**thegd).gdPMap;
pix_inch = Fix2X((**thepix).hRes);
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f/mTwipsToPixels;
}
@ -46,6 +60,9 @@ nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
NS_ASSERTION(!(aNativeWidget == nsnull), "attempt to init devicecontext with null widget");
// this is a windowptr, or grafptr, native to macintosh only
mSurface = aNativeWidget;
return NS_OK;
}
@ -66,8 +83,7 @@ float nsDeviceContextMac :: GetScrollBarHeight() const
nsDrawingSurface nsDeviceContextMac :: GetDrawingSurface(nsIRenderingContext &aContext)
{
//return aContext.CreateDrawingSurface(nsnull);
return nsnull;
return aContext.CreateDrawingSurface(nsnull);
}

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

@ -26,15 +26,6 @@
#include "nsIView.h"
#include "nsIRenderingContext.h"
/* nsDrawingSurface is actually the following struct */
struct nsDrawingSurfaceMac {
/* Display *display ;
Drawable drawable ;
GC gc ;
Visual * visual ;
PRUint32 depth ; */
};
class nsDeviceContextMac : public DeviceContextImpl
{
public:
@ -59,10 +50,9 @@ protected:
virtual ~nsDeviceContextMac();
nsresult CreateFontCache();
nsIFontCache *mFontCache;
nsDrawingSurfaceMac * mSurface ;
PRUint32 mDepth;
nsIFontCache *mFontCache;
nsDrawingSurface mSurface ;
PRUint32 mDepth;
};