PHOTON build only
Updates for drawing and Printing
This commit is contained in:
Родитель
ce112cef66
Коммит
f30be61560
|
@ -44,6 +44,7 @@ CPPSRCS = \
|
|||
nsRenderingContextPh.cpp \
|
||||
nsScreenPh.cpp \
|
||||
nsScreenManagerPh.cpp \
|
||||
nsPrintOptionsPh.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -71,6 +71,8 @@ nsDeviceContextPh :: nsDeviceContextPh()
|
|||
|
||||
mSpec = nsnull;
|
||||
mDC = nsnull;
|
||||
|
||||
mIsPrinting = 0;
|
||||
}
|
||||
|
||||
nsDeviceContextPh :: ~nsDeviceContextPh()
|
||||
|
@ -155,7 +157,6 @@ nsresult nsDeviceContextPh :: Init(nsNativeDeviceContext aContext, nsIDeviceCont
|
|||
mHeightFloat = (float)(psize->h / 10);
|
||||
dim.w = psize->w / 10;
|
||||
dim.h = psize->h / 10;
|
||||
printf("PRINT: %d, %d\n", (int)mWidthFloat, (int)mHeightFloat);
|
||||
PpPrintSetPC(pc, INITIAL_PC, 0 , Pp_PC_SOURCE_SIZE, &dim );
|
||||
|
||||
return NS_OK;
|
||||
|
@ -175,10 +176,8 @@ void nsDeviceContextPh :: GetPrinterRect(int *width, int *height)
|
|||
memset( &rect, 0, sizeof(rect));
|
||||
memset( &margins, 0, sizeof(margins));
|
||||
|
||||
printf("PC: %X\n", pc);
|
||||
PpPrintGetPC(pc, Pp_PC_PAPER_SIZE, (const void **)&psize );
|
||||
PpPrintGetPC(pc, Pp_PC_NONPRINT_MARGINS, (const void **)&non_print );
|
||||
printf("SIZE: %d, %d\n", psize->w, psize->h);
|
||||
dim.w = (psize->w - ( non_print->ul.x + non_print->lr.x )) * 100 / 1000;
|
||||
dim.h = (psize->h - ( non_print->ul.x + non_print->lr.x )) * 100 / 1000;
|
||||
|
||||
|
@ -473,7 +472,7 @@ NS_IMETHODIMP nsDeviceContextPh :: GetClientRect(nsRect &aRect)
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if ( mSpec )
|
||||
if (mIsPrinting) //( mSpec )
|
||||
{
|
||||
// we have a printer device
|
||||
aRect.x = 0;
|
||||
|
@ -543,9 +542,8 @@ NS_IMETHODIMP nsDeviceContextPh :: ConvertPixel(nscolor aColor, PRUint32 & aPixe
|
|||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
|
||||
{
|
||||
if (mSpec)
|
||||
if (mIsPrinting) //(mSpec)
|
||||
{
|
||||
printf("PRINT: GetDeviceSurfaceDimensions\n");
|
||||
aWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
|
||||
aHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
|
||||
return (NS_OK);
|
||||
|
@ -645,114 +643,46 @@ NS_IMETHODIMP nsDeviceContextPh :: BeginDocument(void)
|
|||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
|
||||
PhDrawContext_t *dc = PhDCSetCurrent(NULL);
|
||||
printf("Begin: %X, ", dc);
|
||||
PhDCSetCurrent(dc);
|
||||
|
||||
PpStartJob(pc);
|
||||
PpContinueJob(pc);
|
||||
|
||||
dc = PhDCSetCurrent(NULL);
|
||||
printf("%X\n", dc);
|
||||
PhDCSetCurrent(dc);
|
||||
|
||||
mIsPrinting = 1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: EndDocument(void)
|
||||
{
|
||||
printf("EndDocument\n");
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
PpSuspendJob(pc);
|
||||
PpEndJob(pc);
|
||||
mIsPrinting = 0;
|
||||
return NS_OK;
|
||||
#if 0
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndDocument - Not Implemented\n"));
|
||||
nsresult ret_code = NS_ERROR_FAILURE;
|
||||
|
||||
/* convert the mSpec into a nsDeviceContextPh */
|
||||
if (mSpec)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndDocument - mSpec=<%p>\n", mSpec));
|
||||
nsDeviceContextSpecPh * PrintSpec = nsnull;
|
||||
mSpec->QueryInterface(kIDeviceContextSpecIID, (void**) &PrintSpec);
|
||||
if (PrintSpec)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndDocument - PriontSpec=<%p>\n", PrintSpec));
|
||||
|
||||
PpPrintContext_t *PrinterContext = nsnull;
|
||||
PrintSpec->GetPrintContext( PrinterContext );
|
||||
if (PrinterContext)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndDocument - PrinterContext=<%p>\n", PrinterContext));
|
||||
|
||||
int err;
|
||||
err = PpPrintClose(PrinterContext);
|
||||
if (err == 0)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndDocument - err=<%d>\n", err));
|
||||
ret_code = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(PrintSpec);
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: BeginPage(void)
|
||||
{
|
||||
printf("BeginPage\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: EndPage(void)
|
||||
{
|
||||
printf("EndPage\n");
|
||||
PpPrintNewPage(((nsDeviceContextSpecPh *)mSpec)->GetPrintContext());
|
||||
return NS_OK;
|
||||
#if 0
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndPage - Not Implemented\n"));
|
||||
|
||||
nsresult ret_code = NS_ERROR_FAILURE;
|
||||
|
||||
/* convert the mSpec into a nsDeviceContextPh */
|
||||
if (mSpec)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndPage - mSpec=<%p>\n", mSpec));
|
||||
nsDeviceContextSpecPh * PrintSpec = nsnull;
|
||||
mSpec->QueryInterface(kIDeviceContextSpecIID, (void**) &PrintSpec);
|
||||
if (PrintSpec)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndPage - PriontSpec=<%p>\n", PrintSpec));
|
||||
|
||||
PpPrintContext_t *PrinterContext = nsnull;
|
||||
PrintSpec->GetPrintContext( PrinterContext );
|
||||
if (PrinterContext)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndPage - PrinterContext=<%p>\n", PrinterContext));
|
||||
|
||||
int err;
|
||||
err = PpPrintNewPage(PrinterContext);
|
||||
if (err == 0)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::EndPage - err=<%d>\n", err));
|
||||
ret_code = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(PrintSpec);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int nsDeviceContextPh :: IsPrinting(void)
|
||||
{
|
||||
if (mSpec)
|
||||
return 1;
|
||||
if (mIsPrinting)
|
||||
return (1);
|
||||
|
||||
// if (mSpec)
|
||||
// return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -104,6 +104,8 @@ protected:
|
|||
|
||||
static nscoord mDpi;
|
||||
|
||||
int mIsPrinting;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextPh_h___ */
|
||||
|
|
|
@ -56,45 +56,21 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIDeviceC
|
|||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PpPrintContext_t *pc = nsnull;
|
||||
int action;
|
||||
|
||||
/* Create a Printer Context */
|
||||
pc = PpPrintCreatePC();
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIDeviceContextSpec *devSpec = nsnull;
|
||||
|
||||
#if 0
|
||||
/* copy over user selections from prOps to PrintContext */
|
||||
if (aOldSpec)
|
||||
devSpec = aOldSpec;
|
||||
else
|
||||
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
|
||||
|
||||
/* REVISIT: Need to find my parent widget */
|
||||
action = PtPrintSelection(NULL, NULL, NULL, pc, (Pt_PRINTSEL_DFLT_LOOK));
|
||||
if (action == Pt_PRINTSEL_PRINT)
|
||||
if (devSpec != nsnull)
|
||||
{
|
||||
#else
|
||||
PpLoadPrinter(pc, NULL);
|
||||
printf("LoadPrinter: %X\n", pc);
|
||||
#endif
|
||||
|
||||
nsIDeviceContextSpec *devSpec = nsnull;
|
||||
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
|
||||
|
||||
if (nsnull != devSpec)
|
||||
if (NS_OK == ((nsDeviceContextSpecPh *)devSpec)->Init(aQuiet))
|
||||
{
|
||||
/* Pass ownership of the "pc" to the nsDeviceContextSpecPh */
|
||||
if (NS_OK == ((nsDeviceContextSpecPh *)devSpec)->Init(aQuiet, pc))
|
||||
{
|
||||
aNewSpec = devSpec;
|
||||
aNewSpec = devSpec;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
}
|
||||
else if (action == Pt_PRINTSEL_PREVIEW)
|
||||
{
|
||||
/* REVISIT: Somehow trigger a Print Preview? */
|
||||
}
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -21,20 +21,21 @@
|
|||
*/
|
||||
|
||||
#include "nsDeviceContextSpecPh.h"
|
||||
#include "nsPrintOptionsPh.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsPhGfxLog.h"
|
||||
|
||||
nsDeviceContextSpecPh :: nsDeviceContextSpecPh()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mPC = nsnull;
|
||||
NS_INIT_REFCNT();
|
||||
mPC = nsnull;
|
||||
}
|
||||
|
||||
nsDeviceContextSpecPh :: ~nsDeviceContextSpecPh()
|
||||
{
|
||||
if (mPC)
|
||||
PpPrintReleasePC(mPC);
|
||||
if (mPC)
|
||||
PpPrintReleasePC(mPC);
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
|
@ -43,11 +44,46 @@ NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecPh, kDeviceContextSpecIID)
|
|||
NS_IMPL_ADDREF(nsDeviceContextSpecPh)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecPh)
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecPh :: Init(PRBool aQuiet, PpPrintContext_t *aPrintContext)
|
||||
NS_IMETHODIMP nsDeviceContextSpecPh :: Init(PRBool aQuiet)
|
||||
{
|
||||
/* Create a Printer Context */
|
||||
mPC = aPrintContext; /* Assume ownership of the Printer Context */
|
||||
return NS_OK;
|
||||
int action;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mPC)
|
||||
mPC = PpCreatePC();
|
||||
|
||||
if (aQuiet)
|
||||
{
|
||||
// no dialogs
|
||||
PpLoadDefaultPrinter(mPC);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 1
|
||||
action = PtPrintSelection(NULL, NULL, NULL, mPC, (Pt_PRINTSEL_DFLT_LOOK));
|
||||
switch (action)
|
||||
{
|
||||
case Pt_PRINTSEL_PRINT:
|
||||
case Pt_PRINTSEL_PREVIEW:
|
||||
rv = NS_OK;
|
||||
break;
|
||||
case Pt_PRINTSEL_CANCEL:
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// do native print options
|
||||
nsIPrintOptions *printOptions = new nsPrintOptionsPh((void *)mPC);
|
||||
if ((nsPrintOptionsPh *)printOptions->ShowNativeDialog() != NS_OK)
|
||||
{
|
||||
// cancel
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
delete printOptions;
|
||||
#endif
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//NS_IMETHODIMP nsDeviceContextSpecPh :: GetPrintContext(PpPrintContext_t *&aPrintContext) const
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(PRBool aQuiet, PpPrintContext_t *aPrintContext);
|
||||
NS_IMETHOD Init(PRBool aQuiet);
|
||||
//NS_IMETHOD GetPrintContext(PpPrintContext_t *&aPrintContext) const;
|
||||
PpPrintContext_t *GetPrintContext();
|
||||
|
||||
|
|
|
@ -21,22 +21,50 @@
|
|||
*/
|
||||
#include "nsPrintOptionsPh.h"
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS1(nsPrintOptionsPh, nsIPrintOptions)
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsWin.h
|
||||
* @update 6/21/00 dwc
|
||||
*/
|
||||
nsPrintOptionsPh::nsPrintOptionsPh()
|
||||
nsPrintOptionsPh::nsPrintOptionsPh(void *data)
|
||||
{
|
||||
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
mPC = (PpPrintContext_t *) data;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsImpl.h
|
||||
* @update 6/21/00 dwc
|
||||
*/
|
||||
nsPrintOptionsPh::~nsPrintOptionsPh()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* void SetMargins (in PRInt32 aTop, in PRInt32 aLeft, in PRInt32 aRight, in PRInt32 aBottom); */
|
||||
NS_IMETHODIMP nsPrintOptionsPh::SetMargins(PRInt32 aTop, PRInt32 aLeft, PRInt32 aRight, PRInt32 aBottom)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void GetMargins (out PRInt32 aTop, out PRInt32 aLeft, out PRInt32 aRight, out PRInt32 aBottom); */
|
||||
NS_IMETHODIMP nsPrintOptionsPh::GetMargins(PRInt32 *aTop, PRInt32 *aLeft, PRInt32 *aRight, PRInt32 *aBottom)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void ShowNativeDialog (); */
|
||||
NS_IMETHODIMP nsPrintOptionsPh::ShowNativeDialog()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
int action;
|
||||
|
||||
action = PtPrintSelection(NULL, NULL, NULL, mPC, (Pt_PRINTSEL_DFLT_LOOK));
|
||||
switch (action)
|
||||
{
|
||||
case Pt_PRINTSEL_PRINT:
|
||||
case Pt_PRINTSEL_PREVIEW:
|
||||
rv = NS_OK;
|
||||
break;
|
||||
case Pt_PRINTSEL_CANCEL:
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -23,21 +23,27 @@
|
|||
#ifndef nsPrintOptionsPh_h__
|
||||
#define nsPrintOptionsPh_h__
|
||||
|
||||
#include "nsPrintOptionsImpl.h"
|
||||
//#include "nsPrintOptionsImpl.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
#include <Pt.h>
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintOptions
|
||||
//*****************************************************************************
|
||||
class nsPrintOptionsPh : public nsPrintOptions
|
||||
|
||||
/* Header file */
|
||||
class nsPrintOptionsPh : public nsIPrintOptions
|
||||
{
|
||||
public:
|
||||
nsPrintOptionsPh();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPRINTOPTIONS
|
||||
|
||||
nsPrintOptionsPh(void *data);
|
||||
virtual ~nsPrintOptionsPh();
|
||||
|
||||
|
||||
private:
|
||||
PpPrintContext_t *mPC;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* nsPrintOptions_h__ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче