/////////////////////////////////////////////////////////////////////////////
-// Name: printwin.cpp
+// Name: src/msw/printwin.cpp
// Purpose: wxWindowsPrinter framework
// Author: Julian Smart
// Modified by:
// headers
// ---------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "printwin.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#pragma hdrstop
#endif
-#include "wx/defs.h"
-
// Don't use the Windows printer if we're in wxUniv mode and using
// the PostScript architecture
#if wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXUNIVERSAL__) || !wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
#ifndef WX_PRECOMP
+ #include "wx/msw/wrapcdlg.h"
#include "wx/window.h"
#include "wx/msw/private.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/msgdlg.h"
#include "wx/intl.h"
+ #include "wx/log.h"
+ #include "wx/dcprint.h"
#endif
#include "wx/msw/printwin.h"
-#include "wx/dcprint.h"
#include "wx/printdlg.h"
-#include "wx/log.h"
#include "wx/msw/private.h"
#include <stdlib.h>
-#include "wx/msw/private.h"
-
-#include <commdlg.h>
-
#ifndef __WIN32__
#include <print.h>
#endif
wxWindow *win = CreateAbortWindow(parent, printout);
wxYield();
-#if defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__)
+#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__)
#ifdef STRICT
::SetAbortProc((HDC) dc->GetHDC(), (ABORTPROC) m_lpAbortProc);
#else
sm_lastError = wxPRINTER_ERROR;
delete dc;
+ return false;
}
sm_abortWindow = win;
sm_abortWindow->Show();
delete dc;
- return (sm_lastError == wxPRINTER_NO_ERROR);
+ return sm_lastError == wxPRINTER_NO_ERROR;
}
wxDC* wxWindowsPrinter::PrintDialog(wxWindow *parent)
return (ret == wxID_OK);
#else
- return wxID_CANCEL;
+ return false;
#endif
}
void wxWindowsPrintPreview::DetermineScaling()
{
- HDC dc = ::GetDC(NULL);
+ ScreenHDC dc;
int screenWidth = ::GetDeviceCaps(dc, HORZSIZE);
- int screenYRes = ::GetDeviceCaps(dc, VERTRES);
+ int screenXRes = ::GetDeviceCaps(dc, HORZRES);
int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
m_previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
- ::ReleaseDC(NULL, dc);
// Get a device context for the currently selected printer
wxPrinterDC printerDC(m_printDialogData.GetPrintData());
int printerWidth = 150;
- int printerHeight wxDUMMY_INITIALIZE(250);
int printerXRes = 1500;
int printerYRes = 2500;
- dc = GetHdcOf(printerDC);
- if ( dc )
+ if ( printerDC.Ok() )
{
+ HDC dc = GetHdcOf(printerDC);
+
printerWidth = ::GetDeviceCaps(dc, HORZSIZE);
- printerHeight = ::GetDeviceCaps(dc, VERTSIZE);
+ int printerHeight = ::GetDeviceCaps(dc, VERTSIZE);
printerXRes = ::GetDeviceCaps(dc, HORZRES);
printerYRes = ::GetDeviceCaps(dc, VERTRES);
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
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;
+ }
}
else
+ {
m_isOk = false;
+ }
m_pageWidth = printerXRes;
m_pageHeight = printerYRes;
// At 100%, the page should look about page-size on the screen.
- m_previewScale = (float)((float)screenWidth/(float)printerWidth);
- m_previewScale = m_previewScale * (float)((float)screenYRes/(float)printerYRes);
+ //
+ // TODO: the scale could be different in vertical and horizontal directions
+ float screenDPI = (float)screenXRes / screenWidth;
+ float printerDPI = (float)printerXRes / printerWidth;
+
+ m_previewScale = screenDPI / printerDPI;
}
/****************************************************************************
DispatchMessage(&msg);
}
- /* bAbort is TRUE (return is FALSE) if the user has aborted */
+ /* bAbort is TRUE (return is FALSE) if the user has aborted */
- return (!wxPrinterBase::sm_abortIt);
+ return !wxPrinterBase::sm_abortIt;
}
#endif