]>
Commit | Line | Data |
---|---|---|
ff910433 | 1 | ///////////////////////////////////////////////////////////////////////////// |
389076f1 | 2 | // Name: src/gtk/gnome/gprint.cpp |
f85b45fb RR |
3 | // Author: Robert Roebling |
4 | // Purpose: Implement GNOME printing support | |
5 | // Created: 09/20/04 | |
389076f1 | 6 | // RCS-ID: $Id$ |
f85b45fb RR |
7 | // Copyright: Robert Roebling |
8 | // Licence: wxWindows Licence | |
ff910433 RR |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
ff910433 RR |
11 | // For compilers that support precompilation, includes "wx/wx.h". |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
7c72311f RR |
18 | #if wxUSE_LIBGNOMEPRINT |
19 | ||
09a09455 PC |
20 | #include "wx/gtk/gnome/gprint.h" |
21 | ||
e4db172a WS |
22 | #ifndef WX_PRECOMP |
23 | #include "wx/log.h" | |
f38924e8 | 24 | #include "wx/dcmemory.h" |
923d28da | 25 | #include "wx/icon.h" |
18680f86 | 26 | #include "wx/math.h" |
bceff574 | 27 | #include "wx/image.h" |
02761f6c | 28 | #include "wx/module.h" |
e4db172a WS |
29 | #endif |
30 | ||
ff910433 | 31 | #include "wx/fontutil.h" |
ff910433 | 32 | #include "wx/gtk/private.h" |
c6efd6e0 | 33 | #include "wx/dynlib.h" |
459dbfc0 | 34 | #include "wx/paper.h" |
ff910433 RR |
35 | |
36 | #include <libgnomeprint/gnome-print.h> | |
37 | #include <libgnomeprint/gnome-print-pango.h> | |
06cfd325 | 38 | #include <libgnomeprint/gnome-print-config.h> |
ff910433 | 39 | #include <libgnomeprintui/gnome-print-dialog.h> |
0be7709e | 40 | #include <libgnomeprintui/gnome-print-job-preview.h> |
08680429 | 41 | #include <libgnomeprintui/gnome-print-paper-selector.h> |
ff910433 | 42 | |
09a09455 PC |
43 | #include "wx/link.h" |
44 | wxFORCE_LINK_THIS_MODULE(gnome_print) | |
d6c6acd6 | 45 | |
c6efd6e0 RR |
46 | //---------------------------------------------------------------------------- |
47 | // wxGnomePrintLibrary | |
48 | //---------------------------------------------------------------------------- | |
49 | ||
c6efd6e0 RR |
50 | class wxGnomePrintLibrary |
51 | { | |
52 | public: | |
53 | wxGnomePrintLibrary(); | |
54 | ~wxGnomePrintLibrary(); | |
389076f1 | 55 | |
c6efd6e0 | 56 | bool IsOk(); |
6950be01 | 57 | private: |
ced3df77 | 58 | bool InitializeMethods(); |
389076f1 | 59 | |
ced3df77 VZ |
60 | wxDynamicLibrary m_libGnomePrint; |
61 | wxDynamicLibrary m_libGnomePrintUI; | |
62 | ||
63 | // only true if we successfully loaded both libraries | |
64 | // | |
65 | // don't rename this field, it's used by wxDL_XXX macros internally | |
66 | bool m_ok; | |
c6efd6e0 RR |
67 | |
68 | public: | |
389076f1 | 69 | wxDL_METHOD_DEFINE( gint, gnome_print_newpath, |
c6efd6e0 | 70 | (GnomePrintContext *pc), (pc), 0 ) |
389076f1 | 71 | wxDL_METHOD_DEFINE( gint, gnome_print_moveto, |
c6efd6e0 | 72 | (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) |
389076f1 | 73 | wxDL_METHOD_DEFINE( gint, gnome_print_lineto, |
c6efd6e0 | 74 | (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) |
389076f1 | 75 | wxDL_METHOD_DEFINE( gint, gnome_print_arcto, |
16744532 | 76 | (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction ), (pc, x, y, radius, angle1, angle2, direction), 0 ) |
389076f1 | 77 | wxDL_METHOD_DEFINE( gint, gnome_print_curveto, |
c6efd6e0 | 78 | (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3), (pc, x1, y1, x2, y2, x3, y3), 0 ) |
389076f1 | 79 | wxDL_METHOD_DEFINE( gint, gnome_print_closepath, |
c6efd6e0 | 80 | (GnomePrintContext *pc), (pc), 0 ) |
389076f1 | 81 | wxDL_METHOD_DEFINE( gint, gnome_print_stroke, |
c6efd6e0 | 82 | (GnomePrintContext *pc), (pc), 0 ) |
389076f1 | 83 | wxDL_METHOD_DEFINE( gint, gnome_print_fill, |
c6efd6e0 | 84 | (GnomePrintContext *pc), (pc), 0 ) |
389076f1 | 85 | wxDL_METHOD_DEFINE( gint, gnome_print_setrgbcolor, |
c6efd6e0 | 86 | (GnomePrintContext *pc, gdouble r, gdouble g, gdouble b), (pc, r, g, b), 0 ) |
389076f1 | 87 | wxDL_METHOD_DEFINE( gint, gnome_print_setlinewidth, |
c6efd6e0 | 88 | (GnomePrintContext *pc, gdouble width), (pc, width), 0 ) |
59c73be8 RR |
89 | wxDL_METHOD_DEFINE( gint, gnome_print_setdash, |
90 | (GnomePrintContext *pc, gint n_values, const gdouble *values, gdouble offset), (pc, n_values, values, offset), 0 ) | |
91 | ||
92 | wxDL_METHOD_DEFINE( gint, gnome_print_rgbimage, | |
93 | (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 ) | |
94 | wxDL_METHOD_DEFINE( gint, gnome_print_rgbaimage, | |
95 | (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 ) | |
389076f1 | 96 | |
59c73be8 RR |
97 | wxDL_METHOD_DEFINE( gint, gnome_print_concat, |
98 | (GnomePrintContext *pc, const gdouble *matrix), (pc, matrix), 0 ) | |
99 | wxDL_METHOD_DEFINE( gint, gnome_print_scale, | |
100 | (GnomePrintContext *pc, gdouble sx, gdouble sy), (pc, sx, sy), 0 ) | |
101 | wxDL_METHOD_DEFINE( gint, gnome_print_rotate, | |
102 | (GnomePrintContext *pc, gdouble theta), (pc, theta), 0 ) | |
16744532 RR |
103 | wxDL_METHOD_DEFINE( gint, gnome_print_translate, |
104 | (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) | |
59c73be8 RR |
105 | |
106 | wxDL_METHOD_DEFINE( gint, gnome_print_gsave, | |
107 | (GnomePrintContext *pc), (pc), 0 ) | |
108 | wxDL_METHOD_DEFINE( gint, gnome_print_grestore, | |
109 | (GnomePrintContext *pc), (pc), 0 ) | |
389076f1 | 110 | |
3b7ab6bd RR |
111 | wxDL_METHOD_DEFINE( gint, gnome_print_clip, |
112 | (GnomePrintContext *pc), (pc), 0 ) | |
113 | wxDL_METHOD_DEFINE( gint, gnome_print_eoclip, | |
114 | (GnomePrintContext *pc), (pc), 0 ) | |
115 | ||
59c73be8 RR |
116 | wxDL_METHOD_DEFINE( gint, gnome_print_beginpage, |
117 | (GnomePrintContext *pc, const guchar* name), (pc, name), 0 ) | |
118 | wxDL_METHOD_DEFINE( gint, gnome_print_showpage, | |
119 | (GnomePrintContext *pc), (pc), 0 ) | |
120 | wxDL_METHOD_DEFINE( gint, gnome_print_end_doc, | |
121 | (GnomePrintContext *pc), (pc), 0 ) | |
389076f1 | 122 | |
59c73be8 RR |
123 | wxDL_METHOD_DEFINE( PangoLayout*, gnome_print_pango_create_layout, |
124 | (GnomePrintContext *gpc), (gpc), NULL ) | |
32f34982 RR |
125 | wxDL_VOIDMETHOD_DEFINE( gnome_print_pango_layout, |
126 | (GnomePrintContext *gpc, PangoLayout *layout), (gpc, layout) ) | |
389076f1 | 127 | |
59c73be8 RR |
128 | wxDL_METHOD_DEFINE( GnomePrintJob*, gnome_print_job_new, |
129 | (GnomePrintConfig *config), (config), NULL ) | |
130 | wxDL_METHOD_DEFINE( GnomePrintContext*, gnome_print_job_get_context, | |
131 | (GnomePrintJob *job), (job), NULL ) | |
132 | wxDL_METHOD_DEFINE( gint, gnome_print_job_close, | |
133 | (GnomePrintJob *job), (job), 0 ) | |
134 | wxDL_METHOD_DEFINE( gint, gnome_print_job_print, | |
135 | (GnomePrintJob *job), (job), 0 ) | |
136 | wxDL_METHOD_DEFINE( gboolean, gnome_print_job_get_page_size, | |
137 | (GnomePrintJob *job, gdouble *width, gdouble *height), (job, width, height), 0 ) | |
138 | ||
139 | wxDL_METHOD_DEFINE( GnomePrintUnit*, gnome_print_unit_get_by_abbreviation, | |
140 | (const guchar *abbreviation), (abbreviation), NULL ) | |
141 | wxDL_METHOD_DEFINE( gboolean, gnome_print_convert_distance, | |
142 | (gdouble *distance, const GnomePrintUnit *from, const GnomePrintUnit *to), (distance, from, to), false ) | |
143 | ||
144 | wxDL_METHOD_DEFINE( GnomePrintConfig*, gnome_print_config_default, | |
145 | (void), (), NULL ) | |
146 | wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set, | |
147 | (GnomePrintConfig *config, const guchar *key, const guchar *value), (config, key, value), false ) | |
3b7ab6bd RR |
148 | wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_double, |
149 | (GnomePrintConfig *config, const guchar *key, gdouble value), (config, key, value), false ) | |
150 | wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_int, | |
151 | (GnomePrintConfig *config, const guchar *key, gint value), (config, key, value), false ) | |
152 | wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_boolean, | |
153 | (GnomePrintConfig *config, const guchar *key, gboolean value), (config, key, value), false ) | |
154 | wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set_length, | |
155 | (GnomePrintConfig *config, const guchar *key, gdouble value, const GnomePrintUnit *unit), (config, key, value, unit), false ) | |
156 | ||
157 | wxDL_METHOD_DEFINE( guchar*, gnome_print_config_get, | |
158 | (GnomePrintConfig *config, const guchar *key), (config, key), NULL ) | |
59c73be8 RR |
159 | wxDL_METHOD_DEFINE( gboolean, gnome_print_config_get_length, |
160 | (GnomePrintConfig *config, const guchar *key, gdouble *val, const GnomePrintUnit **unit), (config, key, val, unit), false ) | |
b0d7707b RR |
161 | wxDL_METHOD_DEFINE( gboolean, gnome_print_config_get_boolean, |
162 | (GnomePrintConfig *config, const guchar *key, gboolean *val), (config, key, val), false ) | |
59c73be8 | 163 | |
389076f1 | 164 | wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_dialog_new, |
59c73be8 | 165 | (GnomePrintJob *gpj, const guchar *title, gint flags), (gpj, title, flags), NULL ) |
32f34982 | 166 | wxDL_VOIDMETHOD_DEFINE( gnome_print_dialog_construct_range_page, |
59c73be8 RR |
167 | (GnomePrintDialog *gpd, gint flags, gint start, gint end, |
168 | const guchar *currentlabel, const guchar *rangelabel), | |
32f34982 RR |
169 | (gpd, flags, start, end, currentlabel, rangelabel) ) |
170 | wxDL_VOIDMETHOD_DEFINE( gnome_print_dialog_get_copies, | |
171 | (GnomePrintDialog *gpd, gint *copies, gboolean *collate), (gpd, copies, collate) ) | |
172 | wxDL_VOIDMETHOD_DEFINE( gnome_print_dialog_set_copies, | |
173 | (GnomePrintDialog *gpd, gint copies, gint collate), (gpd, copies, collate) ) | |
59c73be8 RR |
174 | wxDL_METHOD_DEFINE( GnomePrintRangeType, gnome_print_dialog_get_range, |
175 | (GnomePrintDialog *gpd), (gpd), GNOME_PRINT_RANGETYPE_NONE ) | |
176 | wxDL_METHOD_DEFINE( int, gnome_print_dialog_get_range_page, | |
177 | (GnomePrintDialog *gpd, gint *start, gint *end), (gpd, start, end), 0 ) | |
389076f1 | 178 | |
59c73be8 RR |
179 | wxDL_METHOD_DEFINE( GtkWidget*, gnome_paper_selector_new_with_flags, |
180 | (GnomePrintConfig *config, gint flags), (config, flags), NULL ) | |
181 | ||
182 | wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_job_preview_new, | |
183 | (GnomePrintJob *gpm, const guchar *title), (gpm, title), NULL ) | |
7d7e4ed0 PC |
184 | |
185 | DECLARE_NO_COPY_CLASS(wxGnomePrintLibrary) | |
c6efd6e0 RR |
186 | }; |
187 | ||
188 | wxGnomePrintLibrary::wxGnomePrintLibrary() | |
189 | { | |
190 | wxLogNull log; | |
389076f1 | 191 | |
ced3df77 VZ |
192 | m_libGnomePrint.Load("libgnomeprint-2-2.so.0"); |
193 | m_ok = m_libGnomePrint.IsLoaded(); | |
194 | if ( !m_ok ) | |
195 | return; | |
389076f1 | 196 | |
ced3df77 | 197 | m_libGnomePrintUI.Load("libgnomeprintui-2-2.so.0"); |
32f34982 | 198 | m_ok = m_libGnomePrintUI.IsLoaded(); |
ced3df77 VZ |
199 | if ( !m_ok ) |
200 | { | |
201 | m_libGnomePrint.Unload(); | |
202 | return; | |
203 | } | |
389076f1 | 204 | |
ced3df77 | 205 | m_ok = InitializeMethods(); |
c6efd6e0 RR |
206 | } |
207 | ||
208 | wxGnomePrintLibrary::~wxGnomePrintLibrary() | |
209 | { | |
c6efd6e0 RR |
210 | } |
211 | ||
212 | bool wxGnomePrintLibrary::IsOk() | |
213 | { | |
214 | return m_ok; | |
215 | } | |
216 | ||
ced3df77 VZ |
217 | bool wxGnomePrintLibrary::InitializeMethods() |
218 | { | |
6950be01 RR |
219 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_newpath ); |
220 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_moveto ); | |
221 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_lineto ); | |
222 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_curveto ); | |
223 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_arcto ); | |
224 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_closepath ); | |
225 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_stroke ); | |
226 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_fill ); | |
227 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_setrgbcolor ); | |
228 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_setlinewidth ); | |
229 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_setdash ); | |
230 | ||
231 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_rgbimage ); | |
232 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_rgbaimage ); | |
233 | ||
234 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_concat ); | |
235 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_scale ); | |
236 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_rotate ); | |
237 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_translate ); | |
238 | ||
239 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_gsave ); | |
240 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_grestore ); | |
241 | ||
242 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_clip ); | |
243 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_eoclip ); | |
244 | ||
245 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_beginpage ); | |
246 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_showpage ); | |
247 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_end_doc ); | |
248 | ||
249 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_pango_create_layout ); | |
250 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_pango_layout ); | |
251 | ||
252 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_new ); | |
253 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_get_context ); | |
254 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_close ); | |
255 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_print ); | |
256 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_job_get_page_size ); | |
257 | ||
258 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_unit_get_by_abbreviation ); | |
259 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_convert_distance ); | |
260 | ||
261 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_default ); | |
262 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set ); | |
263 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_boolean ); | |
264 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_double ); | |
265 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_int ); | |
266 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_set_length ); | |
3b7ab6bd | 267 | |
6950be01 RR |
268 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_get ); |
269 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_get_length ); | |
b0d7707b | 270 | wxDL_METHOD_LOAD( m_libGnomePrint, gnome_print_config_get_boolean ); |
59c73be8 | 271 | |
6950be01 RR |
272 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_new ); |
273 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_construct_range_page ); | |
274 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_get_copies ); | |
275 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_set_copies ); | |
276 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_get_range ); | |
277 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_dialog_get_range_page ); | |
59c73be8 | 278 | |
6950be01 | 279 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_paper_selector_new_with_flags ); |
59c73be8 | 280 | |
6950be01 | 281 | wxDL_METHOD_LOAD( m_libGnomePrintUI, gnome_print_job_preview_new ); |
389076f1 | 282 | |
ced3df77 | 283 | return true; |
c6efd6e0 RR |
284 | } |
285 | ||
ced3df77 | 286 | static wxGnomePrintLibrary* gs_libGnomePrint = NULL; |
c6efd6e0 | 287 | |
ff910433 RR |
288 | //---------------------------------------------------------------------------- |
289 | // wxGnomePrintNativeData | |
290 | //---------------------------------------------------------------------------- | |
291 | ||
292 | IMPLEMENT_CLASS(wxGnomePrintNativeData, wxPrintNativeDataBase) | |
293 | ||
294 | wxGnomePrintNativeData::wxGnomePrintNativeData() | |
295 | { | |
ced3df77 VZ |
296 | m_config = gs_libGnomePrint->gnome_print_config_default(); |
297 | m_job = gs_libGnomePrint->gnome_print_job_new( m_config ); | |
ff910433 RR |
298 | } |
299 | ||
300 | wxGnomePrintNativeData::~wxGnomePrintNativeData() | |
301 | { | |
3fe39b0c | 302 | g_object_unref (m_config); |
ff910433 RR |
303 | } |
304 | ||
305 | bool wxGnomePrintNativeData::TransferTo( wxPrintData &data ) | |
306 | { | |
ced3df77 | 307 | guchar *res = gs_libGnomePrint->gnome_print_config_get( m_config, |
3b7ab6bd RR |
308 | (guchar*)(char*)GNOME_PRINT_KEY_PAGE_ORIENTATION ); |
309 | if (g_ascii_strcasecmp((const gchar *)res,"R90") == 0) | |
310 | data.SetOrientation( wxLANDSCAPE ); | |
311 | else | |
312 | data.SetOrientation( wxPORTRAIT ); | |
313 | g_free( res ); | |
b0d7707b RR |
314 | |
315 | res = gs_libGnomePrint->gnome_print_config_get( m_config, | |
316 | (guchar*)(char*)GNOME_PRINT_KEY_OUTPUT_FILENAME ); | |
317 | if (res) | |
318 | { | |
319 | data.SetFilename( wxConvFile.cMB2WX( (const char*) res ) ); | |
320 | wxPrintf( "filename %s\n", data.GetFilename() ); | |
321 | g_free( res ); | |
322 | } | |
323 | else | |
324 | { | |
325 | data.SetFilename( wxEmptyString ); | |
326 | } | |
327 | ||
328 | gboolean ret; | |
329 | if (gs_libGnomePrint->gnome_print_config_get_boolean( m_config, | |
330 | (guchar*)(char*)GNOME_PRINT_KEY_COLLATE, &ret)) | |
331 | { | |
332 | data.SetCollate( ret ); | |
333 | } | |
334 | ||
335 | // gnome_print_v | |
3b7ab6bd | 336 | |
ff910433 RR |
337 | return true; |
338 | } | |
339 | ||
340 | bool wxGnomePrintNativeData::TransferFrom( const wxPrintData &data ) | |
341 | { | |
3b7ab6bd RR |
342 | if (data.GetOrientation() == wxLANDSCAPE) |
343 | { | |
ced3df77 | 344 | gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
345 | (guchar*)(char*)GNOME_PRINT_KEY_PAGE_ORIENTATION, |
346 | (guchar*)(char*)"R90" ); | |
347 | } | |
348 | else | |
349 | { | |
ced3df77 | 350 | gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
351 | (guchar*)(char*)GNOME_PRINT_KEY_PAGE_ORIENTATION, |
352 | (guchar*)(char*)"R0" ); | |
353 | } | |
354 | ||
355 | if (data.GetCollate()) | |
356 | { | |
ced3df77 | 357 | gs_libGnomePrint->gnome_print_config_set_boolean( m_config, |
3b7ab6bd RR |
358 | (guchar*)(char*)GNOME_PRINT_KEY_COLLATE, |
359 | TRUE ); | |
360 | } | |
361 | else | |
362 | { | |
ced3df77 | 363 | gs_libGnomePrint->gnome_print_config_set_boolean( m_config, |
3b7ab6bd RR |
364 | (guchar*)(char*)GNOME_PRINT_KEY_COLLATE, |
365 | FALSE ); | |
366 | } | |
367 | ||
368 | switch (data.GetPaperId()) | |
369 | { | |
ced3df77 | 370 | case wxPAPER_A3: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
371 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
372 | (guchar*)(char*)"A3" ); | |
373 | break; | |
ced3df77 | 374 | case wxPAPER_A5: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
375 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
376 | (guchar*)(char*)"A5" ); | |
377 | break; | |
ced3df77 | 378 | case wxPAPER_B4: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
379 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
380 | (guchar*)(char*)"B4" ); | |
381 | break; | |
ced3df77 | 382 | case wxPAPER_B5: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
383 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
384 | (guchar*)(char*)"B5" ); | |
385 | break; | |
ced3df77 | 386 | case wxPAPER_LETTER: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
387 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
388 | (guchar*)(char*)"USLetter" ); | |
389 | break; | |
ced3df77 | 390 | case wxPAPER_LEGAL: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
391 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
392 | (guchar*)(char*)"USLegal" ); | |
393 | break; | |
ced3df77 | 394 | case wxPAPER_EXECUTIVE: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
395 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
396 | (guchar*)(char*)"Executive" ); | |
397 | break; | |
ced3df77 | 398 | case wxPAPER_ENV_C5: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
399 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
400 | (guchar*)(char*)"C5" ); | |
401 | break; | |
ced3df77 | 402 | case wxPAPER_ENV_C6: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
403 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
404 | (guchar*)(char*)"C6" ); | |
405 | break; | |
406 | case wxPAPER_NONE: break; | |
407 | ||
408 | default: | |
ced3df77 | 409 | case wxPAPER_A4: gs_libGnomePrint->gnome_print_config_set( m_config, |
3b7ab6bd RR |
410 | (guchar*)(char*)GNOME_PRINT_KEY_PAPER_SIZE, |
411 | (guchar*)(char*)"A4" ); | |
412 | break; | |
413 | } | |
414 | ||
ff910433 RR |
415 | return true; |
416 | } | |
389076f1 | 417 | |
ff910433 RR |
418 | //---------------------------------------------------------------------------- |
419 | // wxGnomePrintFactory | |
420 | //---------------------------------------------------------------------------- | |
421 | ||
422 | wxPrinterBase* wxGnomePrintFactory::CreatePrinter( wxPrintDialogData *data ) | |
423 | { | |
424 | return new wxGnomePrinter( data ); | |
425 | } | |
389076f1 WS |
426 | |
427 | wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview, | |
428 | wxPrintout *printout, | |
ff910433 RR |
429 | wxPrintDialogData *data ) |
430 | { | |
147bf263 | 431 | return new wxGnomePrintPreview( preview, printout, data ); |
ff910433 RR |
432 | } |
433 | ||
389076f1 WS |
434 | wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview, |
435 | wxPrintout *printout, | |
ff910433 RR |
436 | wxPrintData *data ) |
437 | { | |
147bf263 | 438 | return new wxGnomePrintPreview( preview, printout, data ); |
ff910433 RR |
439 | } |
440 | ||
389076f1 | 441 | wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, |
ff910433 RR |
442 | wxPrintDialogData *data ) |
443 | { | |
2934005d | 444 | return new wxGnomePrintDialog( parent, data ); |
ff910433 RR |
445 | } |
446 | ||
389076f1 | 447 | wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, |
ff910433 RR |
448 | wxPrintData *data ) |
449 | { | |
2934005d | 450 | return new wxGnomePrintDialog( parent, data ); |
ff910433 | 451 | } |
389076f1 | 452 | |
08680429 RR |
453 | wxPageSetupDialogBase *wxGnomePrintFactory::CreatePageSetupDialog( wxWindow *parent, |
454 | wxPageSetupDialogData * data ) | |
389076f1 | 455 | { |
06cfd325 RR |
456 | // The native page setup dialog is broken. It |
457 | // miscalculates newly entered values for the | |
458 | // margins if you have not chose "points" but | |
389076f1 | 459 | // e.g. centimerters. |
cffcf831 RR |
460 | // This has been fixed in GNOME CVS (maybe |
461 | // fixed in libgnomeprintui 2.8.1) | |
06cfd325 | 462 | |
cffcf831 | 463 | return new wxGnomePageSetupDialog( parent, data ); |
08680429 | 464 | } |
389076f1 | 465 | |
ff910433 RR |
466 | bool wxGnomePrintFactory::HasPrintSetupDialog() |
467 | { | |
2934005d | 468 | return false; |
ff910433 RR |
469 | } |
470 | ||
471 | wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ) | |
472 | { | |
2934005d | 473 | return NULL; |
ff910433 RR |
474 | } |
475 | ||
147bf263 JS |
476 | wxDC* wxGnomePrintFactory::CreatePrinterDC( const wxPrintData& data ) |
477 | { | |
478 | return new wxGnomePrintDC(data); | |
479 | } | |
480 | ||
ff910433 RR |
481 | bool wxGnomePrintFactory::HasOwnPrintToFile() |
482 | { | |
483 | return true; | |
484 | } | |
485 | ||
486 | bool wxGnomePrintFactory::HasPrinterLine() | |
487 | { | |
488 | return true; | |
489 | } | |
490 | ||
491 | wxString wxGnomePrintFactory::CreatePrinterLine() | |
492 | { | |
2934005d RR |
493 | // redundant now |
494 | return wxEmptyString; | |
ff910433 RR |
495 | } |
496 | ||
497 | bool wxGnomePrintFactory::HasStatusLine() | |
498 | { | |
2934005d | 499 | // redundant now |
389076f1 | 500 | return true; |
ff910433 RR |
501 | } |
502 | ||
503 | wxString wxGnomePrintFactory::CreateStatusLine() | |
504 | { | |
2934005d RR |
505 | // redundant now |
506 | return wxEmptyString; | |
ff910433 RR |
507 | } |
508 | ||
509 | wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData() | |
510 | { | |
511 | return new wxGnomePrintNativeData; | |
512 | } | |
513 | ||
514 | //---------------------------------------------------------------------------- | |
515 | // wxGnomePrintSetupDialog | |
516 | //---------------------------------------------------------------------------- | |
517 | ||
2934005d RR |
518 | IMPLEMENT_CLASS(wxGnomePrintDialog, wxPrintDialogBase) |
519 | ||
520 | wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintDialogData *data ) | |
521 | : wxPrintDialogBase(parent, wxID_ANY, _("Print"), | |
522 | wxPoint(0, 0), wxSize(600, 600), | |
523 | wxDEFAULT_DIALOG_STYLE | | |
524 | wxTAB_TRAVERSAL) | |
525 | { | |
526 | if (data) | |
527 | m_printDialogData = *data; | |
389076f1 | 528 | |
2934005d RR |
529 | Init(); |
530 | } | |
531 | ||
532 | wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintData *data ) | |
533 | : wxPrintDialogBase(parent, wxID_ANY, _("Print"), | |
534 | wxPoint(0, 0), wxSize(600, 600), | |
535 | wxDEFAULT_DIALOG_STYLE | | |
536 | wxTAB_TRAVERSAL) | |
537 | { | |
538 | if (data) | |
539 | m_printDialogData = *data; | |
540 | ||
541 | Init(); | |
542 | } | |
ff910433 | 543 | |
2934005d | 544 | void wxGnomePrintDialog::Init() |
ff910433 | 545 | { |
2934005d | 546 | wxPrintData data = m_printDialogData.GetPrintData(); |
3b7ab6bd RR |
547 | |
548 | data.ConvertToNative(); | |
2934005d | 549 | |
ff910433 | 550 | wxGnomePrintNativeData *native = |
2934005d | 551 | (wxGnomePrintNativeData*) data.GetNativeData(); |
389076f1 | 552 | |
ced3df77 | 553 | m_widget = gs_libGnomePrint->gnome_print_dialog_new( native->GetPrintJob(), |
389076f1 | 554 | (guchar*)"Print", |
2934005d | 555 | GNOME_PRINT_DIALOG_RANGE|GNOME_PRINT_DIALOG_COPIES ); |
b199de59 RR |
556 | |
557 | int flag = 0; | |
558 | if (m_printDialogData.GetEnableSelection()) | |
559 | flag |= GNOME_PRINT_RANGE_SELECTION; | |
560 | if (m_printDialogData.GetEnablePageNumbers()) | |
561 | flag |= GNOME_PRINT_RANGE_ALL|GNOME_PRINT_RANGE_RANGE; | |
562 | ||
ced3df77 | 563 | gs_libGnomePrint->gnome_print_dialog_construct_range_page( (GnomePrintDialog*) m_widget, |
b199de59 RR |
564 | flag, |
565 | m_printDialogData.GetMinPage(), | |
566 | m_printDialogData.GetMaxPage(), | |
567 | NULL, | |
568 | NULL ); | |
ff910433 RR |
569 | } |
570 | ||
2934005d | 571 | wxGnomePrintDialog::~wxGnomePrintDialog() |
ff910433 RR |
572 | { |
573 | m_widget = NULL; | |
574 | } | |
575 | ||
2934005d | 576 | int wxGnomePrintDialog::ShowModal() |
ff910433 RR |
577 | { |
578 | int response = gtk_dialog_run (GTK_DIALOG (m_widget)); | |
389076f1 WS |
579 | |
580 | if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL) | |
b199de59 RR |
581 | { |
582 | gtk_widget_destroy(m_widget); | |
583 | m_widget = NULL; | |
389076f1 | 584 | |
ff910433 | 585 | return wxID_CANCEL; |
b199de59 | 586 | } |
ff910433 | 587 | |
3b7ab6bd RR |
588 | m_printDialogData.GetPrintData().ConvertFromNative(); |
589 | ||
b199de59 RR |
590 | gint copies = 1; |
591 | gboolean collate = false; | |
ced3df77 | 592 | gs_libGnomePrint->gnome_print_dialog_get_copies( (GnomePrintDialog*) m_widget, &copies, &collate ); |
b199de59 RR |
593 | m_printDialogData.SetNoCopies( copies ); |
594 | m_printDialogData.SetCollate( collate ); | |
2934005d | 595 | |
ced3df77 | 596 | switch (gs_libGnomePrint->gnome_print_dialog_get_range( (GnomePrintDialog*) m_widget )) |
b199de59 RR |
597 | { |
598 | case GNOME_PRINT_RANGE_SELECTION: | |
599 | m_printDialogData.SetSelection( true ); | |
600 | break; | |
601 | case GNOME_PRINT_RANGE_ALL: | |
602 | m_printDialogData.SetAllPages( true ); | |
603 | m_printDialogData.SetFromPage( 0 ); | |
604 | m_printDialogData.SetToPage( 9999 ); | |
605 | break; | |
606 | case GNOME_PRINT_RANGE_RANGE: | |
607 | default: | |
608 | gint start,end; | |
ced3df77 | 609 | gs_libGnomePrint->gnome_print_dialog_get_range_page( (GnomePrintDialog*) m_widget, &start, &end ); |
b199de59 RR |
610 | m_printDialogData.SetFromPage( start ); |
611 | m_printDialogData.SetToPage( end ); | |
612 | break; | |
613 | } | |
614 | ||
615 | gtk_widget_destroy(m_widget); | |
616 | m_widget = NULL; | |
389076f1 | 617 | |
0be7709e RR |
618 | if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW) |
619 | return wxID_PREVIEW; | |
389076f1 | 620 | |
ff910433 RR |
621 | return wxID_OK; |
622 | } | |
623 | ||
2934005d | 624 | wxDC *wxGnomePrintDialog::GetPrintDC() |
ff910433 | 625 | { |
2934005d RR |
626 | // Later |
627 | return NULL; | |
ff910433 RR |
628 | } |
629 | ||
2934005d | 630 | bool wxGnomePrintDialog::Validate() |
ff910433 RR |
631 | { |
632 | return true; | |
633 | } | |
634 | ||
2934005d | 635 | bool wxGnomePrintDialog::TransferDataToWindow() |
ff910433 RR |
636 | { |
637 | return true; | |
638 | } | |
639 | ||
2934005d RR |
640 | bool wxGnomePrintDialog::TransferDataFromWindow() |
641 | { | |
642 | return true; | |
643 | } | |
ff910433 | 644 | |
08680429 RR |
645 | //---------------------------------------------------------------------------- |
646 | // wxGnomePageSetupDialog | |
647 | //---------------------------------------------------------------------------- | |
648 | ||
649 | IMPLEMENT_CLASS(wxGnomePageSetupDialog, wxPageSetupDialogBase) | |
650 | ||
651 | wxGnomePageSetupDialog::wxGnomePageSetupDialog( wxWindow *parent, | |
652 | wxPageSetupDialogData* data ) | |
653 | { | |
654 | if (data) | |
655 | m_pageDialogData = *data; | |
389076f1 | 656 | |
3b7ab6bd RR |
657 | m_pageDialogData.GetPrintData().ConvertToNative(); |
658 | ||
08680429 RR |
659 | wxGnomePrintNativeData *native = |
660 | (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData(); | |
cffcf831 | 661 | |
3b7ab6bd | 662 | // This *was* required as the page setup dialog |
cffcf831 | 663 | // calculates wrong values otherwise. |
3b7ab6bd | 664 | #if 0 |
ced3df77 | 665 | gs_libGnomePrint->gnome_print_config_set( native->GetPrintConfig(), |
cffcf831 RR |
666 | (const guchar*) GNOME_PRINT_KEY_PREFERED_UNIT, |
667 | (const guchar*) "Pts" ); | |
3b7ab6bd RR |
668 | #endif |
669 | ||
670 | GnomePrintConfig *config = native->GetPrintConfig(); | |
671 | ||
ced3df77 | 672 | const GnomePrintUnit *mm_unit = gs_libGnomePrint->gnome_print_unit_get_by_abbreviation( (const guchar*) "mm" ); |
3b7ab6bd RR |
673 | |
674 | double ml = (double) m_pageDialogData.GetMarginTopLeft().x; | |
675 | double mt = (double) m_pageDialogData.GetMarginTopLeft().y; | |
676 | double mr = (double) m_pageDialogData.GetMarginBottomRight().x; | |
677 | double mb = (double) m_pageDialogData.GetMarginBottomRight().y; | |
678 | ||
ced3df77 | 679 | gs_libGnomePrint->gnome_print_config_set_length (config, |
3b7ab6bd | 680 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, ml, mm_unit ); |
ced3df77 | 681 | gs_libGnomePrint->gnome_print_config_set_length (config, |
3b7ab6bd | 682 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, mr, mm_unit ); |
ced3df77 | 683 | gs_libGnomePrint->gnome_print_config_set_length (config, |
3b7ab6bd | 684 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_TOP, mt, mm_unit ); |
ced3df77 | 685 | gs_libGnomePrint->gnome_print_config_set_length (config, |
3b7ab6bd | 686 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, mb, mm_unit ); |
389076f1 | 687 | |
08680429 | 688 | m_widget = gtk_dialog_new(); |
389076f1 | 689 | |
08680429 | 690 | gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( _("Page setup") ) ); |
cffcf831 | 691 | |
ced3df77 | 692 | GtkWidget *main = gs_libGnomePrint->gnome_paper_selector_new_with_flags( native->GetPrintConfig(), |
08680429 RR |
693 | GNOME_PAPER_SELECTOR_MARGINS|GNOME_PAPER_SELECTOR_FEED_ORIENTATION ); |
694 | gtk_container_set_border_width (GTK_CONTAINER (main), 8); | |
695 | gtk_widget_show (main); | |
389076f1 | 696 | |
08680429 | 697 | gtk_container_add( GTK_CONTAINER (GTK_DIALOG (m_widget)->vbox), main ); |
08680429 | 698 | |
389076f1 | 699 | gtk_dialog_set_has_separator (GTK_DIALOG (m_widget), TRUE); |
08680429 | 700 | |
389076f1 WS |
701 | gtk_dialog_add_buttons (GTK_DIALOG (m_widget), |
702 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
703 | GTK_STOCK_OK, GTK_RESPONSE_OK, | |
704 | NULL); | |
705 | ||
706 | gtk_dialog_set_default_response (GTK_DIALOG (m_widget), | |
707 | GTK_RESPONSE_OK); | |
08680429 RR |
708 | } |
709 | ||
710 | wxGnomePageSetupDialog::~wxGnomePageSetupDialog() | |
711 | { | |
712 | } | |
713 | ||
714 | wxPageSetupDialogData& wxGnomePageSetupDialog::GetPageSetupDialogData() | |
715 | { | |
716 | return m_pageDialogData; | |
717 | } | |
718 | ||
719 | int wxGnomePageSetupDialog::ShowModal() | |
720 | { | |
06cfd325 RR |
721 | wxGnomePrintNativeData *native = |
722 | (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData(); | |
3b7ab6bd | 723 | |
06cfd325 | 724 | GnomePrintConfig *config = native->GetPrintConfig(); |
389076f1 | 725 | |
08680429 RR |
726 | |
727 | int ret = gtk_dialog_run( GTK_DIALOG(m_widget) ); | |
728 | ||
729 | if (ret == GTK_RESPONSE_OK) | |
730 | { | |
731 | // Transfer data back to m_pageDialogData | |
3b7ab6bd | 732 | m_pageDialogData.GetPrintData().ConvertFromNative(); |
cffcf831 RR |
733 | |
734 | // I don't know how querying the last parameter works | |
06cfd325 | 735 | double ml,mr,mt,mb,pw,ph; |
ced3df77 | 736 | gs_libGnomePrint->gnome_print_config_get_length (config, |
389076f1 | 737 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &ml, NULL); |
ced3df77 | 738 | gs_libGnomePrint->gnome_print_config_get_length (config, |
389076f1 | 739 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &mr, NULL); |
ced3df77 | 740 | gs_libGnomePrint->gnome_print_config_get_length (config, |
389076f1 | 741 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &mt, NULL); |
ced3df77 | 742 | gs_libGnomePrint->gnome_print_config_get_length (config, |
389076f1 | 743 | (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &mb, NULL); |
ced3df77 | 744 | gs_libGnomePrint->gnome_print_config_get_length (config, |
389076f1 | 745 | (const guchar*) GNOME_PRINT_KEY_PAPER_WIDTH, &pw, NULL); |
ced3df77 | 746 | gs_libGnomePrint->gnome_print_config_get_length (config, |
389076f1 WS |
747 | (const guchar*) GNOME_PRINT_KEY_PAPER_HEIGHT, &ph, NULL); |
748 | ||
3b7ab6bd RR |
749 | // This code converts correctly from what the user chose |
750 | // as the unit although I query Pts here | |
ced3df77 VZ |
751 | const GnomePrintUnit *mm_unit = gs_libGnomePrint->gnome_print_unit_get_by_abbreviation( (const guchar*) "mm" ); |
752 | const GnomePrintUnit *pts_unit = gs_libGnomePrint->gnome_print_unit_get_by_abbreviation( (const guchar*) "Pts" ); | |
753 | gs_libGnomePrint->gnome_print_convert_distance( &ml, pts_unit, mm_unit ); | |
754 | gs_libGnomePrint->gnome_print_convert_distance( &mr, pts_unit, mm_unit ); | |
755 | gs_libGnomePrint->gnome_print_convert_distance( &mt, pts_unit, mm_unit ); | |
756 | gs_libGnomePrint->gnome_print_convert_distance( &mb, pts_unit, mm_unit ); | |
757 | gs_libGnomePrint->gnome_print_convert_distance( &pw, pts_unit, mm_unit ); | |
758 | gs_libGnomePrint->gnome_print_convert_distance( &ph, pts_unit, mm_unit ); | |
cffcf831 RR |
759 | |
760 | m_pageDialogData.SetMarginTopLeft( wxPoint( (int)(ml+0.5), (int)(mt+0.5)) ); | |
06cfd325 | 761 | m_pageDialogData.SetMarginBottomRight( wxPoint( (int)(mr+0.5), (int)(mb+0.5)) ); |
389076f1 | 762 | |
06cfd325 | 763 | m_pageDialogData.SetPaperSize( wxSize( (int)(pw+0.5), (int)(ph+0.5) ) ); |
cffcf831 | 764 | |
08680429 RR |
765 | ret = wxID_OK; |
766 | } | |
767 | else | |
768 | { | |
769 | ret = wxID_CANCEL; | |
770 | } | |
389076f1 | 771 | |
08680429 RR |
772 | gtk_widget_destroy( m_widget ); |
773 | m_widget = NULL; | |
774 | ||
775 | return ret; | |
776 | } | |
777 | ||
778 | bool wxGnomePageSetupDialog::Validate() | |
779 | { | |
780 | return true; | |
781 | } | |
782 | ||
783 | bool wxGnomePageSetupDialog::TransferDataToWindow() | |
784 | { | |
785 | return true; | |
786 | } | |
787 | ||
788 | bool wxGnomePageSetupDialog::TransferDataFromWindow() | |
789 | { | |
790 | return true; | |
791 | } | |
792 | ||
ff910433 RR |
793 | //---------------------------------------------------------------------------- |
794 | // wxGnomePrinter | |
795 | //---------------------------------------------------------------------------- | |
796 | ||
797 | IMPLEMENT_CLASS(wxGnomePrinter, wxPrinterBase) | |
798 | ||
799 | wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) : | |
800 | wxPrinterBase( data ) | |
801 | { | |
0be7709e | 802 | m_native_preview = false; |
ff910433 RR |
803 | } |
804 | ||
805 | wxGnomePrinter::~wxGnomePrinter() | |
806 | { | |
807 | } | |
808 | ||
809 | bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) | |
810 | { | |
811 | if (!printout) | |
812 | { | |
813 | sm_lastError = wxPRINTER_ERROR; | |
814 | return false; | |
815 | } | |
816 | ||
817 | wxPrintData printdata = GetPrintDialogData().GetPrintData(); | |
3b7ab6bd | 818 | |
389076f1 | 819 | wxGnomePrintNativeData *native = |
ff910433 RR |
820 | (wxGnomePrintNativeData*) printdata.GetNativeData(); |
821 | ||
ced3df77 | 822 | GnomePrintJob *job = gs_libGnomePrint->gnome_print_job_new( native->GetPrintConfig() ); |
cffcf831 | 823 | |
389076f1 | 824 | // The GnomePrintJob is temporarily stored in the |
2934005d | 825 | // native print data as the native print dialog |
981a6af1 | 826 | // needs to access it. |
cffcf831 RR |
827 | native->SetPrintJob( job ); |
828 | ||
981a6af1 RR |
829 | |
830 | printout->SetIsPreview(false); | |
831 | ||
832 | if (m_printDialogData.GetMinPage() < 1) | |
833 | m_printDialogData.SetMinPage(1); | |
834 | if (m_printDialogData.GetMaxPage() < 1) | |
835 | m_printDialogData.SetMaxPage(9999); | |
389076f1 | 836 | |
ff910433 | 837 | wxDC *dc; |
ff910433 RR |
838 | if (prompt) |
839 | dc = PrintDialog( parent ); | |
840 | else | |
3b7ab6bd | 841 | dc = new wxGnomePrintDC( printdata ); |
389076f1 | 842 | |
0be7709e RR |
843 | if (m_native_preview) |
844 | printout->SetIsPreview(true); | |
389076f1 | 845 | |
ff910433 RR |
846 | if (!dc) |
847 | { | |
ced3df77 | 848 | gs_libGnomePrint->gnome_print_job_close( job ); |
3fe39b0c | 849 | g_object_unref (job); |
a1b289f1 PC |
850 | if (sm_lastError != wxPRINTER_CANCELLED) |
851 | sm_lastError = wxPRINTER_ERROR; | |
ff910433 RR |
852 | return false; |
853 | } | |
854 | ||
981a6af1 RR |
855 | wxSize ScreenPixels = wxGetDisplaySize(); |
856 | wxSize ScreenMM = wxGetDisplaySizeMM(); | |
857 | ||
858 | printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()), | |
859 | (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) ); | |
b199de59 RR |
860 | printout->SetPPIPrinter( wxGnomePrintDC::GetResolution(), |
861 | wxGnomePrintDC::GetResolution() ); | |
389076f1 | 862 | |
ff910433 RR |
863 | printout->SetDC(dc); |
864 | ||
981a6af1 RR |
865 | int w, h; |
866 | dc->GetSize(&w, &h); | |
867 | printout->SetPageSizePixels((int)w, (int)h); | |
f415cab9 JS |
868 | printout->SetPaperRectPixels(wxRect(0, 0, w, h)); |
869 | int mw, mh; | |
870 | dc->GetSizeMM(&mw, &mh); | |
871 | printout->SetPageSizeMM((int)mw, (int)mh); | |
ff910433 | 872 | printout->OnPreparePrinting(); |
389076f1 | 873 | |
b199de59 RR |
874 | // Get some parameters from the printout, if defined |
875 | int fromPage, toPage; | |
876 | int minPage, maxPage; | |
877 | printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); | |
ff910433 | 878 | |
b199de59 | 879 | if (maxPage == 0) |
ff910433 | 880 | { |
ced3df77 | 881 | gs_libGnomePrint->gnome_print_job_close( job ); |
3fe39b0c | 882 | g_object_unref (job); |
ff910433 | 883 | sm_lastError = wxPRINTER_ERROR; |
b199de59 | 884 | return false; |
ff910433 | 885 | } |
389076f1 | 886 | |
b199de59 RR |
887 | printout->OnBeginPrinting(); |
888 | ||
889 | int minPageNum = minPage, maxPageNum = maxPage; | |
890 | ||
891 | if ( !m_printDialogData.GetAllPages() ) | |
ff910433 | 892 | { |
b199de59 RR |
893 | minPageNum = m_printDialogData.GetFromPage(); |
894 | maxPageNum = m_printDialogData.GetToPage(); | |
895 | } | |
896 | ||
389076f1 | 897 | |
b199de59 RR |
898 | int copyCount; |
899 | for ( copyCount = 1; | |
900 | copyCount <= m_printDialogData.GetNoCopies(); | |
901 | copyCount++ ) | |
902 | { | |
903 | if (!printout->OnBeginDocument(minPageNum, maxPageNum)) | |
ff910433 | 904 | { |
b199de59 RR |
905 | wxLogError(_("Could not start printing.")); |
906 | sm_lastError = wxPRINTER_ERROR; | |
907 | break; | |
908 | } | |
389076f1 | 909 | |
b199de59 RR |
910 | int pn; |
911 | for ( pn = minPageNum; | |
912 | pn <= maxPageNum && printout->HasPage(pn); | |
913 | pn++ ) | |
389076f1 | 914 | { |
ff910433 RR |
915 | dc->StartPage(); |
916 | printout->OnPrintPage(pn); | |
917 | dc->EndPage(); | |
918 | } | |
389076f1 | 919 | |
ff910433 RR |
920 | printout->OnEndDocument(); |
921 | printout->OnEndPrinting(); | |
922 | } | |
389076f1 | 923 | |
ced3df77 | 924 | gs_libGnomePrint->gnome_print_job_close( job ); |
0be7709e RR |
925 | if (m_native_preview) |
926 | { | |
46e86fc3 | 927 | const wxCharBuffer title(wxGTK_CONV_SYS(_("Print preview"))); |
ced3df77 | 928 | GtkWidget *preview = gs_libGnomePrint->gnome_print_job_preview_new |
b8f32576 VZ |
929 | ( |
930 | job, | |
46e86fc3 | 931 | (const guchar *)title.data() |
b8f32576 VZ |
932 | ); |
933 | gtk_widget_show(preview); | |
0be7709e RR |
934 | } |
935 | else | |
936 | { | |
ced3df77 | 937 | gs_libGnomePrint->gnome_print_job_print( job ); |
0be7709e | 938 | } |
389076f1 | 939 | |
3fe39b0c | 940 | g_object_unref (job); |
ff910433 | 941 | delete dc; |
389076f1 | 942 | |
ff910433 RR |
943 | return (sm_lastError == wxPRINTER_NO_ERROR); |
944 | } | |
945 | ||
946 | wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent ) | |
947 | { | |
2934005d | 948 | wxGnomePrintDialog dialog( parent, &m_printDialogData ); |
0be7709e RR |
949 | int ret = dialog.ShowModal(); |
950 | if (ret == wxID_CANCEL) | |
ff910433 | 951 | { |
4843cdfe | 952 | sm_lastError = wxPRINTER_CANCELLED; |
ff910433 RR |
953 | return NULL; |
954 | } | |
389076f1 | 955 | |
0be7709e | 956 | m_native_preview = ret == wxID_PREVIEW; |
389076f1 | 957 | |
b199de59 | 958 | m_printDialogData = dialog.GetPrintDialogData(); |
3b7ab6bd | 959 | return new wxGnomePrintDC( m_printDialogData.GetPrintData() ); |
ff910433 RR |
960 | } |
961 | ||
962 | bool wxGnomePrinter::Setup( wxWindow *parent ) | |
963 | { | |
58c30cd8 | 964 | return false; |
ff910433 RR |
965 | } |
966 | ||
967 | //----------------------------------------------------------------------------- | |
968 | // wxGnomePrintDC | |
969 | //----------------------------------------------------------------------------- | |
970 | ||
02255e07 RR |
971 | // conversion |
972 | static const double RAD2DEG = 180.0 / M_PI; | |
973 | ||
974 | // we don't want to use only 72 dpi from GNOME print | |
975 | static const int DPI = 600; | |
976 | static const double PS2DEV = 600.0 / 72.0; | |
977 | static const double DEV2PS = 72.0 / 600.0; | |
978 | ||
979 | #define XLOG2DEV(x) ((double)(LogicalToDeviceX(x)) * DEV2PS) | |
980 | #define XLOG2DEVREL(x) ((double)(LogicalToDeviceXRel(x)) * DEV2PS) | |
981 | #define YLOG2DEV(x) ((m_pageHeight - (double)LogicalToDeviceY(x)) * DEV2PS) | |
982 | #define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * DEV2PS) | |
983 | ||
62075bca | 984 | IMPLEMENT_CLASS(wxGnomePrintDC, wxDC) |
ff910433 | 985 | |
147bf263 JS |
986 | wxGnomePrintDC::wxGnomePrintDC( const wxPrintData& data ) |
987 | { | |
147bf263 JS |
988 | m_printData = data; |
989 | ||
990 | wxGnomePrintNativeData *native = | |
991 | (wxGnomePrintNativeData*) m_printData.GetNativeData(); | |
992 | ||
3b7ab6bd | 993 | m_job = native->GetPrintJob(); |
ced3df77 | 994 | m_gpc = gs_libGnomePrint->gnome_print_job_get_context (m_job); |
147bf263 | 995 | |
ced3df77 | 996 | m_layout = gs_libGnomePrint->gnome_print_pango_create_layout( m_gpc ); |
147bf263 | 997 | m_fontdesc = pango_font_description_from_string( "Sans 12" ); |
7d7e4ed0 | 998 | m_context = NULL; |
147bf263 JS |
999 | |
1000 | m_currentRed = 0; | |
1001 | m_currentBlue = 0; | |
1002 | m_currentGreen = 0; | |
1003 | ||
02255e07 RR |
1004 | // Query page size. This seems to omit the margins |
1005 | double pw,ph; | |
6950be01 | 1006 | gs_libGnomePrint->gnome_print_job_get_page_size( native->GetPrintJob(), &pw, &ph ); |
f4322df6 | 1007 | |
02255e07 | 1008 | m_pageHeight = ph * PS2DEV; |
147bf263 JS |
1009 | } |
1010 | ||
ff910433 RR |
1011 | wxGnomePrintDC::~wxGnomePrintDC() |
1012 | { | |
1013 | } | |
1014 | ||
b7cacb43 | 1015 | bool wxGnomePrintDC::IsOk() const |
ff910433 RR |
1016 | { |
1017 | return true; | |
1018 | } | |
1019 | ||
1020 | bool wxGnomePrintDC::DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style ) | |
1021 | { | |
1022 | return false; | |
1023 | } | |
1024 | ||
1025 | bool wxGnomePrintDC::DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const | |
1026 | { | |
1027 | return false; | |
1028 | } | |
1029 | ||
1030 | void wxGnomePrintDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) | |
1031 | { | |
1032 | if (m_pen.GetStyle() == wxTRANSPARENT) return; | |
389076f1 | 1033 | |
ff910433 RR |
1034 | SetPen( m_pen ); |
1035 | ||
ced3df77 VZ |
1036 | gs_libGnomePrint->gnome_print_moveto ( m_gpc, XLOG2DEV(x1), YLOG2DEV(y1) ); |
1037 | gs_libGnomePrint->gnome_print_lineto ( m_gpc, XLOG2DEV(x2), YLOG2DEV(y2) ); | |
1038 | gs_libGnomePrint->gnome_print_stroke ( m_gpc); | |
cac7ac30 | 1039 | |
ff910433 RR |
1040 | CalcBoundingBox( x1, y1 ); |
1041 | CalcBoundingBox( x2, y2 ); | |
1042 | } | |
1043 | ||
1044 | void wxGnomePrintDC::DoCrossHair(wxCoord x, wxCoord y) | |
1045 | { | |
1046 | } | |
1047 | ||
1048 | void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) | |
1049 | { | |
2f41910a RR |
1050 | double dx = x1 - xc; |
1051 | double dy = y1 - yc; | |
1052 | double radius = sqrt((double)(dx*dx+dy*dy)); | |
1053 | double alpha1, alpha2; | |
1054 | if (x1 == x2 && y1 == y2) | |
1055 | { | |
1056 | alpha1 = 0.0; | |
1057 | alpha2 = 360.0; | |
1058 | } | |
74ab5f5b | 1059 | else if ( wxIsNullDouble(radius) ) |
2f41910a | 1060 | { |
74ab5f5b VZ |
1061 | alpha1 = |
1062 | alpha2 = 0.0; | |
2f41910a RR |
1063 | } |
1064 | else | |
1065 | { | |
1066 | alpha1 = (x1 - xc == 0) ? | |
1067 | (y1 - yc < 0) ? 90.0 : -90.0 : | |
1068 | -atan2(double(y1-yc), double(x1-xc)) * RAD2DEG; | |
1069 | alpha2 = (x2 - xc == 0) ? | |
1070 | (y2 - yc < 0) ? 90.0 : -90.0 : | |
1071 | -atan2(double(y2-yc), double(x2-xc)) * RAD2DEG; | |
389076f1 | 1072 | |
2f41910a RR |
1073 | while (alpha1 <= 0) alpha1 += 360; |
1074 | while (alpha2 <= 0) alpha2 += 360; // adjust angles to be between | |
1075 | while (alpha1 > 360) alpha1 -= 360; // 0 and 360 degree | |
1076 | while (alpha2 > 360) alpha2 -= 360; | |
1077 | } | |
1078 | ||
7d7e4ed0 PC |
1079 | if (m_brush.GetStyle() != wxTRANSPARENT) |
1080 | { | |
1081 | SetBrush( m_brush ); | |
ced3df77 VZ |
1082 | gs_libGnomePrint->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) ); |
1083 | gs_libGnomePrint->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 ); | |
389076f1 | 1084 | |
ced3df77 | 1085 | gs_libGnomePrint->gnome_print_fill( m_gpc ); |
7d7e4ed0 | 1086 | } |
2f41910a | 1087 | |
7d7e4ed0 PC |
1088 | if (m_pen.GetStyle() != wxTRANSPARENT) |
1089 | { | |
1090 | SetPen (m_pen); | |
ced3df77 VZ |
1091 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
1092 | gs_libGnomePrint->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) ); | |
1093 | gs_libGnomePrint->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 ); | |
1094 | gs_libGnomePrint->gnome_print_closepath( m_gpc ); | |
389076f1 | 1095 | |
ced3df77 | 1096 | gs_libGnomePrint->gnome_print_stroke( m_gpc ); |
7d7e4ed0 | 1097 | } |
2f41910a RR |
1098 | |
1099 | CalcBoundingBox (x1, y1); | |
1100 | CalcBoundingBox (x2, y2); | |
1101 | CalcBoundingBox (xc, yc); | |
ff910433 RR |
1102 | } |
1103 | ||
1104 | void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) | |
1105 | { | |
16744532 RR |
1106 | x += w/2; |
1107 | y += h/2; | |
1108 | ||
02255e07 RR |
1109 | double xx = XLOG2DEV(x); |
1110 | double yy = YLOG2DEV(y); | |
16744532 | 1111 | |
ced3df77 | 1112 | gs_libGnomePrint->gnome_print_gsave( m_gpc ); |
16744532 | 1113 | |
ced3df77 | 1114 | gs_libGnomePrint->gnome_print_translate( m_gpc, xx, yy ); |
16744532 | 1115 | double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w); |
ced3df77 | 1116 | gs_libGnomePrint->gnome_print_scale( m_gpc, 1.0, scale ); |
389076f1 | 1117 | |
02255e07 RR |
1118 | xx = 0.0; |
1119 | yy = 0.0; | |
16744532 RR |
1120 | |
1121 | if (m_brush.GetStyle () != wxTRANSPARENT) | |
1122 | { | |
1123 | SetBrush( m_brush ); | |
389076f1 | 1124 | |
ced3df77 VZ |
1125 | gs_libGnomePrint->gnome_print_moveto ( m_gpc, xx, yy ); |
1126 | gs_libGnomePrint->gnome_print_arcto( m_gpc, xx, yy, | |
16744532 | 1127 | XLOG2DEVREL(w)/2, sa, ea, 0 ); |
ced3df77 | 1128 | gs_libGnomePrint->gnome_print_moveto ( m_gpc, xx, yy ); |
389076f1 | 1129 | |
ced3df77 | 1130 | gs_libGnomePrint->gnome_print_fill( m_gpc ); |
16744532 | 1131 | } |
389076f1 | 1132 | |
16744532 RR |
1133 | if (m_pen.GetStyle () != wxTRANSPARENT) |
1134 | { | |
1135 | SetPen (m_pen); | |
389076f1 | 1136 | |
ced3df77 | 1137 | gs_libGnomePrint->gnome_print_arcto( m_gpc, xx, yy, |
16744532 | 1138 | XLOG2DEVREL(w)/2, sa, ea, 0 ); |
389076f1 | 1139 | |
ced3df77 | 1140 | gs_libGnomePrint->gnome_print_stroke( m_gpc ); |
16744532 | 1141 | } |
389076f1 | 1142 | |
ced3df77 | 1143 | gs_libGnomePrint->gnome_print_grestore( m_gpc ); |
389076f1 | 1144 | |
16744532 RR |
1145 | CalcBoundingBox( x, y ); |
1146 | CalcBoundingBox( x+w, y+h ); | |
ff910433 RR |
1147 | } |
1148 | ||
1149 | void wxGnomePrintDC::DoDrawPoint(wxCoord x, wxCoord y) | |
1150 | { | |
1151 | } | |
1152 | ||
1153 | void wxGnomePrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) | |
1154 | { | |
cac7ac30 RR |
1155 | if (m_pen.GetStyle() == wxTRANSPARENT) return; |
1156 | ||
1157 | if (n <= 0) return; | |
1158 | ||
1159 | SetPen (m_pen); | |
1160 | ||
1161 | int i; | |
1162 | for ( i =0; i<n ; i++ ) | |
16744532 | 1163 | CalcBoundingBox( points[i].x+xoffset, points[i].y+yoffset); |
cac7ac30 | 1164 | |
ced3df77 | 1165 | gs_libGnomePrint->gnome_print_moveto ( m_gpc, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) ); |
389076f1 | 1166 | |
cac7ac30 | 1167 | for (i = 1; i < n; i++) |
ced3df77 | 1168 | gs_libGnomePrint->gnome_print_lineto ( m_gpc, XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset) ); |
cac7ac30 | 1169 | |
ced3df77 | 1170 | gs_libGnomePrint->gnome_print_stroke ( m_gpc); |
ff910433 RR |
1171 | } |
1172 | ||
1173 | void wxGnomePrintDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) | |
1174 | { | |
a92964a2 RR |
1175 | if (n==0) return; |
1176 | ||
1177 | if (m_brush.GetStyle () != wxTRANSPARENT) | |
1178 | { | |
1179 | SetBrush( m_brush ); | |
389076f1 | 1180 | |
a92964a2 RR |
1181 | int x = points[0].x + xoffset; |
1182 | int y = points[0].y + yoffset; | |
1183 | CalcBoundingBox( x, y ); | |
ced3df77 VZ |
1184 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
1185 | gs_libGnomePrint->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); | |
a92964a2 RR |
1186 | int i; |
1187 | for (i = 1; i < n; i++) | |
1188 | { | |
74ab5f5b VZ |
1189 | x = points[i].x + xoffset; |
1190 | y = points[i].y + yoffset; | |
ced3df77 | 1191 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); |
a92964a2 RR |
1192 | CalcBoundingBox( x, y ); |
1193 | } | |
ced3df77 VZ |
1194 | gs_libGnomePrint->gnome_print_closepath( m_gpc ); |
1195 | gs_libGnomePrint->gnome_print_fill( m_gpc ); | |
a92964a2 RR |
1196 | } |
1197 | ||
1198 | if (m_pen.GetStyle () != wxTRANSPARENT) | |
1199 | { | |
1200 | SetPen (m_pen); | |
1201 | ||
1202 | int x = points[0].x + xoffset; | |
1203 | int y = points[0].y + yoffset; | |
ced3df77 VZ |
1204 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
1205 | gs_libGnomePrint->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); | |
a92964a2 RR |
1206 | int i; |
1207 | for (i = 1; i < n; i++) | |
1208 | { | |
74ab5f5b VZ |
1209 | x = points[i].x + xoffset; |
1210 | y = points[i].y + yoffset; | |
ced3df77 | 1211 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); |
a92964a2 RR |
1212 | CalcBoundingBox( x, y ); |
1213 | } | |
ced3df77 VZ |
1214 | gs_libGnomePrint->gnome_print_closepath( m_gpc ); |
1215 | gs_libGnomePrint->gnome_print_stroke( m_gpc ); | |
a92964a2 | 1216 | } |
ff910433 RR |
1217 | } |
1218 | ||
1219 | void wxGnomePrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) | |
1220 | { | |
a92964a2 | 1221 | wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); |
ff910433 RR |
1222 | } |
1223 | ||
1224 | void wxGnomePrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
1225 | { | |
728ddc45 RR |
1226 | width--; |
1227 | height--; | |
1228 | ||
ff910433 RR |
1229 | if (m_brush.GetStyle () != wxTRANSPARENT) |
1230 | { | |
1231 | SetBrush( m_brush ); | |
389076f1 | 1232 | |
ced3df77 VZ |
1233 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
1234 | gs_libGnomePrint->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); | |
1235 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) ); | |
1236 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) ); | |
1237 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) ); | |
1238 | gs_libGnomePrint->gnome_print_closepath( m_gpc ); | |
1239 | gs_libGnomePrint->gnome_print_fill( m_gpc ); | |
ff910433 RR |
1240 | |
1241 | CalcBoundingBox( x, y ); | |
1242 | CalcBoundingBox( x + width, y + height ); | |
1243 | } | |
1244 | ||
1245 | if (m_pen.GetStyle () != wxTRANSPARENT) | |
1246 | { | |
1247 | SetPen (m_pen); | |
1248 | ||
ced3df77 VZ |
1249 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
1250 | gs_libGnomePrint->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); | |
1251 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) ); | |
1252 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) ); | |
1253 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) ); | |
1254 | gs_libGnomePrint->gnome_print_closepath( m_gpc ); | |
1255 | gs_libGnomePrint->gnome_print_stroke( m_gpc ); | |
389076f1 | 1256 | |
ff910433 RR |
1257 | CalcBoundingBox( x, y ); |
1258 | CalcBoundingBox( x + width, y + height ); | |
1259 | } | |
1260 | } | |
1261 | ||
1262 | void wxGnomePrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) | |
1263 | { | |
728ddc45 RR |
1264 | width--; |
1265 | height--; | |
1266 | ||
1267 | wxCoord rad = wxRound( radius ); | |
9a2fe010 RR |
1268 | |
1269 | if (m_brush.GetStyle() != wxTRANSPARENT) | |
1270 | { | |
1271 | SetBrush(m_brush); | |
ced3df77 VZ |
1272 | gs_libGnomePrint->gnome_print_newpath(m_gpc); |
1273 | gs_libGnomePrint->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); | |
1274 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1275 | XLOG2DEV(x + rad),YLOG2DEV(y), |
1276 | XLOG2DEV(x),YLOG2DEV(y), | |
1277 | XLOG2DEV(x),YLOG2DEV(y + rad)); | |
ced3df77 VZ |
1278 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad)); |
1279 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1280 | XLOG2DEV(x),YLOG2DEV(y + height - rad), |
1281 | XLOG2DEV(x),YLOG2DEV(y + height), | |
1282 | XLOG2DEV(x + rad),YLOG2DEV(y + height)); | |
ced3df77 VZ |
1283 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height)); |
1284 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1285 | XLOG2DEV(x + width - rad),YLOG2DEV(y + height), |
1286 | XLOG2DEV(x + width),YLOG2DEV(y + height), | |
1287 | XLOG2DEV(x + width),YLOG2DEV(y + height - rad)); | |
ced3df77 VZ |
1288 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad)); |
1289 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1290 | XLOG2DEV(x + width),YLOG2DEV(y + rad), |
1291 | XLOG2DEV(x + width),YLOG2DEV(y), | |
1292 | XLOG2DEV(x + width - rad),YLOG2DEV(y)); | |
ced3df77 VZ |
1293 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); |
1294 | gs_libGnomePrint->gnome_print_closepath(m_gpc); | |
1295 | gs_libGnomePrint->gnome_print_fill(m_gpc); | |
389076f1 | 1296 | |
9a2fe010 RR |
1297 | CalcBoundingBox(x,y); |
1298 | CalcBoundingBox(x+width,y+height); | |
1299 | } | |
389076f1 | 1300 | |
9a2fe010 RR |
1301 | if (m_pen.GetStyle() != wxTRANSPARENT) |
1302 | { | |
1303 | SetPen(m_pen); | |
ced3df77 VZ |
1304 | gs_libGnomePrint->gnome_print_newpath(m_gpc); |
1305 | gs_libGnomePrint->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); | |
1306 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1307 | XLOG2DEV(x + rad),YLOG2DEV(y), |
1308 | XLOG2DEV(x),YLOG2DEV(y), | |
1309 | XLOG2DEV(x),YLOG2DEV(y + rad)); | |
ced3df77 VZ |
1310 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad)); |
1311 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1312 | XLOG2DEV(x),YLOG2DEV(y + height - rad), |
1313 | XLOG2DEV(x),YLOG2DEV(y + height), | |
1314 | XLOG2DEV(x + rad),YLOG2DEV(y + height)); | |
ced3df77 VZ |
1315 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height)); |
1316 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1317 | XLOG2DEV(x + width - rad),YLOG2DEV(y + height), |
1318 | XLOG2DEV(x + width),YLOG2DEV(y + height), | |
1319 | XLOG2DEV(x + width),YLOG2DEV(y + height - rad)); | |
ced3df77 VZ |
1320 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad)); |
1321 | gs_libGnomePrint->gnome_print_curveto(m_gpc, | |
389076f1 WS |
1322 | XLOG2DEV(x + width),YLOG2DEV(y + rad), |
1323 | XLOG2DEV(x + width),YLOG2DEV(y), | |
1324 | XLOG2DEV(x + width - rad),YLOG2DEV(y)); | |
ced3df77 VZ |
1325 | gs_libGnomePrint->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y)); |
1326 | gs_libGnomePrint->gnome_print_closepath(m_gpc); | |
1327 | gs_libGnomePrint->gnome_print_stroke(m_gpc); | |
389076f1 | 1328 | |
9a2fe010 RR |
1329 | CalcBoundingBox(x,y); |
1330 | CalcBoundingBox(x+width,y+height); | |
1331 | } | |
ff910433 RR |
1332 | } |
1333 | ||
e4db172a | 1334 | void wxGnomePrintDC::makeEllipticalPath(wxCoord x, wxCoord y, |
74ab0bfb RR |
1335 | wxCoord width, wxCoord height) |
1336 | { | |
61643018 | 1337 | double r = 4 * (sqrt(2.) - 1) / 3; |
74ab0bfb RR |
1338 | double halfW = 0.5 * width, |
1339 | halfH = 0.5 * height, | |
1340 | halfWR = r * halfW, | |
1341 | halfHR = r * halfH; | |
1342 | wxCoord halfWI = (wxCoord) halfW, | |
1343 | halfHI = (wxCoord) halfH; | |
e4db172a | 1344 | |
ced3df77 | 1345 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
e4db172a | 1346 | |
74ab0bfb | 1347 | // Approximate an ellipse using four cubic splines, clockwise from 0 deg */ |
ced3df77 | 1348 | gs_libGnomePrint->gnome_print_moveto( m_gpc, |
e4db172a | 1349 | XLOG2DEV(x + width), |
74ab0bfb | 1350 | YLOG2DEV(y + halfHI) ); |
ced3df77 | 1351 | gs_libGnomePrint->gnome_print_curveto( m_gpc, |
74ab0bfb RR |
1352 | XLOG2DEV(x + width), |
1353 | YLOG2DEV(y + (wxCoord) rint (halfH + halfHR)), | |
e4db172a | 1354 | XLOG2DEV(x + (wxCoord) rint(halfW + halfWR)), |
74ab0bfb | 1355 | YLOG2DEV(y + height), |
e4db172a | 1356 | XLOG2DEV(x + halfWI), |
74ab0bfb | 1357 | YLOG2DEV(y + height) ); |
ced3df77 | 1358 | gs_libGnomePrint->gnome_print_curveto( m_gpc, |
e4db172a | 1359 | XLOG2DEV(x + (wxCoord) rint(halfW - halfWR)), |
74ab0bfb RR |
1360 | YLOG2DEV(y + height), |
1361 | XLOG2DEV(x), | |
1362 | YLOG2DEV(y + (wxCoord) rint (halfH + halfHR)), | |
1363 | XLOG2DEV(x), YLOG2DEV(y+halfHI) ); | |
ced3df77 | 1364 | gs_libGnomePrint->gnome_print_curveto( m_gpc, |
74ab0bfb RR |
1365 | XLOG2DEV(x), |
1366 | YLOG2DEV(y + (wxCoord) rint (halfH - halfHR)), | |
1367 | XLOG2DEV(x + (wxCoord) rint (halfW - halfWR)), | |
1368 | YLOG2DEV(y), | |
1369 | XLOG2DEV(x+halfWI), YLOG2DEV(y) ); | |
ced3df77 | 1370 | gs_libGnomePrint->gnome_print_curveto( m_gpc, |
74ab0bfb RR |
1371 | XLOG2DEV(x + (wxCoord) rint(halfW + halfWR)), |
1372 | YLOG2DEV(y), | |
1373 | XLOG2DEV(x + width), | |
1374 | YLOG2DEV(y + (wxCoord) rint(halfH - halfHR)), | |
1375 | XLOG2DEV(x + width), YLOG2DEV(y + halfHI) ); | |
e4db172a | 1376 | |
ced3df77 | 1377 | gs_libGnomePrint->gnome_print_closepath(m_gpc); |
74ab0bfb RR |
1378 | } |
1379 | ||
ff910433 RR |
1380 | void wxGnomePrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) |
1381 | { | |
728ddc45 RR |
1382 | width--; |
1383 | height--; | |
1384 | ||
cac7ac30 RR |
1385 | if (m_brush.GetStyle () != wxTRANSPARENT) |
1386 | { | |
1387 | SetBrush( m_brush ); | |
74ab0bfb | 1388 | makeEllipticalPath( x, y, width, height ); |
ced3df77 | 1389 | gs_libGnomePrint->gnome_print_fill( m_gpc ); |
cac7ac30 RR |
1390 | CalcBoundingBox( x, y ); |
1391 | CalcBoundingBox( x + width, y + height ); | |
1392 | } | |
1393 | ||
1394 | if (m_pen.GetStyle () != wxTRANSPARENT) | |
1395 | { | |
1396 | SetPen (m_pen); | |
74ab0bfb | 1397 | makeEllipticalPath( x, y, width, height ); |
ced3df77 | 1398 | gs_libGnomePrint->gnome_print_stroke( m_gpc ); |
cac7ac30 RR |
1399 | CalcBoundingBox( x, y ); |
1400 | CalcBoundingBox( x + width, y + height ); | |
1401 | } | |
ff910433 RR |
1402 | } |
1403 | ||
389076f1 | 1404 | #if wxUSE_SPLINES |
b0d7707b | 1405 | void wxGnomePrintDC::DoDrawSpline(const wxPointList *points) |
ff910433 | 1406 | { |
121c09cd RR |
1407 | SetPen (m_pen); |
1408 | ||
1409 | double c, d, x1, y1, x2, y2, x3, y3; | |
1410 | wxPoint *p, *q; | |
1411 | ||
b0d7707b RR |
1412 | wxPointList::compatibility_iterator node = points->GetFirst(); |
1413 | p = node->GetData(); | |
121c09cd RR |
1414 | x1 = p->x; |
1415 | y1 = p->y; | |
1416 | ||
1417 | node = node->GetNext(); | |
b0d7707b | 1418 | p = node->GetData(); |
121c09cd RR |
1419 | c = p->x; |
1420 | d = p->y; | |
1421 | x3 = | |
1422 | (double)(x1 + c) / 2; | |
1423 | y3 = | |
1424 | (double)(y1 + d) / 2; | |
1425 | ||
ced3df77 VZ |
1426 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
1427 | gs_libGnomePrint->gnome_print_moveto( m_gpc, XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1) ); | |
1428 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) ); | |
389076f1 | 1429 | |
121c09cd RR |
1430 | CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); |
1431 | CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); | |
1432 | ||
1433 | node = node->GetNext(); | |
1434 | while (node) | |
1435 | { | |
b0d7707b | 1436 | q = node->GetData(); |
121c09cd RR |
1437 | |
1438 | x1 = x3; | |
1439 | y1 = y3; | |
1440 | x2 = c; | |
1441 | y2 = d; | |
1442 | c = q->x; | |
1443 | d = q->y; | |
1444 | x3 = (double)(x2 + c) / 2; | |
1445 | y3 = (double)(y2 + d) / 2; | |
1446 | ||
ced3df77 | 1447 | gs_libGnomePrint->gnome_print_curveto(m_gpc, |
121c09cd RR |
1448 | XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1), |
1449 | XLOG2DEV((wxCoord)x2), YLOG2DEV((wxCoord)y2), | |
1450 | XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) ); | |
1451 | ||
1452 | CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); | |
1453 | CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); | |
1454 | ||
1455 | node = node->GetNext(); | |
1456 | } | |
389076f1 | 1457 | |
ced3df77 | 1458 | gs_libGnomePrint->gnome_print_lineto ( m_gpc, XLOG2DEV((wxCoord)c), YLOG2DEV((wxCoord)d) ); |
389076f1 | 1459 | |
ced3df77 | 1460 | gs_libGnomePrint->gnome_print_stroke( m_gpc ); |
ff910433 | 1461 | } |
389076f1 | 1462 | #endif // wxUSE_SPLINES |
ff910433 RR |
1463 | |
1464 | bool wxGnomePrintDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
1465 | wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, | |
1466 | wxCoord xsrcMask, wxCoord ysrcMask) | |
1467 | { | |
2f41910a RR |
1468 | wxCHECK_MSG( source, false, wxT("invalid source dc") ); |
1469 | ||
1470 | // blit into a bitmap | |
1471 | wxBitmap bitmap( width, height ); | |
1472 | wxMemoryDC memDC; | |
1473 | memDC.SelectObject(bitmap); | |
1474 | memDC.Blit(0, 0, width, height, source, xsrc, ysrc, rop); /* TODO: Blit transparently? */ | |
1475 | memDC.SelectObject(wxNullBitmap); | |
1476 | ||
1477 | // draw bitmap. scaling and positioning is done there | |
1478 | DrawBitmap( bitmap, xdest, ydest ); | |
1479 | ||
1480 | return true; | |
ff910433 RR |
1481 | } |
1482 | ||
1483 | void wxGnomePrintDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) | |
1484 | { | |
e1bf3ad3 | 1485 | DoDrawBitmap( icon, x, y, true ); |
ff910433 RR |
1486 | } |
1487 | ||
1488 | void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) | |
1489 | { | |
e1bf3ad3 | 1490 | if (!bitmap.Ok()) return; |
389076f1 | 1491 | |
e1bf3ad3 RR |
1492 | if (bitmap.HasPixbuf()) |
1493 | { | |
2934005d | 1494 | GdkPixbuf *pixbuf = bitmap.GetPixbuf(); |
389076f1 WS |
1495 | guchar *raw_image = gdk_pixbuf_get_pixels( pixbuf ); |
1496 | bool has_alpha = gdk_pixbuf_get_has_alpha( pixbuf ); | |
1497 | int rowstride = gdk_pixbuf_get_rowstride( pixbuf ); | |
1498 | int height = gdk_pixbuf_get_height( pixbuf ); | |
1499 | int width = gdk_pixbuf_get_width( pixbuf ); | |
1500 | ||
ced3df77 | 1501 | gs_libGnomePrint->gnome_print_gsave( m_gpc ); |
2934005d | 1502 | double matrix[6]; |
389076f1 WS |
1503 | matrix[0] = XLOG2DEVREL(width); |
1504 | matrix[1] = 0; | |
1505 | matrix[2] = 0; | |
1506 | matrix[3] = YLOG2DEVREL(height); | |
1507 | matrix[4] = XLOG2DEV(x); | |
2934005d | 1508 | matrix[5] = YLOG2DEV(y+height); |
ced3df77 VZ |
1509 | gs_libGnomePrint->gnome_print_concat( m_gpc, matrix ); |
1510 | gs_libGnomePrint->gnome_print_moveto( m_gpc, 0, 0 ); | |
2934005d | 1511 | if (has_alpha) |
ced3df77 | 1512 | gs_libGnomePrint->gnome_print_rgbaimage( m_gpc, (guchar *)raw_image, width, height, rowstride ); |
2934005d | 1513 | else |
ced3df77 VZ |
1514 | gs_libGnomePrint->gnome_print_rgbimage( m_gpc, (guchar *)raw_image, width, height, rowstride ); |
1515 | gs_libGnomePrint->gnome_print_grestore( m_gpc ); | |
e1bf3ad3 RR |
1516 | } |
1517 | else | |
e1bf3ad3 RR |
1518 | { |
1519 | wxImage image = bitmap.ConvertToImage(); | |
1520 | ||
1521 | if (!image.Ok()) return; | |
2934005d | 1522 | |
ced3df77 | 1523 | gs_libGnomePrint->gnome_print_gsave( m_gpc ); |
b4382784 | 1524 | double matrix[6]; |
389076f1 WS |
1525 | matrix[0] = XLOG2DEVREL(image.GetWidth()); |
1526 | matrix[1] = 0; | |
1527 | matrix[2] = 0; | |
1528 | matrix[3] = YLOG2DEVREL(image.GetHeight()); | |
1529 | matrix[4] = XLOG2DEV(x); | |
b4382784 | 1530 | matrix[5] = YLOG2DEV(y+image.GetHeight()); |
ced3df77 VZ |
1531 | gs_libGnomePrint->gnome_print_concat( m_gpc, matrix ); |
1532 | gs_libGnomePrint->gnome_print_moveto( m_gpc, 0, 0 ); | |
1533 | gs_libGnomePrint->gnome_print_rgbimage( m_gpc, (guchar*) image.GetData(), image.GetWidth(), image.GetHeight(), image.GetWidth()*3 ); | |
1534 | gs_libGnomePrint->gnome_print_grestore( m_gpc ); | |
e1bf3ad3 | 1535 | } |
ff910433 RR |
1536 | } |
1537 | ||
1538 | void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) | |
b199de59 RR |
1539 | { |
1540 | DoDrawRotatedText( text, x, y, 0.0 ); | |
1541 | } | |
1542 | ||
1543 | void wxGnomePrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) | |
ff910433 | 1544 | { |
02255e07 RR |
1545 | double xx = XLOG2DEV(x); |
1546 | double yy = YLOG2DEV(y); | |
389076f1 | 1547 | |
ff910433 RR |
1548 | bool underlined = m_font.Ok() && m_font.GetUnderlined(); |
1549 | ||
e0a050e3 VS |
1550 | // FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer |
1551 | #if wxUSE_UNICODE_UTF8 | |
1552 | const char *data = text.utf8_str(); | |
ff910433 | 1553 | #else |
e0a050e3 | 1554 | const wxCharBuffer data = text.utf8_str(); |
ff910433 RR |
1555 | #endif |
1556 | ||
e0a050e3 VS |
1557 | size_t datalen = strlen(data); |
1558 | pango_layout_set_text( m_layout, data, datalen); | |
389076f1 | 1559 | |
ff910433 RR |
1560 | if (underlined) |
1561 | { | |
1562 | PangoAttrList *attrs = pango_attr_list_new(); | |
1563 | PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); | |
1564 | a->start_index = 0; | |
1565 | a->end_index = datalen; | |
1566 | pango_attr_list_insert(attrs, a); | |
1567 | pango_layout_set_attributes(m_layout, attrs); | |
1568 | pango_attr_list_unref(attrs); | |
1569 | } | |
1570 | ||
2934005d RR |
1571 | if (m_textForegroundColour.Ok()) |
1572 | { | |
1573 | unsigned char red = m_textForegroundColour.Red(); | |
1574 | unsigned char blue = m_textForegroundColour.Blue(); | |
1575 | unsigned char green = m_textForegroundColour.Green(); | |
1576 | ||
b199de59 RR |
1577 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) |
1578 | { | |
1579 | double redPS = (double)(red) / 255.0; | |
1580 | double bluePS = (double)(blue) / 255.0; | |
1581 | double greenPS = (double)(green) / 255.0; | |
1582 | ||
ced3df77 | 1583 | gs_libGnomePrint->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS ); |
b199de59 RR |
1584 | |
1585 | m_currentRed = red; | |
1586 | m_currentBlue = blue; | |
1587 | m_currentGreen = green; | |
1588 | } | |
2934005d RR |
1589 | } |
1590 | ||
fa499247 | 1591 | int w,h; |
02255e07 | 1592 | pango_layout_get_pixel_size( m_layout, &w, &h ); |
fa499247 RR |
1593 | #if 0 |
1594 | if ( m_backgroundMode == wxSOLID ) | |
1595 | { | |
1596 | gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor()); | |
02255e07 | 1597 | gdk_draw_rectangle(m_window, m_textGC, TRUE, xx, yy, w, h); |
fa499247 RR |
1598 | gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor()); |
1599 | } | |
389076f1 | 1600 | #endif |
fa499247 | 1601 | |
02255e07 RR |
1602 | // Draw layout. |
1603 | gs_libGnomePrint->gnome_print_moveto (m_gpc, xx, yy); | |
1604 | ||
1605 | gs_libGnomePrint->gnome_print_gsave( m_gpc ); | |
1606 | ||
1607 | gs_libGnomePrint->gnome_print_scale( m_gpc, m_scaleX * DEV2PS, m_scaleY * DEV2PS ); | |
1608 | ||
1609 | if (fabs(angle) > 0.00001) | |
1610 | gs_libGnomePrint->gnome_print_rotate( m_gpc, angle ); | |
1611 | ||
1612 | gs_libGnomePrint->gnome_print_pango_layout( m_gpc, m_layout ); | |
1613 | ||
1614 | gs_libGnomePrint->gnome_print_grestore( m_gpc ); | |
1615 | ||
ff910433 RR |
1616 | if (underlined) |
1617 | { | |
1618 | // undo underline attributes setting: | |
1619 | pango_layout_set_attributes(m_layout, NULL); | |
1620 | } | |
389076f1 | 1621 | |
b199de59 | 1622 | CalcBoundingBox (x + w, y + h); |
ff910433 RR |
1623 | } |
1624 | ||
1625 | void wxGnomePrintDC::Clear() | |
1626 | { | |
1627 | } | |
1628 | ||
1629 | void wxGnomePrintDC::SetFont( const wxFont& font ) | |
1630 | { | |
1631 | m_font = font; | |
389076f1 | 1632 | |
ff910433 RR |
1633 | if (m_font.Ok()) |
1634 | { | |
1635 | if (m_fontdesc) | |
1636 | pango_font_description_free( m_fontdesc ); | |
389076f1 | 1637 | |
ff910433 | 1638 | m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); |
389076f1 | 1639 | |
ff910433 RR |
1640 | pango_layout_set_font_description( m_layout, m_fontdesc ); |
1641 | } | |
1642 | } | |
1643 | ||
1644 | void wxGnomePrintDC::SetPen( const wxPen& pen ) | |
1645 | { | |
1646 | if (!pen.Ok()) return; | |
1647 | ||
ff910433 RR |
1648 | m_pen = pen; |
1649 | ||
f62edb0e RR |
1650 | double width; |
1651 | ||
1652 | if (m_pen.GetWidth() <= 0) | |
1653 | width = 0.1; | |
1654 | else | |
1655 | width = (double) m_pen.GetWidth(); | |
1656 | ||
1657 | gs_libGnomePrint->gnome_print_setlinewidth( m_gpc, width * DEV2PS * m_scaleX ); | |
cac7ac30 RR |
1658 | |
1659 | static const double dotted[] = {2.0, 5.0}; | |
1660 | static const double short_dashed[] = {4.0, 4.0}; | |
1661 | static const double wxCoord_dashed[] = {4.0, 8.0}; | |
1662 | static const double dotted_dashed[] = {6.0, 6.0, 2.0, 6.0}; | |
1663 | ||
1664 | switch (m_pen.GetStyle()) | |
1665 | { | |
ced3df77 VZ |
1666 | case wxDOT: gs_libGnomePrint->gnome_print_setdash( m_gpc, 2, dotted, 0 ); break; |
1667 | case wxSHORT_DASH: gs_libGnomePrint->gnome_print_setdash( m_gpc, 2, short_dashed, 0 ); break; | |
1668 | case wxLONG_DASH: gs_libGnomePrint->gnome_print_setdash( m_gpc, 2, wxCoord_dashed, 0 ); break; | |
1669 | case wxDOT_DASH: gs_libGnomePrint->gnome_print_setdash( m_gpc, 4, dotted_dashed, 0 ); break; | |
e4db172a | 1670 | case wxUSER_DASH: |
8c419a5c RR |
1671 | { |
1672 | // It may be noted that libgnomeprint between at least | |
1673 | // versions 2.8.0 and 2.12.1 makes a copy of the dashes | |
1674 | // and then leak the memory since it doesn't set the | |
1675 | // internal flag "privatedash" to 0. | |
1676 | wxDash *wx_dashes; | |
1677 | int num = m_pen.GetDashes (&wx_dashes); | |
1678 | gdouble *g_dashes = g_new( gdouble, num ); | |
1679 | int i; | |
1680 | for (i = 0; i < num; ++i) | |
1681 | g_dashes[i] = (gdouble) wx_dashes[i]; | |
ced3df77 | 1682 | gs_libGnomePrint -> gnome_print_setdash( m_gpc, num, g_dashes, 0); |
8c419a5c RR |
1683 | g_free( g_dashes ); |
1684 | } | |
1685 | break; | |
cac7ac30 RR |
1686 | case wxSOLID: |
1687 | case wxTRANSPARENT: | |
ced3df77 | 1688 | default: gs_libGnomePrint->gnome_print_setdash( m_gpc, 0, NULL, 0 ); break; |
cac7ac30 RR |
1689 | } |
1690 | ||
389076f1 | 1691 | |
ff910433 RR |
1692 | unsigned char red = m_pen.GetColour().Red(); |
1693 | unsigned char blue = m_pen.GetColour().Blue(); | |
1694 | unsigned char green = m_pen.GetColour().Green(); | |
1695 | ||
1696 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) | |
1697 | { | |
1698 | double redPS = (double)(red) / 255.0; | |
1699 | double bluePS = (double)(blue) / 255.0; | |
1700 | double greenPS = (double)(green) / 255.0; | |
1701 | ||
ced3df77 | 1702 | gs_libGnomePrint->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS ); |
ff910433 RR |
1703 | |
1704 | m_currentRed = red; | |
1705 | m_currentBlue = blue; | |
1706 | m_currentGreen = green; | |
1707 | } | |
1708 | } | |
1709 | ||
1710 | void wxGnomePrintDC::SetBrush( const wxBrush& brush ) | |
1711 | { | |
fa499247 RR |
1712 | if (!brush.Ok()) return; |
1713 | ||
1714 | m_brush = brush; | |
1715 | ||
1716 | // Brush colour | |
1717 | unsigned char red = m_brush.GetColour().Red(); | |
1718 | unsigned char blue = m_brush.GetColour().Blue(); | |
1719 | unsigned char green = m_brush.GetColour().Green(); | |
1720 | ||
1721 | if (!m_colour) | |
1722 | { | |
1723 | // Anything not white is black | |
1724 | if (! (red == (unsigned char) 255 && | |
1725 | blue == (unsigned char) 255 && | |
1726 | green == (unsigned char) 255) ) | |
1727 | { | |
1728 | red = (unsigned char) 0; | |
1729 | green = (unsigned char) 0; | |
1730 | blue = (unsigned char) 0; | |
1731 | } | |
1732 | // setgray here ? | |
1733 | } | |
1734 | ||
1735 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) | |
1736 | { | |
1737 | double redPS = (double)(red) / 255.0; | |
1738 | double bluePS = (double)(blue) / 255.0; | |
1739 | double greenPS = (double)(green) / 255.0; | |
1740 | ||
ced3df77 | 1741 | gs_libGnomePrint->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS ); |
fa499247 RR |
1742 | |
1743 | m_currentRed = red; | |
1744 | m_currentBlue = blue; | |
1745 | m_currentGreen = green; | |
1746 | } | |
ff910433 RR |
1747 | } |
1748 | ||
1749 | void wxGnomePrintDC::SetLogicalFunction( int function ) | |
1750 | { | |
1751 | } | |
1752 | ||
1753 | void wxGnomePrintDC::SetBackground( const wxBrush& brush ) | |
1754 | { | |
1755 | } | |
1756 | ||
1757 | void wxGnomePrintDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
1758 | { | |
75aa53c9 RR |
1759 | wxDC::DoSetClippingRegion( x, y, width, height ); |
1760 | ||
ced3df77 | 1761 | gs_libGnomePrint->gnome_print_gsave( m_gpc ); |
3b7ab6bd | 1762 | |
ced3df77 VZ |
1763 | gs_libGnomePrint->gnome_print_newpath( m_gpc ); |
1764 | gs_libGnomePrint->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); | |
1765 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) ); | |
1766 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) ); | |
1767 | gs_libGnomePrint->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) ); | |
1768 | gs_libGnomePrint->gnome_print_closepath( m_gpc ); | |
1769 | gs_libGnomePrint->gnome_print_clip( m_gpc ); | |
ff910433 RR |
1770 | } |
1771 | ||
1772 | void wxGnomePrintDC::DestroyClippingRegion() | |
1773 | { | |
75aa53c9 RR |
1774 | wxDC::DestroyClippingRegion(); |
1775 | ||
ced3df77 | 1776 | gs_libGnomePrint->gnome_print_grestore( m_gpc ); |
3b7ab6bd RR |
1777 | |
1778 | #if 0 | |
1779 | // not needed, we set the values in each | |
1780 | // drawing method anyways | |
1781 | SetPen( m_pen ); | |
1782 | SetBrush( m_brush ); | |
1783 | SetFont( m_font ); | |
1784 | #endif | |
ff910433 RR |
1785 | } |
1786 | ||
1787 | bool wxGnomePrintDC::StartDoc(const wxString& message) | |
1788 | { | |
ff910433 RR |
1789 | return true; |
1790 | } | |
1791 | ||
1792 | void wxGnomePrintDC::EndDoc() | |
1793 | { | |
ced3df77 | 1794 | gs_libGnomePrint->gnome_print_end_doc( m_gpc ); |
ff910433 RR |
1795 | } |
1796 | ||
1797 | void wxGnomePrintDC::StartPage() | |
1798 | { | |
ced3df77 | 1799 | gs_libGnomePrint->gnome_print_beginpage( m_gpc, (const guchar*) "page" ); |
ff910433 RR |
1800 | } |
1801 | ||
1802 | void wxGnomePrintDC::EndPage() | |
1803 | { | |
ced3df77 | 1804 | gs_libGnomePrint->gnome_print_showpage( m_gpc ); |
ff910433 RR |
1805 | } |
1806 | ||
1807 | wxCoord wxGnomePrintDC::GetCharHeight() const | |
1808 | { | |
b199de59 | 1809 | pango_layout_set_text( m_layout, "H", 1 ); |
389076f1 | 1810 | |
b199de59 RR |
1811 | int w,h; |
1812 | pango_layout_get_pixel_size( m_layout, &w, &h ); | |
389076f1 | 1813 | |
b199de59 | 1814 | return h; |
ff910433 RR |
1815 | } |
1816 | ||
1817 | wxCoord wxGnomePrintDC::GetCharWidth() const | |
1818 | { | |
b199de59 | 1819 | pango_layout_set_text( m_layout, "H", 1 ); |
389076f1 | 1820 | |
b199de59 RR |
1821 | int w,h; |
1822 | pango_layout_get_pixel_size( m_layout, &w, &h ); | |
389076f1 | 1823 | |
b199de59 | 1824 | return w; |
ff910433 RR |
1825 | } |
1826 | ||
981a6af1 | 1827 | void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, |
ff910433 RR |
1828 | wxCoord *descent, |
1829 | wxCoord *externalLeading, | |
c94f845b | 1830 | const wxFont *theFont ) const |
ff910433 | 1831 | { |
981a6af1 RR |
1832 | if ( width ) |
1833 | *width = 0; | |
1834 | if ( height ) | |
1835 | *height = 0; | |
1836 | if ( descent ) | |
1837 | *descent = 0; | |
1838 | if ( externalLeading ) | |
1839 | *externalLeading = 0; | |
1840 | ||
389076f1 | 1841 | if (string.empty()) |
981a6af1 RR |
1842 | { |
1843 | return; | |
1844 | } | |
389076f1 | 1845 | |
981a6af1 | 1846 | // Set layout's text |
e0a050e3 VS |
1847 | |
1848 | // FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer | |
1849 | #if wxUSE_UNICODE_UTF8 | |
1850 | const char *dataUTF8 = string.utf8_str(); | |
981a6af1 | 1851 | #else |
e0a050e3 | 1852 | const wxCharBuffer dataUTF8 = string.utf8_str(); |
981a6af1 RR |
1853 | #endif |
1854 | ||
0cc0ce06 RR |
1855 | PangoFontDescription *desc = (theFont) ? theFont->GetNativeFontInfo()->description : m_fontdesc; |
1856 | ||
1857 | gint oldSize = pango_font_description_get_size( desc ); | |
1858 | double size = oldSize; | |
1859 | size = size * m_scaleY; | |
1860 | pango_font_description_set_size( desc, (gint)size ); | |
1861 | ||
1862 | // apply scaled font | |
1863 | pango_layout_set_font_description( m_layout, desc ); | |
1864 | ||
981a6af1 | 1865 | pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) ); |
389076f1 | 1866 | |
0cc0ce06 | 1867 | int w, h; |
981a6af1 | 1868 | pango_layout_get_pixel_size( m_layout, &w, &h ); |
389076f1 | 1869 | |
0cc0ce06 | 1870 | |
981a6af1 | 1871 | if (width) |
389076f1 | 1872 | *width = (wxCoord)(w / m_scaleX); |
981a6af1 | 1873 | if (height) |
15236815 | 1874 | *height = (wxCoord)(h / m_scaleY); |
0cc0ce06 | 1875 | |
981a6af1 RR |
1876 | if (descent) |
1877 | { | |
1878 | PangoLayoutIter *iter = pango_layout_get_iter(m_layout); | |
1879 | int baseline = pango_layout_iter_get_baseline(iter); | |
1880 | pango_layout_iter_free(iter); | |
1881 | *descent = h - PANGO_PIXELS(baseline); | |
1882 | } | |
389076f1 | 1883 | |
0cc0ce06 RR |
1884 | // reset unscaled size |
1885 | pango_font_description_set_size( desc, oldSize ); | |
1886 | ||
1887 | // reset unscaled font | |
1888 | pango_layout_set_font_description( m_layout, m_fontdesc ); | |
ff910433 RR |
1889 | } |
1890 | ||
1891 | void wxGnomePrintDC::DoGetSize(int* width, int* height) const | |
1892 | { | |
cffcf831 RR |
1893 | wxGnomePrintNativeData *native = |
1894 | (wxGnomePrintNativeData*) m_printData.GetNativeData(); | |
1895 | ||
1896 | // Query page size. This seems to omit the margins | |
cffcf831 | 1897 | double pw,ph; |
ced3df77 | 1898 | gs_libGnomePrint->gnome_print_job_get_page_size( native->GetPrintJob(), &pw, &ph ); |
ff910433 | 1899 | |
ff910433 | 1900 | if (width) |
02255e07 | 1901 | *width = wxRound( pw * PS2DEV ); |
f62edb0e | 1902 | |
ff910433 | 1903 | if (height) |
02255e07 | 1904 | *height = wxRound( ph * PS2DEV ); |
ff910433 RR |
1905 | } |
1906 | ||
1907 | void wxGnomePrintDC::DoGetSizeMM(int *width, int *height) const | |
1908 | { | |
cffcf831 RR |
1909 | wxGnomePrintNativeData *native = |
1910 | (wxGnomePrintNativeData*) m_printData.GetNativeData(); | |
1911 | ||
389076f1 WS |
1912 | // This code assumes values in Pts. |
1913 | ||
cffcf831 | 1914 | double pw,ph; |
ced3df77 | 1915 | gs_libGnomePrint->gnome_print_job_get_page_size( native->GetPrintJob(), &pw, &ph ); |
cffcf831 RR |
1916 | |
1917 | // Convert to mm. | |
389076f1 | 1918 | |
ced3df77 VZ |
1919 | const GnomePrintUnit *mm_unit = gs_libGnomePrint->gnome_print_unit_get_by_abbreviation( (const guchar*) "mm" ); |
1920 | const GnomePrintUnit *pts_unit = gs_libGnomePrint->gnome_print_unit_get_by_abbreviation( (const guchar*) "Pts" ); | |
1921 | gs_libGnomePrint->gnome_print_convert_distance( &pw, pts_unit, mm_unit ); | |
1922 | gs_libGnomePrint->gnome_print_convert_distance( &ph, pts_unit, mm_unit ); | |
389076f1 | 1923 | |
ff910433 | 1924 | if (width) |
cffcf831 | 1925 | *width = (int) (pw + 0.5); |
ff910433 | 1926 | if (height) |
cffcf831 | 1927 | *height = (int) (ph + 0.5); |
ff910433 RR |
1928 | } |
1929 | ||
1930 | wxSize wxGnomePrintDC::GetPPI() const | |
1931 | { | |
02255e07 | 1932 | return wxSize(DPI,DPI); |
92120c6e RR |
1933 | } |
1934 | ||
3b7ab6bd RR |
1935 | void wxGnomePrintDC::SetPrintData(const wxPrintData& data) |
1936 | { | |
1937 | m_printData = data; | |
1938 | ||
02255e07 | 1939 | int height; |
3b7ab6bd | 1940 | if (m_printData.GetOrientation() == wxPORTRAIT) |
02255e07 | 1941 | GetSize( NULL, &height ); |
3b7ab6bd | 1942 | else |
02255e07 RR |
1943 | GetSize( &height, NULL ); |
1944 | m_deviceLocalOriginY = height; | |
3b7ab6bd RR |
1945 | } |
1946 | ||
ff910433 RR |
1947 | void wxGnomePrintDC::SetResolution(int ppi) |
1948 | { | |
1949 | } | |
1950 | ||
1951 | int wxGnomePrintDC::GetResolution() | |
1952 | { | |
02255e07 | 1953 | return DPI; |
ff910433 | 1954 | } |
7c72311f | 1955 | |
1ff62f51 RR |
1956 | // ---------------------------------------------------------------------------- |
1957 | // wxGnomePrintModule | |
1958 | // ---------------------------------------------------------------------------- | |
58c30cd8 | 1959 | |
c6efd6e0 RR |
1960 | bool wxGnomePrintModule::OnInit() |
1961 | { | |
ced3df77 VZ |
1962 | gs_libGnomePrint = new wxGnomePrintLibrary; |
1963 | if (gs_libGnomePrint->IsOk()) | |
c6efd6e0 RR |
1964 | wxPrintFactory::SetPrintFactory( new wxGnomePrintFactory ); |
1965 | return true; | |
1966 | } | |
1967 | ||
1968 | void wxGnomePrintModule::OnExit() | |
1969 | { | |
ced3df77 VZ |
1970 | delete gs_libGnomePrint; |
1971 | gs_libGnomePrint = NULL; | |
c6efd6e0 RR |
1972 | } |
1973 | ||
58c30cd8 | 1974 | IMPLEMENT_DYNAMIC_CLASS(wxGnomePrintModule, wxModule) |
389076f1 | 1975 | |
147bf263 JS |
1976 | // ---------------------------------------------------------------------------- |
1977 | // Print preview | |
1978 | // ---------------------------------------------------------------------------- | |
1979 | ||
1980 | IMPLEMENT_CLASS(wxGnomePrintPreview, wxPrintPreviewBase) | |
1981 | ||
1982 | void wxGnomePrintPreview::Init(wxPrintout * WXUNUSED(printout), | |
1983 | wxPrintout * WXUNUSED(printoutForPrinting)) | |
1984 | { | |
1985 | DetermineScaling(); | |
1986 | } | |
1987 | ||
1988 | wxGnomePrintPreview::wxGnomePrintPreview(wxPrintout *printout, | |
1989 | wxPrintout *printoutForPrinting, | |
1990 | wxPrintDialogData *data) | |
1991 | : wxPrintPreviewBase(printout, printoutForPrinting, data) | |
1992 | { | |
1993 | Init(printout, printoutForPrinting); | |
1994 | } | |
1995 | ||
1996 | wxGnomePrintPreview::wxGnomePrintPreview(wxPrintout *printout, | |
1997 | wxPrintout *printoutForPrinting, | |
1998 | wxPrintData *data) | |
1999 | : wxPrintPreviewBase(printout, printoutForPrinting, data) | |
2000 | { | |
2001 | Init(printout, printoutForPrinting); | |
2002 | } | |
2003 | ||
2004 | wxGnomePrintPreview::~wxGnomePrintPreview() | |
2005 | { | |
2006 | } | |
2007 | ||
2008 | bool wxGnomePrintPreview::Print(bool interactive) | |
2009 | { | |
2010 | if (!m_printPrintout) | |
2011 | return false; | |
2012 | ||
2013 | wxPrinter printer(& m_printDialogData); | |
2014 | return printer.Print(m_previewFrame, m_printPrintout, interactive); | |
2015 | } | |
2016 | ||
2017 | void wxGnomePrintPreview::DetermineScaling() | |
2018 | { | |
2019 | wxPaperSize paperType = m_printDialogData.GetPrintData().GetPaperId(); | |
2020 | if (paperType == wxPAPER_NONE) | |
2021 | paperType = wxPAPER_NONE; | |
2022 | ||
2023 | wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType); | |
2024 | if (!paper) | |
2025 | paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); | |
2026 | ||
2027 | if (paper) | |
2028 | { | |
2029 | wxSize ScreenPixels = wxGetDisplaySize(); | |
2030 | wxSize ScreenMM = wxGetDisplaySizeMM(); | |
2031 | ||
2032 | m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()), | |
2033 | (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) ); | |
2034 | m_previewPrintout->SetPPIPrinter(wxGnomePrintDC::GetResolution(), wxGnomePrintDC::GetResolution()); | |
2035 | ||
2036 | wxSize sizeDevUnits(paper->GetSizeDeviceUnits()); | |
f4322df6 | 2037 | |
147bf263 JS |
2038 | // TODO: get better resolution information from wxGnomePrintDC, if possible. |
2039 | ||
2040 | sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * wxGnomePrintDC::GetResolution() / 72.0); | |
2041 | sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * wxGnomePrintDC::GetResolution() / 72.0); | |
2042 | wxSize sizeTenthsMM(paper->GetSize()); | |
2043 | wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10); | |
2044 | ||
2045 | // If in landscape mode, we need to swap the width and height. | |
2046 | if ( m_printDialogData.GetPrintData().GetOrientation() == wxLANDSCAPE ) | |
2047 | { | |
2048 | m_pageWidth = sizeDevUnits.y; | |
2049 | m_pageHeight = sizeDevUnits.x; | |
2050 | m_previewPrintout->SetPageSizeMM(sizeMM.y, sizeMM.x); | |
147bf263 JS |
2051 | } |
2052 | else | |
2053 | { | |
2054 | m_pageWidth = sizeDevUnits.x; | |
2055 | m_pageHeight = sizeDevUnits.y; | |
2056 | m_previewPrintout->SetPageSizeMM(sizeMM.x, sizeMM.y); | |
147bf263 | 2057 | } |
f415cab9 JS |
2058 | m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight); |
2059 | m_previewPrintout->SetPaperRectPixels(wxRect(0, 0, m_pageWidth, m_pageHeight)); | |
147bf263 JS |
2060 | |
2061 | // At 100%, the page should look about page-size on the screen. | |
f415cab9 JS |
2062 | m_previewScaleX = (float)0.8 * 72.0 / (float)wxGnomePrintDC::GetResolution(); |
2063 | m_previewScaleY = m_previewScaleX; | |
147bf263 JS |
2064 | } |
2065 | } | |
2066 | ||
32f34982 RR |
2067 | #endif |
2068 | // wxUSE_LIBGNOMEPRINT |