1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Paper database types and classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "paper.h"
21 #include "wx/cmndata.h"
25 * Paper type: see defs.h for wxPaperSize enum.
26 * A wxPrintePaperType 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 wxPrintPaperDatabase
: public wxList
75 wxPrintPaperDatabase();
77 void CreateDatabase();
80 void AddPaperType(wxPaperSize paperId
, const wxString
& name
, int w
, int h
);
81 void AddPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
84 wxPrintPaperType
*FindPaperType(const wxString
& name
);
87 wxPrintPaperType
*FindPaperType(wxPaperSize id
);
89 // Find by platform id
90 wxPrintPaperType
*FindPaperTypeByPlatformId(int id
);
93 wxPrintPaperType
*FindPaperType(const wxSize
& size
);
95 // Convert name to size id
96 wxPaperSize
ConvertNameToId(const wxString
& name
);
98 // Convert size id to name
99 wxString
ConvertIdToName(wxPaperSize paperId
);
101 // Get the paper size
102 wxSize
GetSize(wxPaperSize paperId
);
104 // Get the paper size
105 wxPaperSize
GetSize(const wxSize
& size
);
108 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
111 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;