]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/prntdlgg.cpp
1. suppressed some messages from HasEntry()/HasKeys()
[wxWidgets.git] / src / generic / prntdlgg.cpp
index 033d18ba8d778b30c9102e2e3120ffb3610465b4..dbde8255cb1c549333a9f023d178d3945131eba0 100644 (file)
@@ -73,7 +73,7 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data):
 {
   if ( data )
     printData = *data;
 {
   if ( data )
     printData = *data;
-
+  
   int buttonWidth = 65;
   int buttonHeight = 25;
   int spacing = 5;
   int buttonWidth = 65;
   int buttonHeight = 25;
   int spacing = 5;
@@ -90,32 +90,40 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data):
 
   yPos += 35;
 
 
   yPos += 35;
 
-  wxString choices[2];
+  wxString *choices = new wxString[2];
   choices[0] = _("All");
   choices[1] = _("Pages");
   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);
-
+  
+  fromText = (wxTextCtrl*)NULL;
+  
+  if(printData.GetFromPage() != 0)
+  {
+     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;
 
   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;
-
+  if(printData.GetFromPage() != 0)
+  {
+     (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;
 
   (void) new wxStaticText(this, wxPRINTID_STATIC, _("Copies:"), wxPoint(xPos, yPos));
   xPos += spacing + staticWidth;
 
@@ -131,6 +139,7 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data):
 
   // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
   InitDialog();
 
   // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
   InitDialog();
+  delete[] choices;
 }
 
 int wxGenericPrintDialog::ShowModal(void)
 }
 
 int wxGenericPrintDialog::ShowModal(void)
@@ -186,6 +195,8 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
 
 void wxGenericPrintDialog::OnRange(wxCommandEvent& event)
 {
 
 void wxGenericPrintDialog::OnRange(wxCommandEvent& event)
 {
+  if (!fromText) return;
+
   if (event.GetInt() == 0)
   {
     fromText->Enable(FALSE);
   if (event.GetInt() == 0)
   {
     fromText->Enable(FALSE);
@@ -214,29 +225,33 @@ void wxGenericPrintDialog::OnSetup(wxCommandEvent& WXUNUSED(event))
 
 bool wxGenericPrintDialog::TransferDataToWindow(void)
 {
 
 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);
 
   sprintf(buf, "%d", printData.GetNoCopies());
   noCopiesText->SetValue(buf);
 
@@ -247,24 +262,32 @@ bool wxGenericPrintDialog::TransferDataToWindow(void)
 
 bool wxGenericPrintDialog::TransferDataFromWindow(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 TRUE;
 }
 
 wxDC *wxGenericPrintDialog::GetPrintDC(void)
 {
-  return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, NULL);
+  return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
 }
 
 /*
 }
 
 /*
@@ -295,7 +318,7 @@ wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSe
 
   paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
 
 
   paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
 
-  wxString choices[2];
+  wxString *choices =  new wxString[2];
   choices[0] = _("Portrait");
   choices[1] = _("Landscape");
 
   choices[0] = _("Portrait");
   choices[1] = _("Landscape");
 
@@ -329,6 +352,7 @@ wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSe
   Centre(wxBOTH);
 
   InitDialog();
   Centre(wxBOTH);
 
   InitDialog();
+  delete[] choices;
 }
 
 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog(void)
 }
 
 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog(void)
@@ -470,7 +494,7 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
 
   xPos = 5;
 
 
   xPos = 5;
 
-  wxString choices[2];
+  wxString *choices = new wxString[2];
   choices[0] = _("Portrait");
   choices[1] = _("Landscape");
   orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
   choices[0] = _("Portrait");
   choices[1] = _("Landscape");
   orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
@@ -514,6 +538,7 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetup
   Centre(wxBOTH);
 
   InitDialog();
   Centre(wxBOTH);
 
   InitDialog();
+  delete [] choices;
 }
 
 wxGenericPageSetupDialog::~wxGenericPageSetupDialog(void)
 }
 
 wxGenericPageSetupDialog::~wxGenericPageSetupDialog(void)