X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/02761f6cd478e3c2c97cf6f93442747f7b029833..bb69632a56a827bed4cfae842bfffa88259ac1aa:/src/html/htmprint.cpp diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index 80fa773564..80277e0336 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -33,6 +33,10 @@ #include "wx/wfstream.h" +// default font size of normal text (HTML font size 0) for printing, in points: +#define DEFAULT_PRINT_FONT_SIZE 12 + + //-------------------------------------------------------------------------------- // wxHtmlDCRenderer //-------------------------------------------------------------------------------- @@ -46,6 +50,7 @@ wxHtmlDCRenderer::wxHtmlDCRenderer() : wxObject() m_Parser = new wxHtmlWinParser(); m_FS = new wxFileSystem(); m_Parser->SetFS(m_FS); + SetStandardFonts(DEFAULT_PRINT_FONT_SIZE); } @@ -127,7 +132,7 @@ int wxHtmlDCRenderer::Render(int x, int y, m_DC->SetClippingRegion(x, y, m_Width, hght); m_Cells->Draw(*m_DC, x, (y - from), - y, pbreak + (y /*- from*/), + y, y + hght, rinfo); m_DC->DestroyClippingRegion(); } @@ -161,6 +166,7 @@ wxHtmlPrintout::wxHtmlPrintout(const wxString& title) : wxPrintout(title) m_Footers[0] = m_Footers[1] = wxEmptyString; m_HeaderHeight = m_FooterHeight = 0; SetMargins(); // to default values + SetStandardFonts(DEFAULT_PRINT_FONT_SIZE); } @@ -194,13 +200,16 @@ void wxHtmlPrintout::OnPreparePrinting() int ppiPrinterX, ppiPrinterY; GetPPIPrinter(&ppiPrinterX, &ppiPrinterY); + wxUnusedVar(ppiPrinterX); int ppiScreenX, ppiScreenY; GetPPIScreen(&ppiScreenX, &ppiScreenY); + wxUnusedVar(ppiScreenX); wxDisplaySize(&scr_w, &scr_h); GetDC()->GetSize(&dc_w, &dc_h); - GetDC()->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth); + GetDC()->SetUserScale((double)dc_w / (double)pageWidth, + (double)dc_h / (double)pageHeight); /* prepare headers/footers renderer: */ @@ -251,7 +260,7 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage) bool wxHtmlPrintout::OnPrintPage(int page) { wxDC *dc = GetDC(); - if (dc) + if (dc && dc->IsOk()) { if (HasPage(page)) RenderPage(dc, page); @@ -264,19 +273,19 @@ bool wxHtmlPrintout::OnPrintPage(int page) void wxHtmlPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) { *minPage = 1; - if ( m_NumPages >= (signed)m_PageBreaks.Count()-1) + if ( m_NumPages >= (signed)m_PageBreaks.GetCount()-1) *maxPage = m_NumPages; else - *maxPage = (signed)m_PageBreaks.Count()-1; + *maxPage = (signed)m_PageBreaks.GetCount()-1; *selPageFrom = 1; - *selPageTo = (signed)m_PageBreaks.Count()-1; + *selPageTo = (signed)m_PageBreaks.GetCount()-1; } bool wxHtmlPrintout::HasPage(int pageNum) { - return (pageNum >= 1 && pageNum-1 <= (signed)m_PageBreaks.Count()); + return pageNum > 0 && (unsigned)pageNum < m_PageBreaks.GetCount(); } @@ -374,9 +383,9 @@ void wxHtmlPrintout::CountPages() m_PageBreaks, pos, true, INT_MAX); m_PageBreaks.Add( pos); - if( m_PageBreaks.Count() > wxHTML_PRINT_MAX_PAGES) + if( m_PageBreaks.GetCount() > wxHTML_PRINT_MAX_PAGES) { - wxMessageBox( _("HTML pagination algorithm generated more than the allowed maximum number of pages and it can continue any longer!"), + wxMessageBox( _("HTML pagination algorithm generated more than the allowed maximum number of pages and it can't continue any longer!"), _("Warning"), wxCANCEL | wxICON_ERROR ); break; } @@ -406,11 +415,12 @@ void wxHtmlPrintout::RenderPage(wxDC *dc, int page) GetPPIScreen(&ppiScreenX, &ppiScreenY); wxUnusedVar(ppiScreenX); - dc->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth); + dc->SetUserScale((double)dc_w / (double)pageWidth, + (double)dc_h / (double)pageHeight); m_Renderer->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); m_Renderer->Render((int) (ppmm_h * m_MarginLeft), (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight), m_PageBreaks, @@ -440,7 +450,7 @@ wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page) num.Printf(wxT("%i"), page); r.Replace(wxT("@PAGENUM@"), num); - num.Printf(wxT("%lu"), (unsigned long)(m_PageBreaks.Count() - 1)); + num.Printf(wxT("%lu"), (unsigned long)(m_PageBreaks.GetCount() - 1)); r.Replace(wxT("@PAGESCNT@"), num); const wxDateTime now = wxDateTime::Now(); @@ -500,7 +510,7 @@ wxHtmlEasyPrinting::wxHtmlEasyPrinting(const wxString& name, wxWindow *parentWin m_PageSetupData->SetMarginTopLeft(wxPoint(25, 25)); m_PageSetupData->SetMarginBottomRight(wxPoint(25, 25)); - SetFonts(wxEmptyString, wxEmptyString, NULL); + SetStandardFonts(DEFAULT_PRINT_FONT_SIZE); }