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