1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Generic print dialogs
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "prntdlgg.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #if wxUSE_PRINTING_ARCHITECTURE
40 #include "wx/stattext.h"
41 #include "wx/statbox.h"
42 #include "wx/button.h"
43 #include "wx/checkbox.h"
44 #include "wx/textctrl.h"
45 #include "wx/radiobox.h"
46 #include "wx/filedlg.h"
47 #include "wx/choice.h"
48 #include "wx/combobox.h"
54 #include "wx/statline.h"
57 #include "wx/generic/prntdlgg.h"
60 #include "wx/generic/dcpsg.h"
63 #include "wx/printdlg.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
)
89 IMPLEMENT_CLASS(wxGenericPageSetupDialog
, wxDialog
)
91 BEGIN_EVENT_TABLE(wxGenericPageSetupDialog
, wxDialog
)
92 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPageSetupDialog::OnPrinter
)
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
99 extern wxPrintPaperDatabase
*wxThePrintPaperDatabase
;
103 // ============================================================================
105 // ============================================================================
107 // ----------------------------------------------------------------------------
108 // Generic print dialog for non-Windows printing use.
109 // ----------------------------------------------------------------------------
111 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
112 wxPrintDialogData
* data
)
113 : wxDialog(parent
, -1, _("Print"),
114 wxPoint(0, 0), wxSize(600, 600),
115 wxDEFAULT_DIALOG_STYLE
|
120 m_printDialogData
= *data
;
125 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
127 : wxDialog(parent
, -1, _("Print"),
128 wxPoint(0, 0), wxSize(600, 600),
129 wxDEFAULT_DIALOG_STYLE
|
134 m_printDialogData
= *data
;
139 void wxGenericPrintDialog::Init(wxWindow
* WXUNUSED(parent
))
141 // wxDialog::Create(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600),
142 // wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL | wxTAB_TRAVERSAL);
144 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
148 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
149 new wxStaticBox( this, -1, _( "Printer options" ) ), wxHORIZONTAL
);
150 m_printToFileCheckBox
= new wxCheckBox( this, wxPRINTID_PRINTTOFILE
, _("Print to File") );
151 topsizer
->Add( m_printToFileCheckBox
, 0, wxCENTER
|wxALL
, 5 );
153 topsizer
->Add( 60,2,1 );
155 m_setupButton
= new wxButton(this, wxPRINTID_SETUP
, _("Setup...") );
156 topsizer
->Add( m_setupButton
, 0, wxCENTER
|wxALL
, 5 );
158 mainsizer
->Add( topsizer
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
160 // 2) middle row with radio box
162 wxString
*choices
= new wxString
[2];
163 choices
[0] = _("All");
164 choices
[1] = _("Pages");
166 m_fromText
= (wxTextCtrl
*)NULL
;
167 m_toText
= (wxTextCtrl
*)NULL
;
168 m_rangeRadioBox
= (wxRadioBox
*)NULL
;
170 if (m_printDialogData
.GetFromPage() != 0)
172 m_rangeRadioBox
= new wxRadioBox(this, wxPRINTID_RANGE
, _("Print Range"),
173 wxDefaultPosition
, wxDefaultSize
,
176 m_rangeRadioBox
->SetSelection(1);
178 mainsizer
->Add( m_rangeRadioBox
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
183 wxBoxSizer
*bottomsizer
= new wxBoxSizer( wxHORIZONTAL
);
185 if (m_printDialogData
.GetFromPage() != 0)
187 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("From:") ), 0, wxCENTER
|wxALL
, 5 );
188 m_fromText
= new wxTextCtrl(this, wxPRINTID_FROM
, "", wxDefaultPosition
, wxSize(40, -1));
189 bottomsizer
->Add( m_fromText
, 1, wxCENTER
|wxRIGHT
, 10 );
191 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("To:") ), 0, wxCENTER
|wxALL
, 5);
192 m_toText
= new wxTextCtrl(this, wxPRINTID_TO
, "", wxDefaultPosition
, wxSize(40, -1));
193 bottomsizer
->Add( m_toText
, 1, wxCENTER
|wxRIGHT
, 10 );
196 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Copies:") ), 0, wxCENTER
|wxALL
, 5 );
197 m_noCopiesText
= new wxTextCtrl(this, wxPRINTID_COPIES
, "", wxPoint(252, 130), wxSize(40, -1));
198 bottomsizer
->Add( m_noCopiesText
, 1, wxCENTER
|wxRIGHT
, 10 );
200 mainsizer
->Add( bottomsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 12 );
204 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
209 mainsizer
->Add( CreateButtonSizer( wxOK
|wxCANCEL
), 0, wxCENTER
|wxALL
, 10 );
211 SetAutoLayout( TRUE
);
212 SetSizer( mainsizer
);
214 mainsizer
->Fit( this );
217 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
222 int wxGenericPrintDialog::ShowModal()
224 if ( m_printDialogData
.GetSetupDialog() )
226 // Make sure wxPrintData object reflects the settings now, in case the setup dialog
227 // changes it. In fact there aren't any common settings at
228 // present, but there might be in future.
229 // TransferDataFromWindow();
231 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
232 new wxGenericPrintSetupDialog(this, & m_printDialogData
.GetPrintData());
233 int ret
= genericPrintSetupDialog
->ShowModal();
234 if ( ret
!= wxID_CANCEL
)
236 // Transfer settings to the global object (for compatibility) and to
237 // the print dialog's print data.
238 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
239 m_printDialogData
.GetPrintData() = genericPrintSetupDialog
->GetPrintData();
241 genericPrintSetupDialog
->Destroy();
243 // Restore the wxPrintData settings again (uncomment if any settings become common
245 // TransferDataToWindow();
251 return wxDialog::ShowModal();
255 wxGenericPrintDialog::~wxGenericPrintDialog()
259 void wxGenericPrintDialog::OnOK(wxCommandEvent
& WXUNUSED(event
))
261 TransferDataFromWindow();
263 // There are some interactions between the global setup data
264 // and the standard print dialog. The global printing 'mode'
265 // is determined by whether the user checks Print to file
267 if (m_printDialogData
.GetPrintToFile())
269 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE
);
270 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_FILE
);
272 wxString f
= wxFileSelector(_("PostScript file"),
273 wxPathOnly(wxThePrintSetupData
->GetPrinterFile()),
274 wxFileNameFromPath(wxThePrintSetupData
->GetPrinterFile()),
275 wxT("ps"), wxT("*.ps"), 0, this);
279 m_printDialogData
.GetPrintData().SetFilename(f
);
280 wxThePrintSetupData
->SetPrinterFile(f
);
284 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER
);
285 wxThePrintSetupData
->SetPrinterMode(wxPRINT_MODE_PRINTER
);
291 void wxGenericPrintDialog::OnRange(wxCommandEvent
& event
)
293 if (!m_fromText
) return;
295 if (event
.GetInt() == 0)
297 m_fromText
->Enable(FALSE
);
298 m_toText
->Enable(FALSE
);
300 else if (event
.GetInt() == 1)
302 m_fromText
->Enable(TRUE
);
303 m_toText
->Enable(TRUE
);
307 void wxGenericPrintDialog::OnSetup(wxCommandEvent
& WXUNUSED(event
))
309 *wxThePrintSetupData
= m_printDialogData
.GetPrintData();
310 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
311 new wxGenericPrintSetupDialog(this, wxThePrintSetupData
);
312 int ret
= genericPrintSetupDialog
->ShowModal();
313 if ( ret
!= wxID_CANCEL
)
315 *wxThePrintSetupData
= genericPrintSetupDialog
->GetPrintData();
316 m_printDialogData
= genericPrintSetupDialog
->GetPrintData();
319 genericPrintSetupDialog
->Close(TRUE
);
322 bool wxGenericPrintDialog::TransferDataToWindow()
326 if(m_printDialogData
.GetFromPage() != 0)
330 if (m_printDialogData
.GetEnablePageNumbers())
332 m_fromText
->Enable(TRUE
);
333 m_toText
->Enable(TRUE
);
334 sprintf(buf
, "%d", m_printDialogData
.GetFromPage());
335 m_fromText
->SetValue(buf
);
336 sprintf(buf
, "%d", m_printDialogData
.GetToPage());
337 m_toText
->SetValue(buf
);
339 if (m_printDialogData
.GetAllPages())
340 m_rangeRadioBox
->SetSelection(0);
342 m_rangeRadioBox
->SetSelection(1);
346 m_fromText
->Enable(FALSE
);
347 m_toText
->Enable(FALSE
);
350 m_rangeRadioBox
->SetSelection(0);
351 m_rangeRadioBox
->wxRadioBox::Enable(1, FALSE
);
356 sprintf(buf
, "%d", m_printDialogData
.GetNoCopies());
357 m_noCopiesText
->SetValue(buf
);
359 m_printToFileCheckBox
->SetValue(m_printDialogData
.GetPrintToFile());
360 m_printToFileCheckBox
->Enable(m_printDialogData
.GetEnablePrintToFile());
364 bool wxGenericPrintDialog::TransferDataFromWindow()
366 if(m_printDialogData
.GetFromPage() != -1)
368 if (m_printDialogData
.GetEnablePageNumbers())
370 if(m_fromText
) m_printDialogData
.SetFromPage(wxAtoi(m_fromText
->GetValue()));
371 if(m_toText
) m_printDialogData
.SetToPage(wxAtoi(m_toText
->GetValue()));
375 if (m_rangeRadioBox
->GetSelection() == 0)
376 m_printDialogData
.SetAllPages(TRUE
);
378 m_printDialogData
.SetAllPages(FALSE
);
382 { // continuous printing
383 m_printDialogData
.SetFromPage(1);
384 m_printDialogData
.SetToPage(32000);
386 m_printDialogData
.SetNoCopies(wxAtoi(m_noCopiesText
->GetValue()));
387 m_printDialogData
.SetPrintToFile(m_printToFileCheckBox
->GetValue());
393 TODO: collate and noCopies should be duplicated across dialog data and print data objects
394 (slightly different semantics on Windows but let's ignore this for a bit).
397 wxDC
*wxGenericPrintDialog::GetPrintDC()
399 // return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
400 return new wxPostScriptDC(GetPrintDialogData().GetPrintData());
403 // ----------------------------------------------------------------------------
404 // Generic print setup dialog
405 // ----------------------------------------------------------------------------
407 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintData
* data
):
408 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
413 // Convert wxPrintSetupData to standard wxPrintData object
414 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintSetupData
* data
):
415 wxDialog(parent
, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
|wxTAB_TRAVERSAL
)
417 wxPrintData printData
;
421 printData
= * wxThePrintSetupData
;
426 void wxGenericPrintSetupDialog::Init(wxPrintData
* data
)
431 int staticBoxWidth
= 300;
433 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth
, 60) );
437 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
439 wxString
*choices
= new wxString
[2];
440 choices
[0] = _("Portrait");
441 choices
[1] = _("Landscape");
443 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
444 wxPoint(10, 80), wxSize(-1, -1), 2, choices
, 1, wxRA_VERTICAL
);
445 m_orientationRadioBox
->SetSelection(0);
447 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth
, 50) );
449 int colourYPos
= 145;
455 m_colourCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTCOLOUR
, _("Print in colour"), wxPoint(15, colourYPos
));
457 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
459 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer command:"), wxPoint(340, 30));
461 m_printerCommandText
= new wxTextCtrl(this, wxPRINTID_COMMAND
, "", wxPoint(360, 55), wxSize(150, -1));
463 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer options:"), wxPoint(340, 110));
465 m_printerOptionsText
= new wxTextCtrl(this, wxPRINTID_OPTIONS
, "", wxPoint(360, 135), wxSize(150, -1));
467 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(130, 200), wxSize(80, -1));
468 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(320, 200), wxSize(80, -1));
470 okButton
->SetDefault();
471 okButton
->SetFocus();
480 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog()
484 bool wxGenericPrintSetupDialog::TransferDataToWindow()
486 if (m_printerCommandText
&& m_printData
.GetPrinterCommand())
487 m_printerCommandText
->SetValue(m_printData
.GetPrinterCommand());
488 if (m_printerOptionsText
&& m_printData
.GetPrinterOptions())
489 m_printerOptionsText
->SetValue(m_printData
.GetPrinterOptions());
490 if (m_colourCheckBox
)
491 m_colourCheckBox
->SetValue(m_printData
.GetColour());
493 if (m_orientationRadioBox
)
495 if (m_printData
.GetOrientation() == wxPORTRAIT
)
496 m_orientationRadioBox
->SetSelection(0);
498 m_orientationRadioBox
->SetSelection(1);
503 bool wxGenericPrintSetupDialog::TransferDataFromWindow()
505 if (m_printerCommandText
)
506 m_printData
.SetPrinterCommand(m_printerCommandText
->GetValue());
507 if (m_printerOptionsText
)
508 m_printData
.SetPrinterOptions(m_printerOptionsText
->GetValue());
509 if (m_colourCheckBox
)
510 m_printData
.SetColour(m_colourCheckBox
->GetValue());
511 if (m_orientationRadioBox
)
513 int sel
= m_orientationRadioBox
->GetSelection();
515 m_printData
.SetOrientation(wxPORTRAIT
);
517 m_printData
.SetOrientation(wxLANDSCAPE
);
519 if (m_paperTypeChoice
)
521 wxString
val(m_paperTypeChoice
->GetStringSelection());
522 if (!val
.IsNull() && val
!= "")
523 m_printData
.SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(val
));
526 // This is for backward compatibility only
527 *wxThePrintSetupData
= GetPrintData();
531 wxComboBox
*wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
533 /* Should not be necessary
534 if (!wxThePrintPaperDatabase)
536 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
537 wxThePrintPaperDatabase->CreateDatabase();
540 int n
= wxThePrintPaperDatabase
->Number();
541 wxString
*choices
= new wxString
[n
];
544 for (i
= 0; i
< n
; i
++)
546 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
547 choices
[i
] = paper
->GetName();
548 if (m_printData
.GetPaperId() == paper
->GetId())
554 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
556 wxPoint(*x
, *y
), wxSize(width
, -1), n
,
559 // SetFont(thisFont);
563 choice
->SetSelection(sel
);
566 #endif // wxUSE_POSTSCRIPT
568 // ----------------------------------------------------------------------------
569 // Generic page setup dialog
570 // ----------------------------------------------------------------------------
572 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent
& WXUNUSED(event
))
574 // We no longer query GetPrintMode, so we can eliminate the need
575 // to call SetPrintMode.
576 // This has the limitation that we can't explicitly call the PostScript
577 // print setup dialog from the generic Page Setup dialog under Windows,
578 // but since this choice would only happen when trying to do PostScript
579 // printing under Windows (and only in 16-bit Windows which
580 // doesn't have a Windows-specific page setup dialog) it's worth it.
582 // First save the current settings, so the wxPrintData object is up to date.
583 TransferDataFromWindow();
585 // Transfer the current print settings from this dialog to the page setup dialog.
586 wxPrintDialogData data
;
587 data
= GetPageSetupData().GetPrintData();
588 data
.SetSetupDialog(TRUE
);
589 wxPrintDialog
*printDialog
= new wxPrintDialog(this, & data
);
590 printDialog
->ShowModal();
592 // Transfer the page setup print settings from the page dialog to this dialog again, in case
593 // the page setup dialog changed something.
594 GetPageSetupData().GetPrintData() = printDialog
->GetPrintDialogData().GetPrintData();
595 GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData
597 printDialog
->Destroy();
599 // Now update the dialog in case the page setup dialog changed some of our settings.
600 TransferDataToWindow();
603 wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow
*parent
, wxPageSetupData
* data
):
604 wxDialog(parent
, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL
|wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
611 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
614 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
615 new wxStaticBox(this,wxPRINTID_STATIC
, _("Paper size")), wxHORIZONTAL
);
617 int n
= wxThePrintPaperDatabase
->Number();
618 wxString
*choices
= new wxString
[n
];
620 for (i
= 0; i
< n
; i
++)
622 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
623 choices
[i
] = paper
->GetName();
626 m_paperTypeChoice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
, _("Paper Size"),
627 wxDefaultPosition
, wxSize(300, -1), n
, choices
);
628 topsizer
->Add( m_paperTypeChoice
, 1, wxEXPAND
|wxALL
, 5 );
629 // m_paperTypeChoice->SetSelection(sel);
631 mainsizer
->Add( topsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
| wxEXPAND
, 10 );
633 // 2) middle sizer with radio box
635 wxString
*choices2
= new wxString
[2];
636 choices2
[0] = _("Portrait");
637 choices2
[1] = _("Landscape");
638 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
639 wxDefaultPosition
, wxDefaultSize
, 2, choices2
, 2);
640 m_orientationRadioBox
->SetSelection(0);
642 mainsizer
->Add( m_orientationRadioBox
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 10 );
646 wxBoxSizer
*table
= new wxBoxSizer( wxHORIZONTAL
);
648 wxBoxSizer
*column1
= new wxBoxSizer( wxVERTICAL
);
649 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Left margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
650 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Top margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
651 table
->Add( column1
, 0, wxALL
| wxEXPAND
, 5 );
653 wxBoxSizer
*column2
= new wxBoxSizer( wxVERTICAL
);
654 m_marginLeftText
= new wxTextCtrl(this, wxPRINTID_LEFTMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
655 m_marginTopText
= new wxTextCtrl(this, wxPRINTID_TOPMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
656 column2
->Add( m_marginLeftText
, 1, wxALL
, 5 );
657 column2
->Add( m_marginTopText
, 1, wxALL
, 5 );
658 table
->Add( column2
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
660 wxBoxSizer
*column3
= new wxBoxSizer( wxVERTICAL
);
661 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Right margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
662 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Bottom margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
663 table
->Add( column3
, 0, wxALL
| wxEXPAND
, 5 );
665 wxBoxSizer
*column4
= new wxBoxSizer( wxVERTICAL
);
666 m_marginRightText
= new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
667 m_marginBottomText
= new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN
, "", wxDefaultPosition
, wxSize(textWidth
, -1));
668 column4
->Add( m_marginRightText
, 1, wxALL
, 5 );
669 column4
->Add( m_marginBottomText
, 1, wxALL
, 5 );
670 table
->Add( column4
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
672 mainsizer
->Add( table
, 0 );
676 mainsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
681 wxSizer
* buttonsizer
= CreateButtonSizer( wxOK
|wxCANCEL
);
682 m_printerButton
= new wxButton(this, wxPRINTID_SETUP
, _("Printer...") );
683 buttonsizer
->Add( m_printerButton
, 0, wxLEFT
|wxRIGHT
, 10 );
684 if ( !m_pageData
.GetEnablePrinter() )
685 m_printerButton
->Enable(FALSE
);
686 // if (m_printData.GetEnableHelp())
687 // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
688 mainsizer
->Add( buttonsizer
, 0, wxCENTER
|wxALL
, 10 );
691 SetAutoLayout( TRUE
);
692 SetSizer( mainsizer
);
694 mainsizer
->Fit( this );
703 wxGenericPageSetupDialog::~wxGenericPageSetupDialog()
707 bool wxGenericPageSetupDialog::TransferDataToWindow()
709 if (m_marginLeftText
)
710 m_marginLeftText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().x
));
712 m_marginTopText
->SetValue(IntToString((int) m_pageData
.GetMarginTopLeft().y
));
713 if (m_marginRightText
)
714 m_marginRightText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().x
));
715 if (m_marginBottomText
)
716 m_marginBottomText
->SetValue(IntToString((int) m_pageData
.GetMarginBottomRight().y
));
718 if (m_orientationRadioBox
)
720 if (m_pageData
.GetPrintData().GetOrientation() == wxPORTRAIT
)
721 m_orientationRadioBox
->SetSelection(0);
723 m_orientationRadioBox
->SetSelection(1);
726 // Find the paper type from either the current paper size in the wxPageSetupDialogData, or
727 // failing that, the id in the wxPrintData object.
729 wxPrintPaperType
* type
= wxThePrintPaperDatabase
->FindPaperType(
730 wxSize(m_pageData
.GetPaperSize().x
* 10, m_pageData
.GetPaperSize().y
* 10));
732 if (!type
&& m_pageData
.GetPrintData().GetPaperId() != wxPAPER_NONE
)
733 type
= wxThePrintPaperDatabase
->FindPaperType(m_pageData
.GetPrintData().GetPaperId());
737 m_paperTypeChoice
->SetStringSelection(type
->GetName());
743 bool wxGenericPageSetupDialog::TransferDataFromWindow()
745 if (m_marginLeftText
&& m_marginTopText
)
746 m_pageData
.SetMarginTopLeft(wxPoint(wxAtoi((const wxChar
*)m_marginLeftText
->GetValue()),wxAtoi((const wxChar
*)m_marginTopText
->GetValue())));
747 if (m_marginRightText
&& m_marginBottomText
)
748 m_pageData
.SetMarginBottomRight(wxPoint(wxAtoi((const wxChar
*)m_marginRightText
->GetValue()),wxAtoi((const wxChar
*)m_marginBottomText
->GetValue())));
750 if (m_orientationRadioBox
)
752 int sel
= m_orientationRadioBox
->GetSelection();
756 wxThePrintSetupData
->SetPrinterOrientation(wxPORTRAIT
);
758 m_pageData
.GetPrintData().SetOrientation(wxPORTRAIT
);
763 wxThePrintSetupData
->SetPrinterOrientation(wxLANDSCAPE
);
765 m_pageData
.GetPrintData().SetOrientation(wxLANDSCAPE
);
768 if (m_paperTypeChoice
)
770 wxString
val(m_paperTypeChoice
->GetStringSelection());
771 if (!val
.IsNull() && val
!= "")
773 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(val
);
776 m_pageData
.SetPaperSize(wxSize(paper
->GetWidth()/10, paper
->GetHeight()/10));
777 m_pageData
.GetPrintData().SetPaperId(paper
->GetId());
785 wxComboBox
*wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
788 if (!wxThePrintPaperDatabase)
790 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
791 wxThePrintPaperDatabase->CreateDatabase();
795 int n
= wxThePrintPaperDatabase
->Number();
796 wxString
*choices
= new wxString
[n
];
798 for (i
= 0; i
< n
; i
++)
800 wxPrintPaperType
*paper
= (wxPrintPaperType
*)wxThePrintPaperDatabase
->Nth(i
)->Data();
801 choices
[i
] = paper
->GetName();
804 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(*x
, *y
));
807 wxComboBox
*choice
= new wxComboBox(this, wxPRINTID_PAPERSIZE
,
809 wxPoint(*x
, *y
), wxSize(300, -1), n
,
814 // choice->SetSelection(sel);