]>
Commit | Line | Data |
---|---|---|
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 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "gprint.cpp" | |
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 | ||
21 | #include "gprint.h" | |
22 | #include "wx/fontutil.h" | |
23 | #include "wx/printdlg.h" | |
24 | #include "wx/gtk/private.h" | |
25 | ||
26 | #include <libgnomeprint/gnome-print.h> | |
27 | #include <libgnomeprint/gnome-print-pango.h> | |
28 | #include <libgnomeprintui/gnome-print-dialog.h> | |
29 | ||
30 | //---------------------------------------------------------------------------- | |
31 | // wxGnomePrintNativeData | |
32 | //---------------------------------------------------------------------------- | |
33 | ||
34 | IMPLEMENT_CLASS(wxGnomePrintNativeData, wxPrintNativeDataBase) | |
35 | ||
36 | wxGnomePrintNativeData::wxGnomePrintNativeData() | |
37 | { | |
38 | m_config = gnome_print_config_default(); | |
39 | m_job = gnome_print_job_new( m_config ); | |
40 | } | |
41 | ||
42 | wxGnomePrintNativeData::~wxGnomePrintNativeData() | |
43 | { | |
44 | g_object_unref (G_OBJECT (m_config)); | |
45 | g_object_unref (G_OBJECT (m_job)); | |
46 | } | |
47 | ||
48 | bool wxGnomePrintNativeData::TransferTo( wxPrintData &data ) | |
49 | { | |
50 | // TODO | |
51 | return true; | |
52 | } | |
53 | ||
54 | bool wxGnomePrintNativeData::TransferFrom( const wxPrintData &data ) | |
55 | { | |
56 | // TODO | |
57 | return true; | |
58 | } | |
59 | ||
60 | //---------------------------------------------------------------------------- | |
61 | // wxGnomePrintFactory | |
62 | //---------------------------------------------------------------------------- | |
63 | ||
64 | wxPrinterBase* wxGnomePrintFactory::CreatePrinter( wxPrintDialogData *data ) | |
65 | { | |
66 | return new wxGnomePrinter( data ); | |
67 | } | |
68 | ||
69 | wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview, | |
70 | wxPrintout *printout, | |
71 | wxPrintDialogData *data ) | |
72 | { | |
73 | return new wxPostScriptPrintPreview( preview, printout, data ); | |
74 | } | |
75 | ||
76 | wxPrintPreviewBase *wxGnomePrintFactory::CreatePrintPreview( wxPrintout *preview, | |
77 | wxPrintout *printout, | |
78 | wxPrintData *data ) | |
79 | { | |
80 | return new wxPostScriptPrintPreview( preview, printout, data ); | |
81 | } | |
82 | ||
83 | wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, | |
84 | wxPrintDialogData *data ) | |
85 | { | |
86 | return new wxGenericPrintDialog( parent, data ); | |
87 | } | |
88 | ||
89 | wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, | |
90 | wxPrintData *data ) | |
91 | { | |
92 | return new wxGenericPrintDialog( parent, data ); | |
93 | } | |
94 | ||
95 | bool wxGnomePrintFactory::HasPrintSetupDialog() | |
96 | { | |
97 | return true; | |
98 | } | |
99 | ||
100 | wxDialog *wxGnomePrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ) | |
101 | { | |
102 | return new wxGnomePrintSetupDialog( parent, data ); | |
103 | } | |
104 | ||
105 | bool wxGnomePrintFactory::HasOwnPrintToFile() | |
106 | { | |
107 | return true; | |
108 | } | |
109 | ||
110 | bool wxGnomePrintFactory::HasPrinterLine() | |
111 | { | |
112 | return true; | |
113 | } | |
114 | ||
115 | wxString wxGnomePrintFactory::CreatePrinterLine() | |
116 | { | |
117 | // We should query "gnome_config_default" here | |
118 | return _("GNOME print"); | |
119 | } | |
120 | ||
121 | bool wxGnomePrintFactory::HasStatusLine() | |
122 | { | |
123 | return true; | |
124 | } | |
125 | ||
126 | wxString wxGnomePrintFactory::CreateStatusLine() | |
127 | { | |
128 | // We should query "gnome_config_default" here | |
129 | return _("Ready"); | |
130 | } | |
131 | ||
132 | wxPrintNativeDataBase *wxGnomePrintFactory::CreatePrintNativeData() | |
133 | { | |
134 | return new wxGnomePrintNativeData; | |
135 | } | |
136 | ||
137 | //---------------------------------------------------------------------------- | |
138 | // wxGnomePrintSetupDialog | |
139 | //---------------------------------------------------------------------------- | |
140 | ||
141 | IMPLEMENT_CLASS(wxGnomePrintSetupDialog, wxDialog) | |
142 | ||
143 | wxGnomePrintSetupDialog::wxGnomePrintSetupDialog( wxWindow *parent, wxPrintData *data ) | |
144 | { | |
145 | wxGnomePrintNativeData *native = | |
146 | (wxGnomePrintNativeData*) data->GetNativeData(); | |
147 | ||
148 | m_widget = gnome_print_dialog_new (native->GetPrintJob(), (guchar*)"Print setup", 0); | |
149 | } | |
150 | ||
151 | wxGnomePrintSetupDialog::~wxGnomePrintSetupDialog() | |
152 | { | |
153 | m_widget = NULL; | |
154 | } | |
155 | ||
156 | int wxGnomePrintSetupDialog::ShowModal() | |
157 | { | |
158 | int response = gtk_dialog_run (GTK_DIALOG (m_widget)); | |
159 | gtk_widget_destroy(m_widget); | |
160 | m_widget = NULL; | |
161 | ||
162 | if (response == GNOME_PRINT_DIALOG_RESPONSE_CANCEL) | |
163 | return wxID_CANCEL; | |
164 | ||
165 | return wxID_OK; | |
166 | } | |
167 | ||
168 | bool wxGnomePrintSetupDialog::Validate() | |
169 | { | |
170 | return true; | |
171 | } | |
172 | ||
173 | bool wxGnomePrintSetupDialog::TransferDataToWindow() | |
174 | { | |
175 | return true; | |
176 | } | |
177 | ||
178 | bool wxGnomePrintSetupDialog::TransferDataFromWindow() | |
179 | { | |
180 | return true; | |
181 | } | |
182 | ||
183 | ||
184 | //---------------------------------------------------------------------------- | |
185 | // wxGnomePrinter | |
186 | //---------------------------------------------------------------------------- | |
187 | ||
188 | IMPLEMENT_CLASS(wxGnomePrinter, wxPrinterBase) | |
189 | ||
190 | wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) : | |
191 | wxPrinterBase( data ) | |
192 | { | |
193 | m_gpc = NULL; | |
194 | } | |
195 | ||
196 | wxGnomePrinter::~wxGnomePrinter() | |
197 | { | |
198 | } | |
199 | ||
200 | bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) | |
201 | { | |
202 | if (!printout) | |
203 | { | |
204 | sm_lastError = wxPRINTER_ERROR; | |
205 | return false; | |
206 | } | |
207 | ||
208 | wxPrintData printdata = GetPrintDialogData().GetPrintData(); | |
209 | wxGnomePrintNativeData *data = | |
210 | (wxGnomePrintNativeData*) printdata.GetNativeData(); | |
211 | ||
212 | GnomePrintJob *job = data->GetPrintJob(); | |
213 | m_gpc = gnome_print_job_get_context (job); | |
214 | ||
215 | wxDC *dc; | |
216 | ||
217 | if (prompt) | |
218 | dc = PrintDialog( parent ); | |
219 | else | |
220 | dc = new wxGnomePrintDC( this ); | |
221 | ||
222 | if (!dc) | |
223 | { | |
224 | gnome_print_job_close( job ); | |
225 | return false; | |
226 | } | |
227 | ||
228 | printout->SetDC(dc); | |
229 | ||
230 | printout->OnPreparePrinting(); | |
231 | printout->OnBeginPrinting(); | |
232 | ||
233 | if (!printout->OnBeginDocument(0, 0)) | |
234 | { | |
235 | sm_lastError = wxPRINTER_ERROR; | |
236 | } | |
237 | else | |
238 | { | |
239 | int pn; | |
240 | for (pn = 1; pn <= 2; pn++) | |
241 | { | |
242 | dc->StartPage(); | |
243 | printout->OnPrintPage(pn); | |
244 | dc->EndPage(); | |
245 | } | |
246 | ||
247 | printout->OnEndDocument(); | |
248 | printout->OnEndPrinting(); | |
249 | } | |
250 | ||
251 | gnome_print_job_close( job ); | |
252 | gnome_print_job_print( job ); | |
253 | ||
254 | delete dc; | |
255 | ||
256 | return (sm_lastError == wxPRINTER_NO_ERROR); | |
257 | } | |
258 | ||
259 | wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent ) | |
260 | { | |
261 | wxPrintDialog dialog( parent, &m_printDialogData ); | |
262 | if (dialog.ShowModal() == wxID_CANCEL) | |
263 | { | |
264 | sm_lastError = wxPRINTER_ERROR; | |
265 | return NULL; | |
266 | } | |
267 | ||
268 | return new wxGnomePrintDC( this ); | |
269 | } | |
270 | ||
271 | bool wxGnomePrinter::Setup( wxWindow *parent ) | |
272 | { | |
273 | } | |
274 | ||
275 | //----------------------------------------------------------------------------- | |
276 | // wxGnomePrintDC | |
277 | //----------------------------------------------------------------------------- | |
278 | ||
279 | IMPLEMENT_CLASS(wxGnomePrintDC, wxDCBase) | |
280 | ||
281 | wxGnomePrintDC::wxGnomePrintDC( wxGnomePrinter *printer ) | |
282 | { | |
283 | m_printer = printer; | |
284 | ||
285 | m_gpc = printer->GetPrintContext(); | |
286 | ||
287 | m_layout = gnome_print_pango_create_layout( m_gpc ); | |
288 | m_fontdesc = pango_font_description_from_string( "Sans 12" ); | |
289 | ||
290 | m_currentRed = 0; | |
291 | m_currentBlue = 0; | |
292 | m_currentGreen = 0; | |
293 | ||
294 | m_signX = 1; // default x-axis left to right | |
295 | m_signY = -1; // default y-axis bottom up -> top down | |
296 | } | |
297 | ||
298 | wxGnomePrintDC::~wxGnomePrintDC() | |
299 | { | |
300 | } | |
301 | ||
302 | bool wxGnomePrintDC::Ok() const | |
303 | { | |
304 | return true; | |
305 | } | |
306 | ||
307 | bool wxGnomePrintDC::DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style ) | |
308 | { | |
309 | return false; | |
310 | } | |
311 | ||
312 | bool wxGnomePrintDC::DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const | |
313 | { | |
314 | return false; | |
315 | } | |
316 | ||
317 | void wxGnomePrintDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) | |
318 | { | |
319 | if (m_pen.GetStyle() == wxTRANSPARENT) return; | |
320 | ||
321 | SetPen( m_pen ); | |
322 | ||
323 | gnome_print_moveto ( m_gpc, XDEV2LOG(x1), YDEV2LOG(y1) ); | |
324 | gnome_print_lineto ( m_gpc, XDEV2LOG(x2), YDEV2LOG(y2) ); | |
325 | gnome_print_stroke ( m_gpc); | |
326 | ||
327 | CalcBoundingBox( x1, y1 ); | |
328 | CalcBoundingBox( x2, y2 ); | |
329 | } | |
330 | ||
331 | void wxGnomePrintDC::DoCrossHair(wxCoord x, wxCoord y) | |
332 | { | |
333 | } | |
334 | ||
335 | void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) | |
336 | { | |
337 | } | |
338 | ||
339 | void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) | |
340 | { | |
341 | } | |
342 | ||
343 | void wxGnomePrintDC::DoDrawPoint(wxCoord x, wxCoord y) | |
344 | { | |
345 | } | |
346 | ||
347 | void wxGnomePrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) | |
348 | { | |
349 | } | |
350 | ||
351 | void wxGnomePrintDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) | |
352 | { | |
353 | } | |
354 | ||
355 | void wxGnomePrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) | |
356 | { | |
357 | } | |
358 | ||
359 | void wxGnomePrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
360 | { | |
361 | if (m_brush.GetStyle () != wxTRANSPARENT) | |
362 | { | |
363 | SetBrush( m_brush ); | |
364 | ||
365 | gnome_print_newpath( m_gpc ); | |
366 | gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); | |
367 | gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) ); | |
368 | gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) ); | |
369 | gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) ); | |
370 | gnome_print_closepath( m_gpc ); | |
371 | gnome_print_fill( m_gpc ); | |
372 | ||
373 | CalcBoundingBox( x, y ); | |
374 | CalcBoundingBox( x + width, y + height ); | |
375 | } | |
376 | ||
377 | if (m_pen.GetStyle () != wxTRANSPARENT) | |
378 | { | |
379 | SetPen (m_pen); | |
380 | ||
381 | gnome_print_newpath( m_gpc ); | |
382 | gnome_print_moveto( m_gpc, XLOG2DEV(x), YLOG2DEV(y) ); | |
383 | gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y) ); | |
384 | gnome_print_lineto( m_gpc, XLOG2DEV(x + width), YLOG2DEV(y + height) ); | |
385 | gnome_print_lineto( m_gpc, XLOG2DEV(x), YLOG2DEV(y + height) ); | |
386 | gnome_print_closepath( m_gpc ); | |
387 | gnome_print_stroke( m_gpc ); | |
388 | ||
389 | CalcBoundingBox( x, y ); | |
390 | CalcBoundingBox( x + width, y + height ); | |
391 | } | |
392 | } | |
393 | ||
394 | void wxGnomePrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) | |
395 | { | |
396 | } | |
397 | ||
398 | void wxGnomePrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
399 | { | |
400 | } | |
401 | ||
402 | void wxGnomePrintDC::DoDrawSpline(wxList *points) | |
403 | { | |
404 | } | |
405 | ||
406 | bool wxGnomePrintDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, | |
407 | wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, | |
408 | wxCoord xsrcMask, wxCoord ysrcMask) | |
409 | { | |
410 | return false; | |
411 | } | |
412 | ||
413 | void wxGnomePrintDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) | |
414 | { | |
415 | } | |
416 | ||
417 | void wxGnomePrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) | |
418 | { | |
419 | } | |
420 | ||
421 | void wxGnomePrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) | |
422 | { | |
423 | if (m_textForegroundColour.Ok()) | |
424 | { | |
425 | unsigned char red = m_textForegroundColour.Red(); | |
426 | unsigned char blue = m_textForegroundColour.Blue(); | |
427 | unsigned char green = m_textForegroundColour.Green(); | |
428 | ||
429 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) | |
430 | { | |
431 | double redPS = (double)(red) / 255.0; | |
432 | double bluePS = (double)(blue) / 255.0; | |
433 | double greenPS = (double)(green) / 255.0; | |
434 | ||
435 | gnome_print_setrgbcolor( m_gpc, redPS, bluePS, greenPS ); | |
436 | ||
437 | m_currentRed = red; | |
438 | m_currentBlue = blue; | |
439 | m_currentGreen = green; | |
440 | } | |
441 | } | |
442 | ||
443 | x = XLOG2DEV(x); | |
444 | y = YLOG2DEV(y); | |
445 | ||
446 | wxPrintf( wxT("x,y: %d,%d\n"), x, y ); | |
447 | ||
448 | bool underlined = m_font.Ok() && m_font.GetUnderlined(); | |
449 | ||
450 | #if wxUSE_UNICODE | |
451 | const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); | |
452 | #else | |
453 | const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); | |
454 | if ( !wdata ) | |
455 | return; | |
456 | const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); | |
457 | #endif | |
458 | ||
459 | size_t datalen = strlen((const char*)data); | |
460 | pango_layout_set_text( m_layout, (const char*) data, datalen); | |
461 | ||
462 | if (underlined) | |
463 | { | |
464 | PangoAttrList *attrs = pango_attr_list_new(); | |
465 | PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); | |
466 | a->start_index = 0; | |
467 | a->end_index = datalen; | |
468 | pango_attr_list_insert(attrs, a); | |
469 | pango_layout_set_attributes(m_layout, attrs); | |
470 | pango_attr_list_unref(attrs); | |
471 | } | |
472 | ||
473 | gnome_print_moveto (m_gpc, x, y); | |
474 | gnome_print_pango_layout( m_gpc, m_layout ); | |
475 | ||
476 | if (underlined) | |
477 | { | |
478 | // undo underline attributes setting: | |
479 | pango_layout_set_attributes(m_layout, NULL); | |
480 | } | |
481 | ||
482 | // CalcBoundingBox (x + width, y + height); | |
483 | CalcBoundingBox (x, y); | |
484 | } | |
485 | ||
486 | void wxGnomePrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) | |
487 | { | |
488 | } | |
489 | ||
490 | void wxGnomePrintDC::Clear() | |
491 | { | |
492 | } | |
493 | ||
494 | void wxGnomePrintDC::SetFont( const wxFont& font ) | |
495 | { | |
496 | m_font = font; | |
497 | ||
498 | if (m_font.Ok()) | |
499 | { | |
500 | if (m_fontdesc) | |
501 | pango_font_description_free( m_fontdesc ); | |
502 | ||
503 | m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); | |
504 | ||
505 | pango_layout_set_font_description( m_layout, m_fontdesc ); | |
506 | } | |
507 | } | |
508 | ||
509 | void wxGnomePrintDC::SetPen( const wxPen& pen ) | |
510 | { | |
511 | if (!pen.Ok()) return; | |
512 | ||
513 | int oldStyle = m_pen.GetStyle(); | |
514 | ||
515 | m_pen = pen; | |
516 | ||
517 | gnome_print_setlinewidth( m_gpc, XLOG2DEVREL( 1000 * m_pen.GetWidth() ) / 1000.0f ); | |
518 | ||
519 | unsigned char red = m_pen.GetColour().Red(); | |
520 | unsigned char blue = m_pen.GetColour().Blue(); | |
521 | unsigned char green = m_pen.GetColour().Green(); | |
522 | ||
523 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) | |
524 | { | |
525 | double redPS = (double)(red) / 255.0; | |
526 | double bluePS = (double)(blue) / 255.0; | |
527 | double greenPS = (double)(green) / 255.0; | |
528 | ||
529 | gnome_print_setrgbcolor( m_gpc, redPS, bluePS, greenPS ); | |
530 | ||
531 | m_currentRed = red; | |
532 | m_currentBlue = blue; | |
533 | m_currentGreen = green; | |
534 | } | |
535 | } | |
536 | ||
537 | void wxGnomePrintDC::SetBrush( const wxBrush& brush ) | |
538 | { | |
539 | } | |
540 | ||
541 | void wxGnomePrintDC::SetLogicalFunction( int function ) | |
542 | { | |
543 | } | |
544 | ||
545 | void wxGnomePrintDC::SetBackground( const wxBrush& brush ) | |
546 | { | |
547 | } | |
548 | ||
549 | void wxGnomePrintDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) | |
550 | { | |
551 | } | |
552 | ||
553 | void wxGnomePrintDC::DestroyClippingRegion() | |
554 | { | |
555 | } | |
556 | ||
557 | bool wxGnomePrintDC::StartDoc(const wxString& message) | |
558 | { | |
559 | SetDeviceOrigin( 0,0 ); | |
560 | ||
561 | return true; | |
562 | } | |
563 | ||
564 | void wxGnomePrintDC::EndDoc() | |
565 | { | |
566 | } | |
567 | ||
568 | void wxGnomePrintDC::StartPage() | |
569 | { | |
570 | gnome_print_beginpage( m_gpc, (const guchar*) "1" ); | |
571 | } | |
572 | ||
573 | void wxGnomePrintDC::EndPage() | |
574 | { | |
575 | gnome_print_showpage( m_gpc ); | |
576 | } | |
577 | ||
578 | wxCoord wxGnomePrintDC::GetCharHeight() const | |
579 | { | |
580 | return 0; | |
581 | } | |
582 | ||
583 | wxCoord wxGnomePrintDC::GetCharWidth() const | |
584 | { | |
585 | return 0; | |
586 | } | |
587 | ||
588 | void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, | |
589 | wxCoord *descent, | |
590 | wxCoord *externalLeading, | |
591 | wxFont *theFont ) const | |
592 | { | |
593 | } | |
594 | ||
595 | void wxGnomePrintDC::DoGetSize(int* width, int* height) const | |
596 | { | |
597 | // No idea if that is efficient | |
598 | GnomePrintConfig *config = gnome_print_config_default(); | |
599 | ||
600 | double w,h; | |
601 | bool result = gnome_print_config_get_page_size( config, &w, &h ); | |
602 | ||
603 | if (!result) | |
604 | { | |
605 | // Standard PS resolution DIN A4 size. | |
606 | w = 595.0; | |
607 | h = 842.0; | |
608 | } | |
609 | ||
610 | if (width) | |
611 | *width = (int) w; | |
612 | if (height) | |
613 | *height = (int) h; | |
614 | ||
615 | wxPrintf( wxT("size %d,%d\n"), *width, *height ); | |
616 | } | |
617 | ||
618 | void wxGnomePrintDC::DoGetSizeMM(int *width, int *height) const | |
619 | { | |
620 | double w,h; | |
621 | ||
622 | /// Later, for now DIN A4 | |
623 | w = 210.0; | |
624 | h = 297.0; | |
625 | ||
626 | if (width) | |
627 | *width = (int) w; | |
628 | if (height) | |
629 | *height = (int) h; | |
630 | } | |
631 | ||
632 | wxSize wxGnomePrintDC::GetPPI() const | |
633 | { | |
634 | return wxSize(72,72); | |
635 | } | |
636 | ||
637 | void wxGnomePrintDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) | |
638 | { | |
639 | m_signX = (xLeftRight ? 1 : -1); | |
640 | m_signY = (yBottomUp ? 1 : -1); | |
641 | ||
642 | ComputeScaleAndOrigin(); | |
643 | } | |
644 | ||
645 | void wxGnomePrintDC::SetDeviceOrigin( wxCoord x, wxCoord y ) | |
646 | { | |
647 | int h = 0; | |
648 | int w = 0; | |
649 | GetSize( &w, &h ); | |
650 | ||
651 | wxDC::SetDeviceOrigin( x, h-y ); | |
652 | } | |
653 | ||
654 | void wxGnomePrintDC::SetResolution(int ppi) | |
655 | { | |
656 | } | |
657 | ||
658 | int wxGnomePrintDC::GetResolution() | |
659 | { | |
660 | return 72; | |
661 | } |