]> git.saurik.com Git - wxWidgets.git/blame - src/html/htmprint.cpp
digital mars updated
[wxWidgets.git] / src / html / htmprint.cpp
CommitLineData
3ce369e6
VS
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#ifdef __GNUG__
1aedb1dd 13#pragma implementation "htmprint.h"
3ce369e6
VS
14#endif
15
16// For compilers that support precompilation, includes "wx/wx.h".
17#include "wx/wxprec.h"
18
314260fb
VS
19#include "wx/defs.h"
20
3ce369e6
VS
21#ifdef __BORLANDC__
22#pragma hdrstop
23#endif
24
25#ifndef WX_PRECOMP
04dbb646
VZ
26 #include "wx/log.h"
27 #include "wx/intl.h"
5438a566 28 #include "wx/dc.h"
3ce369e6
VS
29#endif
30
f6bcfd97 31#if wxUSE_HTML && wxUSE_PRINTING_ARCHITECTURE && wxUSE_STREAMS
3ce369e6 32
f11bdd03 33#include "wx/dc.h"
3ce369e6
VS
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
40
41//--------------------------------------------------------------------------------
42// wxHtmlDCRenderer
43//--------------------------------------------------------------------------------
44
45
46wxHtmlDCRenderer::wxHtmlDCRenderer() : wxObject()
47{
48 m_DC = NULL;
49 m_Width = m_Height = 0;
50 m_Cells = NULL;
51 m_Parser = new wxHtmlWinParser(NULL);
52 m_FS = new wxFileSystem();
4f9297b0 53 m_Parser->SetFS(m_FS);
3ce369e6
VS
54}
55
56
57
58wxHtmlDCRenderer::~wxHtmlDCRenderer()
59{
60 if (m_Cells) delete m_Cells;
61 if (m_Parser) delete m_Parser;
62 if (m_FS) delete m_FS;
63}
64
65
66
edbd0635 67void wxHtmlDCRenderer::SetDC(wxDC *dc, double pixel_scale)
3ce369e6 68{
3ce369e6 69 m_DC = dc;
4f9297b0 70 m_Parser->SetDC(m_DC, pixel_scale);
3ce369e6
VS
71}
72
73
74
75void wxHtmlDCRenderer::SetSize(int width, int height)
76{
edbd0635
VS
77 m_Width = width;
78 m_Height = height;
3ce369e6
VS
79}
80
81
3ce369e6
VS
82void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepath, bool isdir)
83{
84 if (m_DC == NULL) return;
85
86 if (m_Cells != NULL) delete m_Cells;
04dbb646 87
4f9297b0
VS
88 m_FS->ChangePathTo(basepath, isdir);
89 m_Cells = (wxHtmlContainerCell*) m_Parser->Parse(html);
90 m_Cells->SetIndent(0, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
91 m_Cells->Layout(m_Width);
3ce369e6
VS
92}
93
94
4eecf115
VS
95void wxHtmlDCRenderer::SetFonts(wxString normal_face, wxString fixed_face,
96 const int *sizes)
97{
98 m_Parser->SetFonts(normal_face, fixed_face, sizes);
99 if (m_DC == NULL && m_Cells != NULL) m_Cells->Layout(m_Width);
100}
101
3ce369e6
VS
102
103int wxHtmlDCRenderer::Render(int x, int y, int from, int dont_render)
104{
ec939b68 105 int pbreak, hght;
04dbb646 106
3ce369e6 107 if (m_Cells == NULL || m_DC == NULL) return 0;
04dbb646 108
edbd0635 109 pbreak = (int)(from + m_Height);
4f9297b0 110 while (m_Cells->AdjustPagebreak(&pbreak)) {}
edbd0635 111 hght = pbreak - from;
04dbb646
VZ
112
113 if (!dont_render)
4f9297b0
VS
114 {
115 m_DC->SetBrush(*wxWHITE_BRUSH);
04dbb646 116
4f9297b0 117 m_DC->SetClippingRegion(x, y, m_Width, hght);
04dbb646 118 m_Cells->Draw(*m_DC,
edbd0635
VS
119 x, (y - from),
120 y, pbreak + (y /*- from*/));
4f9297b0 121 m_DC->DestroyClippingRegion();
3ce369e6 122 }
04dbb646 123
4f9297b0 124 if (pbreak < m_Cells->GetHeight()) return pbreak;
3ce369e6
VS
125 else return GetTotalHeight();
126}
127
128
129
130int wxHtmlDCRenderer::GetTotalHeight()
131{
4f9297b0 132 if (m_Cells) return m_Cells->GetHeight();
3ce369e6
VS
133 else return 0;
134}
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151//--------------------------------------------------------------------------------
152// wxHtmlPrintout
153//--------------------------------------------------------------------------------
154
155
156
157wxHtmlPrintout::wxHtmlPrintout(const wxString& title) : wxPrintout(title)
158{
159 m_Renderer = new wxHtmlDCRenderer;
160 m_RendererHdr = new wxHtmlDCRenderer;
efba2b89 161 m_NumPages = wxHTML_PRINT_MAX_PAGES;
3ce369e6
VS
162 m_Document = m_BasePath = wxEmptyString; m_BasePathIsDir = TRUE;
163 m_Headers[0] = m_Headers[1] = wxEmptyString;
164 m_Footers[0] = m_Footers[1] = wxEmptyString;
165 m_HeaderHeight = m_FooterHeight = 0;
166 SetMargins(); // to default values
167}
168
169
170
171wxHtmlPrintout::~wxHtmlPrintout()
172{
173 delete m_Renderer;
174 delete m_RendererHdr;
175}
176
177
178
2a0eb922 179bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
3ce369e6 180{
edbd0635 181 int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h;
3ce369e6 182 float ppmm_h, ppmm_v;
04dbb646 183
2a0eb922 184 if (!wxPrintout::OnBeginDocument(startPage, endPage)) return FALSE;
3ce369e6
VS
185
186 GetPageSizePixels(&pageWidth, &pageHeight);
187 GetPageSizeMM(&mm_w, &mm_h);
188 ppmm_h = (float)pageWidth / mm_w;
189 ppmm_v = (float)pageHeight / mm_h;
190
edbd0635
VS
191 int ppiPrinterX, ppiPrinterY;
192 GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
193 int ppiScreenX, ppiScreenY;
194 GetPPIScreen(&ppiScreenX, &ppiScreenY);
195
196 wxDisplaySize(&scr_w, &scr_h);
4f9297b0 197 GetDC()->GetSize(&dc_w, &dc_h);
edbd0635 198
4f9297b0 199 GetDC()->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
edbd0635 200
3ce369e6 201 /* prepare headers/footers renderer: */
04dbb646 202
4f9297b0 203 m_RendererHdr->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
04dbb646 204 m_RendererHdr->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)),
68be9f09 205 (int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom)));
04dbb646 206 if (m_Headers[0] != wxEmptyString)
4f9297b0
VS
207 {
208 m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[0], 1));
209 m_HeaderHeight = m_RendererHdr->GetTotalHeight();
3ce369e6 210 }
04dbb646 211 else if (m_Headers[1] != wxEmptyString)
4f9297b0
VS
212 {
213 m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[1], 1));
214 m_HeaderHeight = m_RendererHdr->GetTotalHeight();
3ce369e6 215 }
04dbb646 216 if (m_Footers[0] != wxEmptyString)
4f9297b0
VS
217 {
218 m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[0], 1));
219 m_FooterHeight = m_RendererHdr->GetTotalHeight();
3ce369e6 220 }
04dbb646 221 else if (m_Footers[1] != wxEmptyString)
4f9297b0
VS
222 {
223 m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[1], 1));
224 m_FooterHeight = m_RendererHdr->GetTotalHeight();
3ce369e6 225 }
04dbb646 226
3ce369e6 227 /* prepare main renderer: */
4f9297b0 228 m_Renderer->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
6c5b628e 229 m_Renderer->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)),
04dbb646 230 (int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom) -
3ce369e6
VS
231 m_FooterHeight - m_HeaderHeight -
232 ((m_HeaderHeight == 0) ? 0 : m_MarginSpace * ppmm_v) -
233 ((m_FooterHeight == 0) ? 0 : m_MarginSpace * ppmm_v)
68be9f09 234 ));
4f9297b0 235 m_Renderer->SetHtmlText(m_Document, m_BasePath, m_BasePathIsDir);
3ce369e6 236 CountPages();
2a0eb922 237 return TRUE;
3ce369e6
VS
238}
239
240
241bool wxHtmlPrintout::OnPrintPage(int page)
242{
243 wxDC *dc = GetDC();
04dbb646 244 if (dc)
4f9297b0 245 {
3ce369e6
VS
246 if (HasPage(page))
247 RenderPage(dc, page);
248 return TRUE;
04dbb646 249 }
4f9297b0 250 else return FALSE;
3ce369e6
VS
251}
252
253
254void wxHtmlPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
255{
256 *minPage = 1;
efba2b89 257 *maxPage = wxHTML_PRINT_MAX_PAGES;
3ce369e6 258 *selPageFrom = 1;
efba2b89 259 *selPageTo = wxHTML_PRINT_MAX_PAGES;
3ce369e6
VS
260}
261
262
263
264bool wxHtmlPrintout::HasPage(int pageNum)
265{
266 return (pageNum >= 1 && pageNum <= m_NumPages);
267}
268
269
270
271void wxHtmlPrintout::SetHtmlText(const wxString& html, const wxString &basepath, bool isdir)
272{
273 m_Document = html;
274 m_BasePath = basepath;
275 m_BasePathIsDir = isdir;
276}
277
3ce369e6
VS
278void wxHtmlPrintout::SetHtmlFile(const wxString& htmlfile)
279{
280 wxFileSystem fs;
281 wxFSFile *ff = fs.OpenFile(htmlfile);
04dbb646 282
f5ba273e 283 if (ff == NULL)
04dbb646 284 {
f5ba273e
VS
285 wxLogError(htmlfile + _(": file does not exist!"));
286 return;
287 }
04dbb646 288
2b5f62a0
VZ
289 wxHtmlFilterHTML filter;
290 wxString doc = filter.ReadFile(*ff);
291
3ce369e6 292 SetHtmlText(doc, htmlfile, FALSE);
2b5f62a0 293 delete ff;
3ce369e6
VS
294}
295
296
297
298void wxHtmlPrintout::SetHeader(const wxString& header, int pg)
299{
04dbb646 300 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
3ce369e6 301 m_Headers[0] = header;
04dbb646 302 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
3ce369e6
VS
303 m_Headers[1] = header;
304}
305
306
307
308void wxHtmlPrintout::SetFooter(const wxString& footer, int pg)
309{
04dbb646 310 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
3ce369e6 311 m_Footers[0] = footer;
04dbb646 312 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
3ce369e6
VS
313 m_Footers[1] = footer;
314}
315
316
317
318void wxHtmlPrintout::CountPages()
319{
320 wxBusyCursor wait;
321 int pageWidth, pageHeight, mm_w, mm_h;
322 float ppmm_h, ppmm_v;
323
324 GetPageSizePixels(&pageWidth, &pageHeight);
325 GetPageSizeMM(&mm_w, &mm_h);
326 ppmm_h = (float)pageWidth / mm_w;
327 ppmm_v = (float)pageHeight / mm_h;
328
329 int pos = 0;
330
331 m_NumPages = 0;
04dbb646 332
3ce369e6 333 m_PageBreaks[0] = 0;
04dbb646 334 do
4f9297b0 335 {
04dbb646 336 pos = m_Renderer->Render((int)( ppmm_h * m_MarginLeft),
68be9f09 337 (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight),
3ce369e6
VS
338 pos, TRUE);
339 m_PageBreaks[++m_NumPages] = pos;
4f9297b0 340 } while (pos < m_Renderer->GetTotalHeight());
3ce369e6
VS
341}
342
343
344
345void wxHtmlPrintout::RenderPage(wxDC *dc, int page)
346{
347 wxBusyCursor wait;
348
edbd0635 349 int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h;
3ce369e6
VS
350 float ppmm_h, ppmm_v;
351
352 GetPageSizePixels(&pageWidth, &pageHeight);
353 GetPageSizeMM(&mm_w, &mm_h);
354 ppmm_h = (float)pageWidth / mm_w;
355 ppmm_v = (float)pageHeight / mm_h;
edbd0635 356 wxDisplaySize(&scr_w, &scr_h);
4f9297b0 357 dc->GetSize(&dc_w, &dc_h);
3ce369e6 358
edbd0635
VS
359 int ppiPrinterX, ppiPrinterY;
360 GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
361 int ppiScreenX, ppiScreenY;
362 GetPPIScreen(&ppiScreenX, &ppiScreenY);
363
4f9297b0 364 dc->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
04dbb646 365
4f9297b0 366 m_Renderer->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
04dbb646 367
4f9297b0 368 dc->SetBackgroundMode(wxTRANSPARENT);
3ce369e6 369
04dbb646 370 m_Renderer->Render((int) (ppmm_h * m_MarginLeft),
68be9f09 371 (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight),
3ce369e6 372 m_PageBreaks[page-1]);
04dbb646 373
4f9297b0 374 m_RendererHdr->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
04dbb646 375 if (m_Headers[page % 2] != wxEmptyString)
4f9297b0
VS
376 {
377 m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[page % 2], page));
378 m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (ppmm_v * m_MarginTop));
3ce369e6 379 }
04dbb646 380 if (m_Footers[page % 2] != wxEmptyString)
4f9297b0
VS
381 {
382 m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[page % 2], page));
383 m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (pageHeight - ppmm_v * m_MarginBottom - m_FooterHeight));
3ce369e6
VS
384 }
385}
386
387
388
389wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page)
390{
391 wxString r = instr;
392 wxString num;
04dbb646 393
66a77a74
OK
394 num.Printf(wxT("%i"), page);
395 r.Replace(wxT("@PAGENUM@"), num);
3ce369e6 396
66a77a74
OK
397 num.Printf(wxT("%i"), m_NumPages);
398 r.Replace(wxT("@PAGESCNT@"), num);
3ce369e6
VS
399
400 return r;
401}
402
403
404
405void wxHtmlPrintout::SetMargins(float top, float bottom, float left, float right, float spaces)
406{
407 m_MarginTop = top;
408 m_MarginBottom = bottom;
409 m_MarginLeft = left;
410 m_MarginRight = right;
411 m_MarginSpace = spaces;
412}
413
414
415
416
4eecf115
VS
417void wxHtmlPrintout::SetFonts(wxString normal_face, wxString fixed_face,
418 const int *sizes)
419{
420 m_Renderer->SetFonts(normal_face, fixed_face, sizes);
421 m_RendererHdr->SetFonts(normal_face, fixed_face, sizes);
422}
3ce369e6
VS
423
424
4eecf115
VS
425
426//----------------------------------------------------------------------------
3ce369e6 427// wxHtmlEasyPrinting
4eecf115 428//----------------------------------------------------------------------------
3ce369e6
VS
429
430
431wxHtmlEasyPrinting::wxHtmlEasyPrinting(const wxString& name, wxFrame *parent_frame)
432{
433 m_Frame = parent_frame;
434 m_Name = name;
435 m_PrintData = new wxPrintData;
436 m_PageSetupData = new wxPageSetupDialogData;
437 m_Headers[0] = m_Headers[1] = m_Footers[0] = m_Footers[1] = wxEmptyString;
04dbb646 438
4f9297b0 439 m_PageSetupData->EnableMargins(TRUE);
04dbb646 440 m_PageSetupData->SetMarginTopLeft(wxPoint(25, 25));
4f9297b0 441 m_PageSetupData->SetMarginBottomRight(wxPoint(25, 25));
4eecf115
VS
442
443 SetFonts(wxEmptyString, wxEmptyString, NULL);
3ce369e6
VS
444}
445
446
447
448wxHtmlEasyPrinting::~wxHtmlEasyPrinting()
449{
450 delete m_PrintData;
451 delete m_PageSetupData;
452}
453
454
455
f6bcfd97 456bool wxHtmlEasyPrinting::PreviewFile(const wxString &htmlfile)
3ce369e6
VS
457{
458 wxHtmlPrintout *p1 = CreatePrintout();
4f9297b0 459 p1->SetHtmlFile(htmlfile);
3ce369e6 460 wxHtmlPrintout *p2 = CreatePrintout();
4f9297b0 461 p2->SetHtmlFile(htmlfile);
f6bcfd97 462 return DoPreview(p1, p2);
3ce369e6
VS
463}
464
465
466
f6bcfd97 467bool wxHtmlEasyPrinting::PreviewText(const wxString &htmltext, const wxString &basepath)
3ce369e6
VS
468{
469 wxHtmlPrintout *p1 = CreatePrintout();
4f9297b0 470 p1->SetHtmlText(htmltext, basepath, TRUE);
3ce369e6 471 wxHtmlPrintout *p2 = CreatePrintout();
4f9297b0 472 p2->SetHtmlText(htmltext, basepath, TRUE);
f6bcfd97 473 return DoPreview(p1, p2);
3ce369e6
VS
474}
475
476
477
f6bcfd97 478bool wxHtmlEasyPrinting::PrintFile(const wxString &htmlfile)
3ce369e6
VS
479{
480 wxHtmlPrintout *p = CreatePrintout();
4f9297b0 481 p->SetHtmlFile(htmlfile);
453507f2
VS
482 bool ret = DoPrint(p);
483 delete p;
484 return ret;
3ce369e6
VS
485}
486
487
488
f6bcfd97 489bool wxHtmlEasyPrinting::PrintText(const wxString &htmltext, const wxString &basepath)
3ce369e6
VS
490{
491 wxHtmlPrintout *p = CreatePrintout();
4f9297b0 492 p->SetHtmlText(htmltext, basepath, TRUE);
453507f2
VS
493 bool ret = DoPrint(p);
494 delete p;
495 return ret;
3ce369e6
VS
496}
497
498
499
f6bcfd97 500bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2)
3ce369e6
VS
501{
502 // Pass two printout objects: for preview, and possible printing.
503 wxPrintDialogData printDialogData(*m_PrintData);
504 wxPrintPreview *preview = new wxPrintPreview(printout1, printout2, &printDialogData);
04dbb646 505 if (!preview->Ok())
4f9297b0 506 {
3ce369e6 507 delete preview;
f6bcfd97 508 return FALSE;
3ce369e6 509 }
3ca6a5f0 510
04dbb646
VZ
511 wxPreviewFrame *frame = new wxPreviewFrame(preview, m_Frame,
512 m_Name + _(" Preview"),
3ca6a5f0 513 wxPoint(100, 100), wxSize(650, 500));
4f9297b0
VS
514 frame->Centre(wxBOTH);
515 frame->Initialize();
516 frame->Show(TRUE);
3ca6a5f0 517 return TRUE;
3ce369e6
VS
518}
519
520
521
f6bcfd97 522bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout)
3ce369e6
VS
523{
524 wxPrintDialogData printDialogData(*m_PrintData);
525 wxPrinter printer(&printDialogData);
526
527 if (!printer.Print(m_Frame, printout, TRUE))
f6bcfd97
BP
528 {
529 return FALSE;
530 }
3ca6a5f0
BP
531
532 (*m_PrintData) = printer.GetPrintDialogData().GetPrintData();
533 return TRUE;
3ce369e6
VS
534}
535
536
537
538void wxHtmlEasyPrinting::PrinterSetup()
539{
540 wxPrintDialogData printDialogData(*m_PrintData);
541 wxPrintDialog printerDialog(m_Frame, &printDialogData);
04dbb646 542
3ce369e6
VS
543 printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
544
545 if (printerDialog.ShowModal() == wxID_OK)
546 (*m_PrintData) = printerDialog.GetPrintDialogData().GetPrintData();
547}
548
549
550
551void wxHtmlEasyPrinting::PageSetup()
552{
58cf0491
JS
553 if (!m_PrintData->Ok())
554 {
936b18ac 555 wxLogError(_("There was a problem during page setup: you may need to set a default printer."));
58cf0491
JS
556 return;
557 }
558
4f9297b0 559 m_PageSetupData->SetPrintData(*m_PrintData);
3ce369e6
VS
560 wxPageSetupDialog pageSetupDialog(m_Frame, m_PageSetupData);
561
04dbb646 562 if (pageSetupDialog.ShowModal() == wxID_OK)
4f9297b0 563 {
3ce369e6
VS
564 (*m_PrintData) = pageSetupDialog.GetPageSetupData().GetPrintData();
565 (*m_PageSetupData) = pageSetupDialog.GetPageSetupData();
566 }
567}
568
569
570
571void wxHtmlEasyPrinting::SetHeader(const wxString& header, int pg)
572{
04dbb646 573 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
3ce369e6 574 m_Headers[0] = header;
04dbb646 575 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
3ce369e6
VS
576 m_Headers[1] = header;
577}
578
579
580
581void wxHtmlEasyPrinting::SetFooter(const wxString& footer, int pg)
582{
04dbb646 583 if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
3ce369e6 584 m_Footers[0] = footer;
04dbb646 585 if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
3ce369e6
VS
586 m_Footers[1] = footer;
587}
588
589
4eecf115
VS
590void wxHtmlEasyPrinting::SetFonts(wxString normal_face, wxString fixed_face,
591 const int *sizes)
592{
593 m_FontFaceNormal = normal_face;
594 m_FontFaceFixed = fixed_face;
595
596 if (sizes)
597 {
598 m_FontsSizes = m_FontsSizesArr;
599 for (int i = 0; i < 7; i++) m_FontsSizes[i] = sizes[i];
600 }
601 else
602 m_FontsSizes = NULL;
603}
604
3ce369e6
VS
605
606wxHtmlPrintout *wxHtmlEasyPrinting::CreatePrintout()
607{
608 wxHtmlPrintout *p = new wxHtmlPrintout(m_Name);
04dbb646 609
4eecf115
VS
610 p->SetFonts(m_FontFaceNormal, m_FontFaceFixed, m_FontsSizes);
611
4f9297b0
VS
612 p->SetHeader(m_Headers[0], wxPAGE_EVEN);
613 p->SetHeader(m_Headers[1], wxPAGE_ODD);
614 p->SetFooter(m_Footers[0], wxPAGE_EVEN);
615 p->SetFooter(m_Footers[1], wxPAGE_ODD);
616
617 p->SetMargins(m_PageSetupData->GetMarginTopLeft().y,
618 m_PageSetupData->GetMarginBottomRight().y,
619 m_PageSetupData->GetMarginTopLeft().x,
620 m_PageSetupData->GetMarginBottomRight().x);
04dbb646 621
3ce369e6
VS
622 return p;
623}
624
625
0cecad31
VS
626// This hack forces the linker to always link in m_* files
627// (wxHTML doesn't work without handlers from these files)
628#include "wx/html/forcelnk.h"
629FORCE_WXHTML_MODULES()
3ce369e6 630
72cdf4c9 631#endif // wxUSE_HTML & wxUSE_PRINTING_ARCHITECTURE