]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cmndata.h
Test using wxString::ToCDouble() in wxAny.
[wxWidgets.git] / include / wx / cmndata.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cmndata.h
3 // Purpose: Common GDI data classes
4 // Author: Julian Smart and others
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CMNDATA_H_BASE_
13 #define _WX_CMNDATA_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_PRINTING_ARCHITECTURE
18
19 #include "wx/gdicmn.h"
20
21 #if wxUSE_STREAMS
22 #include "wx/stream.h"
23 #endif
24
25 class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
26
27 /*
28 * wxPrintData
29 * Encapsulates printer information (not printer dialog information)
30 */
31
32 enum wxPrintBin
33 {
34 wxPRINTBIN_DEFAULT,
35
36 wxPRINTBIN_ONLYONE,
37 wxPRINTBIN_LOWER,
38 wxPRINTBIN_MIDDLE,
39 wxPRINTBIN_MANUAL,
40 wxPRINTBIN_ENVELOPE,
41 wxPRINTBIN_ENVMANUAL,
42 wxPRINTBIN_AUTO,
43 wxPRINTBIN_TRACTOR,
44 wxPRINTBIN_SMALLFMT,
45 wxPRINTBIN_LARGEFMT,
46 wxPRINTBIN_LARGECAPACITY,
47 wxPRINTBIN_CASSETTE,
48 wxPRINTBIN_FORMSOURCE,
49
50 wxPRINTBIN_USER
51 };
52
53 const int wxPRINTMEDIA_DEFAULT = 0;
54
55 class WXDLLIMPEXP_CORE wxPrintData: public wxObject
56 {
57 public:
58 wxPrintData();
59 wxPrintData(const wxPrintData& printData);
60 virtual ~wxPrintData();
61
62 int GetNoCopies() const { return m_printNoCopies; }
63 bool GetCollate() const { return m_printCollate; }
64 wxPrintOrientation GetOrientation() const { return m_printOrientation; }
65 bool IsOrientationReversed() const { return m_printOrientationReversed; }
66
67 // Is this data OK for showing the print dialog?
68 bool Ok() const { return IsOk(); }
69 bool IsOk() const ;
70
71 const wxString& GetPrinterName() const { return m_printerName; }
72 bool GetColour() const { return m_colour; }
73 wxDuplexMode GetDuplex() const { return m_duplexMode; }
74 wxPaperSize GetPaperId() const { return m_paperId; }
75 const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
76 // in wxPageSetupDialogData
77 wxPrintQuality GetQuality() const { return m_printQuality; }
78 wxPrintBin GetBin() const { return m_bin; }
79 wxPrintMode GetPrintMode() const { return m_printMode; }
80 int GetMedia() const { return m_media; }
81
82 void SetNoCopies(int v) { m_printNoCopies = v; }
83 void SetCollate(bool flag) { m_printCollate = flag; }
84
85 // Please use the overloaded method below
86 wxDEPRECATED_INLINE(void SetOrientation(int orient),
87 m_printOrientation = (wxPrintOrientation)orient; )
88 void SetOrientation(wxPrintOrientation orient) { m_printOrientation = orient; }
89 void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; }
90
91 void SetPrinterName(const wxString& name) { m_printerName = name; }
92 void SetColour(bool colour) { m_colour = colour; }
93 void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
94 void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
95 void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
96 void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
97 void SetBin(wxPrintBin bin) { m_bin = bin; }
98 void SetMedia(int media) { m_media = media; }
99 void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
100
101 wxString GetFilename() const { return m_filename; }
102 void SetFilename( const wxString &filename ) { m_filename = filename; }
103
104 wxPrintData& operator=(const wxPrintData& data);
105
106 char* GetPrivData() const { return m_privData; }
107 int GetPrivDataLen() const { return m_privDataLen; }
108 void SetPrivData( char *privData, int len );
109
110
111 // Convert between wxPrintData and native data
112 void ConvertToNative();
113 void ConvertFromNative();
114 // Holds the native print data
115 wxPrintNativeDataBase *GetNativeData() const { return m_nativeData; }
116
117 private:
118 wxPrintBin m_bin;
119 int m_media;
120 wxPrintMode m_printMode;
121
122 int m_printNoCopies;
123 wxPrintOrientation m_printOrientation;
124 bool m_printOrientationReversed;
125 bool m_printCollate;
126
127 wxString m_printerName;
128 bool m_colour;
129 wxDuplexMode m_duplexMode;
130 wxPrintQuality m_printQuality;
131 wxPaperSize m_paperId;
132 wxSize m_paperSize;
133
134 wxString m_filename;
135
136 char* m_privData;
137 int m_privDataLen;
138
139 wxPrintNativeDataBase *m_nativeData;
140
141 private:
142 DECLARE_DYNAMIC_CLASS(wxPrintData)
143 };
144
145 /*
146 * wxPrintDialogData
147 * Encapsulates information displayed and edited in the printer dialog box.
148 * Contains a wxPrintData object which is filled in according to the values retrieved
149 * from the dialog.
150 */
151
152 class WXDLLIMPEXP_CORE wxPrintDialogData: public wxObject
153 {
154 public:
155 wxPrintDialogData();
156 wxPrintDialogData(const wxPrintDialogData& dialogData);
157 wxPrintDialogData(const wxPrintData& printData);
158 virtual ~wxPrintDialogData();
159
160 int GetFromPage() const { return m_printFromPage; }
161 int GetToPage() const { return m_printToPage; }
162 int GetMinPage() const { return m_printMinPage; }
163 int GetMaxPage() const { return m_printMaxPage; }
164 int GetNoCopies() const { return m_printNoCopies; }
165 bool GetAllPages() const { return m_printAllPages; }
166 bool GetSelection() const { return m_printSelection; }
167 bool GetCollate() const { return m_printCollate; }
168 bool GetPrintToFile() const { return m_printToFile; }
169
170 void SetFromPage(int v) { m_printFromPage = v; }
171 void SetToPage(int v) { m_printToPage = v; }
172 void SetMinPage(int v) { m_printMinPage = v; }
173 void SetMaxPage(int v) { m_printMaxPage = v; }
174 void SetNoCopies(int v) { m_printNoCopies = v; }
175 void SetAllPages(bool flag) { m_printAllPages = flag; }
176 void SetSelection(bool flag) { m_printSelection = flag; }
177 void SetCollate(bool flag) { m_printCollate = flag; }
178 void SetPrintToFile(bool flag) { m_printToFile = flag; }
179
180 void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }
181 void EnableSelection(bool flag) { m_printEnableSelection = flag; }
182 void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }
183 void EnableHelp(bool flag) { m_printEnableHelp = flag; }
184
185 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; }
186 bool GetEnableSelection() const { return m_printEnableSelection; }
187 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }
188 bool GetEnableHelp() const { return m_printEnableHelp; }
189
190 // Is this data OK for showing the print dialog?
191 bool Ok() const { return IsOk(); }
192 bool IsOk() const { return m_printData.IsOk() ; }
193
194 wxPrintData& GetPrintData() { return m_printData; }
195 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
196
197 void operator=(const wxPrintDialogData& data);
198 void operator=(const wxPrintData& data); // Sets internal m_printData member
199
200 private:
201 int m_printFromPage;
202 int m_printToPage;
203 int m_printMinPage;
204 int m_printMaxPage;
205 int m_printNoCopies;
206 bool m_printAllPages;
207 bool m_printCollate;
208 bool m_printToFile;
209 bool m_printSelection;
210 bool m_printEnableSelection;
211 bool m_printEnablePageNumbers;
212 bool m_printEnableHelp;
213 bool m_printEnablePrintToFile;
214 wxPrintData m_printData;
215
216 private:
217 DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
218 };
219
220 /*
221 * This is the data used (and returned) by the wxPageSetupDialog.
222 */
223
224 // Compatibility with old name
225 #define wxPageSetupData wxPageSetupDialogData
226
227 class WXDLLIMPEXP_CORE wxPageSetupDialogData: public wxObject
228 {
229 public:
230 wxPageSetupDialogData();
231 wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
232 wxPageSetupDialogData(const wxPrintData& printData);
233 virtual ~wxPageSetupDialogData();
234
235 wxSize GetPaperSize() const { return m_paperSize; }
236 wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); }
237 wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; }
238 wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; }
239 wxPoint GetMarginTopLeft() const { return m_marginTopLeft; }
240 wxPoint GetMarginBottomRight() const { return m_marginBottomRight; }
241
242 bool GetDefaultMinMargins() const { return m_defaultMinMargins; }
243 bool GetEnableMargins() const { return m_enableMargins; }
244 bool GetEnableOrientation() const { return m_enableOrientation; }
245 bool GetEnablePaper() const { return m_enablePaper; }
246 bool GetEnablePrinter() const { return m_enablePrinter; }
247 bool GetDefaultInfo() const { return m_getDefaultInfo; }
248 bool GetEnableHelp() const { return m_enableHelp; }
249
250 // Is this data OK for showing the page setup dialog?
251 bool Ok() const { return IsOk(); }
252 bool IsOk() const { return m_printData.IsOk() ; }
253
254 // If a corresponding paper type is found in the paper database, will set the m_printData
255 // paper size id member as well.
256 void SetPaperSize(const wxSize& sz);
257
258 void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); }
259
260 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
261 void SetPaperSize(wxPaperSize id);
262
263 void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; }
264 void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; }
265 void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; }
266 void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; }
267 void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; }
268 void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; }
269
270 void EnableMargins(bool flag) { m_enableMargins = flag; }
271 void EnableOrientation(bool flag) { m_enableOrientation = flag; }
272 void EnablePaper(bool flag) { m_enablePaper = flag; }
273 void EnablePrinter(bool flag) { m_enablePrinter = flag; }
274 void EnableHelp(bool flag) { m_enableHelp = flag; }
275
276 // Use paper size defined in this object to set the wxPrintData
277 // paper id
278 void CalculateIdFromPaperSize();
279
280 // Use paper id in wxPrintData to set this object's paper size
281 void CalculatePaperSizeFromId();
282
283 wxPageSetupDialogData& operator=(const wxPageSetupDialogData& data);
284 wxPageSetupDialogData& operator=(const wxPrintData& data);
285
286 wxPrintData& GetPrintData() { return m_printData; }
287 const wxPrintData& GetPrintData() const { return m_printData; }
288 void SetPrintData(const wxPrintData& printData);
289
290 private:
291 wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
292 wxPoint m_minMarginTopLeft;
293 wxPoint m_minMarginBottomRight;
294 wxPoint m_marginTopLeft;
295 wxPoint m_marginBottomRight;
296 bool m_defaultMinMargins;
297 bool m_enableMargins;
298 bool m_enableOrientation;
299 bool m_enablePaper;
300 bool m_enablePrinter;
301 bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
302 bool m_enableHelp;
303 wxPrintData m_printData;
304
305 private:
306 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
307 };
308
309 #endif // wxUSE_PRINTING_ARCHITECTURE
310
311 #endif
312 // _WX_CMNDATA_H_BASE_