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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "cmndata.h"
19 #include "wx/window.h"
21 #include "wx/encinfo.h"
22 #include "wx/colour.h"
23 #include "wx/gdicmn.h"
25 class WXDLLEXPORT wxColourData
: public wxObject
29 wxColourData(const wxColourData
& data
);
32 void SetChooseFull(bool flag
) { m_chooseFull
= flag
; }
33 bool GetChooseFull() const { return m_chooseFull
; }
34 void SetColour(const wxColour
& colour
) { m_dataColour
= colour
; }
35 const wxColour
& GetColour() const { return m_dataColour
; }
36 wxColour
& GetColour() { return m_dataColour
; }
38 // Array of 16 custom colours
39 void SetCustomColour(int i
, const wxColour
& colour
);
40 wxColour
GetCustomColour(int i
);
42 void operator=(const wxColourData
& data
);
45 wxColour m_dataColour
;
46 wxColour m_custColours
[16];
50 DECLARE_DYNAMIC_CLASS(wxColourData
)
53 class WXDLLEXPORT wxFontData
: public wxObject
59 wxFontData(const wxFontData
& data
)
61 , m_fontColour(data
.m_fontColour
)
62 , m_showHelp(data
.m_showHelp
)
63 , m_allowSymbols(data
.m_allowSymbols
)
64 , m_enableEffects(data
.m_enableEffects
)
65 , m_initialFont(data
.m_initialFont
)
66 , m_chosenFont(data
.m_chosenFont
)
67 , m_minSize(data
.m_minSize
)
68 , m_maxSize(data
.m_maxSize
)
69 , m_encoding(data
.m_encoding
)
70 , m_encodingInfo(data
.m_encodingInfo
)
74 wxFontData
& operator=(const wxFontData
& data
)
76 wxObject::operator=(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 void SetAllowSymbols(bool flag
) { m_allowSymbols
= flag
; }
91 bool GetAllowSymbols() const { return m_allowSymbols
; }
93 void SetColour(const wxColour
& colour
) { m_fontColour
= colour
; }
94 wxColour
&GetColour() { return m_fontColour
; }
96 void SetShowHelp(bool flag
) { m_showHelp
= flag
; }
97 bool GetShowHelp() const { return m_showHelp
; }
99 void EnableEffects(bool flag
) { m_enableEffects
= flag
; }
100 bool GetEnableEffects() const { return m_enableEffects
; }
102 void SetInitialFont(const wxFont
& font
) { m_initialFont
= font
; }
103 wxFont
GetInitialFont() const { return m_initialFont
; }
105 void SetChosenFont(const wxFont
& font
) { m_chosenFont
= font
; }
106 wxFont
GetChosenFont() const { return m_chosenFont
; }
108 void SetRange(int minRange
, int maxRange
) { m_minSize
= minRange
; m_maxSize
= maxRange
; }
110 // encoding info is split into 2 parts: the logical wxWin encoding
111 // (wxFontEncoding) and a structure containing the native parameters for
112 // it (wxNativeEncodingInfo)
113 wxFontEncoding
GetEncoding() const { return m_encoding
; }
114 void SetEncoding(wxFontEncoding encoding
) { m_encoding
= encoding
; }
116 wxNativeEncodingInfo
& EncodingInfo() { return m_encodingInfo
; }
119 wxColour m_fontColour
;
122 bool m_enableEffects
;
123 wxFont m_initialFont
;
129 wxFontEncoding m_encoding
;
130 wxNativeEncodingInfo m_encodingInfo
;
133 DECLARE_DYNAMIC_CLASS(wxFontData
)
136 #if wxUSE_PRINTING_ARCHITECTURE
139 * Encapsulates printer information (not printer dialog information)
144 class wxNativePrintData
;
148 class WXDLLEXPORT wxPrintData
: public wxObject
152 wxPrintData(const wxPrintData
& printData
);
155 int GetNoCopies() const { return m_printNoCopies
; };
156 bool GetCollate() const { return m_printCollate
; };
157 int GetOrientation() const { return m_printOrientation
; };
159 // Is this data OK for showing the print dialog?
162 const wxString
& GetPrinterName() const { return m_printerName
; }
163 bool GetColour() const { return m_colour
; }
164 wxDuplexMode
GetDuplex() const { return m_duplexMode
; }
165 wxPaperSize
GetPaperId() const { return m_paperId
; }
166 const wxSize
& GetPaperSize() const { return m_paperSize
; } // Not used yet: confusable with paper size
167 // in wxPageSetupDialogData
168 wxPrintQuality
GetQuality() const { return m_printQuality
; }
170 void SetNoCopies(int v
) { m_printNoCopies
= v
; };
171 void SetCollate(bool flag
) { m_printCollate
= flag
; };
172 void SetOrientation(int orient
) { m_printOrientation
= orient
; };
174 void SetPrinterName(const wxString
& name
) { m_printerName
= name
; }
175 void SetColour(bool colour
) { m_colour
= colour
; }
176 void SetDuplex(wxDuplexMode duplex
) { m_duplexMode
= duplex
; }
177 void SetPaperId(wxPaperSize sizeId
) { m_paperId
= sizeId
; }
178 void SetPaperSize(const wxSize
& sz
) { m_paperSize
= sz
; }
179 void SetQuality(wxPrintQuality quality
) { m_printQuality
= quality
; }
181 // PostScript-specific data
182 const wxString
& GetPrinterCommand() const { return m_printerCommand
; }
183 const wxString
& GetPrinterOptions() const { return m_printerOptions
; }
184 const wxString
& GetPreviewCommand() const { return m_previewCommand
; }
185 const wxString
& GetFilename() const { return m_filename
; }
186 const wxString
& GetFontMetricPath() const { return m_afmPath
; }
187 double GetPrinterScaleX() const { return m_printerScaleX
; }
188 double GetPrinterScaleY() const { return m_printerScaleY
; }
189 long GetPrinterTranslateX() const { return m_printerTranslateX
; }
190 long GetPrinterTranslateY() const { return m_printerTranslateY
; }
191 wxPrintMode
GetPrintMode() const { return m_printMode
; }
193 void SetPrinterCommand(const wxString
& command
) { m_printerCommand
= command
; }
194 void SetPrinterOptions(const wxString
& options
) { m_printerOptions
= options
; }
195 void SetPreviewCommand(const wxString
& command
) { m_previewCommand
= command
; }
196 void SetFilename(const wxString
& filename
) { m_filename
= filename
; }
197 void SetFontMetricPath(const wxString
& path
) { m_afmPath
= path
; }
198 void SetPrinterScaleX(double x
) { m_printerScaleX
= x
; }
199 void SetPrinterScaleY(double y
) { m_printerScaleY
= y
; }
200 void SetPrinterScaling(double x
, double y
) { m_printerScaleX
= x
; m_printerScaleY
= y
; }
201 void SetPrinterTranslateX(long x
) { m_printerTranslateX
= x
; }
202 void SetPrinterTranslateY(long y
) { m_printerTranslateY
= y
; }
203 void SetPrinterTranslation(long x
, long y
) { m_printerTranslateX
= x
; m_printerTranslateY
= y
; }
204 void SetPrintMode(wxPrintMode printMode
) { m_printMode
= printMode
; }
206 void operator=(const wxPrintData
& data
);
208 #if defined(__WXMSW__)
209 // Convert to/from the DEVMODE structure
210 void ConvertToNative();
211 void ConvertFromNative();
212 void* GetNativeData() const { return m_devMode
; }
213 void SetNativeData(void* data
) { m_devMode
= data
; }
214 void* GetNativeDataDevNames() const { return m_devNames
; }
215 void SetNativeDataDevNames(void* data
) { m_devNames
= data
; }
216 #elif defined(__WXMAC__)
217 void ConvertToNative();
218 void ConvertFromNative();
222 #if defined(__WXMSW__)
225 #elif defined(__WXMAC__)
226 wxNativePrintData
* m_nativePrintData
;
232 int m_printOrientation
;
235 // New members, 24/3/99
236 wxString m_printerName
;
238 wxDuplexMode m_duplexMode
;
239 wxPrintQuality m_printQuality
;
240 wxPaperSize m_paperId
;
243 // PostScript-specific data
244 wxString m_printerCommand
;
245 wxString m_previewCommand
;
246 wxString m_printerOptions
;
249 double m_printerScaleX
;
250 double m_printerScaleY
;
251 long m_printerTranslateX
;
252 long m_printerTranslateY
;
253 wxPrintMode m_printMode
;
256 DECLARE_DYNAMIC_CLASS(wxPrintData
)
261 * Encapsulates information displayed and edited in the printer dialog box.
262 * Contains a wxPrintData object which is filled in according to the values retrieved
266 class WXDLLEXPORT wxPrintDialogData
: public wxObject
270 wxPrintDialogData(const wxPrintDialogData
& dialogData
);
271 wxPrintDialogData(const wxPrintData
& printData
);
272 ~wxPrintDialogData();
274 int GetFromPage() const { return m_printFromPage
; };
275 int GetToPage() const { return m_printToPage
; };
276 int GetMinPage() const { return m_printMinPage
; };
277 int GetMaxPage() const { return m_printMaxPage
; };
278 int GetNoCopies() const { return m_printNoCopies
; };
279 bool GetAllPages() const { return m_printAllPages
; };
280 bool GetSelection() const { return m_printSelection
; };
281 bool GetCollate() const { return m_printCollate
; };
282 bool GetPrintToFile() const { return m_printToFile
; };
283 bool GetSetupDialog() const { return m_printSetupDialog
; };
285 void SetFromPage(int v
) { m_printFromPage
= v
; };
286 void SetToPage(int v
) { m_printToPage
= v
; };
287 void SetMinPage(int v
) { m_printMinPage
= v
; };
288 void SetMaxPage(int v
) { m_printMaxPage
= v
; };
289 void SetNoCopies(int v
) { m_printNoCopies
= v
; };
290 void SetAllPages(bool flag
) { m_printAllPages
= flag
; };
291 void SetSelection(bool flag
) { m_printSelection
= flag
; };
292 void SetCollate(bool flag
) { m_printCollate
= flag
; };
293 void SetPrintToFile(bool flag
) { m_printToFile
= flag
; };
294 void SetSetupDialog(bool flag
) { m_printSetupDialog
= flag
; };
296 void EnablePrintToFile(bool flag
) { m_printEnablePrintToFile
= flag
; };
297 void EnableSelection(bool flag
) { m_printEnableSelection
= flag
; };
298 void EnablePageNumbers(bool flag
) { m_printEnablePageNumbers
= flag
; };
299 void EnableHelp(bool flag
) { m_printEnableHelp
= flag
; };
301 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile
; };
302 bool GetEnableSelection() const { return m_printEnableSelection
; };
303 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers
; };
304 bool GetEnableHelp() const { return m_printEnableHelp
; };
306 // Is this data OK for showing the print dialog?
307 bool Ok() const { return m_printData
.Ok() ; }
309 wxPrintData
& GetPrintData() { return m_printData
; }
310 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
312 void operator=(const wxPrintDialogData
& data
);
313 void operator=(const wxPrintData
& data
); // Sets internal m_printData member
316 // Convert to/from the PRINTDLG structure
317 void ConvertToNative();
318 void ConvertFromNative();
319 void SetOwnerWindow(wxWindow
* win
);
320 void* GetNativeData() const { return m_printDlgData
; }
321 #elif defined(__WXMAC__)
322 void ConvertToNative();
323 void ConvertFromNative();
327 void* m_printDlgData
;
336 bool m_printAllPages
;
339 bool m_printSelection
;
340 bool m_printEnableSelection
;
341 bool m_printEnablePageNumbers
;
342 bool m_printEnableHelp
;
343 bool m_printEnablePrintToFile
;
344 bool m_printSetupDialog
;
345 wxPrintData m_printData
;
348 DECLARE_DYNAMIC_CLASS(wxPrintDialogData
)
352 * This is the data used (and returned) by the wxPageSetupDialog.
355 // Compatibility with old name
356 #define wxPageSetupData wxPageSetupDialogData
358 class WXDLLEXPORT wxPageSetupDialogData
: public wxObject
361 wxPageSetupDialogData();
362 wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
);
363 wxPageSetupDialogData(const wxPrintData
& printData
);
364 ~wxPageSetupDialogData();
366 wxSize
GetPaperSize() const { return m_paperSize
; };
367 wxPaperSize
GetPaperId() const { return m_printData
.GetPaperId(); };
368 wxPoint
GetMinMarginTopLeft() const { return m_minMarginTopLeft
; };
369 wxPoint
GetMinMarginBottomRight() const { return m_minMarginBottomRight
; };
370 wxPoint
GetMarginTopLeft() const { return m_marginTopLeft
; };
371 wxPoint
GetMarginBottomRight() const { return m_marginBottomRight
; };
373 bool GetDefaultMinMargins() const { return m_defaultMinMargins
; };
374 bool GetEnableMargins() const { return m_enableMargins
; };
375 bool GetEnableOrientation() const { return m_enableOrientation
; };
376 bool GetEnablePaper() const { return m_enablePaper
; };
377 bool GetEnablePrinter() const { return m_enablePrinter
; };
378 bool GetDefaultInfo() const { return m_getDefaultInfo
; };
379 bool GetEnableHelp() const { return m_enableHelp
; };
381 // Is this data OK for showing the page setup dialog?
382 bool Ok() const { return m_printData
.Ok() ; }
384 // If a corresponding paper type is found in the paper database, will set the m_printData
385 // paper size id member as well.
386 void SetPaperSize(const wxSize
& sz
);
388 void SetPaperId(wxPaperSize id
) { m_printData
.SetPaperId(id
); };
390 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
391 void SetPaperSize(wxPaperSize id
);
393 void SetMinMarginTopLeft(const wxPoint
& pt
) { m_minMarginTopLeft
= pt
; };
394 void SetMinMarginBottomRight(const wxPoint
& pt
) { m_minMarginBottomRight
= pt
; };
395 void SetMarginTopLeft(const wxPoint
& pt
) { m_marginTopLeft
= pt
; };
396 void SetMarginBottomRight(const wxPoint
& pt
) { m_marginBottomRight
= pt
; };
397 void SetDefaultMinMargins(bool flag
) { m_defaultMinMargins
= flag
; };
398 void SetDefaultInfo(bool flag
) { m_getDefaultInfo
= flag
; };
400 void EnableMargins(bool flag
) { m_enableMargins
= flag
; };
401 void EnableOrientation(bool flag
) { m_enableOrientation
= flag
; };
402 void EnablePaper(bool flag
) { m_enablePaper
= flag
; };
403 void EnablePrinter(bool flag
) { m_enablePrinter
= flag
; };
404 void EnableHelp(bool flag
) { m_enableHelp
= flag
; };
406 #if defined(__WIN95__)
407 // Convert to/from the PAGESETUPDLG structure
408 void ConvertToNative();
409 void ConvertFromNative();
410 void SetOwnerWindow(wxWindow
* win
);
411 void* GetNativeData() const { return m_pageSetupData
; }
412 #elif defined(__WXMAC__)
413 void ConvertToNative();
414 void ConvertFromNative();
417 // Use paper size defined in this object to set the wxPrintData
419 void CalculateIdFromPaperSize();
421 // Use paper id in wxPrintData to set this object's paper size
422 void CalculatePaperSizeFromId();
424 wxPageSetupDialogData
& operator=(const wxPageSetupData
& data
);
425 wxPageSetupDialogData
& operator=(const wxPrintData
& data
);
427 wxPrintData
& GetPrintData() { return m_printData
; }
428 void SetPrintData(const wxPrintData
& printData
) { m_printData
= printData
; }
430 #if defined(__WIN95__)
431 void* m_pageSetupData
;
435 wxSize m_paperSize
; // The dimensions selected by the user (on return, same as in wxPrintData?)
436 wxPoint m_minMarginTopLeft
;
437 wxPoint m_minMarginBottomRight
;
438 wxPoint m_marginTopLeft
;
439 wxPoint m_marginBottomRight
;
440 bool m_defaultMinMargins
;
441 bool m_enableMargins
;
442 bool m_enableOrientation
;
444 bool m_enablePrinter
;
445 bool m_getDefaultInfo
; // Equiv. to PSD_RETURNDEFAULT
447 wxPrintData m_printData
;
450 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData
)
453 #endif // wxUSE_PRINTING_ARCHITECTURE
456 // _WX_CMNDATA_H_BASE_