printmanager.h

Go to the documentation of this file.
00001 // ****************************************************************************
00002 //
00003 // DESCRIPTION: Declaration of the Print Manager
00004 // PATTERN    : Singleton
00005 // CREATED BY : Michael Pittman
00006 // HISTORY    : 12/21/1998
00007 //
00008 // ****************************************************************************
00009 #pragma once
00010 
00011 #include "coreexp.h"
00012 #include <WTypes.h>
00013 #include "strbasic.h"
00014 
00015 class PrintManager
00016 {
00017 private:
00018     static PrintManager* m_instance;    // Singleton instance
00019     HDC                  m_hdc;         // Device context of printer
00020     int                  m_ncopies;     // Number of copies to print
00021     bool                 m_landscape;   // Print in landscape?  
00022 
00023     PRINTDLG             m_pinfo;       // Printer info from PrintDlg
00024     PAGESETUPDLG         m_pgsetup;     // Page Setup info from PageSetupDlg
00025     DEVMODE              m_devmode;     // Device mode structure
00026     MCHAR                m_driver[128]; // Printer driver name
00027     MCHAR                m_device[33];  // Printer device name
00028     bool                 m_use_pgsetup; // User has chosen page setup
00029 
00030     PrintManager();
00031 
00032     bool SetupPrintFromDialog(HWND parent);
00033     bool SetupPrintExisting(void);
00034     bool SetupPrintDefault(void);
00035 
00036 public:
00037     enum PrinterChoice
00038     {
00039         k_UseDefault,
00040         k_PromptUser,
00041         k_UseExisting
00042     };
00043 
00044     ~PrintManager();
00045 
00046     // Access to the singleton
00047     CoreExport static PrintManager* Instance(void);
00048 
00049     // Query methods
00050     CoreExport HDC GetPrinterDC(PrinterChoice getfrom = k_PromptUser);
00051     CoreExport HDC GetDefaultPrinterDC(void) { return GetPrinterDC(k_UseDefault); }
00052     CoreExport HDC GetExistingPrinterDC(void) { return GetPrinterDC(k_UseExisting); }
00053     CoreExport void ReleasePrinterDC(HDC hdc);
00054     CoreExport int NumberCopies(void) { return m_ncopies; }
00055     CoreExport bool DoLandscape(void) { return m_landscape; }
00056 
00057     // The standard print methods interface
00058     CoreExport bool OnPageSetup(HWND parent);
00059 };
00060