]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: 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/window.h" | |
16 | #include "wx/font.h" | |
17 | #include "wx/encinfo.h" | |
18 | #include "wx/colour.h" | |
19 | #include "wx/gdicmn.h" | |
20 | ||
21 | #if wxUSE_STREAMS | |
22 | #include "wx/stream.h" | |
23 | #endif | |
24 | ||
25 | ||
26 | class WXDLLEXPORT wxPrintNativeDataBase; | |
27 | ||
28 | ||
29 | class WXDLLEXPORT wxColourData: public wxObject | |
30 | { | |
31 | public: | |
32 | wxColourData(); | |
33 | wxColourData(const wxColourData& data); | |
34 | virtual ~wxColourData(); | |
35 | ||
36 | void SetChooseFull(bool flag) { m_chooseFull = flag; } | |
37 | bool GetChooseFull() const { return m_chooseFull; } | |
38 | void SetColour(const wxColour& colour) { m_dataColour = colour; } | |
39 | const wxColour& GetColour() const { return m_dataColour; } | |
40 | wxColour& GetColour() { return m_dataColour; } | |
41 | ||
42 | // Array of 16 custom colours | |
43 | void SetCustomColour(int i, const wxColour& colour); | |
44 | wxColour GetCustomColour(int i); | |
45 | ||
46 | void operator=(const wxColourData& data); | |
47 | ||
48 | public: | |
49 | wxColour m_dataColour; | |
50 | wxColour m_custColours[16]; | |
51 | bool m_chooseFull; | |
52 | ||
53 | private: | |
54 | DECLARE_DYNAMIC_CLASS(wxColourData) | |
55 | }; | |
56 | ||
57 | class WXDLLEXPORT wxFontData : public wxObject | |
58 | { | |
59 | public: | |
60 | wxFontData(); | |
61 | virtual ~wxFontData(); | |
62 | ||
63 | wxFontData(const wxFontData& data) | |
64 | : wxObject(), | |
65 | m_fontColour(data.m_fontColour), | |
66 | m_showHelp(data.m_showHelp), | |
67 | m_allowSymbols(data.m_allowSymbols), | |
68 | m_enableEffects(data.m_enableEffects), | |
69 | m_initialFont(data.m_initialFont), | |
70 | m_chosenFont(data.m_chosenFont), | |
71 | m_minSize(data.m_minSize), | |
72 | m_maxSize(data.m_maxSize), | |
73 | m_encoding(data.m_encoding), | |
74 | m_encodingInfo(data.m_encodingInfo) | |
75 | { | |
76 | } | |
77 | ||
78 | wxFontData& operator=(const wxFontData& data) | |
79 | { | |
80 | wxObject::operator=(data); | |
81 | m_fontColour = data.m_fontColour; | |
82 | m_showHelp = data.m_showHelp; | |
83 | m_allowSymbols = data.m_allowSymbols; | |
84 | m_enableEffects = data.m_enableEffects; | |
85 | m_initialFont = data.m_initialFont; | |
86 | m_chosenFont = data.m_chosenFont; | |
87 | m_minSize = data.m_minSize; | |
88 | m_maxSize = data.m_maxSize; | |
89 | m_encoding = data.m_encoding; | |
90 | m_encodingInfo = data.m_encodingInfo; | |
91 | return *this; | |
92 | } | |
93 | ||
94 | void SetAllowSymbols(bool flag) { m_allowSymbols = flag; } | |
95 | bool GetAllowSymbols() const { return m_allowSymbols; } | |
96 | ||
97 | void SetColour(const wxColour& colour) { m_fontColour = colour; } | |
98 | const wxColour& GetColour() const { return m_fontColour; } | |
99 | ||
100 | void SetShowHelp(bool flag) { m_showHelp = flag; } | |
101 | bool GetShowHelp() const { return m_showHelp; } | |
102 | ||
103 | void EnableEffects(bool flag) { m_enableEffects = flag; } | |
104 | bool GetEnableEffects() const { return m_enableEffects; } | |
105 | ||
106 | void SetInitialFont(const wxFont& font) { m_initialFont = font; } | |
107 | wxFont GetInitialFont() const { return m_initialFont; } | |
108 | ||
109 | void SetChosenFont(const wxFont& font) { m_chosenFont = font; } | |
110 | wxFont GetChosenFont() const { return m_chosenFont; } | |
111 | ||
112 | void SetRange(int minRange, int maxRange) { m_minSize = minRange; m_maxSize = maxRange; } | |
113 | ||
114 | // encoding info is split into 2 parts: the logical wxWin encoding | |
115 | // (wxFontEncoding) and a structure containing the native parameters for | |
116 | // it (wxNativeEncodingInfo) | |
117 | wxFontEncoding GetEncoding() const { return m_encoding; } | |
118 | void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; } | |
119 | ||
120 | wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; } | |
121 | ||
122 | ||
123 | // public for backwards compatibility only: don't use directly | |
124 | public: | |
125 | wxColour m_fontColour; | |
126 | bool m_showHelp; | |
127 | bool m_allowSymbols; | |
128 | bool m_enableEffects; | |
129 | wxFont m_initialFont; | |
130 | wxFont m_chosenFont; | |
131 | int m_minSize; | |
132 | int m_maxSize; | |
133 | ||
134 | private: | |
135 | wxFontEncoding m_encoding; | |
136 | wxNativeEncodingInfo m_encodingInfo; | |
137 | ||
138 | private: | |
139 | DECLARE_DYNAMIC_CLASS(wxFontData) | |
140 | }; | |
141 | ||
142 | #if wxUSE_PRINTING_ARCHITECTURE | |
143 | /* | |
144 | * wxPrintData | |
145 | * Encapsulates printer information (not printer dialog information) | |
146 | */ | |
147 | ||
148 | enum wxPrintBin | |
149 | { | |
150 | wxPRINTBIN_DEFAULT, | |
151 | ||
152 | wxPRINTBIN_ONLYONE, | |
153 | wxPRINTBIN_LOWER, | |
154 | wxPRINTBIN_MIDDLE, | |
155 | wxPRINTBIN_MANUAL, | |
156 | wxPRINTBIN_ENVELOPE, | |
157 | wxPRINTBIN_ENVMANUAL, | |
158 | wxPRINTBIN_AUTO, | |
159 | wxPRINTBIN_TRACTOR, | |
160 | wxPRINTBIN_SMALLFMT, | |
161 | wxPRINTBIN_LARGEFMT, | |
162 | wxPRINTBIN_LARGECAPACITY, | |
163 | wxPRINTBIN_CASSETTE, | |
164 | wxPRINTBIN_FORMSOURCE, | |
165 | ||
166 | wxPRINTBIN_USER | |
167 | }; | |
168 | ||
169 | ||
170 | class WXDLLEXPORT wxPrintData: public wxObject | |
171 | { | |
172 | public: | |
173 | wxPrintData(); | |
174 | wxPrintData(const wxPrintData& printData); | |
175 | virtual ~wxPrintData(); | |
176 | ||
177 | int GetNoCopies() const { return m_printNoCopies; } | |
178 | bool GetCollate() const { return m_printCollate; } | |
179 | int GetOrientation() const { return m_printOrientation; } | |
180 | ||
181 | // Is this data OK for showing the print dialog? | |
182 | bool Ok() const { return IsOk(); } | |
183 | bool IsOk() const ; | |
184 | ||
185 | const wxString& GetPrinterName() const { return m_printerName; } | |
186 | bool GetColour() const { return m_colour; } | |
187 | wxDuplexMode GetDuplex() const { return m_duplexMode; } | |
188 | wxPaperSize GetPaperId() const { return m_paperId; } | |
189 | const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size | |
190 | // in wxPageSetupDialogData | |
191 | wxPrintQuality GetQuality() const { return m_printQuality; } | |
192 | wxPrintBin GetBin() const { return m_bin; } | |
193 | wxPrintMode GetPrintMode() const { return m_printMode; } | |
194 | ||
195 | void SetNoCopies(int v) { m_printNoCopies = v; } | |
196 | void SetCollate(bool flag) { m_printCollate = flag; } | |
197 | void SetOrientation(int orient) { m_printOrientation = orient; } | |
198 | ||
199 | void SetPrinterName(const wxString& name) { m_printerName = name; } | |
200 | void SetColour(bool colour) { m_colour = colour; } | |
201 | void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; } | |
202 | void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; } | |
203 | void SetPaperSize(const wxSize& sz) { m_paperSize = sz; } | |
204 | void SetQuality(wxPrintQuality quality) { m_printQuality = quality; } | |
205 | void SetBin(wxPrintBin bin) { m_bin = bin; } | |
206 | void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; } | |
207 | ||
208 | wxString GetFilename() const { return m_filename; } | |
209 | void SetFilename( const wxString &filename ) { m_filename = filename; } | |
210 | ||
211 | void operator=(const wxPrintData& data); | |
212 | ||
213 | char* GetPrivData() const { return m_privData; } | |
214 | int GetPrivDataLen() const { return m_privDataLen; } | |
215 | void SetPrivData( char *privData, int len ); | |
216 | ||
217 | ||
218 | #if WXWIN_COMPATIBILITY_2_4 | |
219 | // PostScript-specific data | |
220 | wxString GetPrinterCommand() const; | |
221 | wxString GetPrinterOptions() const; | |
222 | wxString GetPreviewCommand() const; | |
223 | wxString GetFontMetricPath() const; | |
224 | double GetPrinterScaleX() const; | |
225 | double GetPrinterScaleY() const; | |
226 | long GetPrinterTranslateX() const; | |
227 | long GetPrinterTranslateY() const; | |
228 | ||
229 | void SetPrinterCommand(const wxString& command); | |
230 | void SetPrinterOptions(const wxString& options); | |
231 | void SetPreviewCommand(const wxString& command); | |
232 | void SetFontMetricPath(const wxString& path); | |
233 | void SetPrinterScaleX(double x); | |
234 | void SetPrinterScaleY(double y); | |
235 | void SetPrinterScaling(double x, double y); | |
236 | void SetPrinterTranslateX(long x); | |
237 | void SetPrinterTranslateY(long y); | |
238 | void SetPrinterTranslation(long x, long y); | |
239 | #endif | |
240 | ||
241 | // Convert between wxPrintData and native data | |
242 | void ConvertToNative(); | |
243 | void ConvertFromNative(); | |
244 | // Holds the native print data | |
245 | wxPrintNativeDataBase *GetNativeData() const { return m_nativeData; } | |
246 | ||
247 | private: | |
248 | wxPrintBin m_bin; | |
249 | wxPrintMode m_printMode; | |
250 | ||
251 | int m_printNoCopies; | |
252 | int m_printOrientation; | |
253 | bool m_printCollate; | |
254 | ||
255 | wxString m_printerName; | |
256 | bool m_colour; | |
257 | wxDuplexMode m_duplexMode; | |
258 | wxPrintQuality m_printQuality; | |
259 | wxPaperSize m_paperId; | |
260 | wxSize m_paperSize; | |
261 | ||
262 | wxString m_filename; | |
263 | ||
264 | char* m_privData; | |
265 | int m_privDataLen; | |
266 | ||
267 | wxPrintNativeDataBase *m_nativeData; | |
268 | ||
269 | private: | |
270 | DECLARE_DYNAMIC_CLASS(wxPrintData) | |
271 | }; | |
272 | ||
273 | /* | |
274 | * wxPrintDialogData | |
275 | * Encapsulates information displayed and edited in the printer dialog box. | |
276 | * Contains a wxPrintData object which is filled in according to the values retrieved | |
277 | * from the dialog. | |
278 | */ | |
279 | ||
280 | class WXDLLEXPORT wxPrintDialogData: public wxObject | |
281 | { | |
282 | public: | |
283 | wxPrintDialogData(); | |
284 | wxPrintDialogData(const wxPrintDialogData& dialogData); | |
285 | wxPrintDialogData(const wxPrintData& printData); | |
286 | virtual ~wxPrintDialogData(); | |
287 | ||
288 | int GetFromPage() const { return m_printFromPage; }; | |
289 | int GetToPage() const { return m_printToPage; }; | |
290 | int GetMinPage() const { return m_printMinPage; }; | |
291 | int GetMaxPage() const { return m_printMaxPage; }; | |
292 | int GetNoCopies() const { return m_printNoCopies; }; | |
293 | bool GetAllPages() const { return m_printAllPages; }; | |
294 | bool GetSelection() const { return m_printSelection; }; | |
295 | bool GetCollate() const { return m_printCollate; }; | |
296 | bool GetPrintToFile() const { return m_printToFile; }; | |
297 | #if WXWIN_COMPATIBILITY_2_4 | |
298 | bool GetSetupDialog() const { return m_printSetupDialog; }; | |
299 | #endif | |
300 | void SetFromPage(int v) { m_printFromPage = v; }; | |
301 | void SetToPage(int v) { m_printToPage = v; }; | |
302 | void SetMinPage(int v) { m_printMinPage = v; }; | |
303 | void SetMaxPage(int v) { m_printMaxPage = v; }; | |
304 | void SetNoCopies(int v) { m_printNoCopies = v; }; | |
305 | void SetAllPages(bool flag) { m_printAllPages = flag; }; | |
306 | void SetSelection(bool flag) { m_printSelection = flag; }; | |
307 | void SetCollate(bool flag) { m_printCollate = flag; }; | |
308 | void SetPrintToFile(bool flag) { m_printToFile = flag; }; | |
309 | #if WXWIN_COMPATIBILITY_2_4 | |
310 | void SetSetupDialog(bool flag) { m_printSetupDialog = flag; }; | |
311 | #endif | |
312 | void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }; | |
313 | void EnableSelection(bool flag) { m_printEnableSelection = flag; }; | |
314 | void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }; | |
315 | void EnableHelp(bool flag) { m_printEnableHelp = flag; }; | |
316 | ||
317 | bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; }; | |
318 | bool GetEnableSelection() const { return m_printEnableSelection; }; | |
319 | bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }; | |
320 | bool GetEnableHelp() const { return m_printEnableHelp; }; | |
321 | ||
322 | // Is this data OK for showing the print dialog? | |
323 | bool Ok() const { return IsOk(); } | |
324 | bool IsOk() const { return m_printData.Ok() ; } | |
325 | ||
326 | wxPrintData& GetPrintData() { return m_printData; } | |
327 | void SetPrintData(const wxPrintData& printData) { m_printData = printData; } | |
328 | ||
329 | void operator=(const wxPrintDialogData& data); | |
330 | void operator=(const wxPrintData& data); // Sets internal m_printData member | |
331 | ||
332 | private: | |
333 | int m_printFromPage; | |
334 | int m_printToPage; | |
335 | int m_printMinPage; | |
336 | int m_printMaxPage; | |
337 | int m_printNoCopies; | |
338 | bool m_printAllPages; | |
339 | bool m_printCollate; | |
340 | bool m_printToFile; | |
341 | bool m_printSelection; | |
342 | bool m_printEnableSelection; | |
343 | bool m_printEnablePageNumbers; | |
344 | bool m_printEnableHelp; | |
345 | bool m_printEnablePrintToFile; | |
346 | #if WXWIN_COMPATIBILITY_2_4 | |
347 | bool m_printSetupDialog; | |
348 | #endif | |
349 | wxPrintData m_printData; | |
350 | ||
351 | private: | |
352 | DECLARE_DYNAMIC_CLASS(wxPrintDialogData) | |
353 | }; | |
354 | ||
355 | /* | |
356 | * This is the data used (and returned) by the wxPageSetupDialog. | |
357 | */ | |
358 | ||
359 | // Compatibility with old name | |
360 | #define wxPageSetupData wxPageSetupDialogData | |
361 | ||
362 | class WXDLLEXPORT wxPageSetupDialogData: public wxObject | |
363 | { | |
364 | public: | |
365 | wxPageSetupDialogData(); | |
366 | wxPageSetupDialogData(const wxPageSetupDialogData& dialogData); | |
367 | wxPageSetupDialogData(const wxPrintData& printData); | |
368 | virtual ~wxPageSetupDialogData(); | |
369 | ||
370 | wxSize GetPaperSize() const { return m_paperSize; }; | |
371 | wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); }; | |
372 | wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; }; | |
373 | wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; }; | |
374 | wxPoint GetMarginTopLeft() const { return m_marginTopLeft; }; | |
375 | wxPoint GetMarginBottomRight() const { return m_marginBottomRight; }; | |
376 | ||
377 | bool GetDefaultMinMargins() const { return m_defaultMinMargins; }; | |
378 | bool GetEnableMargins() const { return m_enableMargins; }; | |
379 | bool GetEnableOrientation() const { return m_enableOrientation; }; | |
380 | bool GetEnablePaper() const { return m_enablePaper; }; | |
381 | bool GetEnablePrinter() const { return m_enablePrinter; }; | |
382 | bool GetDefaultInfo() const { return m_getDefaultInfo; }; | |
383 | bool GetEnableHelp() const { return m_enableHelp; }; | |
384 | ||
385 | // Is this data OK for showing the page setup dialog? | |
386 | bool Ok() const { return IsOk(); } | |
387 | bool IsOk() const { return m_printData.Ok() ; } | |
388 | ||
389 | // If a corresponding paper type is found in the paper database, will set the m_printData | |
390 | // paper size id member as well. | |
391 | void SetPaperSize(const wxSize& sz); | |
392 | ||
393 | void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); }; | |
394 | ||
395 | // Sets the wxPrintData id, plus the paper width/height if found in the paper database. | |
396 | void SetPaperSize(wxPaperSize id); | |
397 | ||
398 | void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; }; | |
399 | void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; }; | |
400 | void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; }; | |
401 | void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; }; | |
402 | void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; }; | |
403 | void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; }; | |
404 | ||
405 | void EnableMargins(bool flag) { m_enableMargins = flag; }; | |
406 | void EnableOrientation(bool flag) { m_enableOrientation = flag; }; | |
407 | void EnablePaper(bool flag) { m_enablePaper = flag; }; | |
408 | void EnablePrinter(bool flag) { m_enablePrinter = flag; }; | |
409 | void EnableHelp(bool flag) { m_enableHelp = flag; }; | |
410 | ||
411 | // Use paper size defined in this object to set the wxPrintData | |
412 | // paper id | |
413 | void CalculateIdFromPaperSize(); | |
414 | ||
415 | // Use paper id in wxPrintData to set this object's paper size | |
416 | void CalculatePaperSizeFromId(); | |
417 | ||
418 | wxPageSetupDialogData& operator=(const wxPageSetupData& data); | |
419 | wxPageSetupDialogData& operator=(const wxPrintData& data); | |
420 | ||
421 | wxPrintData& GetPrintData() { return m_printData; } | |
422 | const wxPrintData& GetPrintData() const { return m_printData; } | |
423 | void SetPrintData(const wxPrintData& printData); | |
424 | ||
425 | private: | |
426 | wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?) | |
427 | wxPoint m_minMarginTopLeft; | |
428 | wxPoint m_minMarginBottomRight; | |
429 | wxPoint m_marginTopLeft; | |
430 | wxPoint m_marginBottomRight; | |
431 | bool m_defaultMinMargins; | |
432 | bool m_enableMargins; | |
433 | bool m_enableOrientation; | |
434 | bool m_enablePaper; | |
435 | bool m_enablePrinter; | |
436 | bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT | |
437 | bool m_enableHelp; | |
438 | wxPrintData m_printData; | |
439 | ||
440 | private: | |
441 | DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData) | |
442 | }; | |
443 | ||
444 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
445 | ||
446 | #endif | |
447 | // _WX_CMNDATA_H_BASE_ |