-void wxPrintData::ConvertFromNative()
-{
- HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
- HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
-
- if (!hDevMode)
- return;
-
- if ( hDevMode )
- {
- LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode);
-
-#ifndef __WXWINE__
- //// Orientation
-
- if (devMode->dmFields & DM_ORIENTATION)
- m_printOrientation = devMode->dmOrientation;
-#endif
-
- //// Collation
-
-#ifndef __WIN16__
- if (devMode->dmFields & DM_COLLATE)
- {
- if (devMode->dmCollate == DMCOLLATE_TRUE)
- m_printCollate = TRUE;
- else
- m_printCollate = FALSE;
- }
-#endif
-
- //// Number of copies
-
- if (devMode->dmFields & DM_COPIES)
- {
- m_printNoCopies = devMode->dmCopies;
- }
-
- //// Printer name
-
- if (devMode->dmDeviceName[0] != 0)
- {
- // TODO: make this Unicode compatible
- char buf[32];
- int i = 0;
- while (devMode->dmDeviceName[i] != 0)
- {
- buf[i] = devMode->dmDeviceName[i];
- i ++;
- }
- buf[i] = 0;
-
- m_printerName = buf;
- }
-
- //// Colour
-
- if (devMode->dmFields & DM_COLOR)
- {
- if (devMode->dmColor == DMCOLOR_COLOR)
- m_colour = TRUE;
- else
- m_colour = FALSE;
- }
- else
- m_colour = TRUE;
-
-#ifndef __WXWINE__
- //// Paper size
-
- // We don't know size of user defined paper and some buggy drivers
- // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
- // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
- // code wouldn't set m_paperSize correctly.
- if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER))
- {
- if (wxThePrintPaperDatabase)
- {
- wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize);
- if (paper)
- {
- m_paperId = paper->GetId();
- m_paperSize.x = paper->GetWidth() / 10;
- m_paperSize.y = paper->GetHeight() / 10;
- }
- else
- {
- // Shouldn't really get here
- wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
-
- m_paperId = wxPAPER_NONE;
- m_paperSize.x = 0;
- m_paperSize.y = 0;
- }
- }
- else
- {
- // Shouldn't really get here
- wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
-
- m_paperId = wxPAPER_NONE;
- m_paperSize.x = 0;
- m_paperSize.y = 0;
- }
- }
- else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH))
- {
- // DEVMODE is in tenths of a milimeter
- m_paperSize.x = devMode->dmPaperWidth / 10;
- m_paperSize.y = devMode->dmPaperLength / 10;
- m_paperId = wxPAPER_NONE;
- }
- else
- {
- // Shouldn't really get here
- wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
-
- m_paperSize.x = 0;
- m_paperSize.y = 0;
- m_paperId = wxPAPER_NONE;
- }
-#endif
-
- //// Duplex
-
- if (devMode->dmFields & DM_DUPLEX)
- {
- switch (devMode->dmDuplex)
- {
- case DMDUP_HORIZONTAL: {
- m_duplexMode = wxDUPLEX_HORIZONTAL; break;
- }
- case DMDUP_VERTICAL: {
- m_duplexMode = wxDUPLEX_VERTICAL; break;
- }
- default:
- case DMDUP_SIMPLEX: {
- m_duplexMode = wxDUPLEX_SIMPLEX; break;
- }
- }
- }
- else
- m_duplexMode = wxDUPLEX_SIMPLEX;
-
- //// Quality
-
- if (devMode->dmFields & DM_PRINTQUALITY)
- {
- switch (devMode->dmPrintQuality)
- {
- case DMRES_MEDIUM: {
- m_printQuality = wxPRINT_QUALITY_MEDIUM; break;
- }
- case DMRES_LOW: {
- m_printQuality = wxPRINT_QUALITY_LOW; break;
- }
- case DMRES_DRAFT: {
- m_printQuality = wxPRINT_QUALITY_DRAFT; break;
- }
- case DMRES_HIGH: {
- m_printQuality = wxPRINT_QUALITY_HIGH; break;
- }
- default:
- {
- // TODO: if the printer fills in the resolution in DPI, how
- // will the application know if it's high, low, draft etc.??
- // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
- m_printQuality = devMode->dmPrintQuality; break;
-
- }
- }
- }
- else
- m_printQuality = wxPRINT_QUALITY_HIGH;
-
- GlobalUnlock(hDevMode);
- }
-
- 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 = (LPTSTR)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__