Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::PrintSession Class Reference

The PrintSession is the core printing class. More...

#include <vcf/GraphicsKit/PrintSession.h>

Inheritance diagram for VCF::PrintSession:

VCF::Object List of all members.

Public Types

enum  { PageBegunEvent = 102231, PageDoneEvent, PrintingBegunEvent, PrintingFinishedEvent }
enum  { UnknownPage = -1 }
enum  PrintJob { pjPrintAll = 0, pjPrintSelectedPage, pjPrintRange }
enum  PageSize {
  psA4, psB5, psLetter, psLegal,
  psExecutive, psA0, psA1, psA2,
  psA3, psA5, psA6, psA7,
  psA8, psA9, psB0, psB1,
  psB10, psB2, psB3, psB4,
  psB6, psB7, psB8, psB9,
  psC5E, psComm10E, psDLE, psFolio,
  psLedger, psTabloid, psCustom
}
 An enumeration of different standard page sizes. More...
enum  PageSizeUnits {
  psuPixels = 0, psuPoints, psuInches, psuMillimeters,
  psuTwips
}
 The page units. More...

Public Member Functions

 PrintSession ()
virtual ~PrintSession ()
double getDPI ()
 Returns the dots per inch (DPI) for this session.
String getTitle ()
 returns the title for the print session.
void setTitle (const String &title)
 Set the title for the print session.
void setDefaultPageSettings ()
 Sets the print sessions settings to default values appropriate for the platform.
Size getPageSize ()
 returns the page size in pixels, adjusted for the DPI of the printing device.
Size getPageSizeIn (PageSizeUnits units)
 Returns the page size in the scale of the units requested.
void setPageSize (const Size &pageSize)
 Sets the page size.
void setPageSizeIn (const Size &pageSize, PageSizeUnits units)
 Sets the page size using the requested units.
void setStandardPageSize (const PageSize &pageSize)
 Sets the page size in one of the standard page size enumerations.
void setStartPage (const uint32 &startPage)
 Sets the page number to start printing with.
uint32 getStartPage ()
 returns the page this session wil use to start printing
void setEndPage (const uint32 &endPage)
 Sets the last page to print.
uint32 getEndPage ()
 Returns the last page to print for this session.
std::vector< uint32getPrintablePages ()
 Returns a vector of printable pages.
void setPrintablePages (const std::vector< uint32 > &printablePages)
Rect getPageDrawingRect ()
 Returns the page rect in pixel units.
void setPageDrawingRect (const Rect &drawingRect)
 Sets the page drawing rect.
PrintInfoHandle getPrintInfoHandle ()
 returns the print info handle.
void setPrintInfoHandle (PrintInfoHandle info)
void abort ()
 Aborts the current printing session.
PrintContextbeginPrintingDocument ()
 Starts printing the document.
void endPrintingDocument ()
 This ends the printing for the document.
void beginPage (PrintContext *context)
 This should be called for each page of the "document" that you want to print.
void endPage (PrintContext *context)
 This should be called for each page of the "document" once you are finished with that page.
void runDefaultPrintLoop ()
 This is a high level function that can attempt to run a print loop through all the pages of the printing document, starting with the first page, and ending with the last page.

Public Attributes

VCF::Delegate PrintDelegate
 PageBegun
 PageDone
 PrintingBegun
 PrintingFinished

Protected Attributes

String title_
PrintSessionPeerpeer_
bool errorDuringPrinting_
int currentPage_

Detailed Description

The PrintSession is the core printing class.

You use it to set things up with default attributes, to start printing, to end printing, to start a new page, and to end the page.

Event Delegates for this class:


Member Enumeration Documentation

anonymous enum
 

Enumerator:
PageBegunEvent 
PageDoneEvent 
PrintingBegunEvent 
PrintingFinishedEvent 

anonymous enum
 

Enumerator:
UnknownPage 

enum VCF::PrintSession::PageSize
 

An enumeration of different standard page sizes.

Enumerator:
psA4 
psB5 
psLetter 
psLegal 
psExecutive 
psA0 
psA1 
psA2 
psA3 
psA5 
psA6 
psA7 
psA8 
psA9 
psB0 
psB1 
psB10 
psB2 
psB3 
psB4 
psB6 
psB7 
psB8 
psB9 
psC5E 
psComm10E 
psDLE 
psFolio 
psLedger 
psTabloid 
psCustom 

enum VCF::PrintSession::PageSizeUnits
 

The page units.

Enumerator:
psuPixels  This is the default page unit.
psuPoints  Points - where 72 points make 1 inch.
psuInches  Inches.

To determine the number of pixels in an inch you need to get the Dots Per Inch (or DPI) from the GraphicsToolkit

See also:
GraphicsToolkit::getDPI()
psuMillimeters  Millimeters.

There are 25.4 millimeters in 1 inch.

psuTwips  Twips.

There are 1400 twips in 1 inch.

enum VCF::PrintSession::PrintJob
 

Enumerator:
pjPrintAll 
pjPrintSelectedPage 
pjPrintRange 


Constructor & Destructor Documentation

VCF::PrintSession::PrintSession  ) 
 

virtual VCF::PrintSession::~PrintSession  )  [virtual]
 


Member Function Documentation

void VCF::PrintSession::abort  ) 
 

Aborts the current printing session.

void VCF::PrintSession::beginPage PrintContext context  ) 
 

This should be called for each page of the "document" that you want to print.

See also:
endPage()

PrintContext* VCF::PrintSession::beginPrintingDocument  ) 
 

Starts printing the document.

This will return a new instance of a PrintContext for which the caller is responsible for.

void VCF::PrintSession::endPage PrintContext context  ) 
 

This should be called for each page of the "document" once you are finished with that page.

For example, this will print a single page:

        PrintSession session;
        
        PrintContext* ctx = session.beginPrintingDocument();
        session.beginPage( ctx );

        //your code here that draws in the ctx

        session.endPage( ctx );

        session.endPrintingDocument();

void VCF::PrintSession::endPrintingDocument  ) 
 

This ends the printing for the document.

double VCF::PrintSession::getDPI  ) 
 

Returns the dots per inch (DPI) for this session.

Note that the DPI value for this maybe quite a bit higher than the value returned by GraphicsToolkit::getDPI(NULL), which returns the screen based DPI, whereas this returns the printing device DPI.

Returns:
double a value that represents the dots (pixels) per inch for the print session's printing device.

uint32 VCF::PrintSession::getEndPage  ) 
 

Returns the last page to print for this session.

Rect VCF::PrintSession::getPageDrawingRect  ) 
 

Returns the page rect in pixel units.

Size VCF::PrintSession::getPageSize  ) 
 

returns the page size in pixels, adjusted for the DPI of the printing device.

Size VCF::PrintSession::getPageSizeIn PageSizeUnits  units  ) 
 

Returns the page size in the scale of the units requested.

Parameters:
units the units to use when returning the page size
Returns:
Size the width and height of the page in the units requested.

std::vector<uint32> VCF::PrintSession::getPrintablePages  ) 
 

Returns a vector of printable pages.

The default, assuming the start page was set to 1, and the end page to 10, might look like:

        element     page
            0       1
            1       2
            2       3
            3       4
            4       5
            5       6
            6       7
            7       8
            8       9
            9       10
However, if the user only selected page 2, 4, 5, and 9, then it would look like:
        element     page
            0       2
            1       4
            2       5
            3       9

PrintInfoHandle VCF::PrintSession::getPrintInfoHandle  ) 
 

returns the print info handle.

This is an opaque handle to a platform specific struct, and you cannot manipulate it other than to pass it to other printing classes.

uint32 VCF::PrintSession::getStartPage  ) 
 

returns the page this session wil use to start printing

String VCF::PrintSession::getTitle  ) 
 

returns the title for the print session.

On some platform this may be displayed in the UI for displaying print progress.

void VCF::PrintSession::runDefaultPrintLoop  ) 
 

This is a high level function that can attempt to run a print loop through all the pages of the printing document, starting with the first page, and ending with the last page.

        PrintSession session;
        session.setStartPage( 1 );
        session.setEndPage( 10 );

        session.runDefaultPrintLoop(); //this will print 10 pages. 

This will call beginPrintingDocument(), endPrintingDocument(), beginPage(), and endPage(), as appropriate. You can handle the actual drawing by add an event handler to the PageBegun delegate, which will get fired for each page. See the example in vcf/examples/Printing for a more complete example of this.

void VCF::PrintSession::setDefaultPageSettings  ) 
 

Sets the print sessions settings to default values appropriate for the platform.

void VCF::PrintSession::setEndPage const uint32 endPage  ) 
 

Sets the last page to print.

void VCF::PrintSession::setPageDrawingRect const Rect drawingRect  ) 
 

Sets the page drawing rect.

void VCF::PrintSession::setPageSize const Size pageSize  ) 
 

Sets the page size.

Assumes the width and height are in pixels.

void VCF::PrintSession::setPageSizeIn const Size pageSize,
PageSizeUnits  units
 

Sets the page size using the requested units.

void VCF::PrintSession::setPrintablePages const std::vector< uint32 > &  printablePages  ) 
 

void VCF::PrintSession::setPrintInfoHandle PrintInfoHandle  info  ) 
 

void VCF::PrintSession::setStandardPageSize const PageSize pageSize  ) 
 

Sets the page size in one of the standard page size enumerations.

void VCF::PrintSession::setStartPage const uint32 startPage  ) 
 

Sets the page number to start printing with.

void VCF::PrintSession::setTitle const String title  ) 
 

Set the title for the print session.


Member Data Documentation

int VCF::PrintSession::currentPage_ [protected]
 

bool VCF::PrintSession::errorDuringPrinting_ [protected]
 

VCF::PrintSession::PageBegun
 

VCF::PrintSession::PageDone
 

PrintSessionPeer* VCF::PrintSession::peer_ [protected]
 

VCF::Delegate VCF::PrintSession::PrintDelegate
 

Event Delegate:
PageBegun fired when the beginPage() method is called.
event class: PrintEvent
event type: PrintSession::PageBegunEvent

VCF::PrintSession::PrintingBegun
 

VCF::PrintSession::PrintingFinished
 

String VCF::PrintSession::title_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information