::GetWindowText() -> wxGetWindowText
[wxWidgets.git] / src / generic / prntdlgg.cpp
index c5ea11ae15b0fb80506a96a7457a31f095adde9b..7b83c709ae8fc43eef5428eed01dbe98cca821aa 100644 (file)
@@ -113,6 +113,11 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
 
 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
                                            wxPrintData* data)
+                    : wxDialog(parent, -1, _("Print"),
+                               wxPoint(0, 0), wxSize(600, 600),
+                               wxDEFAULT_DIALOG_STYLE |
+                               wxDIALOG_MODAL |
+                               wxTAB_TRAVERSAL)
 {
     if ( data )
         m_printDialogData = *data;
@@ -122,8 +127,8 @@ wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent,
 
 void wxGenericPrintDialog::Init(wxWindow *parent)
 {
-    wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
-                     wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
+  //    wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
+  //                     wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
 
     (void)new wxStaticBox( this, -1, _( "Printer options" ), wxPoint( 5, 5), wxSize( 300, 60 ) );
 
@@ -136,7 +141,9 @@ void wxGenericPrintDialog::Init(wxWindow *parent)
     choices[1] = _("Pages");
 
     m_fromText = (wxTextCtrl*)NULL;
-
+    m_toText = (wxTextCtrl*)NULL;
+    m_rangeRadioBox = (wxRadioBox *)NULL;
+    
     if (m_printDialogData.GetFromPage() != 0)
     {
         m_rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"),
@@ -276,28 +283,33 @@ bool wxGenericPrintDialog::TransferDataToWindow()
 
     if(m_printDialogData.GetFromPage() != 0)
     {
-        if (m_printDialogData.GetEnablePageNumbers())
-        {
-            m_fromText->Enable(TRUE);
-            m_toText->Enable(TRUE);
-
-            sprintf(buf, "%d", m_printDialogData.GetFromPage());
-            m_fromText->SetValue(buf);
-            sprintf(buf, "%d", m_printDialogData.GetToPage());
-            m_toText->SetValue(buf);
-
-            if (m_printDialogData.GetAllPages())
+       if(m_fromText)
+       {
+          if (m_printDialogData.GetEnablePageNumbers())
+          {
+             m_fromText->Enable(TRUE);
+             m_toText->Enable(TRUE);
+             sprintf(buf, "%d", m_printDialogData.GetFromPage());
+             m_fromText->SetValue(buf);
+             sprintf(buf, "%d", m_printDialogData.GetToPage());
+             m_toText->SetValue(buf);
+             if(m_rangeRadioBox)
+                if (m_printDialogData.GetAllPages())
+                   m_rangeRadioBox->SetSelection(0);
+                else
+                   m_rangeRadioBox->SetSelection(1);
+          }
+          else
+          {
+             m_fromText->Enable(FALSE);
+             m_toText->Enable(FALSE);
+             if(m_rangeRadioBox)
+             {
                 m_rangeRadioBox->SetSelection(0);
-            else
-                m_rangeRadioBox->SetSelection(1);
-        }
-        else
-        {
-            m_fromText->Enable(FALSE);
-            m_toText->Enable(FALSE);
-            m_rangeRadioBox->SetSelection(0);
-            m_rangeRadioBox->wxRadioBox::Enable(1, FALSE);
-        }
+                m_rangeRadioBox->wxRadioBox::Enable(1, FALSE);
+             }
+          }
+       }
     }
     sprintf(buf, "%d", m_printDialogData.GetNoCopies());
     m_noCopiesText->SetValue(buf);
@@ -313,13 +325,16 @@ bool wxGenericPrintDialog::TransferDataFromWindow()
     {
         if (m_printDialogData.GetEnablePageNumbers())
         {
-            m_printDialogData.SetFromPage(atoi(m_fromText->GetValue()));
-            m_printDialogData.SetToPage(atoi(m_toText->GetValue()));
+           if(m_fromText) m_printDialogData.SetFromPage(atoi(m_fromText->GetValue()));
+           if(m_toText)   m_printDialogData.SetToPage(atoi(m_toText->GetValue()));
+        }
+        if(m_rangeRadioBox)
+        {
+           if (m_rangeRadioBox->GetSelection() == 0)
+              m_printDialogData.SetAllPages(TRUE);
+           else
+              m_printDialogData.SetAllPages(FALSE);
         }
-        if (m_rangeRadioBox->GetSelection() == 0)
-            m_printDialogData.SetAllPages(TRUE);
-        else
-            m_printDialogData.SetAllPages(FALSE);
     }
     else
     { // continuous printing