Commit | Line | Data |
---|---|---|
33d28952 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: paper.h | |
3 | // Purpose: Paper database types and classes | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
7e548f6b | 9 | // Licence: wxWindows licence |
33d28952 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_PAPERH__ | |
13 | #define _WX_PAPERH__ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
33d28952 JS |
16 | #pragma interface "paper.h" |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | #include "wx/event.h" | |
21 | #include "wx/cmndata.h" | |
f6bcfd97 | 22 | #include "wx/intl.h" |
bdcade0a | 23 | #include "wx/hashmap.h" |
33d28952 JS |
24 | |
25 | /* | |
26 | * Paper type: see defs.h for wxPaperSize enum. | |
9c110148 | 27 | * A wxPrintPaperType can have an id and a name, or just a name and wxPAPER_NONE, |
33d28952 JS |
28 | * so you can add further paper types without needing new ids. |
29 | */ | |
30 | ||
31 | #ifdef __WXMSW__ | |
32 | #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, platformId, name, w, h) | |
33 | #else | |
34 | #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h) | |
35 | #endif | |
36 | ||
37 | class WXDLLEXPORT wxPrintPaperType: public wxObject | |
38 | { | |
39 | public: | |
40 | wxPrintPaperType(); | |
41 | ||
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); | |
44 | ||
f6bcfd97 | 45 | inline wxString GetName() const { return wxGetTranslation(m_paperName); } |
33d28952 JS |
46 | inline wxPaperSize GetId() const { return m_paperId; } |
47 | inline int GetPlatformId() const { return m_platformId; } | |
48 | ||
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; } | |
52 | ||
53 | // Get size in tenths of a millimetre | |
54 | inline wxSize GetSize() const { return wxSize(m_width, m_height); } | |
55 | ||
56 | // Get size in a millimetres | |
57 | inline wxSize GetSizeMM() const { return wxSize(m_width/10, m_height/10); } | |
58 | ||
59 | // Get width and height in device units (1/72th of an inch) | |
60 | wxSize GetSizeDeviceUnits() const ; | |
61 | ||
62 | public: | |
63 | wxPaperSize m_paperId; | |
64 | int m_platformId; | |
65 | int m_width; // In tenths of a millimetre | |
66 | int m_height; // In tenths of a millimetre | |
67 | wxString m_paperName; | |
68 | ||
69 | private: | |
70 | DECLARE_DYNAMIC_CLASS(wxPrintPaperType) | |
71 | }; | |
72 | ||
bdcade0a MB |
73 | WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType*, wxStringToPrintPaperTypeHashMap); |
74 | ||
222ed1d6 MB |
75 | class WXDLLEXPORT wxPrintPaperTypeList; |
76 | ||
77 | class WXDLLEXPORT wxPrintPaperDatabase | |
33d28952 JS |
78 | { |
79 | public: | |
80 | wxPrintPaperDatabase(); | |
222ed1d6 | 81 | ~wxPrintPaperDatabase(); |
33d28952 JS |
82 | |
83 | void CreateDatabase(); | |
84 | void ClearDatabase(); | |
85 | ||
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); | |
88 | ||
89 | // Find by name | |
90 | wxPrintPaperType *FindPaperType(const wxString& name); | |
91 | ||
92 | // Find by size id | |
93 | wxPrintPaperType *FindPaperType(wxPaperSize id); | |
94 | ||
95 | // Find by platform id | |
96 | wxPrintPaperType *FindPaperTypeByPlatformId(int id); | |
97 | ||
98 | // Find by size | |
99 | wxPrintPaperType *FindPaperType(const wxSize& size); | |
100 | ||
101 | // Convert name to size id | |
102 | wxPaperSize ConvertNameToId(const wxString& name); | |
103 | ||
104 | // Convert size id to name | |
105 | wxString ConvertIdToName(wxPaperSize paperId); | |
106 | ||
107 | // Get the paper size | |
108 | wxSize GetSize(wxPaperSize paperId); | |
109 | ||
110 | // Get the paper size | |
111 | wxPaperSize GetSize(const wxSize& size); | |
112 | ||
222ed1d6 MB |
113 | // |
114 | wxPrintPaperType* Item(size_t index) const; | |
115 | size_t GetCount() const; | |
33d28952 | 116 | private: |
222ed1d6 MB |
117 | wxStringToPrintPaperTypeHashMap* m_map; |
118 | wxPrintPaperTypeList* m_list; | |
119 | // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase) | |
33d28952 JS |
120 | }; |
121 | ||
16cba29d | 122 | extern WXDLLEXPORT_DATA(wxPrintPaperDatabase*) wxThePrintPaperDatabase; |
33d28952 JS |
123 | |
124 | ||
125 | #endif | |
126 | // _WX_PAPERH__ |