/*
 * ************************************************************************************************************
 * Author: Marcin Załęczny
 * Copyright (C)2011 Marcin Załęczny <mzaleczny@hotmail.com>
 * License: The GNU Lesser General Public License, version 3.0 (LGPLv3)
 * Library Name: mzstdprint
 * Version: 1.02
 * First release date:   2011-02-03
 * Current release date: 2011-03-04
 *
 *
 * This file is part of mzstdprint library
 * 
 * mzstdprint library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * mzstdprint library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************************************************
 */

#ifndef __MZSTDPRINT_PRINT_TASK_H__
#define __MZSTDPRINT_PRINT_TASK_H__

#include "mzstdprintCommon.h"
#include "mzObject.h"
#include "mzString.h"
#include <winspool.h>


class CCanvas;
class DECLSPEC_MZSTDPRINT CPrintTask : public CObject {
public:
	WINAPI CPrintTask(CString documentName = L"Document", LONG pageCount = 1);
    virtual WINAPI ~CPrintTask();
    VOID WINAPI setPrinterProperties(WCHAR* printerName, HANDLE hPrinter, BYTE* devmode, DWORD devmodeSize, HDC printerDC,
                        DWORD printJobId, DOCINFO* docInfo);
    // Should return TRUE if page printed properly.
    virtual BOOL WINAPI printPage(LONG pageNumber, CCanvas* canvas) {return TRUE;}
    virtual VOID WINAPI onPrintingAborted() {};
    VOID WINAPI abortPrinting() { this->_abort = TRUE; }
    inline BOOL WINAPI getAbortFlag() { return this->_abort; }
    inline LONG WINAPI getPageCount() { return this->_pageCount; }
    inline CString WINAPI getDocumentName() { return this->_documentName; }

protected:
    CString     _documentName;

    // All Pointer attributes are not for release inside this class. They point to appropriate values in CPrinter
    // class.
    CString     _printerName;
    HANDLE      _hPrinter;
    BYTE*       _devmode;
    DWORD       _devmodeSize;
    HDC         _printerDC;
    DWORD       _printJobId;
    DOCINFO*    _docInfo;
    
    // Initially set to FALSE. Set it to TRUE if printing should be aborted.
    BOOL        _abort;
    LONG        _pageCount;
};
typedef CPrintTask* PPrintTask;

#endif
