r=timeless, sr=blizzard
Revamp of xprint - checkin for gisburn - Roland.Mainz@informatik.med.uni-giessen.de


git-svn-id: svn://10.0.0.236/trunk@95267 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkaply%us.ibm.com
2001-05-17 18:25:30 +00:00
parent cb8d49d560
commit a0804115dd
27 changed files with 3096 additions and 2351 deletions

View File

@@ -34,7 +34,6 @@
#include "nsGfxPSCID.h"
#include "nsIDeviceContextPS.h"
#ifdef USE_XPRINT
#include "nsGfxXPrintCID.h"
#include "nsIDeviceContextXPrint.h"
@@ -357,13 +356,13 @@ NS_IMETHODIMP nsDeviceContextGTK::GetSystemAttribute(nsSystemAttrID anID, System
//---------
// Fonts
//---------
case eSystemAttr_Font_Caption: // css2
case eSystemAttr_Font_Caption: // css2
case eSystemAttr_Font_Icon:
case eSystemAttr_Font_Menu:
case eSystemAttr_Font_MessageBox:
case eSystemAttr_Font_SmallCaption:
case eSystemAttr_Font_StatusBar:
case eSystemAttr_Font_Window: // css3
case eSystemAttr_Font_Window: // css3
case eSystemAttr_Font_Document:
case eSystemAttr_Font_Workspace:
case eSystemAttr_Font_Desktop:
@@ -373,7 +372,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetSystemAttribute(nsSystemAttrID anID, System
case eSystemAttr_Font_PullDownMenu:
case eSystemAttr_Font_List:
case eSystemAttr_Font_Field:
case eSystemAttr_Font_Tooltips: // moz
case eSystemAttr_Font_Tooltips: // moz
case eSystemAttr_Font_Widget:
status = GetSystemFontInfo(style->font, anID, aInfo->mFont);
break;
@@ -465,34 +464,28 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev
{
#ifdef USE_XPRINT
int method=-1;
nsDeviceContextSpecGTK* spec=(nsDeviceContextSpecGTK*)aDevice;
nsDeviceContextSpecGTK *spec = NS_STATIC_CAST(nsDeviceContextSpecGTK *, aDevice);
spec->GetPrintMethod(method);
if (method == 1) { // XPRINT
static NS_DEFINE_CID(kCDeviceContextXP, NS_DEVICECONTEXTXP_CID);
static NS_DEFINE_CID(kCDeviceContextXp, NS_DEVICECONTEXTXP_CID);
nsresult rv;
nsIDeviceContextXP *dcxp;
rv = nsComponentManager::CreateInstance(kCDeviceContextXP,
nsnull,
NS_GET_IID(nsIDeviceContextXP),
(void **)&dcxp);
nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context");
if (NS_FAILED(rv))
return rv;
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create XP Device context");
dcxp->SetSpec(aDevice);
dcxp->InitDeviceContextXP((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
(nsIDeviceContext*)this);
rv = dcxp->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
NS_RELEASE(dcxp);
return rv;
}
// default/PS
#endif
#endif /* USE_XPRINT */
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
// Create a Postscript device context

View File

@@ -17,7 +17,9 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*/
#include "nsDeviceContextSpecG.h"
@@ -45,7 +47,6 @@ static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
@@ -92,11 +93,12 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: QueryInterface(REFNSIID aIID, void** aIn
#ifdef USE_XPRINT
if (aIID.Equals(kIDeviceContextSpecXPIID))
{
*aInstancePtr = (void*) (nsIDeviceContextSpecXP*) this;
nsIDeviceContextSpecXp *tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
#endif
#endif /* USE_XPRINT */
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@@ -119,12 +121,28 @@ NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
* Initialize the nsDeviceContextSpecGTK
* @update dc 2/15/98
* @update syd 3/2/99
*
* gisburn: Please note that this function exists as 1:1 copy in other
* toolkits including:
* - GTK+-toolkit:
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* - Xlib-toolkit:
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
* - Qt-toolkit:
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
*
* ** Please update the other toolkits when changing this function.
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintOptions> printService(do_GetService(kPrintOptionsCID, &rv));
NS_ASSERTION(nsnull != printService, "No print service.");
// if there is a current selection then enable the "Selection" radio button
if (NS_SUCCEEDED(rv) && printService) {
PRBool isOn;
@@ -135,7 +153,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
}
}
char *path;
char *path;
PRBool canPrint = PR_FALSE;
PRBool reversed = PR_FALSE;
PRBool color = PR_FALSE;
@@ -151,7 +169,6 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
double dtop = 0.5;
double dbottom = 0.5;
if (PR_FALSE == aQuiet ) {
rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
@@ -168,8 +185,8 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
if (wwatch) {
nsCOMPtr<nsIDOMWindow> newWindow;
rv = wwatch->OpenWindow(0, "chrome://global/content/printdialog.xul",
"_blank", "chrome,modal", paramBlockWrapper,
getter_AddRefs(newWindow));
"_blank", "chrome,modal", paramBlockWrapper,
getter_AddRefs(newWindow));
}
}
if (NS_SUCCEEDED(rv)) {
@@ -183,8 +200,6 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
canPrint = PR_TRUE;
}
if (canPrint) {
if (printService) {
printService->GetPrintReversed(&reversed);
@@ -202,63 +217,57 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
printService->GetMarginRight(&dright);
if (command != nsnull && printfile != nsnull) {
// convert Unicode strings to cstrings
nsAutoString cmdStr;
nsAutoString printFileStr;
cmdStr = command;
printFileStr = printfile;
char * pCmdStr = cmdStr.ToNewCString();
char * pPrintFileStr = printFileStr.ToNewCString();
sprintf( mPrData.command, pCmdStr );
sprintf( mPrData.path, pPrintFileStr);
nsMemory::Free(pCmdStr);
nsMemory::Free(pPrintFileStr);
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
}
#ifdef DEBUG_rods
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
printf("printRange %d\n", printRange);
printf("fromPage %d\n", fromPage);
printf("toPage %d\n", toPage);
#endif
} else {
#ifndef VMS
sprintf( mPrData.command, "lpr" );
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
printf("printRange %d\n", printRange);
printf("fromPage %d\n", fromPage);
printf("toPage %d\n", toPage);
#endif /* DEBUG_rods */
} else {
#ifdef VMS
// Note to whoever puts the "lpr" into the prefs file. Please contact me
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
strcpy(mPrData.command, "print");
#else
// Note to whoever puts the "lpr" into the prefs file. Please contact me
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
sprintf( mPrData.command, "print" );
#endif
}
mPrData.top = dtop;
mPrData.bottom = dbottom;
mPrData.left = dleft;
mPrData.right = dright;
mPrData.fpf = !reversed;
mPrData.grayscale = !color;
mPrData.size = paper_size;
mPrData.toPrinter = !tofile;
// PWD, HOME, or fail
strcpy(mPrData.command, "lpr");
#endif /* VMS */
}
mPrData.top = dtop;
mPrData.bottom = dbottom;
mPrData.left = dleft;
mPrData.right = dright;
mPrData.fpf = !reversed;
mPrData.grayscale = !color;
mPrData.size = paper_size;
mPrData.toPrinter = !tofile;
// PWD, HOME, or fail
if (!printfile) {
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL )
strcpy( mPrData.path, "mozilla.ps" );
if ( path != (char *) NULL )
sprintf( mPrData.path, "%s/mozilla.ps", path );
else
return NS_ERROR_FAILURE;
}
if (command != nsnull) {
nsMemory::Free(command);
}
if (printfile != nsnull) {
nsMemory::Free(printfile);
}
if (!printfile) {
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
strcpy(mPrData.path, "mozilla.ps");
if ( path != (char *) nsnull )
sprintf(mPrData.path, "%s/mozilla.ps", path);
else
return NS_ERROR_FAILURE;
}
if (command != nsnull) {
nsMemory::Free(command);
}
if (printfile != nsnull) {
nsMemory::Free(printfile);
}
return NS_OK;
}
return NS_ERROR_FAILURE;
}
@@ -361,7 +370,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPrintMethod(int &aMethod )
}
return NS_OK;
}
#endif
#endif /* USE_XPRINT */
/** -------------------------------------------------------
* Closes the printmanager if it is open.
@@ -369,5 +378,6 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPrintMethod(int &aMethod )
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: ClosePrintManager()
{
return NS_OK;
}
return NS_OK;
}

View File

@@ -35,7 +35,7 @@
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec ,
public nsIDeviceContextSpecPS
#ifdef USE_XPRINT
, public nsIDeviceContextSpecXP
, public nsIDeviceContextSpecXp
#endif
{
public:

View File

@@ -44,6 +44,7 @@ CPPSRCS = \
nsRenderingContextXlib.cpp \
nsScreenXlib.cpp \
nsScreenManagerXlib.cpp \
nsPrintOptionsXlib.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk
@@ -68,6 +69,10 @@ ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif
ifdef MOZ_ENABLE_XPRINT
DEFINES += -DUSE_XPRINT
endif
INCLUDES += \
-I$(srcdir)/. \
-I$(srcdir)/.. \

View File

@@ -17,13 +17,17 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*/
#include "nsDeviceContextSpecXlib.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIPrintOptions.h"
#include "nsGfxCIID.h"
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
@@ -34,15 +38,7 @@
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
#ifdef USE_XPRINT
static NS_DEFINE_IID(kIDeviceContextSpecXPIID, NS_IDEVICE_CONTEXT_SPEC_XP_IID);
#endif
NS_IMPL_ADDREF(nsDeviceContextSpecXlib)
NS_IMPL_RELEASE(nsDeviceContextSpecXlib)
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
nsDeviceContextSpecXlib::nsDeviceContextSpecXlib()
{
@@ -53,6 +49,12 @@ nsDeviceContextSpecXlib::~nsDeviceContextSpecXlib()
{
}
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
#ifdef USE_XPRINT
static NS_DEFINE_IID(kIDeviceContextSpecXPIID, NS_IDEVICE_CONTEXT_SPEC_XP_IID);
#endif
NS_IMETHODIMP nsDeviceContextSpecXlib::QueryInterface(REFNSIID aIID, void **aInstancePtr)
{
if (nsnull == aInstancePtr)
@@ -77,11 +79,12 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::QueryInterface(REFNSIID aIID, void **aIns
#ifdef USE_XPRINT
if (aIID.Equals(kIDeviceContextSpecXPIID))
{
*aInstancePtr = (void *) (nsIDeviceContextSpecXP *) this;
nsIDeviceContextSpecXp *tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
#endif
#endif /* USE_XPRINT */
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@@ -96,91 +99,161 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::QueryInterface(REFNSIID aIID, void **aIns
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDeviceContextSpecXlib)
NS_IMPL_RELEASE(nsDeviceContextSpecXlib)
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecGTK
* @update dc 2/15/98
* @update syd 3/2/99
*
* gisburn: Please note that this function exists as 1:1 copy in other
* toolkits including:
* - GTK+-toolkit:
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* - Xlib-toolkit:
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
* - Qt-toolkit:
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
*
* ** Please update the other toolkits when changing this function.
*/
NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
{
char *path;
PRBool reversed = PR_FALSE, color = PR_FALSE, landscape = PR_FALSE;
PRBool tofile = PR_FALSE;
PRInt32 paper_size = NS_LETTER_SIZE;
int ileft = 500, iright = 0, itop = 500, ibottom = 0;
char *command;
char *printfile = nsnull;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
nsCOMPtr<nsISupportsInterfacePointer> paramBlockWrapper;
if (ioParamBlock)
paramBlockWrapper = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID);
if (paramBlockWrapper) {
paramBlockWrapper->SetData(ioParamBlock);
paramBlockWrapper->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> newWindow;
rv = wwatch->OpenWindow(0, "chrome://global/content/printdialog.xul",
"_blank", "chrome,modal", paramBlockWrapper,
getter_AddRefs(newWindow));
nsCOMPtr<nsIPrintOptions> printService(do_GetService(kPrintOptionsCID, &rv));
NS_ASSERTION(nsnull != printService, "No print service.");
// if there is a current selection then enable the "Selection" radio button
if (NS_SUCCEEDED(rv) && printService) {
PRBool isOn;
printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, &isOn);
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && pPrefs) {
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
}
}
if (NS_SUCCEEDED(rv)) {
PRInt32 buttonPressed = 0;
ioParamBlock->GetInt(0, &buttonPressed);
if (buttonPressed == 0) {
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && pPrefs) {
(void) pPrefs->GetBoolPref("print.print_reversed", &reversed);
(void) pPrefs->GetBoolPref("print.print_color", &color);
(void) pPrefs->GetBoolPref("print.print_landscape", &landscape);
(void) pPrefs->GetIntPref("print.print_paper_size", &paper_size);
(void) pPrefs->CopyCharPref("print.print_command", (char **) &command);
(void) pPrefs->GetIntPref("print.print_margin_top", &itop);
(void) pPrefs->GetIntPref("print.print_margin_left", &ileft);
(void) pPrefs->GetIntPref("print.print_margin_bottom", &ibottom);
(void) pPrefs->GetIntPref("print.print_margin_right", &iright);
(void) pPrefs->CopyCharPref("print.print_file", (char **) &printfile);
(void) pPrefs->GetBoolPref("print.print_tofile", &tofile);
sprintf(mPrData.command, command);
sprintf(mPrData.path, printfile);
} else {
#ifndef VMS
sprintf(mPrData.command, "lpr");
char *path;
PRBool canPrint = PR_FALSE;
PRBool reversed = PR_FALSE;
PRBool color = PR_FALSE;
PRBool tofile = PR_FALSE;
PRInt16 printRange = nsIPrintOptions::kRangeAllPages;
PRInt32 paper_size = NS_LETTER_SIZE;
PRInt32 fromPage = 1;
PRInt32 toPage = 1;
PRUnichar *command = nsnull;
PRUnichar *printfile = nsnull;
double dleft = 0.5;
double dright = 0.5;
double dtop = 0.5;
double dbottom = 0.5;
if (PR_FALSE == aQuiet ) {
rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
nsCOMPtr<nsISupportsInterfacePointer> paramBlockWrapper;
if (ioParamBlock)
paramBlockWrapper = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID);
if (paramBlockWrapper) {
paramBlockWrapper->SetData(ioParamBlock);
paramBlockWrapper->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> newWindow;
rv = wwatch->OpenWindow(0, "chrome://global/content/printdialog.xul",
"_blank", "chrome,modal", paramBlockWrapper,
getter_AddRefs(newWindow));
}
}
if (NS_SUCCEEDED(rv)) {
PRInt32 buttonPressed = 0;
ioParamBlock->GetInt(0, &buttonPressed);
if (buttonPressed == 0) {
canPrint = PR_TRUE;
}
}
} else {
canPrint = PR_TRUE;
}
if (canPrint) {
if (printService) {
printService->GetPrintReversed(&reversed);
printService->GetPrintInColor(&color);
printService->GetPaperSize(&paper_size);
printService->GetPrintCommand(&command);
printService->GetPrintRange(&printRange);
printService->GetToFileName(&printfile);
printService->GetPrintToFile(&tofile);
printService->GetStartPageRange(&fromPage);
printService->GetEndPageRange(&toPage);
printService->GetMarginTop(&dtop);
printService->GetMarginLeft(&dleft);
printService->GetMarginBottom(&dbottom);
printService->GetMarginRight(&dright);
if (command != nsnull && printfile != nsnull) {
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
}
#ifdef DEBUG_rods
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
printf("printRange %d\n", printRange);
printf("fromPage %d\n", fromPage);
printf("toPage %d\n", toPage);
#endif /* DEBUG_rods */
} else {
#ifdef VMS
// Note to whoever puts the "lpr" into the prefs file. Please contact me
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
strcpy(mPrData.command, "print");
#else
// Note to whoever puts the "lpr" into the prefs file. Please contact me
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
sprintf(mPrData.command, "print");
#endif
}
mPrData.top = itop / 1000.0;
mPrData.bottom = ibottom / 1000.0;
mPrData.left = ileft / 1000.0;
mPrData.right = iright / 1000.0;
mPrData.fpf = !reversed;
mPrData.grayscale = !color;
mPrData.size = paper_size;
mPrData.toPrinter = !tofile;
// PWD, HOME, or fail
if (!printfile) {
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL )
strcpy( mPrData.path, "mozilla.ps" );
if ( path != (char *) NULL )
sprintf( mPrData.path, "%s/mozilla.ps", path );
else
return NS_ERROR_FAILURE;
}
return NS_OK;
strcpy(mPrData.command, "lpr");
#endif /* VMS */
}
mPrData.top = dtop;
mPrData.bottom = dbottom;
mPrData.left = dleft;
mPrData.right = dright;
mPrData.fpf = !reversed;
mPrData.grayscale = !color;
mPrData.size = paper_size;
mPrData.toPrinter = !tofile;
// PWD, HOME, or fail
if (!printfile) {
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
strcpy(mPrData.path, "mozilla.ps");
if ( path != (char *) nsnull )
sprintf(mPrData.path, "%s/mozilla.ps", path);
else
return NS_ERROR_FAILURE;
}
if (command != nsnull) {
nsMemory::Free(command);
}
if (printfile != nsnull) {
nsMemory::Free(printfile);
}
return NS_OK;
}
return NS_ERROR_FAILURE;
}
@@ -283,7 +356,7 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::GetPrintMethod(int &aMethod)
}
return NS_OK;
}
#endif
#endif /* USE_XPRINT */
NS_IMETHODIMP nsDeviceContextSpecXlib::ClosePrintManager()
{

View File

@@ -18,6 +18,8 @@
* Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*/
#ifndef nsDeviceContextSpecXlib_h___
@@ -26,18 +28,16 @@
#include "nsIDeviceContextSpec.h"
#include "nsDeviceContextSpecXlib.h"
#include "nsIDeviceContextSpecPS.h"
#ifdef USE_XPRINT
#include "nsIDeviceContextSpecXPrint.h"
#endif
#endif /* USE_XPRINT */
#include "nsPrintdXlib.h"
class nsDeviceContextSpecXlib : public nsIDeviceContextSpec,
public nsIDeviceContextSpecPS
#ifdef USE_XPRINT
, public nsIDeviceContextSpecXP
#endif
, public nsIDeviceContextSpecXp
#endif /* USE_XPRINT */
{
public:
nsDeviceContextSpecXlib();
@@ -45,8 +45,8 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(PRBool aQuiet);
NS_IMETHOD ClosePrintManager();
protected:
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
NS_IMETHOD GetFirstPageFirst(PRBool &aFpf);
NS_IMETHOD GetGrayscale(PRBool &aGrayscale);
@@ -59,12 +59,11 @@ protected:
NS_IMETHOD GetPath (char **aPath);
NS_IMETHOD GetPageDimensions(float &aWidth, float &aHeight);
NS_IMETHOD GetUserCancelled(PRBool &aCancel);
#ifdef USE_XPRINT
NS_IMETHOD GetPrintMethod(int &aMethod);
#endif
#endif /* USE_XPRINT */
virtual ~nsDeviceContextSpecXlib();
protected:
UnixPrData mPrData;
};

View File

@@ -22,6 +22,7 @@
* Peter Hartshorn <peter@igelaus.com.au>
* Ken Faulkner <faulkner@igelaus.com.au>
* Tony Tsui <tony@igelaus.com.au>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*/
#include "nsRenderingContextXlib.h"
@@ -36,8 +37,14 @@
#include "xlibrgb.h"
#include "nsDeviceContextSpecXlib.h"
#include "nsGfxPSCID.h"
#include "nsIDeviceContextPS.h"
#ifdef USE_XPRINT
#include "nsGfxXPrintCID.h"
#include "nsIDeviceContextXPrint.h"
#endif
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
@@ -138,13 +145,12 @@ nsDeviceContextXlib::CommonInit(void)
}
}
// Do extra rounding (based on GTK). KenF
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(72)) / float(dpi)));
mTwipsToPixels = 1.0f / mPixelsToTwips;
// Do extra rounding (based on GTK). KenF
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(72)) / float(dpi)));
mTwipsToPixels = 1.0f / mPixelsToTwips;
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("GFX: dpi=%d t2p=%g p2t=%g\n", dpi, mTwipsToPixels, mPixelsToTwips));
mWidthFloat = (float) WidthOfScreen(mScreen);
mHeightFloat = (float) HeightOfScreen(mScreen);
@@ -318,9 +324,9 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDrawingSurface(nsIRenderingContext &aConte
NS_IMETHODIMP nsDeviceContextXlib::ConvertPixel(nscolor aColor, PRUint32 & aPixel)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::ConvertPixel()\n"));
aPixel = xlib_rgb_xpixel_from_rgb(NS_RGB(NS_GET_B(aPixel),
NS_GET_G(aPixel),
NS_GET_R(aPixel)));
aPixel = xlib_rgb_xpixel_from_rgb(NS_RGB(NS_GET_B(aColor),
NS_GET_G(aColor),
NS_GET_R(aColor)));
return NS_OK;
}
@@ -370,6 +376,31 @@ NS_IMETHODIMP nsDeviceContextXlib::GetClientRect(nsRect &aRect)
NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
#ifdef USE_XPRINT
int method=-1;
nsDeviceContextSpecXlib *spec = NS_STATIC_CAST(nsDeviceContextSpecXlib *, aDevice);
spec->GetPrintMethod(method);
if (method == 1) { // XPRINT
static NS_DEFINE_CID(kCDeviceContextXp, NS_DEVICECONTEXTXP_CID);
nsresult rv;
nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context");
if (NS_FAILED(rv))
return rv;
dcxp->SetSpec(aDevice);
dcxp->InitDeviceContextXP((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
rv = dcxp->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
return rv;
}
#endif /* USE_XPRINT */
// default/PS
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
// Create a Postscript device context

View File

@@ -58,7 +58,9 @@ static NS_DEFINE_CID(kCharSetManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
#ifdef PR_LOGGING
static PRLogModuleInfo * FontMetricsXlibLM = PR_NewLogModule("FontMetricsXlib");
#endif /* PR_LOGGING */
static int gFontMetricsXlibCount = 0;
static int gInitialized = 0;

View File

@@ -20,6 +20,7 @@
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Tony Tsui <tony@igelaus.com.au>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*/
#include "nsIGenericFactory.h"
@@ -39,6 +40,7 @@
#include "nsIImageManager.h"
#include "nsDeviceContextXlib.h"
#include "nsImageXlib.h"
#include "nsPrintOptionsXlib.h"
// objects that just require generic constructors
@@ -52,6 +54,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsXlib)
// our custom constructors
@@ -161,8 +164,13 @@ static nsModuleComponentInfo components[] =
{ "Image Manager",
NS_IMAGEMANAGER_CID,
// "@mozilla.org/gfx/image_manager;1",
"@mozilla.org/gfx/imagemanager;1",
"@mozilla.org/gfx/imagemanager;1",
nsImageManagerConstructor },
{ "Print Options",
NS_PRINTOPTIONS_CID,
// "@mozilla.org/gfx/printoptions;1",
"@mozilla.org/gfx/printoptions;1",
nsPrintOptionsXlibConstructor },
{ "Xlib Font Enumerator",
NS_FONT_ENUMERATOR_CID,
// "@mozilla.org/gfx/font_enumerator/xlib;1",

View File

@@ -0,0 +1,39 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is Mozilla Xlib toolkit.
*
* The Initial Developer of the Original Code is Roland Mainz.
* Copyright (C) 2001 Roland Mainz. All Rights Reserved.
*
* Contributor(s):
*/
#include "nsPrintOptionsXlib.h"
/** ---------------------------------------------------
* See documentation in nsPrintOptionsWin.h
* @update 6/21/00 dwc
*/
nsPrintOptionsXlib::nsPrintOptionsXlib()
{
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
nsPrintOptionsXlib::~nsPrintOptionsXlib()
{
}

View File

@@ -0,0 +1,39 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is Mozilla Xlib toolkit.
*
* The Initial Developer of the Original Code is Roland Mainz.
* Copyright (C) 2001 Roland Mainz. All Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsPrintOptionsXlib_h__
#define nsPrintOptionsXlib_h__
#include "nsPrintOptionsImpl.h"
// *****************************************************************************
// *** nsPrintOptions
// *****************************************************************************
class nsPrintOptionsXlib : public nsPrintOptions
{
public:
nsPrintOptionsXlib();
virtual ~nsPrintOptionsXlib();
};
#endif /* !nsPrintOptionsXlib_h__ */

View File

@@ -28,7 +28,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = layout
LIBRARY_NAME = gfxxprt
LIBRARY_NAME = gfxxprint
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
EXTRA_DSO_LIBS = gkgfx
@@ -45,7 +45,7 @@ CPPSRCS = \
nsRenderingContextXP.cpp \
nsGfxFactoryXP.cpp \
nsXPrintContext.cpp \
nsRegionXP.cpp \
../xlib/nsRegionXlib.cpp \
$(NULL)
EXPORTS = \
@@ -78,5 +78,6 @@ EXTRA_DSO_LDOPTS += \
INCLUDES += \
-I$(srcdir)/../gtk \
-I$(srcdir)/../xlib \
-I$(srcdir)/../xlibrgb \
$(NULL)

View File

@@ -22,41 +22,50 @@
* Bradley Baetz <bbaetz@cs.mcgill.ca>
*
*/
#include <strings.h>
#include <unistd.h>
#include <X11/Xatom.h>
#include "nsDeviceContextXP.h"
#include "nsRenderingContextXP.h"
#include "nsString.h"
#include "nsFontMetricsXP.h"
#include "xlibrgb.h"
#include "nsIDeviceContext.h"
#include "nsIDeviceContextSpecXPrint.h"
#include "il_util.h"
#include "nspr.h"
#include "nsXPrintContext.h"
static PRLogModuleInfo *nsDeviceContextXPLM = PR_NewLogModule("nsDeviceContextXP");
#ifdef PR_LOGGING
static PRLogModuleInfo *nsDeviceContextXpLM = PR_NewLogModule("nsDeviceContextXp");
#endif /* PR_LOGGING */
static NS_DEFINE_IID(kIDeviceContextSpecXPIID, NS_IDEVICE_CONTEXT_SPEC_XP_IID);
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
nsDeviceContextXP :: nsDeviceContextXP()
nsDeviceContextXp :: nsDeviceContextXp()
{
NS_INIT_REFCNT();
/* Inherited from xlib device context code */
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mPaletteInfo.isPaletteDevice = PR_FALSE;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = NULL;
mNumCells = 0;
mPrintContext = nsnull;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = nsnull;
mNumCells = 0;
mPrintContext = nsnull;
mSpec = nsnull;
mParentDeviceContext = nsnull;
mWidthFloat = 0.0f;
mHeightFloat = 0.0f;
mWidth = -1;
mHeight = -1;
mWidth = -1;
mHeight = -1;
NS_NewISupportsArray(getter_AddRefs(mFontMetrics));
}
@@ -65,75 +74,100 @@ nsDeviceContextXP :: nsDeviceContextXP()
* See documentation in nsIDeviceContext.h
* @update 12/21/98 dwc
*/
nsDeviceContextXP :: ~nsDeviceContextXP() { }
nsDeviceContextXp :: ~nsDeviceContextXp()
{
NS_IF_RELEASE(mParentDeviceContext);
}
NS_IMETHODIMP
nsDeviceContextXP :: SetSpec(nsIDeviceContextSpec* aSpec)
nsDeviceContextXp :: SetSpec(nsIDeviceContextSpec* aSpec)
{
PR_LOG(nsDeviceContextXPLM, PR_LOG_DEBUG, ("nsDeviceContextXP::SetSpec()\n"));
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIDeviceContextSpecXP> xpSpec;
PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::SetSpec()\n"));
nsCOMPtr<nsIDeviceContextSpecXp> xpSpec;
mSpec = aSpec;
if (!mPrintContext) {
mPrintContext = new nsXPrintContext();
xpSpec = do_QueryInterface(mSpec);
if (xpSpec) {
mPrintContext->Init(xpSpec);
}
if(mPrintContext) delete mPrintContext; // we cannot reuse that...
mPrintContext = new nsXPrintContext();
xpSpec = do_QueryInterface(mSpec);
if(xpSpec) {
rv = mPrintContext->Init(xpSpec);
}
return NS_OK;
return rv;
}
NS_IMPL_ISUPPORTS_INHERITED(nsDeviceContextXP,
NS_IMPL_ISUPPORTS_INHERITED(nsDeviceContextXp,
DeviceContextImpl,
nsIDeviceContextXP)
nsIDeviceContextXp)
/** ---------------------------------------------------
* See documentation in nsDeviceContextXP.h
* See documentation in nsDeviceContextXp.h
*
* This method is called after SetSpec
*/
NS_IMETHODIMP
nsDeviceContextXP::InitDeviceContextXP(nsIDeviceContext *aCreatingDeviceContext,nsIDeviceContext *aPrinterContext)
nsDeviceContextXp::InitDeviceContextXP(nsIDeviceContext *aCreatingDeviceContext,nsIDeviceContext *aParentContext)
{
float t2d, a2d;
// Initialization moved to SetSpec to be done after creating the Print Context
int print_resolution;
mPrintContext->GetPrintResolution(print_resolution);
float origscale, newscale;
float t2d, a2d;
int print_resolution;
mTwipsToPixels = (float)print_resolution/(float)NSIntPointsToTwips(72);
mTwipsToPixels = mTwipsToPixels * 2.0;
mPixelsToTwips = 1.0f / mTwipsToPixels;
mPrintContext->GetPrintResolution(print_resolution);
mScreen = mPrintContext->GetScreen();
mDisplay = mPrintContext->GetDisplay();
aPrinterContext->GetTwipsToDevUnits(t2d);
aPrinterContext->GetAppUnitsToDevUnits(a2d);
mPixelsToTwips = (float)NSIntPointsToTwips(72) / (float)print_resolution;
mTwipsToPixels = 1.0f / mPixelsToTwips;
GetTwipsToDevUnits(newscale);
aParentContext->GetTwipsToDevUnits(origscale);
/* gisburn: Unfortunately the image scaling code doesn't work properly yet
* - scaling both images+fonts would break the images.
* For now we do do the scaling right and disable the images (see
* XPRINT_PRINT_IMAGES in nsXPrintContext).
* Change "#if 1" to "#if 0" and set XPRINT_PRINT_IMAGES in nsXPrintContext
* - this only scales the fonts and does not scale the images.
* This will be removed when image scaling has been fixed.
*/
#if 1
mCPixelScale = newscale / origscale;
#else
mTextZoom = newscale / origscale;
#endif
aParentContext->GetTwipsToDevUnits(t2d);
aParentContext->GetAppUnitsToDevUnits(a2d);
mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels;
mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;
mScreen = mPrintContext->GetScreen();
mDisplay = mPrintContext->GetDisplay();
// mPrintContext->GetAppUnitsToDevUnits(mAppUnitsToDevUnits);
// mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;
mPrintContext->GetTextZoom(mTextZoom);
return NS_OK;
mParentDeviceContext = aParentContext;
NS_ASSERTION(mParentDeviceContext, "aCreatingDeviceContext cannot be NULL!!!");
NS_ADDREF(mParentDeviceContext);
return NS_OK;
}
/** ---------------------------------------------------
*/
NS_IMETHODIMP nsDeviceContextXP :: CreateRenderingContext(nsIRenderingContext *&aContext)
NS_IMETHODIMP nsDeviceContextXp :: CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsRenderingContextXP> xpContext;
nsCOMPtr<nsRenderingContextXp> xpContext;
xpContext = new nsRenderingContextXP();
xpContext = new nsRenderingContextXp();
if (xpContext){
rv = xpContext->Init(this);
}
@@ -148,7 +182,7 @@ NS_IMETHODIMP nsDeviceContextXP :: CreateRenderingContext(nsIRenderingContext *&
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
NS_IMETHODIMP nsDeviceContextXp :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
aSupportsWidgets = PR_FALSE;
return NS_OK;
@@ -157,7 +191,7 @@ NS_IMETHODIMP nsDeviceContextXP :: SupportsNativeWidgets(PRBool &aSupportsWidget
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP :: GetScrollBarDimensions(float &aWidth,
NS_IMETHODIMP nsDeviceContextXp :: GetScrollBarDimensions(float &aWidth,
float &aHeight) const
{
// XXX Oh, yeah. These are hard coded.
@@ -165,13 +199,12 @@ NS_IMETHODIMP nsDeviceContextXP :: GetScrollBarDimensions(float &aWidth,
aHeight = 15 * mPixelsToTwips;
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
NS_IMETHODIMP nsDeviceContextXp :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
{
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
@@ -180,7 +213,7 @@ NS_IMETHODIMP nsDeviceContextXP :: GetDrawingSurface(nsIRenderingContext &aConte
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::GetILColorSpace(IL_ColorSpace*& aColorSpace)
NS_IMETHODIMP nsDeviceContextXp::GetILColorSpace(IL_ColorSpace*& aColorSpace)
{
#ifdef NOTNOW
if (nsnull == mColorSpace) {
@@ -195,7 +228,7 @@ NS_IMETHODIMP nsDeviceContextXP::GetILColorSpace(IL_ColorSpace*& aColorSpace)
// Return the color space
aColorSpace = mColorSpace;
IL_AddRefToColorSpace(aColorSpace);
#endif
#endif /* NOTNOW */
if(!mColorSpace) {
IL_RGBBits colorRGBBits;
@@ -228,77 +261,25 @@ NS_IMETHODIMP nsDeviceContextXP::GetILColorSpace(IL_ColorSpace*& aColorSpace)
* See documentation in nsIDeviceContext.h
* @update 12/21/98 dwc
*/
NS_IMETHODIMP nsDeviceContextXP :: CheckFontExistence(const nsString& aFontName)
NS_IMETHODIMP nsDeviceContextXp :: CheckFontExistence(const nsString& aFontName)
{
PR_LOG(nsDeviceContextXPLM, PR_LOG_DEBUG, ("nsDeviceContextXP::CheckFontExistence()\n"));
/* BUG: this does - unfortunately - not work due missing DISPLAY ptr
* Additionally this is the _wrong_ time to make any assumtions
* about fonts - this info+the correct information is _only_
* available _after_ XpSetContext() - therefore any assumtions
* made here are _wrong_ until we have a vaoid XPContext
* (X11 print context)
*/
#if 0
return nsFontMetricsXP::FamilyExists(aFontName);
#else
char **fnames = nsnull;
PRInt32 namelen = aFontName.Length() + 1;
char *wildstring = (char *)PR_Malloc(namelen + 200);
float t2d;
GetTwipsToDevUnits(t2d);
PRInt32 dpi = NSToIntRound(t2d * 1440);
int numnames = 0;
XFontStruct *fonts;
nsresult rv = NS_ERROR_FAILURE;
if (!wildstring)
return NS_ERROR_UNEXPECTED;
#if 0 /* gisburn: this cannot work - Xprint usually operates at >= 300dpi */
if (abs(dpi - 75) < abs(dpi - 100))
dpi = 75;
else
dpi = 100;
#endif
PR_snprintf(wildstring, namelen + 200,
" -*-%s-*-*-normal-*-*-*-%d-%d-*-*-*-*",
aFontName.get(), dpi, dpi);
/* applications must not make any assumptions about fonts _before_ XpSetContext() !!! */
NS_ASSERTION((XpGetContext(mDisplay) != None), "Obtaining font information (XListFontsWithInfo()) _before_ XpSetContext()");
fnames = ::XListFontsWithInfo(mDisplay, wildstring, 1, &numnames, &fonts);
PR_LOG(nsDeviceContextXPLM, PR_LOG_DEBUG,
("nsDeviceContextXP::CheckFontExistence: XListFontsWithInfo '%s'=%d\n", wildstring, numnames));
if (numnames > 0)
{
::XFreeFontInfo(fnames, fonts, numnames);
rv = NS_OK;
}
PR_Free(wildstring);
return NS_OK;
#endif
PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::CheckFontExistence()\n"));
return nsFontMetricsXp::FamilyExists(aFontName);
}
NS_IMETHODIMP nsDeviceContextXP :: GetSystemAttribute(nsSystemAttrID anID,
SystemAttrStruct * aInfo) const
NS_IMETHODIMP nsDeviceContextXp :: GetSystemAttribute(nsSystemAttrID anID,
SystemAttrStruct * aInfo) const
{
switch (anID) {
case 0:
break;
default:
break;
if (mParentDeviceContext != nsnull) {
return mParentDeviceContext->GetSystemAttribute(anID, aInfo);
}
return NS_OK;
return NS_ERROR_FAILURE;
}
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::GetDeviceSurfaceDimensions(PRInt32 &aWidth,
NS_IMETHODIMP nsDeviceContextXp::GetDeviceSurfaceDimensions(PRInt32 &aWidth,
PRInt32 &aHeight)
{
float width, height;
@@ -312,7 +293,7 @@ NS_IMETHODIMP nsDeviceContextXP::GetDeviceSurfaceDimensions(PRInt32 &aWidth,
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXP::GetRect(nsRect &aRect)
NS_IMETHODIMP nsDeviceContextXp::GetRect(nsRect &aRect)
{
PRInt32 width, height;
nsresult rv;
@@ -327,7 +308,7 @@ NS_IMETHODIMP nsDeviceContextXP::GetRect(nsRect &aRect)
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::GetClientRect(nsRect &aRect)
NS_IMETHODIMP nsDeviceContextXp::GetClientRect(nsRect &aRect)
{
return GetRect(aRect);
}
@@ -335,7 +316,7 @@ NS_IMETHODIMP nsDeviceContextXP::GetClientRect(nsRect &aRect)
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext)
NS_IMETHODIMP nsDeviceContextXp::GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext)
{
return NS_OK;
}
@@ -343,7 +324,7 @@ NS_IMETHODIMP nsDeviceContextXP::GetDeviceContextFor(nsIDeviceContextSpec *aDevi
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::BeginDocument(PRUnichar * aTitle)
NS_IMETHODIMP nsDeviceContextXp::BeginDocument(PRUnichar * aTitle)
{
nsresult rv = NS_OK;
if (mPrintContext != nsnull) {
@@ -355,7 +336,7 @@ NS_IMETHODIMP nsDeviceContextXP::BeginDocument(PRUnichar * aTitle)
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::EndDocument(void)
NS_IMETHODIMP nsDeviceContextXp::EndDocument(void)
{
nsresult rv = NS_OK;
if (mPrintContext != nsnull) {
@@ -376,7 +357,7 @@ NS_IMETHODIMP nsDeviceContextXP::EndDocument(void)
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::BeginPage(void)
NS_IMETHODIMP nsDeviceContextXp::BeginPage(void)
{
nsresult rv = NS_OK;
if (mPrintContext != nsnull) {
@@ -389,7 +370,7 @@ NS_IMETHODIMP nsDeviceContextXP::BeginPage(void)
* See documentation in nsIDeviceContext.h
* @update 12/21/98 dwc
*/
NS_IMETHODIMP nsDeviceContextXP::EndPage(void)
NS_IMETHODIMP nsDeviceContextXp::EndPage(void)
{
nsresult rv = NS_OK;
if (mPrintContext != nsnull) {
@@ -402,24 +383,27 @@ NS_IMETHODIMP nsDeviceContextXP::EndPage(void)
* See documentation in nsIDeviceContext.h
* @update 12/21/98 dwc
*/
NS_IMETHODIMP nsDeviceContextXP :: ConvertPixel(nscolor aColor,
NS_IMETHODIMP nsDeviceContextXp :: ConvertPixel(nscolor aColor,
PRUint32 & aPixel)
{
aPixel = aColor;
PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::ConvertPixel()\n"));
aPixel = xlib_rgb_xpixel_from_rgb(NS_RGB(NS_GET_B(aColor),
NS_GET_G(aColor),
NS_GET_R(aColor)));
return NS_OK;
}
Display *
nsDeviceContextXP::GetDisplay()
nsDeviceContextXp::GetDisplay()
{
if (mPrintContext != nsnull) {
return mDisplay;
} else {
return (Display *)0;
return (Display *)nsnull;
}
}
NS_IMETHODIMP nsDeviceContextXP::GetDepth(PRUint32& aDepth)
NS_IMETHODIMP nsDeviceContextXp::GetDepth(PRUint32& aDepth)
{
if (mPrintContext != nsnull) {
aDepth = mPrintContext->GetDepth();
@@ -432,13 +416,13 @@ NS_IMETHODIMP nsDeviceContextXP::GetDepth(PRUint32& aDepth)
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXP::GetMetricsFor(const nsFont& aFont,
NS_IMETHODIMP nsDeviceContextXp::GetMetricsFor(const nsFont& aFont,
nsIAtom* aLangGroup, nsIFontMetrics *&aMetrics)
{
return GetMetricsFor(aFont, aMetrics);
}
NS_IMETHODIMP nsDeviceContextXP::GetMetricsFor(const nsFont& aFont,
NS_IMETHODIMP nsDeviceContextXp::GetMetricsFor(const nsFont& aFont,
nsIFontMetrics *&aMetrics)
{
PRUint32 n,cnt;
@@ -466,7 +450,7 @@ NS_IMETHODIMP nsDeviceContextXP::GetMetricsFor(const nsFont& aFont,
}
// It's not in the cache. Get font metrics and then cache them.
nsCOMPtr<nsIFontMetrics> fm = new nsFontMetricsXP();
nsCOMPtr<nsIFontMetrics> fm = new nsFontMetricsXp();
if (!fm) {
aMetrics = nsnull;
return NS_ERROR_FAILURE;
@@ -488,8 +472,9 @@ NS_IMETHODIMP nsDeviceContextXP::GetMetricsFor(const nsFont& aFont,
}
NS_IMETHODIMP
nsDeviceContextXP::GetPrintContext(nsXPrintContext*& aContext) {
nsDeviceContextXp::GetPrintContext(nsXPrintContext*& aContext) {
aContext = mPrintContext;
//NS_ADDREF(aContext);
return NS_OK;
}

View File

@@ -17,11 +17,12 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*/
#ifndef nsDeviceContextXP_h___
#define nsDeviceContextXP_h___
#ifndef nsDeviceContextXp_h___
#define nsDeviceContextXp_h___
#include <X11/Xlib.h>
#include "nsDeviceContext.h"
@@ -35,10 +36,10 @@
class nsXPrintContext;
class nsDeviceContextXP : public nsIDeviceContextXP
class nsDeviceContextXp : public nsIDeviceContextXp
{
public:
nsDeviceContextXP();
nsDeviceContextXp();
NS_DECL_ISUPPORTS_INHERITED
@@ -86,7 +87,7 @@ public:
nsIFontMetrics*& aMetrics);
protected:
virtual ~nsDeviceContextXP();
virtual ~nsDeviceContextXp();
nsDrawingSurface mSurface;
nsXPrintContext *mPrintContext;
@@ -96,7 +97,8 @@ protected:
nsCOMPtr<nsIDeviceContextSpec> mSpec;
float mPixelScale;
nsCOMPtr<nsISupportsArray> mFontMetrics; // we are not using the normal font cache
nsIDeviceContext *mParentDeviceContext;
private:
nsPaletteInfo mPaletteInfo;
PRBool mWriteable;
@@ -106,7 +108,6 @@ private:
float mHeightFloat;
PRInt32 mWidth;
PRInt32 mHeight;
};
#endif /* !nsDeviceContextPS_h___ */
#endif /* !nsDeviceContextXp_h___ */

File diff suppressed because it is too large Load Diff

View File

@@ -18,90 +18,108 @@
* Rights Reserved.
*
* Contributor(s):
* Tony Tsui <tony@igelaus.com.au>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen,de>
*/
#ifndef nsFontMetricsXP_h__
#define nsFontMetricsXP_h__
#ifndef nsFontMetricsXp_h__
#define nsFontMetricsXp_h__ 1
#include "nsICharRepresentable.h"
#include "nsIDeviceContext.h"
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsDeviceContextXP.h"
#ifdef XPRINT_NOT_NOW
#include "nsDrawingSurfaceXP.h"
#else
#include "nsXPrintContext.h"
#endif
#include "nsFont.h"
#include "nsRenderingContextXP.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#define FONT_SWITCHING
/* #undef FONT_SWITCHING */
// Remove this eventually after I remove all usage from implementation file. TonyT
#define FONT_SWITCHING
#ifdef ADD_GLYPH
#undef ADD_GLYPH
#endif
#define ADD_GLYPH(map, g) (map)[(g) >> 3] |= (1 << ((g) & 7))
#ifdef FONT_HAS_GLYPH
#undef FONT_HAS_GLYPH
#endif
#define FONT_HAS_GLYPH(map, g) (((map)[(g) >> 3] >> ((g) & 7)) & 1)
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
typedef int (*nsFontCharSetConverter)(nsFontCharSetInfo* aSelf,
const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf,
PRInt32 aDestLen);
XFontStruct* aFont, const PRUnichar* aSrcBuf, PRInt32 aSrcLen,
char* aDestBuf, PRInt32 aDestLen);
struct nsFontCharSet;
class nsFontMetricsXP;
struct nsFontFamily;
struct nsFontNode;
struct nsFontStretch;
struct nsFontXP
class nsFontXpUserDefined;
class nsFontMetricsXp;
class nsFontXp
{
nsFontXP();
virtual ~nsFontXP();
public:
nsFontXp();
virtual ~nsFontXp();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void LoadFont(nsFontCharSet* aCharSet, nsFontMetricsXP* aMetrics);
void LoadFont(void);
inline int SupportsChar(PRUnichar aChar)
{ return mFont && FONT_HAS_GLYPH(mMap, aChar); };
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
#ifdef XPRINT_NOT_NOW
virtual int DrawString(nsRenderingContextXp* aContext,
nsDrawingSurfaceXp* aSurface,
nscoord aX, nscoord aY,
const PRUnichar* aString, PRUint32 aLength) = 0;
#else
virtual int DrawString(nsXPrintContext* aSurface,
nscoord aX,
nscoord aY, const PRUnichar* aString,
PRUint32 aLength) = 0;
nscoord aX,
nscoord aY, const PRUnichar* aString,
PRUint32 aLength) = 0;
#endif /* XPRINT_NOT_NOW */
#ifdef MOZ_MATHML
// bounding metrics for a string
// remember returned values are not in app units
// bounding metrics for a string
// remember returned values are not in app units
// - to emulate GetWidth () above
virtual nsresult
GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics) = 0;
#endif
#endif /* MOZ_MATHML */
XFontStruct *mFont;
PRUint32* mMap;
nsFontCharSetInfo* mCharSetInfo;
char* mName;
PRUint32 *mMap;
nsFontCharSetInfo *mCharSetInfo;
char *mName;
nsFontXpUserDefined *mUserDefinedFont;
PRUint16 mSize;
PRUint16 mActualSize;
PRInt16 mBaselineAdjust;
};
struct nsFontStretch;
struct nsFontFamily;
typedef struct nsFontSearch nsFontSearch;
//typedef struct nsFontSearch nsFontSearch;
class nsFontMetricsXP : public nsIFontMetrics
class nsFontMetricsXp : public nsIFontMetrics
{
public:
nsFontMetricsXP();
virtual ~nsFontMetricsXP();
nsFontMetricsXp();
virtual ~nsFontMetricsXp();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
@@ -130,50 +148,60 @@ public:
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
virtual nsresult GetSpaceWidth(nscoord &aSpaceWidth);
nsFontXP* FindFont(PRUnichar aChar);
void FindGenericFont(nsFontSearch* aSearch);
void FindSubstituteFont(nsFontSearch* aSearch);
nsFontXp* FindFont(PRUnichar aChar);
nsFontXp* FindUserDefinedFont(PRUnichar aChar);
nsFontXp* FindLocalFont(PRUnichar aChar);
nsFontXp* FindGenericFont(PRUnichar aChar);
nsFontXp* FindGlobalFont(PRUnichar aChar);
nsFontXp* FindSubstituteFont(PRUnichar aChar);
nsFontXp* SearchNode(nsFontNode* aNode, PRUnichar aChar);
nsFontXp* TryAliases(nsCString* aName, PRUnichar aChar);
nsFontXp* TryFamily(nsCString* aName, PRUnichar aChar);
nsFontXp* TryNode(nsCString* aName, PRUnichar aChar);
nsFontXp* PickASizeAndLoad(nsFontStretch* aStretch,
nsFontCharSetInfo* aCharSet,
PRUnichar aChar);
static nsresult FamilyExists(const nsString& aFontName);
static void SetFont(nsXPrintContext* aSurface, Font fid);
static void InitFonts(void);
nsCAutoString mDefaultFont;
friend void PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
nsFontCharSet* aCharSet);
friend void TryCharSet(nsFontSearch* aSearch, nsFontCharSet* aCharSet);
friend void TryFamily(nsFontSearch* aSearch, nsFontFamily* aFamily);
friend struct nsFontXP;
nsCStringArray mFonts;
PRUint16 mFontsAlloc;
PRUint16 mFontsCount;
PRUint16 mFontsIndex;
nsVoidArray mFontIsGeneric;
nsFontXP **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsCString *mGeneric;
PRUint8 mIsUserDefined;
nsCOMPtr<nsIAtom> mLangGroup;
int mInFindSubstituteFont;
nsFontXP *mSubstituteFont;
nsFontXp **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsString *mFonts;
PRUint16 mFontsAlloc;
PRUint16 mFontsCount;
PRUint16 mFontsIndex;
nsString *mGeneric;
int mTriedAllGenerics;
nsCOMPtr<nsIAtom> mLangGroup;
PRUint8 mTriedAllGenerics;
nsFontXp *mSubstituteFont;
nsCAutoString mUserDefined;
protected:
char *PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired);
void RealizeFont();
Display *mDisplay;
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
XFontStruct *mFontHandle;
XFontStruct *mFontStruct;
nsFontXP *mWesternFont;
nscoord mHeight;
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
XFontStruct *mFontHandle;
XFontStruct *mFontStruct;
nsFontXp *mWesternFont;
nscoord mAscent;
nscoord mDescent;
nscoord mLeading;
nscoord mEmHeight;
nscoord mEmAscent;
@@ -191,24 +219,20 @@ protected:
nscoord mUnderlineOffset;
nscoord mSpaceWidth;
#ifdef FONT_SWITCHING
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
#endif /* FONT_SWITCHING */
private:
static Font mLastSetFont;
};
class nsFontEnumeratorXP : public nsIFontEnumerator
class nsFontEnumeratorXp : public nsIFontEnumerator
{
public:
nsFontEnumeratorXP();
nsFontEnumeratorXp();
NS_DECL_ISUPPORTS
NS_DECL_NSIFONTENUMERATOR
};
#endif /* !nsFontMetricsXP_h__ */
#endif /* !nsFontMetricsXp_h__ */

View File

@@ -32,14 +32,15 @@
#include "nsDeviceContextXP.h"
#include "nsGfxXPrintCID.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextXP)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextXp)
static nsModuleComponentInfo components[] =
{
{ "GFX Postscript Device Context",
{ "GFX Xprint Device Context",
NS_DEVICECONTEXTXP_CID,
"@mozilla.org/gfx/decidecontext/xprt;1",
nsDeviceContextXPConstructor }
"@mozilla.org/gfx/decidecontext/xprint;1",
nsDeviceContextXpConstructor }
};
NS_IMPL_NSGETMODULE(nsGfxXprintModule, components)
NS_IMPL_NSGETMODULE(nsGfxXPModule, components)

View File

@@ -20,8 +20,8 @@
* Contributor(s):
*/
#ifndef nsGfxFactoryXP_h__
#define nsGfxFactoryXP_h__
#ifndef nsGfxFactoryXp_h__
#define nsGfxFactoryXp_h__
/* {4c2bb896-13c9-11d3-9304-006008948010} */
#define NS_DEVICECONTEXTXP_CID \
@@ -29,3 +29,4 @@
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}}
#endif

View File

@@ -39,7 +39,7 @@
#define NS_IDEVICE_CONTEXT_SPEC_XP_IID { 0xa4ef8910, 0xdd65, 0x11d2, { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } }
class nsIDeviceContextSpecXP : public nsISupports
class nsIDeviceContextSpecXp : public nsISupports
{
public:

View File

@@ -23,8 +23,8 @@
#include "nsISupports.h"
#include "nsIDeviceContext.h"
#ifndef __nsIDeviceContextXP_h
#define __nsIDeviceContextXP_h
#ifndef __nsIDeviceContextXp_h
#define __nsIDeviceContextXp_h
/* {35efd8b6-13cc-11d3-9d3a-006008948010} */
#define NS_IDEVICECONTEXTXP_IID \
@@ -33,7 +33,7 @@
class nsXPrintContext;
class nsIDeviceContextXP : public DeviceContextImpl
class nsIDeviceContextXp : public DeviceContextImpl
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICECONTEXTXP_IID);

View File

@@ -22,9 +22,10 @@
*
*/
#include <math.h>
#include <strings.h>
#include "nsRenderingContextXP.h"
#include "nsFontMetricsXP.h"
#include <math.h>
#include "libimg.h"
#include "nsDeviceContextXP.h"
#include "nsXPrintContext.h"
@@ -35,6 +36,11 @@
static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
#ifdef PR_LOGGING
static PRLogModuleInfo *RenderingContextXpLM = PR_NewLogModule("nsRenderingContextXp");
#endif /* PR_LOGGING */
// Macro to convert from TWIPS (1440 per inch) to POINTS (72 per inch)
#define FLAG_CLIP_VALID 0x0001
@@ -115,8 +121,10 @@ static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
nsRenderingContextXP :: nsRenderingContextXP()
nsRenderingContextXp :: nsRenderingContextXp()
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::nsRenderingContextXp()\n"));
NS_INIT_REFCNT();
mContext = nsnull;
@@ -133,8 +141,10 @@ nsRenderingContextXP :: nsRenderingContextXP()
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
nsRenderingContextXP :: ~nsRenderingContextXP()
nsRenderingContextXp :: ~nsRenderingContextXp()
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::~nsRenderingContextXp()\n"));
if (nsnull != mStateCache){
PRInt32 cnt = mStateCache->Count();
@@ -157,9 +167,8 @@ nsRenderingContextXP :: ~nsRenderingContextXP()
* See documentation in nsIRenderingContext.h
*/
nsresult
nsRenderingContextXP :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
nsRenderingContextXp :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
@@ -183,16 +192,15 @@ nsRenderingContextXP :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsRenderingContextXP)
NS_IMPL_RELEASE(nsRenderingContextXP)
NS_IMPL_ADDREF(nsRenderingContextXp)
NS_IMPL_RELEASE(nsRenderingContextXp)
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: Init(nsIDeviceContext* aContext)
nsRenderingContextXp :: Init(nsIDeviceContext* aContext)
{
mContext = do_QueryInterface(aContext);
if (mContext) {
mContext->GetPrintContext(mPrintContext);
@@ -214,7 +222,7 @@ nsRenderingContextXP :: Init(nsIDeviceContext* aContext)
&height,
&border,
&depth);
mClipRegion = new nsRegionXP();
mClipRegion = new nsRegionXlib();
mClipRegion->Init();
mClipRegion->SetTo(0, 0, width, height);
@@ -223,15 +231,13 @@ nsRenderingContextXP :: Init(nsIDeviceContext* aContext)
mContext->GetAppUnitsToDevUnits(app2dev);
mTranMatrix->AddScale(app2dev, app2dev);
// mRenderingSurface = new nsDrawingSurfaceXP();
// mRenderingSurface->InitDrawingSurface(mPrintContext);
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: LockDrawingSurface(PRInt32 aX, PRInt32 aY,
NS_IMETHODIMP nsRenderingContextXp :: LockDrawingSurface(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes,
@@ -244,7 +250,7 @@ NS_IMETHODIMP nsRenderingContextXP :: LockDrawingSurface(PRInt32 aX, PRInt32 aY,
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: UnlockDrawingSurface(void)
NS_IMETHODIMP nsRenderingContextXp :: UnlockDrawingSurface(void)
{
PRBool clipstate;
PopState(clipstate);
@@ -255,8 +261,10 @@ NS_IMETHODIMP nsRenderingContextXP :: UnlockDrawingSurface(void)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
nsRenderingContextXp :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::SelectOffScreenDrawingSurface()\n"));
return NS_OK;
}
@@ -264,8 +272,10 @@ nsRenderingContextXP :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetDrawingSurface(nsDrawingSurface *aSurface)
nsRenderingContextXp :: GetDrawingSurface(nsDrawingSurface *aSurface)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::GetDrawingSurface()\n"));
*aSurface = nsnull;
return NS_OK;
}
@@ -273,7 +283,7 @@ nsRenderingContextXP :: GetDrawingSurface(nsDrawingSurface *aSurface)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetHints(PRUint32& aResult)
nsRenderingContextXp :: GetHints(PRUint32& aResult)
{
PRUint32 result = 0;
// Most X servers implement 8 bit text rendering alot faster than
@@ -288,7 +298,7 @@ nsRenderingContextXP :: GetHints(PRUint32& aResult)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: Reset()
nsRenderingContextXp :: Reset()
{
return NS_OK;
}
@@ -297,7 +307,7 @@ nsRenderingContextXP :: Reset()
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetDeviceContext(nsIDeviceContext *&aContext)
nsRenderingContextXp :: GetDeviceContext(nsIDeviceContext *&aContext)
{
aContext = mContext;
NS_IF_ADDREF(aContext);
@@ -309,7 +319,7 @@ nsRenderingContextXP :: GetDeviceContext(nsIDeviceContext *&aContext)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: PushState(void)
nsRenderingContextXp :: PushState(void)
{
PRInt32 cnt = mStateCache->Count();
@@ -344,7 +354,7 @@ nsRenderingContextXP :: PushState(void)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: PopState(PRBool &aClipEmpty)
nsRenderingContextXp :: PopState(PRBool &aClipEmpty)
{
PRBool retval = PR_FALSE;
@@ -373,7 +383,7 @@ nsRenderingContextXP :: PopState(PRBool &aClipEmpty)
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: IsVisibleRect(const nsRect& aRect, PRBool &aVisible)
NS_IMETHODIMP nsRenderingContextXp :: IsVisibleRect(const nsRect& aRect, PRBool &aVisible)
{
aVisible = PR_TRUE;
return NS_OK;
@@ -382,7 +392,7 @@ NS_IMETHODIMP nsRenderingContextXP :: IsVisibleRect(const nsRect& aRect, PRBool
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty)
NS_IMETHODIMP nsRenderingContextXp :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect trect = aRect;
#ifdef XP_PC
@@ -427,7 +437,7 @@ PRInt32 cliptype;
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
nsRenderingContextXp :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
{
PRInt32 x, y, w, h;
if (!mClipRegion->IsEmpty()) {
@@ -446,7 +456,7 @@ nsRenderingContextXP :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty)
nsRenderingContextXp :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect rect;
nsIRegion* pRegion = (nsIRegion*)&aRegion;
@@ -460,7 +470,7 @@ nsRenderingContextXP :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aC
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: CopyClipRegion(nsIRegion &aRegion)
nsRenderingContextXp :: CopyClipRegion(nsIRegion &aRegion)
{
aRegion.SetTo(*NS_STATIC_CAST(nsIRegion*, mClipRegion));
return NS_OK;
@@ -470,7 +480,7 @@ nsRenderingContextXP :: CopyClipRegion(nsIRegion &aRegion)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetClipRegion(nsIRegion **aRegion)
nsRenderingContextXp :: GetClipRegion(nsIRegion **aRegion)
{
NS_ASSERTION(!(nsnull == aRegion), "no region ptr");
@@ -485,7 +495,7 @@ nsRenderingContextXP :: GetClipRegion(nsIRegion **aRegion)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: SetColor(nscolor aColor)
nsRenderingContextXp :: SetColor(nscolor aColor)
{
if (nsnull == mContext)
return NS_ERROR_FAILURE;
@@ -500,7 +510,7 @@ nsRenderingContextXP :: SetColor(nscolor aColor)
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: GetColor(nscolor &aColor) const
NS_IMETHODIMP nsRenderingContextXp :: GetColor(nscolor &aColor) const
{
aColor = mCurrentColor;
return NS_OK;
@@ -509,7 +519,7 @@ NS_IMETHODIMP nsRenderingContextXP :: GetColor(nscolor &aColor) const
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: SetLineStyle(nsLineStyle aLineStyle)
NS_IMETHODIMP nsRenderingContextXp :: SetLineStyle(nsLineStyle aLineStyle)
{
if (aLineStyle != mCurrLineStyle) {
switch(aLineStyle)
@@ -551,33 +561,25 @@ NS_IMETHODIMP nsRenderingContextXP :: SetLineStyle(nsLineStyle aLineStyle)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetLineStyle(nsLineStyle &aLineStyle)
nsRenderingContextXp :: GetLineStyle(nsLineStyle &aLineStyle)
{
aLineStyle = mCurrLineStyle;
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: SetFont(const nsFont& aFont)
NS_IMETHODIMP
nsRenderingContextXp::SetFont(const nsFont& aFont)
{
// FIX_ME
//PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::SetFont(nsFont)\n"));
NS_IF_RELEASE(mFontMetrics);
if (mContext) {
mContext->GetMetricsFor(aFont, mFontMetrics);
}
mContext->GetMetricsFor(aFont, mFontMetrics);
return SetFont(mFontMetrics);
}
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: SetFont(nsIFontMetrics *aFontMetrics)
NS_IMETHODIMP
nsRenderingContextXp::SetFont(nsIFontMetrics *aFontMetrics)
{
// FIX_ME
//PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::SetFont(nsIFontMetrics)\n"));
NS_IF_RELEASE(mFontMetrics);
mFontMetrics = aFontMetrics;
NS_IF_ADDREF(mFontMetrics);
@@ -587,7 +589,7 @@ nsRenderingContextXP :: SetFont(nsIFontMetrics *aFontMetrics)
nsFontHandle fontHandle;
mFontMetrics->GetFontHandle(fontHandle);
mCurrentFont = (XFontStruct *)fontHandle;
nsFontMetricsXP::SetFont(mPrintContext, mCurrentFont->fid);
XSetFont(mPrintContext->GetDisplay(), mPrintContext->GetGC(), mCurrentFont->fid);
}
return NS_OK;
}
@@ -596,7 +598,7 @@ nsRenderingContextXP :: SetFont(nsIFontMetrics *aFontMetrics)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetFontMetrics(nsIFontMetrics *&aFontMetrics)
nsRenderingContextXp :: GetFontMetrics(nsIFontMetrics *&aFontMetrics)
{
NS_IF_ADDREF(mFontMetrics);
@@ -608,7 +610,7 @@ nsRenderingContextXP :: GetFontMetrics(nsIFontMetrics *&aFontMetrics)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: Translate(nscoord aX, nscoord aY)
nsRenderingContextXp :: Translate(nscoord aX, nscoord aY)
{
mTranMatrix->AddTranslation((float)aX,(float)aY);
return NS_OK;
@@ -618,7 +620,7 @@ nsRenderingContextXP :: Translate(nscoord aX, nscoord aY)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: Scale(float aSx, float aSy)
nsRenderingContextXp :: Scale(float aSx, float aSy)
{
mTranMatrix->AddScale(aSx, aSy);
return NS_OK;
@@ -628,7 +630,7 @@ nsRenderingContextXP :: Scale(float aSx, float aSy)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetCurrentTransform(nsTransform2D *&aTransform)
nsRenderingContextXp :: GetCurrentTransform(nsTransform2D *&aTransform)
{
aTransform = mTranMatrix;
return NS_OK;
@@ -638,7 +640,7 @@ nsRenderingContextXP :: GetCurrentTransform(nsTransform2D *&aTransform)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
nsRenderingContextXp :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
{
return NS_OK;
}
@@ -647,7 +649,7 @@ nsRenderingContextXP :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlag
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DestroyDrawingSurface(nsDrawingSurface aDS)
nsRenderingContextXp :: DestroyDrawingSurface(nsDrawingSurface aDS)
{
return NS_OK;
}
@@ -656,7 +658,7 @@ nsRenderingContextXP :: DestroyDrawingSurface(nsDrawingSurface aDS)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
nsRenderingContextXp :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
if (nsnull == mTranMatrix )
return NS_ERROR_FAILURE;
@@ -675,7 +677,7 @@ nsRenderingContextXP :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
nsRenderingContextXp :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
{
if (nsnull == mTranMatrix) {
return NS_ERROR_FAILURE;
@@ -708,7 +710,7 @@ nsRenderingContextXP :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawRect(const nsRect& aRect)
nsRenderingContextXp :: DrawRect(const nsRect& aRect)
{
return DrawRect(aRect.x, aRect.y, aRect.width, aRect.height);
@@ -718,7 +720,7 @@ nsRenderingContextXP :: DrawRect(const nsRect& aRect)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsRenderingContextXp :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTranMatrix ) {
return NS_ERROR_FAILURE;
@@ -753,7 +755,7 @@ nsRenderingContextXP :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: FillRect(const nsRect& aRect)
nsRenderingContextXp :: FillRect(const nsRect& aRect)
{
return FillRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
@@ -762,7 +764,7 @@ nsRenderingContextXP :: FillRect(const nsRect& aRect)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsRenderingContextXp :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTranMatrix ) {
return NS_ERROR_FAILURE;
@@ -787,13 +789,13 @@ nsRenderingContextXP :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord
}
NS_IMETHODIMP
nsRenderingContextXP :: InvertRect(const nsRect& aRect)
nsRenderingContextXp :: InvertRect(const nsRect& aRect)
{
return InvertRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP
nsRenderingContextXP :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsRenderingContextXp :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTranMatrix )
return NS_ERROR_FAILURE;
@@ -832,7 +834,7 @@ nsRenderingContextXP :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoo
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
nsRenderingContextXp :: DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
if (nsnull == mTranMatrix ) {
return NS_ERROR_FAILURE;
@@ -864,7 +866,7 @@ nsRenderingContextXP :: DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
nsRenderingContextXp :: FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
if (nsnull == mTranMatrix ) {
return NS_ERROR_FAILURE;
@@ -899,7 +901,7 @@ nsRenderingContextXP :: FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawEllipse(const nsRect& aRect)
nsRenderingContextXp :: DrawEllipse(const nsRect& aRect)
{
return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
@@ -908,7 +910,7 @@ nsRenderingContextXP :: DrawEllipse(const nsRect& aRect)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsRenderingContextXp :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsLineStyle_kNone == mCurrLineStyle)
return NS_OK;
@@ -934,7 +936,7 @@ nsRenderingContextXP :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nsco
}
NS_IMETHODIMP
nsRenderingContextXP :: FillEllipse(const nsRect& aRect)
nsRenderingContextXp :: FillEllipse(const nsRect& aRect)
{
return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
@@ -942,7 +944,7 @@ nsRenderingContextXP :: FillEllipse(const nsRect& aRect)
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextXp :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTranMatrix ) {
return NS_ERROR_FAILURE;
@@ -965,10 +967,11 @@ NS_IMETHODIMP nsRenderingContextXP :: FillEllipse(nscoord aX, nscoord aY, nscoor
}
NS_IMETHODIMP
nsRenderingContextXP::DrawTile(nsIImage *aImage, nscoord aX0, nscoord aY0,
nsRenderingContextXp::DrawTile(nsIImage *aImage, nscoord aX0, nscoord aY0,
nscoord aX1, nscoord aY1,
nscoord aWidth, nscoord aHeight)
{
NS_NOTREACHED("nsRenderingContextXp::DrawTile() not yet implemented");
return NS_OK;
}
@@ -976,7 +979,7 @@ nsRenderingContextXP::DrawTile(nsIImage *aImage, nscoord aX0, nscoord aY0,
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawArc(const nsRect& aRect,
nsRenderingContextXp :: DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
return DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle);
@@ -986,7 +989,7 @@ nsRenderingContextXP :: DrawArc(const nsRect& aRect,
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
nsRenderingContextXp :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
if (nsLineStyle_kNone == mCurrLineStyle)
@@ -1017,7 +1020,7 @@ nsRenderingContextXP :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: FillArc(const nsRect& aRect,
nsRenderingContextXp :: FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
return FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
@@ -1027,7 +1030,7 @@ nsRenderingContextXP :: FillArc(const nsRect& aRect,
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
nsRenderingContextXp :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
if (nsLineStyle_kNone == mCurrLineStyle)
@@ -1057,11 +1060,11 @@ nsRenderingContextXP :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetWidth(char ch, nscoord& aWidth)
nsRenderingContextXp :: GetWidth(char ch, nscoord& aWidth)
{
// Check for common case of getting the width of single space
if ((ch == ' ') && (nsnull != mFontMetrics)) {
nsFontMetricsXP* fontMetricsXP = (nsFontMetricsXP*)mFontMetrics;
nsFontMetricsXp* fontMetricsXP = (nsFontMetricsXp*)mFontMetrics;
return fontMetricsXP->GetSpaceWidth(aWidth);
}
char buf[1];
@@ -1073,7 +1076,7 @@ nsRenderingContextXP :: GetWidth(char ch, nscoord& aWidth)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID)
nsRenderingContextXp :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID)
{
PRUnichar buf[1];
buf[0] = ch;
@@ -1084,7 +1087,7 @@ nsRenderingContextXP :: GetWidth(PRUnichar ch, nscoord &aWidth, PRInt32 *aFontID
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetWidth(const char* aString, nscoord& aWidth)
nsRenderingContextXp :: GetWidth(const char* aString, nscoord& aWidth)
{
return GetWidth(aString, strlen(aString),aWidth);
}
@@ -1093,7 +1096,7 @@ nsRenderingContextXP :: GetWidth(const char* aString, nscoord& aWidth)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetWidth(const char* aString, PRUint32 aLength,
nsRenderingContextXp :: GetWidth(const char* aString, PRUint32 aLength,
nscoord& aWidth)
{
@@ -1114,7 +1117,7 @@ nsRenderingContextXP :: GetWidth(const char* aString, PRUint32 aLength,
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetWidth(const nsString& aString, nscoord& aWidth, PRInt32 *aFontID)
nsRenderingContextXp :: GetWidth(const nsString& aString, nscoord& aWidth, PRInt32 *aFontID)
{
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth, aFontID);
}
@@ -1123,21 +1126,21 @@ nsRenderingContextXP :: GetWidth(const nsString& aString, nscoord& aWidth, PRInt
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoord &aWidth, PRInt32 *aFontID)
nsRenderingContextXp :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoord &aWidth, PRInt32 *aFontID)
{
if (0 == aLength) {
aWidth = 0;
} else {
nsFontMetricsXP* metrics = (nsFontMetricsXP*) mFontMetrics;
nsFontXP *prevFont = nsnull;
nsFontMetricsXp* metrics = (nsFontMetricsXp*) mFontMetrics;
nsFontXp *prevFont = nsnull;
int rawWidth = 0;
PRUint32 start = 0;
PRUint32 i;
for (i = 0; i < aLength; i++) {
PRUnichar c = aString[i];
nsFontXP* currFont = nsnull;
nsFontXP** font = metrics->mLoadedFonts;
nsFontXP** end = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
nsFontXp* currFont = nsnull;
nsFontXp** font = metrics->mLoadedFonts;
nsFontXp** end = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
while (font < end) {
if (IS_REPRESENTABLE((*font)->mMap, c)) {
currFont = *font;
@@ -1178,7 +1181,7 @@ FoundFont:
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawString(const char *aString, PRUint32 aLength,
nsRenderingContextXp :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing)
{
@@ -1250,7 +1253,7 @@ nsRenderingContextXP :: DrawString(const char *aString, PRUint32 aLength,
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nsRenderingContextXp :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
@@ -1273,15 +1276,15 @@ nsRenderingContextXP :: DrawString(const PRUnichar *aString, PRUint32 aLength,
mTranMatrix->TransformCoord(&x, &y);
nsFontMetricsXP* metrics = (nsFontMetricsXP*) mFontMetrics;
nsFontXP* prevFont = nsnull;
nsFontMetricsXp* metrics = (nsFontMetricsXp*) mFontMetrics;
nsFontXp* prevFont = nsnull;
PRUint32 start = 0;
PRUint32 i;
for (i = 0; i < aLength; i++) {
PRUnichar c = aString[i];
nsFontXP* currFont = nsnull;
nsFontXP** font = metrics->mLoadedFonts;
nsFontXP** lastFont = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
nsFontXp* currFont = nsnull;
nsFontXp** font = metrics->mLoadedFonts;
nsFontXp** lastFont = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
while (font < lastFont) {
if (IS_REPRESENTABLE((*font)->mMap, c)) {
currFont = *font;
@@ -1347,7 +1350,7 @@ FoundFont:
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawString(const nsString& aString,nscoord aX, nscoord aY, PRInt32 aFontID,
nsRenderingContextXp :: DrawString(const nsString& aString,nscoord aX, nscoord aY, PRInt32 aFontID,
const nscoord* aSpacing)
{
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aFontID, aSpacing);
@@ -1357,8 +1360,10 @@ nsRenderingContextXP :: DrawString(const nsString& aString,nscoord aX, nscoord a
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
nsRenderingContextXp :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::DrawImage(%d/%d)\n", (int)aX, (int)aY));
nscoord width, height;
// we have to do this here because we are doing a transform below
@@ -1372,9 +1377,12 @@ nsRenderingContextXP :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nsRenderingContextXp :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::DrawImage(%d/%d/%d/%d)\n",
(int)aX, (int)aY, (int)aWidth, (int)aHeight));
nscoord x, y, w, h;
x = aX;
@@ -1391,42 +1399,109 @@ nsRenderingContextXP :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
nsRenderingContextXp :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
{
nsRect sr,dr;
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::DrawImage(aSRect,aDRect)\n"));
nsRect sr,dr;
sr = aSRect;
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
sr.x = aSRect.x;
sr.y = aSRect.y;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
sr = aSRect;
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
sr.x = aSRect.x;
sr.y = aSRect.y;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
dr = aDRect;
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
return mPrintContext->DrawImage(aImage,
sr.x, sr.y,
sr.width, sr.height,
dr.x, dr.y,
dr.width, dr.height);
dr = aDRect;
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
return mPrintContext->DrawImage(aImage,
sr.x, sr.y,
sr.width, sr.height,
dr.x, dr.y,
dr.width, dr.height);
}
/** ---------------------------------------------------
* See documentation ndow_private/in nsIRenderingContext.h
*/
NS_IMETHODIMP
nsRenderingContextXP :: DrawImage(nsIImage *aImage, const nsRect& aRect)
nsRenderingContextXp :: DrawImage(nsIImage *aImage, const nsRect& aRect)
{
return DrawImage(aImage, aRect.x, aRect.y,
aRect.width, aRect.height);
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::DrawImage(aRect)\n"));
return DrawImage(aImage, aRect.x, aRect.y,
aRect.width, aRect.height);
}
#ifdef USE_IMG2
#include "imgIContainer.h"
#include "gfxIImageFrame.h"
#include "nsIInterfaceRequestor.h"
/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
NS_IMETHODIMP nsRenderingContextXp::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
{
nsPoint pt;
nsRect sr;
pt = *aDestPoint;
mTranMatrix->TransformCoord(&pt.x, &pt.y);
sr = *aSrcRect;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
nsCOMPtr<gfxIImageFrame> iframe;
aImage->GetCurrentFrame(getter_AddRefs(iframe));
if (!iframe) return NS_ERROR_FAILURE;
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
if (!img) return NS_ERROR_FAILURE;
// doesn't it seem like we should use more of the params here?
// img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height,
// pt.x + sr.x, pt.y + sr.y, sr.width, sr.height);
return mPrintContext->DrawImage(img, pt.x, pt.y, sr.width, sr.height);
}
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
NS_IMETHODIMP nsRenderingContextXp::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
{
nsRect dr;
dr = *aDestRect;
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
nsCOMPtr<gfxIImageFrame> iframe;
aImage->GetCurrentFrame(getter_AddRefs(iframe));
if (!iframe) return NS_ERROR_FAILURE;
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
if (!img) return NS_ERROR_FAILURE;
// doesn't it seem like we should use more of the params here?
// img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height, dr.x, dr.y, dr.width, dr.height);
nsRect sr;
sr = *aSrcRect;
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
sr.x = aSrcRect->x;
sr.y = aSrcRect->y;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
return mPrintContext->DrawImage(img,
sr.x, sr.y,
sr.width, sr.height,
dr.x, dr.y,
dr.width, dr.height);
}
#endif /* USE_IMG2 */
#ifdef MOZ_MATHML
/**
* Returns metrics (in app units) of an 8-bit character string
*/
NS_IMETHODIMP
nsRenderingContextXP::GetBoundingMetrics(const char* aString,
nsRenderingContextXp::GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
{
@@ -1466,7 +1541,7 @@ nsRenderingContextXP::GetBoundingMetrics(const char* aString,
* Returns metrics (in app units) of a Unicode character string
*/
NS_IMETHODIMP
nsRenderingContextXP::GetBoundingMetrics(const PRUnichar* aString,
nsRenderingContextXp::GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID)
@@ -1475,8 +1550,8 @@ nsRenderingContextXP::GetBoundingMetrics(const PRUnichar* aString,
if (!aString || 0 > aLength) {
return NS_OK;
}
nsFontMetricsXP* metrics = (nsFontMetricsXP*) mFontMetrics;
nsFontXP* prevFont = nsnull;
nsFontMetricsXp* metrics = (nsFontMetricsXp*) mFontMetrics;
nsFontXp* prevFont = nsnull;
nsBoundingMetrics rawbm;
PRBool firstTime = PR_TRUE;
@@ -1484,9 +1559,9 @@ nsRenderingContextXP::GetBoundingMetrics(const PRUnichar* aString,
PRUint32 i;
for (i = 0; i < aLength; i++) {
PRUnichar c = aString[i];
nsFontXP* currFont = nsnull;
nsFontXP** font = metrics->mLoadedFonts;
nsFontXP** end = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
nsFontXp* currFont = nsnull;
nsFontXp** font = metrics->mLoadedFonts;
nsFontXp** end = &metrics->mLoadedFonts[metrics->mLoadedFontsCount];
while (font < end) {
if (IS_REPRESENTABLE((*font)->mMap, c)) {
currFont = *font;
@@ -1545,16 +1620,19 @@ FoundFont:
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
*/
NS_IMETHODIMP nsRenderingContextXP :: CopyOffScreenBits(nsDrawingSurface aSrcSurf,
NS_IMETHODIMP nsRenderingContextXp :: CopyOffScreenBits(nsDrawingSurface aSrcSurf,
PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds,
PRUint32 aCopyFlags)
{
NS_NOTREACHED("nsRenderingContextXp::CopyOffScreenBits() not yet implemented");
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextXP::RetrieveCurrentNativeGraphicData(PRUint32 * ngd)
NS_IMETHODIMP nsRenderingContextXp::RetrieveCurrentNativeGraphicData(PRUint32 * ngd)
{
NS_NOTREACHED("nsRenderingContextXp::RetrieveCurrentNativeGraphicData() not yet implemented");
return NS_OK;
}
@@ -1562,33 +1640,32 @@ NS_IMETHODIMP nsRenderingContextXP::RetrieveCurrentNativeGraphicData(PRUint32 *
* See documentation in nsIRenderingContext.h
*/
void
nsRenderingContextXP :: SetupFontAndColor(void)
nsRenderingContextXp :: SetupFontAndColor(void)
{
return;
}
#ifdef NOTNOW
HPEN nsRenderingContextXP :: SetupSolidPen(void)
HPEN nsRenderingContextXp :: SetupSolidPen(void)
{
return mCurrPen;
}
HPEN nsRenderingContextXP :: SetupDashedPen(void)
HPEN nsRenderingContextXp :: SetupDashedPen(void)
{
return mCurrPen;
}
HPEN nsRenderingContextXP :: SetupDottedPen(void)
HPEN nsRenderingContextXp :: SetupDottedPen(void)
{
return mCurrPen;
}
#endif
#endif /* NOTNOW */
#ifdef DC
NS_IMETHODIMP
nsRenderingContextXP::GetColor(nsString& aColor)
nsRenderingContextXp::GetColor(nsString& aColor)
{
char cbuf[40];
PR_snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
@@ -1600,7 +1677,7 @@ nsRenderingContextXP::GetColor(nsString& aColor)
}
NS_IMETHODIMP
nsRenderingContextXP::SetColor(const nsString& aColor)
nsRenderingContextXp::SetColor(const nsString& aColor)
{
nscolor rgb;
if (NS_ColorNameToRGB(aColor, &rgb)) {
@@ -1611,4 +1688,6 @@ nsRenderingContextXP::SetColor(const nsString& aColor)
}
return NS_OK;
}
#endif
#endif /* DC */

View File

@@ -20,8 +20,8 @@
* Contributor(s):
*/
#ifndef nsRenderingContextXP_h___
#define nsRenderingContextXP_h___
#ifndef nsRenderingContextXp_h___
#define nsRenderingContextXp_h___ 1
#include "nsRenderingContextImpl.h"
#include "nsUnitConversion.h"
@@ -36,16 +36,16 @@
#include "nsRect.h"
#include "nsDeviceContextXP.h"
#include "nsVoidArray.h"
#include "nsRegionXP.h"
#include "nsRegionXlib.h"
class XP_State;
class nsXPrintContext;
class nsRenderingContextXP : public nsRenderingContextImpl
class nsRenderingContextXp : public nsRenderingContextImpl
{
public:
nsRenderingContextXP();
virtual ~nsRenderingContextXP();
nsRenderingContextXp();
virtual ~nsRenderingContextXp();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
@@ -162,6 +162,12 @@ public:
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
#ifdef USE_IMG2
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
#endif
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
@@ -190,10 +196,10 @@ private:
void PushClipState(void);
protected:
nsCOMPtr<nsIDeviceContextXP> mContext;
nsCOMPtr<nsIDeviceContextXp> mContext;
nsXPrintContext *mPrintContext;
nsIFontMetrics *mFontMetrics;
nsRegionXP *mClipRegion;
nsRegionXlib *mClipRegion;
float mP2T;
nscolor mCurrentColor;
@@ -201,10 +207,8 @@ protected:
XP_State *mStates;
nsVoidArray *mStateCache;
XFontStruct *mCurrentFont;
//state management
PRUint8 *mGammaTable;
};
#endif /* nsRenderingContextXP_h___ */
#endif /* !nsRenderingContextXp_h___ */

View File

@@ -30,11 +30,16 @@
#include "nsXPrintContext.h"
#include "xprintutil.h"
//#define HACK_PRINTONSCREEN 1
//#define XPRINT_PRINT_IMAGES 1
#ifdef PR_LOGGING
/* DEBUG: use
* % export NSPR_LOG_MODULES=nsXPrintContext:5
* to see these debug messages...
*/
static PRLogModuleInfo *nsXPrintContextLM = PR_NewLogModule("nsXPrintContext");
#endif /* PR_LOGGING */
#ifdef __SUNPRO_C
extern "C" /* Make Sun Workshop and other conformant compilers happy... :-) */
@@ -45,7 +50,7 @@ int xerror_handler(Display *display, XErrorEvent *ev)
/* this should _never_ be happen... but if this happens - debug mode or not - scream !!! */
char errmsg[80];
XGetErrorText(display, ev->error_code, errmsg, sizeof(errmsg));
fprintf(stderr, "lib_xprint: Warning (X Error) - %s\n", errmsg);
fprintf(stderr, "nsGfxXprintModule: Warning (X Error) - %s\n", errmsg);
return 0;
}
@@ -63,8 +68,8 @@ nsXPrintContext::nsXPrintContext()
mGC = (GC)None;
mDrawable = (Drawable)None;
mDepth = 0;
mAlphaPixmap = (Pixmap)None;
mImagePixmap = (Pixmap)None;
mIsGrayscale = PR_FALSE; /* default is color output */
mIsAPrinter = PR_TRUE; /* default destination is printer */
}
/** ---------------------------------------------------
@@ -86,11 +91,12 @@ nsXPrintContext::~nsXPrintContext()
#endif /* HACK_PRINTONSCREEN */
NS_IMETHODIMP
nsXPrintContext::Init(nsIDeviceContextSpecXP *aSpec)
nsXPrintContext::Init(nsIDeviceContextSpecXp *aSpec)
{
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::Init()\n"));
int prefDepth = 24; /* 24 or 8 */
int prefDepth = 8; /* 24 or 8...
* I wish current Xprt would have a StaticGray visual... ;-( */
char *buf;
/* print on screen(="normal" Xserver) is "DEBUG" for now...
@@ -101,11 +107,11 @@ nsXPrintContext::Init(nsIDeviceContextSpecXP *aSpec)
{
mPDisplay = (Display *)XOpenDisplay(nsnull);
mScreen = XDefaultScreenOfDisplay(mPDisplay);
mScreenNumber = XScreenNumberOfScreen(mScreen);
xlib_rgb_init_with_depth(mPDisplay, mScreen, prefDepth);
mScreenNumber = XDefaultScreen(mPDisplay);
SetupWindow(0, 0, 1200, 1200);
mPrintResolution = 300;
mTextZoom = 1.0f;
XMapWindow(mPDisplay, mDrawable);
}
else
@@ -124,7 +130,6 @@ nsXPrintContext::Init(nsIDeviceContextSpecXP *aSpec)
XpGetPageDimensions(mPDisplay, mPContext, &width, &height, &rect);
SetupWindow(rect.x, rect.y, rect.width, rect.height);
mTextZoom = 2.4f; // should this be printer_DPI / display_DPI ?
XMapWindow(mPDisplay, mDrawable);
}
@@ -144,27 +149,28 @@ nsXPrintContext::SetupWindow(int x, int y, int width, int height)
("nsXPrintContext::SetupWindow: x=%d y=%d width=%d height=%d\n",
x, y, width, height));
XSetWindowAttributes xattributes;
long xattributes_mask;
Window parent_win;
XVisualInfo *visual_info;
unsigned long gcmask;
XGCValues gcvalues;
XSetWindowAttributes xattributes;
long xattributes_mask;
Window parent_win;
XVisualInfo *visual_info;
unsigned long gcmask;
XGCValues gcvalues;
mWidth = width;
mHeight = height;
visual_info = xlib_rgb_get_visual_info();
parent_win = RootWindow(mPDisplay, mScreenNumber);
xattributes.background_pixel = WhitePixel (mPDisplay, mScreenNumber);
xattributes.border_pixel = BlackPixel (mPDisplay, mScreenNumber);
xattributes.background_pixel = WhitePixel(mPDisplay, mScreenNumber);
xattributes.border_pixel = BlackPixel(mPDisplay, mScreenNumber);
xattributes_mask |= CWBorderPixel | CWBackPixel;
mDrawable = (Drawable)XCreateSimpleWindow(mPDisplay,
parent_win,
x, y,
width, height,
0, BlackPixel(mPDisplay, mScreenNumber),
0,
BlackPixel(mPDisplay, mScreenNumber),
WhitePixel(mPDisplay, mScreenNumber));
mDepth = XDefaultDepth(mPDisplay, mScreenNumber);
mVisual = XDefaultVisual(mPDisplay, mScreenNumber);
@@ -179,16 +185,17 @@ nsXPrintContext::SetupWindow(int x, int y, int width, int height)
NS_IMETHODIMP
nsXPrintContext::SetupPrintContext(nsIDeviceContextSpecXP *aSpec)
nsXPrintContext::SetupPrintContext(nsIDeviceContextSpecXp *aSpec)
{
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::SetupPrintContext()\n"));
int printSize;
float top, bottom, left, right;
char *buf;
int printSize;
float top, bottom, left, right;
char *buf;
// Get the Attributes
aSpec->GetToPrinter(mIsAPrinter);
aSpec->GetGrayscale(mIsGrayscale);
aSpec->GetSize(printSize);
aSpec->GetTopMargin(top);
aSpec->GetBottomMargin(bottom);
@@ -382,18 +389,43 @@ nsXPrintContext::DrawImage(nsIImage *aImage,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::DrawImage(%d/%d/%d/%d - %d/%d/%d/%d)\n",
(int)aSX, (int)aSY, (int)aSWidth, (int)aSHeight,
(int)aDX, (int)aDY, (int)aDWidth, (int)aDHeight));
PRUint8 *image_bits = aImage->GetBits();
PRInt32 row_bytes = aImage->GetLineStride();
NS_ASSERTION((aSWidth==aDWidth)&&(aSHeight==aDHeight),
"nsXPrintContext::DrawImage(): Image scaling not implemented yet... ,-( .");
#ifdef XPRINT_PRINT_IMAGES
// XpSetImageResolution(mPDisplay, mPContext, new_res, &prev_res);
xlib_draw_gray_image(mDrawable,
mGC,
aDX, aDY, aDWidth, aDHeight,
XLIB_RGB_DITHER_MAX,
image_bits + row_bytes * aSY + 3 * aDX,
row_bytes);
if( mIsGrayscale )
{
xlib_draw_gray_image(mDrawable,
mGC,
aDX, aDY, aDWidth, aDHeight,
XLIB_RGB_DITHER_MAX,
image_bits + row_bytes * aSY + 3 * aDX,
row_bytes);
}
else
{
xlib_draw_rgb_image(mDrawable,
mGC,
aDX, aDY, aDWidth, aDHeight,
XLIB_RGB_DITHER_MAX,
image_bits + row_bytes * aSY + 3 * aDX,
row_bytes);
}
// XpSetImageResolution(mPDisplay, mPContext, prev_res, &new_res);
#else
XDrawRectangle(mPDisplay, mDrawable, mGC, aDX, aDY, aDWidth, aDHeight);
#endif /* XPRINT_PRINT_IMAGES */
return NS_OK;
}
@@ -403,34 +435,38 @@ NS_IMETHODIMP
nsXPrintContext::DrawImage(nsIImage *aImage,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
{
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::DrawImage(%d/%d/%d/%d)\n",
(int)aX, (int)aY, (int)aWidth, (int)aHeight));
#ifdef XPRINT_PRINT_IMAGES
PRInt32 width = aImage->GetWidth();
PRInt32 height = aImage->GetHeight();
PRUint8 *alphaBits = aImage->GetAlphaBits();
PRInt32 alphaRowBytes = aImage->GetAlphaLineStride();
PRUint8 *image_bits = aImage->GetBits();
PRInt32 row_bytes = aImage->GetLineStride();
Pixmap alpha_pixmap = None;
Pixmap image_pixmap = None;
// XXX kipp: this is temporary code until we eliminate the
// width/height arguments from the draw method.
if ((aWidth != width) || (aHeight != height))
{
aWidth = width;
aHeight = height;
aWidth = width;
aHeight = height;
}
XImage *x_image = nsnull;
GC gc;
XGCValues gcv;
// Create gc clip-mask on demand
if ((alphaBits != nsnull) && (mAlphaPixmap == None)) {
if (mAlphaPixmap==None) {
mAlphaPixmap = XCreatePixmap(mPDisplay,
RootWindow(mPDisplay, mScreenNumber),
aWidth, aHeight, 1); /* ToDo: Check for error */
}
if ( alphaBits != nsnull ) {
XImage *x_image = nsnull;
GC gc;
XGCValues gcv;
alpha_pixmap = XCreatePixmap(mPDisplay,
mDrawable,
aWidth, aHeight, 1); /* ToDo: Check for error */
/* Make an image out of the alpha-bits created by the image library (ToDo: check for error) */
x_image = XCreateImage(mPDisplay, mVisual,
1, /* visual depth...1 for bitmaps */
@@ -448,9 +484,9 @@ nsXPrintContext::DrawImage(nsIImage *aImage,
x_image->bitmap_bit_order = MSBFirst;
/* This definition doesn't depend on client byte ordering
because the image library ensures that the bytes in
bitmask data are arranged left to right on the screen,
low to high address in memory. */
* because the image library ensures that the bytes in
* bitmask data are arranged left to right on the screen,
* low to high address in memory. */
x_image->byte_order = MSBFirst;
#if defined(IS_LITTLE_ENDIAN)
// no, it's still MSB XXX check on this!!
@@ -460,79 +496,98 @@ nsXPrintContext::DrawImage(nsIImage *aImage,
#else
#error ERROR! Endianness is unknown;
#endif
// Write into the pixemap that is underneath gdk's mAlphaPixmap
// Write into the pixemap that is underneath gdk's alpha_pixmap
// the image we just created.
memset(&gcv, 0, sizeof(XGCValues));
gcv.function = GXcopy;
gc = XCreateGC(mPDisplay, mAlphaPixmap, GCFunction, &gcv);
gc = XCreateGC(mPDisplay, alpha_pixmap, GCFunction, &gcv);
XPutImage(mPDisplay, mAlphaPixmap, gc, x_image, 0, 0, 0, 0,
XPutImage(mPDisplay, alpha_pixmap, gc, x_image, 0, 0, 0, 0,
aWidth, aHeight);
XFreeGC(mPDisplay, gc);
// Now we are done with the temporary image
x_image->data = 0; /* Don't free the IL_Pixmap's bits. */
x_image->data = nsnull; /* Don't free the IL_Pixmap's bits. */
XDestroyImage(x_image);
}
if (mImagePixmap == None) {
// Create an off screen pixmap to hold the image bits.
mImagePixmap = XCreatePixmap(mPDisplay,
RootWindow(mPDisplay, mScreenNumber),
aWidth, aHeight,
mDepth);
XSetClipOrigin(mPDisplay, mGC, 0, 0);
XSetClipMask(mPDisplay, mGC, None);
GC gc;
XGCValues xvalues;
unsigned long xvalues_mask;
// Create an off screen pixmap to hold the image bits.
image_pixmap = XCreatePixmap(mPDisplay,
mDrawable,
aWidth, aHeight,
mDepth);
XSetClipOrigin(mPDisplay, mGC, 0, 0);
XSetClipMask(mPDisplay, mGC, None);
GC gc;
XGCValues xvalues;
unsigned long xvalues_mask;
xvalues.function = GXcopy;
xvalues.fill_style = FillSolid;
xvalues.arc_mode = ArcPieSlice;
xvalues.subwindow_mode = ClipByChildren;
xvalues.graphics_exposures = True;
xvalues_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures;
xvalues.function = GXcopy;
xvalues.fill_style = FillSolid;
xvalues.arc_mode = ArcPieSlice;
xvalues.subwindow_mode = ClipByChildren;
xvalues.graphics_exposures = True;
xvalues_mask = GCFunction | GCFillStyle | GCArcMode | GCSubwindowMode | GCGraphicsExposures;
gc = XCreateGC(mPDisplay, mImagePixmap, xvalues_mask, &xvalues);
gc = XCreateGC(mPDisplay, image_pixmap, xvalues_mask, &xvalues);
// XpSetImageResolution(mPDisplay, mPContext, new_res, &prev_res);
xlib_draw_rgb_image(mImagePixmap,
// XpSetImageResolution(mPDisplay, mPContext, new_res, &prev_res);
if( mIsGrayscale )
{
xlib_draw_gray_image(image_pixmap,
gc,
0, 0, aWidth, aHeight,
XLIB_RGB_DITHER_MAX,
image_bits, row_bytes);
}
else
{
xlib_draw_rgb_image(image_pixmap,
gc,
0, 0, aWidth, aHeight,
XLIB_RGB_DITHER_NONE,
XLIB_RGB_DITHER_MAX,
image_bits, row_bytes);
// XpSetImageResolution(mPDisplay, mPContext, prev_res, &new_res);
}
// XpSetImageResolution(mPDisplay, mPContext, prev_res, &new_res);
if (mAlphaPixmap != None)
XFreeGC(mPDisplay, gc);
if (alpha_pixmap != None)
{
// set up the gc to use the alpha pixmap for clipping
XSetClipOrigin(mPDisplay, mGC, aX, aY);
XSetClipMask(mPDisplay, mGC, mAlphaPixmap);
XSetClipMask(mPDisplay, mGC, alpha_pixmap);
}
// copy our off screen pixmap onto the window.
XCopyArea(mPDisplay, // display
mImagePixmap, // source
image_pixmap, // source
mDrawable, // dest
mGC, // GC
0, 0, // xsrc, ysrc
aWidth, aHeight, // width, height
aX, aY); // xdest, ydest
if (mAlphaPixmap != None)
if (alpha_pixmap != None)
{
XSetClipOrigin(mPDisplay, mGC, 0, 0);
XSetClipMask(mPDisplay, mGC, None);
}
if( image_pixmap != None ) XFreePixmap(mPDisplay, image_pixmap);
if( alpha_pixmap != None ) XFreePixmap(mPDisplay, alpha_pixmap);
#else
XDrawRectangle(mPDisplay, mDrawable, mGC, aX, aY, aWidth, aHeight);
#endif /* XPRINT_PRINT_IMAGES */
return NS_OK;
}
NS_IMETHODIMP nsXPrintContext::GetPrintResolution(int &aPrintResolution) const
{
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::GetPrintResolution()\n"));
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::GetPrintResolution() res=%d\n",
(int)mPrintResolution));
aPrintResolution = mPrintResolution;
return NS_OK;

View File

@@ -43,7 +43,7 @@ public:
nsXPrintContext();
virtual ~nsXPrintContext();
NS_IMETHOD Init(nsIDeviceContextSpecXP *aSpec);
NS_IMETHOD Init(nsIDeviceContextSpecXp *aSpec);
NS_IMETHOD BeginPage();
NS_IMETHOD EndPage();
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
@@ -60,7 +60,6 @@ public:
Display * GetDisplay() { return mPDisplay; }
NS_IMETHOD GetPrintResolution(int &aPrintResolution) const;
NS_IMETHOD GetTextZoom(float &aTextZoom) const { aTextZoom = mTextZoom; return NS_OK; }
NS_IMETHOD DrawImage(nsIImage *aImage,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
@@ -78,23 +77,21 @@ private:
Screen *mScreen;
Visual *mVisual;
GC mGC;
Drawable mDrawable;
Drawable mDrawable; /* window */
XImage *mImage;
int mDepth;
int mScreenNumber;
Pixmap mAlphaPixmap;
Pixmap mImagePixmap;
int mWidth;
int mHeight;
XPContext mPContext;
PRBool mIsAPrinter;
char *mPrintFile; /* file to "print" to */
PRBool mIsGrayscale; /* color or grayscale ? */
PRBool mIsAPrinter; /* destination: printer or file ? */
char *mPrintFile; /* file to "print" to */
void *mXpuPrintToFileHandle; /* handle for XpuPrintToFile/XpuWaitForPrintFileChild when printing to file */
long mPrintResolution;
float mTextZoom;
NS_IMETHOD SetupWindow(int x, int y, int width, int height);
NS_IMETHOD SetupPrintContext(nsIDeviceContextSpecXP *aSpec);
NS_IMETHOD SetupPrintContext(nsIDeviceContextSpecXp *aSpec);
};

View File

@@ -30,6 +30,8 @@
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "xprintutil.h"
#include <stdlib.h>
#include <string.h>
@@ -37,12 +39,6 @@
#include <limits.h>
#include <errno.h>
#define NeedFunctionPrototypes (1) /* is this legal from within an app. !? */
#include <X11/Xlibint.h>
#include <X11/extensions/Print.h>
#include <X11/Intrinsic.h>
#include "xprintutil.h"
/*
** XprintUtil functions start with Xpu

View File

@@ -1,4 +1,6 @@
#ifndef XPRINTUTIL_H
#define XPRINTUTIL_H 1
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
@@ -30,7 +32,13 @@
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef NeedFunctionPrototypes
#define NeedFunctionPrototypes (1) /* is this legal from within an app. !? */
#endif
#include <X11/Xlibint.h>
#include <X11/extensions/Print.h>
#include <X11/Intrinsic.h>
/* I don't know how to make this "better" yet... ;-( */
#ifdef USE_MOZILLA_TYPES
@@ -86,4 +94,5 @@ XPGetDocStatus XpuWaitForPrintFileChild( void *handle );
_XFUNCPROTOEND
#endif /* !XPRINTUTIL_H */
/* EOF. */

View File

@@ -30,6 +30,8 @@
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "xprintutil.h"
#include <stdlib.h>
#include <string.h>
@@ -40,18 +42,13 @@
#include <time.h>
#include <pthread.h>
#else
#ifdef __sun
#include <wait.h>
#endif /* __sun */
#endif /* XPU_USE_THREADS */
#include <unistd.h>
#include <sys/time.h>
#define NeedFunctionPrototypes (1) /* is this legal from within an app. !? */
#include <X11/Xlibint.h>
#include <X11/extensions/Print.h>
#include <X11/Intrinsic.h>
#include "xprintutil.h"
/* local prototypes */
#ifdef DEBUG
static void PrintXPGetDocStatus( XPGetDocStatus status );