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