1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Generic print dialogs
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "prntdlgg.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
31 #if wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
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(wxGenericPrintSetupDialog
, wxDialog
)
78 #endif // wxUSE_POSTSCRIPT
80 IMPLEMENT_CLASS(wxGenericPageSetupDialog
, wxDialog
)
82 BEGIN_EVENT_TABLE(wxGenericPageSetupDialog
, wxDialog
)
83 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPageSetupDialog::OnPrinter
)
86 // ----------------------------------------------------------------------------
88 // ----------------------------------------------------------------------------
90 extern wxPrintPaperDatabase
*wxThePrintPaperDatabase
;
94 // ----------------------------------------------------------------------------
95 // Generic print dialog for non-Windows printing use.
96 // ----------------------------------------------------------------------------
98 IMPLEMENT_CLASS(wxGenericPrintDialog
, wxPrintDialogBase
)
100 BEGIN_EVENT_TABLE(wxGenericPrintDialog
, wxPrintDialogBase
)
101 EVT_BUTTON(wxID_OK
, wxGenericPrintDialog::OnOK
)
102 EVT_BUTTON(wxPRINTID_SETUP
, wxGenericPrintDialog::OnSetup
)
103 EVT_RADIOBOX(wxPRINTID_RANGE
, wxGenericPrintDialog::OnRange
)
106 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
107 wxPrintDialogData
* data
)
108 : wxPrintDialogBase(parent
, wxID_ANY
, _("Print"),
109 wxPoint(0, 0), wxSize(600, 600),
110 wxDEFAULT_DIALOG_STYLE
|
114 m_printDialogData
= *data
;
119 wxGenericPrintDialog::wxGenericPrintDialog(wxWindow
*parent
,
121 : wxPrintDialogBase(parent
, wxID_ANY
, _("Print"),
122 wxPoint(0, 0), wxSize(600, 600),
123 wxDEFAULT_DIALOG_STYLE
|
127 m_printDialogData
= *data
;
132 void wxGenericPrintDialog::Init(wxWindow
* WXUNUSED(parent
))
134 // wxDialog::Create(parent, wxID_ANY, _("Print"), wxPoint(0, 0), wxSize(600, 600),
135 // wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL);
137 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
141 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
142 new wxStaticBox( this, wxID_ANY
, _( "Printer options" ) ), wxHORIZONTAL
);
143 m_printToFileCheckBox
= new wxCheckBox( this, wxPRINTID_PRINTTOFILE
, _("Print to File") );
144 topsizer
->Add( m_printToFileCheckBox
, 0, wxCENTER
|wxALL
, 5 );
146 topsizer
->Add( 60,2,1 );
148 m_setupButton
= new wxButton(this, wxPRINTID_SETUP
, _("Setup...") );
149 topsizer
->Add( m_setupButton
, 0, wxCENTER
|wxALL
, 5 );
151 mainsizer
->Add( topsizer
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
153 // 2) middle row with radio box
155 wxString
*choices
= new wxString
[2];
156 choices
[0] = _("All");
157 choices
[1] = _("Pages");
159 m_fromText
= (wxTextCtrl
*)NULL
;
160 m_toText
= (wxTextCtrl
*)NULL
;
161 m_rangeRadioBox
= (wxRadioBox
*)NULL
;
163 if (m_printDialogData
.GetFromPage() != 0)
165 m_rangeRadioBox
= new wxRadioBox(this, wxPRINTID_RANGE
, _("Print Range"),
166 wxDefaultPosition
, wxDefaultSize
,
169 m_rangeRadioBox
->SetSelection(1);
171 mainsizer
->Add( m_rangeRadioBox
, 0, wxLEFT
|wxTOP
|wxRIGHT
, 10 );
176 wxBoxSizer
*bottomsizer
= new wxBoxSizer( wxHORIZONTAL
);
178 if (m_printDialogData
.GetFromPage() != 0)
180 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("From:") ), 0, wxCENTER
|wxALL
, 5 );
181 m_fromText
= new wxTextCtrl(this, wxPRINTID_FROM
, wxEmptyString
, wxDefaultPosition
, wxSize(40, wxDefaultCoord
));
182 bottomsizer
->Add( m_fromText
, 1, wxCENTER
|wxRIGHT
, 10 );
184 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("To:") ), 0, wxCENTER
|wxALL
, 5);
185 m_toText
= new wxTextCtrl(this, wxPRINTID_TO
, wxEmptyString
, wxDefaultPosition
, wxSize(40, wxDefaultCoord
));
186 bottomsizer
->Add( m_toText
, 1, wxCENTER
|wxRIGHT
, 10 );
189 bottomsizer
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Copies:") ), 0, wxCENTER
|wxALL
, 5 );
190 m_noCopiesText
= new wxTextCtrl(this, wxPRINTID_COPIES
, wxEmptyString
, wxPoint(252, 130), wxSize(40, wxDefaultCoord
));
191 bottomsizer
->Add( m_noCopiesText
, 1, wxCENTER
|wxRIGHT
, 10 );
193 mainsizer
->Add( bottomsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 12 );
197 mainsizer
->Add( new wxStaticLine( this, wxID_ANY
), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
202 mainsizer
->Add( CreateButtonSizer( wxOK
|wxCANCEL
), 0, wxCENTER
|wxALL
, 10 );
204 SetAutoLayout( true );
205 SetSizer( mainsizer
);
207 mainsizer
->Fit( this );
210 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
215 int wxGenericPrintDialog::ShowModal()
217 if ( m_printDialogData
.GetSetupDialog() )
219 // Make sure wxPrintData object reflects the settings now, in case the setup dialog
220 // changes it. In fact there aren't any common settings at
221 // present, but there might be in future.
222 // TransferDataFromWindow();
224 wxGenericPrintSetupDialog
*genericPrintSetupDialog
=
225 new wxGenericPrintSetupDialog(this, & m_printDialogData
.GetPrintData());
226 int ret
= genericPrintSetupDialog
->ShowModal();
227 if ( ret
!= wxID_CANCEL
)
229 // Transfer settings to the print dialog's print data.
230 m_printDialogData
.GetPrintData() = genericPrintSetupDialog
->GetPrintData();
232 // genericPrintSetupDialog->Destroy();
234 // Restore the wxPrintData settings again (uncomment if any settings become common
236 // TransferDataToWindow();
242 return wxDialog::ShowModal();
246 wxGenericPrintDialog::~wxGenericPrintDialog()
250 void wxGenericPrintDialog::OnOK(wxCommandEvent
& WXUNUSED(event
))
252 TransferDataFromWindow();
254 // An empty 'to' field signals printing just the
256 if (m_printDialogData
.GetToPage() < 1)
257 m_printDialogData
.SetToPage(m_printDialogData
.GetFromPage());
259 // There are some interactions between the global setup data
260 // and the standard print dialog. The global printing 'mode'
261 // is determined by whether the user checks Print to file
263 if (m_printDialogData
.GetPrintToFile())
265 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE
);
267 wxFileName
fname( m_printDialogData
.GetPrintData().GetFilename() );
269 wxFileDialog
dialog( this, _("PostScript file"),
270 fname
.GetPath(), fname
.GetFullName(), wxT("*.ps"), wxOPEN
| wxOVERWRITE_PROMPT
);
271 if (dialog
.ShowModal() != wxID_OK
) return;
273 m_printDialogData
.GetPrintData().SetFilename( dialog
.GetPath() );
277 m_printDialogData
.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER
);
283 void wxGenericPrintDialog::OnRange(wxCommandEvent
& event
)
285 if (!m_fromText
) return;
287 if (event
.GetInt() == 0)
289 m_fromText
->Enable(false);
290 m_toText
->Enable(false);
292 else if (event
.GetInt() == 1)
294 m_fromText
->Enable(true);
295 m_toText
->Enable(true);
299 void wxGenericPrintDialog::OnSetup(wxCommandEvent
& WXUNUSED(event
))
301 wxGenericPrintSetupDialog
dialog( this, &m_printDialogData
.GetPrintData() );
302 if (dialog
.ShowModal() != wxID_CANCEL
)
304 m_printDialogData
= dialog
.GetPrintData();
308 bool wxGenericPrintDialog::TransferDataToWindow()
310 if(m_printDialogData
.GetFromPage() != 0)
314 if (m_printDialogData
.GetEnablePageNumbers())
316 m_fromText
->Enable(true);
317 m_toText
->Enable(true);
318 if (m_printDialogData
.GetFromPage() > 0)
319 m_fromText
->SetValue(wxString::Format(_T("%d"), m_printDialogData
.GetFromPage()));
320 if (m_printDialogData
.GetToPage() > 0)
321 m_toText
->SetValue(wxString::Format(_T("%d"), m_printDialogData
.GetToPage()));
323 if (m_printDialogData
.GetAllPages() || m_printDialogData
.GetFromPage() == 0)
324 m_rangeRadioBox
->SetSelection(0);
326 m_rangeRadioBox
->SetSelection(1);
330 m_fromText
->Enable(false);
331 m_toText
->Enable(false);
334 m_rangeRadioBox
->SetSelection(0);
335 m_rangeRadioBox
->wxRadioBox::Enable(1, false);
340 m_noCopiesText
->SetValue(
341 wxString::Format(_T("%d"), m_printDialogData
.GetNoCopies()));
343 m_printToFileCheckBox
->SetValue(m_printDialogData
.GetPrintToFile());
344 m_printToFileCheckBox
->Enable(m_printDialogData
.GetEnablePrintToFile());
348 bool wxGenericPrintDialog::TransferDataFromWindow()
351 if(m_printDialogData
.GetFromPage() != -1)
353 if (m_printDialogData
.GetEnablePageNumbers())
357 wxString value
= m_fromText
->GetValue();
358 if (value
.ToLong( &res
))
359 m_printDialogData
.SetFromPage( res
);
363 wxString value
= m_toText
->GetValue();
364 if (value
.ToLong( &res
))
365 m_printDialogData
.SetToPage( res
);
370 if (m_rangeRadioBox
->GetSelection() == 0)
371 m_printDialogData
.SetAllPages(true);
373 m_printDialogData
.SetAllPages(false);
377 { // continuous printing
378 m_printDialogData
.SetFromPage(1);
379 m_printDialogData
.SetToPage(32000);
382 wxString value
= m_noCopiesText
->GetValue();
383 if (value
.ToLong( &res
))
384 m_printDialogData
.SetNoCopies( res
);
386 m_printDialogData
.SetPrintToFile(m_printToFileCheckBox
->GetValue());
392 TODO: collate and noCopies should be duplicated across dialog data and print data objects
393 (slightly different semantics on Windows but let's ignore this for a bit).
396 wxDC
*wxGenericPrintDialog::GetPrintDC()
398 // return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), false, (wxWindow *) NULL);
399 return new wxPostScriptDC(GetPrintDialogData().GetPrintData());
402 // ----------------------------------------------------------------------------
403 // Generic print setup dialog
404 // ----------------------------------------------------------------------------
406 wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow
*parent
, wxPrintData
* data
):
407 wxDialog(parent
, wxID_ANY
, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
412 void wxGenericPrintSetupDialog::Init(wxPrintData
* data
)
417 int staticBoxWidth
= 300;
419 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(10, 10), wxSize(staticBoxWidth
, 60) );
423 m_paperTypeChoice
= CreatePaperTypeChoice(&xPos
, &yPos
);
425 wxString
*choices
= new wxString
[2];
426 choices
[0] = _("Portrait");
427 choices
[1] = _("Landscape");
429 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
430 wxPoint(10, 80), wxDefaultSize
, 2, choices
, 1, wxRA_VERTICAL
);
431 m_orientationRadioBox
->SetSelection(0);
433 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Options"), wxPoint(10, 130), wxSize(staticBoxWidth
, 50) );
435 int colourYPos
= 145;
441 m_colourCheckBox
= new wxCheckBox(this, wxPRINTID_PRINTCOLOUR
, _("Print in colour"), wxPoint(15, colourYPos
));
443 (void) new wxStaticBox(this, wxPRINTID_STATIC
, _("Print spooling"), wxPoint(330, 10), wxSize(200,170) );
445 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer command:"), wxPoint(340, 30));
447 m_printerCommandText
= new wxTextCtrl(this, wxPRINTID_COMMAND
, wxEmptyString
, wxPoint(360, 55), wxSize(150, wxDefaultCoord
));
449 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Printer options:"), wxPoint(340, 110));
451 m_printerOptionsText
= new wxTextCtrl(this, wxPRINTID_OPTIONS
, wxEmptyString
, wxPoint(360, 135), wxSize(150, wxDefaultCoord
));
453 wxButton
*okButton
= new wxButton(this, wxID_OK
, _("OK"), wxPoint(130, 200), wxSize(80, wxDefaultCoord
));
454 (void) new wxButton(this, wxID_CANCEL
, _("Cancel"), wxPoint(320, 200), wxSize(80, wxDefaultCoord
));
456 okButton
->SetDefault();
457 okButton
->SetFocus();
466 wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog()
470 bool wxGenericPrintSetupDialog::TransferDataToWindow()
472 if (m_printerCommandText
&& m_printData
.GetPrinterCommand())
473 m_printerCommandText
->SetValue(m_printData
.GetPrinterCommand());
474 if (m_printerOptionsText
&& m_printData
.GetPrinterOptions())
475 m_printerOptionsText
->SetValue(m_printData
.GetPrinterOptions());
476 if (m_colourCheckBox
)
477 m_colourCheckBox
->SetValue(m_printData
.GetColour());
479 if (m_orientationRadioBox
)
481 if (m_printData
.GetOrientation() == wxPORTRAIT
)
482 m_orientationRadioBox
->SetSelection(0);
484 m_orientationRadioBox
->SetSelection(1);
489 bool wxGenericPrintSetupDialog::TransferDataFromWindow()
491 if (m_printerCommandText
)
492 m_printData
.SetPrinterCommand(m_printerCommandText
->GetValue());
493 if (m_printerOptionsText
)
494 m_printData
.SetPrinterOptions(m_printerOptionsText
->GetValue());
495 if (m_colourCheckBox
)
496 m_printData
.SetColour(m_colourCheckBox
->GetValue());
497 if (m_orientationRadioBox
)
499 int sel
= m_orientationRadioBox
->GetSelection();
501 m_printData
.SetOrientation(wxPORTRAIT
);
503 m_printData
.SetOrientation(wxLANDSCAPE
);
505 if (m_paperTypeChoice
)
507 int selectedItem
= m_paperTypeChoice
->GetSelection();
508 if (selectedItem
!= -1)
510 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->Item(selectedItem
);
512 m_printData
.SetPaperId( paper
->GetId());
519 wxComboBox
*wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
521 /* Should not be necessary
522 if (!wxThePrintPaperDatabase)
524 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
525 wxThePrintPaperDatabase->CreateDatabase();
528 size_t n
= wxThePrintPaperDatabase
->GetCount();
529 wxString
*choices
= new wxString
[n
];
532 for (size_t i
= 0; i
< n
; i
++)
534 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->Item(i
);
535 choices
[i
] = paper
->GetName();
536 if (m_printData
.GetPaperId() == paper
->GetId())
542 wxComboBox
*choice
= new wxComboBox( this,
546 wxSize(width
, wxDefaultCoord
),
549 // SetFont(thisFont);
553 choice
->SetSelection(sel
);
556 #endif // wxUSE_POSTSCRIPT
558 // ----------------------------------------------------------------------------
559 // Generic page setup dialog
560 // ----------------------------------------------------------------------------
562 void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent
& WXUNUSED(event
))
564 // We no longer query GetPrintMode, so we can eliminate the need
565 // to call SetPrintMode.
566 // This has the limitation that we can't explicitly call the PostScript
567 // print setup dialog from the generic Page Setup dialog under Windows,
568 // but since this choice would only happen when trying to do PostScript
569 // printing under Windows (and only in 16-bit Windows which
570 // doesn't have a Windows-specific page setup dialog) it's worth it.
572 // First save the current settings, so the wxPrintData object is up to date.
573 TransferDataFromWindow();
575 // Transfer the current print settings from this dialog to the page setup dialog.
576 wxPrintDialogData data
;
577 data
= GetPageSetupData().GetPrintData();
578 data
.SetSetupDialog(true);
579 wxPrintDialog
printDialog(this, & data
);
580 printDialog
.ShowModal();
582 // Transfer the page setup print settings from the page dialog to this dialog again, in case
583 // the page setup dialog changed something.
584 GetPageSetupData().GetPrintData() = printDialog
.GetPrintDialogData().GetPrintData();
585 GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData
587 // Now update the dialog in case the page setup dialog changed some of our settings.
588 TransferDataToWindow();
591 wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow
*parent
,
592 wxPageSetupData
* data
)
598 wxDEFAULT_DIALOG_STYLE
|wxTAB_TRAVERSAL
)
605 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
608 wxStaticBoxSizer
*topsizer
= new wxStaticBoxSizer(
609 new wxStaticBox(this,wxPRINTID_STATIC
, _("Paper size")), wxHORIZONTAL
);
611 size_t n
= wxThePrintPaperDatabase
->GetCount();
612 wxString
*choices
= new wxString
[n
];
614 for (size_t i
= 0; i
< n
; i
++)
616 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->Item(i
);
617 choices
[i
] = paper
->GetName();
620 m_paperTypeChoice
= new wxComboBox( this,
624 wxSize(300, wxDefaultCoord
),
626 topsizer
->Add( m_paperTypeChoice
, 1, wxEXPAND
|wxALL
, 5 );
627 // m_paperTypeChoice->SetSelection(sel);
629 mainsizer
->Add( topsizer
, 0, wxTOP
|wxLEFT
|wxRIGHT
| wxEXPAND
, 10 );
631 // 2) middle sizer with radio box
633 wxString
*choices2
= new wxString
[2];
634 choices2
[0] = _("Portrait");
635 choices2
[1] = _("Landscape");
636 m_orientationRadioBox
= new wxRadioBox(this, wxPRINTID_ORIENTATION
, _("Orientation"),
637 wxDefaultPosition
, wxDefaultSize
, 2, choices2
, 2);
638 m_orientationRadioBox
->SetSelection(0);
640 mainsizer
->Add( m_orientationRadioBox
, 0, wxTOP
|wxLEFT
|wxRIGHT
, 10 );
644 wxBoxSizer
*table
= new wxBoxSizer( wxHORIZONTAL
);
646 wxBoxSizer
*column1
= new wxBoxSizer( wxVERTICAL
);
647 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Left margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
648 column1
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Top margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
649 table
->Add( column1
, 0, wxALL
| wxEXPAND
, 5 );
651 wxBoxSizer
*column2
= new wxBoxSizer( wxVERTICAL
);
652 m_marginLeftText
= new wxTextCtrl(this, wxPRINTID_LEFTMARGIN
, wxEmptyString
, wxDefaultPosition
, wxSize(textWidth
, wxDefaultCoord
));
653 m_marginTopText
= new wxTextCtrl(this, wxPRINTID_TOPMARGIN
, wxEmptyString
, wxDefaultPosition
, wxSize(textWidth
, wxDefaultCoord
));
654 column2
->Add( m_marginLeftText
, 1, wxALL
, 5 );
655 column2
->Add( m_marginTopText
, 1, wxALL
, 5 );
656 table
->Add( column2
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
658 wxBoxSizer
*column3
= new wxBoxSizer( wxVERTICAL
);
659 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Right margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
660 column3
->Add( new wxStaticText(this, wxPRINTID_STATIC
, _("Bottom margin (mm):")),1,wxALL
|wxALIGN_RIGHT
,5 );
661 table
->Add( column3
, 0, wxALL
| wxEXPAND
, 5 );
663 wxBoxSizer
*column4
= new wxBoxSizer( wxVERTICAL
);
664 m_marginRightText
= new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN
, wxEmptyString
, wxDefaultPosition
, wxSize(textWidth
, wxDefaultCoord
));
665 m_marginBottomText
= new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN
, wxEmptyString
, wxDefaultPosition
, wxSize(textWidth
, wxDefaultCoord
));
666 column4
->Add( m_marginRightText
, 1, wxALL
, 5 );
667 column4
->Add( m_marginBottomText
, 1, wxALL
, 5 );
668 table
->Add( column4
, 0, wxRIGHT
|wxTOP
|wxBOTTOM
| wxEXPAND
, 5 );
670 mainsizer
->Add( table
, 0 );
674 mainsizer
->Add( new wxStaticLine( this, wxID_ANY
), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
679 wxSizer
* buttonsizer
= CreateButtonSizer( wxOK
|wxCANCEL
);
680 m_printerButton
= new wxButton(this, wxPRINTID_SETUP
, _("Printer...") );
681 buttonsizer
->Add( m_printerButton
, 0, wxLEFT
|wxRIGHT
, 10 );
682 if ( !m_pageData
.GetEnablePrinter() )
683 m_printerButton
->Enable(false);
684 // if (m_printData.GetEnableHelp())
685 // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), wxDefaultCoord, wxDefaultCoord, buttonWidth, buttonHeight);
686 mainsizer
->Add( buttonsizer
, 0, wxCENTER
|wxALL
, 10 );
689 SetAutoLayout( true );
690 SetSizer( mainsizer
);
692 mainsizer
->Fit( this );
701 wxGenericPageSetupDialog::~wxGenericPageSetupDialog()
705 bool wxGenericPageSetupDialog::TransferDataToWindow()
707 if (m_marginLeftText
)
708 m_marginLeftText
->SetValue(wxString::Format(wxT("%d"), m_pageData
.GetMarginTopLeft().x
));
710 m_marginTopText
->SetValue(wxString::Format(wxT("%d"), m_pageData
.GetMarginTopLeft().y
));
711 if (m_marginRightText
)
712 m_marginRightText
->SetValue(wxString::Format(wxT("%d"), m_pageData
.GetMarginBottomRight().x
));
713 if (m_marginBottomText
)
714 m_marginBottomText
->SetValue(wxString::Format(wxT("%d"), m_pageData
.GetMarginBottomRight().y
));
716 if (m_orientationRadioBox
)
718 if (m_pageData
.GetPrintData().GetOrientation() == wxPORTRAIT
)
719 m_orientationRadioBox
->SetSelection(0);
721 m_orientationRadioBox
->SetSelection(1);
724 // Find the paper type from either the current paper size in the wxPageSetupDialogData, or
725 // failing that, the id in the wxPrintData object.
727 wxPrintPaperType
* type
= wxThePrintPaperDatabase
->FindPaperType(
728 wxSize(m_pageData
.GetPaperSize().x
* 10, m_pageData
.GetPaperSize().y
* 10));
730 if (!type
&& m_pageData
.GetPrintData().GetPaperId() != wxPAPER_NONE
)
731 type
= wxThePrintPaperDatabase
->FindPaperType(m_pageData
.GetPrintData().GetPaperId());
735 m_paperTypeChoice
->SetStringSelection(type
->GetName());
741 bool wxGenericPageSetupDialog::TransferDataFromWindow()
743 if (m_marginLeftText
&& m_marginTopText
)
745 int left
= wxAtoi( m_marginLeftText
->GetValue().c_str() );
746 int top
= wxAtoi( m_marginTopText
->GetValue().c_str() );
747 m_pageData
.SetMarginTopLeft( wxPoint(left
,top
) );
749 if (m_marginRightText
&& m_marginBottomText
)
751 int right
= wxAtoi( m_marginRightText
->GetValue().c_str() );
752 int bottom
= wxAtoi( m_marginBottomText
->GetValue().c_str() );
753 m_pageData
.SetMarginBottomRight( wxPoint(right
,bottom
) );
756 if (m_orientationRadioBox
)
758 int sel
= m_orientationRadioBox
->GetSelection();
761 m_pageData
.GetPrintData().SetOrientation(wxPORTRAIT
);
765 m_pageData
.GetPrintData().SetOrientation(wxLANDSCAPE
);
769 if (m_paperTypeChoice
)
771 int selectedItem
= m_paperTypeChoice
->GetSelection();
772 if (selectedItem
!= -1)
774 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->Item(selectedItem
);
777 m_pageData
.SetPaperSize(wxSize(paper
->GetWidth()/10, paper
->GetHeight()/10));
778 m_pageData
.GetPrintData().SetPaperId(paper
->GetId());
786 wxComboBox
*wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x
, int *y
)
789 if (!wxThePrintPaperDatabase)
791 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
792 wxThePrintPaperDatabase->CreateDatabase();
796 size_t n
= wxThePrintPaperDatabase
->GetCount();
797 wxString
*choices
= new wxString
[n
];
799 for (size_t i
= 0; i
< n
; i
++)
801 wxPrintPaperType
*paper
= wxThePrintPaperDatabase
->Item(i
);
802 choices
[i
] = paper
->GetName();
805 (void) new wxStaticText(this, wxPRINTID_STATIC
, _("Paper size"), wxPoint(*x
, *y
));
808 wxComboBox
*choice
= new wxComboBox( this,
812 wxSize(300, wxDefaultCoord
),
817 // choice->SetSelection(sel);