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