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