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"
49 #include "wx/cmndata.h"
53 #include "wx/statline.h"
56 #include "wx/generic/prntdlgg.h"
59 #include "wx/generic/dcpsg.h"
62 #include "wx/printdlg.h"
64 #include "wx/filename.h"
66 // For print paper things
67 #include "wx/prntbase.h"
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
79 IMPLEMENT_CLASS(wxGenericPrintDialog
, wxDialog
)
80 IMPLEMENT_CLASS(wxGenericPrintSetupDialog
, wxDialog
)
82 BEGIN_EVENT_TABLE(wxGenericPrintDialog
, wxDialog
)
83 EVT_BUTTON(wxID_OK
, wxGenericPrintDialog::OnOK
)
84 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPrintDialog::OnSetup
)
85 EVT_RADIOBOX(wxPRINTID_RANGE
, wxGenericPrintDialog::OnRange
)
88 #endif // wxUSE_POSTSCRIPT
90 IMPLEMENT_CLASS(wxGenericPageSetupDialog
, wxDialog
)
92 BEGIN_EVENT_TABLE(wxGenericPageSetupDialog
, wxDialog
)
93 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPageSetupDialog::OnPrinter
)
96 // ----------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
100 extern wxPrintPaperDatabase
*wxThePrintPaperDatabase
;
104 // ----------------------------------------------------------------------------
105 // Generic print dialog for non-Windows printing use.
106 // ----------------------------------------------------------------------------
108 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
109 wxPrintDialogData
* data
)
110 : wxDialog(parent
, -1, _("Print"),
111 wxPoint(0, 0), wxSize(600, 600),
112 wxDEFAULT_DIALOG_STYLE
|
117 m_printDialogData
= *data
;
122 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
124 : wxDialog(parent
, -1, _("Print"),
125 wxPoint(0, 0), wxSize(600, 600),
126 wxDEFAULT_DIALOG_STYLE
|
131 m_printDialogData
= *data
;
136 void wxGenericPrintDialog::Init(wxWindow
* WXUNUSED(parent
))
138 // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
139 // wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
141 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
145 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
146 new wxStaticBox( this, -1, _( "Printer options" ) ), wxHORIZONTAL
);
147 m_printToFileCheckBox
= new wxCheckBox( this, wxPRINTID_PRINTTOFILE
, _("Print to File") );
148 topsizer
->Add( m_printToFileCheckBox
, 0, wxCENTER
|wxALL
, 5 );
150 topsizer
->Add( 60,2,1 );
152 m_setupButton
= new wxButton(this, wxPRINTID_SETUP
, _("Setup...") );
153 topsizer
->Add( m_setupButton
, 0, wxCENTER
|wxALL
, 5 );
155 mainsizer
->Add( topsizer
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
157 // 2) middle row with radio box
159 wxString
*choices
= new wxString
[2];
160 choices
[0] = _("All");
161 choices
[1] = _("Pages");
163 m_fromText
= (wxTextCtrl
*)NULL
;
164 m_toText
= (wxTextCtrl
*)NULL
;
165 m_rangeRadioBox
= (wxRadioBox
*)NULL
;
167 if (m_printDialogData
.GetFromPage() != 0)
169 m_rangeRadioBox
= new wxRadioBox(this, wxPRINTID_RANGE
, _("Print Range"),
170 wxDefaultPosition
, wxDefaultSize
,
173 m_rangeRadioBox
->SetSelection(1);
175 mainsizer
->Add( m_rangeRadioBox
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
180 wxBoxSizer
*bottomsizer
= new wxBoxSizer( wxHORIZONTAL
);
182 if (m_printDialogData
.GetFromPage() != 0)
184 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("From:") ), 0, wxCENTER
|wxALL
, 5 );
185 m_fromText
= new wxTextCtrl(this, wxPRINTID_FROM
, wxT(""), wxDefaultPosition
, wxSize(40, -1));
186 bottomsizer
->Add( m_fromText
, 1, wxCENTER
|wxRIGHT
, 10 );
188 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("To:") ), 0, wxCENTER
|wxALL
, 5);
189 m_toText
= new wxTextCtrl(this, wxPRINTID_TO
, wxT(""), wxDefaultPosition
, wxSize(40, -1));
190 bottomsizer
->Add( m_toText
, 1, wxCENTER
|wxRIGHT
, 10 );
193 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Copies:") ), 0, wxCENTER
|wxALL
, 5 );
194 m_noCopiesText
= new wxTextCtrl(this, wxPRINTID_COPIES
, wxT(""), wxPoint(252, 130), wxSize(40, -1));
195 bottomsizer
->Add( m_noCopiesText
, 1, wxCENTER
|wxRIGHT
, 10 );
197 mainsizer
->Add( bottomsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 12 );
201 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
206 mainsizer
->Add( CreateButtonSizer( wxOK
|wxCANCEL
), 0, wxCENTER
|wxALL
, 10 );
208 SetAutoLayout( TRUE
);
209 SetSizer( mainsizer
);
211 mainsizer
->Fit( this );
214 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
219 int wxGenericPrintDialog::ShowModal()
221 if ( m_printDialogData
.GetSetupDialog() )
223 // Make sure wxPrintData object reflects the settings now, in case the setup dialog
224 // changes it. In fact there aren't any common settings at
225 // present, but there might be in future.
226 // TransferDataFromWindow();
228 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
229 new wxGenericPrintSetupDialog(this, & m_printDialogData
.GetPrintData());
230 int ret
= genericPrintSetupDialog
->ShowModal();
231 if ( ret
!= wxID_CANCEL
)
233 // Transfer settings to the print dialog's print data.
234 m_printDialogData
.GetPrintData() = genericPrintSetupDialog
->GetPrintData();
236 genericPrintSetupDialog
->Destroy();
238 // Restore the wxPrintData settings again (uncomment if any settings become common
240 // TransferDataToWindow();
246 return wxDialog::ShowModal();
250 wxGenericPrintDialog::~wxGenericPrintDialog()
254 void wxGenericPrintDialog::OnOK(wxCommandEvent
& WXUNUSED(event
))
256 TransferDataFromWindow();
258 // There are some interactions between the global setup data
259 // and the standard print dialog. The global printing 'mode'
260 // is determined by whether the user checks Print to file
262 if (m_printDialogData
.GetPrintToFile())
264 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE
);
266 wxFileName
fname( m_printDialogData
.GetPrintData().GetFilename() );
268 wxFileDialog
dialog( this, _("PostScript file"),
269 fname
.GetPath(), fname
.GetFullName(), wxT("*.ps"), wxOPEN
| wxOVERWRITE_PROMPT
);
270 if (dialog
.ShowModal() != wxID_OK
) return;
272 m_printDialogData
.GetPrintData().SetFilename( dialog
.GetPath() );
276 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER
);
282 void wxGenericPrintDialog::OnRange(wxCommandEvent
& event
)
284 if (!m_fromText
) return;
286 if (event
.GetInt() == 0)
288 m_fromText
->Enable(FALSE
);
289 m_toText
->Enable(FALSE
);
291 else if (event
.GetInt() == 1)
293 m_fromText
->Enable(TRUE
);
294 m_toText
->Enable(TRUE
);
298 void wxGenericPrintDialog::OnSetup(wxCommandEvent
& WXUNUSED(event
))
300 wxGenericPrintSetupDialog
dialog( this, &m_printDialogData
.GetPrintData() );
301 if (dialog
.ShowModal() != wxID_CANCEL
)
303 m_printDialogData
= dialog
.GetPrintData();
307 bool wxGenericPrintDialog::TransferDataToWindow()
309 if(m_printDialogData
.GetFromPage() != 0)
313 if (m_printDialogData
.GetEnablePageNumbers())
315 m_fromText
->Enable(TRUE
);
316 m_toText
->Enable(TRUE
);
317 m_fromText
->SetValue(
318 wxString::Format(_T("%d"), m_printDialogData
.GetFromPage()));
320 wxString::Format(_T("%d"), m_printDialogData
.GetToPage()));
322 if (m_printDialogData
.GetAllPages())
323 m_rangeRadioBox
->SetSelection(0);
325 m_rangeRadioBox
->SetSelection(1);
329 m_fromText
->Enable(FALSE
);
330 m_toText
->Enable(FALSE
);
333 m_rangeRadioBox
->SetSelection(0);
334 m_rangeRadioBox
->wxRadioBox::Enable(1, FALSE
);
339 m_noCopiesText
->SetValue(
340 wxString::Format(_T("%d"), m_printDialogData
.GetNoCopies()));
342 m_printToFileCheckBox
->SetValue(m_printDialogData
.GetPrintToFile());
343 m_printToFileCheckBox
->Enable(m_printDialogData
.GetEnablePrintToFile());
347 bool wxGenericPrintDialog::TransferDataFromWindow()
350 if(m_printDialogData
.GetFromPage() != -1)
352 if (m_printDialogData
.GetEnablePageNumbers())
356 wxString value
= m_fromText
->GetValue();
357 if (value
.ToLong( &res
))
358 m_printDialogData
.SetFromPage( res
);
362 wxString value
= m_toText
->GetValue();
363 if (value
.ToLong( &res
))
364 m_printDialogData
.SetToPage( res
);
369 if (m_rangeRadioBox
->GetSelection() == 0)
370 m_printDialogData
.SetAllPages(TRUE
);
372 m_printDialogData
.SetAllPages(FALSE
);
376 { // continuous printing
377 m_printDialogData
.SetFromPage(1);
378 m_printDialogData
.SetToPage(32000);
381 wxString value
= m_noCopiesText
->GetValue();
382 if (value
.ToLong( &res
))
383 m_printDialogData
.SetNoCopies( res
);
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 void wxGenericPrintSetupDialog::Init(wxPrintData
* data
)
416 int staticBoxWidth
= 300;
418 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth
, 60) );
422 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
424 wxString
*choices
= new wxString
[2];
425 choices
[0] = _("Portrait");
426 choices
[1] = _("Landscape");
428 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
429 wxPoint(10, 80), wxSize(-1, -1), 2, choices
, 1, wxRA_VERTICAL
);
430 m_orientationRadioBox
->SetSelection(0);
432 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth
, 50) );
434 int colourYPos
= 145;
440 m_colourCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTCOLOUR
, _("Print in colour"), wxPoint(15, colourYPos
));
442 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
444 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer command:"), wxPoint(340, 30));
446 m_printerCommandText
= new wxTextCtrl(this, wxPRINTID_COMMAND
, wxT(""), wxPoint(360, 55), wxSize(150, -1));
448 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer options:"), wxPoint(340, 110));
450 m_printerOptionsText
= new wxTextCtrl(this, wxPRINTID_OPTIONS
, wxT(""), wxPoint(360, 135), wxSize(150, -1));
452 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(130, 200), wxSize(80, -1));
453 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(320, 200), wxSize(80, -1));
455 okButton
->SetDefault();
456 okButton
->SetFocus();
465 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog()
469 bool wxGenericPrintSetupDialog::TransferDataToWindow()
471 if (m_printerCommandText
&& m_printData
.GetPrinterCommand())
472 m_printerCommandText
->SetValue(m_printData
.GetPrinterCommand());
473 if (m_printerOptionsText
&& m_printData
.GetPrinterOptions())
474 m_printerOptionsText
->SetValue(m_printData
.GetPrinterOptions());
475 if (m_colourCheckBox
)
476 m_colourCheckBox
->SetValue(m_printData
.GetColour());
478 if (m_orientationRadioBox
)
480 if (m_printData
.GetOrientation() == wxPORTRAIT
)
481 m_orientationRadioBox
->SetSelection(0);
483 m_orientationRadioBox
->SetSelection(1);
488 bool wxGenericPrintSetupDialog::TransferDataFromWindow()
490 if (m_printerCommandText
)
491 m_printData
.SetPrinterCommand(m_printerCommandText
->GetValue());
492 if (m_printerOptionsText
)
493 m_printData
.SetPrinterOptions(m_printerOptionsText
->GetValue());
494 if (m_colourCheckBox
)
495 m_printData
.SetColour(m_colourCheckBox
->GetValue());
496 if (m_orientationRadioBox
)
498 int sel
= m_orientationRadioBox
->GetSelection();
500 m_printData
.SetOrientation(wxPORTRAIT
);
502 m_printData
.SetOrientation(wxLANDSCAPE
);
504 if (m_paperTypeChoice
)
506 wxString
val(m_paperTypeChoice
->GetStringSelection());
507 if (!val
.IsNull() && val
!= wxT(""))
508 m_printData
.SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(val
));
514 wxComboBox
*wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
516 /* Should not be necessary
517 if (!wxThePrintPaperDatabase)
519 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
520 wxThePrintPaperDatabase->CreateDatabase();
523 int n
= wxThePrintPaperDatabase
->Number();
524 wxString
*choices
= new wxString
[n
];
527 for (i
= 0; i
< n
; i
++)
529 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
530 choices
[i
] = paper
->GetName();
531 if (m_printData
.GetPaperId() == paper
->GetId())
537 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
539 wxPoint(*x
, *y
), wxSize(width
, -1), n
,
542 // SetFont(thisFont);
546 choice
->SetSelection(sel
);
549 #endif // wxUSE_POSTSCRIPT
551 // ----------------------------------------------------------------------------
552 // Generic page setup dialog
553 // ----------------------------------------------------------------------------
555 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent
& WXUNUSED(event
))
557 // We no longer query GetPrintMode, so we can eliminate the need
558 // to call SetPrintMode.
559 // This has the limitation that we can't explicitly call the PostScript
560 // print setup dialog from the generic Page Setup dialog under Windows,
561 // but since this choice would only happen when trying to do PostScript
562 // printing under Windows (and only in 16-bit Windows which
563 // doesn't have a Windows-specific page setup dialog) it's worth it.
565 // First save the current settings, so the wxPrintData object is up to date.
566 TransferDataFromWindow();
568 // Transfer the current print settings from this dialog to the page setup dialog.
569 wxPrintDialogData data
;
570 data
= GetPageSetupData().GetPrintData();
571 data
.SetSetupDialog(TRUE
);
572 wxPrintDialog
*printDialog
= new wxPrintDialog(this, & data
);
573 printDialog
->ShowModal();
575 // Transfer the page setup print settings from the page dialog to this dialog again, in case
576 // the page setup dialog changed something.
577 GetPageSetupData().GetPrintData() = printDialog
->GetPrintDialogData().GetPrintData();
578 GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData
580 printDialog
->Destroy();
582 // Now update the dialog in case the page setup dialog changed some of our settings.
583 TransferDataToWindow();
586 wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow
*parent
, wxPageSetupData
* data
):
587 wxDialog(parent
, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL
|wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
594 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
597 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
598 new wxStaticBox(this,wxPRINTID_STATIC
, _("Paper size")), wxHORIZONTAL
);
600 int n
= wxThePrintPaperDatabase
->Number();
601 wxString
*choices
= new wxString
[n
];
603 for (i
= 0; i
< n
; i
++)
605 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
606 choices
[i
] = paper
->GetName();
609 m_paperTypeChoice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
, _("Paper Size"),
610 wxDefaultPosition
, wxSize(300, -1), n
, choices
);
611 topsizer
->Add( m_paperTypeChoice
, 1, wxEXPAND
|wxALL
, 5 );
612 // m_paperTypeChoice->SetSelection(sel);
614 mainsizer
->Add( topsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
| wxEXPAND
, 10 );
616 // 2) middle sizer with radio box
618 wxString
*choices2
= new wxString
[2];
619 choices2
[0] = _("Portrait");
620 choices2
[1] = _("Landscape");
621 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
622 wxDefaultPosition
, wxDefaultSize
, 2, choices2
, 2);
623 m_orientationRadioBox
->SetSelection(0);
625 mainsizer
->Add( m_orientationRadioBox
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 10 );
629 wxBoxSizer
*table
= new wxBoxSizer( wxHORIZONTAL
);
631 wxBoxSizer
*column1
= new wxBoxSizer( wxVERTICAL
);
632 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Left margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
633 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Top margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
634 table
->Add( column1
, 0, wxALL
| wxEXPAND
, 5 );
636 wxBoxSizer
*column2
= new wxBoxSizer( wxVERTICAL
);
637 m_marginLeftText
= new wxTextCtrl(this, wxPRINTID_LEFTMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
638 m_marginTopText
= new wxTextCtrl(this, wxPRINTID_TOPMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
639 column2
->Add( m_marginLeftText
, 1, wxALL
, 5 );
640 column2
->Add( m_marginTopText
, 1, wxALL
, 5 );
641 table
->Add( column2
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
643 wxBoxSizer
*column3
= new wxBoxSizer( wxVERTICAL
);
644 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Right margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
645 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Bottom margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
646 table
->Add( column3
, 0, wxALL
| wxEXPAND
, 5 );
648 wxBoxSizer
*column4
= new wxBoxSizer( wxVERTICAL
);
649 m_marginRightText
= new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
650 m_marginBottomText
= new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN
, wxT(""), wxDefaultPosition
, wxSize(textWidth
, -1));
651 column4
->Add( m_marginRightText
, 1, wxALL
, 5 );
652 column4
->Add( m_marginBottomText
, 1, wxALL
, 5 );
653 table
->Add( column4
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
655 mainsizer
->Add( table
, 0 );
659 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
664 wxSizer
* buttonsizer
= CreateButtonSizer( wxOK
|wxCANCEL
);
665 m_printerButton
= new wxButton(this, wxPRINTID_SETUP
, _("Printer...") );
666 buttonsizer
->Add( m_printerButton
, 0, wxLEFT
|wxRIGHT
, 10 );
667 if ( !m_pageData
.GetEnablePrinter() )
668 m_printerButton
->Enable(FALSE
);
669 // if (m_printData.GetEnableHelp())
670 // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
671 mainsizer
->Add( buttonsizer
, 0, wxCENTER
|wxALL
, 10 );
674 SetAutoLayout( TRUE
);
675 SetSizer( mainsizer
);
677 mainsizer
->Fit( this );
686 wxGenericPageSetupDialog::~wxGenericPageSetupDialog()
690 bool wxGenericPageSetupDialog::TransferDataToWindow()
692 if (m_marginLeftText
)
693 m_marginLeftText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().x
));
695 m_marginTopText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().y
));
696 if (m_marginRightText
)
697 m_marginRightText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().x
));
698 if (m_marginBottomText
)
699 m_marginBottomText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().y
));
701 if (m_orientationRadioBox
)
703 if (m_pageData
.GetPrintData().GetOrientation() == wxPORTRAIT
)
704 m_orientationRadioBox
->SetSelection(0);
706 m_orientationRadioBox
->SetSelection(1);
709 // Find the paper type from either the current paper size in the wxPageSetupDialogData, or
710 // failing that, the id in the wxPrintData object.
712 wxPrintPaperType
* type
= wxThePrintPaperDatabase
->FindPaperType(
713 wxSize(m_pageData
.GetPaperSize().x
* 10, m_pageData
.GetPaperSize().y
* 10));
715 if (!type
&& m_pageData
.GetPrintData().GetPaperId() != wxPAPER_NONE
)
716 type
= wxThePrintPaperDatabase
->FindPaperType(m_pageData
.GetPrintData().GetPaperId());
720 m_paperTypeChoice
->SetStringSelection(type
->GetName());
726 bool wxGenericPageSetupDialog::TransferDataFromWindow()
728 if (m_marginLeftText
&& m_marginTopText
)
730 int left
= wxAtoi( m_marginLeftText
->GetValue().c_str() );
731 int top
= wxAtoi( m_marginTopText
->GetValue().c_str() );
732 m_pageData
.SetMarginTopLeft( wxPoint(left
,top
) );
734 if (m_marginRightText
&& m_marginBottomText
)
736 int right
= wxAtoi( m_marginRightText
->GetValue().c_str() );
737 int bottom
= wxAtoi( m_marginBottomText
->GetValue().c_str() );
738 m_pageData
.SetMarginBottomRight( wxPoint(right
,bottom
) );
741 if (m_orientationRadioBox
)
743 int sel
= m_orientationRadioBox
->GetSelection();
746 m_pageData
.GetPrintData().SetOrientation(wxPORTRAIT
);
750 m_pageData
.GetPrintData().SetOrientation(wxLANDSCAPE
);
754 if (m_paperTypeChoice
)
756 wxString
val(m_paperTypeChoice
->GetStringSelection());
759 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(val
);
762 m_pageData
.SetPaperSize(wxSize(paper
->GetWidth()/10, paper
->GetHeight()/10));
763 m_pageData
.GetPrintData().SetPaperId(paper
->GetId());
771 wxComboBox
*wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
774 if (!wxThePrintPaperDatabase)
776 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
777 wxThePrintPaperDatabase->CreateDatabase();
781 int n
= wxThePrintPaperDatabase
->Number();
782 wxString
*choices
= new wxString
[n
];
784 for (i
= 0; i
< n
; i
++)
786 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
787 choices
[i
] = paper
->GetName();
790 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(*x
, *y
));
793 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
795 wxPoint(*x
, *y
), wxSize(300, -1), n
,
800 // choice->SetSelection(sel);