cmndata.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cmndata.h
  3. // Purpose: Common GDI data classes
  4. // Author: Julian Smart and others
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c)
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CMNDATA_H_BASE_
  11. #define _WX_CMNDATA_H_BASE_
  12. #include "wx/defs.h"
  13. #if wxUSE_PRINTING_ARCHITECTURE
  14. #include "wx/gdicmn.h"
  15. #if wxUSE_STREAMS
  16. #include "wx/stream.h"
  17. #endif
  18. class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
  19. /*
  20. * wxPrintData
  21. * Encapsulates printer information (not printer dialog information)
  22. */
  23. enum wxPrintBin
  24. {
  25. wxPRINTBIN_DEFAULT,
  26. wxPRINTBIN_ONLYONE,
  27. wxPRINTBIN_LOWER,
  28. wxPRINTBIN_MIDDLE,
  29. wxPRINTBIN_MANUAL,
  30. wxPRINTBIN_ENVELOPE,
  31. wxPRINTBIN_ENVMANUAL,
  32. wxPRINTBIN_AUTO,
  33. wxPRINTBIN_TRACTOR,
  34. wxPRINTBIN_SMALLFMT,
  35. wxPRINTBIN_LARGEFMT,
  36. wxPRINTBIN_LARGECAPACITY,
  37. wxPRINTBIN_CASSETTE,
  38. wxPRINTBIN_FORMSOURCE,
  39. wxPRINTBIN_USER
  40. };
  41. const int wxPRINTMEDIA_DEFAULT = 0;
  42. class WXDLLIMPEXP_CORE wxPrintData: public wxObject
  43. {
  44. public:
  45. wxPrintData();
  46. wxPrintData(const wxPrintData& printData);
  47. virtual ~wxPrintData();
  48. int GetNoCopies() const { return m_printNoCopies; }
  49. bool GetCollate() const { return m_printCollate; }
  50. wxPrintOrientation GetOrientation() const { return m_printOrientation; }
  51. bool IsOrientationReversed() const { return m_printOrientationReversed; }
  52. // Is this data OK for showing the print dialog?
  53. bool Ok() const { return IsOk(); }
  54. bool IsOk() const ;
  55. const wxString& GetPrinterName() const { return m_printerName; }
  56. bool GetColour() const { return m_colour; }
  57. wxDuplexMode GetDuplex() const { return m_duplexMode; }
  58. wxPaperSize GetPaperId() const { return m_paperId; }
  59. const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
  60. // in wxPageSetupDialogData
  61. wxPrintQuality GetQuality() const { return m_printQuality; }
  62. wxPrintBin GetBin() const { return m_bin; }
  63. wxPrintMode GetPrintMode() const { return m_printMode; }
  64. int GetMedia() const { return m_media; }
  65. void SetNoCopies(int v) { m_printNoCopies = v; }
  66. void SetCollate(bool flag) { m_printCollate = flag; }
  67. // Please use the overloaded method below
  68. wxDEPRECATED_INLINE(void SetOrientation(int orient),
  69. m_printOrientation = (wxPrintOrientation)orient; )
  70. void SetOrientation(wxPrintOrientation orient) { m_printOrientation = orient; }
  71. void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; }
  72. void SetPrinterName(const wxString& name) { m_printerName = name; }
  73. void SetColour(bool colour) { m_colour = colour; }
  74. void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
  75. void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
  76. void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
  77. void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
  78. void SetBin(wxPrintBin bin) { m_bin = bin; }
  79. void SetMedia(int media) { m_media = media; }
  80. void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
  81. wxString GetFilename() const { return m_filename; }
  82. void SetFilename( const wxString &filename ) { m_filename = filename; }
  83. wxPrintData& operator=(const wxPrintData& data);
  84. char* GetPrivData() const { return m_privData; }
  85. int GetPrivDataLen() const { return m_privDataLen; }
  86. void SetPrivData( char *privData, int len );
  87. // Convert between wxPrintData and native data
  88. void ConvertToNative();
  89. void ConvertFromNative();
  90. // Holds the native print data
  91. wxPrintNativeDataBase *GetNativeData() const { return m_nativeData; }
  92. private:
  93. wxPrintBin m_bin;
  94. int m_media;
  95. wxPrintMode m_printMode;
  96. int m_printNoCopies;
  97. wxPrintOrientation m_printOrientation;
  98. bool m_printOrientationReversed;
  99. bool m_printCollate;
  100. wxString m_printerName;
  101. bool m_colour;
  102. wxDuplexMode m_duplexMode;
  103. wxPrintQuality m_printQuality;
  104. wxPaperSize m_paperId;
  105. wxSize m_paperSize;
  106. wxString m_filename;
  107. char* m_privData;
  108. int m_privDataLen;
  109. wxPrintNativeDataBase *m_nativeData;
  110. private:
  111. DECLARE_DYNAMIC_CLASS(wxPrintData)
  112. };
  113. /*
  114. * wxPrintDialogData
  115. * Encapsulates information displayed and edited in the printer dialog box.
  116. * Contains a wxPrintData object which is filled in according to the values retrieved
  117. * from the dialog.
  118. */
  119. class WXDLLIMPEXP_CORE wxPrintDialogData: public wxObject
  120. {
  121. public:
  122. wxPrintDialogData();
  123. wxPrintDialogData(const wxPrintDialogData& dialogData);
  124. wxPrintDialogData(const wxPrintData& printData);
  125. virtual ~wxPrintDialogData();
  126. int GetFromPage() const { return m_printFromPage; }
  127. int GetToPage() const { return m_printToPage; }
  128. int GetMinPage() const { return m_printMinPage; }
  129. int GetMaxPage() const { return m_printMaxPage; }
  130. int GetNoCopies() const { return m_printNoCopies; }
  131. bool GetAllPages() const { return m_printAllPages; }
  132. bool GetSelection() const { return m_printSelection; }
  133. bool GetCollate() const { return m_printCollate; }
  134. bool GetPrintToFile() const { return m_printToFile; }
  135. void SetFromPage(int v) { m_printFromPage = v; }
  136. void SetToPage(int v) { m_printToPage = v; }
  137. void SetMinPage(int v) { m_printMinPage = v; }
  138. void SetMaxPage(int v) { m_printMaxPage = v; }
  139. void SetNoCopies(int v) { m_printNoCopies = v; }
  140. void SetAllPages(bool flag) { m_printAllPages = flag; }
  141. void SetSelection(bool flag) { m_printSelection = flag; }
  142. void SetCollate(bool flag) { m_printCollate = flag; }
  143. void SetPrintToFile(bool flag) { m_printToFile = flag; }
  144. void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }
  145. void EnableSelection(bool flag) { m_printEnableSelection = flag; }
  146. void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }
  147. void EnableHelp(bool flag) { m_printEnableHelp = flag; }
  148. bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; }
  149. bool GetEnableSelection() const { return m_printEnableSelection; }
  150. bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }
  151. bool GetEnableHelp() const { return m_printEnableHelp; }
  152. // Is this data OK for showing the print dialog?
  153. bool Ok() const { return IsOk(); }
  154. bool IsOk() const { return m_printData.IsOk() ; }
  155. wxPrintData& GetPrintData() { return m_printData; }
  156. void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
  157. void operator=(const wxPrintDialogData& data);
  158. void operator=(const wxPrintData& data); // Sets internal m_printData member
  159. private:
  160. int m_printFromPage;
  161. int m_printToPage;
  162. int m_printMinPage;
  163. int m_printMaxPage;
  164. int m_printNoCopies;
  165. bool m_printAllPages;
  166. bool m_printCollate;
  167. bool m_printToFile;
  168. bool m_printSelection;
  169. bool m_printEnableSelection;
  170. bool m_printEnablePageNumbers;
  171. bool m_printEnableHelp;
  172. bool m_printEnablePrintToFile;
  173. wxPrintData m_printData;
  174. private:
  175. DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
  176. };
  177. /*
  178. * This is the data used (and returned) by the wxPageSetupDialog.
  179. */
  180. // Compatibility with old name
  181. #define wxPageSetupData wxPageSetupDialogData
  182. class WXDLLIMPEXP_CORE wxPageSetupDialogData: public wxObject
  183. {
  184. public:
  185. wxPageSetupDialogData();
  186. wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
  187. wxPageSetupDialogData(const wxPrintData& printData);
  188. virtual ~wxPageSetupDialogData();
  189. wxSize GetPaperSize() const { return m_paperSize; }
  190. wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); }
  191. wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; }
  192. wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; }
  193. wxPoint GetMarginTopLeft() const { return m_marginTopLeft; }
  194. wxPoint GetMarginBottomRight() const { return m_marginBottomRight; }
  195. bool GetDefaultMinMargins() const { return m_defaultMinMargins; }
  196. bool GetEnableMargins() const { return m_enableMargins; }
  197. bool GetEnableOrientation() const { return m_enableOrientation; }
  198. bool GetEnablePaper() const { return m_enablePaper; }
  199. bool GetEnablePrinter() const { return m_enablePrinter; }
  200. bool GetDefaultInfo() const { return m_getDefaultInfo; }
  201. bool GetEnableHelp() const { return m_enableHelp; }
  202. // Is this data OK for showing the page setup dialog?
  203. bool Ok() const { return IsOk(); }
  204. bool IsOk() const { return m_printData.IsOk() ; }
  205. // If a corresponding paper type is found in the paper database, will set the m_printData
  206. // paper size id member as well.
  207. void SetPaperSize(const wxSize& sz);
  208. void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); }
  209. // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
  210. void SetPaperSize(wxPaperSize id);
  211. void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; }
  212. void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; }
  213. void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; }
  214. void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; }
  215. void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; }
  216. void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; }
  217. void EnableMargins(bool flag) { m_enableMargins = flag; }
  218. void EnableOrientation(bool flag) { m_enableOrientation = flag; }
  219. void EnablePaper(bool flag) { m_enablePaper = flag; }
  220. void EnablePrinter(bool flag) { m_enablePrinter = flag; }
  221. void EnableHelp(bool flag) { m_enableHelp = flag; }
  222. // Use paper size defined in this object to set the wxPrintData
  223. // paper id
  224. void CalculateIdFromPaperSize();
  225. // Use paper id in wxPrintData to set this object's paper size
  226. void CalculatePaperSizeFromId();
  227. wxPageSetupDialogData& operator=(const wxPageSetupDialogData& data);
  228. wxPageSetupDialogData& operator=(const wxPrintData& data);
  229. wxPrintData& GetPrintData() { return m_printData; }
  230. const wxPrintData& GetPrintData() const { return m_printData; }
  231. void SetPrintData(const wxPrintData& printData);
  232. private:
  233. wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
  234. wxPoint m_minMarginTopLeft;
  235. wxPoint m_minMarginBottomRight;
  236. wxPoint m_marginTopLeft;
  237. wxPoint m_marginBottomRight;
  238. bool m_defaultMinMargins;
  239. bool m_enableMargins;
  240. bool m_enableOrientation;
  241. bool m_enablePaper;
  242. bool m_enablePrinter;
  243. bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
  244. bool m_enableHelp;
  245. wxPrintData m_printData;
  246. private:
  247. DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
  248. };
  249. #endif // wxUSE_PRINTING_ARCHITECTURE
  250. #endif
  251. // _WX_CMNDATA_H_BASE_