1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI data classes
4 // Author: Julian Smart and others
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CMNDATA_H_BASE_
13 #define _WX_CMNDATA_H_BASE_
15 #include "wx/window.h"
17 #include "wx/encinfo.h"
18 #include "wx/colour.h"
19 #include "wx/gdicmn.h"
22 #include "wx/stream.h"
26 class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase
;
29 class WXDLLEXPORT wxColourData
: public wxObject
32 // number of custom colours we store
39 wxColourData(const wxColourData
& data
);
40 wxColourData
& operator=(const wxColourData
& data
);
41 virtual ~wxColourData();
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
; }
49 // These functions modify colours in an internal array of NUM_CUSTOM custom
51 void SetCustomColour(int i
, const wxColour
& colour
);
52 wxColour
GetCustomColour(int i
);
54 // Serialize the object to a string and restore it from it
55 wxString
ToString() const;
56 bool FromString(const wxString
& str
);
58 public: // TODO: make these fields private
59 wxColour m_dataColour
;
60 wxColour m_custColours
[NUM_CUSTOM
];
64 DECLARE_DYNAMIC_CLASS(wxColourData
)
67 class WXDLLEXPORT wxFontData
: public wxObject
71 virtual ~wxFontData();
73 wxFontData(const wxFontData
& data
)
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
)
88 wxFontData
& operator=(const wxFontData
& data
)
92 wxObject::operator=(data
);
93 m_fontColour
= data
.m_fontColour
;
94 m_showHelp
= data
.m_showHelp
;
95 m_allowSymbols
= data
.m_allowSymbols
;
96 m_enableEffects
= data
.m_enableEffects
;
97 m_initialFont
= data
.m_initialFont
;
98 m_chosenFont
= data
.m_chosenFont
;
99 m_minSize
= data
.m_minSize
;
100 m_maxSize
= data
.m_maxSize
;
101 m_encoding
= data
.m_encoding
;
102 m_encodingInfo
= data
.m_encodingInfo
;
107 void SetAllowSymbols(bool flag
) { m_allowSymbols
= flag
; }
108 bool GetAllowSymbols() const { return m_allowSymbols
; }
110 void SetColour(const wxColour
& colour
) { m_fontColour
= colour
; }
111 const wxColour
& GetColour() const { return m_fontColour
; }
113 void SetShowHelp(bool flag
) { m_showHelp
= flag
; }
114 bool GetShowHelp() const { return m_showHelp
; }
116 void EnableEffects(bool flag
) { m_enableEffects
= flag
; }
117 bool GetEnableEffects() const { return m_enableEffects
; }
119 void SetInitialFont(const wxFont
& font
) { m_initialFont
= font
; }
120 wxFont
GetInitialFont() const { return m_initialFont
; }
122 void SetChosenFont(const wxFont
& font
) { m_chosenFont
= font
; }
123 wxFont
GetChosenFont() const { return m_chosenFont
; }
125 void SetRange(int minRange
, int maxRange
) { m_minSize
= minRange
; m_maxSize
= maxRange
; }
127 // encoding info is split into 2 parts: the logical wxWin encoding
128 // (wxFontEncoding) and a structure containing the native parameters for
129 // it (wxNativeEncodingInfo)
130 wxFontEncoding
GetEncoding() const { return m_encoding
; }
131 void SetEncoding(wxFontEncoding encoding
) { m_encoding
= encoding
; }
133 wxNativeEncodingInfo
& EncodingInfo() { return m_encodingInfo
; }
136 // public for backwards compatibility only: don't use directly
138 wxColour m_fontColour
;
141 bool m_enableEffects
;
142 wxFont m_initialFont
;
148 wxFontEncoding m_encoding
;
149 wxNativeEncodingInfo m_encodingInfo
;
152 DECLARE_DYNAMIC_CLASS(wxFontData
)
155 #if wxUSE_PRINTING_ARCHITECTURE
158 * Encapsulates printer information (not printer dialog information)
170 wxPRINTBIN_ENVMANUAL
,
175 wxPRINTBIN_LARGECAPACITY
,
177 wxPRINTBIN_FORMSOURCE
,
182 const int wxPRINTMEDIA_DEFAULT
= 0;
184 class WXDLLEXPORT wxPrintData
: public wxObject
188 wxPrintData(const wxPrintData
& printData
);
189 virtual ~wxPrintData();
191 int GetNoCopies() const { return m_printNoCopies
; }
192 bool GetCollate() const { return m_printCollate
; }
193 int GetOrientation() const { return m_printOrientation
; }
194 bool IsOrientationReversed() const { return m_printOrientationReversed
; }
196 // Is this data OK for showing the print dialog?
197 bool Ok() const { return IsOk(); }
200 const wxString
& GetPrinterName() const { return m_printerName
; }
201 bool GetColour() const { return m_colour
; }
202 wxDuplexMode
GetDuplex() const { return m_duplexMode
; }
203 wxPaperSize
GetPaperId() const { return m_paperId
; }
204 const wxSize
& GetPaperSize() const { return m_paperSize
; } // Not used yet: confusable with paper size
205 // in wxPageSetupDialogData
206 wxPrintQuality
GetQuality() const { return m_printQuality
; }
207 wxPrintBin
GetBin() const { return m_bin
; }
208 wxPrintMode
GetPrintMode() const { return m_printMode
; }
209 int GetMedia() const { return m_media
; }
211 void SetNoCopies(int v
) { m_printNoCopies
= v
; }
212 void SetCollate(bool flag
) { m_printCollate
= flag
; }
213 void SetOrientation(int orient
) { m_printOrientation
= orient
; }
214 void SetOrientationReversed(bool reversed
) { m_printOrientationReversed
= reversed
; }
216 void SetPrinterName(const wxString
& name
) { m_printerName
= name
; }
217 void SetColour(bool colour
) { m_colour
= colour
; }
218 void SetDuplex(wxDuplexMode duplex
) { m_duplexMode
= duplex
; }
219 void SetPaperId(wxPaperSize sizeId
) { m_paperId
= sizeId
; }
220 void SetPaperSize(const wxSize
& sz
) { m_paperSize
= sz
; }
221 void SetQuality(wxPrintQuality quality
) { m_printQuality
= quality
; }
222 void SetBin(wxPrintBin bin
) { m_bin
= bin
; }
223 void SetMedia(int media
) { m_media
= media
; }
224 void SetPrintMode(wxPrintMode printMode
) { m_printMode
= printMode
; }
226 wxString
GetFilename() const { return m_filename
; }
227 void SetFilename( const wxString
&filename
) { m_filename
= filename
; }
229 void operator=(const wxPrintData
& data
);
231 char* GetPrivData() const { return m_privData
; }
232 int GetPrivDataLen() const { return m_privDataLen
; }
233 void SetPrivData( char *privData
, int len
);
236 // Convert between wxPrintData and native data
237 void ConvertToNative();
238 void ConvertFromNative();
239 // Holds the native print data
240 wxPrintNativeDataBase
*GetNativeData() const { return m_nativeData
; }
245 wxPrintMode m_printMode
;
248 int m_printOrientation
;
249 bool m_printOrientationReversed
;
252 wxString m_printerName
;
254 wxDuplexMode m_duplexMode
;
255 wxPrintQuality m_printQuality
;
256 wxPaperSize m_paperId
;
264 wxPrintNativeDataBase
*m_nativeData
;
267 DECLARE_DYNAMIC_CLASS(wxPrintData
)
272 * Encapsulates information displayed and edited in the printer dialog box.
273 * Contains a wxPrintData object which is filled in according to the values retrieved
277 class WXDLLEXPORT wxPrintDialogData
: public wxObject
281 wxPrintDialogData(const wxPrintDialogData
& dialogData
);
282 wxPrintDialogData(const wxPrintData
& printData
);
283 virtual ~wxPrintDialogData();
285 int GetFromPage() const { return m_printFromPage
; }
286 int GetToPage() const { return m_printToPage
; }
287 int GetMinPage() const { return m_printMinPage
; }
288 int GetMaxPage() const { return m_printMaxPage
; }
289 int GetNoCopies() const { return m_printNoCopies
; }
290 bool GetAllPages() const { return m_printAllPages
; }
291 bool GetSelection() const { return m_printSelection
; }
292 bool GetCollate() const { return m_printCollate
; }
293 bool GetPrintToFile() const { return m_printToFile
; }
295 void SetFromPage(int v
) { m_printFromPage
= v
; }
296 void SetToPage(int v
) { m_printToPage
= v
; }
297 void SetMinPage(int v
) { m_printMinPage
= v
; }
298 void SetMaxPage(int v
) { m_printMaxPage
= v
; }
299 void SetNoCopies(int v
) { m_printNoCopies
= v
; }
300 void SetAllPages(bool flag
) { m_printAllPages
= flag
; }
301 void SetSelection(bool flag
) { m_printSelection
= flag
; }
302 void SetCollate(bool flag
) { m_printCollate
= flag
; }
303 void SetPrintToFile(bool flag
) { m_printToFile
= flag
; }
305 void EnablePrintToFile(bool flag
) { m_printEnablePrintToFile
= flag
; }
306 void EnableSelection(bool flag
) { m_printEnableSelection
= flag
; }
307 void EnablePageNumbers(bool flag
) { m_printEnablePageNumbers
= flag
; }
308 void EnableHelp(bool flag
) { m_printEnableHelp
= flag
; }
310 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile
; }
311 bool GetEnableSelection() const { return m_printEnableSelection
; }
312 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers
; }
313 bool GetEnableHelp() const { return m_printEnableHelp
; }
315 // Is this data OK for showing the print dialog?
316 bool Ok() const { return IsOk(); }
317 bool IsOk() const { return m_printData
.Ok() ; }
319 wxPrintData
& GetPrintData() { return m_printData
; }
320 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
322 void operator=(const wxPrintDialogData
& data
);
323 void operator=(const wxPrintData
& data
); // Sets internal m_printData member
331 bool m_printAllPages
;
334 bool m_printSelection
;
335 bool m_printEnableSelection
;
336 bool m_printEnablePageNumbers
;
337 bool m_printEnableHelp
;
338 bool m_printEnablePrintToFile
;
339 wxPrintData m_printData
;
342 DECLARE_DYNAMIC_CLASS(wxPrintDialogData
)
346 * This is the data used (and returned) by the wxPageSetupDialog.
349 // Compatibility with old name
350 #define wxPageSetupData wxPageSetupDialogData
352 class WXDLLEXPORT wxPageSetupDialogData
: public wxObject
355 wxPageSetupDialogData();
356 wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
);
357 wxPageSetupDialogData(const wxPrintData
& printData
);
358 virtual ~wxPageSetupDialogData();
360 wxSize
GetPaperSize() const { return m_paperSize
; }
361 wxPaperSize
GetPaperId() const { return m_printData
.GetPaperId(); }
362 wxPoint
GetMinMarginTopLeft() const { return m_minMarginTopLeft
; }
363 wxPoint
GetMinMarginBottomRight() const { return m_minMarginBottomRight
; }
364 wxPoint
GetMarginTopLeft() const { return m_marginTopLeft
; }
365 wxPoint
GetMarginBottomRight() const { return m_marginBottomRight
; }
367 bool GetDefaultMinMargins() const { return m_defaultMinMargins
; }
368 bool GetEnableMargins() const { return m_enableMargins
; }
369 bool GetEnableOrientation() const { return m_enableOrientation
; }
370 bool GetEnablePaper() const { return m_enablePaper
; }
371 bool GetEnablePrinter() const { return m_enablePrinter
; }
372 bool GetDefaultInfo() const { return m_getDefaultInfo
; }
373 bool GetEnableHelp() const { return m_enableHelp
; }
375 // Is this data OK for showing the page setup dialog?
376 bool Ok() const { return IsOk(); }
377 bool IsOk() const { return m_printData
.Ok() ; }
379 // If a corresponding paper type is found in the paper database, will set the m_printData
380 // paper size id member as well.
381 void SetPaperSize(const wxSize
& sz
);
383 void SetPaperId(wxPaperSize id
) { m_printData
.SetPaperId(id
); }
385 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
386 void SetPaperSize(wxPaperSize id
);
388 void SetMinMarginTopLeft(const wxPoint
& pt
) { m_minMarginTopLeft
= pt
; }
389 void SetMinMarginBottomRight(const wxPoint
& pt
) { m_minMarginBottomRight
= pt
; }
390 void SetMarginTopLeft(const wxPoint
& pt
) { m_marginTopLeft
= pt
; }
391 void SetMarginBottomRight(const wxPoint
& pt
) { m_marginBottomRight
= pt
; }
392 void SetDefaultMinMargins(bool flag
) { m_defaultMinMargins
= flag
; }
393 void SetDefaultInfo(bool flag
) { m_getDefaultInfo
= flag
; }
395 void EnableMargins(bool flag
) { m_enableMargins
= flag
; }
396 void EnableOrientation(bool flag
) { m_enableOrientation
= flag
; }
397 void EnablePaper(bool flag
) { m_enablePaper
= flag
; }
398 void EnablePrinter(bool flag
) { m_enablePrinter
= flag
; }
399 void EnableHelp(bool flag
) { m_enableHelp
= flag
; }
401 // Use paper size defined in this object to set the wxPrintData
403 void CalculateIdFromPaperSize();
405 // Use paper id in wxPrintData to set this object's paper size
406 void CalculatePaperSizeFromId();
408 wxPageSetupDialogData
& operator=(const wxPageSetupData
& data
);
409 wxPageSetupDialogData
& operator=(const wxPrintData
& data
);
411 wxPrintData
& GetPrintData() { return m_printData
; }
412 const wxPrintData
& GetPrintData() const { return m_printData
; }
413 void SetPrintData(const wxPrintData
& printData
);
416 wxSize m_paperSize
; // The dimensions selected by the user (on return, same as in wxPrintData?)
417 wxPoint m_minMarginTopLeft
;
418 wxPoint m_minMarginBottomRight
;
419 wxPoint m_marginTopLeft
;
420 wxPoint m_marginBottomRight
;
421 bool m_defaultMinMargins
;
422 bool m_enableMargins
;
423 bool m_enableOrientation
;
425 bool m_enablePrinter
;
426 bool m_getDefaultInfo
; // Equiv. to PSD_RETURNDEFAULT
428 wxPrintData m_printData
;
431 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData
)
434 #endif // wxUSE_PRINTING_ARCHITECTURE
437 // _WX_CMNDATA_H_BASE_