X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa10c70ceb3a08a11302c00c9f0e29941174a21b..3a5bcc4db0851bf8cd3063917511b0b17c7f9679:/src/html/htmprint.cpp diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index 6f4912caee..720bde4849 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -9,7 +9,7 @@ ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "htmprint.h" #endif @@ -169,8 +169,7 @@ wxHtmlPrintout::~wxHtmlPrintout() void wxHtmlPrintout::CleanUpStatics() { - m_Filters.DeleteContents(TRUE); - m_Filters.Clear(); + WX_CLEAR_LIST(wxList, m_Filters); } // Adds input filter @@ -179,13 +178,11 @@ void wxHtmlPrintout::AddFilter(wxHtmlFilter *filter) m_Filters.Append(filter); } -bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage) +void wxHtmlPrintout::OnPreparePrinting() { int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h; float ppmm_h, ppmm_v; - if (!wxPrintout::OnBeginDocument(startPage, endPage)) return FALSE; - GetPageSizePixels(&pageWidth, &pageHeight); GetPageSizeMM(&mm_w, &mm_h); ppmm_h = (float)pageWidth / mm_w; @@ -237,6 +234,12 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage) )); m_Renderer->SetHtmlText(m_Document, m_BasePath, m_BasePathIsDir); CountPages(); +} + +bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage) +{ + if (!wxPrintout::OnBeginDocument(startPage, endPage)) return FALSE; + return TRUE; } @@ -257,9 +260,9 @@ bool wxHtmlPrintout::OnPrintPage(int page) void wxHtmlPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) { *minPage = 1; - *maxPage = wxHTML_PRINT_MAX_PAGES; + *maxPage = m_NumPages; *selPageFrom = 1; - *selPageTo = wxHTML_PRINT_MAX_PAGES; + *selPageTo = m_NumPages; } @@ -293,7 +296,7 @@ void wxHtmlPrintout::SetHtmlFile(const wxString& htmlfile) wxHtmlFilterHTML defaultFilter; wxString doc; - wxNode* node = m_Filters.GetFirst(); + wxList::compatibility_iterator node = m_Filters.GetFirst(); while (node) { wxHtmlFilter *h = (wxHtmlFilter*) node->GetData(); @@ -378,8 +381,10 @@ void wxHtmlPrintout::RenderPage(wxDC *dc, int page) int ppiPrinterX, ppiPrinterY; GetPPIPrinter(&ppiPrinterX, &ppiPrinterY); + wxUnusedVar(ppiPrinterX); int ppiScreenX, ppiScreenY; GetPPIScreen(&ppiScreenX, &ppiScreenY); + wxUnusedVar(ppiScreenX); dc->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth); @@ -452,7 +457,7 @@ wxHtmlEasyPrinting::wxHtmlEasyPrinting(const wxString& name, wxWindow *parentWin { m_ParentWindow = parentWindow; m_Name = name; - m_PrintData = new wxPrintData; + m_PrintData = NULL; m_PageSetupData = new wxPageSetupDialogData; m_Headers[0] = m_Headers[1] = m_Footers[0] = m_Footers[1] = wxEmptyString; @@ -472,6 +477,13 @@ wxHtmlEasyPrinting::~wxHtmlEasyPrinting() } +wxPrintData *wxHtmlEasyPrinting::GetPrintData() +{ + if (m_PrintData == NULL) + m_PrintData = new wxPrintData(); + return m_PrintData; +} + bool wxHtmlEasyPrinting::PreviewFile(const wxString &htmlfile) { @@ -520,7 +532,7 @@ bool wxHtmlEasyPrinting::PrintText(const wxString &htmltext, const wxString &bas bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2) { // Pass two printout objects: for preview, and possible printing. - wxPrintDialogData printDialogData(*m_PrintData); + wxPrintDialogData printDialogData(*GetPrintData()); wxPrintPreview *preview = new wxPrintPreview(printout1, printout2, &printDialogData); if (!preview->Ok()) { @@ -541,7 +553,7 @@ bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *pr bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout) { - wxPrintDialogData printDialogData(*m_PrintData); + wxPrintDialogData printDialogData(*GetPrintData()); wxPrinter printer(&printDialogData); if (!printer.Print(m_ParentWindow, printout, TRUE)) @@ -549,7 +561,7 @@ bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout) return FALSE; } - (*m_PrintData) = printer.GetPrintDialogData().GetPrintData(); + (*GetPrintData()) = printer.GetPrintDialogData().GetPrintData(); return TRUE; } @@ -557,31 +569,31 @@ bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout) void wxHtmlEasyPrinting::PrinterSetup() { - wxPrintDialogData printDialogData(*m_PrintData); + wxPrintDialogData printDialogData(*GetPrintData()); wxPrintDialog printerDialog(m_ParentWindow, &printDialogData); printerDialog.GetPrintDialogData().SetSetupDialog(TRUE); if (printerDialog.ShowModal() == wxID_OK) - (*m_PrintData) = printerDialog.GetPrintDialogData().GetPrintData(); + (*GetPrintData()) = printerDialog.GetPrintDialogData().GetPrintData(); } void wxHtmlEasyPrinting::PageSetup() { - if (!m_PrintData->Ok()) + if (!GetPrintData()->Ok()) { wxLogError(_("There was a problem during page setup: you may need to set a default printer.")); return; } - m_PageSetupData->SetPrintData(*m_PrintData); + m_PageSetupData->SetPrintData(*GetPrintData()); wxPageSetupDialog pageSetupDialog(m_ParentWindow, m_PageSetupData); if (pageSetupDialog.ShowModal() == wxID_OK) { - (*m_PrintData) = pageSetupDialog.GetPageSetupData().GetPrintData(); + (*GetPrintData()) = pageSetupDialog.GetPageSetupData().GetPrintData(); (*m_PageSetupData) = pageSetupDialog.GetPageSetupData(); } }