+
+ if (hDevNames)
+ {
+ LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(hDevNames);
+ if (lpDevNames)
+ {
+ // TODO: Unicode-ification
+
+ // Get the port name
+ // port is obsolete in WIN32
+ // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
+
+ // Get the printer name
+ wxString printerName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
+
+ // Not sure if we should check for this mismatch
+// wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
+
+ if (printerName != wxT(""))
+ m_printerName = printerName;
+
+ GlobalUnlock(hDevNames);
+ }
+ }
+}
+
+#endif
+
+#ifdef __WXMAC__
+void wxPrintData::ConvertToNative()
+{
+#ifdef TARGET_CARBON
+#else
+ (**m_macPrintInfo).prJob.iCopies = m_printNoCopies ;
+#endif
+}
+
+void wxPrintData::ConvertFromNative()
+{
+#ifdef TARGET_CARBON
+#else
+ m_printNoCopies = (**m_macPrintInfo).prJob.iCopies ;
+#endif
+}
+#endif
+
+void wxPrintData::operator=(const wxPrintData& data)
+{
+#ifdef __WXMAC__
+#ifdef TARGET_CARBON
+#else
+ m_macPrintInfo = data.m_macPrintInfo ;
+ HandToHand( (Handle*) &m_macPrintInfo ) ;
+#endif
+#endif
+ m_printNoCopies = data.m_printNoCopies;
+ m_printCollate = data.m_printCollate;
+ m_printOrientation = data.m_printOrientation;
+ m_printerName = data.m_printerName;
+ m_colour = data.m_colour;
+ m_duplexMode = data.m_duplexMode;
+ m_printQuality = data.m_printQuality;
+ m_paperId = data.m_paperId;
+ m_paperSize = data.m_paperSize;
+
+ // PostScript-specific data
+ m_printerCommand = data.m_printerCommand;
+ m_previewCommand = data.m_previewCommand;
+ m_printerOptions = data.m_printerOptions;
+ m_filename = data.m_filename;
+ m_afmPath = data.m_afmPath;
+ m_printerScaleX = data.m_printerScaleX;
+ m_printerScaleY = data.m_printerScaleY;
+ m_printerTranslateX = data.m_printerTranslateX;
+ m_printerTranslateY = data.m_printerTranslateY;
+ m_printMode = data.m_printMode;
+}
+
+// For compatibility
+#if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
+void wxPrintData::operator=(const wxPrintSetupData& setupData)
+{
+ SetPrinterCommand(setupData.GetPrinterCommand());
+ SetPreviewCommand(setupData.GetPrintPreviewCommand());
+ SetPrinterOptions(setupData.GetPrinterOptions());
+
+ long xt, yt;
+ setupData.GetPrinterTranslation(& xt, & yt);
+ SetPrinterTranslation(xt, yt);
+
+ double xs, ys;
+ setupData.GetPrinterScaling(& xs, & ys);
+ SetPrinterScaling(xs, ys);
+
+ SetOrientation(setupData.GetPrinterOrientation());
+ SetPrintMode((wxPrintMode) setupData.GetPrinterMode());
+ SetFontMetricPath(setupData.GetAFMPath());
+ if (setupData.GetPaperName() != "")
+ SetPaperId(wxThePrintPaperDatabase->ConvertNameToId(setupData.GetPaperName()));
+ SetColour(setupData.GetColour());
+ SetFilename(setupData.GetPrinterFile());
+}
+#endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
+
+
+// ----------------------------------------------------------------------------
+// Print dialog data
+// ----------------------------------------------------------------------------
+
+wxPrintDialogData::wxPrintDialogData()
+{
+#ifdef __WXMSW__
+ m_printDlgData = NULL;
+#endif
+ m_printFromPage = 0;
+ m_printToPage = 0;
+ m_printMinPage = 0;
+ m_printMaxPage = 0;
+ m_printNoCopies = 1;
+ m_printAllPages = FALSE;
+ m_printCollate = FALSE;
+ m_printToFile = FALSE;
+ m_printSelection = FALSE;
+ m_printEnableSelection = FALSE;
+ m_printEnablePageNumbers = TRUE;
+ m_printEnablePrintToFile = TRUE;
+ m_printEnableHelp = FALSE;
+ m_printSetupDialog = FALSE;
+}
+
+wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData)
+{
+#ifdef __WXMSW__
+ m_printDlgData = NULL;
+#endif
+ (*this) = dialogData;
+}
+
+wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData)
+{
+#ifdef __WXMSW__
+ m_printDlgData = NULL;
+#endif
+ m_printFromPage = 0;
+ m_printToPage = 0;
+ m_printMinPage = 0;
+ m_printMaxPage = 0;
+ m_printNoCopies = 1;
+ m_printAllPages = FALSE;
+ m_printCollate = FALSE;
+ m_printToFile = FALSE;
+ m_printSelection = FALSE;
+ m_printEnableSelection = FALSE;
+ m_printEnablePageNumbers = TRUE;
+ m_printEnablePrintToFile = TRUE;
+ m_printEnableHelp = FALSE;
+ m_printSetupDialog = FALSE;
+
+ m_printData = printData;
+}
+
+wxPrintDialogData::~wxPrintDialogData()
+{
+#ifdef __WXMSW__
+ PRINTDLG *pd = (PRINTDLG *) m_printDlgData;
+ if ( pd && pd->hDevMode )
+ GlobalFree(pd->hDevMode);
+ if ( pd )
+ delete pd;
+#endif
+}
+
+#ifdef __WXMSW__
+void wxPrintDialogData::ConvertToNative()
+{
+ m_printData.ConvertToNative();
+
+ PRINTDLG *pd = (PRINTDLG*) m_printDlgData;
+
+ if (!pd)
+ {
+ pd = new PRINTDLG;
+ m_printDlgData = (void*) pd;
+
+ // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
+#ifdef __GNUWIN32__
+ pd->lStructSize = 66 ;
+#else
+ pd->lStructSize = sizeof(PRINTDLG);
+#endif
+ pd->hwndOwner = (HWND)NULL;
+ pd->hDevMode = NULL; // Will be created by PrintDlg
+ pd->hDevNames = NULL; // Ditto
+
+ pd->Flags = PD_RETURNDEFAULT;
+ pd->nCopies = 1;
+ }
+
+ // Pass the devmode data to the PRINTDLG structure, since it'll
+ // be needed when PrintDlg is called.
+ if (pd->hDevMode)
+ {
+ GlobalFree(pd->hDevMode);
+ }
+
+ // Pass the devnames data to the PRINTDLG structure, since it'll
+ // be needed when PrintDlg is called.
+ if (pd->hDevNames)
+ {
+ GlobalFree(pd->hDevNames);
+ }
+
+ pd->hDevMode = (HGLOBAL)(DWORD) m_printData.GetNativeData();
+
+ m_printData.SetNativeData((void*) NULL);
+
+ wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
+
+ pd->hDevNames = (HGLOBAL)(DWORD) m_printData.GetNativeDataDevNames();
+
+ m_printData.SetNativeDataDevNames((void*) NULL);
+