From 7da33e042c4e373e2e97e428f5c174f324c69c93 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 28 Sep 2009 16:15:34 +0000 Subject: [PATCH] Moved WinPrinter from private.h to printdlg.cpp. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62190 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/private.h | 46 --------------------------------------- src/msw/printdlg.cpp | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index fa95062dc0..9e40732a37 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -727,52 +727,6 @@ private: wxDECLARE_NO_COPY_CLASS(GlobalPtrLock); }; -// smart pointer like class using OpenPrinter and ClosePrinter -class WinPrinter -{ -public: - // default ctor - WinPrinter() - { - m_hPrinter = (HANDLE)NULL; - } - - WinPrinter( const wxString& printerName ) - { - Open( printerName ); - } - - ~WinPrinter() - { - Close(); - } - - BOOL Open( const wxString& printerName, LPPRINTER_DEFAULTS pDefault=(LPPRINTER_DEFAULTS)NULL ) - { - Close(); - return OpenPrinter( (LPTSTR)printerName.wx_str(), &m_hPrinter, pDefault ); - } - - BOOL Close() - { - BOOL result = TRUE; - if( m_hPrinter ) - { - result = ClosePrinter( m_hPrinter ); - m_hPrinter = (HANDLE)NULL; - } - return result; - } - - operator HANDLE() { return m_hPrinter; } - operator bool() { return m_hPrinter != (HANDLE)NULL; } - -private: - HANDLE m_hPrinter; - - wxDECLARE_NO_COPY_CLASS(WinPrinter); -}; - // register the class when it is first needed and unregister it in dtor class ClassRegistrar { diff --git a/src/msw/printdlg.cpp b/src/msw/printdlg.cpp index b9b89b6210..2d6717597a 100644 --- a/src/msw/printdlg.cpp +++ b/src/msw/printdlg.cpp @@ -42,6 +42,53 @@ #include +// smart pointer like class using OpenPrinter and ClosePrinter +class WinPrinter +{ +public: + // default ctor + WinPrinter() + { + m_hPrinter = (HANDLE)NULL; + } + + WinPrinter( const wxString& printerName ) + { + Open( printerName ); + } + + ~WinPrinter() + { + Close(); + } + + BOOL Open( const wxString& printerName, LPPRINTER_DEFAULTS pDefault=(LPPRINTER_DEFAULTS)NULL ) + { + Close(); + return OpenPrinter( (LPTSTR)printerName.wx_str(), &m_hPrinter, pDefault ); + } + + BOOL Close() + { + BOOL result = TRUE; + if( m_hPrinter ) + { + result = ClosePrinter( m_hPrinter ); + m_hPrinter = (HANDLE)NULL; + } + return result; + } + + operator HANDLE() { return m_hPrinter; } + operator bool() { return m_hPrinter != (HANDLE)NULL; } + +private: + HANDLE m_hPrinter; + + wxDECLARE_NO_COPY_CLASS(WinPrinter); +}; + + //---------------------------------------------------------------------------- // wxWindowsPrintNativeData //---------------------------------------------------------------------------- -- 2.45.2