![]() |
wxIScan
|
Class to print out an image. More...
#include <wxiviewprintout.h>
Public Member Functions | |
wxIViewPrintout (wxIViewPaintBase *poPaint, const wxString &strTitle=wxT("wxIViewPrintout"), bool bFitToPage=true, int nResolutionX=(180), int nResolutionY=(180)) | |
Standard constructor. | |
virtual void | GetPageInfo (int *nMinPage, int *nMaxPage, int *nSelPageFrom, int *nSelPageTo) |
From the wxWidgets documentation: Called by the framework to obtain information from the application about minimum and maximum page values that the user can select, and the required page range to be printed. By default this returns 1, 32000 for the page minimum and maximum values, and 1, 1 for the required page range. If minPage is zero, the page number controls in the print dialog will be disabled. | |
virtual bool | HasPage (int nPage) |
From the wxWidgets documentation: Should be overridden to return true if the document has this page, or false if not. Returning false signifies the end of the document. By default, HasPage behaves as if the document has only one page. | |
virtual bool | OnPrintPage (int nPage) |
From the wxWidgets documentation: Called by the framework when a page should be printed. Returning false cancels the print job. The application can use wxPrintout::GetDC to obtain a device context to draw on. | |
Protected Attributes | |
wxIViewPaintBase * | m_poPaint |
Pointer to the parent object. | |
bool | m_bFitToPage |
Flag: Should the output scaled to fix the printer page? | |
int | m_nResolutionX |
Resolution in width direction in DPI. | |
int | m_nResolutionY |
Resolution in height direction in DPI. |
Class to print out an image.
Images can be multipage images, too.
Definition at line 29 of file wxiviewprintout.h.
wxIViewPrintout::wxIViewPrintout | ( | wxIViewPaintBase * | poPaint, |
const wxString & | strTitle = wxT( "wxIViewPrintout" ) , |
||
bool | bFitToPage = true , |
||
int | nResolutionX = (180) , |
||
int | nResolutionY = (180) |
||
) |
Standard constructor.
poPaint | a pointer to an instance of wxIViewPaintBase |
strTitle | the window caption text, defaults to "wxIViewPrintout" |
bFitToPage | flag to indicate it the image is to be scaled to full page size, defaults to true |
nResolutionX | horizontal resolution of the image in dpi, defaults to wxivIMAGEPPIX |
nResolutionY | vertical resolution of the image in dpi, defaults to wxivIMAGEPPIY |
Definition at line 31 of file wxiviewprintout.cpp.
References m_bFitToPage, m_nResolutionX, m_nResolutionY, and m_poPaint.
: wxPrintout( strTitle ) { // Initialize member variables. m_poPaint= poPaint; m_bFitToPage= bFitToPage; m_nResolutionX= nResolutionX; m_nResolutionY= nResolutionY; }
void wxIViewPrintout::GetPageInfo | ( | int * | nMinPage, |
int * | nMaxPage, | ||
int * | nSelPageFrom, | ||
int * | nSelPageTo | ||
) | [virtual] |
From the wxWidgets documentation: Called by the framework to obtain information from the application about minimum and maximum page values that the user can select, and the required page range to be printed. By default this returns 1, 32000 for the page minimum and maximum values, and 1, 1 for the required page range. If minPage is zero, the page number controls in the print dialog will be disabled.
nMinPage | ... |
nMaxPage | ... |
nSelPageFrom | ... |
nSelPageTo | ... |
Definition at line 51 of file wxiviewprintout.cpp.
References wxIViewPaintBase::GetMaxPage(), and m_poPaint.
Referenced by HasPage().
{ // Return 1 for the minimal page number and the correct number of pages // returned by wxIViewPaintBase::GetMaxPage() (if a valid wxIViewPaintBase object // is connnected to the wxIViewPrint object). (*nMinPage)= (*nMaxPage)= (*nSelPageFrom)= (*nSelPageTo)= 1; if( m_poPaint ) { (*nMaxPage)= (*nSelPageTo)= m_poPaint->GetMaxPage(); } }
bool wxIViewPrintout::HasPage | ( | int | nPage | ) | [virtual] |
From the wxWidgets documentation: Should be overridden to return true if the document has this page, or false if not. Returning false signifies the end of the document. By default, HasPage behaves as if the document has only one page.
nPage | page number to print |
Definition at line 69 of file wxiviewprintout.cpp.
References GetPageInfo().
{ int nMinPage; int nMaxPage; int nDummy; GetPageInfo( &nMinPage, &nMaxPage, &nDummy, &nDummy ); return ( nPage >= nMinPage) && ( nPage <= nMaxPage ); }
bool wxIViewPrintout::OnPrintPage | ( | int | nPage | ) | [virtual] |
From the wxWidgets documentation: Called by the framework when a page should be printed. Returning false cancels the print job. The application can use wxPrintout::GetDC to obtain a device context to draw on.
nPage | page number to print |
Definition at line 83 of file wxiviewprintout.cpp.
References wxIViewPaintBase::GetPageSizeMM(), wxIViewPaintBase::GotoPage(), m_bFitToPage, m_nResolutionX, m_nResolutionY, m_poPaint, and wxIViewPaintBase::Paint().
{ // Check validity of the wxIViewPaintBase object (normaly the wxIViewFrame object). if( !m_poPaint ) { // Signal error. return false; } // Get a device context. wxDC *oDc = GetDC(); // Check validity of the device context. if( !oDc ) { // Signal error. return false; } // Get printer resolution ... int nPrinterPpiX; int nPrinterPpiY; GetPPIPrinter( &nPrinterPpiX, &nPrinterPpiY ); // ... and adjust scalation factor using image resolution. // // NOTE: We asume a fixed image resolution of 180 PPI in X and Y direction // until there is a possibility to get the image resoltuion from // image (EXIF/IPTC) itself. You can change this value by changing // nResolutionX and wxivIMAGEPPIY in file wxIViewPaint.h. // double nScaleFactorX; double nScaleFactorY; if( IsPreview() ) { int nPageWidth; int nPageHeight; int nDcWidth; int nDcHeight; oDc->GetSize( &nDcWidth, &nDcHeight ); GetPageSizePixels( &nPageWidth, &nPageHeight ); nScaleFactorX= (double)nPrinterPpiX / (double)m_nResolutionX * (double)nDcWidth / (double)nPageWidth; nScaleFactorY= (double)nPrinterPpiY / (double)m_nResolutionY * (double)nDcHeight / (double)nPageHeight; } else { nScaleFactorX= (double)nPrinterPpiX / (double)m_nResolutionX; nScaleFactorY= (double)nPrinterPpiY / (double)m_nResolutionY; } // Scale image to fit full page size if given. if( m_bFitToPage ) { int nImageWidthMM; int nImageHeightMM; int nPageWidthMM; int nPageHeightMM; if( m_poPaint->GetPageSizeMM( &nImageWidthMM, &nImageHeightMM ) ) { GetPageSizeMM( &nPageWidthMM, &nPageHeightMM ); double nFitToPageScaleFactorX= (double)nPageWidthMM / (double)nImageWidthMM; double nFitToPageScaleFactorY= (double)nPageHeightMM / (double)nImageHeightMM; if( nFitToPageScaleFactorX > nFitToPageScaleFactorY ) { nFitToPageScaleFactorX= nFitToPageScaleFactorY; } nScaleFactorX *= nFitToPageScaleFactorX; nScaleFactorY *= nFitToPageScaleFactorX; } } // Set device origin to (0, 0). oDc->SetDeviceOrigin( 0, 0 ); // Set scale factor. oDc->SetUserScale( nScaleFactorX, nScaleFactorY ); // Set printer page... if( !m_poPaint->GotoPage( nPage ) ) { return false; } // ... and paint it. return m_poPaint->Paint( *oDc ); }
bool wxIViewPrintout::m_bFitToPage [protected] |
Flag: Should the output scaled to fix the printer page?
Definition at line 77 of file wxiviewprintout.h.
Referenced by OnPrintPage(), and wxIViewPrintout().
int wxIViewPrintout::m_nResolutionX [protected] |
Resolution in width direction in DPI.
Definition at line 78 of file wxiviewprintout.h.
Referenced by OnPrintPage(), and wxIViewPrintout().
int wxIViewPrintout::m_nResolutionY [protected] |
Resolution in height direction in DPI.
Definition at line 79 of file wxiviewprintout.h.
Referenced by OnPrintPage(), and wxIViewPrintout().
wxIViewPaintBase* wxIViewPrintout::m_poPaint [protected] |
Pointer to the parent object.
Definition at line 76 of file wxiviewprintout.h.
Referenced by GetPageInfo(), OnPrintPage(), and wxIViewPrintout().