]> git.saurik.com Git - wxWidgets.git/blob - src/html/htmprint.cpp
increase worst case to *4 for UTF8, switch a memcpy for wxMemcpy
[wxWidgets.git] / src / html / htmprint.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: htmprint.cpp
3 // Purpose: html printing classes
4 // Author: Vaclav Slavik
5 // Created: 25/09/99
6 // RCS-ID: $Id$
7 // Copyright: (c) Vaclav Slavik, 1999
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "htmprint.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
18
19 #include "wx/defs.h"
20
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24
25 #ifndef WX_PRECOMP
26 #include "wx/log.h"
27 #include "wx/intl.h"
28 #include "wx/dc.h"
29 #endif
30
31 #if wxUSE_HTML && wxUSE_PRINTING_ARCHITECTURE && wxUSE_STREAMS
32
33 #include "wx/dc.h"
34 #include "wx/print.h"
35 #include "wx/printdlg.h"
36 #include "wx/html/htmprint.h"
37 #include "wx/wxhtml.h"
38 #include "wx/wfstream.h"
39 #include "wx/module.h"
40 #include "wx/settings.h"
41
42
43 //--------------------------------------------------------------------------------
44 // wxHtmlDCRenderer
45 //--------------------------------------------------------------------------------
46
47
48 wxHtmlDCRenderer::wxHtmlDCRenderer() : wxObject()
49 {
50 m_DC = NULL;
51 m_Width = m_Height = 0;
52 m_Cells = NULL;
53 m_Parser = new wxHtmlWinParser(NULL);
54 m_FS = new wxFileSystem();
55 m_Parser->SetFS(m_FS);
56 }
57
58
59
60 wxHtmlDCRenderer::~wxHtmlDCRenderer()
61 {
62 if (m_Cells) delete m_Cells;
63 if (m_Parser) delete m_Parser;
64 if (m_FS) delete m_FS;
65 }
66
67
68
69 void wxHtmlDCRenderer::SetDC(wxDC *dc, double pixel_scale)
70 {
71 m_DC = dc;
72 m_Parser->SetDC(m_DC, pixel_scale);
73 }
74
75
76
77 void wxHtmlDCRenderer::SetSize(int width, int height)
78 {
79 m_Width = width;
80 m_Height = height;
81 }
82
83
84 void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepath, bool isdir)
85 {
86 if (m_DC == NULL) return;
87
88 if (m_Cells != NULL) delete m_Cells;
89
90 m_FS->ChangePathTo(basepath, isdir);
91 m_Cells = (wxHtmlContainerCell*) m_Parser->Parse(html);
92 m_Cells->SetIndent(0, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
93 m_Cells->Layout(m_Width);
94 }
95
96
97 void wxHtmlDCRenderer::SetFonts(wxString normal_face, wxString fixed_face,
98 const int *sizes)
99 {
100 m_Parser->SetFonts(normal_face, fixed_face, sizes);
101 if (m_DC == NULL && m_Cells != NULL)
102 m_Cells->Layout(m_Width);
103 }
104
105 void wxHtmlDCRenderer::SetStandardFonts(int size,
106 const wxString& normal_face,
107 const wxString& fixed_face)
108 {
109 m_Parser->SetStandardFonts(size, normal_face, fixed_face);
110 if (m_DC == NULL && m_Cells != NULL)
111 m_Cells->Layout(m_Width);
112 }
113
114
115 int wxHtmlDCRenderer::Render(int x, int y, int from, int dont_render, int to, int *known_pagebreaks, int number_of_pages)
116 {
117 int pbreak, hght;
118
119 if (m_Cells == NULL || m_DC == NULL) return 0;
120
121 pbreak = (int)(from + m_Height);
122 while (m_Cells->AdjustPagebreak(&pbreak, known_pagebreaks, number_of_pages)) {}
123 hght = pbreak - from;
124 if(to < hght)
125 hght = to;
126
127 if (!dont_render)
128 {
129 wxHtmlRenderingInfo rinfo;
130 wxDefaultHtmlRenderingStyle rstyle;
131 rinfo.SetStyle(&rstyle);
132 m_DC->SetBrush(*wxWHITE_BRUSH);
133 m_DC->SetClippingRegion(x, y, m_Width, hght);
134 m_Cells->Draw(*m_DC,
135 x, (y - from),
136 y, pbreak + (y /*- from*/),
137 rinfo);
138 m_DC->DestroyClippingRegion();
139 }
140
141 if (pbreak < m_Cells->GetHeight()) return pbreak;
142 else return GetTotalHeight();
143 }
144
145
146
147 int wxHtmlDCRenderer::GetTotalHeight()
148 {
149 if (m_Cells) return m_Cells->GetHeight();
150 else return 0;
151 }
152
153
154 //--------------------------------------------------------------------------------
155 // wxHtmlPrintout
156 //--------------------------------------------------------------------------------
157
158
159 wxList wxHtmlPrintout::m_Filters;
160
161 wxHtmlPrintout::wxHtmlPrintout(const wxString& title) : wxPrintout(title)
162 {
163 m_Renderer = new wxHtmlDCRenderer;
164 m_RendererHdr = new wxHtmlDCRenderer;
165 m_NumPages = wxHTML_PRINT_MAX_PAGES;
166 m_Document = m_BasePath = wxEmptyString; m_BasePathIsDir = true;
167 m_Headers[0] = m_Headers[1] = wxEmptyString;
168 m_Footers[0] = m_Footers[1] = wxEmptyString;
169 m_HeaderHeight = m_FooterHeight = 0;
170 SetMargins(); // to default values
171 }
172
173
174
175 wxHtmlPrintout::~wxHtmlPrintout()
176 {
177 delete m_Renderer;
178 delete m_RendererHdr;
179 }
180
181 void wxHtmlPrintout::CleanUpStatics()
182 {
183 WX_CLEAR_LIST(wxList, m_Filters);
184 }
185
186 // Adds input filter
187 void wxHtmlPrintout::AddFilter(wxHtmlFilter *filter)
188 {
189 m_Filters.Append(filter);
190 }
191
192 void wxHtmlPrintout::OnPreparePrinting()
193 {
194 int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h;
195 float ppmm_h, ppmm_v;
196
197 GetPageSizePixels(&pageWidth, &pageHeight);
198 GetPageSizeMM(&mm_w, &mm_h);
199 ppmm_h = (float)pageWidth / mm_w;
200 ppmm_v = (float)pageHeight / mm_h;
201
202 int ppiPrinterX, ppiPrinterY;
203 GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
204 int ppiScreenX, ppiScreenY;
205 GetPPIScreen(&ppiScreenX, &ppiScreenY);
206
207 wxDisplaySize(&scr_w, &scr_h);
208 GetDC()->GetSize(&dc_w, &dc_h);
209
210 GetDC()->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
211
212 /* prepare headers/footers renderer: */
213
214 m_RendererHdr->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
215 m_RendererHdr->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)),
216 (int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom)));
217 if (m_Headers[0] != wxEmptyString)
218 {
219 m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[0], 1));
220 m_HeaderHeight = m_RendererHdr->GetTotalHeight();
221 }
222 else if (m_Headers[1] != wxEmptyString)
223 {
224 m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[1], 1));
225 m_HeaderHeight = m_RendererHdr->GetTotalHeight();
226 }
227 if (m_Footers[0] != wxEmptyString)
228 {
229 m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[0], 1));
230 m_FooterHeight = m_RendererHdr->GetTotalHeight();
231 }
232 else if (m_Footers[1] != wxEmptyString)
233 {
234 m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[1], 1));
235 m_FooterHeight = m_RendererHdr->GetTotalHeight();
236 }
237
238 /* prepare main renderer: */
239 m_Renderer->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
240 m_Renderer->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)),
241 (int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom) -
242 m_FooterHeight - m_HeaderHeight -
243 ((m_HeaderHeight == 0) ? 0 : m_MarginSpace * ppmm_v) -
244 ((m_FooterHeight == 0) ? 0 : m_MarginSpace * ppmm_v)
245 ));
246 m_Renderer->SetHtmlText(m_Document, m_BasePath, m_BasePathIsDir);
247 CountPages();
248 }
249
250 bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
251 {
252 if (!wxPrintout::OnBeginDocument(startPage, endPage)) return false;
253
254 return true;
255 }
256
257
258 bool wxHtmlPrintout::OnPrintPage(int page)
259 {
260 wxDC *dc = GetDC();
261 if (dc)
262 {
263 if (HasPage(page))
264 RenderPage(dc, page);
265 return true;
266 }
267 else return false;
268 }
269
270
271 void wxHtmlPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
272 {
273 *minPage = 1;
274 *maxPage = m_NumPages;
275 *selPageFrom = 1;
276 *selPageTo = m_NumPages;
277 }
278
279
280
281 bool wxHtmlPrintout::HasPage(int pageNum)
282 {
283 return (pageNum >= 1 && pageNum <= m_NumPages);
284 }
285
286
287
288 void wxHtmlPrintout::SetHtmlText(const wxString& html, const wxString &basepath, bool isdir)
289 {
290 m_Document = html;
291 m_BasePath = basepath;
292 m_BasePathIsDir = isdir;
293 }
294
295 void wxHtmlPrintout::SetHtmlFile(const wxString& htmlfile)
296 {
297 wxFileSystem fs;
298 wxFSFile *ff;
299
300 if (wxFileExists(htmlfile))
301 ff = fs.OpenFile(wxFileSystem::FileNameToURL(htmlfile));
302 else
303 ff = fs.OpenFile(htmlfile);
304
305 if (ff == NULL)
306 {
307 wxLogError(htmlfile + _(": file does not exist!"));
308 return;
309 }
310
311 bool done = false;
312 wxHtmlFilterHTML defaultFilter;
313 wxString doc;
314
315 wxList::compatibility_iterator node = m_Filters.GetFirst();
316 while (node)
317 {
318 wxHtmlFilter *h = (wxHtmlFilter*) node->GetData();
319 if (h->CanRead(*ff))
320 {
321 doc = h->ReadFile(*ff);
322 done = true;
323 break;
324 }
325 node = node->GetNext();
326 }
327
328 if (!done)
329 doc = defaultFilter.ReadFile(*ff);
330
331 SetHtmlText(doc, htmlfile, false);
332 delete ff;
333 }
334
335
336
337 void wxHtmlPrintout::SetHeader(const wxString& header, int pg)
338 {
339 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
340 m_Headers[0] = header;
341 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
342 m_Headers[1] = header;
343 }
344
345
346
347 void wxHtmlPrintout::SetFooter(const wxString& footer, int pg)
348 {
349 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
350 m_Footers[0] = footer;
351 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
352 m_Footers[1] = footer;
353 }
354
355
356
357 void wxHtmlPrintout::CountPages()
358 {
359 wxBusyCursor wait;
360 int pageWidth, pageHeight, mm_w, mm_h;
361 float ppmm_h, ppmm_v;
362
363 GetPageSizePixels(&pageWidth, &pageHeight);
364 GetPageSizeMM(&mm_w, &mm_h);
365 ppmm_h = (float)pageWidth / mm_w;
366 ppmm_v = (float)pageHeight / mm_h;
367
368 int pos = 0;
369
370 m_NumPages = 0;
371
372 m_PageBreaks[0] = 0;
373 do
374 {
375 pos = m_Renderer->Render((int)( ppmm_h * m_MarginLeft),
376 (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight),
377 pos, true, INT_MAX, m_PageBreaks, m_NumPages);
378 m_PageBreaks[++m_NumPages] = pos;
379 } while (pos < m_Renderer->GetTotalHeight());
380 }
381
382
383
384 void wxHtmlPrintout::RenderPage(wxDC *dc, int page)
385 {
386 wxBusyCursor wait;
387
388 int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h;
389 float ppmm_h, ppmm_v;
390
391 GetPageSizePixels(&pageWidth, &pageHeight);
392 GetPageSizeMM(&mm_w, &mm_h);
393 ppmm_h = (float)pageWidth / mm_w;
394 ppmm_v = (float)pageHeight / mm_h;
395 wxDisplaySize(&scr_w, &scr_h);
396 dc->GetSize(&dc_w, &dc_h);
397
398 int ppiPrinterX, ppiPrinterY;
399 GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
400 wxUnusedVar(ppiPrinterX);
401 int ppiScreenX, ppiScreenY;
402 GetPPIScreen(&ppiScreenX, &ppiScreenY);
403 wxUnusedVar(ppiScreenX);
404
405 dc->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
406
407 m_Renderer->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
408
409 dc->SetBackgroundMode(wxTRANSPARENT);
410
411 m_Renderer->Render((int) (ppmm_h * m_MarginLeft),
412 (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight),
413 m_PageBreaks[page-1], false, m_PageBreaks[page]-m_PageBreaks[page-1]);
414
415 m_RendererHdr->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
416 if (m_Headers[page % 2] != wxEmptyString)
417 {
418 m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[page % 2], page));
419 m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (ppmm_v * m_MarginTop));
420 }
421 if (m_Footers[page % 2] != wxEmptyString)
422 {
423 m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[page % 2], page));
424 m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (pageHeight - ppmm_v * m_MarginBottom - m_FooterHeight));
425 }
426 }
427
428
429
430 wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page)
431 {
432 wxString r = instr;
433 wxString num;
434
435 num.Printf(wxT("%i"), page);
436 r.Replace(wxT("@PAGENUM@"), num);
437
438 num.Printf(wxT("%i"), m_NumPages);
439 r.Replace(wxT("@PAGESCNT@"), num);
440
441 return r;
442 }
443
444
445
446 void wxHtmlPrintout::SetMargins(float top, float bottom, float left, float right, float spaces)
447 {
448 m_MarginTop = top;
449 m_MarginBottom = bottom;
450 m_MarginLeft = left;
451 m_MarginRight = right;
452 m_MarginSpace = spaces;
453 }
454
455
456
457
458 void wxHtmlPrintout::SetFonts(wxString normal_face, wxString fixed_face,
459 const int *sizes)
460 {
461 m_Renderer->SetFonts(normal_face, fixed_face, sizes);
462 m_RendererHdr->SetFonts(normal_face, fixed_face, sizes);
463 }
464
465 void wxHtmlPrintout::SetStandardFonts(int size,
466 const wxString& normal_face,
467 const wxString& fixed_face)
468 {
469 m_Renderer->SetStandardFonts(size, normal_face, fixed_face);
470 m_RendererHdr->SetStandardFonts(size, normal_face, fixed_face);
471 }
472
473
474
475 //----------------------------------------------------------------------------
476 // wxHtmlEasyPrinting
477 //----------------------------------------------------------------------------
478
479
480 wxHtmlEasyPrinting::wxHtmlEasyPrinting(const wxString& name, wxWindow *parentWindow)
481 {
482 m_ParentWindow = parentWindow;
483 m_Name = name;
484 m_PrintData = NULL;
485 m_PageSetupData = new wxPageSetupDialogData;
486 m_Headers[0] = m_Headers[1] = m_Footers[0] = m_Footers[1] = wxEmptyString;
487
488 m_PageSetupData->EnableMargins(true);
489 m_PageSetupData->SetMarginTopLeft(wxPoint(25, 25));
490 m_PageSetupData->SetMarginBottomRight(wxPoint(25, 25));
491
492 SetFonts(wxEmptyString, wxEmptyString, NULL);
493 }
494
495
496
497 wxHtmlEasyPrinting::~wxHtmlEasyPrinting()
498 {
499 delete m_PrintData;
500 delete m_PageSetupData;
501 }
502
503
504 wxPrintData *wxHtmlEasyPrinting::GetPrintData()
505 {
506 if (m_PrintData == NULL)
507 m_PrintData = new wxPrintData();
508 return m_PrintData;
509 }
510
511
512 bool wxHtmlEasyPrinting::PreviewFile(const wxString &htmlfile)
513 {
514 wxHtmlPrintout *p1 = CreatePrintout();
515 p1->SetHtmlFile(htmlfile);
516 wxHtmlPrintout *p2 = CreatePrintout();
517 p2->SetHtmlFile(htmlfile);
518 return DoPreview(p1, p2);
519 }
520
521
522
523 bool wxHtmlEasyPrinting::PreviewText(const wxString &htmltext, const wxString &basepath)
524 {
525 wxHtmlPrintout *p1 = CreatePrintout();
526 p1->SetHtmlText(htmltext, basepath, true);
527 wxHtmlPrintout *p2 = CreatePrintout();
528 p2->SetHtmlText(htmltext, basepath, true);
529 return DoPreview(p1, p2);
530 }
531
532
533
534 bool wxHtmlEasyPrinting::PrintFile(const wxString &htmlfile)
535 {
536 wxHtmlPrintout *p = CreatePrintout();
537 p->SetHtmlFile(htmlfile);
538 bool ret = DoPrint(p);
539 delete p;
540 return ret;
541 }
542
543
544
545 bool wxHtmlEasyPrinting::PrintText(const wxString &htmltext, const wxString &basepath)
546 {
547 wxHtmlPrintout *p = CreatePrintout();
548 p->SetHtmlText(htmltext, basepath, true);
549 bool ret = DoPrint(p);
550 delete p;
551 return ret;
552 }
553
554
555
556 bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2)
557 {
558 // Pass two printout objects: for preview, and possible printing.
559 wxPrintDialogData printDialogData(*GetPrintData());
560 wxPrintPreview *preview = new wxPrintPreview(printout1, printout2, &printDialogData);
561 if (!preview->Ok())
562 {
563 delete preview;
564 return false;
565 }
566
567 wxPreviewFrame *frame = new wxPreviewFrame(preview, m_ParentWindow,
568 m_Name + _(" Preview"),
569 wxPoint(100, 100), wxSize(650, 500));
570 frame->Centre(wxBOTH);
571 frame->Initialize();
572 frame->Show(true);
573 return true;
574 }
575
576
577
578 bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout)
579 {
580 wxPrintDialogData printDialogData(*GetPrintData());
581 wxPrinter printer(&printDialogData);
582
583 if (!printer.Print(m_ParentWindow, printout, true))
584 {
585 return false;
586 }
587
588 (*GetPrintData()) = printer.GetPrintDialogData().GetPrintData();
589 return true;
590 }
591
592
593
594 void wxHtmlEasyPrinting::PrinterSetup()
595 {
596 wxPrintDialogData printDialogData(*GetPrintData());
597 wxPrintDialog printerDialog(m_ParentWindow, &printDialogData);
598
599 printerDialog.GetPrintDialogData().SetSetupDialog(true);
600
601 if (printerDialog.ShowModal() == wxID_OK)
602 (*GetPrintData()) = printerDialog.GetPrintDialogData().GetPrintData();
603 }
604
605
606
607 void wxHtmlEasyPrinting::PageSetup()
608 {
609 if (!GetPrintData()->Ok())
610 {
611 wxLogError(_("There was a problem during page setup: you may need to set a default printer."));
612 return;
613 }
614
615 m_PageSetupData->SetPrintData(*GetPrintData());
616 wxPageSetupDialog pageSetupDialog(m_ParentWindow, m_PageSetupData);
617
618 if (pageSetupDialog.ShowModal() == wxID_OK)
619 {
620 (*GetPrintData()) = pageSetupDialog.GetPageSetupData().GetPrintData();
621 (*m_PageSetupData) = pageSetupDialog.GetPageSetupData();
622 }
623 }
624
625
626
627 void wxHtmlEasyPrinting::SetHeader(const wxString& header, int pg)
628 {
629 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
630 m_Headers[0] = header;
631 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
632 m_Headers[1] = header;
633 }
634
635
636
637 void wxHtmlEasyPrinting::SetFooter(const wxString& footer, int pg)
638 {
639 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
640 m_Footers[0] = footer;
641 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
642 m_Footers[1] = footer;
643 }
644
645
646 void wxHtmlEasyPrinting::SetFonts(wxString normal_face, wxString fixed_face,
647 const int *sizes)
648 {
649 m_fontMode = FontMode_Explicit;
650 m_FontFaceNormal = normal_face;
651 m_FontFaceFixed = fixed_face;
652
653 if (sizes)
654 {
655 m_FontsSizes = m_FontsSizesArr;
656 for (int i = 0; i < 7; i++) m_FontsSizes[i] = sizes[i];
657 }
658 else
659 m_FontsSizes = NULL;
660 }
661
662 void wxHtmlEasyPrinting::SetStandardFonts(int size,
663 const wxString& normal_face,
664 const wxString& fixed_face)
665 {
666 m_fontMode = FontMode_Standard;
667 m_FontFaceNormal = normal_face;
668 m_FontFaceFixed = fixed_face;
669 m_FontsSizesArr[0] = size;
670 }
671
672
673 wxHtmlPrintout *wxHtmlEasyPrinting::CreatePrintout()
674 {
675 wxHtmlPrintout *p = new wxHtmlPrintout(m_Name);
676
677 if (m_fontMode == FontMode_Explicit)
678 {
679 p->SetFonts(m_FontFaceNormal, m_FontFaceFixed, m_FontsSizes);
680 }
681 else // FontMode_Standard
682 {
683 p->SetStandardFonts(m_FontsSizesArr[0],
684 m_FontFaceNormal, m_FontFaceFixed);
685 }
686
687 p->SetHeader(m_Headers[0], wxPAGE_EVEN);
688 p->SetHeader(m_Headers[1], wxPAGE_ODD);
689 p->SetFooter(m_Footers[0], wxPAGE_EVEN);
690 p->SetFooter(m_Footers[1], wxPAGE_ODD);
691
692 p->SetMargins(m_PageSetupData->GetMarginTopLeft().y,
693 m_PageSetupData->GetMarginBottomRight().y,
694 m_PageSetupData->GetMarginTopLeft().x,
695 m_PageSetupData->GetMarginBottomRight().x);
696
697 return p;
698 }
699
700 // A module to allow initialization/cleanup
701 // without calling these functions from app.cpp or from
702 // the user's application.
703
704 class wxHtmlPrintingModule: public wxModule
705 {
706 DECLARE_DYNAMIC_CLASS(wxHtmlPrintingModule)
707 public:
708 wxHtmlPrintingModule() : wxModule() {}
709 bool OnInit() { return true; }
710 void OnExit() { wxHtmlPrintout::CleanUpStatics(); }
711 };
712
713 IMPLEMENT_DYNAMIC_CLASS(wxHtmlPrintingModule, wxModule)
714
715
716 // This hack forces the linker to always link in m_* files
717 // (wxHTML doesn't work without handlers from these files)
718 #include "wx/html/forcelnk.h"
719 FORCE_WXHTML_MODULES()
720
721 #endif // wxUSE_HTML & wxUSE_PRINTING_ARCHITECTURE