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
)
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
;
104 void SetAllowSymbols(bool flag
) { m_allowSymbols
= flag
; }
105 bool GetAllowSymbols() const { return m_allowSymbols
; }
107 void SetColour(const wxColour
& colour
) { m_fontColour
= colour
; }
108 const wxColour
& GetColour() const { return m_fontColour
; }
110 void SetShowHelp(bool flag
) { m_showHelp
= flag
; }
111 bool GetShowHelp() const { return m_showHelp
; }
113 void EnableEffects(bool flag
) { m_enableEffects
= flag
; }
114 bool GetEnableEffects() const { return m_enableEffects
; }
116 void SetInitialFont(const wxFont
& font
) { m_initialFont
= font
; }
117 wxFont
GetInitialFont() const { return m_initialFont
; }
119 void SetChosenFont(const wxFont
& font
) { m_chosenFont
= font
; }
120 wxFont
GetChosenFont() const { return m_chosenFont
; }
122 void SetRange(int minRange
, int maxRange
) { m_minSize
= minRange
; m_maxSize
= maxRange
; }
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
; }
130 wxNativeEncodingInfo
& EncodingInfo() { return m_encodingInfo
; }
133 // public for backwards compatibility only: don't use directly
135 wxColour m_fontColour
;
138 bool m_enableEffects
;
139 wxFont m_initialFont
;
145 wxFontEncoding m_encoding
;
146 wxNativeEncodingInfo m_encodingInfo
;
149 DECLARE_DYNAMIC_CLASS(wxFontData
)
152 #if wxUSE_PRINTING_ARCHITECTURE
155 * Encapsulates printer information (not printer dialog information)
167 wxPRINTBIN_ENVMANUAL
,
172 wxPRINTBIN_LARGECAPACITY
,
174 wxPRINTBIN_FORMSOURCE
,
179 const int wxPRINTMEDIA_DEFAULT
= 0;
181 class WXDLLEXPORT wxPrintData
: public wxObject
185 wxPrintData(const wxPrintData
& printData
);
186 virtual ~wxPrintData();
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
; }
193 // Is this data OK for showing the print dialog?
194 bool Ok() const { return IsOk(); }
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
; }
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
; }
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
; }
223 wxString
GetFilename() const { return m_filename
; }
224 void SetFilename( const wxString
&filename
) { m_filename
= filename
; }
226 void operator=(const wxPrintData
& data
);
228 char* GetPrivData() const { return m_privData
; }
229 int GetPrivDataLen() const { return m_privDataLen
; }
230 void SetPrivData( char *privData
, int len
);
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
; }
242 wxPrintMode m_printMode
;
245 int m_printOrientation
;
246 bool m_printOrientationReversed
;
249 wxString m_printerName
;
251 wxDuplexMode m_duplexMode
;
252 wxPrintQuality m_printQuality
;
253 wxPaperSize m_paperId
;
261 wxPrintNativeDataBase
*m_nativeData
;
264 DECLARE_DYNAMIC_CLASS(wxPrintData
)
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
274 class WXDLLEXPORT wxPrintDialogData
: public wxObject
278 wxPrintDialogData(const wxPrintDialogData
& dialogData
);
279 wxPrintDialogData(const wxPrintData
& printData
);
280 virtual ~wxPrintDialogData();
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
; }
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
; }
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
; }
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
; }
312 // Is this data OK for showing the print dialog?
313 bool Ok() const { return IsOk(); }
314 bool IsOk() const { return m_printData
.Ok() ; }
316 wxPrintData
& GetPrintData() { return m_printData
; }
317 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
319 void operator=(const wxPrintDialogData
& data
);
320 void operator=(const wxPrintData
& data
); // Sets internal m_printData member
328 bool m_printAllPages
;
331 bool m_printSelection
;
332 bool m_printEnableSelection
;
333 bool m_printEnablePageNumbers
;
334 bool m_printEnableHelp
;
335 bool m_printEnablePrintToFile
;
336 wxPrintData m_printData
;
339 DECLARE_DYNAMIC_CLASS(wxPrintDialogData
)
343 * This is the data used (and returned) by the wxPageSetupDialog.
346 // Compatibility with old name
347 #define wxPageSetupData wxPageSetupDialogData
349 class WXDLLEXPORT wxPageSetupDialogData
: public wxObject
352 wxPageSetupDialogData();
353 wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
);
354 wxPageSetupDialogData(const wxPrintData
& printData
);
355 virtual ~wxPageSetupDialogData();
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
; }
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
; }
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() ; }
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
);
380 void SetPaperId(wxPaperSize id
) { m_printData
.SetPaperId(id
); }
382 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
383 void SetPaperSize(wxPaperSize id
);
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
; }
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
; }
398 // Use paper size defined in this object to set the wxPrintData
400 void CalculateIdFromPaperSize();
402 // Use paper id in wxPrintData to set this object's paper size
403 void CalculatePaperSizeFromId();
405 wxPageSetupDialogData
& operator=(const wxPageSetupData
& data
);
406 wxPageSetupDialogData
& operator=(const wxPrintData
& data
);
408 wxPrintData
& GetPrintData() { return m_printData
; }
409 const wxPrintData
& GetPrintData() const { return m_printData
; }
410 void SetPrintData(const wxPrintData
& printData
);
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
;
422 bool m_enablePrinter
;
423 bool m_getDefaultInfo
; // Equiv. to PSD_RETURNDEFAULT
425 wxPrintData m_printData
;
428 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData
)
431 #endif // wxUSE_PRINTING_ARCHITECTURE
434 // _WX_CMNDATA_H_BASE_