Initial
This commit is contained in:
216
test/Printman.hpp
Normal file
216
test/Printman.hpp
Normal file
@@ -0,0 +1,216 @@
|
||||
#ifndef _TEST_PRINTMANAGER_HPP_
|
||||
#define _TEST_PRINMANAGER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_PUREDEVICE_HPP_
|
||||
#include <common/purehdc.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FONT_HPP_
|
||||
#include <common/font.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SMARTPOINTER_HPP_
|
||||
#include <common/pointer.hpp>
|
||||
#endif
|
||||
#ifndef _BONEYARD_PRINTER_HPP_
|
||||
#include <test/printer.hpp>
|
||||
#endif
|
||||
#ifndef _TEST_VINFO_HPP_
|
||||
#include <test/vinfo.hpp>
|
||||
#endif
|
||||
#ifndef _TEST_ABORTDLG_HPP_
|
||||
#include <test/abortdlg.hpp>
|
||||
#endif
|
||||
|
||||
class GUIWindow;
|
||||
|
||||
class PrintManager
|
||||
{
|
||||
public:
|
||||
PrintManager(void);
|
||||
virtual ~PrintManager();
|
||||
const String &strDefaultPrinter(void)const;
|
||||
BOOL openPrinter(const String &strPrinterName,GUIWindow &parentWindow,const String &strPrintDocName=String());
|
||||
BOOL openPrinter(const String &strPrinterName,const String &strPrintDocName=String());
|
||||
void closePrinter(void);
|
||||
PureDevice &printerDevice(void);
|
||||
BOOL startPage(void);
|
||||
BOOL endPage(void);
|
||||
BOOL endDoc(void);
|
||||
BOOL abortDoc(void);
|
||||
BOOL printLines(Block<String> &strLines,Font &pageFont,Point xyPoint);
|
||||
WORD getCount(void)const;
|
||||
const Printer &getDefaultPrinter(void)const;
|
||||
BOOL getFirstPrinter(Printer &printer);
|
||||
BOOL getNextPrinter(Printer &printer);
|
||||
private:
|
||||
BOOL getPrinters(void);
|
||||
BOOL getPrinter(String &strPrinterKey,Printer &printer);
|
||||
PrintManager(const PrintManager &somePrintmanager);
|
||||
PrintManager &operator=(const PrintManager &somePrintManager);
|
||||
BOOL operator==(const PrintManager &somePrintManager);
|
||||
BOOL isInPage(void)const;
|
||||
void isInPage(BOOL isInPage);
|
||||
BOOL isInDoc(void)const;
|
||||
void isInDoc(BOOL isInDoc);
|
||||
BOOL startDoc(const String &strPrintDocName);
|
||||
BOOL createAbortDlg(void);
|
||||
static BOOL CALLBACK abortProc(HDC hDC,int nCode);
|
||||
|
||||
static Block<VInfo> smVInfoBlock;
|
||||
SmartPointer<GUIWindow> mParentWindow;
|
||||
SmartPointer<AbortDlg> mAbortDlg;
|
||||
Block<Printer> mPrinters;
|
||||
Printer mDefaultPrinter;
|
||||
PureDevice mPrinterDevice;
|
||||
WORD mIndexPrinter;
|
||||
BOOL mIsInDoc;
|
||||
BOOL mIsInPage;
|
||||
};
|
||||
|
||||
inline
|
||||
PrintManager::PrintManager(void)
|
||||
: mIndexPrinter(0), mIsInDoc(FALSE), mIsInPage(FALSE)
|
||||
{
|
||||
getPrinters();
|
||||
}
|
||||
|
||||
inline
|
||||
PrintManager::PrintManager(const PrintManager &somePrintManager)
|
||||
{ // private implementation
|
||||
*this=somePrintManager;
|
||||
}
|
||||
|
||||
inline
|
||||
PrintManager::~PrintManager()
|
||||
{
|
||||
closePrinter();
|
||||
}
|
||||
|
||||
inline
|
||||
PrintManager &PrintManager::operator=(const PrintManager &/*somePrintManager*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::operator==(const PrintManager &somePrintManager)
|
||||
{ // private implementation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD PrintManager::getCount(void)const
|
||||
{
|
||||
return mPrinters.size();
|
||||
}
|
||||
|
||||
inline
|
||||
const Printer &PrintManager::getDefaultPrinter(void)const
|
||||
{
|
||||
return mDefaultPrinter;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::getFirstPrinter(Printer &printer)
|
||||
{
|
||||
if(!mPrinters.size())return FALSE;
|
||||
printer=mPrinters[(mIndexPrinter=0)];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::getNextPrinter(Printer &printer)
|
||||
{
|
||||
if(++mIndexPrinter>=mPrinters.size())return FALSE;
|
||||
printer=mPrinters[mIndexPrinter];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
void PrintManager::closePrinter(void)
|
||||
{
|
||||
if(isInPage())endPage();
|
||||
if(isInDoc())endDoc();
|
||||
mPrinterDevice.destroyDevice();
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::startPage(void)
|
||||
{
|
||||
if(!isInDoc()||!mPrinterDevice.isOkay())return FALSE;
|
||||
if(isInPage())endPage();
|
||||
::StartPage(mPrinterDevice);
|
||||
isInPage(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::endPage(void)
|
||||
{
|
||||
BOOL returnCode(FALSE);
|
||||
|
||||
if(!isInPage()||!isInDoc()||!mPrinterDevice.isOkay())return returnCode;
|
||||
returnCode=::EndPage(mPrinterDevice)?TRUE:FALSE;
|
||||
isInPage(FALSE);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::endDoc(void)
|
||||
{
|
||||
BOOL returnCode(FALSE);
|
||||
|
||||
if(!isInDoc()||!mPrinterDevice.isOkay())return returnCode;
|
||||
if(isInPage())endPage();
|
||||
if(mAbortDlg.isOkay()){mAbortDlg->destroy();mAbortDlg.destroy();}
|
||||
returnCode=::EndDoc(mPrinterDevice)?TRUE:FALSE;
|
||||
isInDoc(FALSE);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::abortDoc(void)
|
||||
{
|
||||
BOOL returnCode(FALSE);
|
||||
|
||||
if(!isInDoc()||!mPrinterDevice.isOkay())return returnCode;
|
||||
returnCode=::AbortDoc(mPrinterDevice)?TRUE:FALSE;
|
||||
isInPage(FALSE);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
inline
|
||||
PureDevice &PrintManager::printerDevice(void)
|
||||
{
|
||||
assert(FALSE!=mPrinterDevice.isOkay());
|
||||
return mPrinterDevice;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::isInDoc(void)const
|
||||
{
|
||||
return mIsInDoc;
|
||||
}
|
||||
|
||||
inline
|
||||
void PrintManager::isInDoc(BOOL isInDoc)
|
||||
{
|
||||
mIsInDoc=isInDoc;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL PrintManager::isInPage(void)const
|
||||
{
|
||||
return mIsInPage;
|
||||
}
|
||||
|
||||
inline
|
||||
void PrintManager::isInPage(BOOL isInPage)
|
||||
{
|
||||
mIsInPage=isInPage;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user