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