1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Generic print dialogs
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
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
36 #include "wx/stattext.h"
37 #include "wx/statbox.h"
38 #include "wx/button.h"
39 #include "wx/checkbox.h"
40 #include "wx/textctrl.h"
41 #include "wx/radiobox.h"
42 #include "wx/filedlg.h"
43 #include "wx/combobox.h"
46 #include "wx/cmndata.h"
50 #include "wx/statline.h"
53 #include "wx/generic/prntdlgg.h"
56 #include "wx/generic/dcpsg.h"
59 #include "wx/printdlg.h"
61 #include "wx/filename.h"
63 // For print paper things
64 #include "wx/prntbase.h"
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
76 IMPLEMENT_CLASS(wxGenericPrintDialog
, wxDialog
)
77 IMPLEMENT_CLASS(wxGenericPrintSetupDialog
, wxDialog
)
79 BEGIN_EVENT_TABLE(wxGenericPrintDialog
, wxDialog
)
80 EVT_BUTTON(wxID_OK
, wxGenericPrintDialog::OnOK
)
81 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPrintDialog::OnSetup
)
82 EVT_RADIOBOX(wxPRINTID_RANGE
, wxGenericPrintDialog::OnRange
)
85 #endif // wxUSE_POSTSCRIPT
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 // ----------------------------------------------------------------------------
102 // Generic print dialog for non-Windows printing use.
103 // ----------------------------------------------------------------------------
105 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
106 wxPrintDialogData
* data
)
107 : wxDialog(parent
, -1, _("Print"),
108 wxPoint(0, 0), wxSize(600, 600),
109 wxDEFAULT_DIALOG_STYLE
|
114 m_printDialogData
= *data
;
119 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
121 : wxDialog(parent
, -1, _("Print"),
122 wxPoint(0, 0), wxSize(600, 600),
123 wxDEFAULT_DIALOG_STYLE
|
128 m_printDialogData
= *data
;
133 void wxGenericPrintDialog::Init(wxWindow
* WXUNUSED(parent
))
135 // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
136 // wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
138 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
142 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
143 new wxStaticBox( this, -1, _( "Printer options" ) ), wxHORIZONTAL
);
144 m_printToFileCheckBox
= new wxCheckBox( this, wxPRINTID_PRINTTOFILE
, _("Print to File") );
145 topsizer
->Add( m_printToFileCheckBox
, 0, wxCENTER
|wxALL
, 5 );
147 topsizer
->Add( 60,2,1 );
149 m_setupButton
= new wxButton(this, wxPRINTID_SETUP
, _("Setup...") );
150 topsizer
->Add( m_setupButton
, 0, wxCENTER
|wxALL
, 5 );
152 mainsizer
->Add( topsizer
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
154 // 2) middle row with radio box
156 wxString
*choices
= new wxString
[2];
157 choices
[0] = _("All");
158 choices
[1] = _("Pages");
160 m_fromText
= (wxTextCtrl
*)NULL
;
161 m_toText
= (wxTextCtrl
*)NULL
;
162 m_rangeRadioBox
= (wxRadioBox
*)NULL
;
164 if (m_printDialogData
.GetFromPage() != 0)
166 m_rangeRadioBox
= new wxRadioBox(this, wxPRINTID_RANGE
, _("Print Range"),
167 wxDefaultPosition
, wxDefaultSize
,
170 m_rangeRadioBox
->SetSelection(1);
172 mainsizer
->Add( m_rangeRadioBox
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
177 wxBoxSizer
*bottomsizer
= new wxBoxSizer( wxHORIZONTAL
);
179 if (m_printDialogData
.GetFromPage() != 0)
181 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("From:") ), 0, wxCENTER
|wxALL
, 5 );
182 m_fromText
= new wxTextCtrl(this, wxPRINTID_FROM
, wxT(""), wxDefaultPosition
, wxSize(40, -1));
183 bottomsizer
->Add( m_fromText
, 1, wxCENTER
|wxRIGHT
, 10 );
185 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("To:") ), 0, wxCENTER
|wxALL
, 5);
186 m_toText
= new wxTextCtrl(this, wxPRINTID_TO
, wxT(""), wxDefaultPosition
, wxSize(40, -1));
187 bottomsizer
->Add( m_toText
, 1, wxCENTER
|wxRIGHT
, 10 );
190 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Copies:") ), 0, wxCENTER
|wxALL
, 5 );
191 m_noCopiesText
= new wxTextCtrl(this, wxPRINTID_COPIES
, wxT(""), wxPoint(252, 130), wxSize(40, -1));
192 bottomsizer
->Add( m_noCopiesText
, 1, wxCENTER
|wxRIGHT
, 10 );
194 mainsizer
->Add( bottomsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 12 );
198 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
203 mainsizer
->Add( CreateButtonSizer( wxOK
|wxCANCEL
), 0, wxCENTER
|wxALL
, 10 );
205 SetAutoLayout( TRUE
);
206 SetSizer( mainsizer
);
208 mainsizer
->Fit( this );
211 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
216 int wxGenericPrintDialog::ShowModal()
218 if ( m_printDialogData
.GetSetupDialog() )
220 // Make sure wxPrintData object reflects the settings now, in case the setup dialog
221 // changes it. In fact there aren't any common settings at
222 // present, but there might be in future.
223 // TransferDataFromWindow();
225 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
226 new wxGenericPrintSetupDialog(this, & m_printDialogData
.GetPrintData());
227 int ret
= genericPrintSetupDialog
->ShowModal();
228 if ( ret
!= wxID_CANCEL
)
230 // Transfer settings to the print dialog's print data.
231 m_printDialogData
.GetPrintData() = genericPrintSetupDialog
->GetPrintData();
233 genericPrintSetupDialog
->Destroy();
235 // Restore the wxPrintData settings again (uncomment if any settings become common
237 // TransferDataToWindow();
243 return wxDialog::ShowModal();
247 wxGenericPrintDialog::~wxGenericPrintDialog()
251 void wxGenericPrintDialog::OnOK(wxCommandEvent
& WXUNUSED(event
))
253 TransferDataFromWindow();
255 // There are some interactions between the global setup data
256 // and the standard print dialog. The global printing 'mode'
257 // is determined by whether the user checks Print to file
259 if (m_printDialogData
.GetPrintToFile())
261 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE
);
263 wxFileName
fname( m_printDialogData
.GetPrintData().GetFilename() );
265 wxFileDialog
dialog( this, _("PostScript file"),
266 fname
.GetPath(), fname
.GetFullName(), wxT("*.ps"), wxOPEN
| wxOVERWRITE_PROMPT
);
267 if (dialog
.ShowModal() != wxID_OK
) return;
269 m_printDialogData
.GetPrintData().SetFilename( dialog
.GetPath() );
273 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER
);
279 void wxGenericPrintDialog::OnRange(wxCommandEvent
& event
)
281 if (!m_fromText
) return;
283 if (event
.GetInt() == 0)
285 m_fromText
->Enable(FALSE
);
286 m_toText
->Enable(FALSE
);
288 else if (event
.GetInt() == 1)
290 m_fromText
->Enable(TRUE
);
291 m_toText
->Enable(TRUE
);
295 void wxGenericPrintDialog::OnSetup(wxCommandEvent
& WXUNUSED(event
))
297 wxGenericPrintSetupDialog
dialog( this, &m_printDialogData
.GetPrintData() );
298 if (dialog
.ShowModal() != wxID_CANCEL
)
300 m_printDialogData
= dialog
.GetPrintData();
304 bool wxGenericPrintDialog::TransferDataToWindow()
306 if(m_printDialogData
.GetFromPage() != 0)
310 if (m_printDialogData
.GetEnablePageNumbers())
312 m_fromText
->Enable(TRUE
);
313 m_toText
->Enable(TRUE
);
314 m_fromText
->SetValue(
315 wxString::Format(_T("%d"), m_printDialogData
.GetFromPage()));
317 wxString::Format(_T("%d"), m_printDialogData
.GetToPage()));
319 if (m_printDialogData
.GetAllPages())
320 m_rangeRadioBox
->SetSelection(0);
322 m_rangeRadioBox
->SetSelection(1);
326 m_fromText
->Enable(FALSE
);
327 m_toText
->Enable(FALSE
);
330 m_rangeRadioBox
->SetSelection(0);
331 m_rangeRadioBox
->wxRadioBox::Enable(1, FALSE
);
336 m_noCopiesText
->SetValue(
337 wxString::Format(_T("%d"), m_printDialogData
.GetNoCopies()));
339 m_printToFileCheckBox
->SetValue(m_printDialogData
.GetPrintToFile());
340 m_printToFileCheckBox
->Enable(m_printDialogData
.GetEnablePrintToFile());
344 bool wxGenericPrintDialog::TransferDataFromWindow()
347 if(m_printDialogData
.GetFromPage() != -1)
349 if (m_printDialogData
.GetEnablePageNumbers())
353 wxString value
= m_fromText
->GetValue();
354 if (value
.ToLong( &res
))
355 m_printDialogData
.SetFromPage( res
);
359 wxString value
= m_toText
->GetValue();
360 if (value
.ToLong( &res
))
361 m_printDialogData
.SetToPage( res
);
366 if (m_rangeRadioBox
->GetSelection() == 0)
367 m_printDialogData
.SetAllPages(TRUE
);
369 m_printDialogData
.SetAllPages(FALSE
);
373 { // continuous printing
374 m_printDialogData
.SetFromPage(1);
375 m_printDialogData
.SetToPage(32000);
378 wxString value
= m_noCopiesText
->GetValue();
379 if (value
.ToLong( &res
))
380 m_printDialogData
.SetNoCopies( res
);
382 m_printDialogData
.SetPrintToFile(m_printToFileCheckBox
->GetValue());
388 TODO: collate and noCopies should be duplicated across dialog data and print data objects
389 (slightly different semantics on Windows but let's ignore this for a bit).
392 wxDC
*wxGenericPrintDialog::GetPrintDC()
394 // return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
395 return new wxPostScriptDC(GetPrintDialogData().GetPrintData());
398 // ----------------------------------------------------------------------------
399 // Generic print setup dialog
400 // ----------------------------------------------------------------------------
402 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintData
* data
):
403 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
408 void wxGenericPrintSetupDialog::Init(wxPrintData
* data
)
413 int staticBoxWidth
= 300;
415 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth
, 60) );
419 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
421 wxString
*choices
= new wxString
[2];
422 choices
[0] = _("Portrait");
423 choices
[1] = _("Landscape");
425 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
426 wxPoint(10, 80), wxSize(-1, -1), 2, choices
, 1, wxRA_VERTICAL
);
427 m_orientationRadioBox
->SetSelection(0);
429 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth
, 50) );
431 int colourYPos
= 145;
437 m_colourCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTCOLOUR
, _("Print in colour"), wxPoint(15, colourYPos
));
439 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
441 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer command:"), wxPoint(340, 30));
443 m_printerCommandText
= new wxTextCtrl(this, wxPRINTID_COMMAND
, wxT(""), wxPoint(360, 55), wxSize(150, -1));
445 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer options:"), wxPoint(340, 110));
447 m_printerOptionsText
= new wxTextCtrl(this, wxPRINTID_OPTIONS
, wxT(""), wxPoint(360, 135), wxSize(150, -1));
449 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(130, 200), wxSize(80, -1));
450 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(320, 200), wxSize(80, -1));
452 okButton
->SetDefault();
453 okButton
->SetFocus();
462 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog()
466 bool wxGenericPrintSetupDialog::TransferDataToWindow()
468 if (m_printerCommandText
&& m_printData
.GetPrinterCommand())
469 m_printerCommandText
->SetValue(m_printData
.GetPrinterCommand());
470 if (m_printerOptionsText
&& m_printData
.GetPrinterOptions())
471 m_printerOptionsText
->SetValue(m_printData
.GetPrinterOptions());
472 if (m_colourCheckBox
)
473 m_colourCheckBox
->SetValue(m_printData
.GetColour());
475 if (m_orientationRadioBox
)
477 if (m_printData
.GetOrientation() == wxPORTRAIT
)
478 m_orientationRadioBox
->SetSelection(0);
480 m_orientationRadioBox
->SetSelection(1);
485 bool wxGenericPrintSetupDialog::TransferDataFromWindow()
487 if (m_printerCommandText
)
488 m_printData
.SetPrinterCommand(m_printerCommandText
->GetValue());
489 if (m_printerOptionsText
)
490 m_printData
.SetPrinterOptions(m_printerOptionsText
->GetValue());
491 if (m_colourCheckBox
)
492 m_printData
.SetColour(m_colourCheckBox
->GetValue());
493 if (m_orientationRadioBox
)
495 int sel
= m_orientationRadioBox
->GetSelection();
497 m_printData
.SetOrientation(wxPORTRAIT
);
499 m_printData
.SetOrientation(wxLANDSCAPE
);
501 if (m_paperTypeChoice
)
503 int selectedItem
= m_paperTypeChoice
->GetSelection();
504 if (selectedItem
!= -1)
506 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Item(selectedItem
)->GetData();
508 m_printData
.SetPaperId( paper
->GetId());
515 wxComboBox
*wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
517 /* Should not be necessary
518 if (!wxThePrintPaperDatabase)
520 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
521 wxThePrintPaperDatabase->CreateDatabase();
524 size_t n
= wxThePrintPaperDatabase
->GetCount();
525 wxString
*choices
= new wxString
[n
];
528 for (size_t i
= 0; i
< n
; i
++)
530 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Item(i
)->GetData();
531 choices
[i
] = paper
->GetName();
532 if (m_printData
.GetPaperId() == paper
->GetId())
538 wxComboBox
*choice
= new wxComboBox( this,
545 // SetFont(thisFont);
549 choice
->SetSelection(sel
);
552 #endif // wxUSE_POSTSCRIPT
554 // ----------------------------------------------------------------------------
555 // Generic page setup dialog
556 // ----------------------------------------------------------------------------
558 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent
& WXUNUSED(event
))
560 // We no longer query GetPrintMode, so we can eliminate the need
561 // to call SetPrintMode.
562 // This has the limitation that we can't explicitly call the PostScript
563 // print setup dialog from the generic Page Setup dialog under Windows,
564 // but since this choice would only happen when trying to do PostScript
565 // printing under Windows (and only in 16-bit Windows which
566 // doesn't have a Windows-specific page setup dialog) it's worth it.
568 // First save the current settings, so the wxPrintData object is up to date.
569 TransferDataFromWindow();
571 // Transfer the current print settings from this dialog to the page setup dialog.
572 wxPrintDialogData data
;
573 data
= GetPageSetupData().GetPrintData();
574 data
.SetSetupDialog(TRUE
);
575 wxPrintDialog
*printDialog
= new wxPrintDialog(this, & data
);
576 printDialog
->ShowModal();
578 // Transfer the page setup print settings from the page dialog to this dialog again, in case
579 // the page setup dialog changed something.
580 GetPageSetupData().GetPrintData() = printDialog
->GetPrintDialogData().GetPrintData();
581 GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData
583 printDialog
->Destroy();
585 // Now update the dialog in case the page setup dialog changed some of our settings.
586 TransferDataToWindow();
589 wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow
*parent
,
590 wxPageSetupData
* data
)
596 wxDIALOG_MODAL
|wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
603 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
606 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
607 new wxStaticBox(this,wxPRINTID_STATIC
, _("Paper size")), wxHORIZONTAL
);
609 size_t n
= wxThePrintPaperDatabase
->GetCount();
610 wxString
*choices
= new wxString
[n
];
612 for (size_t i
= 0; i
< n
; i
++)
614 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Item(i
)->GetData();
615 choices
[i
] = paper
->GetName();
618 m_paperTypeChoice
= new wxComboBox( this,
624 topsizer
->Add( m_paperTypeChoice
, 1, wxEXPAND
|wxALL
, 5 );
625 // m_paperTypeChoice->SetSelection(sel);
627 mainsizer
->Add( topsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
| wxEXPAND
, 10 );
629 // 2) middle sizer with radio box
631 wxString
*choices2
= new wxString
[2];
632 choices2
[0] = _("Portrait");
633 choices2
[1] = _("Landscape");
634 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
635 wxDefaultPosition
, wxDefaultSize
, 2, choices2
, 2);
636 m_orientationRadioBox
->SetSelection(0);
638 mainsizer
->Add( m_orientationRadioBox
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 10 );
642 wxBoxSizer
*table
= new wxBoxSizer( wxHORIZONTAL
);
644 wxBoxSizer
*column1
= new wxBoxSizer( wxVERTICAL
);
645 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Left margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
646 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Top margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
647 table
->Add( column1
, 0, wxALL
| wxEXPAND
, 5 );
649 wxBoxSizer
*column2
= new wxBoxSizer( wxVERTICAL
);
650 m_marginLeftText
= new wxTextCtrl(this, wxPRINTID_LEFTMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
651 m_marginTopText
= new wxTextCtrl(this, wxPRINTID_TOPMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
652 column2
->Add( m_marginLeftText
, 1, wxALL
, 5 );
653 column2
->Add( m_marginTopText
, 1, wxALL
, 5 );
654 table
->Add( column2
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
656 wxBoxSizer
*column3
= new wxBoxSizer( wxVERTICAL
);
657 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Right margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
658 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Bottom margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
659 table
->Add( column3
, 0, wxALL
| wxEXPAND
, 5 );
661 wxBoxSizer
*column4
= new wxBoxSizer( wxVERTICAL
);
662 m_marginRightText
= new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
663 m_marginBottomText
= new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
664 column4
->Add( m_marginRightText
, 1, wxALL
, 5 );
665 column4
->Add( m_marginBottomText
, 1, wxALL
, 5 );
666 table
->Add( column4
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
668 mainsizer
->Add( table
, 0 );
672 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
677 wxSizer
* buttonsizer
= CreateButtonSizer( wxOK
|wxCANCEL
);
678 m_printerButton
= new wxButton(this, wxPRINTID_SETUP
, _("Printer...") );
679 buttonsizer
->Add( m_printerButton
, 0, wxLEFT
|wxRIGHT
, 10 );
680 if ( !m_pageData
.GetEnablePrinter() )
681 m_printerButton
->Enable(FALSE
);
682 // if (m_printData.GetEnableHelp())
683 // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
684 mainsizer
->Add( buttonsizer
, 0, wxCENTER
|wxALL
, 10 );
687 SetAutoLayout( TRUE
);
688 SetSizer( mainsizer
);
690 mainsizer
->Fit( this );
699 wxGenericPageSetupDialog::~wxGenericPageSetupDialog()
703 static inline wxString
IntToString( long value
)
705 return wxString::Format(wxT("%ld"), value
);
708 bool wxGenericPageSetupDialog::TransferDataToWindow()
710 if (m_marginLeftText
)
711 m_marginLeftText
->SetValue(IntToString(m_pageData
.GetMarginTopLeft().x
));
713 m_marginTopText
->SetValue(IntToString(m_pageData
.GetMarginTopLeft().y
));
714 if (m_marginRightText
)
715 m_marginRightText
->SetValue(IntToString(m_pageData
.GetMarginBottomRight().x
));
716 if (m_marginBottomText
)
717 m_marginBottomText
->SetValue(IntToString(m_pageData
.GetMarginBottomRight().y
));
719 if (m_orientationRadioBox
)
721 if (m_pageData
.GetPrintData().GetOrientation() == wxPORTRAIT
)
722 m_orientationRadioBox
->SetSelection(0);
724 m_orientationRadioBox
->SetSelection(1);
727 // Find the paper type from either the current paper size in the wxPageSetupDialogData, or
728 // failing that, the id in the wxPrintData object.
730 wxPrintPaperType
* type
= wxThePrintPaperDatabase
->FindPaperType(
731 wxSize(m_pageData
.GetPaperSize().x
* 10, m_pageData
.GetPaperSize().y
* 10));
733 if (!type
&& m_pageData
.GetPrintData().GetPaperId() != wxPAPER_NONE
)
734 type
= wxThePrintPaperDatabase
->FindPaperType(m_pageData
.GetPrintData().GetPaperId());
738 m_paperTypeChoice
->SetStringSelection(type
->GetName());
744 bool wxGenericPageSetupDialog::TransferDataFromWindow()
746 if (m_marginLeftText
&& m_marginTopText
)
748 int left
= wxAtoi( m_marginLeftText
->GetValue().c_str() );
749 int top
= wxAtoi( m_marginTopText
->GetValue().c_str() );
750 m_pageData
.SetMarginTopLeft( wxPoint(left
,top
) );
752 if (m_marginRightText
&& m_marginBottomText
)
754 int right
= wxAtoi( m_marginRightText
->GetValue().c_str() );
755 int bottom
= wxAtoi( m_marginBottomText
->GetValue().c_str() );
756 m_pageData
.SetMarginBottomRight( wxPoint(right
,bottom
) );
759 if (m_orientationRadioBox
)
761 int sel
= m_orientationRadioBox
->GetSelection();
764 m_pageData
.GetPrintData().SetOrientation(wxPORTRAIT
);
768 m_pageData
.GetPrintData().SetOrientation(wxLANDSCAPE
);
772 if (m_paperTypeChoice
)
774 int selectedItem
= m_paperTypeChoice
->GetSelection();
775 if (selectedItem
!= -1)
777 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Item(selectedItem
)->GetData();
780 m_pageData
.SetPaperSize(wxSize(paper
->GetWidth()/10, paper
->GetHeight()/10));
781 m_pageData
.GetPrintData().SetPaperId(paper
->GetId());
789 wxComboBox
*wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
792 if (!wxThePrintPaperDatabase)
794 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
795 wxThePrintPaperDatabase->CreateDatabase();
799 size_t n
= wxThePrintPaperDatabase
->GetCount();
800 wxString
*choices
= new wxString
[n
];
802 for (size_t i
= 0; i
< n
; i
++)
804 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Item(i
)->GetData();
805 choices
[i
] = paper
->GetName();
808 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(*x
, *y
));
811 wxComboBox
*choice
= new wxComboBox( this,
820 // choice->SetSelection(sel);