-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintDlg.h
162 lines (136 loc) · 3.89 KB
/
PrintDlg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// WinDjView
// Copyright (C) 2004-2015 Andrew Zhezherun
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// http://www.gnu.org/copyleft/gpl.html
#pragma once
#include "MyDialog.h"
#include "MyEdit.h"
#include "Drawing.h"
class DjVuSource;
class CPrintDlg : public CMyDialog
{
DECLARE_DYNAMIC(CPrintDlg)
public:
CPrintDlg(DjVuSource* pSource, int nPage, int nRotate, int nMode, CWnd* pParent = NULL);
virtual ~CPrintDlg();
// Dialog Data
enum { IDD = IDD_PRINT };
public:
struct Printer
{
CString strPrinterName;
CString strDriverName;
CString strPortName;
CString strComment;
// Device capabilities
bool bCanCollate;
DWORD nMaxCopies;
// Device capabilities that depend on current paper type
int nPhysicalWidth;
int nPhysicalHeight;
int nOffsetLeft;
int nOffsetTop;
int nUserWidth;
int nUserHeight;
};
struct Paper
{
Paper(const CString& name, WORD code, const CSize& sz)
: strName(name), nCode(code), size(sz) {}
CString strName;
WORD nCode;
CSize size;
};
Printer* m_pPrinter;
DEVMODE* m_pDevMode;
Paper* m_pPaper;
HANDLE m_hPrinter;
typedef vector<pair<int, int> > PageArr;
PageArr m_arrPages;
bool m_bHasSelection;
GRect m_rcSelection;
bool IsPrintSelection() const { return m_bHasSelection && m_nRangeType == CurrentSelection; }
void SetCustomRange(const CString& strRange);
DjVuSource* GetSource() const { return m_pSource; }
int GetRotate() const { return m_nRotate; }
int GetMode() const { return m_nMode; }
public:
CPrintSettings m_settings;
BOOL m_bPrintToFile;
protected:
enum RangeType
{
AllPages = 0,
CurrentPage = 1,
CurrentSelection = 2,
CustomRange = 3
};
// Dialog data
CString m_strPages;
int m_nRangeType;
BOOL m_bReverse;
CComboBox m_cboPrinter;
CComboBox m_cboPaper;
CComboBox m_cboPagesPerSheet;
CComboBox m_cboPagesInRange;
CMyEdit m_edtCopies;
CMyEdit m_edtScale;
CMyEdit m_edtMarginBottom;
CMyEdit m_edtMarginTop;
CMyEdit m_edtMarginLeft;
CMyEdit m_edtMarginRight;
CMyEdit m_edtPosLeft;
CMyEdit m_edtPosTop;
// Overrides
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
virtual void OnCancel();
// Implementation
protected:
vector<BYTE> m_printerData;
vector<BYTE> m_devModeData;
vector<Paper> m_paperSizes;
CRect m_rcPreview;
COffscreenDC m_offscreenDC;
DjVuSource* m_pSource;
GP<DjVuImage> m_pCurPage, m_pNextPage;
bool m_bDrawPreview;
int m_nCurPage;
int m_nRotate;
int m_nMode;
vector<int> m_pages;
static map<CString, vector<byte> > s_devModes;
static LPDEVMODE GetCachedDevMode(const CString& strPrinter);
static void UpdateDevModeCache(const CString& strPrinter, LPDEVMODE pDevMode, size_t nSize);
void LoadPaperTypes();
bool ParseRange();
void SaveSettings();
void UpdateDevMode();
void PreviewTwoPages(CDC* pDC, const CRect& rcPage, const CSize& szPaper, double fScreenMM);
// Message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg void OnChangePagesPerSheet();
afx_msg void OnChangePaper();
afx_msg void OnChangePrinter();
afx_msg void OnPrintRange(UINT nID);
afx_msg void OnCopiesUpDown(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnUpdateControls();
afx_msg void OnProperties();
afx_msg void OnUpdateDialogData();
DECLARE_MESSAGE_MAP()
};