1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Paper database types and classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/cmndata.h"
19 #include "wx/hashmap.h"
22 * Paper type: see defs.h for wxPaperSize enum.
23 * A wxPrintPaperType can have an id and a name, or just a name and wxPAPER_NONE,
24 * so you can add further paper types without needing new ids.
28 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, platformId, name, w, h)
30 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h)
33 class WXDLLEXPORT wxPrintPaperType
: public wxObject
38 // platformId is a platform-specific id, such as in Windows, DMPAPER_...
39 wxPrintPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
41 inline wxString
GetName() const { return wxGetTranslation(m_paperName
); }
42 inline wxPaperSize
GetId() const { return m_paperId
; }
43 inline int GetPlatformId() const { return m_platformId
; }
45 // Get width and height in tenths of a millimetre
46 inline int GetWidth() const { return m_width
; }
47 inline int GetHeight() const { return m_height
; }
49 // Get size in tenths of a millimetre
50 inline wxSize
GetSize() const { return wxSize(m_width
, m_height
); }
52 // Get size in a millimetres
53 inline wxSize
GetSizeMM() const { return wxSize(m_width
/10, m_height
/10); }
55 // Get width and height in device units (1/72th of an inch)
56 wxSize
GetSizeDeviceUnits() const ;
59 wxPaperSize m_paperId
;
61 int m_width
; // In tenths of a millimetre
62 int m_height
; // In tenths of a millimetre
66 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
69 WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType
*, wxStringToPrintPaperTypeHashMap
);
71 class WXDLLIMPEXP_FWD_CORE wxPrintPaperTypeList
;
73 class WXDLLEXPORT wxPrintPaperDatabase
76 wxPrintPaperDatabase();
77 ~wxPrintPaperDatabase();
79 void CreateDatabase();
82 void AddPaperType(wxPaperSize paperId
, const wxString
& name
, int w
, int h
);
83 void AddPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
86 wxPrintPaperType
*FindPaperType(const wxString
& name
);
89 wxPrintPaperType
*FindPaperType(wxPaperSize id
);
91 // Find by platform id
92 wxPrintPaperType
*FindPaperTypeByPlatformId(int id
);
95 wxPrintPaperType
*FindPaperType(const wxSize
& size
);
97 // Convert name to size id
98 wxPaperSize
ConvertNameToId(const wxString
& name
);
100 // Convert size id to name
101 wxString
ConvertIdToName(wxPaperSize paperId
);
103 // Get the paper size
104 wxSize
GetSize(wxPaperSize paperId
);
106 // Get the paper size
107 wxPaperSize
GetSize(const wxSize
& size
);
110 wxPrintPaperType
* Item(size_t index
) const;
111 size_t GetCount() const;
113 wxStringToPrintPaperTypeHashMap
* m_map
;
114 wxPrintPaperTypeList
* m_list
;
115 // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
118 extern WXDLLEXPORT_DATA(wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;