1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Paper database types and classes
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/cmndata.h"
18 #include "wx/hashmap.h"
21 * Paper type: see defs.h for wxPaperSize enum.
22 * A wxPrintPaperType can have an id and a name, or just a name and wxPAPER_NONE,
23 * so you can add further paper types without needing new ids.
27 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, platformId, name, w, h)
29 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h)
32 class WXDLLIMPEXP_CORE wxPrintPaperType
: public wxObject
37 // platformId is a platform-specific id, such as in Windows, DMPAPER_...
38 wxPrintPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
40 inline wxString
GetName() const { return wxGetTranslation(m_paperName
); }
41 inline wxPaperSize
GetId() const { return m_paperId
; }
42 inline int GetPlatformId() const { return m_platformId
; }
44 // Get width and height in tenths of a millimetre
45 inline int GetWidth() const { return m_width
; }
46 inline int GetHeight() const { return m_height
; }
48 // Get size in tenths of a millimetre
49 inline wxSize
GetSize() const { return wxSize(m_width
, m_height
); }
51 // Get size in a millimetres
52 inline wxSize
GetSizeMM() const { return wxSize(m_width
/10, m_height
/10); }
54 // Get width and height in device units (1/72th of an inch)
55 wxSize
GetSizeDeviceUnits() const ;
58 wxPaperSize m_paperId
;
60 int m_width
; // In tenths of a millimetre
61 int m_height
; // In tenths of a millimetre
65 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
68 WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType
*, wxStringToPrintPaperTypeHashMap
);
70 class WXDLLIMPEXP_FWD_CORE wxPrintPaperTypeList
;
72 class WXDLLIMPEXP_CORE wxPrintPaperDatabase
75 wxPrintPaperDatabase();
76 ~wxPrintPaperDatabase();
78 void CreateDatabase();
81 void AddPaperType(wxPaperSize paperId
, const wxString
& name
, int w
, int h
);
82 void AddPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
85 wxPrintPaperType
*FindPaperType(const wxString
& name
);
88 wxPrintPaperType
*FindPaperType(wxPaperSize id
);
90 // Find by platform id
91 wxPrintPaperType
*FindPaperTypeByPlatformId(int id
);
94 wxPrintPaperType
*FindPaperType(const wxSize
& size
);
96 // Convert name to size id
97 wxPaperSize
ConvertNameToId(const wxString
& name
);
99 // Convert size id to name
100 wxString
ConvertIdToName(wxPaperSize paperId
);
102 // Get the paper size
103 wxSize
GetSize(wxPaperSize paperId
);
105 // Get the paper size
106 wxPaperSize
GetSize(const wxSize
& size
);
109 wxPrintPaperType
* Item(size_t index
) const;
110 size_t GetCount() const;
112 wxStringToPrintPaperTypeHashMap
* m_map
;
113 wxPrintPaperTypeList
* m_list
;
114 // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
117 extern WXDLLIMPEXP_DATA_CORE(wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;