]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/prntdlgg.cpp
more fixes for paused thread termination
[wxWidgets.git] / src / generic / prntdlgg.cpp
index a9d860300bf73c3dbb90f4f142de5eaa9c5f6eed..b1ff434de5cb718bd0b0cd53b92cc625b2f2af8f 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "wx/defs.h"
 
-#define WINDOWS_PRINTING    (wxTheApp->GetPrintMode() == wxPRINT_WINDOWS)
-
 #ifndef WX_PRECOMP
 #include "wx/utils.h"
 #include "wx/dc.h"
 #endif
 
 #include "wx/generic/prntdlgg.h"
+
+#if wxUSE_POSTSCRIPT
+#include "wx/generic/dcpsg.h"
+#endif
+
 #include "wx/printdlg.h"
 
+// For print paper things
+#include "wx/prntbase.h"
+
 #include <stdlib.h>
 #include <string.h>
 
+#if wxUSE_POSTSCRIPT
+
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_CLASS(wxGenericPrintDialog, wxDialog)
 IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog)
@@ -70,7 +78,7 @@ extern wxPrintPaperDatabase *wxThePrintPaperDatabase;
 
 
 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data):
-  wxDialog(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
+  wxDialog(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
 {
   if ( data )
     printData = *data;
@@ -158,14 +166,14 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
   {
     wxThePrintSetupData->SetPrinterMode(PS_FILE);
 
-    char *f = wxFileSelector(_("PostScript file"),
-        wxPathOnly(wxThePrintSetupData->GetPrinterFile()),
-        wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()),
-        "ps", "*.ps", 0, this);
-    if (f)
-      wxThePrintSetupData->SetPrinterFile(f);
-    else
-      return;
+    wxString f = wxFileSelector(_("PostScript file"),
+                                wxPathOnly(wxThePrintSetupData->GetPrinterFile()),
+                                wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()),
+                                "ps", "*.ps", 0, this);
+    if ( f.IsEmpty() )
+        return;
+
+    wxThePrintSetupData->SetPrinterFile(f);
   }
   else
     wxThePrintSetupData->SetPrinterMode(PS_PRINTER);
@@ -275,7 +283,7 @@ wxDC *wxGenericPrintDialog::GetPrintDC(void)
  */
 
 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSetupData* data):
-  wxDialog(parent, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
+  wxDialog(parent, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL|wxTAB_TRAVERSAL)
 {
   if ( data )
     printData = *data;
@@ -295,8 +303,14 @@ wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSe
   orientationRadioBox->SetSelection(0);
 
   (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Options"), wxPoint(10, 130), wxSize(200,50) );
+
+  int colourXPos = 145;
+
+#ifdef __WXMOTIF__
+  colourXPos = 150;
+#endif
   
-  colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, _("Print in colour"), wxPoint(15, 145));
+  colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, _("Print in colour"), wxPoint(15, colourXPos));
   
 
   (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Print spooling"), wxPoint(230, 10), wxSize(200,170) );
@@ -367,6 +381,7 @@ bool wxGenericPrintSetupDialog::TransferDataFromWindow(void)
     if (!val.IsNull() && val != "")
       printData.SetPaperName((char *)(const char *)val);
   }
+  *wxThePrintSetupData = GetPrintData();
   return TRUE;
 }
 
@@ -389,7 +404,12 @@ wxChoice *wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x, int *y)
       sel = i;
   }
 
-  wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(170, -1), n,
+  int width = 170;
+#ifdef __WXMOTIF__
+  width = 150;
+#endif
+
+  wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(width, -1), n,
     choices);
     
   delete[] choices;
@@ -397,6 +417,8 @@ wxChoice *wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x, int *y)
   choice->SetSelection(sel);
   return choice;
 }
+#endif
+  // wxUSE_POSTSCRIPT
 
 /*
  * Generic page setup dialog
@@ -404,29 +426,24 @@ wxChoice *wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x, int *y)
 
 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event))
 {
-  if (wxTheApp->GetPrintMode() == wxPRINT_POSTSCRIPT)
-  {
-    wxGenericPrintSetupDialog *genericPrintSetupDialog =
-          new wxGenericPrintSetupDialog(this, wxThePrintSetupData);
-    int ret = genericPrintSetupDialog->ShowModal();
-    if (ret == wxID_OK)
-      *wxThePrintSetupData = genericPrintSetupDialog->GetPrintData();
+    // We no longer query GetPrintMode, so we can eliminate the need
+    // to call SetPrintMode.
+    // This has the limitation that we can't explicitly call the PostScript
+    // print setup dialog from the generic Page Setup dialog under Windows,
+    // but since this choice would only happen when trying to do PostScript
+    // printing under Windows (and only in 16-bit Windows which
+    // doesn't have a Windows-specific page setup dialog) it's worth it.
 
-    genericPrintSetupDialog->Close(TRUE);
-  }
-#ifdef __WXMSW__
-  else
-  {
     wxPrintData data;
     data.SetSetupDialog(TRUE);
-    wxPrintDialog printDialog(this, & data);
-    printDialog.Show(TRUE);
-  }
-#endif
+    wxPrintDialog *printDialog = new wxPrintDialog(this, & data);
+    printDialog->ShowModal();
+
+    printDialog->Destroy();
 }
 
 wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetupData* data):
-  wxDialog(parent, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL|wxDEFAULT_DIALOG_STYLE)
+  wxDialog(parent, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL|wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL)
 {
   if ( data )
     pageData = *data;
@@ -434,6 +451,10 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   int buttonWidth = 75;
   int buttonHeight = 25;
   int spacing = 5;
+#ifdef __WXMOTIF__
+  spacing = 15;
+#endif
+
   int yPos = 5;
   int xPos = 5;
 
@@ -454,6 +475,10 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   xPos = 5;
   yPos += 35;
 
+#ifdef __WXMOTIF__
+  yPos += 10;
+#endif
+
   paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
 
   xPos = 5;
@@ -469,6 +494,10 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   yPos += 60;
 
   int staticWidth = 110;
+#ifdef __WXMOTIF__
+  staticWidth += 20;
+#endif
+
   int textWidth = 60;
   spacing = 10;
 
@@ -542,12 +571,16 @@ bool wxGenericPageSetupDialog::TransferDataFromWindow(void)
     int sel = orientationRadioBox->GetSelection();
     if (sel == 0)
     {
+#if wxUSE_POSTSCRIPT
       wxThePrintSetupData->SetPrinterOrientation(wxPORTRAIT);
+#endif
       pageData.SetOrientation(wxPORTRAIT);
     }
     else
     {
+#if wxUSE_POSTSCRIPT
       wxThePrintSetupData->SetPrinterOrientation(wxLANDSCAPE);
+#endif
       pageData.SetOrientation(wxLANDSCAPE);
     }
   }
@@ -563,6 +596,7 @@ bool wxGenericPageSetupDialog::TransferDataFromWindow(void)
         }
     }
   }
+
   return TRUE;
 }