зеркало из https://github.com/mozilla/pjs.git
Took out files no longer needed for ps, updated all the files for postscript support
This commit is contained in:
Родитель
636667fecc
Коммит
53d344fffa
|
@ -1,55 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
** The names of the characters in the ISO Latin1 set.
|
||||
** Index into this array is the encoding for that character
|
||||
*/
|
||||
char *isotab[256] = {
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "space",
|
||||
"exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand",
|
||||
"quoteright", "parenleft", "parenright", "asterisk", "plus", "comma",
|
||||
"hyphen", "period", "slash", "zero", "one", "two", "three", "four",
|
||||
"five", "six", "seven", "eight", "nine", "colon", "semicolon", "less",
|
||||
"equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F",
|
||||
"G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
|
||||
"U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash",
|
||||
"bracketright", "asciicircum", "underscore", "quoteleft", "a", "b",
|
||||
"c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p",
|
||||
"q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar",
|
||||
"braceright", "asciitilde", "", "", "", "", "", "", "", "", "", "", "", "",
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
|
||||
"", "", "", "space", "exclamdown", "cent", "sterling", "currency",
|
||||
"yen", "brokenbar", "section", "dieresis", "copyright", "ordfeminine",
|
||||
"guillemotleft", "logicalnot", "hyphen", "registered", "macron",
|
||||
"degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu",
|
||||
"paragraph", "periodcentered", "cedilla", "onesuperior",
|
||||
"ordmasculine", "guillemotright", "onequarter", "onehalf",
|
||||
"threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex",
|
||||
"Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute",
|
||||
"Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex",
|
||||
"Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex",
|
||||
"Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute",
|
||||
"Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave",
|
||||
"aacute", "acircumflex", "atilde", "adieresis", "aring", "ae",
|
||||
"ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave",
|
||||
"iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve",
|
||||
"oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash",
|
||||
"ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn",
|
||||
"ydieresis"
|
||||
};
|
|
@ -16,432 +16,373 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDeviceContextWin.h"
|
||||
#include "nsRenderingContextWin.h"
|
||||
#include "nsDeviceContextSpecWin.h"
|
||||
#include "il_util.h"
|
||||
#include "nsDeviceContextPS.h"
|
||||
#include "nsRenderingContextPS.h"
|
||||
#include "nsDeviceContextSpecPS.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// Size of the color cube
|
||||
#define COLOR_CUBE_SIZE 216
|
||||
#include "prprf.h"
|
||||
#include "nsPSUtil.h"
|
||||
#include "nsPrintManager.h"
|
||||
#include "xlate.h"
|
||||
|
||||
nsDeviceContextWin :: nsDeviceContextWin()
|
||||
: DeviceContextImpl()
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
nsDeviceContextPS :: nsDeviceContextPS()
|
||||
{
|
||||
mSurface = NULL;
|
||||
mPaletteInfo.isPaletteDevice = PR_FALSE;
|
||||
mPaletteInfo.sizePalette = 0;
|
||||
mPaletteInfo.numReserved = 0;
|
||||
mPaletteInfo.palette = NULL;
|
||||
mDC = NULL;
|
||||
mPixelScale = 1.0f;
|
||||
mWidthFloat = 0.0f;
|
||||
mHeightFloat = 0.0f;
|
||||
mWidth = -1;
|
||||
mHeight = -1;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
mSpec = nsnull;
|
||||
}
|
||||
|
||||
nsDeviceContextWin :: ~nsDeviceContextWin()
|
||||
{
|
||||
nsDrawingSurfaceWin *surf = (nsDrawingSurfaceWin *)mSurface;
|
||||
|
||||
NS_IF_RELEASE(surf); //this clears the surf pointer...
|
||||
mSurface = nsnull;
|
||||
|
||||
if (NULL != mPaletteInfo.palette)
|
||||
::DeleteObject((HPALETTE)mPaletteInfo.palette);
|
||||
|
||||
if (NULL != mDC)
|
||||
{
|
||||
::DeleteDC(mDC);
|
||||
mDC = NULL;
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: Init(nsNativeWidget aWidget)
|
||||
{
|
||||
HWND hwnd = (HWND)aWidget;
|
||||
HDC hdc = ::GetDC(hwnd);
|
||||
|
||||
CommonInit(hdc);
|
||||
|
||||
::ReleaseDC(hwnd, hdc);
|
||||
|
||||
return DeviceContextImpl::Init(aWidget);
|
||||
}
|
||||
|
||||
//local method...
|
||||
|
||||
nsresult nsDeviceContextWin :: Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext)
|
||||
{
|
||||
float origscale, newscale;
|
||||
float t2d, a2d;
|
||||
|
||||
mDC = (HDC)aContext;
|
||||
|
||||
CommonInit(mDC);
|
||||
|
||||
GetTwipsToDevUnits(newscale);
|
||||
aOrigContext->GetTwipsToDevUnits(origscale);
|
||||
|
||||
mPixelScale = newscale / origscale;
|
||||
|
||||
aOrigContext->GetTwipsToDevUnits(t2d);
|
||||
aOrigContext->GetAppUnitsToDevUnits(a2d);
|
||||
|
||||
mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels;
|
||||
mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
nsDeviceContextPS :: ~nsDeviceContextPS()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextPS, kDeviceContextIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextPS)
|
||||
NS_IMPL_RELEASE(nsDeviceContextPS)
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsDeviceContextPS.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: Init(nsNativeWidget aNativeWidget)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDeviceContextWin :: CommonInit(HDC aDC)
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: CreateRenderingContext(nsIRenderingContext *&aContext)
|
||||
{
|
||||
int rasterCaps = ::GetDeviceCaps(aDC, RASTERCAPS);
|
||||
nsIRenderingContext *pContext;
|
||||
nsresult rv;
|
||||
//GrafPtr thePort;
|
||||
|
||||
mTwipsToPixels = ((float)::GetDeviceCaps(aDC, LOGPIXELSY)) / (float)NSIntPointsToTwips(72);
|
||||
mPixelsToTwips = 1.0f / mTwipsToPixels;
|
||||
|
||||
mDepth = (PRUint32)::GetDeviceCaps(aDC, BITSPIXEL);
|
||||
mPaletteInfo.isPaletteDevice = RC_PALETTE == (rasterCaps & RC_PALETTE);
|
||||
mPaletteInfo.sizePalette = (PRUint8)::GetDeviceCaps(aDC, SIZEPALETTE);
|
||||
mPaletteInfo.numReserved = (PRUint8)::GetDeviceCaps(aDC, NUMRESERVED);
|
||||
|
||||
mWidthFloat = (float)::GetDeviceCaps(aDC, HORZRES);
|
||||
mHeightFloat = (float)::GetDeviceCaps(aDC, VERTRES);
|
||||
|
||||
DeviceContextImpl::CommonInit();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: CreateRenderingContext(nsIRenderingContext *&aContext)
|
||||
{
|
||||
nsIRenderingContext *pContext;
|
||||
nsresult rv;
|
||||
nsDrawingSurfaceWin *surf;
|
||||
|
||||
pContext = new nsRenderingContextWin();
|
||||
|
||||
if (nsnull != pContext)
|
||||
{
|
||||
pContext = new nsRenderingContextPS();
|
||||
if (nsnull != pContext){
|
||||
NS_ADDREF(pContext);
|
||||
|
||||
surf = new nsDrawingSurfaceWin();
|
||||
//::GetPort(&thePort);
|
||||
|
||||
if (nsnull != surf)
|
||||
{
|
||||
rv = surf->Init(mDC);
|
||||
|
||||
if (NS_OK == rv)
|
||||
rv = pContext->Init(this, surf);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
//if (nsnull != thePort){
|
||||
rv = pContext->Init(this,(nsDrawingSurface)nsnull);
|
||||
//}
|
||||
//else
|
||||
//rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_OK != rv)
|
||||
{
|
||||
if (NS_OK != rv){
|
||||
NS_IF_RELEASE(pContext);
|
||||
}
|
||||
|
||||
aContext = pContext;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
|
||||
{
|
||||
if (nsnull == mDC)
|
||||
aSupportsWidgets = PR_TRUE;
|
||||
else
|
||||
aSupportsWidgets = PR_FALSE;
|
||||
|
||||
aSupportsWidgets = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: GetCanonicalPixelScale(float &aScale) const
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
|
||||
{
|
||||
aScale = mPixelScale;
|
||||
// XXX Should we push this to widget library
|
||||
aWidth = 320.0;
|
||||
aHeight = 320.0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
|
||||
{
|
||||
aWidth = ::GetSystemMetrics(SM_CXVSCROLL) * mDevUnitsToAppUnits;
|
||||
aHeight = ::GetSystemMetrics(SM_CXHSCROLL) * mDevUnitsToAppUnits;
|
||||
return NS_OK;
|
||||
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
|
||||
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
|
||||
{
|
||||
if (NULL == mSurface) {
|
||||
aContext.CreateDrawingSurface(nsnull, 0, mSurface);
|
||||
}
|
||||
|
||||
aSurface = mSurface;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int CALLBACK fontcallback(ENUMLOGFONT FAR *lpelf, NEWTEXTMETRIC FAR *lpntm,
|
||||
int FontType, LPARAM lParam)
|
||||
{
|
||||
if (NULL != lpelf)
|
||||
*((PRBool *)lParam) = PR_TRUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
HWND hwnd = (HWND)mWidget;
|
||||
HDC hdc = ::GetDC(hwnd);
|
||||
PRBool isthere = PR_FALSE;
|
||||
|
||||
char fontName[LF_FACESIZE];
|
||||
aFontName.ToCString(fontName, LF_FACESIZE);
|
||||
::EnumFontFamilies(hdc, fontName, (FONTENUMPROC)fontcallback, (LPARAM)&isthere);
|
||||
|
||||
::ReleaseDC(hwnd, hdc);
|
||||
|
||||
if (PR_TRUE == isthere)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin::GetDepth(PRUint32& aDepth)
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
aDepth = mDepth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::CreateILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
if (nsnull == mColorSpace) {
|
||||
// See if we're dealing with an 8-bit palette device
|
||||
if ((8 == mDepth) && mPaletteInfo.isPaletteDevice) {
|
||||
// Create a color cube. We want to use DIB_PAL_COLORS because it's faster
|
||||
// than DIB_RGB_COLORS, so make sure the indexes match that of the
|
||||
// GDI physical palette
|
||||
//
|
||||
// Note: the image library doesn't use the reserved colors, so it doesn't
|
||||
// matter what they're set to...
|
||||
IL_RGB reserved[10];
|
||||
memset(reserved, 0, sizeof(reserved));
|
||||
IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 10, COLOR_CUBE_SIZE + 10);
|
||||
if (nsnull == colorMap) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Create a pseudo color space
|
||||
mColorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8);
|
||||
|
||||
} else {
|
||||
IL_RGBBits colorRGBBits;
|
||||
|
||||
// Create a 24-bit color space
|
||||
colorRGBBits.red_shift = 16;
|
||||
colorRGBBits.red_bits = 8;
|
||||
colorRGBBits.green_shift = 8;
|
||||
colorRGBBits.green_bits = 8;
|
||||
colorRGBBits.blue_shift = 0;
|
||||
colorRGBBits.blue_bits = 8;
|
||||
|
||||
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 24);
|
||||
}
|
||||
nsresult result = NS_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
|
||||
if (nsnull == mColorSpace) {
|
||||
IL_RGBBits colorRGBBits;
|
||||
|
||||
// Default is to create a 32-bit color space
|
||||
colorRGBBits.red_shift = 16;
|
||||
colorRGBBits.red_bits = 8;
|
||||
colorRGBBits.green_shift = 8;
|
||||
colorRGBBits.green_bits = 8;
|
||||
colorRGBBits.blue_shift = 0;
|
||||
colorRGBBits.blue_bits = 8;
|
||||
|
||||
//mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 32);
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the color space
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
//NS_POSTCONDITION(nsnull != mColorSpace, "null color space");
|
||||
//aColorSpace = mColorSpace;
|
||||
//IL_AddRefToColorSpace(aColorSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
|
||||
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
|
||||
aPaletteInfo.numReserved = mPaletteInfo.numReserved;
|
||||
#ifdef NEVER
|
||||
short fontNum;
|
||||
if (GetMacFontNumber(aFontName, fontNum))
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
if (NULL == mPaletteInfo.palette) {
|
||||
IL_ColorSpace* colorSpace;
|
||||
GetILColorSpace(colorSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NI_PseudoColor == colorSpace->type) {
|
||||
// Create a logical palette
|
||||
BYTE tmp[sizeof(LOGPALETTE) + ((COLOR_CUBE_SIZE + 20) * sizeof(PALETTEENTRY))];
|
||||
LPLOGPALETTE logPal = (LPLOGPALETTE)tmp;
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
|
||||
{
|
||||
aWidth = 1;
|
||||
aHeight = 1;
|
||||
|
||||
logPal->palVersion = 0x300;
|
||||
logPal->palNumEntries = COLOR_CUBE_SIZE + 20;
|
||||
|
||||
// Initialize it from the default Windows palette
|
||||
HPALETTE hDefaultPalette = (HPALETTE)::GetStockObject(DEFAULT_PALETTE);
|
||||
|
||||
// First ten system colors
|
||||
::GetPaletteEntries(hDefaultPalette, 0, 10, logPal->palPalEntry);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Last ten system colors
|
||||
::GetPaletteEntries(hDefaultPalette, 10, 10, &logPal->palPalEntry[COLOR_CUBE_SIZE + 10]);
|
||||
|
||||
// Now set the color cube entries.
|
||||
PALETTEENTRY* entry = &logPal->palPalEntry[10];
|
||||
NI_RGB* map = colorSpace->cmap.map + 10;
|
||||
for (PRInt32 i = 0; i < COLOR_CUBE_SIZE; i++) {
|
||||
entry->peRed = map->red;
|
||||
entry->peGreen = map->green;
|
||||
entry->peBlue = map->blue;
|
||||
entry->peFlags = 0;
|
||||
|
||||
entry++;
|
||||
map++;
|
||||
}
|
||||
|
||||
// Create a GDI palette
|
||||
mPaletteInfo.palette = ::CreatePalette(logPal);
|
||||
}
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext)
|
||||
{
|
||||
|
||||
IL_ReleaseColorSpace(colorSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::BeginDocument(void)
|
||||
{
|
||||
PrintInfo* pi = new PrintInfo();
|
||||
PrintSetup* ps = new PrintSetup();
|
||||
|
||||
//XXX:PS Get rid of the need for a MWContext
|
||||
mPrintContext = new MWContext();
|
||||
memset(mPrintContext, 0, sizeof(struct MWContext_));
|
||||
memset(ps, 0, sizeof(struct PrintSetup_));
|
||||
memset(pi, 0, sizeof(struct PrintInfo_));
|
||||
|
||||
ps->top = 0; /* Margins (PostScript Only) */
|
||||
ps->bottom = 0;
|
||||
ps->left = 0;
|
||||
ps->right = 0;
|
||||
ps->width = PAGE_WIDTH; /* Paper size, # of cols for text xlate */
|
||||
ps->height = PAGE_HEIGHT;
|
||||
ps->header = "header";
|
||||
ps->footer = "footer";
|
||||
ps->sizes = NULL;
|
||||
ps->reverse = 1; /* Output order */
|
||||
ps->color = TRUE; /* Image output */
|
||||
ps->deep_color = TRUE; /* 24 bit color output */
|
||||
ps->landscape = FALSE; /* Rotated output */
|
||||
ps->underline = TRUE; /* underline links */
|
||||
ps->scale_images = TRUE; /* Scale unsized images which are too big */
|
||||
ps->scale_pre = FALSE; /* do the pre-scaling thing */
|
||||
ps->dpi = 72.0f; /* dpi for externally sized items */
|
||||
ps->rules = 1.0f; /* Scale factor for rulers */
|
||||
ps->n_up = 0; /* cool page combining */
|
||||
ps->bigger = 1; /* Used to init sizes if sizesin NULL */
|
||||
ps->paper_size = NS_LEGAL_SIZE; /* Paper Size(letter,legal,exec,a4) */
|
||||
ps->prefix = ""; /* For text xlate, prepended to each line */
|
||||
ps->eol = ""; /* For text translation, line terminator */
|
||||
ps->bullet = "+"; /* What char to use for bullets */
|
||||
|
||||
URL_Struct_* url = new URL_Struct_;
|
||||
memset(url, 0, sizeof(URL_Struct_));
|
||||
ps->url = url; /* url of doc being translated */
|
||||
char filename[30];
|
||||
static char g_nsPostscriptFileCount = 0; //('a');
|
||||
char ext[30];
|
||||
sprintf(ext,"%d",g_nsPostscriptFileCount);
|
||||
sprintf(filename,"file%s.ps", ext);
|
||||
g_nsPostscriptFileCount++;
|
||||
ps->out = fopen(filename , "w"); /* Where to send the output */
|
||||
ps->filename = filename; /* output file name, if any */
|
||||
ps->completion = NULL; /* Called when translation finished */
|
||||
ps->carg = NULL; /* Data saved for completion routine */
|
||||
ps->status = 0; /* Status of URL on completion */
|
||||
/* "other" font is for encodings other than iso-8859-1 */
|
||||
ps->otherFontName[0] = NULL;
|
||||
/* name of "other" PostScript font */
|
||||
ps->otherFontInfo[0] = NULL;
|
||||
/* font info parsed from "other" afm file */
|
||||
ps->otherFontCharSetID = 0; /* charset ID of "other" font */
|
||||
ps->cx = NULL; /* original context, if available */
|
||||
|
||||
pi->page_height = PAGE_HEIGHT * 10; /* Size of printable area on page */
|
||||
pi->page_width = PAGE_WIDTH * 10; /* Size of printable area on page */
|
||||
pi->page_break = 0; /* Current page bottom */
|
||||
pi->page_topy = 0; /* Current page top */
|
||||
pi->phase = 0;
|
||||
/*
|
||||
** CONTINUE SPECIAL
|
||||
** The table print code maintains these
|
||||
*/
|
||||
|
||||
pi->pages=NULL; /* Contains extents of each page */
|
||||
|
||||
pi->pt_size = 0; /* Size of above table */
|
||||
pi->n_pages = 0; /* # of valid entries in above table */
|
||||
/*
|
||||
** END SPECIAL
|
||||
*/
|
||||
|
||||
pi->doc_title="Test Title"; /* best guess at title */
|
||||
pi->doc_width = 0; /* Total document width */
|
||||
pi->doc_height = 0; /* Total document height */
|
||||
|
||||
mPrintContext->prInfo = pi;
|
||||
|
||||
// begin the document
|
||||
xl_initialize_translation(mPrintContext, ps);
|
||||
xl_begin_document(mPrintContext);
|
||||
mPrintSetup = ps;
|
||||
|
||||
// begin the page
|
||||
xl_begin_page(mPrintContext, 1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::EndDocument(void)
|
||||
{
|
||||
// end the page
|
||||
xl_end_page(mPrintContext, 1);
|
||||
|
||||
// end the document
|
||||
xl_end_document(mPrintContext);
|
||||
xl_finalize_translation(mPrintContext);
|
||||
|
||||
// Cleanup things allocated along the way
|
||||
if (nsnull != mPrintContext){
|
||||
if (nsnull != mPrintContext->prInfo)
|
||||
delete mPrintContext->prInfo;
|
||||
|
||||
if (nsnull != mPrintContext->prSetup)
|
||||
delete mPrintContext->prSetup;
|
||||
|
||||
delete mPrintContext;
|
||||
}
|
||||
|
||||
aPaletteInfo.palette = mPaletteInfo.palette;
|
||||
if (nsnull != mPrintSetup)
|
||||
delete mPrintSetup;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: ConvertPixel(nscolor aColor, PRUint32 & aPixel)
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::BeginPage(void)
|
||||
{
|
||||
#ifdef NEVER
|
||||
if(((nsDeviceContextSpecPS*)(this->mSpec))->mPrintManagerOpen)
|
||||
::PrOpenPage(((nsDeviceContextSpecPS*)(this->mSpec))->mPrinterPort,nsnull);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::EndPage(void)
|
||||
{
|
||||
#ifdef NEVER
|
||||
if(((nsDeviceContextSpecPS*)(this->mSpec))->mPrintManagerOpen) {
|
||||
::SetPort((GrafPtr)(((nsDeviceContextSpecPS*)(this->mSpec))->mPrinterPort));
|
||||
::PrClosePage(((nsDeviceContextSpecPS*)(this->mSpec))->mPrinterPort);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: ConvertPixel(nscolor aColor, PRUint32 & aPixel)
|
||||
{
|
||||
aPixel = aColor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
|
||||
{
|
||||
if (mWidth == -1)
|
||||
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
|
||||
|
||||
if (mHeight == -1)
|
||||
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
|
||||
|
||||
aWidth = mWidth;
|
||||
aHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BOOL CALLBACK abortproc( HDC hdc, int iError )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext)
|
||||
{
|
||||
char *devicename;
|
||||
char *drivername;
|
||||
HGLOBAL hdevmode;
|
||||
DEVMODE *devmode;
|
||||
|
||||
//XXX this API should take an CID, use the repository and
|
||||
//then QI for the real object rather than casting... MMP
|
||||
|
||||
aContext = new nsDeviceContextWin();
|
||||
|
||||
((nsDeviceContextWin *)aContext)->mSpec = aDevice;
|
||||
NS_ADDREF(aDevice);
|
||||
|
||||
((nsDeviceContextSpecWin *)aDevice)->GetDeviceName(devicename);
|
||||
((nsDeviceContextSpecWin *)aDevice)->GetDriverName(drivername);
|
||||
((nsDeviceContextSpecWin *)aDevice)->GetDEVMODE(hdevmode);
|
||||
|
||||
devmode = (DEVMODE *)::GlobalLock(hdevmode);
|
||||
HDC dc = ::CreateDC(drivername, devicename, NULL, devmode);
|
||||
|
||||
// ::SetAbortProc(dc, (ABORTPROC)abortproc);
|
||||
|
||||
::GlobalUnlock(hdevmode);
|
||||
|
||||
return ((nsDeviceContextWin *)aContext)->Init(dc, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(void)
|
||||
{
|
||||
if (NULL != mDC)
|
||||
{
|
||||
DOCINFO docinfo;
|
||||
|
||||
docinfo.cbSize = sizeof(docinfo);
|
||||
docinfo.lpszDocName = "New Layout Document";
|
||||
docinfo.lpszOutput = NULL;
|
||||
docinfo.lpszDatatype = NULL;
|
||||
docinfo.fwType = 0;
|
||||
|
||||
HGLOBAL hdevmode;
|
||||
DEVMODE *devmode;
|
||||
|
||||
//XXX need to QI rather than cast... MMP
|
||||
|
||||
((nsDeviceContextSpecWin *)mSpec)->GetDEVMODE(hdevmode);
|
||||
|
||||
devmode = (DEVMODE *)::GlobalLock(hdevmode);
|
||||
|
||||
// ::ResetDC(mDC, devmode);
|
||||
|
||||
::GlobalUnlock(hdevmode);
|
||||
|
||||
if (::StartDoc(mDC, &docinfo) > 0)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: EndDocument(void)
|
||||
{
|
||||
if (NULL != mDC)
|
||||
{
|
||||
if (::EndDoc(mDC) > 0)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: BeginPage(void)
|
||||
{
|
||||
if (NULL != mDC)
|
||||
{
|
||||
if (::StartPage(mDC) > 0)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: EndPage(void)
|
||||
{
|
||||
if (NULL != mDC)
|
||||
{
|
||||
if (::EndPage(mDC) > 0)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -16,71 +16,72 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsDeviceContextWin_h___
|
||||
#define nsDeviceContextWin_h___
|
||||
#ifndef nsDeviceContextPS_h___
|
||||
#define nsDeviceContextPS_h___
|
||||
|
||||
#include "nsDeviceContext.h"
|
||||
#include <windows.h>
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsPrintManager.h"
|
||||
|
||||
class nsDeviceContextWin : public DeviceContextImpl
|
||||
|
||||
class nsDeviceContextPS : public DeviceContextImpl
|
||||
{
|
||||
public:
|
||||
nsDeviceContextWin();
|
||||
nsDeviceContextPS();
|
||||
|
||||
NS_IMETHOD Init(nsNativeWidget aWidget);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* This method does nothing since a postscript devicecontext will never be created
|
||||
* with a NativeWidget.
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
|
||||
|
||||
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
|
||||
|
||||
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
|
||||
|
||||
NS_IMETHOD GetCanonicalPixelScale(float &aScale) 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
|
||||
//already one in the device context. the drawing surface is then cached
|
||||
//in the device context for re-use.
|
||||
void SetDrawingSurface(nsDrawingSurface aSurface) { mSurface = aSurface; }
|
||||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
NS_IMETHOD CreateILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
NS_IMETHODIMP GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
|
||||
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&);
|
||||
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(void);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD BeginDocument(void);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
NS_IMETHOD EndPage(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
NS_IMETHOD EndPage(void);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextWin();
|
||||
void CommonInit(HDC aDC);
|
||||
nsresult Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext);
|
||||
|
||||
nsDrawingSurface mSurface;
|
||||
PRUint32 mDepth; // bit depth of device
|
||||
nsPaletteInfo mPaletteInfo;
|
||||
float mPixelScale;
|
||||
float mWidthFloat;
|
||||
float mHeightFloat;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
virtual ~nsDeviceContextPS();
|
||||
|
||||
nsDrawingSurface mSurface;
|
||||
PRUint32 mDepth;
|
||||
MWContext *mPrintContext; //XXX: Remove need for MWContext
|
||||
nsIDeviceContextSpec *mSpec;
|
||||
PrintSetup *mPrintSetup;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
HDC mDC;
|
||||
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
|
||||
MWContext* GetPrintContext() { return mPrintContext; }
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextWin_h___ */
|
||||
#endif /* nsDeviceContextMac_h___ */
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDeviceContextSpecFactoryWin.h"
|
||||
#include "nsDeviceContextSpecWin.h"
|
||||
#include <windows.h>
|
||||
#include <commdlg.h>
|
||||
#include "nsGfxCIID.h"
|
||||
#include "plstr.h"
|
||||
|
||||
nsDeviceContextSpecFactoryWin :: nsDeviceContextSpecFactoryWin()
|
||||
{
|
||||
}
|
||||
|
||||
nsDeviceContextSpecFactoryWin :: ~nsDeviceContextSpecFactoryWin()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryWin, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryWin)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryWin)
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: Init(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//XXX this method needs to do what the API says...
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
{
|
||||
PRINTDLG prntdlg;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
prntdlg.lStructSize = sizeof(prntdlg);
|
||||
prntdlg.hwndOwner = NULL; //XXX need to find a window here. MMP
|
||||
prntdlg.hDevMode = NULL;
|
||||
prntdlg.hDevNames = NULL;
|
||||
prntdlg.hDC = NULL;
|
||||
prntdlg.Flags = PD_ALLPAGES | PD_RETURNIC;
|
||||
prntdlg.nFromPage = 0;
|
||||
prntdlg.nToPage = 0;
|
||||
prntdlg.nMinPage = 0;
|
||||
prntdlg.nMaxPage = 0;
|
||||
prntdlg.nCopies = 1;
|
||||
prntdlg.hInstance = NULL;
|
||||
prntdlg.lCustData = 0;
|
||||
prntdlg.lpfnPrintHook = NULL;
|
||||
prntdlg.lpfnSetupHook = NULL;
|
||||
prntdlg.lpPrintTemplateName = NULL;
|
||||
prntdlg.lpSetupTemplateName = NULL;
|
||||
prntdlg.hPrintTemplate = NULL;
|
||||
prntdlg.hSetupTemplate = NULL;
|
||||
|
||||
BOOL res = ::PrintDlg(&prntdlg);
|
||||
|
||||
if (TRUE == res)
|
||||
{
|
||||
DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(prntdlg.hDevNames);
|
||||
|
||||
char device[200], driver[200];
|
||||
|
||||
//print something...
|
||||
|
||||
PL_strcpy(device, &(((char *)devnames)[devnames->wDeviceOffset]));
|
||||
PL_strcpy(driver, &(((char *)devnames)[devnames->wDriverOffset]));
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
printf("printer: driver %s, device %s\n", driver, device);
|
||||
#endif
|
||||
|
||||
nsIDeviceContextSpec *devspec = nsnull;
|
||||
|
||||
nsRepository::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devspec);
|
||||
|
||||
if (nsnull != devspec)
|
||||
{
|
||||
//XXX need to QI rather than cast... MMP
|
||||
if (NS_OK == ((nsDeviceContextSpecWin *)devspec)->Init(driver, device, prntdlg.hDevMode))
|
||||
{
|
||||
aNewSpec = devspec;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
//don't free the DEVMODE because the device context spec now owns it...
|
||||
::GlobalUnlock(prntdlg.hDevNames);
|
||||
::GlobalFree(prntdlg.hDevNames);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsDeviceContextSpecFactoryWin_h___
|
||||
#define nsDeviceContextSpecFactoryWin_h___
|
||||
|
||||
#include "nsIDeviceContextSpecFactory.h"
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
|
||||
class nsDeviceContextSpecFactoryWin : public nsIDeviceContextSpecFactory
|
||||
{
|
||||
public:
|
||||
nsDeviceContextSpecFactoryWin();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(void);
|
||||
NS_IMETHOD CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
~nsDeviceContextSpecFactoryWin();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,92 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDeviceContextSpecWin.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
|
||||
nsDeviceContextSpecWin :: nsDeviceContextSpecWin()
|
||||
{
|
||||
mDriverName = nsnull;
|
||||
mDeviceName = nsnull;
|
||||
mDEVMODE = NULL;
|
||||
}
|
||||
|
||||
nsDeviceContextSpecWin :: ~nsDeviceContextSpecWin()
|
||||
{
|
||||
if (nsnull != mDriverName)
|
||||
{
|
||||
PR_Free(mDriverName);
|
||||
mDriverName = nsnull;
|
||||
}
|
||||
|
||||
if (nsnull != mDeviceName)
|
||||
{
|
||||
PR_Free(mDeviceName);
|
||||
mDeviceName = nsnull;
|
||||
}
|
||||
|
||||
if (NULL != mDEVMODE)
|
||||
{
|
||||
::GlobalFree(mDEVMODE);
|
||||
mDEVMODE = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecWin, kDeviceContextSpecIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecWin)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecWin)
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecWin :: Init(char *aDriverName, char *aDeviceName, HGLOBAL aDEVMODE)
|
||||
{
|
||||
if (nsnull != aDriverName)
|
||||
{
|
||||
mDriverName = (char *)PR_Malloc(PL_strlen(aDriverName) + 1);
|
||||
PL_strcpy(mDriverName, aDriverName);
|
||||
}
|
||||
|
||||
if (nsnull != aDeviceName)
|
||||
{
|
||||
mDeviceName = (char *)PR_Malloc(PL_strlen(aDeviceName) + 1);
|
||||
PL_strcpy(mDeviceName, aDeviceName);
|
||||
}
|
||||
|
||||
mDEVMODE = aDEVMODE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecWin :: GetDriverName(char *&aDriverName) const
|
||||
{
|
||||
aDriverName = mDriverName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecWin :: GetDeviceName(char *&aDeviceName) const
|
||||
{
|
||||
aDeviceName = mDeviceName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecWin :: GetDEVMODE(HGLOBAL &aDEVMODE) const
|
||||
{
|
||||
aDEVMODE = mDEVMODE;
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsDeviceContextSpecWin_h___
|
||||
#define nsDeviceContextSpecWin_h___
|
||||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include <windows.h>
|
||||
|
||||
class nsDeviceContextSpecWin : public nsIDeviceContextSpec
|
||||
{
|
||||
public:
|
||||
nsDeviceContextSpecWin();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(char *aDriverName, char *aDeviceName, HGLOBAL aDEVMODE);
|
||||
NS_IMETHOD GetDriverName(char *&aDriverName) const;
|
||||
NS_IMETHOD GetDeviceName(char *&aDeviceName) const;
|
||||
NS_IMETHOD GetDEVMODE(HGLOBAL &aDevMode) const;
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecWin();
|
||||
|
||||
char *mDriverName;
|
||||
char *mDeviceName;
|
||||
HGLOBAL mDEVMODE;
|
||||
};
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -16,8 +16,8 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsRenderingContextWin_h___
|
||||
#define nsRenderingContextWin_h___
|
||||
#ifndef nsRenderingContextPS_h___
|
||||
#define nsRenderingContextPS_h___
|
||||
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsUnitConversion.h"
|
||||
|
@ -30,28 +30,18 @@
|
|||
#include "nsIViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsImageWin.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMRenderingContext.h"
|
||||
|
||||
#include "nsPrintManager.h"
|
||||
|
||||
class GraphicsState;
|
||||
class nsDrawingSurfaceWin;
|
||||
class GraphicState;
|
||||
typedef void* nsDrawingSurfacePS;
|
||||
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
#include "ddraw.h"
|
||||
#endif
|
||||
|
||||
class nsRenderingContextWin : public nsIRenderingContext,
|
||||
nsIDOMRenderingContext,
|
||||
nsIScriptObjectOwner
|
||||
class nsRenderingContextPS : public nsIRenderingContext
|
||||
{
|
||||
public:
|
||||
nsRenderingContextWin();
|
||||
~nsRenderingContextWin();
|
||||
nsRenderingContextPS();
|
||||
~nsRenderingContextPS();
|
||||
|
||||
void* operator new(size_t sz) {
|
||||
void* rv = new char[sz];
|
||||
|
@ -63,14 +53,6 @@ public:
|
|||
|
||||
// nsIPrinterRenderingContext methods
|
||||
|
||||
NS_IMETHODIMP BeginDocument(PrintSetup *aPrintInfo);
|
||||
|
||||
NS_IMETHODIMP EndDocument();
|
||||
|
||||
NS_IMETHODIMP BeginPage();
|
||||
|
||||
NS_IMETHODIMP EndPage();
|
||||
|
||||
// Postscript utilities
|
||||
void PostscriptColor(nscolor aColor);
|
||||
void PostscriptFillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
|
||||
|
@ -81,20 +63,11 @@ public:
|
|||
nscoord aX, nscoord aY, nscoord aWidth,
|
||||
const nscoord* aSpacing, PRBool aIsUnicode);
|
||||
|
||||
//XXX:PS Test methods, remove when fully implemented
|
||||
virtual void TestInitialize();
|
||||
virtual void TestFinalize();
|
||||
|
||||
protected:
|
||||
MWContext *mPrintContext; //XXX: Remove need for MWContext
|
||||
PrintSetup *mPrintSetup;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// nsIRenderingContext
|
||||
|
||||
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
|
||||
|
||||
|
@ -187,105 +160,55 @@ public:
|
|||
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// nsIDOMRenderingContext
|
||||
NS_DECL_IDOMRENDERINGCONTEXT
|
||||
|
||||
// locals
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
nsresult GetDDraw(IDirectDraw2 **aDDraw);
|
||||
#endif
|
||||
|
||||
private:
|
||||
nsresult CommonInit(void);
|
||||
nsresult SetupDC(HDC aOldDC, HDC aNewDC);
|
||||
HBRUSH SetupSolidBrush(void);
|
||||
HPEN SetupPen(void);
|
||||
HPEN SetupSolidPen(void);
|
||||
HPEN SetupDashedPen(void);
|
||||
HPEN SetupDottedPen(void);
|
||||
void SetupFontAndColor(void);
|
||||
void PushClipState(void);
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
nsresult CreateDDraw(void);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nscolor mCurrentColor;
|
||||
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
HDC mDC;
|
||||
HDC mMainDC;
|
||||
nsDrawingSurfaceWin *mSurface;
|
||||
nsDrawingSurfaceWin *mMainSurface;
|
||||
COLORREF mColor;
|
||||
nsIWidget *mDCOwner;
|
||||
// int mOldMapMode;
|
||||
nsIDeviceContext *mContext;
|
||||
float mP2T;
|
||||
HRGN mClipRegion;
|
||||
nscolor mCurrentColor;
|
||||
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
//HDC mDC;
|
||||
//HDC mMainDC;
|
||||
nsDrawingSurfacePS *mSurface;
|
||||
//nsDrawingSurfaceWin *mMainSurface;
|
||||
COLORREF mColor;
|
||||
//nsIWidget *mDCOwner;
|
||||
nsIDeviceContext *mContext;
|
||||
float mP2T;
|
||||
HRGN mClipRegion;
|
||||
//default objects
|
||||
HBRUSH mOrigSolidBrush;
|
||||
HBRUSH mBlackBrush;
|
||||
HFONT mOrigFont;
|
||||
HFONT mDefFont;
|
||||
HPEN mOrigSolidPen;
|
||||
HPEN mBlackPen;
|
||||
HPALETTE mOrigPalette;
|
||||
HBRUSH mOrigSolidBrush;
|
||||
HBRUSH mBlackBrush;
|
||||
HFONT mOrigFont;
|
||||
HFONT mDefFont;
|
||||
HPEN mOrigSolidPen;
|
||||
HPEN mBlackPen;
|
||||
HPALETTE mOrigPalette;
|
||||
|
||||
//state management
|
||||
GraphicsState *mStates;
|
||||
nsVoidArray *mStateCache;
|
||||
nscolor mCurrBrushColor;
|
||||
HBRUSH mCurrBrush;
|
||||
nsIFontMetrics *mCurrFontMetrics;
|
||||
HFONT mCurrFont;
|
||||
nscolor mCurrPenColor;
|
||||
HPEN mCurrPen;
|
||||
HPEN mNullPen;
|
||||
PRUint8 *mGammaTable;
|
||||
COLORREF mCurrTextColor;
|
||||
nsLineStyle mCurrLineStyle;
|
||||
nsVoidArray *mStateCache;
|
||||
nscolor mCurrBrushColor;
|
||||
HBRUSH mCurrBrush;
|
||||
nsIFontMetrics *mCurrFontMetrics;
|
||||
HFONT mCurrFont;
|
||||
nscolor mCurrPenColor;
|
||||
HPEN mCurrPen;
|
||||
HPEN mNullPen;
|
||||
PRUint8 *mGammaTable;
|
||||
COLORREF mCurrTextColor;
|
||||
nsLineStyle mCurrLineStyle;
|
||||
PRBool mGetNearestColor;
|
||||
MWContext *mPrintContext; //XXX: Remove need for MWContext
|
||||
nsDrawingSurfacePS mFrontBuffer; // screen port
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRBool mInitialized;
|
||||
#endif
|
||||
// graphic state management
|
||||
GraphicState * mStates; // Pointer to the current graphic state, top of stack
|
||||
nsVoidArray * mGSArray;
|
||||
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
static IDirectDraw *mDDraw;
|
||||
static IDirectDraw2 *mDDraw2;
|
||||
static nsresult mDDrawResult;
|
||||
#endif
|
||||
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
class nsDrawingSurfaceWin : public nsISupports
|
||||
{
|
||||
public:
|
||||
nsDrawingSurfaceWin();
|
||||
~nsDrawingSurfaceWin();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsresult Init(HDC aDC);
|
||||
nsresult Init(nsIWidget *aOwner);
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
nsresult Init(LPDIRECTDRAWSURFACE aSurface);
|
||||
nsresult GetDC();
|
||||
nsresult ReleaseDC();
|
||||
#endif
|
||||
|
||||
nsIWidget *mDCOwner;
|
||||
HDC mDC;
|
||||
HBITMAP mOrigBitmap;
|
||||
HBITMAP mSelectedBitmap;
|
||||
|
||||
#ifdef NGLAYOUT_DDRAW
|
||||
IDirectDrawSurface *mSurface;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsRenderingContextWin_h___ */
|
||||
#endif /* nsRenderingContextPS_h___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче