1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Paper database types and classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "paper.h"
21 #include "wx/cmndata.h"
25 * Paper type: see defs.h for wxPaperSize enum.
26 * A wxPrintPaperType can have an id and a name, or just a name and wxPAPER_NONE,
27 * so you can add further paper types without needing new ids.
31 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, platformId, name, w, h)
33 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h)
36 class WXDLLEXPORT wxPrintPaperType
: public wxObject
41 // platformId is a platform-specific id, such as in Windows, DMPAPER_...
42 wxPrintPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
44 inline wxString
GetName() const { return wxGetTranslation(m_paperName
); }
45 inline wxPaperSize
GetId() const { return m_paperId
; }
46 inline int GetPlatformId() const { return m_platformId
; }
48 // Get width and height in tenths of a millimetre
49 inline int GetWidth() const { return m_width
; }
50 inline int GetHeight() const { return m_height
; }
52 // Get size in tenths of a millimetre
53 inline wxSize
GetSize() const { return wxSize(m_width
, m_height
); }
55 // Get size in a millimetres
56 inline wxSize
GetSizeMM() const { return wxSize(m_width
/10, m_height
/10); }
58 // Get width and height in device units (1/72th of an inch)
59 wxSize
GetSizeDeviceUnits() const ;
62 wxPaperSize m_paperId
;
64 int m_width
; // In tenths of a millimetre
65 int m_height
; // In tenths of a millimetre
69 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
72 class WXDLLEXPORT wxStringToPrintPaperTypeHashMap
;
73 class WXDLLEXPORT wxPrintPaperTypeList
;
75 class WXDLLEXPORT wxPrintPaperDatabase
78 wxPrintPaperDatabase();
79 ~wxPrintPaperDatabase();
81 void CreateDatabase();
84 void AddPaperType(wxPaperSize paperId
, const wxString
& name
, int w
, int h
);
85 void AddPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
88 wxPrintPaperType
*FindPaperType(const wxString
& name
);
91 wxPrintPaperType
*FindPaperType(wxPaperSize id
);
93 // Find by platform id
94 wxPrintPaperType
*FindPaperTypeByPlatformId(int id
);
97 wxPrintPaperType
*FindPaperType(const wxSize
& size
);
99 // Convert name to size id
100 wxPaperSize
ConvertNameToId(const wxString
& name
);
102 // Convert size id to name
103 wxString
ConvertIdToName(wxPaperSize paperId
);
105 // Get the paper size
106 wxSize
GetSize(wxPaperSize paperId
);
108 // Get the paper size
109 wxPaperSize
GetSize(const wxSize
& size
);
112 wxPrintPaperType
* Item(size_t index
) const;
113 size_t GetCount() const;
115 wxStringToPrintPaperTypeHashMap
* m_map
;
116 wxPrintPaperTypeList
* m_list
;
117 // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
120 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;