Initial
This commit is contained in:
212
printman/PRINTMAN.HPP
Normal file
212
printman/PRINTMAN.HPP
Normal file
@@ -0,0 +1,212 @@
|
||||
#ifndef _PRINTMAN_PRINTMANAGER_HPP_
|
||||
#define _PRINTMAN_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 _COMMON_ASSERT_HPP_
|
||||
#include <common/assert.hpp>
|
||||
#endif
|
||||
#ifndef _PRINTMAN_PRINTER_HPP_
|
||||
#include <printman/printer.hpp>
|
||||
#endif
|
||||
#ifndef _PRINTMAN_ABORTDLG_HPP_
|
||||
#include <printman/abortdlg.hpp>
|
||||
#endif
|
||||
|
||||
class GUIWindow;
|
||||
class Bitmap;
|
||||
class ResBitmap;
|
||||
class PureBitmap;
|
||||
class RegKey;
|
||||
|
||||
class PrintManager
|
||||
{
|
||||
public:
|
||||
PrintManager(void);
|
||||
virtual ~PrintManager();
|
||||
const String &strDefaultPrinter(void)const;
|
||||
bool choosePrinter(GUIWindow &parentWindow,String &strPrinter);
|
||||
bool choosePrinter(GUIWindow &parentWindow,Printer &printer);
|
||||
bool openPrinter(const Printer &printer,GUIWindow &parentWindow,const String &strPrintDocName);
|
||||
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,bool advancePage=TRUE);
|
||||
bool printBitmap(Bitmap &bitmap,bool advancePage=true,int width=0,int height=0);
|
||||
bool printBitmap(ResBitmap &resBitmap,bool advancePage=true,int width=0,int height=0);
|
||||
bool printBitmap(PureBitmap &pureBitmap,bool advancePage=true,int width=0,int height=0);
|
||||
bool printBitmap(PureBitmap &pureBitmap,bool advancePage=true,WORD scale=100);
|
||||
bool printDevice(PureBitmap &pureBitmap,bool advancePage=true);
|
||||
WORD getCount(void)const;
|
||||
const Printer &getDefaultPrinter(void)const;
|
||||
bool getFirstPrinter(Printer &printer);
|
||||
bool getNextPrinter(Printer &printer);
|
||||
private:
|
||||
void scaleImage(float factor,WORD &width,WORD &height)const;
|
||||
bool getPrinters(RegKey ®Key,const String &strPrinterKey);
|
||||
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);
|
||||
|
||||
SmartPointer<GUIWindow> mParentWindow;
|
||||
SmartPointer<AbortDlg> mAbortDlg;
|
||||
Block<Printer> mPrinters;
|
||||
Printer mDefaultPrinter;
|
||||
String mPrinterKey;
|
||||
PureDevice mPrinterDevice;
|
||||
WORD mIndexPrinter;
|
||||
bool mIsInDoc;
|
||||
bool mIsInPage;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
int returnCode;
|
||||
if(!isInDoc()||!mPrinterDevice.isOkay())return FALSE;
|
||||
if(isInPage())endPage();
|
||||
returnCode=::StartPage(mPrinterDevice);
|
||||
if(returnCode>0)isInPage(TRUE);
|
||||
return isInPage();
|
||||
}
|
||||
|
||||
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