]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/gnome/gprint.cpp
adding core services and increase Universal Header min req
[wxWidgets.git] / src / gtk1 / gnome / gprint.cpp
CommitLineData
ff910433 1/////////////////////////////////////////////////////////////////////////////
f85b45fb
RR
2// Name: gprint.cpp
3// Author: Robert Roebling
4// Purpose: Implement GNOME printing support
5// Created: 09/20/04
6// Copyright: Robert Roebling
7// Licence: wxWindows Licence
ff910433
RR
8/////////////////////////////////////////////////////////////////////////////
9
58c30cd8
RR
10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11#pragma implementation "gprint.h"
ff910433
RR
12#endif
13
14// For compilers that support precompilation, includes "wx/wx.h".
15#include "wx/wxprec.h"
16
17#ifdef __BORLANDC__
18 #pragma hdrstop
19#endif
20
7c72311f
RR
21#include "wx/gtk/gnome/gprint.h"
22
23#if wxUSE_LIBGNOMEPRINT
24
463c4d71 25#include "wx/math.h"
ff910433
RR
26#include "wx/fontutil.h"
27#include "wx/printdlg.h"
28#include "wx/gtk/private.h"
08680429 29#include "wx/module.h"
06cfd325 30#include "wx/generic/prntdlgg.h"
c6efd6e0 31#include "wx/dynlib.h"
ff910433
RR
32
33#include <libgnomeprint/gnome-print.h>
34#include <libgnomeprint/gnome-print-pango.h>
06cfd325 35#include <libgnomeprint/gnome-print-config.h>
ff910433 36#include <libgnomeprintui/gnome-print-dialog.h>
0be7709e 37#include <libgnomeprintui/gnome-print-job-preview.h>
08680429 38#include <libgnomeprintui/gnome-print-paper-selector.h>
ff910433 39
d6c6acd6
RR
40
41#include "wx/html/forcelnk.h"
42FORCE_LINK_ME(gnome_print)
43
c6efd6e0
RR
44//----------------------------------------------------------------------------
45// wxGnomePrintLibrary
46//----------------------------------------------------------------------------
47
48#define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \
49 typedef rettype (* name ## Type) args ; \
50 name ## Type pfn_ ## name; \
51 rettype name args \
52 { if (m_ok) return pfn_ ## name shortargs ; return defret; }
53
54#define wxDL_METHOD_LOAD( lib, name, success ) \
55 pfn_ ## name = (name ## Type) lib->GetSymbol( wxT(#name), &success ); \
56 if (!success) return;
57
58class wxGnomePrintLibrary
59{
60public:
61 wxGnomePrintLibrary();
62 ~wxGnomePrintLibrary();
63
64 bool IsOk();
65 void InitializeMethods();
66
67private:
68 bool m_ok;
69 wxDynamicLibrary *m_gnome_print_lib;
59c73be8 70 wxDynamicLibrary *m_gnome_printui_lib;
c6efd6e0
RR
71
72public:
73 wxDL_METHOD_DEFINE( gint, gnome_print_newpath,
74 (GnomePrintContext *pc), (pc), 0 )
75 wxDL_METHOD_DEFINE( gint, gnome_print_moveto,
76 (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
77 wxDL_METHOD_DEFINE( gint, gnome_print_lineto,
78 (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 )
79 wxDL_METHOD_DEFINE( gint, gnome_print_curveto,
80 (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3), (pc, x1, y1, x2, y2, x3, y3), 0 )
81 wxDL_METHOD_DEFINE( gint, gnome_print_closepath,
82 (GnomePrintContext *pc), (pc), 0 )
83 wxDL_METHOD_DEFINE( gint, gnome_print_stroke,
84 (GnomePrintContext *pc), (pc), 0 )
85 wxDL_METHOD_DEFINE( gint, gnome_print_fill,
86 (GnomePrintContext *pc), (pc), 0 )
87 wxDL_METHOD_DEFINE( gint, gnome_print_setrgbcolor,
88 (GnomePrintContext *pc, gdouble r, gdouble g, gdouble b), (pc, r, g, b), 0 )
89 wxDL_METHOD_DEFINE( gint, gnome_print_setlinewidth,
90 (GnomePrintContext *pc, gdouble width), (pc, width), 0 )
59c73be8
RR
91 wxDL_METHOD_DEFINE( gint, gnome_print_setdash,
92 (GnomePrintContext *pc, gint n_values, const gdouble *values, gdouble offset), (pc, n_values, values, offset), 0 )
93
94 wxDL_METHOD_DEFINE( gint, gnome_print_rgbimage,
95 (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 )
96 wxDL_METHOD_DEFINE( gint, gnome_print_rgbaimage,
97 (GnomePrintContext *pc, const guchar *data, gint width, gint height, gint rowstride), (pc, data, width, height, rowstride ), 0 )
98
99 wxDL_METHOD_DEFINE( gint, gnome_print_concat,
100 (GnomePrintContext *pc, const gdouble *matrix), (pc, matrix), 0 )
101 wxDL_METHOD_DEFINE( gint, gnome_print_scale,
102 (GnomePrintContext *pc, gdouble sx, gdouble sy), (pc, sx, sy), 0 )
103 wxDL_METHOD_DEFINE( gint, gnome_print_rotate,
104 (GnomePrintContext *pc, gdouble theta), (pc, theta), 0 )
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 )
110
111 wxDL_METHOD_DEFINE( gint, gnome_print_beginpage,
112 (GnomePrintContext *pc, const guchar* name), (pc, name), 0 )
113 wxDL_METHOD_DEFINE( gint, gnome_print_showpage,
114 (GnomePrintContext *pc), (pc), 0 )
115 wxDL_METHOD_DEFINE( gint, gnome_print_end_doc,
116 (GnomePrintContext *pc), (pc), 0 )
117
118 wxDL_METHOD_DEFINE( PangoLayout*, gnome_print_pango_create_layout,
119 (GnomePrintContext *gpc), (gpc), NULL )
120 wxDL_METHOD_DEFINE( void, gnome_print_pango_layout,
121 (GnomePrintContext *gpc, PangoLayout *layout), (gpc, layout), /**/ )
122
123 wxDL_METHOD_DEFINE( GnomePrintJob*, gnome_print_job_new,
124 (GnomePrintConfig *config), (config), NULL )
125 wxDL_METHOD_DEFINE( GnomePrintContext*, gnome_print_job_get_context,
126 (GnomePrintJob *job), (job), NULL )
127 wxDL_METHOD_DEFINE( gint, gnome_print_job_close,
128 (GnomePrintJob *job), (job), 0 )
129 wxDL_METHOD_DEFINE( gint, gnome_print_job_print,
130 (GnomePrintJob *job), (job), 0 )
131 wxDL_METHOD_DEFINE( gboolean, gnome_print_job_get_page_size,
132 (GnomePrintJob *job, gdouble *width, gdouble *height), (job, width, height), 0 )
133
134 wxDL_METHOD_DEFINE( GnomePrintUnit*, gnome_print_unit_get_by_abbreviation,
135 (const guchar *abbreviation), (abbreviation), NULL )
136 wxDL_METHOD_DEFINE( gboolean, gnome_print_convert_distance,
137 (gdouble *distance, const GnomePrintUnit *from, const GnomePrintUnit *to), (distance, from, to), false )
138
139 wxDL_METHOD_DEFINE( GnomePrintConfig*, gnome_print_config_default,
140 (void), (), NULL )
141 wxDL_METHOD_DEFINE( gboolean, gnome_print_config_set,
142 (GnomePrintConfig *config, const guchar *key, const guchar *value), (config, key, value), false )
143 wxDL_METHOD_DEFINE( gboolean, gnome_print_config_get_length,
144 (GnomePrintConfig *config, const guchar *key, gdouble *val, const GnomePrintUnit **unit), (config, key, val, unit), false )
145
146 wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_dialog_new,
147 (GnomePrintJob *gpj, const guchar *title, gint flags), (gpj, title, flags), NULL )
148 wxDL_METHOD_DEFINE( void, gnome_print_dialog_construct_range_page,
149 (GnomePrintDialog *gpd, gint flags, gint start, gint end,
150 const guchar *currentlabel, const guchar *rangelabel),
151 (gpd, flags, start, end, currentlabel, rangelabel), /**/ )
152 wxDL_METHOD_DEFINE( void, gnome_print_dialog_get_copies,
153 (GnomePrintDialog *gpd, gint *copies, gboolean *collate), (gpd, copies, collate), /**/ )
154 wxDL_METHOD_DEFINE( void, gnome_print_dialog_set_copies,
155 (GnomePrintDialog *gpd, gint copies, gint collate), (gpd, copies, collate), /**/ )
156 wxDL_METHOD_DEFINE( GnomePrintRangeType, gnome_print_dialog_get_range,
157 (GnomePrintDialog *gpd), (gpd), GNOME_PRINT_RANGETYPE_NONE )
158 wxDL_METHOD_DEFINE( int, gnome_print_dialog_get_range_page,
159 (GnomePrintDialog *gpd, gint *start, gint *end), (gpd, start, end), 0 )
160
161 wxDL_METHOD_DEFINE( GtkWidget*, gnome_paper_selector_new_with_flags,
162 (GnomePrintConfig *config, gint flags), (config, flags), NULL )
163
164 wxDL_METHOD_DEFINE( GtkWidget*, gnome_print_job_preview_new,
165 (GnomePrintJob *gpm, const guchar *title), (gpm, title), NULL )
c6efd6e0
RR
166};
167
168wxGnomePrintLibrary::wxGnomePrintLibrary()
169{
59c73be8
RR
170 m_gnome_print_lib = NULL;
171 m_gnome_printui_lib = NULL;
172
c6efd6e0 173 wxLogNull log;
59c73be8 174
a92964a2 175 m_gnome_print_lib = new wxDynamicLibrary( wxT("libgnomeprint-2-2.so.0") );
c6efd6e0 176 m_ok = m_gnome_print_lib->IsLoaded();
59c73be8
RR
177 if (!m_ok) return;
178
a92964a2 179 m_gnome_printui_lib = new wxDynamicLibrary( wxT("libgnomeprintui-2-2.so.0") );
59c73be8
RR
180 m_ok = m_gnome_printui_lib->IsLoaded();
181 if (!m_ok) return;
c6efd6e0 182
59c73be8 183 InitializeMethods();
c6efd6e0
RR
184}
185
186wxGnomePrintLibrary::~wxGnomePrintLibrary()
187{
59c73be8
RR
188 if (m_gnome_print_lib)
189 delete m_gnome_print_lib;
190 if (m_gnome_printui_lib)
191 delete m_gnome_printui_lib;
c6efd6e0
RR
192}
193
194bool wxGnomePrintLibrary::IsOk()
195{
196 return m_ok;
197}
198
199void wxGnomePrintLibrary::InitializeMethods()
200{
201 m_ok = false;
202 bool success;
203
204 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_newpath, success )
205 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_moveto, success )
206 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_lineto, success )
207 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_curveto, success )
208 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_closepath, success )
209 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_stroke, success )
210 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_fill, success )
211 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setrgbcolor, success )
212 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setlinewidth, success )
59c73be8
RR
213 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_setdash, success )
214
215 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rgbimage, success )
216 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rgbaimage, success )
217
218 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_concat, success )
219 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_scale, success )
220 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rotate, success )
221
222 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_gsave, success )
223 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_grestore, success )
224
225 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_beginpage, success )
226 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_showpage, success )
227 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_end_doc, success )
228
229 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_pango_create_layout, success )
230 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_pango_layout, success )
231
232 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_new, success )
233 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_get_context, success )
234 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_close, success )
235 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_print, success )
236 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_job_get_page_size, success )
237
238 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_unit_get_by_abbreviation, success )
239 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_convert_distance, success )
240
241 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_default, success )
242 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_set, success )
243 wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_config_get_length, success )
244
245 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_new, success )
246 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_construct_range_page, success )
247 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_copies, success )
248 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_set_copies, success )
249 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_range, success )
250 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_dialog_get_range_page, success )
251
252 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_paper_selector_new_with_flags, success )
253
254 wxDL_METHOD_LOAD( m_gnome_printui_lib, gnome_print_job_preview_new, success )
255
c6efd6e0
RR
256 m_ok = true;
257}
258
259static wxGnomePrintLibrary* gs_lgp = NULL;
260
ff910433
RR
261//----------------------------------------------------------------------------
262// wxGnomePrintNativeData
263//----------------------------------------------------------------------------
264
265IMPLEMENT_CLASS(wxGnomePrintNativeData, wxPrintNativeDataBase)
266
267wxGnomePrintNativeData::wxGnomePrintNativeData()
268{
59c73be8
RR
269 m_config = gs_lgp->gnome_print_config_default();
270 m_job = gs_lgp->gnome_print_job_new( m_config );
ff910433
RR
271}
272
273wxGnomePrintNativeData::~wxGnomePrintNativeData()
274{
275 g_object_unref (G_OBJECT (m_config));
ff910433
RR
276}
277
278bool wxGnomePrintNativeData::TransferTo( wxPrintData &data )
279{
280 // TODO
281 return true;
282}
283
284bool wxGnomePrintNativeData::TransferFrom( const wxPrintData &data )
285{
286 // TODO
287 return true;
288}
289
290//----------------------------------------------------------------------------
291// wxGnomePrintFactory
292//----------------------------------------------------------------------------
293
294wxPrinterBase* wxGnomePrintFactory::CreatePrinter( wxPrintDialogData *data )
295{
296 return new wxGnomePrinter( data );
297}
298
299wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview,
300 wxPrintout *printout,
301 wxPrintDialogData *data )
302{
303 return new wxPostScriptPrintPreview( preview, printout, data );
304}
305
306wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview,
307 wxPrintout *printout,
308 wxPrintData *data )
309{
310 return new wxPostScriptPrintPreview( preview, printout, data );
311}
312
313wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
314 wxPrintDialogData *data )
315{
2934005d 316 return new wxGnomePrintDialog( parent, data );
ff910433
RR
317}
318
319wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent,
320 wxPrintData *data )
321{
2934005d 322 return new wxGnomePrintDialog( parent, data );
ff910433
RR
323}
324
08680429
RR
325wxPageSetupDialogBase *wxGnomePrintFactory::CreatePageSetupDialog( wxWindow *parent,
326 wxPageSetupDialogData * data )
06cfd325
RR
327{
328// The native page setup dialog is broken. It
329// miscalculates newly entered values for the
330// margins if you have not chose "points" but
cffcf831
RR
331// e.g. centimerters.
332// This has been fixed in GNOME CVS (maybe
333// fixed in libgnomeprintui 2.8.1)
06cfd325 334
cffcf831 335 return new wxGnomePageSetupDialog( parent, data );
08680429
RR
336}
337
ff910433
RR
338bool wxGnomePrintFactory::HasPrintSetupDialog()
339{
2934005d 340 return false;
ff910433
RR
341}
342
343wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data )
344{
2934005d 345 return NULL;
ff910433
RR
346}
347
348bool wxGnomePrintFactory::HasOwnPrintToFile()
349{
350 return true;
351}
352
353bool wxGnomePrintFactory::HasPrinterLine()
354{
355 return true;
356}
357
358wxString wxGnomePrintFactory::CreatePrinterLine()
359{
2934005d
RR
360 // redundant now
361 return wxEmptyString;
ff910433
RR
362}
363
364bool wxGnomePrintFactory::HasStatusLine()
365{
2934005d 366 // redundant now
ff910433
RR
367 return true;
368}
369
370wxString wxGnomePrintFactory::CreateStatusLine()
371{
2934005d
RR
372 // redundant now
373 return wxEmptyString;
ff910433
RR
374}
375
376wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData()
377{
378 return new wxGnomePrintNativeData;
379}
380
381//----------------------------------------------------------------------------
382// wxGnomePrintSetupDialog
383//----------------------------------------------------------------------------
384
2934005d
RR
385IMPLEMENT_CLASS(wxGnomePrintDialog, wxPrintDialogBase)
386
387wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintDialogData *data )
388 : wxPrintDialogBase(parent, wxID_ANY, _("Print"),
389 wxPoint(0, 0), wxSize(600, 600),
390 wxDEFAULT_DIALOG_STYLE |
391 wxTAB_TRAVERSAL)
392{
393 if (data)
394 m_printDialogData = *data;
395
396 Init();
397}
398
399wxGnomePrintDialog::wxGnomePrintDialog( wxWindow *parent, wxPrintData *data )
400 : wxPrintDialogBase(parent, wxID_ANY, _("Print"),
401 wxPoint(0, 0), wxSize(600, 600),
402 wxDEFAULT_DIALOG_STYLE |
403 wxTAB_TRAVERSAL)
404{
405 if (data)
406 m_printDialogData = *data;
407
408 Init();
409}
ff910433 410
2934005d 411void wxGnomePrintDialog::Init()
ff910433 412{
2934005d
RR
413 wxPrintData data = m_printDialogData.GetPrintData();
414
ff910433 415 wxGnomePrintNativeData *native =
2934005d 416 (wxGnomePrintNativeData*) data.GetNativeData();
ff910433 417
59c73be8 418 m_widget = gs_lgp->gnome_print_dialog_new( native->GetPrintJob(),
2934005d
RR
419 (guchar*)"Print",
420 GNOME_PRINT_DIALOG_RANGE|GNOME_PRINT_DIALOG_COPIES );
b199de59
RR
421
422 int flag = 0;
423 if (m_printDialogData.GetEnableSelection())
424 flag |= GNOME_PRINT_RANGE_SELECTION;
425 if (m_printDialogData.GetEnablePageNumbers())
426 flag |= GNOME_PRINT_RANGE_ALL|GNOME_PRINT_RANGE_RANGE;
427
59c73be8 428 gs_lgp->gnome_print_dialog_construct_range_page( (GnomePrintDialog*) m_widget,
b199de59
RR
429 flag,
430 m_printDialogData.GetMinPage(),
431 m_printDialogData.GetMaxPage(),
432 NULL,
433 NULL );
ff910433
RR
434}
435
2934005d 436wxGnomePrintDialog::~wxGnomePrintDialog()
ff910433
RR
437{
438 m_widget = NULL;
439}
440
2934005d 441int wxGnomePrintDialog::ShowModal()
ff910433 442{
2934005d
RR
443 // Transfer data from m_printDalogData to dialog here
444
ff910433 445 int response = gtk_dialog_run (GTK_DIALOG (m_widget));
ff910433
RR
446
447 if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL)
b199de59
RR
448 {
449 gtk_widget_destroy(m_widget);
450 m_widget = NULL;
451
ff910433 452 return wxID_CANCEL;
b199de59 453 }
ff910433 454
b199de59
RR
455 gint copies = 1;
456 gboolean collate = false;
59c73be8 457 gs_lgp->gnome_print_dialog_get_copies( (GnomePrintDialog*) m_widget, &copies, &collate );
b199de59
RR
458 m_printDialogData.SetNoCopies( copies );
459 m_printDialogData.SetCollate( collate );
2934005d 460
59c73be8 461 switch (gs_lgp->gnome_print_dialog_get_range( (GnomePrintDialog*) m_widget ))
b199de59
RR
462 {
463 case GNOME_PRINT_RANGE_SELECTION:
464 m_printDialogData.SetSelection( true );
465 break;
466 case GNOME_PRINT_RANGE_ALL:
467 m_printDialogData.SetAllPages( true );
468 m_printDialogData.SetFromPage( 0 );
469 m_printDialogData.SetToPage( 9999 );
470 break;
471 case GNOME_PRINT_RANGE_RANGE:
472 default:
473 gint start,end;
59c73be8 474 gs_lgp->gnome_print_dialog_get_range_page( (GnomePrintDialog*) m_widget, &start, &end );
b199de59
RR
475 m_printDialogData.SetFromPage( start );
476 m_printDialogData.SetToPage( end );
477 break;
478 }
479
480 gtk_widget_destroy(m_widget);
481 m_widget = NULL;
482
0be7709e
RR
483 if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW)
484 return wxID_PREVIEW;
485
ff910433
RR
486 return wxID_OK;
487}
488
2934005d 489wxDC *wxGnomePrintDialog::GetPrintDC()
ff910433 490{
2934005d
RR
491 // Later
492 return NULL;
ff910433
RR
493}
494
2934005d 495bool wxGnomePrintDialog::Validate()
ff910433
RR
496{
497 return true;
498}
499
2934005d 500bool wxGnomePrintDialog::TransferDataToWindow()
ff910433
RR
501{
502 return true;
503}
504
2934005d
RR
505bool wxGnomePrintDialog::TransferDataFromWindow()
506{
507 return true;
508}
ff910433 509
08680429
RR
510//----------------------------------------------------------------------------
511// wxGnomePageSetupDialog
512//----------------------------------------------------------------------------
513
514IMPLEMENT_CLASS(wxGnomePageSetupDialog, wxPageSetupDialogBase)
515
516wxGnomePageSetupDialog::wxGnomePageSetupDialog( wxWindow *parent,
517 wxPageSetupDialogData* data )
518{
519 if (data)
520 m_pageDialogData = *data;
521
522 wxGnomePrintNativeData *native =
523 (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData();
cffcf831
RR
524
525 // This is required as the page setup dialog
526 // calculates wrong values otherwise.
59c73be8 527 gs_lgp->gnome_print_config_set( native->GetPrintConfig(),
cffcf831
RR
528 (const guchar*) GNOME_PRINT_KEY_PREFERED_UNIT,
529 (const guchar*) "Pts" );
08680429
RR
530
531 m_widget = gtk_dialog_new();
532
533 gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( _("Page setup") ) );
cffcf831 534
59c73be8 535 GtkWidget *main = gs_lgp->gnome_paper_selector_new_with_flags( native->GetPrintConfig(),
08680429
RR
536 GNOME_PAPER_SELECTOR_MARGINS|GNOME_PAPER_SELECTOR_FEED_ORIENTATION );
537 gtk_container_set_border_width (GTK_CONTAINER (main), 8);
538 gtk_widget_show (main);
539
540 gtk_container_add( GTK_CONTAINER (GTK_DIALOG (m_widget)->vbox), main );
541
542 gtk_dialog_set_has_separator (GTK_DIALOG (m_widget), TRUE);
543
544 gtk_dialog_add_buttons (GTK_DIALOG (m_widget),
545 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
546 GTK_STOCK_OK, GTK_RESPONSE_OK,
547 NULL);
548
549 gtk_dialog_set_default_response (GTK_DIALOG (m_widget),
550 GTK_RESPONSE_OK);
551}
552
553wxGnomePageSetupDialog::~wxGnomePageSetupDialog()
554{
555}
556
557wxPageSetupDialogData& wxGnomePageSetupDialog::GetPageSetupDialogData()
558{
559 return m_pageDialogData;
560}
561
562int wxGnomePageSetupDialog::ShowModal()
563{
06cfd325
RR
564 wxGnomePrintNativeData *native =
565 (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData();
566 GnomePrintConfig *config = native->GetPrintConfig();
567
08680429
RR
568 // Transfer data from m_pageDialogData to native dialog
569
570 int ret = gtk_dialog_run( GTK_DIALOG(m_widget) );
571
572 if (ret == GTK_RESPONSE_OK)
573 {
574 // Transfer data back to m_pageDialogData
cffcf831
RR
575
576 // I don't know how querying the last parameter works
577 // I cannot test it as the dialog is currently broken
578 // anyways (it only works for points).
06cfd325 579 double ml,mr,mt,mb,pw,ph;
59c73be8 580 gs_lgp->gnome_print_config_get_length (config,
06cfd325 581 (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &ml, NULL);
59c73be8 582 gs_lgp->gnome_print_config_get_length (config,
06cfd325 583 (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &mr, NULL);
59c73be8 584 gs_lgp->gnome_print_config_get_length (config,
06cfd325 585 (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &mt, NULL);
59c73be8 586 gs_lgp->gnome_print_config_get_length (config,
06cfd325 587 (const guchar*) GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &mb, NULL);
59c73be8 588 gs_lgp->gnome_print_config_get_length (config,
06cfd325 589 (const guchar*) GNOME_PRINT_KEY_PAPER_WIDTH, &pw, NULL);
59c73be8 590 gs_lgp->gnome_print_config_get_length (config,
06cfd325 591 (const guchar*) GNOME_PRINT_KEY_PAPER_HEIGHT, &ph, NULL);
cffcf831
RR
592
593 // This probably assumes that the user entered the
594 // values in Pts. Since that is the only the dialog
595 // works right now, we need to fix this later.
59c73be8
RR
596 const GnomePrintUnit *mm_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "mm" );
597 const GnomePrintUnit *pts_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "Pts" );
598 gs_lgp->gnome_print_convert_distance( &ml, pts_unit, mm_unit );
599 gs_lgp->gnome_print_convert_distance( &mr, pts_unit, mm_unit );
600 gs_lgp->gnome_print_convert_distance( &mt, pts_unit, mm_unit );
601 gs_lgp->gnome_print_convert_distance( &mb, pts_unit, mm_unit );
602 gs_lgp->gnome_print_convert_distance( &pw, pts_unit, mm_unit );
603 gs_lgp->gnome_print_convert_distance( &ph, pts_unit, mm_unit );
cffcf831
RR
604
605 m_pageDialogData.SetMarginTopLeft( wxPoint( (int)(ml+0.5), (int)(mt+0.5)) );
06cfd325
RR
606 m_pageDialogData.SetMarginBottomRight( wxPoint( (int)(mr+0.5), (int)(mb+0.5)) );
607
608 m_pageDialogData.SetPaperSize( wxSize( (int)(pw+0.5), (int)(ph+0.5) ) );
cffcf831 609
cac7ac30 610#if 0
06cfd325
RR
611 wxPrintf( wxT("paper %d %d, top margin %d\n"),
612 m_pageDialogData.GetPaperSize().x,
613 m_pageDialogData.GetPaperSize().y,
614 m_pageDialogData.GetMarginTopLeft().x );
615#endif
616
08680429
RR
617 ret = wxID_OK;
618 }
619 else
620 {
621 ret = wxID_CANCEL;
622 }
623
624 gtk_widget_destroy( m_widget );
625 m_widget = NULL;
626
627 return ret;
628}
629
630bool wxGnomePageSetupDialog::Validate()
631{
632 return true;
633}
634
635bool wxGnomePageSetupDialog::TransferDataToWindow()
636{
637 return true;
638}
639
640bool wxGnomePageSetupDialog::TransferDataFromWindow()
641{
642 return true;
643}
644
ff910433
RR
645//----------------------------------------------------------------------------
646// wxGnomePrinter
647//----------------------------------------------------------------------------
648
649IMPLEMENT_CLASS(wxGnomePrinter, wxPrinterBase)
650
651wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) :
652 wxPrinterBase( data )
653{
654 m_gpc = NULL;
0be7709e 655 m_native_preview = false;
ff910433
RR
656}
657
658wxGnomePrinter::~wxGnomePrinter()
659{
660}
661
662bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
663{
664 if (!printout)
665 {
666 sm_lastError = wxPRINTER_ERROR;
667 return false;
668 }
669
670 wxPrintData printdata = GetPrintDialogData().GetPrintData();
cffcf831 671 wxGnomePrintNativeData *native =
ff910433
RR
672 (wxGnomePrintNativeData*) printdata.GetNativeData();
673
59c73be8
RR
674 GnomePrintJob *job = gs_lgp->gnome_print_job_new( native->GetPrintConfig() );
675 m_gpc = gs_lgp->gnome_print_job_get_context (job);
cffcf831 676
981a6af1 677 // The GnomePrintJob is temporarily stored in the
2934005d 678 // native print data as the native print dialog
981a6af1 679 // needs to access it.
cffcf831
RR
680 native->SetPrintJob( job );
681
981a6af1
RR
682
683 printout->SetIsPreview(false);
684
685 if (m_printDialogData.GetMinPage() < 1)
686 m_printDialogData.SetMinPage(1);
687 if (m_printDialogData.GetMaxPage() < 1)
688 m_printDialogData.SetMaxPage(9999);
ff910433
RR
689
690 wxDC *dc;
ff910433
RR
691 if (prompt)
692 dc = PrintDialog( parent );
693 else
694 dc = new wxGnomePrintDC( this );
695
0be7709e
RR
696 if (m_native_preview)
697 printout->SetIsPreview(true);
698
ff910433
RR
699 if (!dc)
700 {
59c73be8 701 gs_lgp->gnome_print_job_close( job );
cffcf831 702 g_object_unref (G_OBJECT (job));
981a6af1 703 sm_lastError = wxPRINTER_ERROR;
ff910433
RR
704 return false;
705 }
706
981a6af1
RR
707 wxSize ScreenPixels = wxGetDisplaySize();
708 wxSize ScreenMM = wxGetDisplaySizeMM();
709
710 printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
711 (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
b199de59
RR
712 printout->SetPPIPrinter( wxGnomePrintDC::GetResolution(),
713 wxGnomePrintDC::GetResolution() );
981a6af1 714
ff910433
RR
715 printout->SetDC(dc);
716
981a6af1
RR
717 int w, h;
718 dc->GetSize(&w, &h);
719 printout->SetPageSizePixels((int)w, (int)h);
720 dc->GetSizeMM(&w, &h);
721 printout->SetPageSizeMM((int)w, (int)h);
722
ff910433 723 printout->OnPreparePrinting();
b199de59
RR
724
725 // Get some parameters from the printout, if defined
726 int fromPage, toPage;
727 int minPage, maxPage;
728 printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
ff910433 729
b199de59 730 if (maxPage == 0)
ff910433 731 {
59c73be8 732 gs_lgp->gnome_print_job_close( job );
cffcf831 733 g_object_unref (G_OBJECT (job));
ff910433 734 sm_lastError = wxPRINTER_ERROR;
b199de59 735 return false;
ff910433 736 }
b199de59
RR
737
738 printout->OnBeginPrinting();
739
740 int minPageNum = minPage, maxPageNum = maxPage;
741
742 if ( !m_printDialogData.GetAllPages() )
ff910433 743 {
b199de59
RR
744 minPageNum = m_printDialogData.GetFromPage();
745 maxPageNum = m_printDialogData.GetToPage();
746 }
747
748
749 int copyCount;
750 for ( copyCount = 1;
751 copyCount <= m_printDialogData.GetNoCopies();
752 copyCount++ )
753 {
754 if (!printout->OnBeginDocument(minPageNum, maxPageNum))
ff910433 755 {
b199de59
RR
756 wxLogError(_("Could not start printing."));
757 sm_lastError = wxPRINTER_ERROR;
758 break;
759 }
760
761 int pn;
762 for ( pn = minPageNum;
763 pn <= maxPageNum && printout->HasPage(pn);
764 pn++ )
765 {
ff910433
RR
766 dc->StartPage();
767 printout->OnPrintPage(pn);
768 dc->EndPage();
769 }
b199de59 770
ff910433
RR
771 printout->OnEndDocument();
772 printout->OnEndPrinting();
773 }
774
59c73be8 775 gs_lgp->gnome_print_job_close( job );
0be7709e
RR
776 if (m_native_preview)
777 {
778 wxString title( _("Print preview") );
59c73be8 779 gtk_widget_show( gs_lgp->gnome_print_job_preview_new( job, (const guchar*)(const char*)wxGTK_CONV(title) ));
0be7709e
RR
780 }
781 else
782 {
59c73be8 783 gs_lgp->gnome_print_job_print( job );
0be7709e 784 }
ff910433 785
cffcf831 786 g_object_unref (G_OBJECT (job));
ff910433
RR
787 delete dc;
788
789 return (sm_lastError == wxPRINTER_NO_ERROR);
790}
791
792wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
793{
2934005d 794 wxGnomePrintDialog dialog( parent, &m_printDialogData );
0be7709e
RR
795 int ret = dialog.ShowModal();
796 if (ret == wxID_CANCEL)
ff910433 797 {
4843cdfe 798 sm_lastError = wxPRINTER_CANCELLED;
ff910433
RR
799 return NULL;
800 }
801
0be7709e
RR
802 m_native_preview = ret == wxID_PREVIEW;
803
b199de59 804 m_printDialogData = dialog.GetPrintDialogData();
ff910433
RR
805 return new wxGnomePrintDC( this );
806}
807
808bool wxGnomePrinter::Setup( wxWindow *parent )
809{
58c30cd8 810 return false;
ff910433
RR
811}
812
813//-----------------------------------------------------------------------------
814// wxGnomePrintDC
815//-----------------------------------------------------------------------------
816
62075bca 817IMPLEMENT_CLASS(wxGnomePrintDC, wxDC)
ff910433
RR
818
819wxGnomePrintDC::wxGnomePrintDC( wxGnomePrinter *printer )
820{
821 m_printer = printer;
822
823 m_gpc = printer->GetPrintContext();
824
59c73be8 825 m_layout = gs_lgp->gnome_print_pango_create_layout( m_gpc );
ff910433
RR
826 m_fontdesc = pango_font_description_from_string( "Sans 12" );
827
828 m_currentRed = 0;
829 m_currentBlue = 0;
830 m_currentGreen = 0;
831
832 m_signX = 1; // default x-axis left to right
833 m_signY = -1; // default y-axis bottom up -> top down
834}
835
836wxGnomePrintDC::~wxGnomePrintDC()
837{
838}
839
840bool wxGnomePrintDC::Ok() const
841{
842 return true;
843}
844
845bool wxGnomePrintDC::DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style )
846{
847 return false;
848}
849
850bool wxGnomePrintDC::DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const
851{
852 return false;
853}
854
855void wxGnomePrintDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
856{
857 if (m_pen.GetStyle() == wxTRANSPARENT) return;
858
859 SetPen( m_pen );
860
c6efd6e0
RR
861 gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(x1), YLOG2DEV(y1) );
862 gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV(x2), YLOG2DEV(y2) );
863 gs_lgp->gnome_print_stroke ( m_gpc);
cac7ac30 864
ff910433
RR
865 CalcBoundingBox( x1, y1 );
866 CalcBoundingBox( x2, y2 );
867}
868
869void wxGnomePrintDC::DoCrossHair(wxCoord x, wxCoord y)
870{
871}
872
873void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc)
874{
875}
876
877void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
878{
879}
880
881void wxGnomePrintDC::DoDrawPoint(wxCoord x, wxCoord y)
882{
883}
884
885void wxGnomePrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
886{
cac7ac30
RR
887 if (m_pen.GetStyle() == wxTRANSPARENT) return;
888
889 if (n <= 0) return;
890
891 SetPen (m_pen);
892
893 int i;
894 for ( i =0; i<n ; i++ )
895 CalcBoundingBox( XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset));
896
c6efd6e0 897 gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) );
cac7ac30
RR
898
899 for (i = 1; i < n; i++)
c6efd6e0 900 gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset) );
cac7ac30 901
c6efd6e0 902 gs_lgp->gnome_print_stroke ( m_gpc);
ff910433
RR
903}
904
905void wxGnomePrintDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
906{
a92964a2
RR
907 if (n==0) return;
908
909 if (m_brush.GetStyle () != wxTRANSPARENT)
910 {
911 SetBrush( m_brush );
912
913 int x = points[0].x + xoffset;
914 int y = points[0].y + yoffset;
915 CalcBoundingBox( x, y );
916 gs_lgp->gnome_print_newpath( m_gpc );
917 gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );
918 int i;
919 for (i = 1; i < n; i++)
920 {
921 int x = points[i].x + xoffset;
922 int y = points[i].y + yoffset;
923 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );
924 CalcBoundingBox( x, y );
925 }
926 gs_lgp->gnome_print_closepath( m_gpc );
927 gs_lgp->gnome_print_fill( m_gpc );
928 }
929
930 if (m_pen.GetStyle () != wxTRANSPARENT)
931 {
932 SetPen (m_pen);
933
934 int x = points[0].x + xoffset;
935 int y = points[0].y + yoffset;
936 gs_lgp->gnome_print_newpath( m_gpc );
937 gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );
938 int i;
939 for (i = 1; i < n; i++)
940 {
941 int x = points[i].x + xoffset;
942 int y = points[i].y + yoffset;
943 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );
944 CalcBoundingBox( x, y );
945 }
946 gs_lgp->gnome_print_closepath( m_gpc );
947 gs_lgp->gnome_print_stroke( m_gpc );
948 }
ff910433
RR
949}
950
951void wxGnomePrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
952{
a92964a2 953 wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle );
ff910433
RR
954}
955
956void wxGnomePrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
957{
958 if (m_brush.GetStyle () != wxTRANSPARENT)
959 {
960 SetBrush( m_brush );
961
c6efd6e0
RR
962 gs_lgp->gnome_print_newpath( m_gpc );
963 gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );
964 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) );
965 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) );
966 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) );
967 gs_lgp->gnome_print_closepath( m_gpc );
968 gs_lgp->gnome_print_fill( m_gpc );
ff910433
RR
969
970 CalcBoundingBox( x, y );
971 CalcBoundingBox( x + width, y + height );
972 }
973
974 if (m_pen.GetStyle () != wxTRANSPARENT)
975 {
976 SetPen (m_pen);
977
c6efd6e0
RR
978 gs_lgp->gnome_print_newpath( m_gpc );
979 gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) );
980 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) );
981 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) );
982 gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) );
983 gs_lgp->gnome_print_closepath( m_gpc );
984 gs_lgp->gnome_print_stroke( m_gpc );
ff910433
RR
985
986 CalcBoundingBox( x, y );
987 CalcBoundingBox( x + width, y + height );
988 }
989}
990
991void wxGnomePrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
992{
9a2fe010
RR
993 wxCoord rad = (wxCoord) radius;
994
995 if (m_brush.GetStyle() != wxTRANSPARENT)
996 {
997 SetBrush(m_brush);
998 gs_lgp->gnome_print_newpath(m_gpc);
999 gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
1000 gs_lgp->gnome_print_curveto(m_gpc,
1001 XLOG2DEV(x + rad),YLOG2DEV(y),
1002 XLOG2DEV(x),YLOG2DEV(y),
1003 XLOG2DEV(x),YLOG2DEV(y + rad));
1004 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad));
1005 gs_lgp->gnome_print_curveto(m_gpc,
1006 XLOG2DEV(x),YLOG2DEV(y + height - rad),
1007 XLOG2DEV(x),YLOG2DEV(y + height),
1008 XLOG2DEV(x + rad),YLOG2DEV(y + height));
1009 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height));
1010 gs_lgp->gnome_print_curveto(m_gpc,
1011 XLOG2DEV(x + width - rad),YLOG2DEV(y + height),
1012 XLOG2DEV(x + width),YLOG2DEV(y + height),
1013 XLOG2DEV(x + width),YLOG2DEV(y + height - rad));
1014 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad));
1015 gs_lgp->gnome_print_curveto(m_gpc,
1016 XLOG2DEV(x + width),YLOG2DEV(y + rad),
1017 XLOG2DEV(x + width),YLOG2DEV(y),
1018 XLOG2DEV(x + width - rad),YLOG2DEV(y));
1019 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
1020 gs_lgp->gnome_print_closepath(m_gpc);
1021 gs_lgp->gnome_print_fill(m_gpc);
1022
1023 CalcBoundingBox(x,y);
1024 CalcBoundingBox(x+width,y+height);
1025 }
1026
1027 if (m_pen.GetStyle() != wxTRANSPARENT)
1028 {
1029 SetPen(m_pen);
1030 gs_lgp->gnome_print_newpath(m_gpc);
1031 gs_lgp->gnome_print_moveto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
1032 gs_lgp->gnome_print_curveto(m_gpc,
1033 XLOG2DEV(x + rad),YLOG2DEV(y),
1034 XLOG2DEV(x),YLOG2DEV(y),
1035 XLOG2DEV(x),YLOG2DEV(y + rad));
1036 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x),YLOG2DEV(y + height - rad));
1037 gs_lgp->gnome_print_curveto(m_gpc,
1038 XLOG2DEV(x),YLOG2DEV(y + height - rad),
1039 XLOG2DEV(x),YLOG2DEV(y + height),
1040 XLOG2DEV(x + rad),YLOG2DEV(y + height));
1041 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width - rad),YLOG2DEV(y + height));
1042 gs_lgp->gnome_print_curveto(m_gpc,
1043 XLOG2DEV(x + width - rad),YLOG2DEV(y + height),
1044 XLOG2DEV(x + width),YLOG2DEV(y + height),
1045 XLOG2DEV(x + width),YLOG2DEV(y + height - rad));
1046 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + width),YLOG2DEV(y + rad));
1047 gs_lgp->gnome_print_curveto(m_gpc,
1048 XLOG2DEV(x + width),YLOG2DEV(y + rad),
1049 XLOG2DEV(x + width),YLOG2DEV(y),
1050 XLOG2DEV(x + width - rad),YLOG2DEV(y));
1051 gs_lgp->gnome_print_lineto(m_gpc,XLOG2DEV(x + rad),YLOG2DEV(y));
1052 gs_lgp->gnome_print_closepath(m_gpc);
1053 gs_lgp->gnome_print_stroke(m_gpc);
1054
1055 CalcBoundingBox(x,y);
1056 CalcBoundingBox(x+width,y+height);
1057 }
ff910433
RR
1058}
1059
1060void wxGnomePrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1061{
cac7ac30
RR
1062 if (m_brush.GetStyle () != wxTRANSPARENT)
1063 {
1064 SetBrush( m_brush );
1065
c6efd6e0
RR
1066 gs_lgp->gnome_print_newpath( m_gpc );
1067 gs_lgp->gnome_print_moveto( m_gpc,
cac7ac30
RR
1068 XLOG2DEV(x), YLOG2DEV(y+height/2) );
1069
1070 // start with top half
c6efd6e0 1071 gs_lgp->gnome_print_curveto( m_gpc,
cac7ac30
RR
1072 XLOG2DEV(x), YLOG2DEV(y),
1073 XLOG2DEV(x+width), YLOG2DEV(y),
1074 XLOG2DEV(x+width), YLOG2DEV(y+height/2) );
1075 // lower half
c6efd6e0 1076 gs_lgp->gnome_print_curveto( m_gpc,
cac7ac30
RR
1077 XLOG2DEV(x+width), YLOG2DEV(y+height),
1078 XLOG2DEV(x), YLOG2DEV(y+height),
1079 XLOG2DEV(x), YLOG2DEV(y+height/2) );
1080
c6efd6e0
RR
1081 gs_lgp->gnome_print_closepath( m_gpc );
1082 gs_lgp->gnome_print_fill( m_gpc );
cac7ac30
RR
1083
1084 CalcBoundingBox( x, y );
1085 CalcBoundingBox( x + width, y + height );
1086 }
1087
1088 if (m_pen.GetStyle () != wxTRANSPARENT)
1089 {
1090 SetPen (m_pen);
1091
c6efd6e0
RR
1092 gs_lgp->gnome_print_newpath( m_gpc );
1093 gs_lgp->gnome_print_moveto( m_gpc,
cac7ac30
RR
1094 XLOG2DEV(x), YLOG2DEV(y+height/2) );
1095
1096 // start with top half
c6efd6e0 1097 gs_lgp->gnome_print_curveto( m_gpc,
cac7ac30
RR
1098 XLOG2DEV(x), YLOG2DEV(y),
1099 XLOG2DEV(x+width), YLOG2DEV(y),
1100 XLOG2DEV(x+width), YLOG2DEV(y+height/2) );
1101 // lower half
c6efd6e0 1102 gs_lgp->gnome_print_curveto( m_gpc,
cac7ac30
RR
1103 XLOG2DEV(x+width), YLOG2DEV(y+height),
1104 XLOG2DEV(x), YLOG2DEV(y+height),
1105 XLOG2DEV(x), YLOG2DEV(y+height/2) );
1106
c6efd6e0
RR
1107 gs_lgp->gnome_print_closepath( m_gpc );
1108 gs_lgp->gnome_print_stroke( m_gpc );
cac7ac30
RR
1109
1110 CalcBoundingBox( x, y );
1111 CalcBoundingBox( x + width, y + height );
1112 }
ff910433
RR
1113}
1114
1115void wxGnomePrintDC::DoDrawSpline(wxList *points)
1116{
1117}
1118
1119bool wxGnomePrintDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
1120 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask,
1121 wxCoord xsrcMask, wxCoord ysrcMask)
1122{
1123 return false;
1124}
1125
1126void wxGnomePrintDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y )
1127{
e1bf3ad3 1128 DoDrawBitmap( icon, x, y, true );
ff910433
RR
1129}
1130
1131void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask )
1132{
e1bf3ad3
RR
1133 if (!bitmap.Ok()) return;
1134
e1bf3ad3
RR
1135 if (bitmap.HasPixbuf())
1136 {
2934005d
RR
1137 GdkPixbuf *pixbuf = bitmap.GetPixbuf();
1138 guchar *raw_image = gdk_pixbuf_get_pixels( pixbuf );
1139 bool has_alpha = gdk_pixbuf_get_has_alpha( pixbuf );
1140 int rowstride = gdk_pixbuf_get_rowstride( pixbuf );
1141 int height = gdk_pixbuf_get_height( pixbuf );
1142 int width = gdk_pixbuf_get_width( pixbuf );
1143
59c73be8 1144 gs_lgp->gnome_print_gsave( m_gpc );
2934005d
RR
1145 double matrix[6];
1146 matrix[0] = XLOG2DEVREL(width);
1147 matrix[1] = 0;
1148 matrix[2] = 0;
1149 matrix[3] = YLOG2DEVREL(height);
1150 matrix[4] = XLOG2DEV(x);
1151 matrix[5] = YLOG2DEV(y+height);
59c73be8 1152 gs_lgp->gnome_print_concat( m_gpc, matrix );
c6efd6e0 1153 gs_lgp->gnome_print_moveto( m_gpc, 0, 0 );
2934005d 1154 if (has_alpha)
59c73be8 1155 gs_lgp->gnome_print_rgbaimage( m_gpc, (guchar *)raw_image, width, height, rowstride );
2934005d 1156 else
59c73be8
RR
1157 gs_lgp->gnome_print_rgbimage( m_gpc, (guchar *)raw_image, width, height, rowstride );
1158 gs_lgp->gnome_print_grestore( m_gpc );
e1bf3ad3
RR
1159 }
1160 else
e1bf3ad3
RR
1161 {
1162 wxImage image = bitmap.ConvertToImage();
1163
1164 if (!image.Ok()) return;
2934005d 1165
59c73be8 1166 gs_lgp->gnome_print_gsave( m_gpc );
b4382784
RR
1167 double matrix[6];
1168 matrix[0] = XLOG2DEVREL(image.GetWidth());
1169 matrix[1] = 0;
1170 matrix[2] = 0;
1171 matrix[3] = YLOG2DEVREL(image.GetHeight());
1172 matrix[4] = XLOG2DEV(x);
1173 matrix[5] = YLOG2DEV(y+image.GetHeight());
59c73be8 1174 gs_lgp->gnome_print_concat( m_gpc, matrix );
c6efd6e0 1175 gs_lgp->gnome_print_moveto( m_gpc, 0, 0 );
59c73be8
RR
1176 gs_lgp->gnome_print_rgbimage( m_gpc, (guchar*) image.GetData(), image.GetWidth(), image.GetHeight(), image.GetWidth()*3 );
1177 gs_lgp->gnome_print_grestore( m_gpc );
e1bf3ad3 1178 }
ff910433
RR
1179}
1180
1181void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
b199de59
RR
1182{
1183 DoDrawRotatedText( text, x, y, 0.0 );
1184}
1185
1186void wxGnomePrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
ff910433 1187{
ff910433
RR
1188 x = XLOG2DEV(x);
1189 y = YLOG2DEV(y);
1190
ff910433
RR
1191 bool underlined = m_font.Ok() && m_font.GetUnderlined();
1192
1193#if wxUSE_UNICODE
1194 const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
1195#else
1196 const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
1197 if ( !wdata )
1198 return;
1199 const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
1200#endif
1201
1202 size_t datalen = strlen((const char*)data);
1203 pango_layout_set_text( m_layout, (const char*) data, datalen);
1204
1205 if (underlined)
1206 {
1207 PangoAttrList *attrs = pango_attr_list_new();
1208 PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
1209 a->start_index = 0;
1210 a->end_index = datalen;
1211 pango_attr_list_insert(attrs, a);
1212 pango_layout_set_attributes(m_layout, attrs);
1213 pango_attr_list_unref(attrs);
1214 }
1215
2934005d
RR
1216 if (m_textForegroundColour.Ok())
1217 {
1218 unsigned char red = m_textForegroundColour.Red();
1219 unsigned char blue = m_textForegroundColour.Blue();
1220 unsigned char green = m_textForegroundColour.Green();
1221
b199de59
RR
1222 if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue))
1223 {
1224 double redPS = (double)(red) / 255.0;
1225 double bluePS = (double)(blue) / 255.0;
1226 double greenPS = (double)(green) / 255.0;
1227
c6efd6e0 1228 gs_lgp->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS );
b199de59
RR
1229
1230 m_currentRed = red;
1231 m_currentBlue = blue;
1232 m_currentGreen = green;
1233 }
2934005d
RR
1234 }
1235
fa499247
RR
1236 int w,h;
1237
1238 if (fabs(m_scaleY - 1.0) > 0.00001)
1239 {
1240 // If there is a user or actually any scale applied to
1241 // the device context, scale the font.
1242
1243 // scale font description
1244 gint oldSize = pango_font_description_get_size( m_fontdesc );
1245 double size = oldSize;
1246 size = size * m_scaleY;
1247 pango_font_description_set_size( m_fontdesc, (gint)size );
1248
1249 // actually apply scaled font
1250 pango_layout_set_font_description( m_layout, m_fontdesc );
1251
1252 pango_layout_get_pixel_size( m_layout, &w, &h );
1253#if 0
1254 if ( m_backgroundMode == wxSOLID )
1255 {
1256 gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor());
1257 gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h);
1258 gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor());
1259 }
1260#endif
1261 // Draw layout.
c6efd6e0 1262 gs_lgp->gnome_print_moveto (m_gpc, x, y);
b199de59
RR
1263 if (fabs(angle) > 0.00001)
1264 {
59c73be8
RR
1265 gs_lgp->gnome_print_gsave( m_gpc );
1266 gs_lgp->gnome_print_rotate( m_gpc, angle );
1267 gs_lgp->gnome_print_pango_layout( m_gpc, m_layout );
1268 gs_lgp->gnome_print_grestore( m_gpc );
b199de59
RR
1269 }
1270 else
1271 {
59c73be8 1272 gs_lgp->gnome_print_pango_layout( m_gpc, m_layout );
b199de59 1273 }
fa499247
RR
1274
1275 // reset unscaled size
1276 pango_font_description_set_size( m_fontdesc, oldSize );
1277
1278 // actually apply unscaled font
1279 pango_layout_set_font_description( m_layout, m_fontdesc );
1280 }
1281 else
1282 {
1283 pango_layout_get_pixel_size( m_layout, &w, &h );
1284#if 0
1285 if ( m_backgroundMode == wxSOLID )
1286 {
1287 gdk_gc_set_foreground(m_textGC, m_textBackgroundColour.GetColor());
1288 gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h);
1289 gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor());
1290 }
1291#endif
1292 // Draw layout.
c6efd6e0 1293 gs_lgp->gnome_print_moveto (m_gpc, x, y);
b199de59
RR
1294 if (fabs(angle) > 0.00001)
1295 {
59c73be8
RR
1296 gs_lgp->gnome_print_gsave( m_gpc );
1297 gs_lgp->gnome_print_rotate( m_gpc, angle );
1298 gs_lgp->gnome_print_pango_layout( m_gpc, m_layout );
1299 gs_lgp->gnome_print_grestore( m_gpc );
b199de59
RR
1300 }
1301 else
1302 {
59c73be8 1303 gs_lgp->gnome_print_pango_layout( m_gpc, m_layout );
b199de59 1304 }
fa499247
RR
1305 }
1306
ff910433
RR
1307 if (underlined)
1308 {
1309 // undo underline attributes setting:
1310 pango_layout_set_attributes(m_layout, NULL);
1311 }
1312
b199de59 1313 CalcBoundingBox (x + w, y + h);
ff910433
RR
1314}
1315
1316void wxGnomePrintDC::Clear()
1317{
1318}
1319
1320void wxGnomePrintDC::SetFont( const wxFont& font )
1321{
1322 m_font = font;
1323
1324 if (m_font.Ok())
1325 {
1326 if (m_fontdesc)
1327 pango_font_description_free( m_fontdesc );
1328
1329 m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
1330
1331 pango_layout_set_font_description( m_layout, m_fontdesc );
1332 }
1333}
1334
1335void wxGnomePrintDC::SetPen( const wxPen& pen )
1336{
1337 if (!pen.Ok()) return;
1338
ff910433
RR
1339 m_pen = pen;
1340
c6efd6e0 1341 gs_lgp->gnome_print_setlinewidth( m_gpc, XLOG2DEVREL( 1000 * m_pen.GetWidth() ) / 1000.0f );
cac7ac30
RR
1342
1343 static const double dotted[] = {2.0, 5.0};
1344 static const double short_dashed[] = {4.0, 4.0};
1345 static const double wxCoord_dashed[] = {4.0, 8.0};
1346 static const double dotted_dashed[] = {6.0, 6.0, 2.0, 6.0};
1347
1348 switch (m_pen.GetStyle())
1349 {
59c73be8
RR
1350 case wxDOT: gs_lgp->gnome_print_setdash( m_gpc, 2, dotted, 0 ); break;
1351 case wxSHORT_DASH: gs_lgp->gnome_print_setdash( m_gpc, 2, short_dashed, 0 ); break;
1352 case wxLONG_DASH: gs_lgp->gnome_print_setdash( m_gpc, 2, wxCoord_dashed, 0 ); break;
1353 case wxDOT_DASH: gs_lgp->gnome_print_setdash( m_gpc, 4, dotted_dashed, 0 ); break;
cac7ac30
RR
1354 case wxSOLID:
1355 case wxTRANSPARENT:
59c73be8 1356 default: gs_lgp->gnome_print_setdash( m_gpc, 0, NULL, 0 ); break;
cac7ac30
RR
1357 }
1358
1359
ff910433
RR
1360 unsigned char red = m_pen.GetColour().Red();
1361 unsigned char blue = m_pen.GetColour().Blue();
1362 unsigned char green = m_pen.GetColour().Green();
1363
1364 if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue))
1365 {
1366 double redPS = (double)(red) / 255.0;
1367 double bluePS = (double)(blue) / 255.0;
1368 double greenPS = (double)(green) / 255.0;
1369
c6efd6e0 1370 gs_lgp->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS );
ff910433
RR
1371
1372 m_currentRed = red;
1373 m_currentBlue = blue;
1374 m_currentGreen = green;
1375 }
1376}
1377
1378void wxGnomePrintDC::SetBrush( const wxBrush& brush )
1379{
fa499247
RR
1380 if (!brush.Ok()) return;
1381
1382 m_brush = brush;
1383
1384 // Brush colour
1385 unsigned char red = m_brush.GetColour().Red();
1386 unsigned char blue = m_brush.GetColour().Blue();
1387 unsigned char green = m_brush.GetColour().Green();
1388
1389 if (!m_colour)
1390 {
1391 // Anything not white is black
1392 if (! (red == (unsigned char) 255 &&
1393 blue == (unsigned char) 255 &&
1394 green == (unsigned char) 255) )
1395 {
1396 red = (unsigned char) 0;
1397 green = (unsigned char) 0;
1398 blue = (unsigned char) 0;
1399 }
1400 // setgray here ?
1401 }
1402
1403 if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue))
1404 {
1405 double redPS = (double)(red) / 255.0;
1406 double bluePS = (double)(blue) / 255.0;
1407 double greenPS = (double)(green) / 255.0;
1408
c6efd6e0 1409 gs_lgp->gnome_print_setrgbcolor( m_gpc, redPS, greenPS, bluePS );
fa499247
RR
1410
1411 m_currentRed = red;
1412 m_currentBlue = blue;
1413 m_currentGreen = green;
1414 }
ff910433
RR
1415}
1416
1417void wxGnomePrintDC::SetLogicalFunction( int function )
1418{
1419}
1420
1421void wxGnomePrintDC::SetBackground( const wxBrush& brush )
1422{
1423}
1424
1425void wxGnomePrintDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1426{
1427}
1428
1429void wxGnomePrintDC::DestroyClippingRegion()
1430{
1431}
1432
1433bool wxGnomePrintDC::StartDoc(const wxString& message)
1434{
1435 SetDeviceOrigin( 0,0 );
1436
1437 return true;
1438}
1439
1440void wxGnomePrintDC::EndDoc()
1441{
59c73be8 1442 gs_lgp->gnome_print_end_doc( m_gpc );
ff910433
RR
1443}
1444
1445void wxGnomePrintDC::StartPage()
1446{
59c73be8 1447 gs_lgp->gnome_print_beginpage( m_gpc, (const guchar*) "page" );
ff910433
RR
1448}
1449
1450void wxGnomePrintDC::EndPage()
1451{
59c73be8 1452 gs_lgp->gnome_print_showpage( m_gpc );
ff910433
RR
1453}
1454
1455wxCoord wxGnomePrintDC::GetCharHeight() const
1456{
b199de59
RR
1457 pango_layout_set_text( m_layout, "H", 1 );
1458
1459 int w,h;
1460 pango_layout_get_pixel_size( m_layout, &w, &h );
1461
1462 return h;
ff910433
RR
1463}
1464
1465wxCoord wxGnomePrintDC::GetCharWidth() const
1466{
b199de59
RR
1467 pango_layout_set_text( m_layout, "H", 1 );
1468
1469 int w,h;
1470 pango_layout_get_pixel_size( m_layout, &w, &h );
1471
1472 return w;
ff910433
RR
1473}
1474
981a6af1 1475void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height,
ff910433
RR
1476 wxCoord *descent,
1477 wxCoord *externalLeading,
1478 wxFont *theFont ) const
1479{
981a6af1
RR
1480 if ( width )
1481 *width = 0;
1482 if ( height )
1483 *height = 0;
1484 if ( descent )
1485 *descent = 0;
1486 if ( externalLeading )
1487 *externalLeading = 0;
1488
1489 if (string.IsEmpty())
1490 {
1491 return;
1492 }
1493
1494 // Set new font description
1495 if (theFont)
1496 pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
1497
1498 // Set layout's text
1499#if wxUSE_UNICODE
1500 const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
1501 const char *dataUTF8 = (const char *)data;
1502#else
1503 const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string );
1504 if ( !wdata )
1505 {
1506 if (width) (*width) = 0;
1507 if (height) (*height) = 0;
1508 return;
1509 }
1510 const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
1511 const char *dataUTF8 = (const char *)data;
1512#endif
1513
1514 if ( !dataUTF8 )
1515 {
1516 // hardly ideal, but what else can we do if conversion failed?
1517 return;
1518 }
1519
1520 pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
1521
1522 int w,h;
1523 pango_layout_get_pixel_size( m_layout, &w, &h );
1524
1525 if (width)
15236815 1526 *width = (wxCoord)(w / m_scaleX);
981a6af1 1527 if (height)
15236815 1528 *height = (wxCoord)(h / m_scaleY);
981a6af1
RR
1529 if (descent)
1530 {
1531 PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
1532 int baseline = pango_layout_iter_get_baseline(iter);
1533 pango_layout_iter_free(iter);
1534 *descent = h - PANGO_PIXELS(baseline);
1535 }
1536
1537 // Reset old font description
1538 if (theFont)
1539 pango_layout_set_font_description( m_layout, m_fontdesc );
ff910433
RR
1540}
1541
1542void wxGnomePrintDC::DoGetSize(int* width, int* height) const
1543{
cffcf831
RR
1544 wxGnomePrintNativeData *native =
1545 (wxGnomePrintNativeData*) m_printData.GetNativeData();
1546
1547 // Query page size. This seems to omit the margins
1548 // right now, although it shouldn't
1549 double pw,ph;
59c73be8 1550 gs_lgp->gnome_print_job_get_page_size( native->GetPrintJob(), &pw, &ph );
ff910433 1551
ff910433 1552 if (width)
cffcf831 1553 *width = (int) (pw + 0.5);
ff910433 1554 if (height)
cffcf831 1555 *height = (int) (ph + 0.5);
ff910433
RR
1556}
1557
1558void wxGnomePrintDC::DoGetSizeMM(int *width, int *height) const
1559{
cffcf831
RR
1560 wxGnomePrintNativeData *native =
1561 (wxGnomePrintNativeData*) m_printData.GetNativeData();
1562
1563 // This code assumes values in Pts.
1564
1565 double pw,ph;
59c73be8 1566 gs_lgp->gnome_print_job_get_page_size( native->GetPrintJob(), &pw, &ph );
cffcf831
RR
1567
1568 // Convert to mm.
ff910433 1569
59c73be8
RR
1570 const GnomePrintUnit *mm_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "mm" );
1571 const GnomePrintUnit *pts_unit = gs_lgp->gnome_print_unit_get_by_abbreviation( (const guchar*) "Pts" );
1572 gs_lgp->gnome_print_convert_distance( &pw, pts_unit, mm_unit );
1573 gs_lgp->gnome_print_convert_distance( &ph, pts_unit, mm_unit );
ff910433
RR
1574
1575 if (width)
cffcf831 1576 *width = (int) (pw + 0.5);
ff910433 1577 if (height)
cffcf831 1578 *height = (int) (ph + 0.5);
ff910433
RR
1579}
1580
1581wxSize wxGnomePrintDC::GetPPI() const
1582{
1583 return wxSize(72,72);
1584}
1585
1586void wxGnomePrintDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
1587{
1588 m_signX = (xLeftRight ? 1 : -1);
1589 m_signY = (yBottomUp ? 1 : -1);
1590
1591 ComputeScaleAndOrigin();
1592}
1593
1594void wxGnomePrintDC::SetDeviceOrigin( wxCoord x, wxCoord y )
1595{
1596 int h = 0;
1597 int w = 0;
1598 GetSize( &w, &h );
1599
1600 wxDC::SetDeviceOrigin( x, h-y );
1601}
1602
1603void wxGnomePrintDC::SetResolution(int ppi)
1604{
1605}
1606
1607int wxGnomePrintDC::GetResolution()
1608{
1609 return 72;
1610}
7c72311f 1611
58c30cd8
RR
1612
1613class wxGnomePrintModule: public wxModule
1614{
1615public:
1616 wxGnomePrintModule() {}
c6efd6e0
RR
1617 bool OnInit();
1618 void OnExit();
58c30cd8
RR
1619
1620private:
1621 DECLARE_DYNAMIC_CLASS(wxGnomePrintModule)
1622};
1623
c6efd6e0
RR
1624bool wxGnomePrintModule::OnInit()
1625{
1626 gs_lgp = new wxGnomePrintLibrary;
1627 if (gs_lgp->IsOk())
1628 wxPrintFactory::SetPrintFactory( new wxGnomePrintFactory );
1629 return true;
1630}
1631
1632void wxGnomePrintModule::OnExit()
1633{
1634 delete gs_lgp;
1635}
1636
58c30cd8 1637IMPLEMENT_DYNAMIC_CLASS(wxGnomePrintModule, wxModule)
06cfd325 1638
7c72311f
RR
1639#endif
1640 // wxUSE_LIBGNOMEPRINT