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