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_
16 #pragma interface "cmndata.h"
19 #include "wx/window.h"
21 #include "wx/fontutil.h"
22 #include "wx/colour.h"
23 #include "wx/gdicmn.h"
25 #if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__)) && wxUSE_POSTSCRIPT
26 class WXDLLEXPORT wxPrintSetupData
;
29 class WXDLLEXPORT wxColourData
: public wxObject
31 DECLARE_DYNAMIC_CLASS(wxColourData
)
34 wxColourData(const wxColourData
& data
);
37 void SetChooseFull(bool flag
) { chooseFull
= flag
; }
38 bool GetChooseFull() const { return chooseFull
; }
39 void SetColour(wxColour
& colour
) { dataColour
= colour
; }
40 wxColour
&GetColour() { return dataColour
; }
42 // Array of 16 custom colours
43 void SetCustomColour(int i
, wxColour
& colour
);
44 wxColour
GetCustomColour(int i
);
46 void operator=(const wxColourData
& data
);
50 wxColour custColours
[16];
54 class WXDLLEXPORT wxFontData
: public wxObject
56 DECLARE_DYNAMIC_CLASS(wxFontData
)
61 void SetAllowSymbols(bool flag
) { allowSymbols
= flag
; }
62 bool GetAllowSymbols() const { return allowSymbols
; }
64 void SetColour(const wxColour
& colour
) { fontColour
= colour
; }
65 wxColour
&GetColour() { return fontColour
; }
67 void SetShowHelp(bool flag
) { showHelp
= flag
; }
68 bool GetShowHelp() const { return showHelp
; }
70 void EnableEffects(bool flag
) { enableEffects
= flag
; }
71 bool GetEnableEffects() const { return enableEffects
; }
73 void SetInitialFont(const wxFont
& font
) { initialFont
= font
; }
74 wxFont
GetInitialFont() const { return initialFont
; }
76 void SetChosenFont(const wxFont
& font
) { chosenFont
= font
; }
77 wxFont
GetChosenFont() const { return chosenFont
; }
79 void SetRange(int minRange
, int maxRange
) { minSize
= minRange
; maxSize
= maxRange
; }
81 // encoding info is split into 2 parts: the logical wxWin encoding
82 // (wxFontEncoding) and a structure containing the native parameters for
83 // it (wxNativeEncodingInfo)
84 wxFontEncoding
GetEncoding() const { return m_encoding
; }
85 void SetEncoding(wxFontEncoding encoding
) { m_encoding
= encoding
; }
87 wxNativeEncodingInfo
& EncodingInfo() { return m_encodingInfo
; }
100 wxFontEncoding m_encoding
;
101 wxNativeEncodingInfo m_encodingInfo
;
104 #if wxUSE_PRINTING_ARCHITECTURE
107 * Encapsulates printer information (not printer dialog information)
110 class WXDLLEXPORT wxPrintData
: public wxObject
112 DECLARE_DYNAMIC_CLASS(wxPrintData
)
115 wxPrintData(const wxPrintData
& printData
);
118 int GetNoCopies() const { return m_printNoCopies
; };
119 bool GetCollate() const { return m_printCollate
; };
120 int GetOrientation() const { return m_printOrientation
; };
122 const wxString
& GetPrinterName() const { return m_printerName
; }
123 bool GetColour() const { return m_colour
; }
124 wxDuplexMode
GetDuplex() const { return m_duplexMode
; }
125 wxPaperSize
GetPaperId() const { return m_paperId
; }
126 const wxSize
& GetPaperSize() const { return m_paperSize
; } // Not used yet: confusable with paper size
127 // in wxPageSetupDialogData
128 wxPrintQuality
GetQuality() const { return m_printQuality
; }
130 void SetNoCopies(int v
) { m_printNoCopies
= v
; };
131 void SetCollate(bool flag
) { m_printCollate
= flag
; };
132 void SetOrientation(int orient
) { m_printOrientation
= orient
; };
134 void SetPrinterName(const wxString
& name
) { m_printerName
= name
; }
135 void SetColour(bool colour
) { m_colour
= colour
; }
136 void SetDuplex(wxDuplexMode duplex
) { m_duplexMode
= duplex
; }
137 void SetPaperId(wxPaperSize sizeId
) { m_paperId
= sizeId
; }
138 void SetPaperSize(const wxSize
& sz
) { m_paperSize
= sz
; }
139 void SetQuality(wxPrintQuality quality
) { m_printQuality
= quality
; }
141 // PostScript-specific data
142 const wxString
& GetPrinterCommand() const { return m_printerCommand
; }
143 const wxString
& GetPrinterOptions() const { return m_printerOptions
; }
144 const wxString
& GetPreviewCommand() const { return m_previewCommand
; }
145 const wxString
& GetFilename() const { return m_filename
; }
146 const wxString
& GetFontMetricPath() const { return m_afmPath
; }
147 double GetPrinterScaleX() const { return m_printerScaleX
; }
148 double GetPrinterScaleY() const { return m_printerScaleY
; }
149 long GetPrinterTranslateX() const { return m_printerTranslateX
; }
150 long GetPrinterTranslateY() const { return m_printerTranslateY
; }
151 wxPrintMode
GetPrintMode() const { return m_printMode
; }
153 void SetPrinterCommand(const wxString
& command
) { m_printerCommand
= command
; }
154 void SetPrinterOptions(const wxString
& options
) { m_printerOptions
= options
; }
155 void SetPreviewCommand(const wxString
& command
) { m_previewCommand
= command
; }
156 void SetFilename(const wxString
& filename
) { m_filename
= filename
; }
157 void SetFontMetricPath(const wxString
& path
) { m_afmPath
= path
; }
158 void SetPrinterScaleX(double x
) { m_printerScaleX
= x
; }
159 void SetPrinterScaleY(double y
) { m_printerScaleY
= y
; }
160 void SetPrinterScaling(double x
, double y
) { m_printerScaleX
= x
; m_printerScaleY
= y
; }
161 void SetPrinterTranslateX(long x
) { m_printerTranslateX
= x
; }
162 void SetPrinterTranslateY(long y
) { m_printerTranslateY
= y
; }
163 void SetPrinterTranslation(long x
, long y
) { m_printerTranslateX
= x
; m_printerTranslateY
= y
; }
164 void SetPrintMode(wxPrintMode printMode
) { m_printMode
= printMode
; }
166 void operator=(const wxPrintData
& data
);
169 #if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__)) && wxUSE_POSTSCRIPT
170 void operator=(const wxPrintSetupData
& setupData
);
173 #if defined(__WXMSW__)
174 // Convert to/from the DEVMODE structure
175 void ConvertToNative();
176 void ConvertFromNative();
177 void* GetNativeData() const { return m_devMode
; }
178 void SetNativeData(void* data
) { m_devMode
= data
; }
179 void* GetNativeDataDevNames() const { return m_devNames
; }
180 void SetNativeDataDevNames(void* data
) { m_devNames
= data
; }
181 #elif defined( __WXMAC__)
182 void ConvertToNative();
183 void ConvertFromNative();
190 #elif defined( __WXMAC__ )
191 THPrint m_macPrintInfo
;
197 int m_printOrientation
;
200 // New members, 24/3/99
201 wxString m_printerName
;
203 wxDuplexMode m_duplexMode
;
204 wxPrintQuality m_printQuality
;
205 wxPaperSize m_paperId
;
208 // PostScript-specific data
209 wxString m_printerCommand
;
210 wxString m_previewCommand
;
211 wxString m_printerOptions
;
214 double m_printerScaleX
;
215 double m_printerScaleY
;
216 long m_printerTranslateX
;
217 long m_printerTranslateY
;
218 wxPrintMode m_printMode
;
223 * Encapsulates information displayed and edited in the printer dialog box.
224 * Contains a wxPrintData object which is filled in according to the values retrieved
228 class WXDLLEXPORT wxPrintDialogData
: public wxObject
230 DECLARE_DYNAMIC_CLASS(wxPrintDialogData
)
233 wxPrintDialogData(const wxPrintDialogData
& dialogData
);
234 wxPrintDialogData(const wxPrintData
& printData
);
235 ~wxPrintDialogData();
237 int GetFromPage() const { return m_printFromPage
; };
238 int GetToPage() const { return m_printToPage
; };
239 int GetMinPage() const { return m_printMinPage
; };
240 int GetMaxPage() const { return m_printMaxPage
; };
241 int GetNoCopies() const { return m_printNoCopies
; };
242 bool GetAllPages() const { return m_printAllPages
; };
243 bool GetSelection() const { return m_printSelection
; };
244 bool GetCollate() const { return m_printCollate
; };
245 bool GetPrintToFile() const { return m_printToFile
; };
246 bool GetSetupDialog() const { return m_printSetupDialog
; };
248 void SetFromPage(int v
) { m_printFromPage
= v
; };
249 void SetToPage(int v
) { m_printToPage
= v
; };
250 void SetMinPage(int v
) { m_printMinPage
= v
; };
251 void SetMaxPage(int v
) { m_printMaxPage
= v
; };
252 void SetNoCopies(int v
) { m_printNoCopies
= v
; };
253 void SetAllPages(bool flag
) { m_printAllPages
= flag
; };
254 void SetSelection(bool flag
) { m_printSelection
= flag
; };
255 void SetCollate(bool flag
) { m_printCollate
= flag
; };
256 void SetPrintToFile(bool flag
) { m_printToFile
= flag
; };
257 void SetSetupDialog(bool flag
) { m_printSetupDialog
= flag
; };
259 void EnablePrintToFile(bool flag
) { m_printEnablePrintToFile
= flag
; };
260 void EnableSelection(bool flag
) { m_printEnableSelection
= flag
; };
261 void EnablePageNumbers(bool flag
) { m_printEnablePageNumbers
= flag
; };
262 void EnableHelp(bool flag
) { m_printEnableHelp
= flag
; };
264 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile
; };
265 bool GetEnableSelection() const { return m_printEnableSelection
; };
266 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers
; };
267 bool GetEnableHelp() const { return m_printEnableHelp
; };
269 wxPrintData
& GetPrintData() { return m_printData
; }
270 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
272 void operator=(const wxPrintDialogData
& data
);
273 void operator=(const wxPrintData
& data
); // Sets internal m_printData member
276 // Convert to/from the PRINTDLG structure
277 void ConvertToNative();
278 void ConvertFromNative();
279 void SetOwnerWindow(wxWindow
* win
);
280 void* GetNativeData() const { return m_printDlgData
; }
281 #elif defined( __WXMAC__)
282 void ConvertToNative();
283 void ConvertFromNative();
287 void* m_printDlgData
;
288 #elif defined( __WXMAC__ )
289 THPrint m_macPrintInfo
;
299 bool m_printAllPages
;
302 bool m_printSelection
;
303 bool m_printEnableSelection
;
304 bool m_printEnablePageNumbers
;
305 bool m_printEnableHelp
;
306 bool m_printEnablePrintToFile
;
307 bool m_printSetupDialog
;
309 wxPrintData m_printData
;
313 * This is the data used (and returned) by the wxPageSetupDialog.
316 // Compatibility with old name
317 #define wxPageSetupData wxPageSetupDialogData
319 class WXDLLEXPORT wxPageSetupDialogData
: public wxObject
321 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData
)
324 wxPageSetupDialogData();
325 wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
);
326 wxPageSetupDialogData(const wxPrintData
& printData
);
327 ~wxPageSetupDialogData();
329 wxSize
GetPaperSize() const { return m_paperSize
; };
330 wxPaperSize
GetPaperId() const { return m_printData
.GetPaperId(); };
331 wxPoint
GetMinMarginTopLeft() const { return m_minMarginTopLeft
; };
332 wxPoint
GetMinMarginBottomRight() const { return m_minMarginBottomRight
; };
333 wxPoint
GetMarginTopLeft() const { return m_marginTopLeft
; };
334 wxPoint
GetMarginBottomRight() const { return m_marginBottomRight
; };
336 bool GetDefaultMinMargins() const { return m_defaultMinMargins
; };
337 bool GetEnableMargins() const { return m_enableMargins
; };
338 bool GetEnableOrientation() const { return m_enableOrientation
; };
339 bool GetEnablePaper() const { return m_enablePaper
; };
340 bool GetEnablePrinter() const { return m_enablePrinter
; };
341 bool GetDefaultInfo() const { return m_getDefaultInfo
; };
342 bool GetEnableHelp() const { return m_enableHelp
; };
344 // If a corresponding paper type is found in the paper database, will set the m_printData
345 // paper size id member as well.
346 void SetPaperSize(const wxSize
& sz
);
348 void SetPaperId(wxPaperSize
& id
) { m_printData
.SetPaperId(id
); };
350 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
351 void SetPaperSize(wxPaperSize id
);
353 void SetMinMarginTopLeft(const wxPoint
& pt
) { m_minMarginTopLeft
= pt
; };
354 void SetMinMarginBottomRight(const wxPoint
& pt
) { m_minMarginBottomRight
= pt
; };
355 void SetMarginTopLeft(const wxPoint
& pt
) { m_marginTopLeft
= pt
; };
356 void SetMarginBottomRight(const wxPoint
& pt
) { m_marginBottomRight
= pt
; };
357 void SetDefaultMinMargins(bool flag
) { m_defaultMinMargins
= flag
; };
358 void SetDefaultInfo(bool flag
) { m_getDefaultInfo
= flag
; };
360 void EnableMargins(bool flag
) { m_enableMargins
= flag
; };
361 void EnableOrientation(bool flag
) { m_enableOrientation
= flag
; };
362 void EnablePaper(bool flag
) { m_enablePaper
= flag
; };
363 void EnablePrinter(bool flag
) { m_enablePrinter
= flag
; };
364 void EnableHelp(bool flag
) { m_enableHelp
= flag
; };
366 #if defined(__WIN95__)
367 // Convert to/from the PAGESETUPDLG structure
368 void ConvertToNative();
369 void ConvertFromNative();
370 void SetOwnerWindow(wxWindow
* win
);
371 void* GetNativeData() const { return m_pageSetupData
; }
372 #elif defined( __WXMAC__)
373 void ConvertToNative();
374 void ConvertFromNative();
377 // Use paper size defined in this object to set the wxPrintData
379 void CalculateIdFromPaperSize();
381 // Use paper id in wxPrintData to set this object's paper size
382 void CalculatePaperSizeFromId();
384 void operator=(const wxPageSetupData
& data
);
385 void operator=(const wxPrintData
& data
);
387 wxPrintData
& GetPrintData() { return m_printData
; }
388 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
390 #if defined(__WIN95__)
391 void* m_pageSetupData
;
392 #elif defined( __WXMAC__ )
393 THPrint m_macPageSetupInfo
;
398 wxSize m_paperSize
; // The dimensions selected by the user (on return, same as in wxPrintData?)
399 wxPoint m_minMarginTopLeft
;
400 wxPoint m_minMarginBottomRight
;
401 wxPoint m_marginTopLeft
;
402 wxPoint m_marginBottomRight
;
405 bool m_defaultMinMargins
;
406 bool m_enableMargins
;
407 bool m_enableOrientation
;
409 bool m_enablePrinter
;
410 bool m_getDefaultInfo
; // Equiv. to PSD_RETURNDEFAULT
413 wxPrintData m_printData
;
416 #endif // wxUSE_PRINTING_ARCHITECTURE
419 // _WX_CMNDATA_H_BASE_