// Gets an HDC for the specified printer configuration WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) { #if defined(__WXUNIVERSAL__) && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) #if 0 wxPostScriptPrintNativeData *data = (wxPostScriptPrintNativeData *) printDataConst.GetNativeData(); // FIXME: how further ??? #else return 0; #endif #else // Postscript vs. native Windows wxWindowsPrintNativeData *data = (wxWindowsPrintNativeData *) printDataConst.GetNativeData(); data->TransferFrom( printDataConst ); wxChar* driverName = (wxChar*) NULL; wxString devNameStr = printDataConst.GetPrinterName(); wxChar* portName = (wxChar*) NULL; // Obsolete in WIN32 const wxChar* deviceName; if ( !devNameStr ) deviceName = (wxChar*) NULL; else deviceName = devNameStr.c_str(); LPDEVMODE lpDevMode = (LPDEVMODE) NULL; HGLOBAL hDevMode = (HGLOBAL)(DWORD) data->GetDevMode(); if ( hDevMode ) lpDevMode = (DEVMODE*) GlobalLock(hDevMode); if ( !devNameStr ) { // Retrieve the default device name wxString portName; if ( !wxGetDefaultDeviceName(devNameStr, portName) ) { return 0; // Could not get default device name } deviceName = devNameStr.c_str(); } #ifdef __WIN32__ HDC hDC = CreateDC(driverName, deviceName, portName, (DEVMODE *) lpDevMode); #else HDC hDC = CreateDC(driverName, deviceName, portName, (LPSTR) lpDevMode); #endif if (hDevMode && lpDevMode) GlobalUnlock(hDevMode); return (WXHDC) hDC; #endif }
// Gets an HDC for the specified printer configuration WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) { #if wxUSE_PS_PRINTING // TODO wxUnusedVar(printDataConst); return 0; #else // native Windows printing wxWindowsPrintNativeData *data = (wxWindowsPrintNativeData *) printDataConst.GetNativeData(); data->TransferFrom( printDataConst ); wxString deviceName = printDataConst.GetPrinterName(); if ( deviceName.empty() ) { // Retrieve the default device name wxString portName; if ( !wxGetDefaultDeviceName(deviceName, portName) ) { return 0; // Could not get default device name } } GlobalPtrLock lockDevMode; const HGLOBAL devMode = data->GetDevMode(); if ( devMode ) lockDevMode.Init(devMode); HDC hDC = ::CreateDC ( NULL, // no driver name as we use device name deviceName.t_str(), NULL, // unused static_cast<DEVMODE *>(lockDevMode.Get()) ); if ( !hDC ) { wxLogLastError(wxT("CreateDC(printer)")); } return (WXHDC) hDC; #endif // PostScript/Windows printing }
void wxPrintData::operator=(const wxPrintData& data) { 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; m_bin = data.m_bin; m_printMode = data.m_printMode; m_filename = data.m_filename; // UnRef old m_nativeData if (m_nativeData) { m_nativeData->m_ref--; if (m_nativeData->m_ref == 0) delete m_nativeData; } // Set Ref new one m_nativeData = data.GetNativeData(); m_nativeData->m_ref++; if (m_privData) { delete [] m_privData; m_privData = NULL; } m_privDataLen = data.GetPrivDataLen(); if (m_privDataLen > 0) { m_privData = new char[m_privDataLen]; memcpy( m_privData, data.GetPrivData(), m_privDataLen ); } }
// Gets an HDC for the specified printer configuration WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) { #if wxUSE_PS_PRINTING // TODO wxUnusedVar(printDataConst); return 0; #else // native Windows printing wxWindowsPrintNativeData *data = (wxWindowsPrintNativeData *) printDataConst.GetNativeData(); data->TransferFrom( printDataConst ); wxString deviceName = printDataConst.GetPrinterName(); if ( deviceName.empty() ) { // Retrieve the default device name wxString portName; if ( !wxGetDefaultDeviceName(deviceName, portName) ) { return 0; // Could not get default device name } } HGLOBAL hDevMode = (HGLOBAL)(DWORD) data->GetDevMode(); DEVMODE *lpDevMode = hDevMode ? (DEVMODE *)::GlobalLock(hDevMode) : NULL; HDC hDC = ::CreateDC(NULL, deviceName, NULL, lpDevMode); if ( !hDC ) wxLogLastError(_T("CreateDC(printer)")); if ( lpDevMode ) ::GlobalUnlock(hDevMode); return (WXHDC) hDC; #endif // PostScript/Windows printing }