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 WXDLLEXPORT wxPrintNativeDataBase
;
29 class WXDLLEXPORT wxColourData
: public wxObject
33 wxColourData(const wxColourData
& data
);
34 virtual ~wxColourData();
36 void SetChooseFull(bool flag
) { m_chooseFull
= flag
; }
37 bool GetChooseFull() const { return m_chooseFull
; }
38 void SetColour(const wxColour
& colour
) { m_dataColour
= colour
; }
39 const wxColour
& GetColour() const { return m_dataColour
; }
40 wxColour
& GetColour() { return m_dataColour
; }
42 // Array of 16 custom colours
43 void SetCustomColour(int i
, const wxColour
& colour
);
44 wxColour
GetCustomColour(int i
);
46 void operator=(const wxColourData
& data
);
49 wxColour m_dataColour
;
50 wxColour m_custColours
[16];
54 DECLARE_DYNAMIC_CLASS(wxColourData
)
57 class WXDLLEXPORT wxFontData
: public wxObject
61 virtual ~wxFontData();
63 wxFontData(const wxFontData
& data
)
65 m_fontColour(data
.m_fontColour
),
66 m_showHelp(data
.m_showHelp
),
67 m_allowSymbols(data
.m_allowSymbols
),
68 m_enableEffects(data
.m_enableEffects
),
69 m_initialFont(data
.m_initialFont
),
70 m_chosenFont(data
.m_chosenFont
),
71 m_minSize(data
.m_minSize
),
72 m_maxSize(data
.m_maxSize
),
73 m_encoding(data
.m_encoding
),
74 m_encodingInfo(data
.m_encodingInfo
)
78 wxFontData
& operator=(const wxFontData
& data
)
80 wxObject::operator=(data
);
81 m_fontColour
= data
.m_fontColour
;
82 m_showHelp
= data
.m_showHelp
;
83 m_allowSymbols
= data
.m_allowSymbols
;
84 m_enableEffects
= data
.m_enableEffects
;
85 m_initialFont
= data
.m_initialFont
;
86 m_chosenFont
= data
.m_chosenFont
;
87 m_minSize
= data
.m_minSize
;
88 m_maxSize
= data
.m_maxSize
;
89 m_encoding
= data
.m_encoding
;
90 m_encodingInfo
= data
.m_encodingInfo
;
94 void SetAllowSymbols(bool flag
) { m_allowSymbols
= flag
; }
95 bool GetAllowSymbols() const { return m_allowSymbols
; }
97 void SetColour(const wxColour
& colour
) { m_fontColour
= colour
; }
98 const wxColour
& GetColour() const { return m_fontColour
; }
100 void SetShowHelp(bool flag
) { m_showHelp
= flag
; }
101 bool GetShowHelp() const { return m_showHelp
; }
103 void EnableEffects(bool flag
) { m_enableEffects
= flag
; }
104 bool GetEnableEffects() const { return m_enableEffects
; }
106 void SetInitialFont(const wxFont
& font
) { m_initialFont
= font
; }
107 wxFont
GetInitialFont() const { return m_initialFont
; }
109 void SetChosenFont(const wxFont
& font
) { m_chosenFont
= font
; }
110 wxFont
GetChosenFont() const { return m_chosenFont
; }
112 void SetRange(int minRange
, int maxRange
) { m_minSize
= minRange
; m_maxSize
= maxRange
; }
114 // encoding info is split into 2 parts: the logical wxWin encoding
115 // (wxFontEncoding) and a structure containing the native parameters for
116 // it (wxNativeEncodingInfo)
117 wxFontEncoding
GetEncoding() const { return m_encoding
; }
118 void SetEncoding(wxFontEncoding encoding
) { m_encoding
= encoding
; }
120 wxNativeEncodingInfo
& EncodingInfo() { return m_encodingInfo
; }
123 // public for backwards compatibility only: don't use directly
125 wxColour m_fontColour
;
128 bool m_enableEffects
;
129 wxFont m_initialFont
;
135 wxFontEncoding m_encoding
;
136 wxNativeEncodingInfo m_encodingInfo
;
139 DECLARE_DYNAMIC_CLASS(wxFontData
)
142 #if wxUSE_PRINTING_ARCHITECTURE
145 * Encapsulates printer information (not printer dialog information)
157 wxPRINTBIN_ENVMANUAL
,
162 wxPRINTBIN_LARGECAPACITY
,
164 wxPRINTBIN_FORMSOURCE
,
169 const int wxPRINTMEDIA_DEFAULT
= 0;
171 class WXDLLEXPORT wxPrintData
: public wxObject
175 wxPrintData(const wxPrintData
& printData
);
176 virtual ~wxPrintData();
178 int GetNoCopies() const { return m_printNoCopies
; }
179 bool GetCollate() const { return m_printCollate
; }
180 int GetOrientation() const { return m_printOrientation
; }
182 // Is this data OK for showing the print dialog?
183 bool Ok() const { return IsOk(); }
186 const wxString
& GetPrinterName() const { return m_printerName
; }
187 bool GetColour() const { return m_colour
; }
188 wxDuplexMode
GetDuplex() const { return m_duplexMode
; }
189 wxPaperSize
GetPaperId() const { return m_paperId
; }
190 const wxSize
& GetPaperSize() const { return m_paperSize
; } // Not used yet: confusable with paper size
191 // in wxPageSetupDialogData
192 wxPrintQuality
GetQuality() const { return m_printQuality
; }
193 wxPrintBin
GetBin() const { return m_bin
; }
194 wxPrintMode
GetPrintMode() const { return m_printMode
; }
195 int GetMedia() const { return m_media
; }
197 void SetNoCopies(int v
) { m_printNoCopies
= v
; }
198 void SetCollate(bool flag
) { m_printCollate
= flag
; }
199 void SetOrientation(int orient
) { m_printOrientation
= orient
; }
201 void SetPrinterName(const wxString
& name
) { m_printerName
= name
; }
202 void SetColour(bool colour
) { m_colour
= colour
; }
203 void SetDuplex(wxDuplexMode duplex
) { m_duplexMode
= duplex
; }
204 void SetPaperId(wxPaperSize sizeId
) { m_paperId
= sizeId
; }
205 void SetPaperSize(const wxSize
& sz
) { m_paperSize
= sz
; }
206 void SetQuality(wxPrintQuality quality
) { m_printQuality
= quality
; }
207 void SetBin(wxPrintBin bin
) { m_bin
= bin
; }
208 void SetMedia(int media
) { m_media
= media
; }
209 void SetPrintMode(wxPrintMode printMode
) { m_printMode
= printMode
; }
211 wxString
GetFilename() const { return m_filename
; }
212 void SetFilename( const wxString
&filename
) { m_filename
= filename
; }
214 void operator=(const wxPrintData
& data
);
216 char* GetPrivData() const { return m_privData
; }
217 int GetPrivDataLen() const { return m_privDataLen
; }
218 void SetPrivData( char *privData
, int len
);
221 #if WXWIN_COMPATIBILITY_2_4
222 // PostScript-specific data
223 wxString
GetPrinterCommand() const;
224 wxString
GetPrinterOptions() const;
225 wxString
GetPreviewCommand() const;
226 wxString
GetFontMetricPath() const;
227 double GetPrinterScaleX() const;
228 double GetPrinterScaleY() const;
229 long GetPrinterTranslateX() const;
230 long GetPrinterTranslateY() const;
232 void SetPrinterCommand(const wxString
& command
);
233 void SetPrinterOptions(const wxString
& options
);
234 void SetPreviewCommand(const wxString
& command
);
235 void SetFontMetricPath(const wxString
& path
);
236 void SetPrinterScaleX(double x
);
237 void SetPrinterScaleY(double y
);
238 void SetPrinterScaling(double x
, double y
);
239 void SetPrinterTranslateX(long x
);
240 void SetPrinterTranslateY(long y
);
241 void SetPrinterTranslation(long x
, long y
);
244 // Convert between wxPrintData and native data
245 void ConvertToNative();
246 void ConvertFromNative();
247 // Holds the native print data
248 wxPrintNativeDataBase
*GetNativeData() const { return m_nativeData
; }
253 wxPrintMode m_printMode
;
256 int m_printOrientation
;
259 wxString m_printerName
;
261 wxDuplexMode m_duplexMode
;
262 wxPrintQuality m_printQuality
;
263 wxPaperSize m_paperId
;
271 wxPrintNativeDataBase
*m_nativeData
;
274 DECLARE_DYNAMIC_CLASS(wxPrintData
)
279 * Encapsulates information displayed and edited in the printer dialog box.
280 * Contains a wxPrintData object which is filled in according to the values retrieved
284 class WXDLLEXPORT wxPrintDialogData
: public wxObject
288 wxPrintDialogData(const wxPrintDialogData
& dialogData
);
289 wxPrintDialogData(const wxPrintData
& printData
);
290 virtual ~wxPrintDialogData();
292 int GetFromPage() const { return m_printFromPage
; };
293 int GetToPage() const { return m_printToPage
; };
294 int GetMinPage() const { return m_printMinPage
; };
295 int GetMaxPage() const { return m_printMaxPage
; };
296 int GetNoCopies() const { return m_printNoCopies
; };
297 bool GetAllPages() const { return m_printAllPages
; };
298 bool GetSelection() const { return m_printSelection
; };
299 bool GetCollate() const { return m_printCollate
; };
300 bool GetPrintToFile() const { return m_printToFile
; };
301 #if WXWIN_COMPATIBILITY_2_4
302 bool GetSetupDialog() const { return m_printSetupDialog
; };
304 void SetFromPage(int v
) { m_printFromPage
= v
; };
305 void SetToPage(int v
) { m_printToPage
= v
; };
306 void SetMinPage(int v
) { m_printMinPage
= v
; };
307 void SetMaxPage(int v
) { m_printMaxPage
= v
; };
308 void SetNoCopies(int v
) { m_printNoCopies
= v
; };
309 void SetAllPages(bool flag
) { m_printAllPages
= flag
; };
310 void SetSelection(bool flag
) { m_printSelection
= flag
; };
311 void SetCollate(bool flag
) { m_printCollate
= flag
; };
312 void SetPrintToFile(bool flag
) { m_printToFile
= flag
; };
313 #if WXWIN_COMPATIBILITY_2_4
314 void SetSetupDialog(bool flag
) { m_printSetupDialog
= flag
; };
316 void EnablePrintToFile(bool flag
) { m_printEnablePrintToFile
= flag
; };
317 void EnableSelection(bool flag
) { m_printEnableSelection
= flag
; };
318 void EnablePageNumbers(bool flag
) { m_printEnablePageNumbers
= flag
; };
319 void EnableHelp(bool flag
) { m_printEnableHelp
= flag
; };
321 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile
; };
322 bool GetEnableSelection() const { return m_printEnableSelection
; };
323 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers
; };
324 bool GetEnableHelp() const { return m_printEnableHelp
; };
326 // Is this data OK for showing the print dialog?
327 bool Ok() const { return IsOk(); }
328 bool IsOk() const { return m_printData
.Ok() ; }
330 wxPrintData
& GetPrintData() { return m_printData
; }
331 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
333 void operator=(const wxPrintDialogData
& data
);
334 void operator=(const wxPrintData
& data
); // Sets internal m_printData member
342 bool m_printAllPages
;
345 bool m_printSelection
;
346 bool m_printEnableSelection
;
347 bool m_printEnablePageNumbers
;
348 bool m_printEnableHelp
;
349 bool m_printEnablePrintToFile
;
350 #if WXWIN_COMPATIBILITY_2_4
351 bool m_printSetupDialog
;
353 wxPrintData m_printData
;
356 DECLARE_DYNAMIC_CLASS(wxPrintDialogData
)
360 * This is the data used (and returned) by the wxPageSetupDialog.
363 // Compatibility with old name
364 #define wxPageSetupData wxPageSetupDialogData
366 class WXDLLEXPORT wxPageSetupDialogData
: public wxObject
369 wxPageSetupDialogData();
370 wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
);
371 wxPageSetupDialogData(const wxPrintData
& printData
);
372 virtual ~wxPageSetupDialogData();
374 wxSize
GetPaperSize() const { return m_paperSize
; };
375 wxPaperSize
GetPaperId() const { return m_printData
.GetPaperId(); };
376 wxPoint
GetMinMarginTopLeft() const { return m_minMarginTopLeft
; };
377 wxPoint
GetMinMarginBottomRight() const { return m_minMarginBottomRight
; };
378 wxPoint
GetMarginTopLeft() const { return m_marginTopLeft
; };
379 wxPoint
GetMarginBottomRight() const { return m_marginBottomRight
; };
381 bool GetDefaultMinMargins() const { return m_defaultMinMargins
; };
382 bool GetEnableMargins() const { return m_enableMargins
; };
383 bool GetEnableOrientation() const { return m_enableOrientation
; };
384 bool GetEnablePaper() const { return m_enablePaper
; };
385 bool GetEnablePrinter() const { return m_enablePrinter
; };
386 bool GetDefaultInfo() const { return m_getDefaultInfo
; };
387 bool GetEnableHelp() const { return m_enableHelp
; };
389 // Is this data OK for showing the page setup dialog?
390 bool Ok() const { return IsOk(); }
391 bool IsOk() const { return m_printData
.Ok() ; }
393 // If a corresponding paper type is found in the paper database, will set the m_printData
394 // paper size id member as well.
395 void SetPaperSize(const wxSize
& sz
);
397 void SetPaperId(wxPaperSize id
) { m_printData
.SetPaperId(id
); };
399 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
400 void SetPaperSize(wxPaperSize id
);
402 void SetMinMarginTopLeft(const wxPoint
& pt
) { m_minMarginTopLeft
= pt
; };
403 void SetMinMarginBottomRight(const wxPoint
& pt
) { m_minMarginBottomRight
= pt
; };
404 void SetMarginTopLeft(const wxPoint
& pt
) { m_marginTopLeft
= pt
; };
405 void SetMarginBottomRight(const wxPoint
& pt
) { m_marginBottomRight
= pt
; };
406 void SetDefaultMinMargins(bool flag
) { m_defaultMinMargins
= flag
; };
407 void SetDefaultInfo(bool flag
) { m_getDefaultInfo
= flag
; };
409 void EnableMargins(bool flag
) { m_enableMargins
= flag
; };
410 void EnableOrientation(bool flag
) { m_enableOrientation
= flag
; };
411 void EnablePaper(bool flag
) { m_enablePaper
= flag
; };
412 void EnablePrinter(bool flag
) { m_enablePrinter
= flag
; };
413 void EnableHelp(bool flag
) { m_enableHelp
= flag
; };
415 // Use paper size defined in this object to set the wxPrintData
417 void CalculateIdFromPaperSize();
419 // Use paper id in wxPrintData to set this object's paper size
420 void CalculatePaperSizeFromId();
422 wxPageSetupDialogData
& operator=(const wxPageSetupData
& data
);
423 wxPageSetupDialogData
& operator=(const wxPrintData
& data
);
425 wxPrintData
& GetPrintData() { return m_printData
; }
426 const wxPrintData
& GetPrintData() const { return m_printData
; }
427 void SetPrintData(const wxPrintData
& printData
);
430 wxSize m_paperSize
; // The dimensions selected by the user (on return, same as in wxPrintData?)
431 wxPoint m_minMarginTopLeft
;
432 wxPoint m_minMarginBottomRight
;
433 wxPoint m_marginTopLeft
;
434 wxPoint m_marginBottomRight
;
435 bool m_defaultMinMargins
;
436 bool m_enableMargins
;
437 bool m_enableOrientation
;
439 bool m_enablePrinter
;
440 bool m_getDefaultInfo
; // Equiv. to PSD_RETURNDEFAULT
442 wxPrintData m_printData
;
445 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData
)
448 #endif // wxUSE_PRINTING_ARCHITECTURE
451 // _WX_CMNDATA_H_BASE_