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(NO_GCC_PRAGMA)
16 #pragma interface "paper.h"
21 #include "wx/cmndata.h"
23 #include "wx/hashmap.h"
26 * Paper type: see defs.h for wxPaperSize enum.
27 * A wxPrintPaperType can have an id and a name, or just a name and wxPAPER_NONE,
28 * so you can add further paper types without needing new ids.
32 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, platformId, name, w, h)
34 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h)
37 class WXDLLEXPORT wxPrintPaperType
: public wxObject
42 // platformId is a platform-specific id, such as in Windows, DMPAPER_...
43 wxPrintPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
45 inline wxString
GetName() const { return wxGetTranslation(m_paperName
); }
46 inline wxPaperSize
GetId() const { return m_paperId
; }
47 inline int GetPlatformId() const { return m_platformId
; }
49 // Get width and height in tenths of a millimetre
50 inline int GetWidth() const { return m_width
; }
51 inline int GetHeight() const { return m_height
; }
53 // Get size in tenths of a millimetre
54 inline wxSize
GetSize() const { return wxSize(m_width
, m_height
); }
56 // Get size in a millimetres
57 inline wxSize
GetSizeMM() const { return wxSize(m_width
/10, m_height
/10); }
59 // Get width and height in device units (1/72th of an inch)
60 wxSize
GetSizeDeviceUnits() const ;
63 wxPaperSize m_paperId
;
65 int m_width
; // In tenths of a millimetre
66 int m_height
; // In tenths of a millimetre
70 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
73 WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType
*, wxStringToPrintPaperTypeHashMap
);
75 class WXDLLEXPORT wxPrintPaperTypeList
;
77 class WXDLLEXPORT wxPrintPaperDatabase
80 wxPrintPaperDatabase();
81 ~wxPrintPaperDatabase();
83 void CreateDatabase();
86 void AddPaperType(wxPaperSize paperId
, const wxString
& name
, int w
, int h
);
87 void AddPaperType(wxPaperSize paperId
, int platformId
, const wxString
& name
, int w
, int h
);
90 wxPrintPaperType
*FindPaperType(const wxString
& name
);
93 wxPrintPaperType
*FindPaperType(wxPaperSize id
);
95 // Find by platform id
96 wxPrintPaperType
*FindPaperTypeByPlatformId(int id
);
99 wxPrintPaperType
*FindPaperType(const wxSize
& size
);
101 // Convert name to size id
102 wxPaperSize
ConvertNameToId(const wxString
& name
);
104 // Convert size id to name
105 wxString
ConvertIdToName(wxPaperSize paperId
);
107 // Get the paper size
108 wxSize
GetSize(wxPaperSize paperId
);
110 // Get the paper size
111 wxPaperSize
GetSize(const wxSize
& size
);
114 wxPrintPaperType
* Item(size_t index
) const;
115 size_t GetCount() const;
117 wxStringToPrintPaperTypeHashMap
* m_map
;
118 wxPrintPaperTypeList
* m_list
;
119 // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
122 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;