1 /*
2  * Copyright 2014 Zane U. Ji.
3  *
4  * This file is part of Xml Copy Editor.
5  *
6  * Xml Copy Editor is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * Xml Copy Editor is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Xml Copy Editor; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 #ifndef MYPRINTOUT_H_
22 #define MYPRINTOUT_H_
23 
24 #include <wx/prntbase.h>
25 #include <vector>
26 
27 class XmlDoc;
28 
29 class MyPrintout: public wxPrintout
30 {
31 public:
32 	MyPrintout ( XmlDoc *doc, const wxString &title );
33 	virtual ~MyPrintout();
34 
35 	virtual void OnPreparePrinting();
36 
37 	virtual void OnBeginPrinting();
38 	virtual void OnEndPrinting();
39 
40 	virtual bool HasPage ( int nPage );
41 	virtual bool OnPrintPage ( int nPage );
42 	virtual void GetPageInfo ( int *minPage, int *maxPage, int *pageFrom
43 			, int *pageTo );
44 
45 	static wxPageSetupDialogData &GetPageData();
46 
47 protected:
48 	void SetupDC();
49 
50 	int CalcMaxPage();
51 
52 	// Returns the height of the header
53 	int PrintHeader();
54 	// Returns the height of the footer
55 	int PrintFooter();
56 
57 protected:
58 	XmlDoc *mDoc;
59 	int mMinPage, mMaxPage; // 1 based
60 	std::vector<int> mStartPositions; // Start positions of each page
61 	wxRect mPrintRect, mPageRect;
62 };
63 
64 #endif /* MYPRINTOUT_H_ */
65