#5000: added "browser.screen_resolution" pref

This commit is contained in:
pierre%netscape.com 1999-04-28 00:20:58 +00:00
parent 5672625203
commit 710dd4f29d
5 changed files with 78 additions and 8 deletions

View File

@ -28,9 +28,11 @@
#include <Resources.h>
#include "il_util.h"
#include <FixMath.h>
#include "nsIPref.h"
#include "nsIServiceManager.h"
const PRUint32 nsDeviceContextMac::kPixelsPerInch = 96;
PRUint32 nsDeviceContextMac::mPixelsPerInch = 96;
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
@ -72,7 +74,7 @@ double pix_inch;
thegd = ::GetMainDevice();
thepix = (**thegd).gdPMap; // dereferenced handle: don't move memory below!
mDepth = (**thepix).pixelSize;
pix_inch = kPixelsPerInch; //Fix2X((**thepix).hRes);
pix_inch = GetScreenResolution(); //Fix2X((**thepix).hRes);
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f/mTwipsToPixels;
@ -325,6 +327,7 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PR
}
#pragma mark -
//------------------------------------------------------------------------
NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext)
@ -561,3 +564,32 @@ nsresult nsDeviceContextMac::CreateFontAliasTable()
}
return result;
}
#pragma mark -
//------------------------------------------------------------------------
//
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
PRUint32 nsDeviceContextMac::GetScreenResolution()
{
static PRBool initialized = PR_FALSE;
if (initialized)
return mPixelsPerInch;
initialized = PR_TRUE;
nsIPref* prefs;
nsresult rv = nsServiceManager::GetService(kPrefCID, kIPrefIID, (nsISupports**)&prefs);
if (NS_SUCCEEDED(rv) && prefs) {
PRInt32 intVal;
if (NS_SUCCEEDED(prefs->GetIntPref("browser.screen_resolution", &intVal))) {
mPixelsPerInch = intVal;
}
nsServiceManager::ReleaseService(kPrefCID, prefs);
}
return mPixelsPerInch;
}

View File

@ -79,7 +79,10 @@ protected:
public:
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
static const PRUint32 kPixelsPerInch;
private:
static PRUint32 mPixelsPerInch;
public:
static PRUint32 GetScreenResolution();
};
#endif /* nsDeviceContextMac_h___ */

View File

@ -113,8 +113,8 @@ PRInt32 bufferdepth;
mThePixelmap.pixelSize = bufferdepth;
mThePixelmap.packType = 0;
mThePixelmap.packSize = 0;
mThePixelmap.hRes = nsDeviceContextMac::kPixelsPerInch<<16;
mThePixelmap.vRes = nsDeviceContextMac::kPixelsPerInch<<16;
mThePixelmap.hRes = nsDeviceContextMac::GetScreenResolution()<<16;
mThePixelmap.vRes = nsDeviceContextMac::GetScreenResolution()<<16;
mThePixelmap.planeBytes = 0;
mThePixelmap.pmReserved = 0;
mThePixelmap.pmVersion = 0;

View File

@ -28,9 +28,11 @@
#include <Resources.h>
#include "il_util.h"
#include <FixMath.h>
#include "nsIPref.h"
#include "nsIServiceManager.h"
const PRUint32 nsDeviceContextMac::kPixelsPerInch = 96;
PRUint32 nsDeviceContextMac::mPixelsPerInch = 96;
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
@ -72,7 +74,7 @@ double pix_inch;
thegd = ::GetMainDevice();
thepix = (**thegd).gdPMap; // dereferenced handle: don't move memory below!
mDepth = (**thepix).pixelSize;
pix_inch = kPixelsPerInch; //Fix2X((**thepix).hRes);
pix_inch = GetScreenResolution(); //Fix2X((**thepix).hRes);
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f/mTwipsToPixels;
@ -325,6 +327,7 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PR
}
#pragma mark -
//------------------------------------------------------------------------
NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext)
@ -561,3 +564,32 @@ nsresult nsDeviceContextMac::CreateFontAliasTable()
}
return result;
}
#pragma mark -
//------------------------------------------------------------------------
//
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
PRUint32 nsDeviceContextMac::GetScreenResolution()
{
static PRBool initialized = PR_FALSE;
if (initialized)
return mPixelsPerInch;
initialized = PR_TRUE;
nsIPref* prefs;
nsresult rv = nsServiceManager::GetService(kPrefCID, kIPrefIID, (nsISupports**)&prefs);
if (NS_SUCCEEDED(rv) && prefs) {
PRInt32 intVal;
if (NS_SUCCEEDED(prefs->GetIntPref("browser.screen_resolution", &intVal))) {
mPixelsPerInch = intVal;
}
nsServiceManager::ReleaseService(kPrefCID, prefs);
}
return mPixelsPerInch;
}

View File

@ -79,7 +79,10 @@ protected:
public:
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
static const PRUint32 kPixelsPerInch;
private:
static PRUint32 mPixelsPerInch;
public:
static PRUint32 GetScreenResolution();
};
#endif /* nsDeviceContextMac_h___ */