]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/prntdlgg.cpp
OnExit() is called for modules which were initialized even if the init of
[wxWidgets.git] / src / generic / prntdlgg.cpp
index cf3e8a61ff416ae465a424e2422de627c9d4a90c..43f334039fec0fdcac8b35b5d0af1c1de6fd978e 100644 (file)
 #include "wx/app.h"
 #include "wx/frame.h"
 #include "wx/stattext.h"
+#include "wx/statbox.h"
 #include "wx/button.h"
 #include "wx/checkbox.h"
 #include "wx/textctrl.h"
 #include "wx/radiobox.h"
 #include "wx/filedlg.h"
 #include "wx/choice.h"
+#include <wx/intl.h>
 #endif
 
 #include "wx/generic/prntdlgg.h"
@@ -68,68 +70,56 @@ 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)
 {
   if ( data )
     printData = *data;
+  
+  (void)new wxStaticBox( this, -1, _( "Printer options" ), wxPoint( 5, 5), wxSize( 300, 60 ) );
 
-  int buttonWidth = 65;
-  int buttonHeight = 25;
-  int spacing = 5;
-  int yPos = 5;
-  int xPos = 5;
+  printToFileCheckBox = new wxCheckBox(this, wxPRINTID_PRINTTOFILE, _("Print to File"), wxPoint(20, 25) );
+  
+  setupButton = new wxButton(this, wxPRINTID_SETUP, _("Setup..."), wxPoint(160, 25), wxSize(100, -1));
+  
+  wxString *choices = new wxString[2];
+  choices[0] = _("All");
+  choices[1] = _("Pages");
+  
+  fromText = (wxTextCtrl*)NULL;
+  
+  if(printData.GetFromPage() != 0)
+  {
+     rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"),
+                                    wxPoint(5, 80), wxSize(-1, -1), 2, choices, 1, wxRA_VERTICAL);
+     rangeRadioBox->SetSelection(1);
+  }
+  
+  if(printData.GetFromPage() != 0)
+  {
+     (void) new wxStaticText(this, wxPRINTID_STATIC, _("From:"), wxPoint(5, 135));
+
+     fromText = new wxTextCtrl(this, wxPRINTID_FROM, "", wxPoint(45, 130), wxSize(40, -1));
+     
+     (void) new wxStaticText(this, wxPRINTID_STATIC, _("To:"), wxPoint(100, 135));
+     
+     toText = new wxTextCtrl(this, wxPRINTID_TO, "", wxPoint(133, 130), wxSize(40, -1));
+  }
+  
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Copies:"), wxPoint(200, 135));
 
-  wxButton *okButton = new wxButton(this, wxID_OK, "OK", wxPoint(5, yPos), wxSize(buttonWidth, buttonHeight));
-  (void) new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(buttonWidth + 5 + spacing, yPos), wxSize(buttonWidth, buttonHeight));
+  noCopiesText = new wxTextCtrl(this, wxPRINTID_COPIES, "", wxPoint(252, 130), wxSize(40, -1));
 
-  setupButton = new wxButton(this, wxPRINTID_SETUP, "Setup...", wxPoint(buttonWidth*2 + 5 + 2*spacing, yPos), wxSize(buttonWidth, buttonHeight));
+  wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(40, 180), wxSize(100, -1));
+  (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(180, 180), wxSize(100, -1));
 
   okButton->SetDefault();
   okButton->SetFocus();
-
-  yPos += 35;
-
-  wxString choices[2];
-  choices[0] = "All";
-  choices[1] = "Pages";
-
-  rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, "Print Range",
-    wxPoint(5, yPos), wxSize(-1, -1), 2, choices, 2);
-  rangeRadioBox->SetSelection(1);
-
-  yPos += 60;
-  xPos = 5;
-  int staticWidth = 45;
-  int textWidth = 40;
-  spacing = 10;
-
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "From:", wxPoint(xPos, yPos));
-  xPos += staticWidth;
-
-  fromText = new wxTextCtrl(this, wxPRINTID_FROM, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
-  xPos += spacing + textWidth;
-
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "To:", wxPoint(xPos, yPos));
-  xPos += staticWidth;
-
-  toText = new wxTextCtrl(this, wxPRINTID_TO, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
-  xPos += spacing + textWidth;
-
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Copies:", wxPoint(xPos, yPos));
-  xPos += spacing + staticWidth;
-
-  noCopiesText = new wxTextCtrl(this, wxPRINTID_COPIES, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
-
-  yPos += 30;
-  xPos = 5;
-
-  printToFileCheckBox = new wxCheckBox(this, wxPRINTID_PRINTTOFILE, "Print to File", wxPoint(xPos, yPos));
-
   Fit();
   Centre(wxBOTH);
 
   // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
   InitDialog();
+  delete[] choices;
 }
 
 int wxGenericPrintDialog::ShowModal(void)
@@ -168,7 +158,7 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
   {
     wxThePrintSetupData->SetPrinterMode(PS_FILE);
 
-    char *f = wxFileSelector("PostScript file",
+    char *f = wxFileSelector(_("PostScript file"),
         wxPathOnly(wxThePrintSetupData->GetPrinterFile()),
         wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()),
         "ps", "*.ps", 0, this);
@@ -185,6 +175,8 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
 
 void wxGenericPrintDialog::OnRange(wxCommandEvent& event)
 {
+  if (!fromText) return;
+
   if (event.GetInt() == 0)
   {
     fromText->Enable(FALSE);
@@ -213,29 +205,33 @@ void wxGenericPrintDialog::OnSetup(wxCommandEvent& WXUNUSED(event))
 
 bool wxGenericPrintDialog::TransferDataToWindow(void)
 {
-  char buf[10];
-  if (printData.GetEnablePageNumbers())
-  {
-    fromText->Enable(TRUE);
-    toText->Enable(TRUE);
-
-    sprintf(buf, "%d", printData.GetFromPage());
-    fromText->SetValue(buf);
-    sprintf(buf, "%d", printData.GetToPage());
-    toText->SetValue(buf);
-
-    if (printData.GetAllPages())
-      rangeRadioBox->SetSelection(0);
-    else
-      rangeRadioBox->SetSelection(1);
-  }
-  else
-  {
-    fromText->Enable(FALSE);
-    toText->Enable(FALSE);
-    rangeRadioBox->SetSelection(0);
-    rangeRadioBox->wxRadioBox::Enable(1, FALSE);
-  }
+   char buf[10];
+
+   if(printData.GetFromPage() != 0)
+   {
+      if (printData.GetEnablePageNumbers())
+      {
+         fromText->Enable(TRUE);
+         toText->Enable(TRUE);
+         
+         sprintf(buf, "%d", printData.GetFromPage());
+         fromText->SetValue(buf);
+         sprintf(buf, "%d", printData.GetToPage());
+         toText->SetValue(buf);
+         
+         if (printData.GetAllPages())
+            rangeRadioBox->SetSelection(0);
+         else
+            rangeRadioBox->SetSelection(1);
+      }
+      else
+      {
+         fromText->Enable(FALSE);
+         toText->Enable(FALSE);
+         rangeRadioBox->SetSelection(0);
+         rangeRadioBox->wxRadioBox::Enable(1, FALSE);
+      }
+   }
   sprintf(buf, "%d", printData.GetNoCopies());
   noCopiesText->SetValue(buf);
 
@@ -246,24 +242,32 @@ bool wxGenericPrintDialog::TransferDataToWindow(void)
 
 bool wxGenericPrintDialog::TransferDataFromWindow(void)
 {
-  if (printData.GetEnablePageNumbers())
-  {
-    printData.SetFromPage(atoi(fromText->GetValue()));
-    printData.SetToPage(atoi(toText->GetValue()));
-  }
-  if (rangeRadioBox->GetSelection() == 0)
-    printData.SetAllPages(TRUE);
-  else
-    printData.SetAllPages(FALSE);
-  printData.SetNoCopies(atoi(noCopiesText->GetValue()));
-  printData.SetPrintToFile(printToFileCheckBox->GetValue());
+   if(printData.GetFromPage() != -1)
+   {
+      if (printData.GetEnablePageNumbers())
+      {
+         printData.SetFromPage(atoi(fromText->GetValue()));
+         printData.SetToPage(atoi(toText->GetValue()));
+      }
+      if (rangeRadioBox->GetSelection() == 0)
+         printData.SetAllPages(TRUE);
+      else
+         printData.SetAllPages(FALSE);
+   }
+   else
+   { // continuous printing
+      printData.SetFromPage(1);
+      printData.SetToPage(32000);
+   }
+   printData.SetNoCopies(atoi(noCopiesText->GetValue()));
+   printData.SetPrintToFile(printToFileCheckBox->GetValue());
 
   return TRUE;
 }
 
 wxDC *wxGenericPrintDialog::GetPrintDC(void)
 {
-  return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, NULL);
+  return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
 }
 
 /*
@@ -271,63 +275,51 @@ 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)
 {
   if ( data )
     printData = *data;
 
-  int buttonWidth = 65;
-  int buttonHeight = 25;
-  int spacing = 5;
-  int yPos = 5;
-  int xPos = 5;
-
-  wxButton *okButton = new wxButton(this, wxID_OK, "OK", wxPoint(xPos, yPos), wxSize(buttonWidth, buttonHeight));
-  xPos += buttonWidth + spacing;
-  (void) new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(xPos, yPos), wxSize(buttonWidth, buttonHeight));
-
-  okButton->SetDefault();
-  okButton->SetFocus();
-
-  yPos += 35;
-  xPos = 5;
+  (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(10, 10), wxSize(200,60) );
 
+  int xPos = 20;
+  int yPos = 30;
   paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
 
-  wxString choices[2];
-  choices[0] = "Portrait";
-  choices[1] = "Landscape";
+  wxString *choices =  new wxString[2];
+  choices[0] = _("Portrait");
+  choices[1] = _("Landscape");
 
-  orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, "Orientation",
-    wxPoint(xPos, yPos), wxSize(-1, -1), 2, choices, 2);
+  orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
+    wxPoint(10, 80), wxSize(-1, -1), 2, choices, 1, wxRA_VERTICAL );
   orientationRadioBox->SetSelection(0);
 
-  xPos += 200;
-
-  colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, "Print in colour", wxPoint(xPos, yPos));
+  (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Options"), wxPoint(10, 130), wxSize(200,50) );
+  
+  colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, _("Print in colour"), wxPoint(15, 145));
+  
 
-  xPos = 5;
-  yPos += 60;
+  (void) new wxStaticBox(this, wxPRINTID_STATIC, _("Print spooling"), wxPoint(230, 10), wxSize(200,170) );
+  
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer command:"), wxPoint(240, 30));
 
-  int staticWidth = 100;
-  int textWidth = 120;
-  spacing = 10;
+  printerCommandText = new wxTextCtrl(this, wxPRINTID_COMMAND, "", wxPoint(260, 55), wxSize(150, -1));
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Printer command:", wxPoint(xPos, yPos));
-  xPos += staticWidth;
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer options:"), wxPoint(240, 110));
 
-  printerCommandText = new wxTextCtrl(this, wxPRINTID_COMMAND, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
-  xPos += textWidth + spacing;
+  printerOptionsText = new wxTextCtrl(this, wxPRINTID_OPTIONS, "", wxPoint(260, 135), wxSize(150, -1));
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Printer options:", wxPoint(xPos, yPos));
-  xPos += staticWidth;
+  wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(80, 200), wxSize(100, -1));
+  (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(270, 200), wxSize(100, -1));
 
-  printerOptionsText = new wxTextCtrl(this, wxPRINTID_OPTIONS, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
+  okButton->SetDefault();
+  okButton->SetFocus();
 
   Fit();
   Centre(wxBOTH);
 
   InitDialog();
+  delete[] choices;
 }
 
 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog(void)
@@ -397,12 +389,9 @@ wxChoice *wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x, int *y)
       sel = i;
   }
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Paper size", wxPoint(*x, *y));
-  *y += 25;
-
-  wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(300, -1), n,
+  wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(170, -1), n,
     choices);
-  *y += 35;
+    
   delete[] choices;
 
   choice->SetSelection(sel);
@@ -437,7 +426,7 @@ void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event))
 }
 
 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)
 {
   if ( data )
     pageData = *data;
@@ -448,16 +437,16 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   int yPos = 5;
   int xPos = 5;
 
-  wxButton *okButton = new wxButton(this, wxID_OK, "OK", wxPoint(5, yPos), wxSize(buttonWidth, buttonHeight));
-  (void) new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(buttonWidth + 5 + spacing, yPos), wxSize(buttonWidth, buttonHeight));
+  wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(5, yPos), wxSize(buttonWidth, buttonHeight));
+  (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(buttonWidth + 5 + spacing, yPos), wxSize(buttonWidth, buttonHeight));
 
-  printerButton = new wxButton(this, wxPRINTID_SETUP, "Printer...", wxPoint(buttonWidth*2 + 5 + 2*spacing, yPos), wxSize(buttonWidth, buttonHeight));
+  printerButton = new wxButton(this, wxPRINTID_SETUP, _("Printer..."), wxPoint(buttonWidth*2 + 5 + 2*spacing, yPos), wxSize(buttonWidth, buttonHeight));
 
   if ( !pageData.GetEnablePrinter() )
     printerButton->Enable(FALSE);
 
 //  if (printData.GetEnableHelp())
-//  wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, "Help", -1, -1, buttonWidth, buttonHeight);
+//  wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
 
   okButton->SetDefault();
   okButton->SetFocus();
@@ -469,10 +458,10 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
 
   xPos = 5;
 
-  wxString choices[2];
-  choices[0] = "Portrait";
-  choices[1] = "Landscape";
-  orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, "Orientation",
+  wxString *choices = new wxString[2];
+  choices[0] = _("Portrait");
+  choices[1] = _("Landscape");
+  orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
     wxPoint(xPos, yPos), wxSize(-1, -1), 2, choices, 2);
   orientationRadioBox->SetSelection(0);
 
@@ -483,13 +472,13 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   int textWidth = 60;
   spacing = 10;
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Left margin (mm):", wxPoint(xPos, yPos));
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Left margin (mm):"), wxPoint(xPos, yPos));
   xPos += staticWidth;
 
   marginLeftText = new wxTextCtrl(this, wxPRINTID_LEFTMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
   xPos += textWidth + spacing;
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Right margin (mm):", wxPoint(xPos, yPos));
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Right margin (mm):"), wxPoint(xPos, yPos));
   xPos += staticWidth;
 
   marginRightText = new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
@@ -498,13 +487,13 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   yPos += 35;
   xPos = 5;
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Top margin (mm):", wxPoint(xPos, yPos));
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Top margin (mm):"), wxPoint(xPos, yPos));
   xPos += staticWidth;
 
   marginTopText = new wxTextCtrl(this, wxPRINTID_TOPMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
   xPos += textWidth + spacing;
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Bottom margin (mm):", wxPoint(xPos, yPos));
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Bottom margin (mm):"), wxPoint(xPos, yPos));
   xPos += staticWidth;
 
   marginBottomText = new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
@@ -513,6 +502,7 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   Centre(wxBOTH);
 
   InitDialog();
+  delete [] choices;
 }
 
 wxGenericPageSetupDialog::~wxGenericPageSetupDialog(void)
@@ -595,7 +585,7 @@ wxChoice *wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x, int *y)
       sel = i;
   }
 
-  (void) new wxStaticText(this, wxPRINTID_STATIC, "Paper size", wxPoint(*x, *y));
+  (void) new wxStaticText(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(*x, *y));
   *y += 25;
 
   wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(300, -1), n,