wxWindowsPrinter::Print ignored the "All pages" option, instead it was using the (invalid) from-to range (patch #835254); Slight code cleanup.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -98,16 +98,16 @@ wxWindowsPrinter::~wxWindowsPrinter()
|
|||||||
|
|
||||||
bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
||||||
{
|
{
|
||||||
sm_abortIt = FALSE;
|
sm_abortIt = false;
|
||||||
sm_abortWindow = NULL;
|
sm_abortWindow = NULL;
|
||||||
|
|
||||||
if (!printout)
|
if (!printout)
|
||||||
{
|
{
|
||||||
sm_lastError = wxPRINTER_ERROR;
|
sm_lastError = wxPRINTER_ERROR;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printout->SetIsPreview(FALSE);
|
printout->SetIsPreview(false);
|
||||||
|
|
||||||
if (m_printDialogData.GetMinPage() < 1)
|
if (m_printDialogData.GetMinPage() < 1)
|
||||||
m_printDialogData.SetMinPage(1);
|
m_printDialogData.SetMinPage(1);
|
||||||
@@ -120,7 +120,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
{
|
{
|
||||||
dc = PrintDialog(parent);
|
dc = PrintDialog(parent);
|
||||||
if (!dc)
|
if (!dc)
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
if (!dc || !dc->Ok())
|
if (!dc || !dc->Ok())
|
||||||
{
|
{
|
||||||
if (dc) delete dc;
|
if (dc) delete dc;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logPPIScreenX = 0;
|
int logPPIScreenX = 0;
|
||||||
@@ -150,7 +150,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
{
|
{
|
||||||
delete dc;
|
delete dc;
|
||||||
sm_lastError = wxPRINTER_ERROR;
|
sm_lastError = wxPRINTER_ERROR;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
||||||
@@ -180,7 +180,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
{
|
{
|
||||||
sm_lastError = wxPRINTER_ERROR;
|
sm_lastError = wxPRINTER_ERROR;
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only set min and max, because from and to have been
|
// Only set min and max, because from and to have been
|
||||||
@@ -219,19 +219,32 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
delete dc;
|
delete dc;
|
||||||
}
|
}
|
||||||
sm_abortWindow = win;
|
sm_abortWindow = win;
|
||||||
sm_abortWindow->Show(TRUE);
|
sm_abortWindow->Show();
|
||||||
wxSafeYield();
|
wxSafeYield();
|
||||||
|
|
||||||
printout->OnBeginPrinting();
|
printout->OnBeginPrinting();
|
||||||
|
|
||||||
sm_lastError = wxPRINTER_NO_ERROR;
|
sm_lastError = wxPRINTER_NO_ERROR;
|
||||||
|
|
||||||
|
int minPageNum = minPage, maxPageNum = maxPage;
|
||||||
|
|
||||||
|
if ( !m_printDialogData.GetAllPages() )
|
||||||
|
{
|
||||||
|
minPageNum = minPage;
|
||||||
|
maxPageNum = maxPage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
minPageNum = m_printDialogData.GetFromPage();
|
||||||
|
maxPageNum = m_printDialogData.GetToPage();
|
||||||
|
}
|
||||||
|
|
||||||
int copyCount;
|
int copyCount;
|
||||||
for ( copyCount = 1;
|
for ( copyCount = 1;
|
||||||
copyCount <= m_printDialogData.GetNoCopies();
|
copyCount <= m_printDialogData.GetNoCopies();
|
||||||
copyCount++ )
|
copyCount++ )
|
||||||
{
|
{
|
||||||
if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
|
if ( !printout->OnBeginDocument(minPageNum, maxPageNum) )
|
||||||
{
|
{
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
wxLogError(_("Could not start printing."));
|
wxLogError(_("Could not start printing."));
|
||||||
@@ -245,8 +258,9 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pn;
|
int pn;
|
||||||
for ( pn = m_printDialogData.GetFromPage();
|
|
||||||
pn <= m_printDialogData.GetToPage() && printout->HasPage(pn);
|
for ( pn = minPageNum;
|
||||||
|
pn <= maxPageNum && printout->HasPage(pn);
|
||||||
pn++ )
|
pn++ )
|
||||||
{
|
{
|
||||||
if ( sm_abortIt )
|
if ( sm_abortIt )
|
||||||
@@ -273,7 +287,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
|
|
||||||
if (sm_abortWindow)
|
if (sm_abortWindow)
|
||||||
{
|
{
|
||||||
sm_abortWindow->Show(FALSE);
|
sm_abortWindow->Show(false);
|
||||||
delete sm_abortWindow;
|
delete sm_abortWindow;
|
||||||
sm_abortWindow = NULL;
|
sm_abortWindow = NULL;
|
||||||
}
|
}
|
||||||
@@ -310,7 +324,7 @@ wxDC* wxWindowsPrinter::PrintDialog(wxWindow *parent)
|
|||||||
bool wxWindowsPrinter::Setup(wxWindow *parent)
|
bool wxWindowsPrinter::Setup(wxWindow *parent)
|
||||||
{
|
{
|
||||||
wxPrintDialog dialog(parent, & m_printDialogData);
|
wxPrintDialog dialog(parent, & m_printDialogData);
|
||||||
dialog.GetPrintDialogData().SetSetupDialog(TRUE);
|
dialog.GetPrintDialogData().SetSetupDialog(true);
|
||||||
|
|
||||||
int ret = dialog.ShowModal();
|
int ret = dialog.ShowModal();
|
||||||
|
|
||||||
@@ -349,7 +363,7 @@ wxWindowsPrintPreview::~wxWindowsPrintPreview()
|
|||||||
bool wxWindowsPrintPreview::Print(bool interactive)
|
bool wxWindowsPrintPreview::Print(bool interactive)
|
||||||
{
|
{
|
||||||
if (!m_printPrintout)
|
if (!m_printPrintout)
|
||||||
return FALSE;
|
return false;
|
||||||
wxWindowsPrinter printer(&m_printDialogData);
|
wxWindowsPrinter printer(&m_printDialogData);
|
||||||
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
||||||
}
|
}
|
||||||
@@ -388,10 +402,10 @@ void wxWindowsPrintPreview::DetermineScaling()
|
|||||||
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
|
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
|
||||||
|
|
||||||
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
|
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
|
||||||
m_isOk = FALSE;
|
m_isOk = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_isOk = FALSE;
|
m_isOk = false;
|
||||||
|
|
||||||
m_pageWidth = printerXRes;
|
m_pageWidth = printerXRes;
|
||||||
m_pageHeight = printerYRes;
|
m_pageHeight = printerYRes;
|
||||||
|
Reference in New Issue
Block a user