paper.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/paper.h
  3. // Purpose: Paper database types and classes
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_PAPERH__
  11. #define _WX_PAPERH__
  12. #include "wx/defs.h"
  13. #include "wx/event.h"
  14. #include "wx/cmndata.h"
  15. #include "wx/intl.h"
  16. #include "wx/hashmap.h"
  17. /*
  18. * Paper type: see defs.h for wxPaperSize enum.
  19. * A wxPrintPaperType can have an id and a name, or just a name and wxPAPER_NONE,
  20. * so you can add further paper types without needing new ids.
  21. */
  22. #ifdef __WXMSW__
  23. #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, platformId, name, w, h)
  24. #else
  25. #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h)
  26. #endif
  27. class WXDLLIMPEXP_CORE wxPrintPaperType: public wxObject
  28. {
  29. public:
  30. wxPrintPaperType();
  31. // platformId is a platform-specific id, such as in Windows, DMPAPER_...
  32. wxPrintPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h);
  33. inline wxString GetName() const { return wxGetTranslation(m_paperName); }
  34. inline wxPaperSize GetId() const { return m_paperId; }
  35. inline int GetPlatformId() const { return m_platformId; }
  36. // Get width and height in tenths of a millimetre
  37. inline int GetWidth() const { return m_width; }
  38. inline int GetHeight() const { return m_height; }
  39. // Get size in tenths of a millimetre
  40. inline wxSize GetSize() const { return wxSize(m_width, m_height); }
  41. // Get size in a millimetres
  42. inline wxSize GetSizeMM() const { return wxSize(m_width/10, m_height/10); }
  43. // Get width and height in device units (1/72th of an inch)
  44. wxSize GetSizeDeviceUnits() const ;
  45. public:
  46. wxPaperSize m_paperId;
  47. int m_platformId;
  48. int m_width; // In tenths of a millimetre
  49. int m_height; // In tenths of a millimetre
  50. wxString m_paperName;
  51. private:
  52. DECLARE_DYNAMIC_CLASS(wxPrintPaperType)
  53. };
  54. WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType*, wxStringToPrintPaperTypeHashMap);
  55. class WXDLLIMPEXP_FWD_CORE wxPrintPaperTypeList;
  56. class WXDLLIMPEXP_CORE wxPrintPaperDatabase
  57. {
  58. public:
  59. wxPrintPaperDatabase();
  60. ~wxPrintPaperDatabase();
  61. void CreateDatabase();
  62. void ClearDatabase();
  63. void AddPaperType(wxPaperSize paperId, const wxString& name, int w, int h);
  64. void AddPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h);
  65. // Find by name
  66. wxPrintPaperType *FindPaperType(const wxString& name);
  67. // Find by size id
  68. wxPrintPaperType *FindPaperType(wxPaperSize id);
  69. // Find by platform id
  70. wxPrintPaperType *FindPaperTypeByPlatformId(int id);
  71. // Find by size
  72. wxPrintPaperType *FindPaperType(const wxSize& size);
  73. // Convert name to size id
  74. wxPaperSize ConvertNameToId(const wxString& name);
  75. // Convert size id to name
  76. wxString ConvertIdToName(wxPaperSize paperId);
  77. // Get the paper size
  78. wxSize GetSize(wxPaperSize paperId);
  79. // Get the paper size
  80. wxPaperSize GetSize(const wxSize& size);
  81. //
  82. wxPrintPaperType* Item(size_t index) const;
  83. size_t GetCount() const;
  84. private:
  85. wxStringToPrintPaperTypeHashMap* m_map;
  86. wxPrintPaperTypeList* m_list;
  87. // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
  88. };
  89. extern WXDLLIMPEXP_DATA_CORE(wxPrintPaperDatabase*) wxThePrintPaperDatabase;
  90. #endif
  91. // _WX_PAPERH__