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