]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cmndata.h
unicode support for mach-O targets in Metrowerks
[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 #if wxUSE_STREAMS
26 #include "wx/stream.h"
27 #endif
28
29 class WXDLLEXPORT wxColourData: public wxObject
30 {
31 public:
32 wxColourData();
33 wxColourData(const wxColourData& data);
34 ~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 ~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 wxColour &GetColour() { 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 public:
123 wxColour m_fontColour;
124 bool m_showHelp;
125 bool m_allowSymbols;
126 bool m_enableEffects;
127 wxFont m_initialFont;
128 wxFont m_chosenFont;
129 int m_minSize;
130 int m_maxSize;
131
132 private:
133 wxFontEncoding m_encoding;
134 wxNativeEncodingInfo m_encodingInfo;
135
136 private:
137 DECLARE_DYNAMIC_CLASS(wxFontData)
138 };
139
140 #if wxUSE_PRINTING_ARCHITECTURE
141 /*
142 * wxPrintData
143 * Encapsulates printer information (not printer dialog information)
144 */
145
146 #ifdef __WXMAC__
147
148 class wxNativePrintData ;
149
150 #endif
151
152 class WXDLLEXPORT wxPrintData: public wxObject
153 {
154 public:
155 wxPrintData();
156 wxPrintData(const wxPrintData& printData);
157 ~wxPrintData();
158
159 int GetNoCopies() const { return m_printNoCopies; };
160 bool GetCollate() const { return m_printCollate; };
161 int GetOrientation() const { return m_printOrientation; };
162
163 // Is this data OK for showing the print dialog?
164 bool Ok() const ;
165
166 const wxString& GetPrinterName() const { return m_printerName; }
167 bool GetColour() const { return m_colour; }
168 wxDuplexMode GetDuplex() const { return m_duplexMode; }
169 wxPaperSize GetPaperId() const { return m_paperId; }
170 const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
171 // in wxPageSetupDialogData
172 wxPrintQuality GetQuality() const { return m_printQuality; }
173
174 void SetNoCopies(int v) { m_printNoCopies = v; };
175 void SetCollate(bool flag) { m_printCollate = flag; };
176 void SetOrientation(int orient) { m_printOrientation = orient; };
177
178 void SetPrinterName(const wxString& name) { m_printerName = name; }
179 void SetColour(bool colour) { m_colour = colour; }
180 void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
181 void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
182 void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
183 void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
184
185 // PostScript-specific data
186 const wxString& GetPrinterCommand() const { return m_printerCommand; }
187 const wxString& GetPrinterOptions() const { return m_printerOptions; }
188 const wxString& GetPreviewCommand() const { return m_previewCommand; }
189 const wxString& GetFilename() const { return m_filename; }
190 const wxString& GetFontMetricPath() const { return m_afmPath; }
191 double GetPrinterScaleX() const { return m_printerScaleX; }
192 double GetPrinterScaleY() const { return m_printerScaleY; }
193 long GetPrinterTranslateX() const { return m_printerTranslateX; }
194 long GetPrinterTranslateY() const { return m_printerTranslateY; }
195 wxPrintMode GetPrintMode() const { return m_printMode; }
196
197 void SetPrinterCommand(const wxString& command) { m_printerCommand = command; }
198 void SetPrinterOptions(const wxString& options) { m_printerOptions = options; }
199 void SetPreviewCommand(const wxString& command) { m_previewCommand = command; }
200 void SetFilename(const wxString& filename) { m_filename = filename; }
201 void SetFontMetricPath(const wxString& path) { m_afmPath = path; }
202 void SetPrinterScaleX(double x) { m_printerScaleX = x; }
203 void SetPrinterScaleY(double y) { m_printerScaleY = y; }
204 void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; }
205 void SetPrinterTranslateX(long x) { m_printerTranslateX = x; }
206 void SetPrinterTranslateY(long y) { m_printerTranslateY = y; }
207 void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; }
208 void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
209
210 #if wxUSE_STREAMS
211 wxOutputStream* GetOutputStream() { return m_outputstream; }
212 void SetOutputStream(wxOutputStream* outputstream) { m_outputstream = outputstream; }
213 #endif
214
215 void operator=(const wxPrintData& data);
216
217 #if defined(__WXMSW__)
218 // Convert to/from the DEVMODE structure
219 void ConvertToNative();
220 void ConvertFromNative();
221 void* GetNativeData() const { return m_devMode; }
222 void SetNativeData(void* data) { m_devMode = data; }
223 void* GetNativeDataDevNames() const { return m_devNames; }
224 void SetNativeDataDevNames(void* data) { m_devNames = data; }
225 #elif defined(__WXMAC__)
226 void ConvertToNative();
227 void ConvertFromNative();
228 #endif
229
230 public:
231 #if defined(__WXMSW__)
232 void* m_devMode;
233 void* m_devNames;
234 #elif defined(__WXMAC__)
235 wxNativePrintData* m_nativePrintData ;
236 #endif
237 #if wxUSE_STREAMS
238 wxOutputStream* m_outputstream;
239 #endif
240
241 private:
242
243 int m_printNoCopies;
244 int m_printOrientation;
245 bool m_printCollate;
246
247 // New members, 24/3/99
248 wxString m_printerName;
249 bool m_colour;
250 wxDuplexMode m_duplexMode;
251 wxPrintQuality m_printQuality;
252 wxPaperSize m_paperId;
253 wxSize m_paperSize;
254
255 // PostScript-specific data
256 wxString m_printerCommand;
257 wxString m_previewCommand;
258 wxString m_printerOptions;
259 wxString m_filename;
260 wxString m_afmPath;
261 double m_printerScaleX;
262 double m_printerScaleY;
263 long m_printerTranslateX;
264 long m_printerTranslateY;
265 wxPrintMode m_printMode;
266
267 private:
268 DECLARE_DYNAMIC_CLASS(wxPrintData)
269 };
270
271 /*
272 * wxPrintDialogData
273 * Encapsulates information displayed and edited in the printer dialog box.
274 * Contains a wxPrintData object which is filled in according to the values retrieved
275 * from the dialog.
276 */
277
278 class WXDLLEXPORT wxPrintDialogData: public wxObject
279 {
280 public:
281 wxPrintDialogData();
282 wxPrintDialogData(const wxPrintDialogData& dialogData);
283 wxPrintDialogData(const wxPrintData& printData);
284 ~wxPrintDialogData();
285
286 int GetFromPage() const { return m_printFromPage; };
287 int GetToPage() const { return m_printToPage; };
288 int GetMinPage() const { return m_printMinPage; };
289 int GetMaxPage() const { return m_printMaxPage; };
290 int GetNoCopies() const { return m_printNoCopies; };
291 bool GetAllPages() const { return m_printAllPages; };
292 bool GetSelection() const { return m_printSelection; };
293 bool GetCollate() const { return m_printCollate; };
294 bool GetPrintToFile() const { return m_printToFile; };
295 bool GetSetupDialog() const { return m_printSetupDialog; };
296
297 void SetFromPage(int v) { m_printFromPage = v; };
298 void SetToPage(int v) { m_printToPage = v; };
299 void SetMinPage(int v) { m_printMinPage = v; };
300 void SetMaxPage(int v) { m_printMaxPage = v; };
301 void SetNoCopies(int v) { m_printNoCopies = v; };
302 void SetAllPages(bool flag) { m_printAllPages = flag; };
303 void SetSelection(bool flag) { m_printSelection = flag; };
304 void SetCollate(bool flag) { m_printCollate = flag; };
305 void SetPrintToFile(bool flag) { m_printToFile = flag; };
306 void SetSetupDialog(bool flag) { m_printSetupDialog = flag; };
307
308 void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; };
309 void EnableSelection(bool flag) { m_printEnableSelection = flag; };
310 void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; };
311 void EnableHelp(bool flag) { m_printEnableHelp = flag; };
312
313 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; };
314 bool GetEnableSelection() const { return m_printEnableSelection; };
315 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; };
316 bool GetEnableHelp() const { return m_printEnableHelp; };
317
318 // Is this data OK for showing the print dialog?
319 bool Ok() const { return m_printData.Ok() ; }
320
321 wxPrintData& GetPrintData() { return m_printData; }
322 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
323
324 void operator=(const wxPrintDialogData& data);
325 void operator=(const wxPrintData& data); // Sets internal m_printData member
326
327 #ifdef __WXMSW__
328 // Convert to/from the PRINTDLG structure
329 void ConvertToNative();
330 void ConvertFromNative();
331 void SetOwnerWindow(wxWindow* win);
332 void* GetNativeData() const { return m_printDlgData; }
333 #elif defined(__WXMAC__)
334 void ConvertToNative();
335 void ConvertFromNative();
336 #endif
337
338 #ifdef __WXMSW__
339 void* m_printDlgData;
340 #endif
341
342 private:
343 int m_printFromPage;
344 int m_printToPage;
345 int m_printMinPage;
346 int m_printMaxPage;
347 int m_printNoCopies;
348 bool m_printAllPages;
349 bool m_printCollate;
350 bool m_printToFile;
351 bool m_printSelection;
352 bool m_printEnableSelection;
353 bool m_printEnablePageNumbers;
354 bool m_printEnableHelp;
355 bool m_printEnablePrintToFile;
356 bool m_printSetupDialog;
357 wxPrintData m_printData;
358
359 private:
360 DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
361 };
362
363 /*
364 * This is the data used (and returned) by the wxPageSetupDialog.
365 */
366
367 // Compatibility with old name
368 #define wxPageSetupData wxPageSetupDialogData
369
370 class WXDLLEXPORT wxPageSetupDialogData: public wxObject
371 {
372 public:
373 wxPageSetupDialogData();
374 wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
375 wxPageSetupDialogData(const wxPrintData& printData);
376 ~wxPageSetupDialogData();
377
378 wxSize GetPaperSize() const { return m_paperSize; };
379 wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); };
380 wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; };
381 wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; };
382 wxPoint GetMarginTopLeft() const { return m_marginTopLeft; };
383 wxPoint GetMarginBottomRight() const { return m_marginBottomRight; };
384
385 bool GetDefaultMinMargins() const { return m_defaultMinMargins; };
386 bool GetEnableMargins() const { return m_enableMargins; };
387 bool GetEnableOrientation() const { return m_enableOrientation; };
388 bool GetEnablePaper() const { return m_enablePaper; };
389 bool GetEnablePrinter() const { return m_enablePrinter; };
390 bool GetDefaultInfo() const { return m_getDefaultInfo; };
391 bool GetEnableHelp() const { return m_enableHelp; };
392
393 // Is this data OK for showing the page setup dialog?
394 bool Ok() const { return m_printData.Ok() ; }
395
396 // If a corresponding paper type is found in the paper database, will set the m_printData
397 // paper size id member as well.
398 void SetPaperSize(const wxSize& sz);
399
400 void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); };
401
402 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
403 void SetPaperSize(wxPaperSize id);
404
405 void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; };
406 void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; };
407 void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; };
408 void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; };
409 void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; };
410 void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; };
411
412 void EnableMargins(bool flag) { m_enableMargins = flag; };
413 void EnableOrientation(bool flag) { m_enableOrientation = flag; };
414 void EnablePaper(bool flag) { m_enablePaper = flag; };
415 void EnablePrinter(bool flag) { m_enablePrinter = flag; };
416 void EnableHelp(bool flag) { m_enableHelp = flag; };
417
418 #if defined(__WIN95__)
419 // Convert to/from the PAGESETUPDLG structure
420 void ConvertToNative();
421 void ConvertFromNative();
422 void SetOwnerWindow(wxWindow* win);
423 void* GetNativeData() const { return m_pageSetupData; }
424 #elif defined(__WXMAC__)
425 void ConvertToNative();
426 void ConvertFromNative();
427 #endif
428
429 // Use paper size defined in this object to set the wxPrintData
430 // paper id
431 void CalculateIdFromPaperSize();
432
433 // Use paper id in wxPrintData to set this object's paper size
434 void CalculatePaperSizeFromId();
435
436 wxPageSetupDialogData& operator=(const wxPageSetupData& data);
437 wxPageSetupDialogData& operator=(const wxPrintData& data);
438
439 wxPrintData& GetPrintData() { return m_printData; }
440 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
441
442 #if defined(__WIN95__)
443 void* m_pageSetupData;
444 #endif
445
446 private:
447 wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
448 wxPoint m_minMarginTopLeft;
449 wxPoint m_minMarginBottomRight;
450 wxPoint m_marginTopLeft;
451 wxPoint m_marginBottomRight;
452 bool m_defaultMinMargins;
453 bool m_enableMargins;
454 bool m_enableOrientation;
455 bool m_enablePaper;
456 bool m_enablePrinter;
457 bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
458 bool m_enableHelp;
459 wxPrintData m_printData;
460
461 private:
462 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
463 };
464
465 #endif // wxUSE_PRINTING_ARCHITECTURE
466
467 #endif
468 // _WX_CMNDATA_H_BASE_