]> git.saurik.com Git - wxWidgets.git/blame - src/generic/prntdlgg.cpp
wxToolBarBase -> wxToolBar
[wxWidgets.git] / src / generic / prntdlgg.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: prntdlgg.cpp
3// Purpose: Generic print dialogs
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "prntdlgg.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#include "wx/defs.h"
24
25#define WINDOWS_PRINTING (wxTheApp->GetPrintMode() == wxPRINT_WINDOWS)
26
27#ifndef WX_PRECOMP
28#include "wx/utils.h"
29#include "wx/dc.h"
30#include "wx/app.h"
31#include "wx/frame.h"
32#include "wx/stattext.h"
33#include "wx/button.h"
34#include "wx/checkbox.h"
35#include "wx/textctrl.h"
36#include "wx/radiobox.h"
37#include "wx/filedlg.h"
38#include "wx/choice.h"
1a5a8367 39#include <wx/intl.h>
c801d85f
KB
40#endif
41
42#include "wx/generic/prntdlgg.h"
43#include "wx/printdlg.h"
44
45#include <stdlib.h>
46#include <string.h>
47
48#if !USE_SHARED_LIBRARY
49IMPLEMENT_CLASS(wxGenericPrintDialog, wxDialog)
50IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog)
51IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxDialog)
52
53BEGIN_EVENT_TABLE(wxGenericPrintDialog, wxDialog)
54 EVT_BUTTON(wxID_OK, wxGenericPrintDialog::OnOK)
55 EVT_BUTTON(wxPRINTID_SETUP, wxGenericPrintDialog::OnSetup)
56 EVT_RADIOBOX(wxPRINTID_RANGE, wxGenericPrintDialog::OnRange)
57END_EVENT_TABLE()
58
59BEGIN_EVENT_TABLE(wxGenericPageSetupDialog, wxDialog)
60 EVT_BUTTON(wxPRINTID_SETUP, wxGenericPageSetupDialog::OnPrinter)
61END_EVENT_TABLE()
62#endif
63
64extern wxPrintPaperDatabase *wxThePrintPaperDatabase;
65
66/*
67 * Generic print dialog for non-Windows printing use.
68 */
69
70
71wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, wxPrintData* data):
1a5a8367 72 wxDialog(parent, -1, _("Print"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
c801d85f
KB
73{
74 if ( data )
75 printData = *data;
76
77 int buttonWidth = 65;
78 int buttonHeight = 25;
79 int spacing = 5;
80 int yPos = 5;
81 int xPos = 5;
82
1a5a8367
DP
83 wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(5, yPos), wxSize(buttonWidth, buttonHeight));
84 (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(buttonWidth + 5 + spacing, yPos), wxSize(buttonWidth, buttonHeight));
c801d85f 85
1a5a8367 86 setupButton = new wxButton(this, wxPRINTID_SETUP, _("Setup..."), wxPoint(buttonWidth*2 + 5 + 2*spacing, yPos), wxSize(buttonWidth, buttonHeight));
c801d85f
KB
87
88 okButton->SetDefault();
89 okButton->SetFocus();
90
91 yPos += 35;
92
93 wxString choices[2];
1a5a8367
DP
94 choices[0] = _("All");
95 choices[1] = _("Pages");
86b29a61
RR
96
97 fromText = (wxTextCtrl*)NULL;
98
1a5a8367 99 rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"),
c801d85f
KB
100 wxPoint(5, yPos), wxSize(-1, -1), 2, choices, 2);
101 rangeRadioBox->SetSelection(1);
102
103 yPos += 60;
104 xPos = 5;
105 int staticWidth = 45;
106 int textWidth = 40;
107 spacing = 10;
108
1a5a8367 109 (void) new wxStaticText(this, wxPRINTID_STATIC, _("From:"), wxPoint(xPos, yPos));
c801d85f
KB
110 xPos += staticWidth;
111
112 fromText = new wxTextCtrl(this, wxPRINTID_FROM, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
113 xPos += spacing + textWidth;
114
1a5a8367 115 (void) new wxStaticText(this, wxPRINTID_STATIC, _("To:"), wxPoint(xPos, yPos));
c801d85f
KB
116 xPos += staticWidth;
117
118 toText = new wxTextCtrl(this, wxPRINTID_TO, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
119 xPos += spacing + textWidth;
120
1a5a8367 121 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Copies:"), wxPoint(xPos, yPos));
c801d85f
KB
122 xPos += spacing + staticWidth;
123
124 noCopiesText = new wxTextCtrl(this, wxPRINTID_COPIES, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
125
126 yPos += 30;
127 xPos = 5;
128
1a5a8367 129 printToFileCheckBox = new wxCheckBox(this, wxPRINTID_PRINTTOFILE, _("Print to File"), wxPoint(xPos, yPos));
c801d85f
KB
130
131 Fit();
132 Centre(wxBOTH);
133
134 // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow
135 InitDialog();
136}
137
138int wxGenericPrintDialog::ShowModal(void)
139{
140 if ( printData.GetSetupDialog() )
141 {
142 wxGenericPrintSetupDialog *genericPrintSetupDialog =
143 new wxGenericPrintSetupDialog(GetParent(), wxThePrintSetupData);
144 int ret = genericPrintSetupDialog->ShowModal();
145 if ( ret != wxID_CANCEL )
146 {
147 *wxThePrintSetupData = genericPrintSetupDialog->printData;
148 }
149 genericPrintSetupDialog->Close(TRUE);
150 return ret;
151 }
152 else
153 {
154 return wxDialog::ShowModal();
155 }
156}
157
158wxGenericPrintDialog::~wxGenericPrintDialog(void)
159{
160}
161
162void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
163{
164 TransferDataFromWindow();
165
166 // There are some interactions between the global setup data
167 // and the standard print dialog. The global printing 'mode'
168 // is determined by whether the user checks Print to file
169 // or not.
170 if (printData.GetPrintToFile())
171 {
172 wxThePrintSetupData->SetPrinterMode(PS_FILE);
173
1a5a8367 174 char *f = wxFileSelector(_("PostScript file"),
c801d85f
KB
175 wxPathOnly(wxThePrintSetupData->GetPrinterFile()),
176 wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()),
177 "ps", "*.ps", 0, this);
178 if (f)
179 wxThePrintSetupData->SetPrinterFile(f);
180 else
181 return;
182 }
183 else
184 wxThePrintSetupData->SetPrinterMode(PS_PRINTER);
185
186 EndModal(wxID_OK);
187}
188
189void wxGenericPrintDialog::OnRange(wxCommandEvent& event)
190{
86b29a61
RR
191 if (!fromText) return;
192
193 if (event.GetInt() == 1)
c801d85f
KB
194 {
195 fromText->Enable(FALSE);
196 toText->Enable(FALSE);
197 }
86b29a61 198 else if (event.GetInt() == 0)
c801d85f
KB
199 {
200 fromText->Enable(TRUE);
201 toText->Enable(TRUE);
202 }
203}
204
205void wxGenericPrintDialog::OnSetup(wxCommandEvent& WXUNUSED(event))
206{
207 wxGenericPrintSetupDialog *genericPrintSetupDialog =
208 new wxGenericPrintSetupDialog(this, wxThePrintSetupData);
209 int ret = genericPrintSetupDialog->ShowModal();
210 if ( ret != wxID_CANCEL )
211 {
212 *wxThePrintSetupData = genericPrintSetupDialog->printData;
213 printData.SetOrientation(wxThePrintSetupData->GetPrinterOrientation());
214 }
215
216 genericPrintSetupDialog->Close(TRUE);
217}
218
219bool wxGenericPrintDialog::TransferDataToWindow(void)
220{
221 char buf[10];
222 if (printData.GetEnablePageNumbers())
223 {
224 fromText->Enable(TRUE);
225 toText->Enable(TRUE);
226
227 sprintf(buf, "%d", printData.GetFromPage());
228 fromText->SetValue(buf);
229 sprintf(buf, "%d", printData.GetToPage());
230 toText->SetValue(buf);
231
232 if (printData.GetAllPages())
233 rangeRadioBox->SetSelection(0);
234 else
235 rangeRadioBox->SetSelection(1);
236 }
237 else
238 {
239 fromText->Enable(FALSE);
240 toText->Enable(FALSE);
241 rangeRadioBox->SetSelection(0);
242 rangeRadioBox->wxRadioBox::Enable(1, FALSE);
243 }
244 sprintf(buf, "%d", printData.GetNoCopies());
245 noCopiesText->SetValue(buf);
246
247 printToFileCheckBox->SetValue(printData.GetPrintToFile());
248 printToFileCheckBox->Enable(printData.GetEnablePrintToFile());
249 return TRUE;
250}
251
252bool wxGenericPrintDialog::TransferDataFromWindow(void)
253{
254 if (printData.GetEnablePageNumbers())
255 {
256 printData.SetFromPage(atoi(fromText->GetValue()));
257 printData.SetToPage(atoi(toText->GetValue()));
258 }
259 if (rangeRadioBox->GetSelection() == 0)
260 printData.SetAllPages(TRUE);
261 else
262 printData.SetAllPages(FALSE);
263 printData.SetNoCopies(atoi(noCopiesText->GetValue()));
264 printData.SetPrintToFile(printToFileCheckBox->GetValue());
265
266 return TRUE;
267}
268
269wxDC *wxGenericPrintDialog::GetPrintDC(void)
270{
271 return new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, NULL);
272}
273
274/*
275 * Generic print setup dialog
276 */
277
278wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSetupData* data):
1a5a8367 279 wxDialog(parent, -1, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
c801d85f
KB
280{
281 if ( data )
282 printData = *data;
283
284 int buttonWidth = 65;
285 int buttonHeight = 25;
286 int spacing = 5;
287 int yPos = 5;
288 int xPos = 5;
289
1a5a8367 290 wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(xPos, yPos), wxSize(buttonWidth, buttonHeight));
c801d85f 291 xPos += buttonWidth + spacing;
1a5a8367 292 (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(xPos, yPos), wxSize(buttonWidth, buttonHeight));
c801d85f
KB
293
294 okButton->SetDefault();
295 okButton->SetFocus();
296
297 yPos += 35;
298 xPos = 5;
299
300 paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
301
302 wxString choices[2];
1a5a8367
DP
303 choices[0] = _("Portrait");
304 choices[1] = _("Landscape");
c801d85f 305
1a5a8367 306 orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
c801d85f
KB
307 wxPoint(xPos, yPos), wxSize(-1, -1), 2, choices, 2);
308 orientationRadioBox->SetSelection(0);
309
310 xPos += 200;
311
1a5a8367 312 colourCheckBox = new wxCheckBox(this, wxPRINTID_PRINTCOLOUR, _("Print in colour"), wxPoint(xPos, yPos));
c801d85f
KB
313
314 xPos = 5;
315 yPos += 60;
316
317 int staticWidth = 100;
318 int textWidth = 120;
319 spacing = 10;
320
1a5a8367 321 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer command:"), wxPoint(xPos, yPos));
c801d85f
KB
322 xPos += staticWidth;
323
324 printerCommandText = new wxTextCtrl(this, wxPRINTID_COMMAND, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
325 xPos += textWidth + spacing;
326
1a5a8367 327 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Printer options:"), wxPoint(xPos, yPos));
c801d85f
KB
328 xPos += staticWidth;
329
330 printerOptionsText = new wxTextCtrl(this, wxPRINTID_OPTIONS, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
331
332 Fit();
333 Centre(wxBOTH);
334
335 InitDialog();
336}
337
338wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog(void)
339{
340}
341
342bool wxGenericPrintSetupDialog::TransferDataToWindow(void)
343{
344 if (printerCommandText && printData.GetPrinterCommand())
345 printerCommandText->SetValue(printData.GetPrinterCommand());
346 if (printerOptionsText && printData.GetPrinterOptions())
347 printerOptionsText->SetValue(printData.GetPrinterOptions());
348 if (colourCheckBox)
349 colourCheckBox->SetValue(printData.GetColour());
350
351 if (orientationRadioBox)
352 {
353 if (printData.GetPrinterOrientation() == PS_PORTRAIT)
354 orientationRadioBox->SetSelection(0);
355 else
356 orientationRadioBox->SetSelection(1);
357 }
358 return TRUE;
359}
360
361bool wxGenericPrintSetupDialog::TransferDataFromWindow(void)
362{
363 if (printerCommandText)
364 printData.SetPrinterCommand(WXSTRINGCAST printerCommandText->GetValue());
365 if (printerOptionsText)
366 printData.SetPrinterOptions(WXSTRINGCAST printerOptionsText->GetValue());
367 if (colourCheckBox)
368 printData.SetColour(colourCheckBox->GetValue());
369 if (orientationRadioBox)
370 {
371 int sel = orientationRadioBox->GetSelection();
372 if (sel == 0)
373 printData.SetPrinterOrientation(PS_PORTRAIT);
374 else
375 printData.SetPrinterOrientation(PS_LANDSCAPE);
376 }
377 if (paperTypeChoice)
378 {
379 wxString val(paperTypeChoice->GetStringSelection());
380 if (!val.IsNull() && val != "")
381 printData.SetPaperName((char *)(const char *)val);
382 }
383 return TRUE;
384}
385
386wxChoice *wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x, int *y)
387{
388 if (!wxThePrintPaperDatabase)
389 {
390 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
391 wxThePrintPaperDatabase->CreateDatabase();
392 }
393 int n = wxThePrintPaperDatabase->Number();
394 wxString *choices = new wxString [n];
395 int sel = 0;
396 int i;
397 for (i = 0; i < n; i++)
398 {
399 wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Nth(i)->Data();
400 choices[i] = paper->pageName;
401 if (printData.GetPaperName() && choices[i] == printData.GetPaperName())
402 sel = i;
403 }
404
1a5a8367 405 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(*x, *y));
c801d85f
KB
406 *y += 25;
407
408 wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(300, -1), n,
409 choices);
410 *y += 35;
411 delete[] choices;
412
413 choice->SetSelection(sel);
414 return choice;
415}
416
417/*
418 * Generic page setup dialog
419 */
420
421void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event))
422{
423 if (wxTheApp->GetPrintMode() == wxPRINT_POSTSCRIPT)
424 {
425 wxGenericPrintSetupDialog *genericPrintSetupDialog =
426 new wxGenericPrintSetupDialog(this, wxThePrintSetupData);
427 int ret = genericPrintSetupDialog->ShowModal();
428 if (ret == wxID_OK)
429 *wxThePrintSetupData = genericPrintSetupDialog->GetPrintData();
430
431 genericPrintSetupDialog->Close(TRUE);
432 }
2049ba38 433#ifdef __WXMSW__
c801d85f
KB
434 else
435 {
436 wxPrintData data;
437 data.SetSetupDialog(TRUE);
438 wxPrintDialog printDialog(this, & data);
439 printDialog.Show(TRUE);
440 }
441#endif
442}
443
444wxGenericPageSetupDialog::wxGenericPageSetupDialog(wxWindow *parent, wxPageSetupData* data):
1a5a8367 445 wxDialog(parent, -1, _("Page Setup"), wxPoint(0, 0), wxSize(600, 600), wxDIALOG_MODAL|wxDEFAULT_DIALOG_STYLE)
c801d85f
KB
446{
447 if ( data )
448 pageData = *data;
449
450 int buttonWidth = 75;
451 int buttonHeight = 25;
452 int spacing = 5;
453 int yPos = 5;
454 int xPos = 5;
455
1a5a8367
DP
456 wxButton *okButton = new wxButton(this, wxID_OK, _("OK"), wxPoint(5, yPos), wxSize(buttonWidth, buttonHeight));
457 (void) new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(buttonWidth + 5 + spacing, yPos), wxSize(buttonWidth, buttonHeight));
c801d85f 458
1a5a8367 459 printerButton = new wxButton(this, wxPRINTID_SETUP, _("Printer..."), wxPoint(buttonWidth*2 + 5 + 2*spacing, yPos), wxSize(buttonWidth, buttonHeight));
c801d85f
KB
460
461 if ( !pageData.GetEnablePrinter() )
462 printerButton->Enable(FALSE);
463
464// if (printData.GetEnableHelp())
1a5a8367 465// wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), -1, -1, buttonWidth, buttonHeight);
c801d85f
KB
466
467 okButton->SetDefault();
468 okButton->SetFocus();
469
470 xPos = 5;
471 yPos += 35;
472
473 paperTypeChoice = CreatePaperTypeChoice(&xPos, &yPos);
474
475 xPos = 5;
476
477 wxString choices[2];
1a5a8367
DP
478 choices[0] = _("Portrait");
479 choices[1] = _("Landscape");
480 orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"),
c801d85f
KB
481 wxPoint(xPos, yPos), wxSize(-1, -1), 2, choices, 2);
482 orientationRadioBox->SetSelection(0);
483
484 xPos = 5;
485 yPos += 60;
486
487 int staticWidth = 110;
488 int textWidth = 60;
489 spacing = 10;
490
1a5a8367 491 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Left margin (mm):"), wxPoint(xPos, yPos));
c801d85f
KB
492 xPos += staticWidth;
493
494 marginLeftText = new wxTextCtrl(this, wxPRINTID_LEFTMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
495 xPos += textWidth + spacing;
496
1a5a8367 497 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Right margin (mm):"), wxPoint(xPos, yPos));
c801d85f
KB
498 xPos += staticWidth;
499
500 marginRightText = new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
501 xPos += textWidth + spacing;
502
503 yPos += 35;
504 xPos = 5;
505
1a5a8367 506 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Top margin (mm):"), wxPoint(xPos, yPos));
c801d85f
KB
507 xPos += staticWidth;
508
509 marginTopText = new wxTextCtrl(this, wxPRINTID_TOPMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
510 xPos += textWidth + spacing;
511
1a5a8367 512 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Bottom margin (mm):"), wxPoint(xPos, yPos));
c801d85f
KB
513 xPos += staticWidth;
514
515 marginBottomText = new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN, "", wxPoint(xPos, yPos), wxSize(textWidth, -1));
516
517 Fit();
518 Centre(wxBOTH);
519
520 InitDialog();
521}
522
523wxGenericPageSetupDialog::~wxGenericPageSetupDialog(void)
524{
525}
526
527bool wxGenericPageSetupDialog::TransferDataToWindow(void)
528{
529 if (marginLeftText)
530 marginLeftText->SetValue(IntToString((int) pageData.GetMarginTopLeft().x));
531 if (marginTopText)
532 marginTopText->SetValue(IntToString((int) pageData.GetMarginTopLeft().y));
533 if (marginRightText)
534 marginRightText->SetValue(IntToString((int) pageData.GetMarginBottomRight().x));
535 if (marginBottomText)
536 marginBottomText->SetValue(IntToString((int) pageData.GetMarginBottomRight().y));
537
538 if (orientationRadioBox)
539 {
540 if (pageData.GetOrientation() == wxPORTRAIT)
541 orientationRadioBox->SetSelection(0);
542 else
543 orientationRadioBox->SetSelection(1);
544 }
545 return TRUE;
546}
547
548bool wxGenericPageSetupDialog::TransferDataFromWindow(void)
549{
550 if (marginLeftText && marginTopText)
551 pageData.SetMarginTopLeft(wxPoint(atoi((const char *)marginLeftText->GetValue()),atoi((const char *)marginTopText->GetValue())));
552 if (marginRightText && marginBottomText)
553 pageData.SetMarginBottomRight(wxPoint(atoi((const char *)marginRightText->GetValue()),atoi((const char *)marginBottomText->GetValue())));
554
555 if (orientationRadioBox)
556 {
557 int sel = orientationRadioBox->GetSelection();
558 if (sel == 0)
559 {
560 wxThePrintSetupData->SetPrinterOrientation(wxPORTRAIT);
561 pageData.SetOrientation(wxPORTRAIT);
562 }
563 else
564 {
565 wxThePrintSetupData->SetPrinterOrientation(wxLANDSCAPE);
566 pageData.SetOrientation(wxLANDSCAPE);
567 }
568 }
569 if (paperTypeChoice)
570 {
571 wxString val(paperTypeChoice->GetStringSelection());
572 if (!val.IsNull() && val != "")
573 {
574 wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType((char*) (const char *)val);
575 if ( paper )
576 {
577 pageData.SetPaperSize(wxPoint(paper->widthMM, paper->heightMM));
578 }
579 }
580 }
581 return TRUE;
582}
583
584wxChoice *wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x, int *y)
585{
586 if (!wxThePrintPaperDatabase)
587 {
588 wxThePrintPaperDatabase = new wxPrintPaperDatabase;
589 wxThePrintPaperDatabase->CreateDatabase();
590 }
591 int n = wxThePrintPaperDatabase->Number();
592 wxString *choices = new wxString [n];
593 int sel = 0;
594 int i;
595 for (i = 0; i < n; i++)
596 {
597 wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Nth(i)->Data();
598 choices[i] = paper->pageName;
599 if (pageData.GetPaperSize().x == paper->widthMM && pageData.GetPaperSize().y == paper->heightMM)
600 sel = i;
601 }
602
1a5a8367 603 (void) new wxStaticText(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(*x, *y));
c801d85f
KB
604 *y += 25;
605
606 wxChoice *choice = new wxChoice(this, wxPRINTID_PAPERSIZE, wxPoint(*x, *y), wxSize(300, -1), n,
607 choices);
608 *y += 35;
609 delete[] choices;
610
611 choice->SetSelection(sel);
612 return choice;
613}
614
615