summaryrefslogtreecommitdiff
path: root/support/dktools/WinprintFrame.cpp
blob: ca4d4f56b768dc3354241200f008af7cc0442699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
/*
Copyright (C) 2013-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/

/*
	WARNING: This file was generated by the dkct program (see
	http://dktools.sourceforge.net/ for details).
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: WinprintFrame.wxc
*/

/**	@file WinprintFrame.cpp The WinprintFrame module.
*/


#line 313 "WinprintFrame.wxc"

#include "dk3conf.h"
#include "winprint.h"
#if 0
#include "dkt-version.h"
#endif
#include "dk4verswx.h"
#include "dk4verswx.h"
#include "gui-img/shared/toolbar/run-conversion.xpm"
#include "gui-img/shared/toolbar/exit-program.xpm"


#if !defined(__WXMSW__)
#include "gui-img/icons/winprint.xpm"
#endif





#line 332 "WinprintFrame.wxc"



/*	__CHANGE__ 017: Add further events. */
/*	__CHANGE__ 008: Remove OnIdle if no idle processing required. */

#if	wxCHECK_VERSION(3,0,0)
wxBEGIN_EVENT_TABLE(WinprintFrame,wxFrame)
#else
BEGIN_EVENT_TABLE(WinprintFrame,wxFrame)
#endif
	EVT_MENU(WinprintFrame_Quit, WinprintFrame::OnQuit)
	EVT_MENU(WinprintFrame_Print, WinprintFrame::OnPrint)
	EVT_MENU(WinprintFrame_Help_About, WinprintFrame::OnAbout)
	EVT_MENU(WinprintFrame_Help_Contents, WinprintFrame::OnHelpContents)
	EVT_IDLE(WinprintFrame::OnIdle)
#if	wxCHECK_VERSION(3,0,0)
wxEND_EVENT_TABLE()
#else
END_EVENT_TABLE()
#endif



#if __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif

static const wxCmdLineEntryDesc winprint_cmd_line_desc[] = {
  {
    wxCMD_LINE_OPTION,
    wxT_2("P"),
    wxT_2("printer"),
    wxT_2("choose printer"),
    wxCMD_LINE_VAL_STRING
  },
  {
    wxCMD_LINE_SWITCH,
    wxT_2("d"),
    wxT_2("default"),
    wxT_2("Use default printer")
  },
  {
    wxCMD_LINE_PARAM,
    NULL,
    NULL,
    wxT_2("input file"),
    wxCMD_LINE_VAL_STRING,
    wxCMD_LINE_PARAM_OPTIONAL
  },
  { wxCMD_LINE_NONE }
};

#if __GNUC__
#pragma GCC diagnostic pop
#endif



#line 392 "WinprintFrame.wxc"
WinprintFrame::WinprintFrame(
  int			  wxid,
  DkWxAppHelper		 *applicationHelper,
  DkWxHelpController	 *hc,
  int			  argc,
  wxChar		**argv,
  wxChar const * const	 *localizedTexts,
  wxChar const * const	 *nlWx,
  dkChar const * const	 *nlDk,
  dk3_print_conf_t	 *pPrintConf,
  DK3_PCWXCHAR		 *printerNames,
  size_t		  numberOfPrinters,
  int			  defaultPrinterIndex
) : DkWxFrame(nlWx[0], applicationHelper, hc, wxid),
    cBlack(0, 0, 0),
    cGreen(0, 127, 0),
    cRed(127, 0, 0)
{
  /*	__CHANGE__ 012:	Add further local variables.
  */
  size_t	i;	/* Traverse pNames when creating wxsNames. */

  /*	__CHANGE__ 012: Initialize further local variables.
  */
  fdx = -1; fdy = -1;
  pcx = -1; pcy = -1;
  wxsNames = NULL;
  pNames = printerNames;
  nNames = numberOfPrinters;
  nDefPrinter = defaultPrinterIndex;
  pComm = NULL;
  bCloseScheduled = false;
  bAutostartWanted = false;
  timeClose = (dk3_time_t)0UL;
  sNamedFile = NULL;
  sNamedPrinter = NULL;
  bUseDefaultPrinter = false;
  sTexts = localizedTexts;
  sNlWx  = nlWx;
  sNlDk  = nlDk;
  pc = pPrintConf;
#if defined(__WXMSW__)
  wxIcon	winprint_icon(sNlWx[4]);
#else
  wxIcon	winprint_icon(winprint_xpm);
#endif
  /*	__CHANGE__ 011:	Initialize further class members.
  */
  dkctGUILayoutOK = false;
  dkctGUIContentsPanel = NULL;
  mainSizer = NULL;
  tbMain = NULL;
  mbMain = NULL;
  bRun = NULL;
  bExit = NULL;
  menuFile = NULL;
  menuHelp = NULL;
  miFilePrint = NULL;
  miFileExit = NULL;
  miHelpAbout = NULL;
  miHelpContents = NULL;
  verticalSizer = NULL;
  contentsSizer = NULL;
  tStatus = NULL;
  dkctGUIContentsPanel = new wxPanel(this);
  if(!(dkctGUIContentsPanel)) {
    goto dkctGUILayoutFinished;
  }
#if wxUSE_MENUS
  mbMain = new wxMenuBar(
  );
  if(!(mbMain)) {
    goto dkctGUILayoutFinished;
  }
  menuFile = new wxMenu(
  );
  if(!(menuFile)) {
    goto dkctGUILayoutFinished;
  }
  miFilePrint = menuFile->Append(
    WinprintFrame_Print,
    sTexts[15],
    sTexts[16]
  );
  if(!(miFilePrint)) {
    goto dkctGUILayoutFinished;
  }
  miFileExit = menuFile->Append(
    WinprintFrame_Quit,
    sTexts[1],
    sTexts[2]
  );
  if(!(miFileExit)) {
    goto dkctGUILayoutFinished;
  }
  mbMain->Append(menuFile, sTexts[0]);
  menuHelp = new wxMenu(
  );
  if(!(menuHelp)) {
    goto dkctGUILayoutFinished;
  }
  miHelpAbout = menuHelp->Append(
    WinprintFrame_Help_About,
    sTexts[4],
    sTexts[5]
  );
  if(!(miHelpAbout)) {
    goto dkctGUILayoutFinished;
  }
  miHelpContents = menuHelp->Append(
    WinprintFrame_Help_Contents,
    sTexts[6],
    sTexts[7]
  );
  if(!(miHelpContents)) {
    goto dkctGUILayoutFinished;
  }
  mbMain->Append(menuHelp, sTexts[3]);
  SetMenuBar(mbMain);
#endif
#if wxUSE_TOOLBAR
  tbMain = new wxToolBar(
    this,
    wxID_ANY
  );
  if(!(tbMain)) {
    goto dkctGUILayoutFinished;
  }
  bRun = tbMain->AddTool(
    WinprintFrame_Print,
    sTexts[15],
    xpm_run_conversion,
    wxNullBitmap,
    wxITEM_NORMAL,
    sTexts[16]
  );
  if(!(bRun)) {
    goto dkctGUILayoutFinished;
  }
  bExit = tbMain->AddTool(
    WinprintFrame_Quit,
    sTexts[1],
    xpm_exit_program,
    wxNullBitmap,
    wxITEM_NORMAL,
    sTexts[2]
  );
  if(!(bExit)) {
    goto dkctGUILayoutFinished;
  }
  tbMain->Realize();
  SetToolBar(tbMain);
#endif
  mainSizer = new wxBoxSizer(
    wxHORIZONTAL
  );
  if(!(mainSizer)) {
    goto dkctGUILayoutFinished;
  }
  mainSizer->Add(10, 10, 0);
  verticalSizer = new wxBoxSizer(
    wxVERTICAL
  );
  if(!(verticalSizer)) {
    goto dkctGUILayoutFinished;
  }
  verticalSizer->Add(10, 10, 0);
  contentsSizer = new wxGridBagSizer(
    5, 5
  );
  if(!(contentsSizer)) {
    goto dkctGUILayoutFinished;
  }
  tStatus = new wxStaticText(
    dkctGUIContentsPanel,
    wxID_ANY,
    sTexts[13]
  );
  if(!(tStatus)) {
    goto dkctGUILayoutFinished;
  }
  contentsSizer->Add(
    tStatus,
    wxGBPosition(0, 0),
    wxGBSpan(1, 1),
    wxALIGN_LEFT
  );
  verticalSizer->Add(
    contentsSizer
  );
  verticalSizer->Add(10, 10, 0);
  mainSizer->Add(
    verticalSizer,
    1,
    wxGROW
  );
  mainSizer->Add(10, 10, 0);
  dkctGUIContentsPanel->SetSizer(mainSizer);
  SetIcon(winprint_icon);
  dkctGUILayoutOK = true;
  dkctGUILayoutFinished:
#if wxUSE_STATUSBAR
  if(dkctGUILayoutOK) {
    CreateStatusBar(1);
    SetStatusText(sTexts[8]);
  }
#endif
  if(dkctGUILayoutOK) {
    mainSizer->Fit(this);
    mainSizer->SetSizeHints(this);
  }

#line 441 "WinprintFrame.wxc"
  if(dkctGUILayoutOK) {
    SetTitle(nlWx[0]);
  }
  if((pNames) && (nNames > 0)) {
    wxsNames = new wxString[nNames];
    if(wxsNames) {
      for(i = 0; i < nNames; i++) {
        wxsNames[i] = wxString(pNames[i]);
      }
    }
  }
  pComm = new DkWxCommunicator(
    applicationHelper->getWxEncoding(),
    applicationHelper->getDkEncoding()
  );
  if(argc > 1) {
    bAutostartWanted = true;
    {
      wxChar const	*ptr;
      int		res	= -1;
      wxCmdLineParser parser(winprint_cmd_line_desc, argc, argv);
      {
        wxLogNull log;
	res = parser.Parse(false);
      }
      if(0 == res) {
        wxString	sPrinter(wxT(""));
	if(pComm) {
	  pComm->autostartEnable(true);
	}
	if(parser.Found(wxT("d"))) {
	  /* Use default printer */
	  bUseDefaultPrinter = true;
	} else {
	  if(parser.Found(wxT("P"), &sPrinter)) {
	    /* Use named printer */
	    wxCStrData printerstrdata = sPrinter.c_str();
	    ptr = (wxChar const *)printerstrdata;
	    if(ptr) {
	      if(sNamedPrinter) {
	        dk3_release(sNamedPrinter);
	      }
	      sNamedPrinter = dk3wxs_dup(ptr);
	    }
	  }
	}
	if(parser.GetParamCount() > 0) {
	  wxString	cmdfn;
	  wxString	fullPath;
	  /* Print named file(s) */
	  cmdfn = parser.GetParam(0);
	  wxFileName fn(cmdfn);
	  fn.Normalize(
	    wxPATH_NORM_LONG | wxPATH_NORM_DOTS
	    | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE
	  );
	  fullPath = fn.GetFullPath();
	  wxCStrData fullpathstrdata = fullPath.c_str();
	  ptr = (wxChar const *)fullpathstrdata;
	  if(ptr) {
	    if(sNamedFile) {
	      dk3_release(sNamedFile);
	    }
	    sNamedFile = dk3wxs_dup(ptr);
	  }
	}
      }
    }
  }
}




#line 515 "WinprintFrame.wxc"



WinprintFrame::~WinprintFrame()
{
  size_t		i;	/* Index of current string to delete. */
  /*	__CHANGE__ 011:	Release resources allocated by further class members.
  */
  if(wxsNames) {
    for(i = 0; i < nNames; i++) {
      wxsNames[i] = wxString(wxT(""));
    }
    delete [] wxsNames;
  }
  dk3_cpp_release(pComm);
  if(sNamedPrinter) {
    dk3_release(sNamedPrinter);
    sNamedPrinter = NULL;
  }
  if(sNamedFile) {
    dk3_release(sNamedFile);
    sNamedFile = NULL;
  }
}



bool
WinprintFrame::canClose(bool isLast)
{
  bool		back	= true;

  /*	__CHANGE__ 013: Check for unsaved data.
  */

  return back;
}


void
WinprintFrame::OnQuit(wxCommandEvent & event)
{
  Close();
}



void
WinprintFrame::OnAbout(wxCommandEvent & event)
{
  wxString	text(wxT(""));	/* Text to show. */
  wxString	title(wxT(""));	/* Windows title. */

  /* Construct message text. */
  text.Append(sNlWx[0]);
  text.Append(sNlWx[7]);
#if 0
  text.Append(sNlWx[1]);
#else
  text.Append( DKT_VERSION_WX );
#endif
  text.Append(sNlWx[8]);
  text.Append(sTexts[9]);
  text.Append(sNlWx[2]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[8]);
  text.Append(sTexts[11]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[9]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[8]);
  text.Append(sTexts[12]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[10]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[11]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[12]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[13]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[14]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[15]);
  text.Append(sNlWx[8]);
  
  /* Construct dialog box title. */
  title.Append(sTexts[10]);
  title.Append(sNlWx[0]);

  /* Show dialog box. */
  wxMessageBox(text, title, wxOK, this);

  /*	__CHANGE__ 019:	Create better about box.
  */
}



void
WinprintFrame::OnHelpContents(wxCommandEvent & event)
{
  openHelp();
}

/*	__CHANGE__ 017:	Event handlers for further events.
*/

void
WinprintFrame::OnPrint(wxCommandEvent & event)
{
  (void)runJob();
}


/*	__CHANGE__ 014:	Implementation of further methods.
*/


/*	__CHANGE__ 008:	Remove OnIdle if no idle processing required.
*/

void
WinprintFrame::OnIdle(wxIdleEvent & event)
{
  static BOOL firstIdle = true;	/* Flag: First idle event of application. */
  dk3_time_t		  ct;	/* Current time. */
  int			  res;	/* Operation result. */
  

#line 644 "WinprintFrame.wxc"
  /* __CHANGE__
  */
  if(firstIdle) {			

#line 647 "WinprintFrame.wxc"
    firstIdle = false;
    tStatus->SetLabel(wxT(""));
    Refresh();
    Update();
    /* For autostart */
    event.RequestMore();
  } else {				

#line 654 "WinprintFrame.wxc"
    if(!bCloseScheduled) {		

#line 655 "WinprintFrame.wxc"
      if(pComm) {			

#line 656 "WinprintFrame.wxc"
        if((bAutostartWanted) && (pComm->autostartCanRun())) {
	  

#line 658 "WinprintFrame.wxc"
          res = runJob();
	  if(res > 0) {			

#line 660 "WinprintFrame.wxc"
	    event.RequestMore();
	  }
        } else {			

#line 663 "WinprintFrame.wxc"
          if(pComm->autostartIsFinished()) {	

#line 664 "WinprintFrame.wxc"
	    if(!(timeClose)) {			

#line 665 "WinprintFrame.wxc"
	      if(pComm->getLogLevel() > DK3_LL_WARNING) {	

#line 666 "WinprintFrame.wxc"
	        dk3sf_time(&timeClose);		

#line 667 "WinprintFrame.wxc"
	        event.RequestMore();
	        tStatus->SetLabel(sTexts[14]);	

#line 669 "WinprintFrame.wxc"
		tStatus->SetForegroundColour(cGreen);
	        Refresh();
	        Update();
	      } else {
	        tStatus->SetLabel(pComm->getText());	

#line 674 "WinprintFrame.wxc"
		tStatus->SetForegroundColour(cRed);
		Refresh();
		Update();
		wxMessageBox(
		  pComm->getText(), sTexts[29], (wxICON_ERROR | wxOK), this
		);
		dk3sf_time(&timeClose);		

#line 681 "WinprintFrame.wxc"
		event.RequestMore();
	      }
	    }
	  }
	  if(timeClose) {		

#line 686 "WinprintFrame.wxc"
	    dk3sf_time(&ct);
	    if(ct > (timeClose + (dk3_time_t)1UL)) {	

#line 688 "WinprintFrame.wxc"
	      timeClose = (dk3_time_t)0UL;
	      bCloseScheduled = true;
	      Show(false);
	      Close();
	    } else {			

#line 693 "WinprintFrame.wxc"
	      event.RequestMore();
	    }
	  }
        }
      } else {				

#line 698 "WinprintFrame.wxc"
        /* ERROR: No communicator */
	if(timeClose) {
	  dk3sf_time(&ct);
	  if(ct > (timeClose * (dk3_time_t)1UL)) {
	    timeClose = (dk3_time_t)0UL;
	    bCloseScheduled = true;
	    Show(false);
	    Close();
	  } else {
	    event.RequestMore();
	  }
	}
      }
    } else {					

#line 712 "WinprintFrame.wxc"
    }
  }
  event.Skip();
  

#line 716 "WinprintFrame.wxc"
}



int
WinprintFrame::runFileNameJob(wxChar const *filename)
{
  wxChar		 prbuf[512];		/* Printer name system enc */
  wxChar const		*printername	= NULL;	/* Printer name */
  int			 res	= 0;		/* Operation result */
  int			 ok	= 0;		/* Flag: Success */
  int			 back	= 0;		/* Function result */
  

#line 729 "WinprintFrame.wxc"
  if(filename) {				

#line 730 "WinprintFrame.wxc"
    if(bUseDefaultPrinter) {			

#line 731 "WinprintFrame.wxc"
      if(pc) {					

#line 732 "WinprintFrame.wxc"
        if(pc->defPrinter) {			

#line 733 "WinprintFrame.wxc"
	  if((pc->defPrinter->name)) {		

#line 734 "WinprintFrame.wxc"
	    res = dk3wxs_from_dkstr(
	      prbuf,
	      DK3_SIZEOF(prbuf,wxChar),
	      pHelper->getWxEncoding(),
	      (pc->defPrinter)->name,
	      pHelper->getDkEncoding()
	    );
	    if(res) {				

#line 742 "WinprintFrame.wxc"
	      printername = prbuf;
	    } else {				

#line 744 "WinprintFrame.wxc"
	      /* ERROR: Failed to convert printer name! */
	      setErrorStatus(sTexts[24], filename);	

#line 746 "WinprintFrame.wxc"
	    }
	  } else {				

#line 748 "WinprintFrame.wxc"
	    /* ERROR: No default printer name */
	    setErrorStatus(sTexts[25], filename);	

#line 750 "WinprintFrame.wxc"
	  }
	} else {				

#line 752 "WinprintFrame.wxc"
	  /* ERROR: No default printer */
	  setErrorStatus(sTexts[25], filename);	

#line 754 "WinprintFrame.wxc"
	}
      } else {					

#line 756 "WinprintFrame.wxc"
        /* ERROR: No print configuration */
	setErrorStatus(sTexts[26], filename);	

#line 758 "WinprintFrame.wxc"
      }
    } else {					

#line 760 "WinprintFrame.wxc"
      if(sNamedPrinter) {			

#line 761 "WinprintFrame.wxc"
        printername = sNamedPrinter;
      } else {					

#line 763 "WinprintFrame.wxc"
	if((pNames) && (wxsNames) && (nNames > 0)) {	

#line 764 "WinprintFrame.wxc"
	  WinprintChooserDialog dlg(this, sTexts[30], sTexts, wxsNames, nNames);
	  dlg.setCurrentPrinter(nDefPrinter);
	  pHelper->setRelatedPosition(this, &dlg, &pcx, &pcy);
	  if(wxID_OK == dlg.ShowModal()) {		

#line 768 "WinprintFrame.wxc"
	    nDefPrinter = dlg.getCurrentPrinter();
	    if((nDefPrinter >= 0) && (nDefPrinter < (int)nNames)) { 

#line 770 "WinprintFrame.wxc"
	      printername = pNames[nDefPrinter];
	    } else {					

#line 772 "WinprintFrame.wxc"
	      /* BUG: Illegal return value from dialog */
	      setErrorStatus(sTexts[26], filename);	

#line 774 "WinprintFrame.wxc"
	    }
	  } else {					

#line 776 "WinprintFrame.wxc"
	    /* ERROR: Aborted by user */
	    setErrorStatus(sTexts[19], filename);	

#line 778 "WinprintFrame.wxc"
	  }
	  dlg.GetPosition(&pcx, &pcy);
	} else {					

#line 781 "WinprintFrame.wxc"
	  /* ERROR: No printer configuration */
	  setErrorStatus(sTexts[26], filename);		

#line 783 "WinprintFrame.wxc"
	}
      }
    }
  } else {					

#line 787 "WinprintFrame.wxc"
  }
  if((filename) && (printername)) {		

#line 789 "WinprintFrame.wxc"
    /* wxMessageBox(filename, printername); */
    if(pComm) {					

#line 791 "WinprintFrame.wxc"
      DkWxProgressDialog *pd;
      pComm->prepareRun();
      pd = new DkWxProgressDialog(
        (DkWxFrame *)this,
	pComm,
	NULL,
	sTexts[20],
	filename,
	sTexts[21],
	sTexts[22],
	sTexts[23]
      );
      if(pd) {					

#line 804 "WinprintFrame.wxc"
        WinprintThread	*pt;
	pt = new WinprintThread(
	  pComm, sTexts, pHelper, pc, filename, printername
	);
	if(pt) {				

#line 809 "WinprintFrame.wxc"
	  if(wxTHREAD_NO_ERROR == pt->Create()) {	

#line 810 "WinprintFrame.wxc"
	    pt->SetPriority(WXTHREAD_DEFAULT_PRIORITY);
	    pt->Run();
	    pd->chooseModalPosition();
	    pd->ShowModal();
	    ok = 1;
	    if(pComm->getLogLevel() <= DK3_LL_WARNING) {	

#line 816 "WinprintFrame.wxc"
	      /* ERRORS occured */
	      tStatus->SetLabel(pComm->getText());		

#line 818 "WinprintFrame.wxc"
	      tStatus->SetForegroundColour(cRed);
	    } else {						

#line 820 "WinprintFrame.wxc"
	      /* Transfer succeeeded */
	      if(!(bAutostartWanted)) {
	        tStatus->SetLabel(sTexts[37]);		

#line 823 "WinprintFrame.wxc"
		tStatus->SetForegroundColour(cGreen);
	      }
	    }
	    Refresh();
	    Update();
	    back = 1;
	  } else {					

#line 830 "WinprintFrame.wxc"
	    /* ERROR: Create method failed! */
	    setErrorStatus(sTexts[27], filename);	

#line 832 "WinprintFrame.wxc"
	  }
	} else {			

#line 834 "WinprintFrame.wxc"
	  /* ERROR: Failed to create thread */
	  setErrorStatus(sTexts[27], filename);		

#line 836 "WinprintFrame.wxc"
	}
        pd->Destroy();
      } else {				

#line 839 "WinprintFrame.wxc"
        /* ERROR: Failed to create progress dialog */
	setErrorStatus(sTexts[28], filename);		

#line 841 "WinprintFrame.wxc"
      }
    } else {				

#line 843 "WinprintFrame.wxc"
      /* ###### ERROR: No communicator */
    }
  } else {				

#line 846 "WinprintFrame.wxc"
    if(pComm) {
      if(!(filename)) {
      }
      if(!(printername)) {
      }
    } else {
      /* ##### ERROR: No communicator */
    }
  }
  

#line 856 "WinprintFrame.wxc"
  return back;
}



int
WinprintFrame::runJob(void)
{
  wxString		 path;		/* File path. */
  wxChar const		*filename = NULL;	/* File name. */
  int			 back = 0;
  

#line 868 "WinprintFrame.wxc"
  tStatus->SetLabel(sTexts[17]);		

#line 869 "WinprintFrame.wxc"
  tStatus->SetForegroundColour(cBlack);
  Refresh();
  Update();
  if(sNamedFile) {				

#line 873 "WinprintFrame.wxc"
    filename = sNamedFile;
    back = runFileNameJob(filename);
  } else {					

#line 876 "WinprintFrame.wxc"
    wxString s(wxT(""));
    s.Append(wxT("Print files (*.prn)|*.prn"));
    s.Append(wxT("|All files (*.*)|*.*"));
#if wxCHECK_VERSION(2, 9, 0)
    wxFileDialog dlg(this, sTexts[18], wxT("."), wxT(""), s, wxFD_OPEN);
#else
    wxFileDialog dlg(this, sTexts[18], wxT("."), wxT(""), s, wxOPEN);
#endif
    pHelper->setRelatedPosition(this, &dlg, &fdx, &fdy);
    if(wxID_OK == dlg.ShowModal()) {
      path = dlg.GetPath();
      wxCStrData pathstrdata = path.c_str();
      filename = (wxChar const *)pathstrdata;
      if (NULL != filename) {
	back = runFileNameJob(filename);
      }
    } else {
      /* Aborted by user */
      setErrorStatus(sTexts[19], NULL);		

#line 895 "WinprintFrame.wxc"
    }
    dlg.GetPosition(&fdx, &fdy);
  }
  

#line 899 "WinprintFrame.wxc"
  return back;
}



void
WinprintFrame::setErrorStatus(wxChar const *txt, wxChar const *filename)
{
  if(pComm) {
    pComm->prepareRun();
    pComm->addWxText(txt);
    pComm->setLogLevel(DK3_LL_ERROR);
    pComm->setUpdates(((filename) ? filename : wxT("")), 1000);
    pComm->setRunning(0);
  }
  tStatus->SetLabel(txt);
  tStatus->SetForegroundColour(cRed);
  Refresh();
  Update();
}