]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/printdlg.cpp
fix for opening files with VC++ 8 (closes bug 994337)
[wxWidgets.git] / src / msw / printdlg.cpp
index 2d0eb79e6c2898ab41fd786aa3d5bfac5be183d6..d3210c96b99ec1209c37e8db04016d2b96d3bf6d 100644 (file)
@@ -5,64 +5,86 @@
 // Modified by:
 // Created:     04/01/98
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows license
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "printdlg.h"
+// ===========================================================================
+// declarations
+// ===========================================================================
+
+// ---------------------------------------------------------------------------
+// headers
+// ---------------------------------------------------------------------------
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+    #pragma implementation "printdlg.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
+// Don't use the Windows print dialog 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/app.h"
 #endif
 
 #include "wx/printdlg.h"
 #include "wx/dcprint.h"
 
-// Have to emulate page setup dialog for Win16
-#if !defined(__WIN95__)
-#include "wx/generic/prntdlgg.h"
-#endif
-
 #include <stdlib.h>
-#include <windows.h>
+
+#include "wx/msw/private.h"
+
 #include <commdlg.h>
 
 #ifndef __WIN32__
-#include <print.h>
+    #include <print.h>
 #endif
 
-// Clash with Windows header files
-#ifdef StartDoc
-#undef StartDoc
-#endif
+// ---------------------------------------------------------------------------
+// wxWin macros
+// ---------------------------------------------------------------------------
 
-#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
-IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
-#endif
+    IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
+    IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
+
+// ===========================================================================
+// implementation
+// ===========================================================================
 
-wxPrintDialog::wxPrintDialog(void):
-wxDialog()
+// ---------------------------------------------------------------------------
+// wxPrintDialog
+// ---------------------------------------------------------------------------
+
+wxPrintDialog::wxPrintDialog()
 {
     m_dialogParent = NULL;
     m_printerDC = NULL;
     m_destroyDC = TRUE;
 }
 
-wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data):
-wxDialog()
+wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
 {
     Create(p, data);
 }
 
+wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
+{
+    wxPrintDialogData data2;
+    if ( data )
+        data2 = *data;
+
+    Create(p, &data2);
+}
+
 bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
 {
     m_dialogParent = p;
@@ -71,23 +93,34 @@ bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
 
     if ( data )
         m_printDialogData = *data;
-    
+
     m_printDialogData.SetOwnerWindow(p);
 
     return TRUE;
 }
 
-wxPrintDialog::~wxPrintDialog(void)
+wxPrintDialog::~wxPrintDialog()
 {
     if (m_destroyDC && m_printerDC)
         delete m_printerDC;
 }
 
-int wxPrintDialog::ShowModal(void)
+int wxPrintDialog::ShowModal()
 {
     m_printDialogData.ConvertToNative();
-    
-    bool ret = (PrintDlg( (PRINTDLG *)m_printDialogData.GetNativeData() ) != 0);
+
+    PRINTDLG* p = (PRINTDLG *)m_printDialogData.GetNativeData() ;
+    if (m_dialogParent)
+        p->hwndOwner = (HWND) m_dialogParent->GetHWND();
+    else if (wxTheApp->GetTopWindow())
+        p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
+    else
+        p->hwndOwner = 0;
+
+    bool ret = (PrintDlg( p ) != 0);
+
+    p->hwndOwner = 0;
+
     if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
     {
         wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
@@ -97,17 +130,11 @@ int wxPrintDialog::ShowModal(void)
     }
     else
     {
-    /*
-    char buf[256];
-    DWORD exError = CommDlgExtendedError();
-    sprintf(buf, "ret = %d, ex error = %d", (int) ret, (int) exError);
-    wxMessageBox(buf);
-        */
         return wxID_CANCEL;
     }
 }
 
-wxDC *wxPrintDialog::GetPrintDC(void)
+wxDC *wxPrintDialog::GetPrintDC()
 {
     if (m_printerDC)
     {
@@ -118,18 +145,16 @@ wxDC *wxPrintDialog::GetPrintDC(void)
         return (wxDC*) NULL;
 }
 
-/*
-* wxPageSetupDialog
-*/
+// ---------------------------------------------------------------------------
+// wxPageSetupDialog
+// ---------------------------------------------------------------------------
 
-wxPageSetupDialog::wxPageSetupDialog(void):
-wxDialog()
+wxPageSetupDialog::wxPageSetupDialog()
 {
     m_dialogParent = NULL;
 }
 
-wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
-wxDialog()
+wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
 {
     Create(p, data);
 }
@@ -137,25 +162,34 @@ wxDialog()
 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
 {
     m_dialogParent = p;
-    
+
     if (data)
         m_pageSetupData = (*data);
-    
+
 #if defined(__WIN95__)
     m_pageSetupData.SetOwnerWindow(p);
 #endif
     return TRUE;
 }
 
-wxPageSetupDialog::~wxPageSetupDialog(void)
+wxPageSetupDialog::~wxPageSetupDialog()
 {
 }
 
-int wxPageSetupDialog::ShowModal(void)
+int wxPageSetupDialog::ShowModal()
 {
 #ifdef __WIN95__
     m_pageSetupData.ConvertToNative();
-    if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
+    PAGESETUPDLG *p = (PAGESETUPDLG *)m_pageSetupData.GetNativeData();
+    if (m_dialogParent)
+        p->hwndOwner = (HWND) m_dialogParent->GetHWND();
+    else if (wxTheApp->GetTopWindow())
+        p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
+    else
+        p->hwndOwner = 0;
+    BOOL retVal = PageSetupDlg( p ) ;
+    p->hwndOwner = 0;
+    if (retVal)
     {
         m_pageSetupData.ConvertFromNative();
         return wxID_OK;
@@ -171,3 +205,5 @@ int wxPageSetupDialog::ShowModal(void)
 #endif
 }
 
+#endif
+    // wxUSE_PRINTING_ARCHITECTURE