]>
Commit | Line | Data |
---|---|---|
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$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
8826f46f VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
8826f46f | 21 | #pragma implementation "prntdlgg.h" |
c801d85f KB |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
8826f46f | 28 | #pragma hdrstop |
c801d85f KB |
29 | #endif |
30 | ||
aba17e09 | 31 | #if wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) |
ce4169a4 | 32 | |
c801d85f | 33 | #ifndef WX_PRECOMP |
8826f46f VZ |
34 | #include "wx/utils.h" |
35 | #include "wx/dc.h" | |
8826f46f VZ |
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" | |
fa12f7e6 | 43 | #include "wx/combobox.h" |
3096bd2f | 44 | #include "wx/intl.h" |
27ea1d8a | 45 | #include "wx/sizer.h" |
ebb7606e | 46 | #include "wx/cmndata.h" |
27ea1d8a RR |
47 | #endif |
48 | ||
49 | #if wxUSE_STATLINE | |
50 | #include "wx/statline.h" | |
c801d85f KB |
51 | #endif |
52 | ||
53 | #include "wx/generic/prntdlgg.h" | |
2a47d3c1 JS |
54 | |
55 | #if wxUSE_POSTSCRIPT | |
8826f46f | 56 | #include "wx/generic/dcpsg.h" |
2a47d3c1 JS |
57 | #endif |
58 | ||
8850cbd3 | 59 | #include "wx/prntbase.h" |
c801d85f | 60 | #include "wx/printdlg.h" |
7bcb11d3 | 61 | #include "wx/paper.h" |
eba33006 | 62 | #include "wx/filename.h" |
c801d85f KB |
63 | |
64 | #include <stdlib.h> | |
65 | #include <string.h> | |
66 | ||
8826f46f | 67 | // ---------------------------------------------------------------------------- |
8850cbd3 | 68 | // global vars |
8826f46f VZ |
69 | // ---------------------------------------------------------------------------- |
70 | ||
8850cbd3 | 71 | extern wxPrintPaperDatabase *wxThePrintPaperDatabase; |
25889d3c | 72 | |
2a47d3c1 JS |
73 | #if wxUSE_POSTSCRIPT |
74 | ||
8850cbd3 RR |
75 | //---------------------------------------------------------------------------- |
76 | // wxPostScriptNativeData | |
77 | //---------------------------------------------------------------------------- | |
30862d99 | 78 | |
8850cbd3 | 79 | IMPLEMENT_CLASS(wxPostScriptPrintNativeData, wxPrintNativeDataBase) |
8826f46f | 80 | |
8850cbd3 RR |
81 | wxPostScriptPrintNativeData::wxPostScriptPrintNativeData() |
82 | { | |
83 | m_previewCommand = wxT(""); | |
84 | #ifdef __VMS__ | |
85 | m_printerCommand = wxT("print"); | |
86 | m_printerOptions = wxT("/nonotify/queue=psqueue"); | |
87 | m_afmPath = wxT("sys$ps_font_metrics:"); | |
88 | #endif | |
30862d99 | 89 | |
8850cbd3 RR |
90 | #ifdef __WXMSW__ |
91 | m_printerCommand = wxT("print"); | |
92 | m_printerOptions = wxT(""); | |
93 | m_afmPath = wxT("c:\\windows\\system\\"); | |
94 | #endif | |
8826f46f | 95 | |
8850cbd3 RR |
96 | #if !defined(__VMS__) && !defined(__WXMSW__) |
97 | m_printerCommand = wxT("lpr"); | |
98 | m_printerOptions = wxT(""); | |
99 | m_afmPath = wxT(""); | |
100 | #endif | |
c801d85f | 101 | |
8850cbd3 RR |
102 | m_printerScaleX = 1.0; |
103 | m_printerScaleY = 1.0; | |
104 | m_printerTranslateX = 0; | |
105 | m_printerTranslateY = 0; | |
8850cbd3 | 106 | } |
c801d85f | 107 | |
8850cbd3 RR |
108 | wxPostScriptPrintNativeData::~wxPostScriptPrintNativeData() |
109 | { | |
110 | } | |
111 | ||
fd64de59 | 112 | bool wxPostScriptPrintNativeData::TransferTo( wxPrintData &data ) |
8850cbd3 RR |
113 | { |
114 | return true; | |
115 | } | |
116 | ||
fd64de59 | 117 | bool wxPostScriptPrintNativeData::TransferFrom( const wxPrintData &data ) |
8850cbd3 RR |
118 | { |
119 | return true; | |
120 | } | |
25889d3c | 121 | |
8826f46f VZ |
122 | // ---------------------------------------------------------------------------- |
123 | // Generic print dialog for non-Windows printing use. | |
124 | // ---------------------------------------------------------------------------- | |
125 | ||
c061373d RR |
126 | IMPLEMENT_CLASS(wxGenericPrintDialog, wxPrintDialogBase) |
127 | ||
128 | BEGIN_EVENT_TABLE(wxGenericPrintDialog, wxPrintDialogBase) | |
129 | EVT_BUTTON(wxID_OK, wxGenericPrintDialog::OnOK) | |
130 | EVT_BUTTON(wxPRINTID_SETUP, wxGenericPrintDialog::OnSetup) | |
131 | EVT_RADIOBOX(wxPRINTID_RANGE, wxGenericPrintDialog::OnRange) | |
132 | END_EVENT_TABLE() | |
133 | ||
8826f46f VZ |
134 | wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, |
135 | wxPrintDialogData* data) | |
c061373d | 136 | : wxPrintDialogBase(parent, wxID_ANY, _("Print"), |
8826f46f VZ |
137 | wxPoint(0, 0), wxSize(600, 600), |
138 | wxDEFAULT_DIALOG_STYLE | | |
8826f46f VZ |
139 | wxTAB_TRAVERSAL) |
140 | { | |
141 | if ( data ) | |
142 | m_printDialogData = *data; | |
c801d85f | 143 | |
8826f46f VZ |
144 | Init(parent); |
145 | } | |
c801d85f | 146 | |
8826f46f VZ |
147 | wxGenericPrintDialog::wxGenericPrintDialog(wxWindow *parent, |
148 | wxPrintData* data) | |
c061373d | 149 | : wxPrintDialogBase(parent, wxID_ANY, _("Print"), |
cb230244 JS |
150 | wxPoint(0, 0), wxSize(600, 600), |
151 | wxDEFAULT_DIALOG_STYLE | | |
cb230244 | 152 | wxTAB_TRAVERSAL) |
c801d85f | 153 | { |
7bcb11d3 JS |
154 | if ( data ) |
155 | m_printDialogData = *data; | |
8826f46f VZ |
156 | |
157 | Init(parent); | |
158 | } | |
159 | ||
74e3313b | 160 | void wxGenericPrintDialog::Init(wxWindow * WXUNUSED(parent)) |
8826f46f | 161 | { |
ca65c044 | 162 | // wxDialog::Create(parent, wxID_ANY, _("Print"), wxPoint(0, 0), wxSize(600, 600), |
2a21ac15 | 163 | // wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL); |
8826f46f | 164 | |
27ea1d8a | 165 | wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); |
6038ec8e | 166 | |
ca65c044 WS |
167 | // 1) top row |
168 | ||
6038ec8e RR |
169 | wxPrintFactory* factory = wxPrintFactory::GetFactory(); |
170 | ||
ca65c044 WS |
171 | wxStaticBoxSizer *topsizer = new wxStaticBoxSizer( |
172 | new wxStaticBox( this, wxID_ANY, _( "Printer options" ) ), wxHORIZONTAL ); | |
6038ec8e RR |
173 | wxFlexGridSizer *flex = new wxFlexGridSizer( 2 ); |
174 | flex->AddGrowableCol( 1 ); | |
175 | topsizer->Add( flex, 1, wxGROW ); | |
176 | ||
27ea1d8a | 177 | m_printToFileCheckBox = new wxCheckBox( this, wxPRINTID_PRINTTOFILE, _("Print to File") ); |
6038ec8e RR |
178 | flex->Add( m_printToFileCheckBox, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
179 | ||
27ea1d8a | 180 | m_setupButton = new wxButton(this, wxPRINTID_SETUP, _("Setup...") ); |
6038ec8e RR |
181 | flex->Add( m_setupButton, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); |
182 | ||
183 | if (!factory->HasPrintSetupDialog()) | |
184 | m_setupButton->Enable( false ); | |
185 | ||
186 | if (factory->HasPrinterLine()) | |
187 | { | |
188 | flex->Add( new wxStaticText( this, -1, _("Printer:") ), | |
189 | 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
190 | flex->Add( new wxStaticText( this, -1, factory->CreatePrinterLine() ), | |
191 | 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
192 | } | |
ca65c044 | 193 | |
6038ec8e RR |
194 | if (factory->HasStatusLine()) |
195 | { | |
196 | flex->Add( new wxStaticText( this, -1, _("Status:") ), | |
197 | 0, wxALIGN_CENTER_VERTICAL|wxALL-wxTOP, 5 ); | |
198 | flex->Add( new wxStaticText( this, -1, factory->CreateStatusLine() ), | |
199 | 0, wxALIGN_CENTER_VERTICAL|wxALL-wxTOP, 5 ); | |
200 | } | |
201 | ||
202 | mainsizer->Add( topsizer, 0, wxLEFT|wxTOP|wxRIGHT|wxGROW, 10 ); | |
ca65c044 | 203 | |
27ea1d8a | 204 | // 2) middle row with radio box |
ca65c044 | 205 | |
7bcb11d3 JS |
206 | wxString *choices = new wxString[2]; |
207 | choices[0] = _("All"); | |
208 | choices[1] = _("Pages"); | |
8826f46f | 209 | |
7bcb11d3 | 210 | m_fromText = (wxTextCtrl*)NULL; |
d14612c6 | 211 | m_toText = (wxTextCtrl*)NULL; |
59e2b19f | 212 | m_rangeRadioBox = (wxRadioBox *)NULL; |
ca65c044 | 213 | |
7bcb11d3 JS |
214 | if (m_printDialogData.GetFromPage() != 0) |
215 | { | |
216 | m_rangeRadioBox = new wxRadioBox(this, wxPRINTID_RANGE, _("Print Range"), | |
27ea1d8a | 217 | wxDefaultPosition, wxDefaultSize, |
8826f46f VZ |
218 | 2, choices, |
219 | 1, wxRA_VERTICAL); | |
7bcb11d3 | 220 | m_rangeRadioBox->SetSelection(1); |
b1d4dd7a | 221 | |
eba33006 | 222 | mainsizer->Add( m_rangeRadioBox, 0, wxLEFT|wxTOP|wxRIGHT, 10 ); |
7bcb11d3 | 223 | } |
8826f46f | 224 | |
27ea1d8a | 225 | // 3) bottom row |
ca65c044 | 226 | |
27ea1d8a RR |
227 | wxBoxSizer *bottomsizer = new wxBoxSizer( wxHORIZONTAL ); |
228 | ||
229 | if (m_printDialogData.GetFromPage() != 0) | |
7bcb11d3 | 230 | { |
27ea1d8a | 231 | bottomsizer->Add( new wxStaticText(this, wxPRINTID_STATIC, _("From:") ), 0, wxCENTER|wxALL, 5 ); |
422d0ff0 | 232 | m_fromText = new wxTextCtrl(this, wxPRINTID_FROM, wxEmptyString, wxDefaultPosition, wxSize(40, wxDefaultCoord)); |
eba33006 | 233 | bottomsizer->Add( m_fromText, 1, wxCENTER|wxRIGHT, 10 ); |
8826f46f | 234 | |
27ea1d8a | 235 | bottomsizer->Add( new wxStaticText(this, wxPRINTID_STATIC, _("To:") ), 0, wxCENTER|wxALL, 5); |
422d0ff0 | 236 | m_toText = new wxTextCtrl(this, wxPRINTID_TO, wxEmptyString, wxDefaultPosition, wxSize(40, wxDefaultCoord)); |
eba33006 | 237 | bottomsizer->Add( m_toText, 1, wxCENTER|wxRIGHT, 10 ); |
27ea1d8a | 238 | } |
8826f46f | 239 | |
27ea1d8a | 240 | bottomsizer->Add( new wxStaticText(this, wxPRINTID_STATIC, _("Copies:") ), 0, wxCENTER|wxALL, 5 ); |
422d0ff0 | 241 | m_noCopiesText = new wxTextCtrl(this, wxPRINTID_COPIES, wxEmptyString, wxPoint(252, 130), wxSize(40, wxDefaultCoord)); |
27ea1d8a | 242 | bottomsizer->Add( m_noCopiesText, 1, wxCENTER|wxRIGHT, 10 ); |
8826f46f | 243 | |
27ea1d8a | 244 | mainsizer->Add( bottomsizer, 0, wxTOP|wxLEFT|wxRIGHT, 12 ); |
8826f46f | 245 | |
27ea1d8a RR |
246 | #if wxUSE_STATLINE |
247 | // 4) static line | |
ca65c044 | 248 | mainsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); |
27ea1d8a | 249 | #endif |
8826f46f | 250 | |
27ea1d8a | 251 | // 5) buttons |
8826f46f | 252 | |
27ea1d8a | 253 | mainsizer->Add( CreateButtonSizer( wxOK|wxCANCEL), 0, wxCENTER|wxALL, 10 ); |
8826f46f | 254 | |
ca65c044 | 255 | SetAutoLayout( true ); |
27ea1d8a RR |
256 | SetSizer( mainsizer ); |
257 | ||
258 | mainsizer->Fit( this ); | |
7bcb11d3 | 259 | Centre(wxBOTH); |
8826f46f | 260 | |
7bcb11d3 JS |
261 | // Calls wxWindow::OnInitDialog and then wxGenericPrintDialog::TransferDataToWindow |
262 | InitDialog(); | |
263 | delete[] choices; | |
c801d85f KB |
264 | } |
265 | ||
7bcb11d3 | 266 | int wxGenericPrintDialog::ShowModal() |
c801d85f | 267 | { |
6038ec8e | 268 | return wxDialog::ShowModal(); |
c801d85f KB |
269 | } |
270 | ||
7bcb11d3 | 271 | wxGenericPrintDialog::~wxGenericPrintDialog() |
c801d85f KB |
272 | { |
273 | } | |
274 | ||
275 | void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event)) | |
276 | { | |
7bcb11d3 | 277 | TransferDataFromWindow(); |
8826f46f | 278 | |
b386cd7a JS |
279 | // An empty 'to' field signals printing just the |
280 | // 'from' page. | |
281 | if (m_printDialogData.GetToPage() < 1) | |
282 | m_printDialogData.SetToPage(m_printDialogData.GetFromPage()); | |
283 | ||
7bcb11d3 JS |
284 | // There are some interactions between the global setup data |
285 | // and the standard print dialog. The global printing 'mode' | |
286 | // is determined by whether the user checks Print to file | |
287 | // or not. | |
288 | if (m_printDialogData.GetPrintToFile()) | |
289 | { | |
6038ec8e | 290 | m_printDialogData.GetPrintData().SetPrintMode(wxPRINT_MODE_FILE); |
ca65c044 | 291 | |
eba33006 | 292 | wxFileName fname( m_printDialogData.GetPrintData().GetFilename() ); |
ca65c044 | 293 | |
eba33006 | 294 | wxFileDialog dialog( this, _("PostScript file"), |
03914ad4 | 295 | fname.GetPath(), fname.GetFullName(), wxT("*.ps"), wxOPEN | wxOVERWRITE_PROMPT ); |
eba33006 | 296 | if (dialog.ShowModal() != wxID_OK) return; |
8850cbd3 | 297 | |
eba33006 | 298 | m_printDialogData.GetPrintData().SetFilename( dialog.GetPath() ); |
7bcb11d3 JS |
299 | } |
300 | else | |
75737d05 | 301 | { |
6038ec8e | 302 | m_printDialogData.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER); |
75737d05 | 303 | } |
8826f46f | 304 | |
7bcb11d3 | 305 | EndModal(wxID_OK); |
c801d85f KB |
306 | } |
307 | ||
308 | void wxGenericPrintDialog::OnRange(wxCommandEvent& event) | |
309 | { | |
7bcb11d3 | 310 | if (!m_fromText) return; |
8826f46f | 311 | |
7bcb11d3 JS |
312 | if (event.GetInt() == 0) |
313 | { | |
ca65c044 WS |
314 | m_fromText->Enable(false); |
315 | m_toText->Enable(false); | |
7bcb11d3 JS |
316 | } |
317 | else if (event.GetInt() == 1) | |
318 | { | |
ca65c044 WS |
319 | m_fromText->Enable(true); |
320 | m_toText->Enable(true); | |
7bcb11d3 | 321 | } |
c801d85f KB |
322 | } |
323 | ||
324 | void wxGenericPrintDialog::OnSetup(wxCommandEvent& WXUNUSED(event)) | |
325 | { | |
6038ec8e RR |
326 | wxPrintFactory* factory = wxPrintFactory::GetFactory(); |
327 | ||
328 | if (factory->HasPrintSetupDialog()) | |
7bcb11d3 | 329 | { |
6038ec8e RR |
330 | // The print setup dialog should change the |
331 | // print data in-place if not cancelled. | |
332 | wxDialog *dialog = factory->CreatePrintSetupDialog( this, &m_printDialogData.GetPrintData() ); | |
333 | dialog->ShowModal(); | |
334 | dialog->Destroy(); | |
7bcb11d3 | 335 | } |
c801d85f KB |
336 | } |
337 | ||
7bcb11d3 | 338 | bool wxGenericPrintDialog::TransferDataToWindow() |
c801d85f | 339 | { |
7bcb11d3 JS |
340 | if(m_printDialogData.GetFromPage() != 0) |
341 | { | |
d14612c6 KB |
342 | if(m_fromText) |
343 | { | |
344 | if (m_printDialogData.GetEnablePageNumbers()) | |
345 | { | |
ca65c044 WS |
346 | m_fromText->Enable(true); |
347 | m_toText->Enable(true); | |
b386cd7a JS |
348 | if (m_printDialogData.GetFromPage() > 0) |
349 | m_fromText->SetValue(wxString::Format(_T("%d"), m_printDialogData.GetFromPage())); | |
350 | if (m_printDialogData.GetToPage() > 0) | |
351 | m_toText->SetValue(wxString::Format(_T("%d"), m_printDialogData.GetToPage())); | |
59e2b19f | 352 | if(m_rangeRadioBox) |
b386cd7a | 353 | if (m_printDialogData.GetAllPages() || m_printDialogData.GetFromPage() == 0) |
59e2b19f KB |
354 | m_rangeRadioBox->SetSelection(0); |
355 | else | |
356 | m_rangeRadioBox->SetSelection(1); | |
d14612c6 KB |
357 | } |
358 | else | |
359 | { | |
ca65c044 WS |
360 | m_fromText->Enable(false); |
361 | m_toText->Enable(false); | |
59e2b19f KB |
362 | if(m_rangeRadioBox) |
363 | { | |
364 | m_rangeRadioBox->SetSelection(0); | |
ca65c044 | 365 | m_rangeRadioBox->wxRadioBox::Enable(1, false); |
59e2b19f | 366 | } |
d14612c6 KB |
367 | } |
368 | } | |
7bcb11d3 | 369 | } |
30862d99 VZ |
370 | m_noCopiesText->SetValue( |
371 | wxString::Format(_T("%d"), m_printDialogData.GetNoCopies())); | |
8826f46f | 372 | |
7bcb11d3 JS |
373 | m_printToFileCheckBox->SetValue(m_printDialogData.GetPrintToFile()); |
374 | m_printToFileCheckBox->Enable(m_printDialogData.GetEnablePrintToFile()); | |
ca65c044 | 375 | return true; |
c801d85f KB |
376 | } |
377 | ||
7bcb11d3 | 378 | bool wxGenericPrintDialog::TransferDataFromWindow() |
c801d85f | 379 | { |
92980e90 | 380 | long res = 0; |
7bcb11d3 JS |
381 | if(m_printDialogData.GetFromPage() != -1) |
382 | { | |
383 | if (m_printDialogData.GetEnablePageNumbers()) | |
384 | { | |
92980e90 RR |
385 | if(m_fromText) |
386 | { | |
387 | wxString value = m_fromText->GetValue(); | |
388 | if (value.ToLong( &res )) | |
389 | m_printDialogData.SetFromPage( res ); | |
390 | } | |
391 | if(m_toText) | |
ca65c044 | 392 | { |
92980e90 RR |
393 | wxString value = m_toText->GetValue(); |
394 | if (value.ToLong( &res )) | |
395 | m_printDialogData.SetToPage( res ); | |
396 | } | |
7bcb11d3 | 397 | } |
59e2b19f KB |
398 | if(m_rangeRadioBox) |
399 | { | |
400 | if (m_rangeRadioBox->GetSelection() == 0) | |
ca65c044 | 401 | m_printDialogData.SetAllPages(true); |
59e2b19f | 402 | else |
ca65c044 | 403 | m_printDialogData.SetAllPages(false); |
59e2b19f | 404 | } |
7bcb11d3 JS |
405 | } |
406 | else | |
407 | { // continuous printing | |
408 | m_printDialogData.SetFromPage(1); | |
409 | m_printDialogData.SetToPage(32000); | |
410 | } | |
ca65c044 | 411 | |
92980e90 RR |
412 | wxString value = m_noCopiesText->GetValue(); |
413 | if (value.ToLong( &res )) | |
414 | m_printDialogData.SetNoCopies( res ); | |
ca65c044 | 415 | |
7bcb11d3 | 416 | m_printDialogData.SetPrintToFile(m_printToFileCheckBox->GetValue()); |
c801d85f | 417 | |
ca65c044 | 418 | return true; |
c801d85f KB |
419 | } |
420 | ||
421 | /* | |
7bcb11d3 JS |
422 | TODO: collate and noCopies should be duplicated across dialog data and print data objects |
423 | (slightly different semantics on Windows but let's ignore this for a bit). | |
424 | */ | |
c801d85f | 425 | |
7bcb11d3 | 426 | wxDC *wxGenericPrintDialog::GetPrintDC() |
c801d85f | 427 | { |
6038ec8e | 428 | return new wxPostScriptDC(GetPrintDialogData().GetPrintData()); |
7bcb11d3 | 429 | } |
c801d85f | 430 | |
8826f46f VZ |
431 | // ---------------------------------------------------------------------------- |
432 | // Generic print setup dialog | |
433 | // ---------------------------------------------------------------------------- | |
c801d85f | 434 | |
8850cbd3 RR |
435 | IMPLEMENT_CLASS(wxGenericPrintSetupDialog, wxDialog) |
436 | ||
7bcb11d3 | 437 | wxGenericPrintSetupDialog::wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data): |
ca65c044 | 438 | wxDialog(parent, wxID_ANY, _("Print Setup"), wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL) |
7bcb11d3 JS |
439 | { |
440 | Init(data); | |
441 | } | |
c801d85f | 442 | |
7bcb11d3 JS |
443 | void wxGenericPrintSetupDialog::Init(wxPrintData* data) |
444 | { | |
445 | if ( data ) | |
446 | m_printData = *data; | |
9838df2c | 447 | |
8826f46f | 448 | |
6038ec8e | 449 | wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); |
8826f46f | 450 | |
6038ec8e RR |
451 | wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL ); |
452 | main_sizer->Add( item1, 0, wxALL, 5 ); | |
8826f46f | 453 | |
6038ec8e | 454 | // printer options (on the left) |
8826f46f | 455 | |
6038ec8e | 456 | wxBoxSizer *item2 = new wxBoxSizer( wxVERTICAL ); |
8826f46f | 457 | |
6038ec8e RR |
458 | wxStaticBox *item4 = new wxStaticBox( this, wxPRINTID_STATIC, _("Paper size") ); |
459 | wxStaticBoxSizer *item3 = new wxStaticBoxSizer( item4, wxVERTICAL ); | |
8826f46f | 460 | |
6038ec8e RR |
461 | m_paperTypeChoice = CreatePaperTypeChoice(); |
462 | item3->Add( m_paperTypeChoice, 0, wxALIGN_CENTER|wxALL, 5 ); | |
8826f46f | 463 | |
6038ec8e RR |
464 | item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 ); |
465 | ||
466 | wxString strs6[] = | |
467 | { | |
468 | _("Portrait"), | |
469 | _("Landscape") | |
470 | }; | |
471 | m_orientationRadioBox= new wxRadioBox( this, wxPRINTID_ORIENTATION, _("Orientation"), wxDefaultPosition, wxDefaultSize, 2, strs6, 1, wxRA_SPECIFY_ROWS ); | |
472 | item2->Add( m_orientationRadioBox, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
8826f46f | 473 | |
6038ec8e RR |
474 | wxStaticBox *item8 = new wxStaticBox( this, -1, _("Options") ); |
475 | wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxHORIZONTAL ); | |
c801d85f | 476 | |
6038ec8e RR |
477 | m_colourCheckBox = new wxCheckBox( this, wxPRINTID_PRINTCOLOUR, _("Print in colour") ); |
478 | item7->Add( m_colourCheckBox, 0, wxALIGN_CENTER|wxALL, 5 ); | |
8826f46f | 479 | |
6038ec8e | 480 | item2->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
8826f46f | 481 | |
6038ec8e | 482 | item1->Add( item2, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); |
8826f46f | 483 | |
6038ec8e | 484 | // spooling options (on the right) |
8826f46f | 485 | |
6038ec8e RR |
486 | wxStaticBox *item11 = new wxStaticBox( this, -1, _("Print spooling") ); |
487 | wxStaticBoxSizer *item10 = new wxStaticBoxSizer( item11, wxVERTICAL ); | |
8826f46f | 488 | |
6038ec8e RR |
489 | wxStaticText *item12 = new wxStaticText( this, -1, _("Printer command:") ); |
490 | item10->Add( item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
491 | ||
492 | wxBoxSizer *item13 = new wxBoxSizer( wxHORIZONTAL ); | |
493 | ||
494 | item13->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 ); | |
495 | ||
496 | m_printerCommandText = new wxTextCtrl( this, wxPRINTID_COMMAND, wxT(""), wxDefaultPosition, wxSize(160,-1) ); | |
497 | item13->Add( m_printerCommandText, 0, wxALIGN_CENTER|wxALL, 5 ); | |
498 | ||
499 | item10->Add( item13, 0, wxALIGN_CENTER|wxALL, 0 ); | |
500 | ||
501 | wxStaticText *item15 = new wxStaticText( this, -1, _("Printer options:") ); | |
502 | item10->Add( item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
503 | ||
504 | wxBoxSizer *item16 = new wxBoxSizer( wxHORIZONTAL ); | |
505 | ||
506 | item16->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 ); | |
507 | ||
508 | m_printerOptionsText = new wxTextCtrl( this, wxPRINTID_OPTIONS, wxT(""), wxDefaultPosition, wxSize(160,-1) ); | |
509 | item16->Add( m_printerOptionsText, 0, wxALIGN_CENTER|wxALL, 5 ); | |
510 | ||
511 | item10->Add( item16, 0, wxALIGN_CENTER|wxALL, 0 ); | |
512 | ||
513 | item1->Add( item10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); | |
514 | ||
515 | ||
516 | #if wxUSE_STATLINE | |
517 | // static line | |
518 | main_sizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); | |
519 | #endif | |
520 | ||
521 | // buttons | |
522 | ||
523 | main_sizer->Add( CreateButtonSizer( wxOK|wxCANCEL), 0, wxCENTER|wxALL, 10 ); | |
524 | ||
525 | SetAutoLayout( true ); | |
526 | SetSizer( main_sizer ); | |
527 | ||
528 | main_sizer->Fit( this ); | |
529 | Centre(wxBOTH); | |
8826f46f | 530 | |
ca65c044 | 531 | |
7bcb11d3 JS |
532 | Fit(); |
533 | Centre(wxBOTH); | |
8826f46f | 534 | |
7bcb11d3 | 535 | InitDialog(); |
c801d85f KB |
536 | } |
537 | ||
7bcb11d3 | 538 | wxGenericPrintSetupDialog::~wxGenericPrintSetupDialog() |
c801d85f KB |
539 | { |
540 | } | |
541 | ||
7bcb11d3 | 542 | bool wxGenericPrintSetupDialog::TransferDataToWindow() |
c801d85f | 543 | { |
8850cbd3 RR |
544 | wxPostScriptPrintNativeData *data = |
545 | (wxPostScriptPrintNativeData *) m_printData.GetNativeData(); | |
546 | ||
547 | if (m_printerCommandText && data->GetPrinterCommand()) | |
548 | m_printerCommandText->SetValue(data->GetPrinterCommand()); | |
549 | if (m_printerOptionsText && data->GetPrinterOptions()) | |
550 | m_printerOptionsText->SetValue(data->GetPrinterOptions()); | |
7bcb11d3 JS |
551 | if (m_colourCheckBox) |
552 | m_colourCheckBox->SetValue(m_printData.GetColour()); | |
8826f46f | 553 | |
7bcb11d3 JS |
554 | if (m_orientationRadioBox) |
555 | { | |
556 | if (m_printData.GetOrientation() == wxPORTRAIT) | |
557 | m_orientationRadioBox->SetSelection(0); | |
558 | else | |
559 | m_orientationRadioBox->SetSelection(1); | |
560 | } | |
ca65c044 | 561 | return true; |
c801d85f KB |
562 | } |
563 | ||
7bcb11d3 | 564 | bool wxGenericPrintSetupDialog::TransferDataFromWindow() |
c801d85f | 565 | { |
8850cbd3 RR |
566 | wxPostScriptPrintNativeData *data = |
567 | (wxPostScriptPrintNativeData *) m_printData.GetNativeData(); | |
568 | ||
7bcb11d3 | 569 | if (m_printerCommandText) |
8850cbd3 | 570 | data->SetPrinterCommand(m_printerCommandText->GetValue()); |
7bcb11d3 | 571 | if (m_printerOptionsText) |
8850cbd3 | 572 | data->SetPrinterOptions(m_printerOptionsText->GetValue()); |
7bcb11d3 JS |
573 | if (m_colourCheckBox) |
574 | m_printData.SetColour(m_colourCheckBox->GetValue()); | |
575 | if (m_orientationRadioBox) | |
576 | { | |
577 | int sel = m_orientationRadioBox->GetSelection(); | |
578 | if (sel == 0) | |
579 | m_printData.SetOrientation(wxPORTRAIT); | |
580 | else | |
581 | m_printData.SetOrientation(wxLANDSCAPE); | |
582 | } | |
583 | if (m_paperTypeChoice) | |
584 | { | |
17dd9caa VZ |
585 | int selectedItem = m_paperTypeChoice->GetSelection(); |
586 | if (selectedItem != -1) | |
587 | { | |
222ed1d6 | 588 | wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(selectedItem); |
17dd9caa VZ |
589 | if (paper != NULL) |
590 | m_printData.SetPaperId( paper->GetId()); | |
591 | } | |
7bcb11d3 JS |
592 | } |
593 | ||
ca65c044 | 594 | return true; |
c801d85f KB |
595 | } |
596 | ||
6038ec8e | 597 | wxComboBox *wxGenericPrintSetupDialog::CreatePaperTypeChoice() |
c801d85f | 598 | { |
6038ec8e RR |
599 | size_t n = wxThePrintPaperDatabase->GetCount(); |
600 | wxString *choices = new wxString [n]; | |
601 | size_t sel = 0; | |
b1d4dd7a RL |
602 | |
603 | for (size_t i = 0; i < n; i++) | |
7bcb11d3 | 604 | { |
222ed1d6 | 605 | wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(i); |
7bcb11d3 JS |
606 | choices[i] = paper->GetName(); |
607 | if (m_printData.GetPaperId() == paper->GetId()) | |
608 | sel = i; | |
609 | } | |
8826f46f | 610 | |
7bcb11d3 JS |
611 | int width = 250; |
612 | ||
b1d4dd7a RL |
613 | wxComboBox *choice = new wxComboBox( this, |
614 | wxPRINTID_PAPERSIZE, | |
615 | _("Paper Size"), | |
6038ec8e | 616 | wxDefaultPosition, |
422d0ff0 | 617 | wxSize(width, wxDefaultCoord), |
b1d4dd7a | 618 | n, choices ); |
7bcb11d3 | 619 | |
7bcb11d3 | 620 | delete[] choices; |
8826f46f | 621 | |
7bcb11d3 JS |
622 | choice->SetSelection(sel); |
623 | return choice; | |
c801d85f | 624 | } |
6038ec8e | 625 | |
8826f46f | 626 | #endif // wxUSE_POSTSCRIPT |
c801d85f | 627 | |
8826f46f VZ |
628 | // ---------------------------------------------------------------------------- |
629 | // Generic page setup dialog | |
630 | // ---------------------------------------------------------------------------- | |
c801d85f | 631 | |
8850cbd3 RR |
632 | IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxDialog) |
633 | ||
634 | BEGIN_EVENT_TABLE(wxGenericPageSetupDialog, wxDialog) | |
635 | EVT_BUTTON(wxPRINTID_SETUP, wxGenericPageSetupDialog::OnPrinter) | |
636 | END_EVENT_TABLE() | |
637 | ||
c801d85f KB |
638 | void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event)) |
639 | { | |
9838df2c JS |
640 | // We no longer query GetPrintMode, so we can eliminate the need |
641 | // to call SetPrintMode. | |
642 | // This has the limitation that we can't explicitly call the PostScript | |
643 | // print setup dialog from the generic Page Setup dialog under Windows, | |
644 | // but since this choice would only happen when trying to do PostScript | |
645 | // printing under Windows (and only in 16-bit Windows which | |
646 | // doesn't have a Windows-specific page setup dialog) it's worth it. | |
647 | ||
7bcb11d3 JS |
648 | // First save the current settings, so the wxPrintData object is up to date. |
649 | TransferDataFromWindow(); | |
650 | ||
651 | // Transfer the current print settings from this dialog to the page setup dialog. | |
652 | wxPrintDialogData data; | |
653 | data = GetPageSetupData().GetPrintData(); | |
ca65c044 | 654 | data.SetSetupDialog(true); |
c061373d RR |
655 | wxPrintDialog printDialog(this, & data); |
656 | printDialog.ShowModal(); | |
9838df2c | 657 | |
7bcb11d3 JS |
658 | // Transfer the page setup print settings from the page dialog to this dialog again, in case |
659 | // the page setup dialog changed something. | |
c061373d | 660 | GetPageSetupData().GetPrintData() = printDialog.GetPrintDialogData().GetPrintData(); |
7bcb11d3 JS |
661 | GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData |
662 | ||
7bcb11d3 JS |
663 | // Now update the dialog in case the page setup dialog changed some of our settings. |
664 | TransferDataToWindow(); | |
c801d85f KB |
665 | } |
666 | ||
b1d4dd7a RL |
667 | wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow *parent, |
668 | wxPageSetupData* data) | |
669 | : wxDialog( parent, | |
ca65c044 | 670 | wxID_ANY, |
b1d4dd7a RL |
671 | _("Page Setup"), |
672 | wxPoint(0, 0), | |
673 | wxSize(600, 600), | |
2a21ac15 | 674 | wxDEFAULT_DIALOG_STYLE|wxTAB_TRAVERSAL ) |
c801d85f | 675 | { |
27ea1d8a | 676 | if (data) |
7bcb11d3 | 677 | m_pageData = *data; |
b1d4dd7a | 678 | |
27ea1d8a | 679 | int textWidth = 80; |
b1d4dd7a | 680 | |
27ea1d8a | 681 | wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); |
b1d4dd7a | 682 | |
27ea1d8a | 683 | // 1) top |
ca65c044 | 684 | wxStaticBoxSizer *topsizer = new wxStaticBoxSizer( |
27ea1d8a | 685 | new wxStaticBox(this,wxPRINTID_STATIC, _("Paper size")), wxHORIZONTAL ); |
b1d4dd7a RL |
686 | |
687 | size_t n = wxThePrintPaperDatabase->GetCount(); | |
688 | wxString *choices = new wxString [n]; | |
689 | ||
690 | for (size_t i = 0; i < n; i++) | |
27ea1d8a | 691 | { |
222ed1d6 | 692 | wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(i); |
27ea1d8a RR |
693 | choices[i] = paper->GetName(); |
694 | } | |
8826f46f | 695 | |
b1d4dd7a RL |
696 | m_paperTypeChoice = new wxComboBox( this, |
697 | wxPRINTID_PAPERSIZE, | |
698 | _("Paper Size"), | |
699 | wxDefaultPosition, | |
422d0ff0 | 700 | wxSize(300, wxDefaultCoord), |
b1d4dd7a | 701 | n, choices ); |
27ea1d8a RR |
702 | topsizer->Add( m_paperTypeChoice, 1, wxEXPAND|wxALL, 5 ); |
703 | // m_paperTypeChoice->SetSelection(sel); | |
8826f46f | 704 | |
27ea1d8a | 705 | mainsizer->Add( topsizer, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 ); |
8826f46f | 706 | |
27ea1d8a | 707 | // 2) middle sizer with radio box |
8826f46f | 708 | |
27ea1d8a RR |
709 | wxString *choices2 = new wxString[2]; |
710 | choices2[0] = _("Portrait"); | |
711 | choices2[1] = _("Landscape"); | |
7bcb11d3 | 712 | m_orientationRadioBox = new wxRadioBox(this, wxPRINTID_ORIENTATION, _("Orientation"), |
27ea1d8a | 713 | wxDefaultPosition, wxDefaultSize, 2, choices2, 2); |
7bcb11d3 | 714 | m_orientationRadioBox->SetSelection(0); |
8826f46f | 715 | |
27ea1d8a | 716 | mainsizer->Add( m_orientationRadioBox, 0, wxTOP|wxLEFT|wxRIGHT, 10 ); |
8826f46f | 717 | |
27ea1d8a | 718 | // 3) margins |
8826f46f | 719 | |
27ea1d8a | 720 | wxBoxSizer *table = new wxBoxSizer( wxHORIZONTAL ); |
8826f46f | 721 | |
27ea1d8a RR |
722 | wxBoxSizer *column1 = new wxBoxSizer( wxVERTICAL ); |
723 | column1->Add( new wxStaticText(this, wxPRINTID_STATIC, _("Left margin (mm):")),1,wxALL|wxALIGN_RIGHT,5 ); | |
724 | column1->Add( new wxStaticText(this, wxPRINTID_STATIC, _("Top margin (mm):")),1,wxALL|wxALIGN_RIGHT,5 ); | |
725 | table->Add( column1, 0, wxALL | wxEXPAND, 5 ); | |
ca65c044 | 726 | |
27ea1d8a | 727 | wxBoxSizer *column2 = new wxBoxSizer( wxVERTICAL ); |
422d0ff0 WS |
728 | m_marginLeftText = new wxTextCtrl(this, wxPRINTID_LEFTMARGIN, wxEmptyString, wxDefaultPosition, wxSize(textWidth, wxDefaultCoord)); |
729 | m_marginTopText = new wxTextCtrl(this, wxPRINTID_TOPMARGIN, wxEmptyString, wxDefaultPosition, wxSize(textWidth, wxDefaultCoord)); | |
27ea1d8a RR |
730 | column2->Add( m_marginLeftText, 1, wxALL, 5 ); |
731 | column2->Add( m_marginTopText, 1, wxALL, 5 ); | |
732 | table->Add( column2, 0, wxRIGHT|wxTOP|wxBOTTOM | wxEXPAND, 5 ); | |
ca65c044 | 733 | |
27ea1d8a RR |
734 | wxBoxSizer *column3 = new wxBoxSizer( wxVERTICAL ); |
735 | column3->Add( new wxStaticText(this, wxPRINTID_STATIC, _("Right margin (mm):")),1,wxALL|wxALIGN_RIGHT,5 ); | |
736 | column3->Add( new wxStaticText(this, wxPRINTID_STATIC, _("Bottom margin (mm):")),1,wxALL|wxALIGN_RIGHT,5 ); | |
737 | table->Add( column3, 0, wxALL | wxEXPAND, 5 ); | |
ca65c044 | 738 | |
27ea1d8a | 739 | wxBoxSizer *column4 = new wxBoxSizer( wxVERTICAL ); |
422d0ff0 WS |
740 | m_marginRightText = new wxTextCtrl(this, wxPRINTID_RIGHTMARGIN, wxEmptyString, wxDefaultPosition, wxSize(textWidth, wxDefaultCoord)); |
741 | m_marginBottomText = new wxTextCtrl(this, wxPRINTID_BOTTOMMARGIN, wxEmptyString, wxDefaultPosition, wxSize(textWidth, wxDefaultCoord)); | |
27ea1d8a RR |
742 | column4->Add( m_marginRightText, 1, wxALL, 5 ); |
743 | column4->Add( m_marginBottomText, 1, wxALL, 5 ); | |
744 | table->Add( column4, 0, wxRIGHT|wxTOP|wxBOTTOM | wxEXPAND, 5 ); | |
745 | ||
746 | mainsizer->Add( table, 0 ); | |
747 | ||
748 | #if wxUSE_STATLINE | |
749 | // 5) static line | |
ca65c044 | 750 | mainsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); |
27ea1d8a | 751 | #endif |
8826f46f | 752 | |
27ea1d8a | 753 | // 6) buttons |
ca65c044 | 754 | |
27ea1d8a RR |
755 | wxSizer* buttonsizer = CreateButtonSizer( wxOK|wxCANCEL); |
756 | m_printerButton = new wxButton(this, wxPRINTID_SETUP, _("Printer...") ); | |
757 | buttonsizer->Add( m_printerButton, 0, wxLEFT|wxRIGHT, 10 ); | |
758 | if ( !m_pageData.GetEnablePrinter() ) | |
ca65c044 | 759 | m_printerButton->Enable(false); |
27ea1d8a | 760 | // if (m_printData.GetEnableHelp()) |
422d0ff0 | 761 | // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), wxDefaultCoord, wxDefaultCoord, buttonWidth, buttonHeight); |
27ea1d8a | 762 | mainsizer->Add( buttonsizer, 0, wxCENTER|wxALL, 10 ); |
8826f46f | 763 | |
8826f46f | 764 | |
ca65c044 | 765 | SetAutoLayout( true ); |
27ea1d8a | 766 | SetSizer( mainsizer ); |
8826f46f | 767 | |
27ea1d8a | 768 | mainsizer->Fit( this ); |
7bcb11d3 | 769 | Centre(wxBOTH); |
8826f46f | 770 | |
7bcb11d3 | 771 | InitDialog(); |
ca65c044 | 772 | |
27ea1d8a RR |
773 | delete[] choices; |
774 | delete [] choices2; | |
7bcb11d3 | 775 | } |
9838df2c | 776 | |
7bcb11d3 JS |
777 | wxGenericPageSetupDialog::~wxGenericPageSetupDialog() |
778 | { | |
779 | } | |
c801d85f | 780 | |
7bcb11d3 JS |
781 | bool wxGenericPageSetupDialog::TransferDataToWindow() |
782 | { | |
783 | if (m_marginLeftText) | |
963907fa | 784 | m_marginLeftText->SetValue(wxString::Format(wxT("%d"), m_pageData.GetMarginTopLeft().x)); |
7bcb11d3 | 785 | if (m_marginTopText) |
963907fa | 786 | m_marginTopText->SetValue(wxString::Format(wxT("%d"), m_pageData.GetMarginTopLeft().y)); |
7bcb11d3 | 787 | if (m_marginRightText) |
963907fa | 788 | m_marginRightText->SetValue(wxString::Format(wxT("%d"), m_pageData.GetMarginBottomRight().x)); |
7bcb11d3 | 789 | if (m_marginBottomText) |
963907fa | 790 | m_marginBottomText->SetValue(wxString::Format(wxT("%d"), m_pageData.GetMarginBottomRight().y)); |
8826f46f | 791 | |
7bcb11d3 JS |
792 | if (m_orientationRadioBox) |
793 | { | |
794 | if (m_pageData.GetPrintData().GetOrientation() == wxPORTRAIT) | |
795 | m_orientationRadioBox->SetSelection(0); | |
796 | else | |
797 | m_orientationRadioBox->SetSelection(1); | |
798 | } | |
c801d85f | 799 | |
7bcb11d3 JS |
800 | // Find the paper type from either the current paper size in the wxPageSetupDialogData, or |
801 | // failing that, the id in the wxPrintData object. | |
c801d85f | 802 | |
7bcb11d3 JS |
803 | wxPrintPaperType* type = wxThePrintPaperDatabase->FindPaperType( |
804 | wxSize(m_pageData.GetPaperSize().x * 10, m_pageData.GetPaperSize().y * 10)); | |
c801d85f | 805 | |
7bcb11d3 JS |
806 | if (!type && m_pageData.GetPrintData().GetPaperId() != wxPAPER_NONE) |
807 | type = wxThePrintPaperDatabase->FindPaperType(m_pageData.GetPrintData().GetPaperId()); | |
c801d85f | 808 | |
7bcb11d3 JS |
809 | if (type) |
810 | { | |
811 | m_paperTypeChoice->SetStringSelection(type->GetName()); | |
812 | } | |
c801d85f | 813 | |
ca65c044 | 814 | return true; |
c801d85f KB |
815 | } |
816 | ||
7bcb11d3 | 817 | bool wxGenericPageSetupDialog::TransferDataFromWindow() |
c801d85f | 818 | { |
7bcb11d3 | 819 | if (m_marginLeftText && m_marginTopText) |
eba33006 RR |
820 | { |
821 | int left = wxAtoi( m_marginLeftText->GetValue().c_str() ); | |
822 | int top = wxAtoi( m_marginTopText->GetValue().c_str() ); | |
823 | m_pageData.SetMarginTopLeft( wxPoint(left,top) ); | |
824 | } | |
7bcb11d3 | 825 | if (m_marginRightText && m_marginBottomText) |
eba33006 RR |
826 | { |
827 | int right = wxAtoi( m_marginRightText->GetValue().c_str() ); | |
828 | int bottom = wxAtoi( m_marginBottomText->GetValue().c_str() ); | |
829 | m_pageData.SetMarginBottomRight( wxPoint(right,bottom) ); | |
830 | } | |
8826f46f | 831 | |
7bcb11d3 | 832 | if (m_orientationRadioBox) |
c801d85f | 833 | { |
7bcb11d3 JS |
834 | int sel = m_orientationRadioBox->GetSelection(); |
835 | if (sel == 0) | |
836 | { | |
7bcb11d3 JS |
837 | m_pageData.GetPrintData().SetOrientation(wxPORTRAIT); |
838 | } | |
839 | else | |
840 | { | |
7bcb11d3 JS |
841 | m_pageData.GetPrintData().SetOrientation(wxLANDSCAPE); |
842 | } | |
c801d85f | 843 | } |
ca65c044 | 844 | |
7bcb11d3 | 845 | if (m_paperTypeChoice) |
c801d85f | 846 | { |
17dd9caa VZ |
847 | int selectedItem = m_paperTypeChoice->GetSelection(); |
848 | if (selectedItem != -1) | |
c801d85f | 849 | { |
222ed1d6 | 850 | wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(selectedItem); |
7bcb11d3 JS |
851 | if ( paper ) |
852 | { | |
853 | m_pageData.SetPaperSize(wxSize(paper->GetWidth()/10, paper->GetHeight()/10)); | |
854 | m_pageData.GetPrintData().SetPaperId(paper->GetId()); | |
855 | } | |
c801d85f KB |
856 | } |
857 | } | |
8826f46f | 858 | |
ca65c044 | 859 | return true; |
c801d85f KB |
860 | } |
861 | ||
fa12f7e6 | 862 | wxComboBox *wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x, int *y) |
c801d85f | 863 | { |
7bcb11d3 JS |
864 | /* |
865 | if (!wxThePrintPaperDatabase) | |
866 | { | |
867 | wxThePrintPaperDatabase = new wxPrintPaperDatabase; | |
868 | wxThePrintPaperDatabase->CreateDatabase(); | |
869 | } | |
870 | */ | |
871 | ||
b1d4dd7a RL |
872 | size_t n = wxThePrintPaperDatabase->GetCount(); |
873 | wxString *choices = new wxString [n]; | |
874 | ||
875 | for (size_t i = 0; i < n; i++) | |
7bcb11d3 | 876 | { |
222ed1d6 | 877 | wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(i); |
7bcb11d3 JS |
878 | choices[i] = paper->GetName(); |
879 | } | |
8826f46f | 880 | |
7bcb11d3 JS |
881 | (void) new wxStaticText(this, wxPRINTID_STATIC, _("Paper size"), wxPoint(*x, *y)); |
882 | *y += 25; | |
8826f46f | 883 | |
b1d4dd7a RL |
884 | wxComboBox *choice = new wxComboBox( this, |
885 | wxPRINTID_PAPERSIZE, | |
886 | _("Paper Size"), | |
887 | wxPoint(*x, *y), | |
422d0ff0 | 888 | wxSize(300, wxDefaultCoord), |
b1d4dd7a | 889 | n, choices ); |
7bcb11d3 JS |
890 | *y += 35; |
891 | delete[] choices; | |
8826f46f | 892 | |
7bcb11d3 JS |
893 | // choice->SetSelection(sel); |
894 | return choice; | |
c801d85f KB |
895 | } |
896 | ||
ce4169a4 | 897 | #endif |
eba33006 | 898 |