1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Generic print dialogs
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "prntdlgg.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #if wxUSE_PRINTING_ARCHITECTURE
40 #include "wx/stattext.h"
41 #include "wx/statbox.h"
42 #include "wx/button.h"
43 #include "wx/checkbox.h"
44 #include "wx/textctrl.h"
45 #include "wx/radiobox.h"
46 #include "wx/filedlg.h"
47 #include "wx/choice.h"
51 #include "wx/generic/prntdlgg.h"
54 #include "wx/generic/dcpsg.h"
57 #include "wx/printdlg.h"
60 // For print paper things
61 #include "wx/prntbase.h"
66 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 #if !USE_SHARED_LIBRARY
74 IMPLEMENT_CLASS(wxGenericPrintDialog
, wxDialog
)
75 IMPLEMENT_CLASS(wxGenericPrintSetupDialog
, wxDialog
)
77 BEGIN_EVENT_TABLE(wxGenericPrintDialog
, wxDialog
)
78 EVT_BUTTON(wxID_OK
, wxGenericPrintDialog::OnOK
)
79 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPrintDialog::OnSetup
)
80 EVT_RADIOBOX(wxPRINTID_RANGE
, wxGenericPrintDialog::OnRange
)
84 IMPLEMENT_CLASS(wxGenericPageSetupDialog
, wxDialog
)
86 BEGIN_EVENT_TABLE(wxGenericPageSetupDialog
, wxDialog
)
87 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPageSetupDialog::OnPrinter
)
89 #endif // USE_SHARED_LIBRARY
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 extern wxPrintPaperDatabase
*wxThePrintPaperDatabase
;
99 // ============================================================================
101 // ============================================================================
103 // ----------------------------------------------------------------------------
104 // Generic print dialog for non-Windows printing use.
105 // ----------------------------------------------------------------------------
107 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
108 wxPrintDialogData
* data
)
109 : wxDialog(parent
, -1, _("Print"),
110 wxPoint(0, 0), wxSize(600, 600),
111 wxDEFAULT_DIALOG_STYLE
|
116 m_printDialogData
= *data
;
121 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
123 : wxDialog(parent
, -1, _("Print"),
124 wxPoint(0, 0), wxSize(600, 600),
125 wxDEFAULT_DIALOG_STYLE
|
130 m_printDialogData
= *data
;
135 void wxGenericPrintDialog::Init(wxWindow
* WXUNUSED(parent
))
137 // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
138 // wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
140 (void)new wxStaticBox( this, -1, _( "Printer options" ), wxPoint( 5, 5), wxSize( 300, 60 ) );
142 m_printToFileCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTTOFILE
, _("Print to File"), wxPoint(20, 25) );
144 m_setupButton
= new wxButton(this, wxPRINTID_SETUP
, _("Setup..."), wxPoint(160, 25), wxSize(100, -1));
146 wxString
*choices
= new wxString
[2];
147 choices
[0] = _("All");
148 choices
[1] = _("Pages");
150 m_fromText
= (wxTextCtrl
*)NULL
;
151 m_toText
= (wxTextCtrl
*)NULL
;
152 m_rangeRadioBox
= (wxRadioBox
*)NULL
;
154 if (m_printDialogData
.GetFromPage() != 0)
156 m_rangeRadioBox
= new wxRadioBox(this, wxPRINTID_RANGE
, _("Print Range"),
157 wxPoint(5, 80), wxSize(-1, -1),
160 m_rangeRadioBox
->SetSelection(1);
163 if(m_printDialogData
.GetFromPage() != 0)
165 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("From:"), wxPoint(5, 135));
167 m_fromText
= new wxTextCtrl(this, wxPRINTID_FROM
, "", wxPoint(45, 130), wxSize(40, -1));
169 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("To:"), wxPoint(100, 135));
171 m_toText
= new wxTextCtrl(this, wxPRINTID_TO
, "", wxPoint(133, 130), wxSize(40, -1));
174 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Copies:"), wxPoint(200, 135));
176 m_noCopiesText
= new wxTextCtrl(this, wxPRINTID_COPIES
, "", wxPoint(252, 130), wxSize(40, -1));
178 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(40, 180), wxSize(80, -1));
179 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(180, 180), wxSize(80, -1));
181 okButton
->SetDefault();
182 okButton
->SetFocus();
186 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
191 int wxGenericPrintDialog::ShowModal()
193 if ( m_printDialogData
.GetSetupDialog() )
195 // Make sure wxPrintData object reflects the settings now, in case the setup dialog
196 // changes it. In fact there aren't any common settings at
197 // present, but there might be in future.
198 // TransferDataFromWindow();
200 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
201 new wxGenericPrintSetupDialog(this, & m_printDialogData
.GetPrintData());
202 int ret
= genericPrintSetupDialog
->ShowModal();
203 if ( ret
!= wxID_CANCEL
)
205 // Transfer settings to the global object (for compatibility) and to
206 // the print dialog's print data.
207 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
208 m_printDialogData
.GetPrintData() = genericPrintSetupDialog
->GetPrintData();
210 genericPrintSetupDialog
->Destroy();
212 // Restore the wxPrintData settings again (uncomment if any settings become common
214 // TransferDataToWindow();
220 return wxDialog::ShowModal();
224 wxGenericPrintDialog::~wxGenericPrintDialog()
228 void wxGenericPrintDialog::OnOK(wxCommandEvent
& WXUNUSED(event
))
230 TransferDataFromWindow();
232 // There are some interactions between the global setup data
233 // and the standard print dialog. The global printing 'mode'
234 // is determined by whether the user checks Print to file
236 if (m_printDialogData
.GetPrintToFile())
238 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE
);
239 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_FILE
);
241 wxString f
= wxFileSelector(_("PostScript file"),
242 wxPathOnly(wxThePrintSetupData
->GetPrinterFile()),
243 wxFileNameFromPath(wxThePrintSetupData
->GetPrinterFile()),
244 _T("ps"), _T("*.ps"), 0, this);
248 m_printDialogData
.GetPrintData().SetFilename(f
);
249 wxThePrintSetupData
->SetPrinterFile(f
);
253 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER
);
254 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_PRINTER
);
260 void wxGenericPrintDialog::OnRange(wxCommandEvent
& event
)
262 if (!m_fromText
) return;
264 if (event
.GetInt() == 0)
266 m_fromText
->Enable(FALSE
);
267 m_toText
->Enable(FALSE
);
269 else if (event
.GetInt() == 1)
271 m_fromText
->Enable(TRUE
);
272 m_toText
->Enable(TRUE
);
276 void wxGenericPrintDialog::OnSetup(wxCommandEvent
& WXUNUSED(event
))
278 *wxThePrintSetupData
= m_printDialogData
.GetPrintData();
279 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
280 new wxGenericPrintSetupDialog(this, wxThePrintSetupData
);
281 int ret
= genericPrintSetupDialog
->ShowModal();
282 if ( ret
!= wxID_CANCEL
)
284 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
285 m_printDialogData
= genericPrintSetupDialog
->GetPrintData();
288 genericPrintSetupDialog
->Close(TRUE
);
291 bool wxGenericPrintDialog::TransferDataToWindow()
295 if(m_printDialogData
.GetFromPage() != 0)
299 if (m_printDialogData
.GetEnablePageNumbers())
301 m_fromText
->Enable(TRUE
);
302 m_toText
->Enable(TRUE
);
303 sprintf(buf
, "%d", m_printDialogData
.GetFromPage());
304 m_fromText
->SetValue(buf
);
305 sprintf(buf
, "%d", m_printDialogData
.GetToPage());
306 m_toText
->SetValue(buf
);
308 if (m_printDialogData
.GetAllPages())
309 m_rangeRadioBox
->SetSelection(0);
311 m_rangeRadioBox
->SetSelection(1);
315 m_fromText
->Enable(FALSE
);
316 m_toText
->Enable(FALSE
);
319 m_rangeRadioBox
->SetSelection(0);
320 m_rangeRadioBox
->wxRadioBox::Enable(1, FALSE
);
325 sprintf(buf
, "%d", m_printDialogData
.GetNoCopies());
326 m_noCopiesText
->SetValue(buf
);
328 m_printToFileCheckBox
->SetValue(m_printDialogData
.GetPrintToFile());
329 m_printToFileCheckBox
->Enable(m_printDialogData
.GetEnablePrintToFile());
333 bool wxGenericPrintDialog::TransferDataFromWindow()
335 if(m_printDialogData
.GetFromPage() != -1)
337 if (m_printDialogData
.GetEnablePageNumbers())
339 if(m_fromText
) m_printDialogData
.SetFromPage(wxAtoi(m_fromText
->GetValue()));
340 if(m_toText
) m_printDialogData
.SetToPage(wxAtoi(m_toText
->GetValue()));
344 if (m_rangeRadioBox
->GetSelection() == 0)
345 m_printDialogData
.SetAllPages(TRUE
);
347 m_printDialogData
.SetAllPages(FALSE
);
351 { // continuous printing
352 m_printDialogData
.SetFromPage(1);
353 m_printDialogData
.SetToPage(32000);
355 m_printDialogData
.SetNoCopies(wxAtoi(m_noCopiesText
->GetValue()));
356 m_printDialogData
.SetPrintToFile(m_printToFileCheckBox
->GetValue());
362 TODO: collate and noCopies should be duplicated across dialog data and print data objects
363 (slightly different semantics on Windows but let's ignore this for a bit).
366 wxDC
*wxGenericPrintDialog::GetPrintDC()
368 // return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
369 return new wxPostScriptDC(GetPrintDialogData().GetPrintData());
372 // ----------------------------------------------------------------------------
373 // Generic print setup dialog
374 // ----------------------------------------------------------------------------
376 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintData
* data
):
377 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
382 // Convert wxPrintSetupData to standard wxPrintData object
383 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintSetupData
* data
):
384 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
386 wxPrintData printData
;
390 printData
= * wxThePrintSetupData
;
395 void wxGenericPrintSetupDialog::Init(wxPrintData
* data
)
400 int staticBoxWidth
= 300;
402 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth
, 60) );
406 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
408 wxString
*choices
= new wxString
[2];
409 choices
[0] = _("Portrait");
410 choices
[1] = _("Landscape");
412 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
413 wxPoint(10, 80), wxSize(-1, -1), 2, choices
, 1, wxRA_VERTICAL
);
414 m_orientationRadioBox
->SetSelection(0);
416 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth
, 50) );
418 int colourYPos
= 145;
424 m_colourCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTCOLOUR
, _("Print in colour"), wxPoint(15, colourYPos
));
426 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
428 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer command:"), wxPoint(340, 30));
430 m_printerCommandText
= new wxTextCtrl(this, wxPRINTID_COMMAND
, "", wxPoint(360, 55), wxSize(150, -1));
432 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer options:"), wxPoint(340, 110));
434 m_printerOptionsText
= new wxTextCtrl(this, wxPRINTID_OPTIONS
, "", wxPoint(360, 135), wxSize(150, -1));
436 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(130, 200), wxSize(80, -1));
437 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(320, 200), wxSize(80, -1));
439 okButton
->SetDefault();
440 okButton
->SetFocus();
449 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog()
453 bool wxGenericPrintSetupDialog::TransferDataToWindow()
455 if (m_printerCommandText
&& m_printData
.GetPrinterCommand())
456 m_printerCommandText
->SetValue(m_printData
.GetPrinterCommand());
457 if (m_printerOptionsText
&& m_printData
.GetPrinterOptions())
458 m_printerOptionsText
->SetValue(m_printData
.GetPrinterOptions());
459 if (m_colourCheckBox
)
460 m_colourCheckBox
->SetValue(m_printData
.GetColour());
462 if (m_orientationRadioBox
)
464 if (m_printData
.GetOrientation() == wxPORTRAIT
)
465 m_orientationRadioBox
->SetSelection(0);
467 m_orientationRadioBox
->SetSelection(1);
472 bool wxGenericPrintSetupDialog::TransferDataFromWindow()
474 if (m_printerCommandText
)
475 m_printData
.SetPrinterCommand(m_printerCommandText
->GetValue());
476 if (m_printerOptionsText
)
477 m_printData
.SetPrinterOptions(m_printerOptionsText
->GetValue());
478 if (m_colourCheckBox
)
479 m_printData
.SetColour(m_colourCheckBox
->GetValue());
480 if (m_orientationRadioBox
)
482 int sel
= m_orientationRadioBox
->GetSelection();
484 m_printData
.SetOrientation(wxPORTRAIT
);
486 m_printData
.SetOrientation(wxLANDSCAPE
);
488 if (m_paperTypeChoice
)
490 wxString
val(m_paperTypeChoice
->GetStringSelection());
491 if (!val
.IsNull() && val
!= "")
492 m_printData
.SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(val
));
495 // This is for backward compatibility only
496 *wxThePrintSetupData
= GetPrintData();
500 wxChoice
*wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
502 /* Should not be necessary
503 if (!wxThePrintPaperDatabase)
505 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
506 wxThePrintPaperDatabase->CreateDatabase();
509 int n
= wxThePrintPaperDatabase
->Number();
510 wxString
*choices
= new wxString
[n
];
513 for (i
= 0; i
< n
; i
++)
515 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
516 choices
[i
] = paper
->GetName();
517 if (m_printData
.GetPaperId() == paper
->GetId())
523 wxChoice
*choice
= new wxChoice(this, wxPRINTID_PAPERSIZE
, wxPoint(*x
, *y
), wxSize(width
, -1), n
,
526 // SetFont(thisFont);
530 choice
->SetSelection(sel
);
533 #endif // wxUSE_POSTSCRIPT
535 // ----------------------------------------------------------------------------
536 // Generic page setup dialog
537 // ----------------------------------------------------------------------------
539 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent
& WXUNUSED(event
))
541 // We no longer query GetPrintMode, so we can eliminate the need
542 // to call SetPrintMode.
543 // This has the limitation that we can't explicitly call the PostScript
544 // print setup dialog from the generic Page Setup dialog under Windows,
545 // but since this choice would only happen when trying to do PostScript
546 // printing under Windows (and only in 16-bit Windows which
547 // doesn't have a Windows-specific page setup dialog) it's worth it.
549 // First save the current settings, so the wxPrintData object is up to date.
550 TransferDataFromWindow();
552 // Transfer the current print settings from this dialog to the page setup dialog.
553 wxPrintDialogData data
;
554 data
= GetPageSetupData().GetPrintData();
555 data
.SetSetupDialog(TRUE
);
556 wxPrintDialog
*printDialog
= new wxPrintDialog(this, & data
);
557 printDialog
->ShowModal();
559 // Transfer the page setup print settings from the page dialog to this dialog again, in case
560 // the page setup dialog changed something.
561 GetPageSetupData().GetPrintData() = printDialog
->GetPrintDialogData().GetPrintData();
562 GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData
564 printDialog
->Destroy();
566 // Now update the dialog in case the page setup dialog changed some of our settings.
567 TransferDataToWindow();
570 wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow
*parent
, wxPageSetupData
* data
):
571 wxDialog(parent
, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL
|wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
576 int buttonWidth
= 75;
577 int buttonHeight
= 25;
586 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(5, yPos
), wxSize(buttonWidth
, buttonHeight
));
587 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(buttonWidth
+ 5 + spacing
, yPos
), wxSize(buttonWidth
, buttonHeight
));
589 m_printerButton
= new wxButton(this, wxPRINTID_SETUP
, _("Printer..."), wxPoint(buttonWidth
*2 + 5 + 2*spacing
, yPos
), wxSize(buttonWidth
, buttonHeight
));
591 if ( !m_pageData
.GetEnablePrinter() )
592 m_printerButton
->Enable(FALSE
);
594 // if (m_printData.GetEnableHelp())
595 // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
597 okButton
->SetDefault();
598 okButton
->SetFocus();
607 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
611 wxString
*choices
= new wxString
[2];
612 choices
[0] = _("Portrait");
613 choices
[1] = _("Landscape");
614 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
615 wxPoint(xPos
, yPos
), wxSize(-1, -1), 2, choices
, 2);
616 m_orientationRadioBox
->SetSelection(0);
621 int staticWidth
= 110;
629 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Left margin (mm):"), wxPoint(xPos
, yPos
));
632 m_marginLeftText
= new wxTextCtrl(this, wxPRINTID_LEFTMARGIN
, "", wxPoint(xPos
, yPos
), wxSize(textWidth
, -1));
633 xPos
+= textWidth
+ spacing
;
635 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Right margin (mm):"), wxPoint(xPos
, yPos
));
638 m_marginRightText
= new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN
, "", wxPoint(xPos
, yPos
), wxSize(textWidth
, -1));
639 xPos
+= textWidth
+ spacing
;
644 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Top margin (mm):"), wxPoint(xPos
, yPos
));
647 m_marginTopText
= new wxTextCtrl(this, wxPRINTID_TOPMARGIN
, "", wxPoint(xPos
, yPos
), wxSize(textWidth
, -1));
648 xPos
+= textWidth
+ spacing
;
650 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Bottom margin (mm):"), wxPoint(xPos
, yPos
));
653 m_marginBottomText
= new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN
, "", wxPoint(xPos
, yPos
), wxSize(textWidth
, -1));
662 wxGenericPageSetupDialog::~wxGenericPageSetupDialog()
666 bool wxGenericPageSetupDialog::TransferDataToWindow()
668 if (m_marginLeftText
)
669 m_marginLeftText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().x
));
671 m_marginTopText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().y
));
672 if (m_marginRightText
)
673 m_marginRightText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().x
));
674 if (m_marginBottomText
)
675 m_marginBottomText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().y
));
677 if (m_orientationRadioBox
)
679 if (m_pageData
.GetPrintData().GetOrientation() == wxPORTRAIT
)
680 m_orientationRadioBox
->SetSelection(0);
682 m_orientationRadioBox
->SetSelection(1);
685 // Find the paper type from either the current paper size in the wxPageSetupDialogData, or
686 // failing that, the id in the wxPrintData object.
688 wxPrintPaperType
* type
= wxThePrintPaperDatabase
->FindPaperType(
689 wxSize(m_pageData
.GetPaperSize().x
* 10, m_pageData
.GetPaperSize().y
* 10));
691 if (!type
&& m_pageData
.GetPrintData().GetPaperId() != wxPAPER_NONE
)
692 type
= wxThePrintPaperDatabase
->FindPaperType(m_pageData
.GetPrintData().GetPaperId());
696 m_paperTypeChoice
->SetStringSelection(type
->GetName());
702 bool wxGenericPageSetupDialog::TransferDataFromWindow()
704 if (m_marginLeftText
&& m_marginTopText
)
705 m_pageData
.SetMarginTopLeft(wxPoint(wxAtoi((const wxChar
*)m_marginLeftText
->GetValue()),wxAtoi((const wxChar
*)m_marginTopText
->GetValue())));
706 if (m_marginRightText
&& m_marginBottomText
)
707 m_pageData
.SetMarginBottomRight(wxPoint(wxAtoi((const wxChar
*)m_marginRightText
->GetValue()),wxAtoi((const wxChar
*)m_marginBottomText
->GetValue())));
709 if (m_orientationRadioBox
)
711 int sel
= m_orientationRadioBox
->GetSelection();
715 wxThePrintSetupData
->SetPrinterOrientation(wxPORTRAIT
);
717 m_pageData
.GetPrintData().SetOrientation(wxPORTRAIT
);
722 wxThePrintSetupData
->SetPrinterOrientation(wxLANDSCAPE
);
724 m_pageData
.GetPrintData().SetOrientation(wxLANDSCAPE
);
727 if (m_paperTypeChoice
)
729 wxString
val(m_paperTypeChoice
->GetStringSelection());
730 if (!val
.IsNull() && val
!= "")
732 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(val
);
735 m_pageData
.SetPaperSize(wxSize(paper
->GetWidth()/10, paper
->GetHeight()/10));
736 m_pageData
.GetPrintData().SetPaperId(paper
->GetId());
744 wxChoice
*wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
747 if (!wxThePrintPaperDatabase)
749 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
750 wxThePrintPaperDatabase->CreateDatabase();
754 int n
= wxThePrintPaperDatabase
->Number();
755 wxString
*choices
= new wxString
[n
];
757 for (i
= 0; i
< n
; i
++)
759 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
760 choices
[i
] = paper
->GetName();
763 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(*x
, *y
));
766 wxChoice
*choice
= new wxChoice(this, wxPRINTID_PAPERSIZE
, wxPoint(*x
, *y
), wxSize(300, -1), n
,
771 // choice->SetSelection(sel);