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 WXDLLIMPEXP_CORE 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 // SetCustomColour() modifies colours in an internal array of NUM_CUSTOM
51 void SetCustomColour(int i
, const wxColour
& colour
);
52 wxColour
GetCustomColour(int i
) const;
54 // Serialize the object to a string and restore it from it
55 wxString
ToString() const;
56 bool FromString(const wxString
& str
);
59 // public for backwards compatibility only: don't use directly
61 wxColour m_dataColour
;
62 wxColour m_custColours
[NUM_CUSTOM
];
66 DECLARE_DYNAMIC_CLASS(wxColourData
)
69 class WXDLLIMPEXP_CORE wxFontData
: public wxObject
73 virtual ~wxFontData();
75 wxFontData(const wxFontData
& data
)
77 m_fontColour(data
.m_fontColour
),
78 m_showHelp(data
.m_showHelp
),
79 m_allowSymbols(data
.m_allowSymbols
),
80 m_enableEffects(data
.m_enableEffects
),
81 m_initialFont(data
.m_initialFont
),
82 m_chosenFont(data
.m_chosenFont
),
83 m_minSize(data
.m_minSize
),
84 m_maxSize(data
.m_maxSize
),
85 m_encoding(data
.m_encoding
),
86 m_encodingInfo(data
.m_encodingInfo
)
90 wxFontData
& operator=(const wxFontData
& data
)
94 wxObject::operator=(data
);
95 m_fontColour
= data
.m_fontColour
;
96 m_showHelp
= data
.m_showHelp
;
97 m_allowSymbols
= data
.m_allowSymbols
;
98 m_enableEffects
= data
.m_enableEffects
;
99 m_initialFont
= data
.m_initialFont
;
100 m_chosenFont
= data
.m_chosenFont
;
101 m_minSize
= data
.m_minSize
;
102 m_maxSize
= data
.m_maxSize
;
103 m_encoding
= data
.m_encoding
;
104 m_encodingInfo
= data
.m_encodingInfo
;
109 void SetAllowSymbols(bool flag
) { m_allowSymbols
= flag
; }
110 bool GetAllowSymbols() const { return m_allowSymbols
; }
112 void SetColour(const wxColour
& colour
) { m_fontColour
= colour
; }
113 const wxColour
& GetColour() const { return m_fontColour
; }
115 void SetShowHelp(bool flag
) { m_showHelp
= flag
; }
116 bool GetShowHelp() const { return m_showHelp
; }
118 void EnableEffects(bool flag
) { m_enableEffects
= flag
; }
119 bool GetEnableEffects() const { return m_enableEffects
; }
121 void SetInitialFont(const wxFont
& font
) { m_initialFont
= font
; }
122 wxFont
GetInitialFont() const { return m_initialFont
; }
124 void SetChosenFont(const wxFont
& font
) { m_chosenFont
= font
; }
125 wxFont
GetChosenFont() const { return m_chosenFont
; }
127 void SetRange(int minRange
, int maxRange
) { m_minSize
= minRange
; m_maxSize
= maxRange
; }
129 // encoding info is split into 2 parts: the logical wxWin encoding
130 // (wxFontEncoding) and a structure containing the native parameters for
131 // it (wxNativeEncodingInfo)
132 wxFontEncoding
GetEncoding() const { return m_encoding
; }
133 void SetEncoding(wxFontEncoding encoding
) { m_encoding
= encoding
; }
135 wxNativeEncodingInfo
& EncodingInfo() { return m_encodingInfo
; }
138 // public for backwards compatibility only: don't use directly
140 wxColour m_fontColour
;
143 bool m_enableEffects
;
144 wxFont m_initialFont
;
150 wxFontEncoding m_encoding
;
151 wxNativeEncodingInfo m_encodingInfo
;
154 DECLARE_DYNAMIC_CLASS(wxFontData
)
157 #if wxUSE_PRINTING_ARCHITECTURE
160 * Encapsulates printer information (not printer dialog information)
172 wxPRINTBIN_ENVMANUAL
,
177 wxPRINTBIN_LARGECAPACITY
,
179 wxPRINTBIN_FORMSOURCE
,
184 const int wxPRINTMEDIA_DEFAULT
= 0;
186 class WXDLLIMPEXP_CORE wxPrintData
: public wxObject
190 wxPrintData(const wxPrintData
& printData
);
191 virtual ~wxPrintData();
193 int GetNoCopies() const { return m_printNoCopies
; }
194 bool GetCollate() const { return m_printCollate
; }
195 int GetOrientation() const { return m_printOrientation
; }
196 bool IsOrientationReversed() const { return m_printOrientationReversed
; }
198 // Is this data OK for showing the print dialog?
199 bool Ok() const { return IsOk(); }
202 const wxString
& GetPrinterName() const { return m_printerName
; }
203 bool GetColour() const { return m_colour
; }
204 wxDuplexMode
GetDuplex() const { return m_duplexMode
; }
205 wxPaperSize
GetPaperId() const { return m_paperId
; }
206 const wxSize
& GetPaperSize() const { return m_paperSize
; } // Not used yet: confusable with paper size
207 // in wxPageSetupDialogData
208 wxPrintQuality
GetQuality() const { return m_printQuality
; }
209 wxPrintBin
GetBin() const { return m_bin
; }
210 wxPrintMode
GetPrintMode() const { return m_printMode
; }
211 int GetMedia() const { return m_media
; }
213 void SetNoCopies(int v
) { m_printNoCopies
= v
; }
214 void SetCollate(bool flag
) { m_printCollate
= flag
; }
215 void SetOrientation(int orient
) { m_printOrientation
= orient
; }
216 void SetOrientationReversed(bool reversed
) { m_printOrientationReversed
= reversed
; }
218 void SetPrinterName(const wxString
& name
) { m_printerName
= name
; }
219 void SetColour(bool colour
) { m_colour
= colour
; }
220 void SetDuplex(wxDuplexMode duplex
) { m_duplexMode
= duplex
; }
221 void SetPaperId(wxPaperSize sizeId
) { m_paperId
= sizeId
; }
222 void SetPaperSize(const wxSize
& sz
) { m_paperSize
= sz
; }
223 void SetQuality(wxPrintQuality quality
) { m_printQuality
= quality
; }
224 void SetBin(wxPrintBin bin
) { m_bin
= bin
; }
225 void SetMedia(int media
) { m_media
= media
; }
226 void SetPrintMode(wxPrintMode printMode
) { m_printMode
= printMode
; }
228 wxString
GetFilename() const { return m_filename
; }
229 void SetFilename( const wxString
&filename
) { m_filename
= filename
; }
231 void operator=(const wxPrintData
& data
);
233 char* GetPrivData() const { return m_privData
; }
234 int GetPrivDataLen() const { return m_privDataLen
; }
235 void SetPrivData( char *privData
, int len
);
238 // Convert between wxPrintData and native data
239 void ConvertToNative();
240 void ConvertFromNative();
241 // Holds the native print data
242 wxPrintNativeDataBase
*GetNativeData() const { return m_nativeData
; }
247 wxPrintMode m_printMode
;
250 int m_printOrientation
;
251 bool m_printOrientationReversed
;
254 wxString m_printerName
;
256 wxDuplexMode m_duplexMode
;
257 wxPrintQuality m_printQuality
;
258 wxPaperSize m_paperId
;
266 wxPrintNativeDataBase
*m_nativeData
;
269 DECLARE_DYNAMIC_CLASS(wxPrintData
)
274 * Encapsulates information displayed and edited in the printer dialog box.
275 * Contains a wxPrintData object which is filled in according to the values retrieved
279 class WXDLLIMPEXP_CORE wxPrintDialogData
: public wxObject
283 wxPrintDialogData(const wxPrintDialogData
& dialogData
);
284 wxPrintDialogData(const wxPrintData
& printData
);
285 virtual ~wxPrintDialogData();
287 int GetFromPage() const { return m_printFromPage
; }
288 int GetToPage() const { return m_printToPage
; }
289 int GetMinPage() const { return m_printMinPage
; }
290 int GetMaxPage() const { return m_printMaxPage
; }
291 int GetNoCopies() const { return m_printNoCopies
; }
292 bool GetAllPages() const { return m_printAllPages
; }
293 bool GetSelection() const { return m_printSelection
; }
294 bool GetCollate() const { return m_printCollate
; }
295 bool GetPrintToFile() const { return m_printToFile
; }
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
; }
307 void EnablePrintToFile(bool flag
) { m_printEnablePrintToFile
= flag
; }
308 void EnableSelection(bool flag
) { m_printEnableSelection
= flag
; }
309 void EnablePageNumbers(bool flag
) { m_printEnablePageNumbers
= flag
; }
310 void EnableHelp(bool flag
) { m_printEnableHelp
= flag
; }
312 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile
; }
313 bool GetEnableSelection() const { return m_printEnableSelection
; }
314 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers
; }
315 bool GetEnableHelp() const { return m_printEnableHelp
; }
317 // Is this data OK for showing the print dialog?
318 bool Ok() const { return IsOk(); }
319 bool IsOk() const { return m_printData
.Ok() ; }
321 wxPrintData
& GetPrintData() { return m_printData
; }
322 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
324 void operator=(const wxPrintDialogData
& data
);
325 void operator=(const wxPrintData
& data
); // Sets internal m_printData member
333 bool m_printAllPages
;
336 bool m_printSelection
;
337 bool m_printEnableSelection
;
338 bool m_printEnablePageNumbers
;
339 bool m_printEnableHelp
;
340 bool m_printEnablePrintToFile
;
341 wxPrintData m_printData
;
344 DECLARE_DYNAMIC_CLASS(wxPrintDialogData
)
348 * This is the data used (and returned) by the wxPageSetupDialog.
351 // Compatibility with old name
352 #define wxPageSetupData wxPageSetupDialogData
354 class WXDLLIMPEXP_CORE wxPageSetupDialogData
: public wxObject
357 wxPageSetupDialogData();
358 wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
);
359 wxPageSetupDialogData(const wxPrintData
& printData
);
360 virtual ~wxPageSetupDialogData();
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
; }
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
; }
377 // Is this data OK for showing the page setup dialog?
378 bool Ok() const { return IsOk(); }
379 bool IsOk() const { return m_printData
.Ok() ; }
381 // If a corresponding paper type is found in the paper database, will set the m_printData
382 // paper size id member as well.
383 void SetPaperSize(const wxSize
& sz
);
385 void SetPaperId(wxPaperSize id
) { m_printData
.SetPaperId(id
); }
387 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
388 void SetPaperSize(wxPaperSize id
);
390 void SetMinMarginTopLeft(const wxPoint
& pt
) { m_minMarginTopLeft
= pt
; }
391 void SetMinMarginBottomRight(const wxPoint
& pt
) { m_minMarginBottomRight
= pt
; }
392 void SetMarginTopLeft(const wxPoint
& pt
) { m_marginTopLeft
= pt
; }
393 void SetMarginBottomRight(const wxPoint
& pt
) { m_marginBottomRight
= pt
; }
394 void SetDefaultMinMargins(bool flag
) { m_defaultMinMargins
= flag
; }
395 void SetDefaultInfo(bool flag
) { m_getDefaultInfo
= flag
; }
397 void EnableMargins(bool flag
) { m_enableMargins
= flag
; }
398 void EnableOrientation(bool flag
) { m_enableOrientation
= flag
; }
399 void EnablePaper(bool flag
) { m_enablePaper
= flag
; }
400 void EnablePrinter(bool flag
) { m_enablePrinter
= flag
; }
401 void EnableHelp(bool flag
) { m_enableHelp
= flag
; }
403 // Use paper size defined in this object to set the wxPrintData
405 void CalculateIdFromPaperSize();
407 // Use paper id in wxPrintData to set this object's paper size
408 void CalculatePaperSizeFromId();
410 wxPageSetupDialogData
& operator=(const wxPageSetupData
& data
);
411 wxPageSetupDialogData
& operator=(const wxPrintData
& data
);
413 wxPrintData
& GetPrintData() { return m_printData
; }
414 const wxPrintData
& GetPrintData() const { return m_printData
; }
415 void SetPrintData(const wxPrintData
& printData
);
418 wxSize m_paperSize
; // The dimensions selected by the user (on return, same as in wxPrintData?)
419 wxPoint m_minMarginTopLeft
;
420 wxPoint m_minMarginBottomRight
;
421 wxPoint m_marginTopLeft
;
422 wxPoint m_marginBottomRight
;
423 bool m_defaultMinMargins
;
424 bool m_enableMargins
;
425 bool m_enableOrientation
;
427 bool m_enablePrinter
;
428 bool m_getDefaultInfo
; // Equiv. to PSD_RETURNDEFAULT
430 wxPrintData m_printData
;
433 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData
)
436 #endif // wxUSE_PRINTING_ARCHITECTURE
439 // _WX_CMNDATA_H_BASE_