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"
31 #if wxUSE_PRINTING_ARCHITECTURE
38 #include "wx/stattext.h"
39 #include "wx/statbox.h"
40 #include "wx/button.h"
41 #include "wx/checkbox.h"
42 #include "wx/textctrl.h"
43 #include "wx/radiobox.h"
44 #include "wx/filedlg.h"
45 #include "wx/choice.h"
46 #include "wx/combobox.h"
52 #include "wx/statline.h"
55 #include "wx/generic/prntdlgg.h"
58 #include "wx/generic/dcpsg.h"
61 #include "wx/printdlg.h"
64 // For print paper things
65 #include "wx/prntbase.h"
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
77 IMPLEMENT_CLASS(wxGenericPrintDialog
, wxDialog
)
78 IMPLEMENT_CLASS(wxGenericPrintSetupDialog
, wxDialog
)
80 BEGIN_EVENT_TABLE(wxGenericPrintDialog
, wxDialog
)
81 EVT_BUTTON(wxID_OK
, wxGenericPrintDialog::OnOK
)
82 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPrintDialog::OnSetup
)
83 EVT_RADIOBOX(wxPRINTID_RANGE
, wxGenericPrintDialog::OnRange
)
87 IMPLEMENT_CLASS(wxGenericPageSetupDialog
, wxDialog
)
89 BEGIN_EVENT_TABLE(wxGenericPageSetupDialog
, wxDialog
)
90 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPageSetupDialog::OnPrinter
)
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 extern wxPrintPaperDatabase
*wxThePrintPaperDatabase
;
101 // ============================================================================
103 // ============================================================================
105 // ----------------------------------------------------------------------------
106 // Generic print dialog for non-Windows printing use.
107 // ----------------------------------------------------------------------------
109 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
110 wxPrintDialogData
* data
)
111 : wxDialog(parent
, -1, _("Print"),
112 wxPoint(0, 0), wxSize(600, 600),
113 wxDEFAULT_DIALOG_STYLE
|
118 m_printDialogData
= *data
;
123 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
125 : wxDialog(parent
, -1, _("Print"),
126 wxPoint(0, 0), wxSize(600, 600),
127 wxDEFAULT_DIALOG_STYLE
|
132 m_printDialogData
= *data
;
137 void wxGenericPrintDialog::Init(wxWindow
* WXUNUSED(parent
))
139 // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
140 // wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
142 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
146 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
147 new wxStaticBox( this, -1, _( "Printer options" ) ), wxHORIZONTAL
);
148 m_printToFileCheckBox
= new wxCheckBox( this, wxPRINTID_PRINTTOFILE
, _("Print to File") );
149 topsizer
->Add( m_printToFileCheckBox
, 0, wxCENTER
|wxALL
, 5 );
151 topsizer
->Add( 60,2,1 );
153 m_setupButton
= new wxButton(this, wxPRINTID_SETUP
, _("Setup...") );
154 topsizer
->Add( m_setupButton
, 0, wxCENTER
|wxALL
, 5 );
156 mainsizer
->Add( topsizer
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
158 // 2) middle row with radio box
160 wxString
*choices
= new wxString
[2];
161 choices
[0] = _("All");
162 choices
[1] = _("Pages");
164 m_fromText
= (wxTextCtrl
*)NULL
;
165 m_toText
= (wxTextCtrl
*)NULL
;
166 m_rangeRadioBox
= (wxRadioBox
*)NULL
;
168 if (m_printDialogData
.GetFromPage() != 0)
170 m_rangeRadioBox
= new wxRadioBox(this, wxPRINTID_RANGE
, _("Print Range"),
171 wxDefaultPosition
, wxDefaultSize
,
174 m_rangeRadioBox
->SetSelection(1);
176 mainsizer
->Add( m_rangeRadioBox
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
181 wxBoxSizer
*bottomsizer
= new wxBoxSizer( wxHORIZONTAL
);
183 if (m_printDialogData
.GetFromPage() != 0)
185 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("From:") ), 0, wxCENTER
|wxALL
, 5 );
186 m_fromText
= new wxTextCtrl(this, wxPRINTID_FROM
, "", wxDefaultPosition
, wxSize(40, -1));
187 bottomsizer
->Add( m_fromText
, 1, wxCENTER
|wxRIGHT
, 10 );
189 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("To:") ), 0, wxCENTER
|wxALL
, 5);
190 m_toText
= new wxTextCtrl(this, wxPRINTID_TO
, "", wxDefaultPosition
, wxSize(40, -1));
191 bottomsizer
->Add( m_toText
, 1, wxCENTER
|wxRIGHT
, 10 );
194 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Copies:") ), 0, wxCENTER
|wxALL
, 5 );
195 m_noCopiesText
= new wxTextCtrl(this, wxPRINTID_COPIES
, "", wxPoint(252, 130), wxSize(40, -1));
196 bottomsizer
->Add( m_noCopiesText
, 1, wxCENTER
|wxRIGHT
, 10 );
198 mainsizer
->Add( bottomsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 12 );
202 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
207 mainsizer
->Add( CreateButtonSizer( wxOK
|wxCANCEL
), 0, wxCENTER
|wxALL
, 10 );
209 SetAutoLayout( TRUE
);
210 SetSizer( mainsizer
);
212 mainsizer
->Fit( this );
215 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
220 int wxGenericPrintDialog::ShowModal()
222 if ( m_printDialogData
.GetSetupDialog() )
224 // Make sure wxPrintData object reflects the settings now, in case the setup dialog
225 // changes it. In fact there aren't any common settings at
226 // present, but there might be in future.
227 // TransferDataFromWindow();
229 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
230 new wxGenericPrintSetupDialog(this, & m_printDialogData
.GetPrintData());
231 int ret
= genericPrintSetupDialog
->ShowModal();
232 if ( ret
!= wxID_CANCEL
)
234 // Transfer settings to the global object (for compatibility) and to
235 // the print dialog's print data.
236 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
237 m_printDialogData
.GetPrintData() = genericPrintSetupDialog
->GetPrintData();
239 genericPrintSetupDialog
->Destroy();
241 // Restore the wxPrintData settings again (uncomment if any settings become common
243 // TransferDataToWindow();
249 return wxDialog::ShowModal();
253 wxGenericPrintDialog::~wxGenericPrintDialog()
257 void wxGenericPrintDialog::OnOK(wxCommandEvent
& WXUNUSED(event
))
259 TransferDataFromWindow();
261 // There are some interactions between the global setup data
262 // and the standard print dialog. The global printing 'mode'
263 // is determined by whether the user checks Print to file
265 if (m_printDialogData
.GetPrintToFile())
267 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE
);
268 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_FILE
);
270 wxString f
= wxFileSelector(_("PostScript file"),
271 wxPathOnly(wxThePrintSetupData
->GetPrinterFile()),
272 wxFileNameFromPath(wxThePrintSetupData
->GetPrinterFile()),
273 wxT("ps"), wxT("*.ps"), 0, this);
277 m_printDialogData
.GetPrintData().SetFilename(f
);
278 wxThePrintSetupData
->SetPrinterFile(f
);
282 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER
);
283 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_PRINTER
);
289 void wxGenericPrintDialog::OnRange(wxCommandEvent
& event
)
291 if (!m_fromText
) return;
293 if (event
.GetInt() == 0)
295 m_fromText
->Enable(FALSE
);
296 m_toText
->Enable(FALSE
);
298 else if (event
.GetInt() == 1)
300 m_fromText
->Enable(TRUE
);
301 m_toText
->Enable(TRUE
);
305 void wxGenericPrintDialog::OnSetup(wxCommandEvent
& WXUNUSED(event
))
307 *wxThePrintSetupData
= m_printDialogData
.GetPrintData();
308 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
309 new wxGenericPrintSetupDialog(this, wxThePrintSetupData
);
310 int ret
= genericPrintSetupDialog
->ShowModal();
311 if ( ret
!= wxID_CANCEL
)
313 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
314 m_printDialogData
= genericPrintSetupDialog
->GetPrintData();
317 genericPrintSetupDialog
->Close(TRUE
);
320 bool wxGenericPrintDialog::TransferDataToWindow()
324 if(m_printDialogData
.GetFromPage() != 0)
328 if (m_printDialogData
.GetEnablePageNumbers())
330 m_fromText
->Enable(TRUE
);
331 m_toText
->Enable(TRUE
);
332 sprintf(buf
, "%d", m_printDialogData
.GetFromPage());
333 m_fromText
->SetValue(buf
);
334 sprintf(buf
, "%d", m_printDialogData
.GetToPage());
335 m_toText
->SetValue(buf
);
337 if (m_printDialogData
.GetAllPages())
338 m_rangeRadioBox
->SetSelection(0);
340 m_rangeRadioBox
->SetSelection(1);
344 m_fromText
->Enable(FALSE
);
345 m_toText
->Enable(FALSE
);
348 m_rangeRadioBox
->SetSelection(0);
349 m_rangeRadioBox
->wxRadioBox::Enable(1, FALSE
);
354 sprintf(buf
, "%d", m_printDialogData
.GetNoCopies());
355 m_noCopiesText
->SetValue(buf
);
357 m_printToFileCheckBox
->SetValue(m_printDialogData
.GetPrintToFile());
358 m_printToFileCheckBox
->Enable(m_printDialogData
.GetEnablePrintToFile());
362 bool wxGenericPrintDialog::TransferDataFromWindow()
364 if(m_printDialogData
.GetFromPage() != -1)
366 if (m_printDialogData
.GetEnablePageNumbers())
368 if(m_fromText
) m_printDialogData
.SetFromPage(wxAtoi(m_fromText
->GetValue()));
369 if(m_toText
) m_printDialogData
.SetToPage(wxAtoi(m_toText
->GetValue()));
373 if (m_rangeRadioBox
->GetSelection() == 0)
374 m_printDialogData
.SetAllPages(TRUE
);
376 m_printDialogData
.SetAllPages(FALSE
);
380 { // continuous printing
381 m_printDialogData
.SetFromPage(1);
382 m_printDialogData
.SetToPage(32000);
384 m_printDialogData
.SetNoCopies(wxAtoi(m_noCopiesText
->GetValue()));
385 m_printDialogData
.SetPrintToFile(m_printToFileCheckBox
->GetValue());
391 TODO: collate and noCopies should be duplicated across dialog data and print data objects
392 (slightly different semantics on Windows but let's ignore this for a bit).
395 wxDC
*wxGenericPrintDialog::GetPrintDC()
397 // return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
398 return new wxPostScriptDC(GetPrintDialogData().GetPrintData());
401 // ----------------------------------------------------------------------------
402 // Generic print setup dialog
403 // ----------------------------------------------------------------------------
405 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintData
* data
):
406 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
411 // Convert wxPrintSetupData to standard wxPrintData object
412 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintSetupData
* data
):
413 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
415 wxPrintData printData
;
419 printData
= * wxThePrintSetupData
;
424 void wxGenericPrintSetupDialog::Init(wxPrintData
* data
)
429 int staticBoxWidth
= 300;
431 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth
, 60) );
435 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
437 wxString
*choices
= new wxString
[2];
438 choices
[0] = _("Portrait");
439 choices
[1] = _("Landscape");
441 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
442 wxPoint(10, 80), wxSize(-1, -1), 2, choices
, 1, wxRA_VERTICAL
);
443 m_orientationRadioBox
->SetSelection(0);
445 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth
, 50) );
447 int colourYPos
= 145;
453 m_colourCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTCOLOUR
, _("Print in colour"), wxPoint(15, colourYPos
));
455 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
457 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer command:"), wxPoint(340, 30));
459 m_printerCommandText
= new wxTextCtrl(this, wxPRINTID_COMMAND
, "", wxPoint(360, 55), wxSize(150, -1));
461 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer options:"), wxPoint(340, 110));
463 m_printerOptionsText
= new wxTextCtrl(this, wxPRINTID_OPTIONS
, "", wxPoint(360, 135), wxSize(150, -1));
465 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(130, 200), wxSize(80, -1));
466 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(320, 200), wxSize(80, -1));
468 okButton
->SetDefault();
469 okButton
->SetFocus();
478 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog()
482 bool wxGenericPrintSetupDialog::TransferDataToWindow()
484 if (m_printerCommandText
&& m_printData
.GetPrinterCommand())
485 m_printerCommandText
->SetValue(m_printData
.GetPrinterCommand());
486 if (m_printerOptionsText
&& m_printData
.GetPrinterOptions())
487 m_printerOptionsText
->SetValue(m_printData
.GetPrinterOptions());
488 if (m_colourCheckBox
)
489 m_colourCheckBox
->SetValue(m_printData
.GetColour());
491 if (m_orientationRadioBox
)
493 if (m_printData
.GetOrientation() == wxPORTRAIT
)
494 m_orientationRadioBox
->SetSelection(0);
496 m_orientationRadioBox
->SetSelection(1);
501 bool wxGenericPrintSetupDialog::TransferDataFromWindow()
503 if (m_printerCommandText
)
504 m_printData
.SetPrinterCommand(m_printerCommandText
->GetValue());
505 if (m_printerOptionsText
)
506 m_printData
.SetPrinterOptions(m_printerOptionsText
->GetValue());
507 if (m_colourCheckBox
)
508 m_printData
.SetColour(m_colourCheckBox
->GetValue());
509 if (m_orientationRadioBox
)
511 int sel
= m_orientationRadioBox
->GetSelection();
513 m_printData
.SetOrientation(wxPORTRAIT
);
515 m_printData
.SetOrientation(wxLANDSCAPE
);
517 if (m_paperTypeChoice
)
519 wxString
val(m_paperTypeChoice
->GetStringSelection());
520 if (!val
.IsNull() && val
!= "")
521 m_printData
.SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(val
));
524 // This is for backward compatibility only
525 *wxThePrintSetupData
= GetPrintData();
529 wxComboBox
*wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
531 /* Should not be necessary
532 if (!wxThePrintPaperDatabase)
534 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
535 wxThePrintPaperDatabase->CreateDatabase();
538 int n
= wxThePrintPaperDatabase
->Number();
539 wxString
*choices
= new wxString
[n
];
542 for (i
= 0; i
< n
; i
++)
544 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
545 choices
[i
] = paper
->GetName();
546 if (m_printData
.GetPaperId() == paper
->GetId())
552 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
554 wxPoint(*x
, *y
), wxSize(width
, -1), n
,
557 // SetFont(thisFont);
561 choice
->SetSelection(sel
);
564 #endif // wxUSE_POSTSCRIPT
566 // ----------------------------------------------------------------------------
567 // Generic page setup dialog
568 // ----------------------------------------------------------------------------
570 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent
& WXUNUSED(event
))
572 // We no longer query GetPrintMode, so we can eliminate the need
573 // to call SetPrintMode.
574 // This has the limitation that we can't explicitly call the PostScript
575 // print setup dialog from the generic Page Setup dialog under Windows,
576 // but since this choice would only happen when trying to do PostScript
577 // printing under Windows (and only in 16-bit Windows which
578 // doesn't have a Windows-specific page setup dialog) it's worth it.
580 // First save the current settings, so the wxPrintData object is up to date.
581 TransferDataFromWindow();
583 // Transfer the current print settings from this dialog to the page setup dialog.
584 wxPrintDialogData data
;
585 data
= GetPageSetupData().GetPrintData();
586 data
.SetSetupDialog(TRUE
);
587 wxPrintDialog
*printDialog
= new wxPrintDialog(this, & data
);
588 printDialog
->ShowModal();
590 // Transfer the page setup print settings from the page dialog to this dialog again, in case
591 // the page setup dialog changed something.
592 GetPageSetupData().GetPrintData() = printDialog
->GetPrintDialogData().GetPrintData();
593 GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData
595 printDialog
->Destroy();
597 // Now update the dialog in case the page setup dialog changed some of our settings.
598 TransferDataToWindow();
601 wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow
*parent
, wxPageSetupData
* data
):
602 wxDialog(parent
, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL
|wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
609 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
612 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
613 new wxStaticBox(this,wxPRINTID_STATIC
, _("Paper size")), wxHORIZONTAL
);
615 int n
= wxThePrintPaperDatabase
->Number();
616 wxString
*choices
= new wxString
[n
];
618 for (i
= 0; i
< n
; i
++)
620 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
621 choices
[i
] = paper
->GetName();
624 m_paperTypeChoice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
, _("Paper Size"),
625 wxDefaultPosition
, wxSize(300, -1), n
, choices
);
626 topsizer
->Add( m_paperTypeChoice
, 1, wxEXPAND
|wxALL
, 5 );
627 // m_paperTypeChoice->SetSelection(sel);
629 mainsizer
->Add( topsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
| wxEXPAND
, 10 );
631 // 2) middle sizer with radio box
633 wxString
*choices2
= new wxString
[2];
634 choices2
[0] = _("Portrait");
635 choices2
[1] = _("Landscape");
636 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
637 wxDefaultPosition
, wxDefaultSize
, 2, choices2
, 2);
638 m_orientationRadioBox
->SetSelection(0);
640 mainsizer
->Add( m_orientationRadioBox
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 10 );
644 wxBoxSizer
*table
= new wxBoxSizer( wxHORIZONTAL
);
646 wxBoxSizer
*column1
= new wxBoxSizer( wxVERTICAL
);
647 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Left margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
648 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Top margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
649 table
->Add( column1
, 0, wxALL
| wxEXPAND
, 5 );
651 wxBoxSizer
*column2
= new wxBoxSizer( wxVERTICAL
);
652 m_marginLeftText
= new wxTextCtrl(this, wxPRINTID_LEFTMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
653 m_marginTopText
= new wxTextCtrl(this, wxPRINTID_TOPMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
654 column2
->Add( m_marginLeftText
, 1, wxALL
, 5 );
655 column2
->Add( m_marginTopText
, 1, wxALL
, 5 );
656 table
->Add( column2
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
658 wxBoxSizer
*column3
= new wxBoxSizer( wxVERTICAL
);
659 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Right margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
660 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Bottom margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
661 table
->Add( column3
, 0, wxALL
| wxEXPAND
, 5 );
663 wxBoxSizer
*column4
= new wxBoxSizer( wxVERTICAL
);
664 m_marginRightText
= new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
665 m_marginBottomText
= new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
666 column4
->Add( m_marginRightText
, 1, wxALL
, 5 );
667 column4
->Add( m_marginBottomText
, 1, wxALL
, 5 );
668 table
->Add( column4
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
670 mainsizer
->Add( table
, 0 );
674 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
679 wxSizer
* buttonsizer
= CreateButtonSizer( wxOK
|wxCANCEL
);
680 m_printerButton
= new wxButton(this, wxPRINTID_SETUP
, _("Printer...") );
681 buttonsizer
->Add( m_printerButton
, 0, wxLEFT
|wxRIGHT
, 10 );
682 if ( !m_pageData
.GetEnablePrinter() )
683 m_printerButton
->Enable(FALSE
);
684 // if (m_printData.GetEnableHelp())
685 // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
686 mainsizer
->Add( buttonsizer
, 0, wxCENTER
|wxALL
, 10 );
689 SetAutoLayout( TRUE
);
690 SetSizer( mainsizer
);
692 mainsizer
->Fit( this );
701 wxGenericPageSetupDialog::~wxGenericPageSetupDialog()
705 bool wxGenericPageSetupDialog::TransferDataToWindow()
707 if (m_marginLeftText
)
708 m_marginLeftText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().x
));
710 m_marginTopText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().y
));
711 if (m_marginRightText
)
712 m_marginRightText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().x
));
713 if (m_marginBottomText
)
714 m_marginBottomText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().y
));
716 if (m_orientationRadioBox
)
718 if (m_pageData
.GetPrintData().GetOrientation() == wxPORTRAIT
)
719 m_orientationRadioBox
->SetSelection(0);
721 m_orientationRadioBox
->SetSelection(1);
724 // Find the paper type from either the current paper size in the wxPageSetupDialogData, or
725 // failing that, the id in the wxPrintData object.
727 wxPrintPaperType
* type
= wxThePrintPaperDatabase
->FindPaperType(
728 wxSize(m_pageData
.GetPaperSize().x
* 10, m_pageData
.GetPaperSize().y
* 10));
730 if (!type
&& m_pageData
.GetPrintData().GetPaperId() != wxPAPER_NONE
)
731 type
= wxThePrintPaperDatabase
->FindPaperType(m_pageData
.GetPrintData().GetPaperId());
735 m_paperTypeChoice
->SetStringSelection(type
->GetName());
741 bool wxGenericPageSetupDialog::TransferDataFromWindow()
743 if (m_marginLeftText
&& m_marginTopText
)
744 m_pageData
.SetMarginTopLeft(wxPoint(wxAtoi((const wxChar
*)m_marginLeftText
->GetValue()),wxAtoi((const wxChar
*)m_marginTopText
->GetValue())));
745 if (m_marginRightText
&& m_marginBottomText
)
746 m_pageData
.SetMarginBottomRight(wxPoint(wxAtoi((const wxChar
*)m_marginRightText
->GetValue()),wxAtoi((const wxChar
*)m_marginBottomText
->GetValue())));
748 if (m_orientationRadioBox
)
750 int sel
= m_orientationRadioBox
->GetSelection();
754 wxThePrintSetupData
->SetPrinterOrientation(wxPORTRAIT
);
756 m_pageData
.GetPrintData().SetOrientation(wxPORTRAIT
);
761 wxThePrintSetupData
->SetPrinterOrientation(wxLANDSCAPE
);
763 m_pageData
.GetPrintData().SetOrientation(wxLANDSCAPE
);
766 if (m_paperTypeChoice
)
768 wxString
val(m_paperTypeChoice
->GetStringSelection());
769 if (!val
.IsNull() && val
!= "")
771 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(val
);
774 m_pageData
.SetPaperSize(wxSize(paper
->GetWidth()/10, paper
->GetHeight()/10));
775 m_pageData
.GetPrintData().SetPaperId(paper
->GetId());
783 wxComboBox
*wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
786 if (!wxThePrintPaperDatabase)
788 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
789 wxThePrintPaperDatabase->CreateDatabase();
793 int n
= wxThePrintPaperDatabase
->Number();
794 wxString
*choices
= new wxString
[n
];
796 for (i
= 0; i
< n
; i
++)
798 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
799 choices
[i
] = paper
->GetName();
802 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(*x
, *y
));
805 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
807 wxPoint(*x
, *y
), wxSize(300, -1), n
,
812 // choice->SetSelection(sel);