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
)
86 #endif // wxUSE_POSTSCRIPT
88 IMPLEMENT_CLASS(wxGenericPageSetupDialog
, wxDialog
)
90 BEGIN_EVENT_TABLE(wxGenericPageSetupDialog
, wxDialog
)
91 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPageSetupDialog::OnPrinter
)
94 // ----------------------------------------------------------------------------
96 // ----------------------------------------------------------------------------
98 extern wxPrintPaperDatabase
*wxThePrintPaperDatabase
;
102 // ============================================================================
104 // ============================================================================
106 // ----------------------------------------------------------------------------
107 // Generic print dialog for non-Windows printing use.
108 // ----------------------------------------------------------------------------
110 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
111 wxPrintDialogData
* data
)
112 : wxDialog(parent
, -1, _("Print"),
113 wxPoint(0, 0), wxSize(600, 600),
114 wxDEFAULT_DIALOG_STYLE
|
119 m_printDialogData
= *data
;
124 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
126 : wxDialog(parent
, -1, _("Print"),
127 wxPoint(0, 0), wxSize(600, 600),
128 wxDEFAULT_DIALOG_STYLE
|
133 m_printDialogData
= *data
;
138 void wxGenericPrintDialog::Init(wxWindow
* WXUNUSED(parent
))
140 // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
141 // wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
143 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
147 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
148 new wxStaticBox( this, -1, _( "Printer options" ) ), wxHORIZONTAL
);
149 m_printToFileCheckBox
= new wxCheckBox( this, wxPRINTID_PRINTTOFILE
, _("Print to File") );
150 topsizer
->Add( m_printToFileCheckBox
, 0, wxCENTER
|wxALL
, 5 );
152 topsizer
->Add( 60,2,1 );
154 m_setupButton
= new wxButton(this, wxPRINTID_SETUP
, _("Setup...") );
155 topsizer
->Add( m_setupButton
, 0, wxCENTER
|wxALL
, 5 );
157 mainsizer
->Add( topsizer
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
159 // 2) middle row with radio box
161 wxString
*choices
= new wxString
[2];
162 choices
[0] = _("All");
163 choices
[1] = _("Pages");
165 m_fromText
= (wxTextCtrl
*)NULL
;
166 m_toText
= (wxTextCtrl
*)NULL
;
167 m_rangeRadioBox
= (wxRadioBox
*)NULL
;
169 if (m_printDialogData
.GetFromPage() != 0)
171 m_rangeRadioBox
= new wxRadioBox(this, wxPRINTID_RANGE
, _("Print Range"),
172 wxDefaultPosition
, wxDefaultSize
,
175 m_rangeRadioBox
->SetSelection(1);
177 mainsizer
->Add( m_rangeRadioBox
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
182 wxBoxSizer
*bottomsizer
= new wxBoxSizer( wxHORIZONTAL
);
184 if (m_printDialogData
.GetFromPage() != 0)
186 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("From:") ), 0, wxCENTER
|wxALL
, 5 );
187 m_fromText
= new wxTextCtrl(this, wxPRINTID_FROM
, "", wxDefaultPosition
, wxSize(40, -1));
188 bottomsizer
->Add( m_fromText
, 1, wxCENTER
|wxRIGHT
, 10 );
190 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("To:") ), 0, wxCENTER
|wxALL
, 5);
191 m_toText
= new wxTextCtrl(this, wxPRINTID_TO
, "", wxDefaultPosition
, wxSize(40, -1));
192 bottomsizer
->Add( m_toText
, 1, wxCENTER
|wxRIGHT
, 10 );
195 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Copies:") ), 0, wxCENTER
|wxALL
, 5 );
196 m_noCopiesText
= new wxTextCtrl(this, wxPRINTID_COPIES
, "", wxPoint(252, 130), wxSize(40, -1));
197 bottomsizer
->Add( m_noCopiesText
, 1, wxCENTER
|wxRIGHT
, 10 );
199 mainsizer
->Add( bottomsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 12 );
203 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
208 mainsizer
->Add( CreateButtonSizer( wxOK
|wxCANCEL
), 0, wxCENTER
|wxALL
, 10 );
210 SetAutoLayout( TRUE
);
211 SetSizer( mainsizer
);
213 mainsizer
->Fit( this );
216 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
221 int wxGenericPrintDialog::ShowModal()
223 if ( m_printDialogData
.GetSetupDialog() )
225 // Make sure wxPrintData object reflects the settings now, in case the setup dialog
226 // changes it. In fact there aren't any common settings at
227 // present, but there might be in future.
228 // TransferDataFromWindow();
230 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
231 new wxGenericPrintSetupDialog(this, & m_printDialogData
.GetPrintData());
232 int ret
= genericPrintSetupDialog
->ShowModal();
233 if ( ret
!= wxID_CANCEL
)
235 // Transfer settings to the global object (for compatibility) and to
236 // the print dialog's print data.
237 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
238 m_printDialogData
.GetPrintData() = genericPrintSetupDialog
->GetPrintData();
240 genericPrintSetupDialog
->Destroy();
242 // Restore the wxPrintData settings again (uncomment if any settings become common
244 // TransferDataToWindow();
250 return wxDialog::ShowModal();
254 wxGenericPrintDialog::~wxGenericPrintDialog()
258 void wxGenericPrintDialog::OnOK(wxCommandEvent
& WXUNUSED(event
))
260 TransferDataFromWindow();
262 // There are some interactions between the global setup data
263 // and the standard print dialog. The global printing 'mode'
264 // is determined by whether the user checks Print to file
266 if (m_printDialogData
.GetPrintToFile())
268 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE
);
269 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_FILE
);
271 wxString f
= wxFileSelector(_("PostScript file"),
272 wxPathOnly(wxThePrintSetupData
->GetPrinterFile()),
273 wxFileNameFromPath(wxThePrintSetupData
->GetPrinterFile()),
274 wxT("ps"), wxT("*.ps"), 0, this);
278 m_printDialogData
.GetPrintData().SetFilename(f
);
279 wxThePrintSetupData
->SetPrinterFile(f
);
283 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER
);
284 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_PRINTER
);
290 void wxGenericPrintDialog::OnRange(wxCommandEvent
& event
)
292 if (!m_fromText
) return;
294 if (event
.GetInt() == 0)
296 m_fromText
->Enable(FALSE
);
297 m_toText
->Enable(FALSE
);
299 else if (event
.GetInt() == 1)
301 m_fromText
->Enable(TRUE
);
302 m_toText
->Enable(TRUE
);
306 void wxGenericPrintDialog::OnSetup(wxCommandEvent
& WXUNUSED(event
))
308 *wxThePrintSetupData
= m_printDialogData
.GetPrintData();
309 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
310 new wxGenericPrintSetupDialog(this, wxThePrintSetupData
);
311 int ret
= genericPrintSetupDialog
->ShowModal();
312 if ( ret
!= wxID_CANCEL
)
314 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
315 m_printDialogData
= genericPrintSetupDialog
->GetPrintData();
318 genericPrintSetupDialog
->Close(TRUE
);
321 bool wxGenericPrintDialog::TransferDataToWindow()
323 if(m_printDialogData
.GetFromPage() != 0)
327 if (m_printDialogData
.GetEnablePageNumbers())
329 m_fromText
->Enable(TRUE
);
330 m_toText
->Enable(TRUE
);
331 m_fromText
->SetValue(
332 wxString::Format(_T("%d"), m_printDialogData
.GetFromPage()));
334 wxString::Format(_T("%d"), m_printDialogData
.GetToPage()));
336 if (m_printDialogData
.GetAllPages())
337 m_rangeRadioBox
->SetSelection(0);
339 m_rangeRadioBox
->SetSelection(1);
343 m_fromText
->Enable(FALSE
);
344 m_toText
->Enable(FALSE
);
347 m_rangeRadioBox
->SetSelection(0);
348 m_rangeRadioBox
->wxRadioBox::Enable(1, FALSE
);
353 m_noCopiesText
->SetValue(
354 wxString::Format(_T("%d"), m_printDialogData
.GetNoCopies()));
356 m_printToFileCheckBox
->SetValue(m_printDialogData
.GetPrintToFile());
357 m_printToFileCheckBox
->Enable(m_printDialogData
.GetEnablePrintToFile());
361 bool wxGenericPrintDialog::TransferDataFromWindow()
364 if(m_printDialogData
.GetFromPage() != -1)
366 if (m_printDialogData
.GetEnablePageNumbers())
370 wxString value
= m_fromText
->GetValue();
371 if (value
.ToLong( &res
))
372 m_printDialogData
.SetFromPage( res
);
376 wxString value
= m_toText
->GetValue();
377 if (value
.ToLong( &res
))
378 m_printDialogData
.SetToPage( res
);
383 if (m_rangeRadioBox
->GetSelection() == 0)
384 m_printDialogData
.SetAllPages(TRUE
);
386 m_printDialogData
.SetAllPages(FALSE
);
390 { // continuous printing
391 m_printDialogData
.SetFromPage(1);
392 m_printDialogData
.SetToPage(32000);
395 wxString value
= m_noCopiesText
->GetValue();
396 if (value
.ToLong( &res
))
397 m_printDialogData
.SetNoCopies( res
);
399 m_printDialogData
.SetPrintToFile(m_printToFileCheckBox
->GetValue());
405 TODO: collate and noCopies should be duplicated across dialog data and print data objects
406 (slightly different semantics on Windows but let's ignore this for a bit).
409 wxDC
*wxGenericPrintDialog::GetPrintDC()
411 // return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
412 return new wxPostScriptDC(GetPrintDialogData().GetPrintData());
415 // ----------------------------------------------------------------------------
416 // Generic print setup dialog
417 // ----------------------------------------------------------------------------
419 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintData
* data
):
420 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
425 // Convert wxPrintSetupData to standard wxPrintData object
426 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintSetupData
* data
):
427 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
429 wxPrintData printData
;
433 printData
= * wxThePrintSetupData
;
438 void wxGenericPrintSetupDialog::Init(wxPrintData
* data
)
443 int staticBoxWidth
= 300;
445 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth
, 60) );
449 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
451 wxString
*choices
= new wxString
[2];
452 choices
[0] = _("Portrait");
453 choices
[1] = _("Landscape");
455 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
456 wxPoint(10, 80), wxSize(-1, -1), 2, choices
, 1, wxRA_VERTICAL
);
457 m_orientationRadioBox
->SetSelection(0);
459 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth
, 50) );
461 int colourYPos
= 145;
467 m_colourCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTCOLOUR
, _("Print in colour"), wxPoint(15, colourYPos
));
469 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
471 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer command:"), wxPoint(340, 30));
473 m_printerCommandText
= new wxTextCtrl(this, wxPRINTID_COMMAND
, "", wxPoint(360, 55), wxSize(150, -1));
475 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer options:"), wxPoint(340, 110));
477 m_printerOptionsText
= new wxTextCtrl(this, wxPRINTID_OPTIONS
, "", wxPoint(360, 135), wxSize(150, -1));
479 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(130, 200), wxSize(80, -1));
480 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(320, 200), wxSize(80, -1));
482 okButton
->SetDefault();
483 okButton
->SetFocus();
492 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog()
496 bool wxGenericPrintSetupDialog::TransferDataToWindow()
498 if (m_printerCommandText
&& m_printData
.GetPrinterCommand())
499 m_printerCommandText
->SetValue(m_printData
.GetPrinterCommand());
500 if (m_printerOptionsText
&& m_printData
.GetPrinterOptions())
501 m_printerOptionsText
->SetValue(m_printData
.GetPrinterOptions());
502 if (m_colourCheckBox
)
503 m_colourCheckBox
->SetValue(m_printData
.GetColour());
505 if (m_orientationRadioBox
)
507 if (m_printData
.GetOrientation() == wxPORTRAIT
)
508 m_orientationRadioBox
->SetSelection(0);
510 m_orientationRadioBox
->SetSelection(1);
515 bool wxGenericPrintSetupDialog::TransferDataFromWindow()
517 if (m_printerCommandText
)
518 m_printData
.SetPrinterCommand(m_printerCommandText
->GetValue());
519 if (m_printerOptionsText
)
520 m_printData
.SetPrinterOptions(m_printerOptionsText
->GetValue());
521 if (m_colourCheckBox
)
522 m_printData
.SetColour(m_colourCheckBox
->GetValue());
523 if (m_orientationRadioBox
)
525 int sel
= m_orientationRadioBox
->GetSelection();
527 m_printData
.SetOrientation(wxPORTRAIT
);
529 m_printData
.SetOrientation(wxLANDSCAPE
);
531 if (m_paperTypeChoice
)
533 wxString
val(m_paperTypeChoice
->GetStringSelection());
534 if (!val
.IsNull() && val
!= "")
535 m_printData
.SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(val
));
538 // This is for backward compatibility only
539 *wxThePrintSetupData
= GetPrintData();
543 wxComboBox
*wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
545 /* Should not be necessary
546 if (!wxThePrintPaperDatabase)
548 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
549 wxThePrintPaperDatabase->CreateDatabase();
552 int n
= wxThePrintPaperDatabase
->Number();
553 wxString
*choices
= new wxString
[n
];
556 for (i
= 0; i
< n
; i
++)
558 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
559 choices
[i
] = paper
->GetName();
560 if (m_printData
.GetPaperId() == paper
->GetId())
566 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
568 wxPoint(*x
, *y
), wxSize(width
, -1), n
,
571 // SetFont(thisFont);
575 choice
->SetSelection(sel
);
578 #endif // wxUSE_POSTSCRIPT
580 // ----------------------------------------------------------------------------
581 // Generic page setup dialog
582 // ----------------------------------------------------------------------------
584 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent
& WXUNUSED(event
))
586 // We no longer query GetPrintMode, so we can eliminate the need
587 // to call SetPrintMode.
588 // This has the limitation that we can't explicitly call the PostScript
589 // print setup dialog from the generic Page Setup dialog under Windows,
590 // but since this choice would only happen when trying to do PostScript
591 // printing under Windows (and only in 16-bit Windows which
592 // doesn't have a Windows-specific page setup dialog) it's worth it.
594 // First save the current settings, so the wxPrintData object is up to date.
595 TransferDataFromWindow();
597 // Transfer the current print settings from this dialog to the page setup dialog.
598 wxPrintDialogData data
;
599 data
= GetPageSetupData().GetPrintData();
600 data
.SetSetupDialog(TRUE
);
601 wxPrintDialog
*printDialog
= new wxPrintDialog(this, & data
);
602 printDialog
->ShowModal();
604 // Transfer the page setup print settings from the page dialog to this dialog again, in case
605 // the page setup dialog changed something.
606 GetPageSetupData().GetPrintData() = printDialog
->GetPrintDialogData().GetPrintData();
607 GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData
609 printDialog
->Destroy();
611 // Now update the dialog in case the page setup dialog changed some of our settings.
612 TransferDataToWindow();
615 wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow
*parent
, wxPageSetupData
* data
):
616 wxDialog(parent
, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL
|wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
623 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
626 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
627 new wxStaticBox(this,wxPRINTID_STATIC
, _("Paper size")), wxHORIZONTAL
);
629 int n
= wxThePrintPaperDatabase
->Number();
630 wxString
*choices
= new wxString
[n
];
632 for (i
= 0; i
< n
; i
++)
634 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
635 choices
[i
] = paper
->GetName();
638 m_paperTypeChoice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
, _("Paper Size"),
639 wxDefaultPosition
, wxSize(300, -1), n
, choices
);
640 topsizer
->Add( m_paperTypeChoice
, 1, wxEXPAND
|wxALL
, 5 );
641 // m_paperTypeChoice->SetSelection(sel);
643 mainsizer
->Add( topsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
| wxEXPAND
, 10 );
645 // 2) middle sizer with radio box
647 wxString
*choices2
= new wxString
[2];
648 choices2
[0] = _("Portrait");
649 choices2
[1] = _("Landscape");
650 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
651 wxDefaultPosition
, wxDefaultSize
, 2, choices2
, 2);
652 m_orientationRadioBox
->SetSelection(0);
654 mainsizer
->Add( m_orientationRadioBox
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 10 );
658 wxBoxSizer
*table
= new wxBoxSizer( wxHORIZONTAL
);
660 wxBoxSizer
*column1
= new wxBoxSizer( wxVERTICAL
);
661 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Left margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
662 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Top margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
663 table
->Add( column1
, 0, wxALL
| wxEXPAND
, 5 );
665 wxBoxSizer
*column2
= new wxBoxSizer( wxVERTICAL
);
666 m_marginLeftText
= new wxTextCtrl(this, wxPRINTID_LEFTMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
667 m_marginTopText
= new wxTextCtrl(this, wxPRINTID_TOPMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
668 column2
->Add( m_marginLeftText
, 1, wxALL
, 5 );
669 column2
->Add( m_marginTopText
, 1, wxALL
, 5 );
670 table
->Add( column2
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
672 wxBoxSizer
*column3
= new wxBoxSizer( wxVERTICAL
);
673 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Right margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
674 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Bottom margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
675 table
->Add( column3
, 0, wxALL
| wxEXPAND
, 5 );
677 wxBoxSizer
*column4
= new wxBoxSizer( wxVERTICAL
);
678 m_marginRightText
= new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
679 m_marginBottomText
= new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
680 column4
->Add( m_marginRightText
, 1, wxALL
, 5 );
681 column4
->Add( m_marginBottomText
, 1, wxALL
, 5 );
682 table
->Add( column4
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
684 mainsizer
->Add( table
, 0 );
688 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
693 wxSizer
* buttonsizer
= CreateButtonSizer( wxOK
|wxCANCEL
);
694 m_printerButton
= new wxButton(this, wxPRINTID_SETUP
, _("Printer...") );
695 buttonsizer
->Add( m_printerButton
, 0, wxLEFT
|wxRIGHT
, 10 );
696 if ( !m_pageData
.GetEnablePrinter() )
697 m_printerButton
->Enable(FALSE
);
698 // if (m_printData.GetEnableHelp())
699 // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
700 mainsizer
->Add( buttonsizer
, 0, wxCENTER
|wxALL
, 10 );
703 SetAutoLayout( TRUE
);
704 SetSizer( mainsizer
);
706 mainsizer
->Fit( this );
715 wxGenericPageSetupDialog::~wxGenericPageSetupDialog()
719 bool wxGenericPageSetupDialog::TransferDataToWindow()
721 if (m_marginLeftText
)
722 m_marginLeftText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().x
));
724 m_marginTopText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().y
));
725 if (m_marginRightText
)
726 m_marginRightText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().x
));
727 if (m_marginBottomText
)
728 m_marginBottomText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().y
));
730 if (m_orientationRadioBox
)
732 if (m_pageData
.GetPrintData().GetOrientation() == wxPORTRAIT
)
733 m_orientationRadioBox
->SetSelection(0);
735 m_orientationRadioBox
->SetSelection(1);
738 // Find the paper type from either the current paper size in the wxPageSetupDialogData, or
739 // failing that, the id in the wxPrintData object.
741 wxPrintPaperType
* type
= wxThePrintPaperDatabase
->FindPaperType(
742 wxSize(m_pageData
.GetPaperSize().x
* 10, m_pageData
.GetPaperSize().y
* 10));
744 if (!type
&& m_pageData
.GetPrintData().GetPaperId() != wxPAPER_NONE
)
745 type
= wxThePrintPaperDatabase
->FindPaperType(m_pageData
.GetPrintData().GetPaperId());
749 m_paperTypeChoice
->SetStringSelection(type
->GetName());
755 bool wxGenericPageSetupDialog::TransferDataFromWindow()
757 if (m_marginLeftText
&& m_marginTopText
)
758 m_pageData
.SetMarginTopLeft(wxPoint(wxAtoi((const wxChar
*)m_marginLeftText
->GetValue()),wxAtoi((const wxChar
*)m_marginTopText
->GetValue())));
759 if (m_marginRightText
&& m_marginBottomText
)
760 m_pageData
.SetMarginBottomRight(wxPoint(wxAtoi((const wxChar
*)m_marginRightText
->GetValue()),wxAtoi((const wxChar
*)m_marginBottomText
->GetValue())));
762 if (m_orientationRadioBox
)
764 int sel
= m_orientationRadioBox
->GetSelection();
768 wxThePrintSetupData
->SetPrinterOrientation(wxPORTRAIT
);
770 m_pageData
.GetPrintData().SetOrientation(wxPORTRAIT
);
775 wxThePrintSetupData
->SetPrinterOrientation(wxLANDSCAPE
);
777 m_pageData
.GetPrintData().SetOrientation(wxLANDSCAPE
);
780 if (m_paperTypeChoice
)
782 wxString
val(m_paperTypeChoice
->GetStringSelection());
783 if (!val
.IsNull() && val
!= "")
785 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(val
);
788 m_pageData
.SetPaperSize(wxSize(paper
->GetWidth()/10, paper
->GetHeight()/10));
789 m_pageData
.GetPrintData().SetPaperId(paper
->GetId());
797 wxComboBox
*wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
800 if (!wxThePrintPaperDatabase)
802 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
803 wxThePrintPaperDatabase->CreateDatabase();
807 int n
= wxThePrintPaperDatabase
->Number();
808 wxString
*choices
= new wxString
[n
];
810 for (i
= 0; i
< n
; i
++)
812 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
813 choices
[i
] = paper
->GetName();
816 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(*x
, *y
));
819 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
821 wxPoint(*x
, *y
), wxSize(300, -1), n
,
826 // choice->SetSelection(sel);