]>
Commit | Line | Data |
---|---|---|
33d28952 | 1 | ///////////////////////////////////////////////////////////////////////////// |
8898456d | 2 | // Name: src/common/paper.cpp |
33d28952 | 3 | // Purpose: Paper size classes |
7e548f6b | 4 | // Author: Julian Smart |
33d28952 JS |
5 | // Modified by: |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
7e548f6b | 9 | // Licence: wxWindows licence |
33d28952 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
33d28952 JS |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
8898456d | 16 | #pragma hdrstop |
33d28952 JS |
17 | #endif |
18 | ||
93d38175 VS |
19 | #if wxUSE_PRINTING_ARCHITECTURE |
20 | ||
33d28952 | 21 | #ifndef WX_PRECOMP |
57bd4c60 WS |
22 | #if defined(__WXMSW__) |
23 | #include "wx/msw/wrapcdlg.h" | |
24 | #endif // MSW | |
8898456d WS |
25 | #include "wx/utils.h" |
26 | #include "wx/settings.h" | |
27 | #include "wx/intl.h" | |
02761f6c | 28 | #include "wx/module.h" |
33d28952 JS |
29 | #endif |
30 | ||
31 | #include "wx/paper.h" | |
33d28952 JS |
32 | |
33 | #include <stdlib.h> | |
34 | #include <string.h> | |
35 | ||
36 | #ifdef __WXMSW__ | |
660296aa WS |
37 | #ifndef __WIN32__ |
38 | #include <print.h> | |
39 | #endif | |
33d28952 JS |
40 | #endif |
41 | // End __WXMSW__ | |
42 | ||
33d28952 | 43 | IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject) |
222ed1d6 | 44 | // IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList) |
33d28952 JS |
45 | |
46 | /* | |
47 | * Paper size database for all platforms | |
48 | */ | |
49 | ||
50 | wxPrintPaperType::wxPrintPaperType() | |
51 | { | |
52 | m_paperId = wxPAPER_NONE; | |
53 | m_platformId = 0; | |
525d8583 | 54 | m_paperName = wxEmptyString; |
33d28952 JS |
55 | m_width = 0; |
56 | m_height = 0; | |
57 | } | |
58 | ||
59 | wxPrintPaperType::wxPrintPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h) | |
60 | { | |
61 | m_paperId = paperId; | |
62 | m_platformId = platformId; | |
63 | m_paperName = name; | |
64 | m_width = w; | |
65 | m_height = h; | |
66 | } | |
67 | ||
68 | // Get width and height in points (1/72th of an inch) | |
69 | wxSize wxPrintPaperType::GetSizeDeviceUnits() const | |
70 | { | |
71 | return wxSize( (int) ((m_width / 10.0) / (25.4 / 72.0)), (int) ((m_height / 10.0) / (25.4 / 72.0)) ); | |
72 | } | |
73 | ||
74 | /* | |
75 | * Print paper database for PostScript | |
76 | */ | |
77 | ||
222ed1d6 | 78 | WX_DECLARE_LIST(wxPrintPaperType, wxPrintPaperTypeList); |
c54b92d3 | 79 | #include "wx/listimpl.cpp" |
259c43f6 | 80 | WX_DEFINE_LIST(wxPrintPaperTypeList) |
222ed1d6 | 81 | |
d3b9f782 | 82 | wxPrintPaperDatabase* wxThePrintPaperDatabase = NULL; |
33d28952 | 83 | |
222ed1d6 MB |
84 | wxPrintPaperDatabase::wxPrintPaperDatabase() |
85 | { | |
86 | m_map = new wxStringToPrintPaperTypeHashMap; | |
87 | m_list = new wxPrintPaperTypeList; | |
88 | } | |
89 | ||
90 | wxPrintPaperDatabase::~wxPrintPaperDatabase() | |
33d28952 | 91 | { |
222ed1d6 | 92 | ClearDatabase(); |
33d28952 JS |
93 | } |
94 | ||
95 | void wxPrintPaperDatabase::CreateDatabase() | |
96 | { | |
f6bcfd97 BP |
97 | WXADDPAPER(wxPAPER_LETTER, DMPAPER_LETTER, wxTRANSLATE("Letter, 8 1/2 x 11 in"), 2159, 2794); |
98 | WXADDPAPER(wxPAPER_LEGAL, DMPAPER_LEGAL, wxTRANSLATE("Legal, 8 1/2 x 14 in"), 2159, 3556); | |
99 | WXADDPAPER(wxPAPER_A4, DMPAPER_A4, wxTRANSLATE("A4 sheet, 210 x 297 mm"), 2100, 2970); | |
100 | WXADDPAPER(wxPAPER_CSHEET, DMPAPER_CSHEET, wxTRANSLATE("C sheet, 17 x 22 in"), 4318, 5588); | |
101 | WXADDPAPER(wxPAPER_DSHEET, DMPAPER_DSHEET, wxTRANSLATE("D sheet, 22 x 34 in"), 5588, 8636); | |
102 | WXADDPAPER(wxPAPER_ESHEET, DMPAPER_ESHEET, wxTRANSLATE("E sheet, 34 x 44 in"), 8636, 11176); | |
103 | WXADDPAPER(wxPAPER_LETTERSMALL, DMPAPER_LETTERSMALL, wxTRANSLATE("Letter Small, 8 1/2 x 11 in"), 2159, 2794); | |
104 | WXADDPAPER(wxPAPER_TABLOID, DMPAPER_TABLOID, wxTRANSLATE("Tabloid, 11 x 17 in"), 2794, 4318); | |
105 | WXADDPAPER(wxPAPER_LEDGER, DMPAPER_LEDGER, wxTRANSLATE("Ledger, 17 x 11 in"), 4318, 2794); | |
106 | WXADDPAPER(wxPAPER_STATEMENT, DMPAPER_STATEMENT, wxTRANSLATE("Statement, 5 1/2 x 8 1/2 in"), 1397, 2159); | |
107 | WXADDPAPER(wxPAPER_EXECUTIVE, DMPAPER_EXECUTIVE, wxTRANSLATE("Executive, 7 1/4 x 10 1/2 in"), 1842, 2667); | |
108 | WXADDPAPER(wxPAPER_A3, DMPAPER_A3, wxTRANSLATE("A3 sheet, 297 x 420 mm"), 2970, 4200); | |
109 | WXADDPAPER(wxPAPER_A4SMALL, DMPAPER_A4SMALL, wxTRANSLATE("A4 small sheet, 210 x 297 mm"), 2100, 2970); | |
110 | WXADDPAPER(wxPAPER_A5, DMPAPER_A5, wxTRANSLATE("A5 sheet, 148 x 210 mm"), 1480, 2100); | |
111 | WXADDPAPER(wxPAPER_B4, DMPAPER_B4, wxTRANSLATE("B4 sheet, 250 x 354 mm"), 2500, 3540); | |
112 | WXADDPAPER(wxPAPER_B5, DMPAPER_B5, wxTRANSLATE("B5 sheet, 182 x 257 millimeter"), 1820, 2570); | |
113 | WXADDPAPER(wxPAPER_FOLIO, DMPAPER_FOLIO, wxTRANSLATE("Folio, 8 1/2 x 13 in"), 2159, 3302); | |
114 | WXADDPAPER(wxPAPER_QUARTO, DMPAPER_QUARTO, wxTRANSLATE("Quarto, 215 x 275 mm"), 2150, 2750); | |
115 | WXADDPAPER(wxPAPER_10X14, DMPAPER_10X14, wxTRANSLATE("10 x 14 in"), 2540, 3556); | |
116 | WXADDPAPER(wxPAPER_11X17, DMPAPER_11X17, wxTRANSLATE("11 x 17 in"), 2794, 4318); | |
117 | WXADDPAPER(wxPAPER_NOTE, DMPAPER_NOTE, wxTRANSLATE("Note, 8 1/2 x 11 in"), 2159, 2794); | |
118 | WXADDPAPER(wxPAPER_ENV_9, DMPAPER_ENV_9, wxTRANSLATE("#9 Envelope, 3 7/8 x 8 7/8 in"), 984, 2254); | |
119 | WXADDPAPER(wxPAPER_ENV_10, DMPAPER_ENV_10, wxTRANSLATE("#10 Envelope, 4 1/8 x 9 1/2 in"), 1048, 2413); | |
120 | WXADDPAPER(wxPAPER_ENV_11, DMPAPER_ENV_11, wxTRANSLATE("#11 Envelope, 4 1/2 x 10 3/8 in"), 1143, 2635); | |
121 | WXADDPAPER(wxPAPER_ENV_12, DMPAPER_ENV_12, wxTRANSLATE("#12 Envelope, 4 3/4 x 11 in"), 1206, 2794); | |
122 | WXADDPAPER(wxPAPER_ENV_14, DMPAPER_ENV_14, wxTRANSLATE("#14 Envelope, 5 x 11 1/2 in"), 1270, 2921); | |
123 | WXADDPAPER(wxPAPER_ENV_DL, DMPAPER_ENV_DL, wxTRANSLATE("DL Envelope, 110 x 220 mm"), 1100, 2200); | |
124 | WXADDPAPER(wxPAPER_ENV_C5, DMPAPER_ENV_C5, wxTRANSLATE("C5 Envelope, 162 x 229 mm"), 1620, 2290); | |
125 | WXADDPAPER(wxPAPER_ENV_C3, DMPAPER_ENV_C3, wxTRANSLATE("C3 Envelope, 324 x 458 mm"), 3240, 4580); | |
126 | WXADDPAPER(wxPAPER_ENV_C4, DMPAPER_ENV_C4, wxTRANSLATE("C4 Envelope, 229 x 324 mm"), 2290, 3240); | |
127 | WXADDPAPER(wxPAPER_ENV_C6, DMPAPER_ENV_C6, wxTRANSLATE("C6 Envelope, 114 x 162 mm"), 1140, 1620); | |
128 | WXADDPAPER(wxPAPER_ENV_C65, DMPAPER_ENV_C65, wxTRANSLATE("C65 Envelope, 114 x 229 mm"), 1140, 2290); | |
129 | WXADDPAPER(wxPAPER_ENV_B4, DMPAPER_ENV_B4, wxTRANSLATE("B4 Envelope, 250 x 353 mm"), 2500, 3530); | |
130 | WXADDPAPER(wxPAPER_ENV_B5, DMPAPER_ENV_B5, wxTRANSLATE("B5 Envelope, 176 x 250 mm"), 1760, 2500); | |
131 | WXADDPAPER(wxPAPER_ENV_B6, DMPAPER_ENV_B6, wxTRANSLATE("B6 Envelope, 176 x 125 mm"), 1760, 1250); | |
132 | WXADDPAPER(wxPAPER_ENV_ITALY, DMPAPER_ENV_ITALY, wxTRANSLATE("Italy Envelope, 110 x 230 mm"), 1100, 2300); | |
133 | WXADDPAPER(wxPAPER_ENV_MONARCH, DMPAPER_ENV_MONARCH, wxTRANSLATE("Monarch Envelope, 3 7/8 x 7 1/2 in"), 984, 1905); | |
134 | WXADDPAPER(wxPAPER_ENV_PERSONAL, DMPAPER_ENV_PERSONAL, wxTRANSLATE("6 3/4 Envelope, 3 5/8 x 6 1/2 in"), 921, 1651); | |
135 | WXADDPAPER(wxPAPER_FANFOLD_US, DMPAPER_FANFOLD_US, wxTRANSLATE("US Std Fanfold, 14 7/8 x 11 in"), 3778, 2794); | |
136 | WXADDPAPER(wxPAPER_FANFOLD_STD_GERMAN, DMPAPER_FANFOLD_STD_GERMAN, wxTRANSLATE("German Std Fanfold, 8 1/2 x 12 in"), 2159, 3048); | |
137 | WXADDPAPER(wxPAPER_FANFOLD_LGL_GERMAN, DMPAPER_FANFOLD_LGL_GERMAN, wxTRANSLATE("German Legal Fanfold, 8 1/2 x 13 in"), 2159, 3302); | |
33d28952 | 138 | |
21c358b2 JS |
139 | WXADDPAPER(wxPAPER_ISO_B4, DMPAPER_ISO_B4, wxTRANSLATE("B4 (ISO) 250 x 353 mm"), 2500, 2530); |
140 | WXADDPAPER(wxPAPER_JAPANESE_POSTCARD, DMPAPER_JAPANESE_POSTCARD, wxTRANSLATE("Japanese Postcard 100 x 148 mm"), 1000, 1480); | |
141 | WXADDPAPER(wxPAPER_9X11, DMPAPER_9X11, wxTRANSLATE("9 x 11 in"), 2286, 2794); | |
142 | WXADDPAPER(wxPAPER_10X11, DMPAPER_10X11, wxTRANSLATE("10 x 11 in"), 2540, 2794); | |
143 | WXADDPAPER(wxPAPER_15X11, DMPAPER_15X11, wxTRANSLATE("15 x 11 in"), 3810, 2794); | |
144 | WXADDPAPER(wxPAPER_ENV_INVITE, DMPAPER_ENV_INVITE, wxTRANSLATE("Envelope Invite 220 x 220 mm"), 2200, 2200); | |
145 | WXADDPAPER(wxPAPER_LETTER_EXTRA, DMPAPER_LETTER_EXTRA, wxTRANSLATE("Letter Extra 9 1/2 x 12 in"), 2413, 3048); | |
146 | WXADDPAPER(wxPAPER_LEGAL_EXTRA, DMPAPER_LEGAL_EXTRA, wxTRANSLATE("Legal Extra 9 1/2 x 15 in"), 2413, 3810); | |
147 | WXADDPAPER(wxPAPER_TABLOID_EXTRA, DMPAPER_TABLOID_EXTRA, wxTRANSLATE("Tabloid Extra 11.69 x 18 in"), 2969, 4572); | |
148 | WXADDPAPER(wxPAPER_A4_EXTRA, DMPAPER_A4_EXTRA, wxTRANSLATE("A4 Extra 9.27 x 12.69 in"), 2355, 3223); | |
149 | WXADDPAPER(wxPAPER_LETTER_TRANSVERSE, DMPAPER_LETTER_TRANSVERSE, wxTRANSLATE("Letter Transverse 8 1/2 x 11 in"), 2159, 2794); | |
150 | WXADDPAPER(wxPAPER_A4_TRANSVERSE, DMPAPER_A4_TRANSVERSE, wxTRANSLATE("A4 Transverse 210 x 297 mm"), 2100, 2970); | |
151 | WXADDPAPER(wxPAPER_LETTER_EXTRA_TRANSVERSE, DMPAPER_LETTER_EXTRA_TRANSVERSE, wxTRANSLATE("Letter Extra Transverse 9.275 x 12 in"), 2355, 3048); | |
152 | WXADDPAPER(wxPAPER_A_PLUS, DMPAPER_A_PLUS, wxTRANSLATE("SuperA/SuperA/A4 227 x 356 mm"), 2270, 3560); | |
153 | WXADDPAPER(wxPAPER_B_PLUS, DMPAPER_B_PLUS, wxTRANSLATE("SuperB/SuperB/A3 305 x 487 mm"), 3050, 4870); | |
154 | WXADDPAPER(wxPAPER_LETTER_PLUS, DMPAPER_LETTER_PLUS, wxTRANSLATE("Letter Plus 8 1/2 x 12.69 in"), 2159, 3223); | |
155 | WXADDPAPER(wxPAPER_A4_PLUS, DMPAPER_A4_PLUS, wxTRANSLATE("A4 Plus 210 x 330 mm"), 2100, 3300); | |
156 | WXADDPAPER(wxPAPER_A5_TRANSVERSE, DMPAPER_A5_TRANSVERSE, wxTRANSLATE("A5 Transverse 148 x 210 mm"), 1480, 2100); | |
157 | WXADDPAPER(wxPAPER_B5_TRANSVERSE, DMPAPER_B5_TRANSVERSE, wxTRANSLATE("B5 (JIS) Transverse 182 x 257 mm"), 1820, 2570); | |
158 | WXADDPAPER(wxPAPER_A3_EXTRA, DMPAPER_A3_EXTRA, wxTRANSLATE("A3 Extra 322 x 445 mm"), 3220, 4450); | |
159 | WXADDPAPER(wxPAPER_A5_EXTRA, DMPAPER_A5_EXTRA, wxTRANSLATE("A5 Extra 174 x 235 mm"), 1740, 2350); | |
160 | WXADDPAPER(wxPAPER_B5_EXTRA, DMPAPER_B5_EXTRA, wxTRANSLATE("B5 (ISO) Extra 201 x 276 mm"), 2010, 2760); | |
161 | WXADDPAPER(wxPAPER_A2, DMPAPER_A2, wxTRANSLATE("A2 420 x 594 mm"), 4200, 5940); | |
162 | WXADDPAPER(wxPAPER_A3_TRANSVERSE, DMPAPER_A3_TRANSVERSE, wxTRANSLATE("A3 Transverse 297 x 420 mm"), 2970, 4200); | |
163 | WXADDPAPER(wxPAPER_A3_EXTRA_TRANSVERSE,DMPAPER_A3_EXTRA_TRANSVERSE,wxTRANSLATE("A3 Extra Transverse 322 x 445 mm"), 3220, 4450); | |
8898456d | 164 | |
21c358b2 JS |
165 | WXADDPAPER(wxPAPER_DBL_JAPANESE_POSTCARD, 69, wxTRANSLATE("Japanese Double Postcard 200 x 148 mm"), 2000, 1480); |
166 | WXADDPAPER(wxPAPER_A6, 70, wxTRANSLATE("A6 105 x 148 mm"), 1050, 1480); | |
167 | WXADDPAPER(wxPAPER_JENV_KAKU2, 71, wxTRANSLATE("Japanese Envelope Kaku #2"), 2400, 3320); | |
168 | WXADDPAPER(wxPAPER_JENV_KAKU3, 72, wxTRANSLATE("Japanese Envelope Kaku #3"), 2160, 2770); | |
169 | WXADDPAPER(wxPAPER_JENV_CHOU3, 73, wxTRANSLATE("Japanese Envelope Chou #3"), 1200, 2350); | |
170 | WXADDPAPER(wxPAPER_JENV_CHOU4, 74, wxTRANSLATE("Japanese Envelope Chou #4"), 900, 2050); | |
171 | WXADDPAPER(wxPAPER_LETTER_ROTATED, 75, wxTRANSLATE("Letter Rotated 11 x 8 1/2 in"), 2794, 2159); | |
172 | WXADDPAPER(wxPAPER_A3_ROTATED, 76, wxTRANSLATE("A3 Rotated 420 x 297 mm"), 4200, 2970); | |
173 | WXADDPAPER(wxPAPER_A4_ROTATED, 77, wxTRANSLATE("A4 Rotated 297 x 210 mm"), 2970, 2100); | |
174 | WXADDPAPER(wxPAPER_A5_ROTATED, 78, wxTRANSLATE("A5 Rotated 210 x 148 mm"), 2100, 1480); | |
175 | WXADDPAPER(wxPAPER_B4_JIS_ROTATED, 79, wxTRANSLATE("B4 (JIS) Rotated 364 x 257 mm"), 3640, 2570); | |
176 | WXADDPAPER(wxPAPER_B5_JIS_ROTATED, 80, wxTRANSLATE("B5 (JIS) Rotated 257 x 182 mm"), 2570, 1820); | |
177 | WXADDPAPER(wxPAPER_JAPANESE_POSTCARD_ROTATED, 81, wxTRANSLATE("Japanese Postcard Rotated 148 x 100 mm"), 1480, 1000); | |
178 | WXADDPAPER(wxPAPER_DBL_JAPANESE_POSTCARD_ROTATED, 82, wxTRANSLATE("Double Japanese Postcard Rotated 148 x 200 mm"), 1480, 2000); | |
179 | WXADDPAPER(wxPAPER_A6_ROTATED, 83, wxTRANSLATE("A6 Rotated 148 x 105 mm"), 1480, 1050); | |
180 | WXADDPAPER(wxPAPER_JENV_KAKU2_ROTATED, 84, wxTRANSLATE("Japanese Envelope Kaku #2 Rotated"), 3320, 2400); | |
181 | WXADDPAPER(wxPAPER_JENV_KAKU3_ROTATED, 85, wxTRANSLATE("Japanese Envelope Kaku #3 Rotated"), 2770, 2160); | |
182 | WXADDPAPER(wxPAPER_JENV_CHOU3_ROTATED, 86, wxTRANSLATE("Japanese Envelope Chou #3 Rotated"), 2350, 1200); | |
183 | WXADDPAPER(wxPAPER_JENV_CHOU4_ROTATED, 87, wxTRANSLATE("Japanese Envelope Chou #4 Rotated"), 2050, 900); | |
184 | WXADDPAPER(wxPAPER_B6_JIS, 88, wxTRANSLATE("B6 (JIS) 128 x 182 mm"), 1280, 1820); | |
185 | WXADDPAPER(wxPAPER_B6_JIS_ROTATED, 89, wxTRANSLATE("B6 (JIS) Rotated 182 x 128 mm"), 1920, 1280); | |
186 | WXADDPAPER(wxPAPER_12X11, 90, wxTRANSLATE("12 x 11 in"), 3048, 2794); | |
187 | WXADDPAPER(wxPAPER_JENV_YOU4, 91, wxTRANSLATE("Japanese Envelope You #4"), 2350, 1050); | |
188 | WXADDPAPER(wxPAPER_JENV_YOU4_ROTATED, 92, wxTRANSLATE("Japanese Envelope You #4 Rotated"), 1050, 2350); | |
189 | WXADDPAPER(wxPAPER_P16K, 93, wxTRANSLATE("PRC 16K 146 x 215 mm"), 1460, 2150); | |
190 | WXADDPAPER(wxPAPER_P32K, 94, wxTRANSLATE("PRC 32K 97 x 151 mm"), 970, 1510); | |
191 | WXADDPAPER(wxPAPER_P32KBIG, 95, wxTRANSLATE("PRC 32K(Big) 97 x 151 mm"), 970, 1510); | |
192 | WXADDPAPER(wxPAPER_PENV_1, 96, wxTRANSLATE("PRC Envelope #1 102 x 165 mm"), 1020, 1650); | |
193 | WXADDPAPER(wxPAPER_PENV_2, 97, wxTRANSLATE("PRC Envelope #2 102 x 176 mm"), 1020, 1760); | |
194 | WXADDPAPER(wxPAPER_PENV_3, 98, wxTRANSLATE("PRC Envelope #3 125 x 176 mm"), 1250, 1760); | |
195 | WXADDPAPER(wxPAPER_PENV_4, 99, wxTRANSLATE("PRC Envelope #4 110 x 208 mm"), 1100, 2080); | |
196 | WXADDPAPER(wxPAPER_PENV_5, 100, wxTRANSLATE("PRC Envelope #5 110 x 220 mm"), 1100, 2200); | |
197 | WXADDPAPER(wxPAPER_PENV_6, 101, wxTRANSLATE("PRC Envelope #6 120 x 230 mm"), 1200, 2300); | |
198 | WXADDPAPER(wxPAPER_PENV_7, 102, wxTRANSLATE("PRC Envelope #7 160 x 230 mm"), 1600, 2300); | |
199 | WXADDPAPER(wxPAPER_PENV_8, 103, wxTRANSLATE("PRC Envelope #8 120 x 309 mm"), 1200, 3090); | |
200 | WXADDPAPER(wxPAPER_PENV_9, 104, wxTRANSLATE("PRC Envelope #9 229 x 324 mm"), 2290, 3240); | |
201 | WXADDPAPER(wxPAPER_PENV_10, 105, wxTRANSLATE("PRC Envelope #10 324 x 458 mm"), 3240, 4580); | |
202 | WXADDPAPER(wxPAPER_P16K_ROTATED, 106, wxTRANSLATE("PRC 16K Rotated"), 2150, 1460); | |
203 | WXADDPAPER(wxPAPER_P32K_ROTATED, 107, wxTRANSLATE("PRC 32K Rotated"), 1510, 970); | |
204 | WXADDPAPER(wxPAPER_P32KBIG_ROTATED, 108, wxTRANSLATE("PRC 32K(Big) Rotated"), 1510, 970); | |
205 | WXADDPAPER(wxPAPER_PENV_1_ROTATED, 109, wxTRANSLATE("PRC Envelope #1 Rotated 165 x 102 mm"), 1650, 1020); | |
206 | WXADDPAPER(wxPAPER_PENV_2_ROTATED, 110, wxTRANSLATE("PRC Envelope #2 Rotated 176 x 102 mm"), 1760, 1020); | |
207 | WXADDPAPER(wxPAPER_PENV_3_ROTATED, 111, wxTRANSLATE("PRC Envelope #3 Rotated 176 x 125 mm"), 1760, 1250); | |
208 | WXADDPAPER(wxPAPER_PENV_4_ROTATED, 112, wxTRANSLATE("PRC Envelope #4 Rotated 208 x 110 mm"), 2080, 1100); | |
209 | WXADDPAPER(wxPAPER_PENV_5_ROTATED, 113, wxTRANSLATE("PRC Envelope #5 Rotated 220 x 110 mm"), 2200, 1100); | |
210 | WXADDPAPER(wxPAPER_PENV_6_ROTATED, 114, wxTRANSLATE("PRC Envelope #6 Rotated 230 x 120 mm"), 2300, 1200); | |
211 | WXADDPAPER(wxPAPER_PENV_7_ROTATED, 115, wxTRANSLATE("PRC Envelope #7 Rotated 230 x 160 mm"), 2300, 1600); | |
212 | WXADDPAPER(wxPAPER_PENV_8_ROTATED, 116, wxTRANSLATE("PRC Envelope #8 Rotated 309 x 120 mm"), 3090, 1200); | |
213 | WXADDPAPER(wxPAPER_PENV_9_ROTATED, 117, wxTRANSLATE("PRC Envelope #9 Rotated 324 x 229 mm"), 3240, 2290); | |
8a5434c1 | 214 | WXADDPAPER(wxPAPER_PENV_10_ROTATED, 118, wxTRANSLATE("PRC Envelope #10 Rotated 458 x 324 mm"), 4580, 3240); |
33d28952 JS |
215 | } |
216 | ||
217 | void wxPrintPaperDatabase::ClearDatabase() | |
218 | { | |
222ed1d6 MB |
219 | delete m_list; |
220 | WX_CLEAR_HASH_MAP(wxStringToPrintPaperTypeHashMap, *m_map); | |
221 | delete m_map; | |
33d28952 JS |
222 | } |
223 | ||
224 | void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, const wxString& name, int w, int h) | |
225 | { | |
222ed1d6 MB |
226 | wxPrintPaperType* tmp = new wxPrintPaperType(paperId, 0, name, w, h); |
227 | (*m_map)[name] = tmp; | |
228 | m_list->push_back(tmp); | |
33d28952 JS |
229 | } |
230 | ||
231 | void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h) | |
232 | { | |
222ed1d6 MB |
233 | wxPrintPaperType* tmp = new wxPrintPaperType(paperId, platformId, name, w, h); |
234 | (*m_map)[name] = tmp; | |
235 | m_list->push_back(tmp); | |
33d28952 JS |
236 | } |
237 | ||
238 | wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxString& name) | |
239 | { | |
222ed1d6 MB |
240 | wxStringToPrintPaperTypeHashMap::iterator it = m_map->find(name); |
241 | if (it != m_map->end()) | |
242 | return it->second; | |
33d28952 | 243 | else |
222ed1d6 | 244 | return NULL; |
33d28952 JS |
245 | } |
246 | ||
247 | wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(wxPaperSize id) | |
248 | { | |
17547f0f JS |
249 | typedef wxStringToPrintPaperTypeHashMap::iterator iterator; |
250 | ||
251 | for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it) | |
33d28952 | 252 | { |
17547f0f JS |
253 | wxPrintPaperType* paperType = it->second; |
254 | if (paperType->GetId() == id) | |
33d28952 | 255 | return paperType; |
33d28952 | 256 | } |
222ed1d6 MB |
257 | |
258 | return NULL; | |
33d28952 JS |
259 | } |
260 | ||
261 | wxPrintPaperType *wxPrintPaperDatabase::FindPaperTypeByPlatformId(int id) | |
262 | { | |
222ed1d6 MB |
263 | typedef wxStringToPrintPaperTypeHashMap::iterator iterator; |
264 | ||
265 | for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it) | |
33d28952 | 266 | { |
222ed1d6 | 267 | wxPrintPaperType* paperType = it->second; |
33d28952 JS |
268 | if (paperType->GetPlatformId() == id) |
269 | return paperType; | |
33d28952 | 270 | } |
222ed1d6 MB |
271 | |
272 | return NULL; | |
33d28952 JS |
273 | } |
274 | ||
275 | wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxSize& sz) | |
276 | { | |
17547f0f JS |
277 | // Take the item ordering into account so that the more common types |
278 | // are likely to be taken into account first. This fixes problems with, | |
279 | // for example, Letter reverting to A4 in the page setup dialog because | |
280 | // it was wrongly translated to Note. | |
281 | for ( size_t i = 0; i < GetCount(); i++ ) | |
33d28952 | 282 | { |
17547f0f JS |
283 | wxPrintPaperType* const paperType = Item(i); |
284 | const wxSize paperSize = paperType->GetSize() ; | |
285 | if ( abs(paperSize.x - sz.x) < 10 && abs(paperSize.y - sz.y) < 10 ) | |
33d28952 | 286 | return paperType; |
33d28952 | 287 | } |
222ed1d6 MB |
288 | |
289 | return NULL; | |
33d28952 JS |
290 | } |
291 | ||
292 | // Convert name to size id | |
293 | wxPaperSize wxPrintPaperDatabase::ConvertNameToId(const wxString& name) | |
294 | { | |
295 | wxPrintPaperType* type = FindPaperType(name); | |
296 | if (type) | |
297 | return type->GetId(); | |
298 | else | |
299 | return wxPAPER_NONE; | |
300 | } | |
301 | ||
302 | // Convert size id to name | |
303 | wxString wxPrintPaperDatabase::ConvertIdToName(wxPaperSize paperId) | |
304 | { | |
305 | wxPrintPaperType* type = FindPaperType(paperId); | |
306 | if (type) | |
307 | return type->GetName(); | |
308 | else | |
309 | return wxEmptyString; | |
310 | } | |
311 | ||
312 | // Get the paper size | |
313 | wxSize wxPrintPaperDatabase::GetSize(wxPaperSize paperId) | |
314 | { | |
315 | wxPrintPaperType* type = FindPaperType(paperId); | |
316 | if (type) | |
317 | return type->GetSize(); | |
318 | else | |
c47addef | 319 | return wxSize(0,0); |
33d28952 JS |
320 | } |
321 | ||
322 | // Get the paper size | |
323 | wxPaperSize wxPrintPaperDatabase::GetSize(const wxSize& size) | |
324 | { | |
325 | wxPrintPaperType* type = FindPaperType(size); | |
326 | if (type) | |
327 | return type->GetId(); | |
328 | else | |
329 | return wxPAPER_NONE; | |
330 | } | |
331 | ||
222ed1d6 MB |
332 | // QUICK and DIRTY |
333 | size_t wxPrintPaperDatabase::GetCount() const | |
334 | { | |
335 | return m_list->GetCount(); | |
336 | } | |
337 | ||
338 | wxPrintPaperType* wxPrintPaperDatabase::Item(size_t index) const | |
339 | { | |
340 | return m_list->Item(index)->GetData(); | |
341 | } | |
342 | ||
33d28952 JS |
343 | // A module to allow initialization/cleanup of print paper |
344 | // things without calling these functions from app.cpp. | |
345 | ||
346 | class WXDLLEXPORT wxPrintPaperModule: public wxModule | |
347 | { | |
348 | DECLARE_DYNAMIC_CLASS(wxPrintPaperModule) | |
349 | public: | |
350 | wxPrintPaperModule() {} | |
351 | bool OnInit(); | |
352 | void OnExit(); | |
353 | }; | |
354 | ||
355 | IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperModule, wxModule) | |
356 | ||
357 | /* | |
358 | * Initialization/cleanup module | |
359 | */ | |
360 | ||
361 | bool wxPrintPaperModule::OnInit() | |
362 | { | |
363 | wxThePrintPaperDatabase = new wxPrintPaperDatabase; | |
364 | wxThePrintPaperDatabase->CreateDatabase(); | |
365 | ||
7e548f6b | 366 | return true; |
33d28952 JS |
367 | } |
368 | ||
369 | void wxPrintPaperModule::OnExit() | |
370 | { | |
371 | delete wxThePrintPaperDatabase; | |
372 | wxThePrintPaperDatabase = NULL; | |
373 | } | |
374 | ||
93d38175 | 375 | #endif // wxUSE_PRINTING_ARCHITECTURE |