summaryrefslogtreecommitdiff
path: root/support/dktools/DkWxBmepsFrame.wxc
blob: 1d367de58ab28820c9fb4146638d5c567be63be2 (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
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
%%	options

copyright owner	=	Dirk Krause
copyright year	=	2011-xxxx
license		=	bsd

%%	wx-gui

type		=	frame
menu bar	=	mbMain
contents	=	mainSizer
tool bar	=	tbMain
icon		=	dkicon_bitmap
status bar	=	1 sTexts[3]

[wxToolBar tbMain]
contents	=	bDir
contents	=	bOptions
contents	=	bRun
contents	=	bExit

[wxToolBarToolBase bDir]
text		=	sTexts[4]
bitmap		=	xpm_choose_dir
id		=	DkWxBmeps_ChooseDirectory
tip		=	sTexts[5]

[wxToolBarToolBase bOptions]
text		=	sTexts[6]
bitmap		=	xpm_set_options
id		=	DkWxBmeps_SetOptions
tip		=	sTexts[7]

[wxToolBarToolBase bRun]
text		=	sTexts[8]
bitmap		=	xpm_run_conversion
id		=	DkWxBmeps_Run
tip		=	sTexts[9]

[wxToolBarToolBase bExit]
text		=	sTexts[10]
bitmap		=	xpm_exit_program
id		=	DkWxBmeps_Quit
tip		=	sTexts[11]

[wxMenuBar mbMain]
contents	=	menuFile
contents	=	menuHelp

[wxMenu menuFile]
contents	=	miFileDir
contents	=	miFileOptions
contents	=	miFileRun
contents	=	miFileExit
text		=	sTexts[12]

[wxMenu menuHelp]
contents	=	miHelpContents
contents	=	miHelpAbout
text		=	sTexts[13]

[wxMenuItem miFileDir]
id		=	DkWxBmeps_ChooseDirectory
text		=	sTexts[14]
tip		=	sTexts[15]

[wxMenu miFileOptions]
text		=	sTexts[16]
tip		=	sTexts[17]
contents	=	miFileOptionsSetup
contents	=	miFileOptionsReset

[wxMenuItem miFileOptionsSetup]
id		=	DkWxBmeps_SetOptions
text		=	sTexts[99]
tip		=	sTexts[100]

[wxMenuItem miFileOptionsReset]
id		=	DkWxBmeps_ResetOptions
text		=	sTexts[101]
tip		=	sTexts[102]


[wxMenuItem	miFileRun]
id		=	DkWxBmeps_Run
text		=	sTexts[18]
tip		=	sTexts[19]

[wxMenuItem miFileExit]
id		=	DkWxBmeps_Quit
text		=	sTexts[20]
tip		=	sTexts[21]

[wxMenuItem miHelpContents]
id		=	DkWxBmeps_Help_Contents
text		=	sTexts[22]
tip		=	sTexts[23]

[wxMenuItem miHelpAbout]
id		=	DkWxBmeps_About
text		=	sTexts[24]
tip		=	sTexts[25]

[wxBoxSizer mainSizer]
direction	=	horizontal
contents	=	$space(10)
contents	=	verticalSizer
contents	=	$space(10)

[wxBoxSizer verticalSizer]
direction	=	vertical
grow		=	yes
proportion	=	1
contents	=	$space(10)
contents	=	contentsSizer	left
contents	=	$space(10)
contents	=	tLogmessages	left top
contents	=	$space(10)
contents	=	tStatus		left
contents	=	$space(10)

[wxGridBagSizer contentsSizer]
grid		=	5 5
contents	=	lDirectory		 0  0  1  1	right
contents	=	tDirectory		 .  1  1  1

[wxStaticText lDirectory]
text		=	sTexts[26]

[wxStaticText tDirectory]
text		=	((sDirectory) ? sDirectory : sTexts[27])

[wxTextCtrl tLogmessages]
grow		=	yes
proportion	=	1
size		=	400 60
text style	=	readonly multiline left no-wrap selection
text		=	sTexts[28]

[wxStaticText tStatus]
text		=	sTexts[28]



%%	header start

%%	class start

/**	Top-level frame for the wxbmeps application.
*/
class DkWxBmepsFrame : public DkWxFrame
{
  private:

    /**	Event table.
    */
    DECLARE_EVENT_TABLE()

    void
    findPaperSizes();

  protected:

    /**	Conversion options.
    */
    dk3_bm_eps_options_t	bmeo;

    /**	Timestamp to close the application.
    */
    dk3_time_t			 timeClose;

    /**	Localized texts.
    */
    wxChar const * const	*sTexts;

    /**	Localized dkChar texts.
    */
    dkChar const * const	*msg;

    /**	Directory or file nameto process.
    */
    wxChar const		*sDirectory;

    /**	Communication object for main thread and worker thread.
    */
    DkWxCommunicator		*pComm;

    /**	Color: Black.
    */
    wxColour			*cBlack;

    /**	Color: Green.
    */
    wxColour			*cGreen;

    /**	Color: Red.
    */
    wxColour			*cRed;

    /**	Paper sizes list.
    */
    wxArrayString		*asPaperSizes;

    /**	Paper sizes array.
    */
    dk3_paper_size_t		*paperSizes;

    /**	Number of paper sizes in the array.
    */
    size_t			 nPaperSizes;

    /**	Index of current paper size in asPaperSizes and paperSizes.
    */
    size_t			 currentPaperSize;

    /**	Directory dialog x position.
    */
    int				 ddx;

    /**	Directory dialog y position.
    */
    int				 ddy;

    /**	Options dialog x position.
    */
    int				 odx;
    
    /**	Options dialog y position.
    */
    int				 ody;

    /**	Flag: Save settings when the program exits.
    */
    bool			 bSaveSettings;

    /**	Flag: Command line options require automatic start.
    */
    bool			 bAutostartWanted;

    /**	Flag: Automatic start initialized.
    */
    bool			 bAutostartDone;

    /**	Flag: GUI active.
    */
    bool			 bGuiActive;

    /**	Flag: Close operation scheduled.
    */
    bool			 bCloseScheduled;

    /**	Flag: Setup was checked.
    */
    bool			 bSetupChecked;

%%	class end
  public:

    /**	Constructor.
    	@param	applicationName		Application name.
    	@param	messageTexts		Localized texts.
	@param	ms			Localized texts as dkChar strings.
    	@param	applicationHelper	Application helper.
    	@param	wxid			Window ID.
	@param	hc			Help controller.
	@param	argc			Number of command line arguments.
	@param	argv			Command line arguments array.
    */
    DkWxBmepsFrame(
      wxChar const		*applicationName,
      wxChar const * const	*messageTexts,
      dkChar const * const	*ms,
      DkWxAppHelper		*applicationHelper,
      int				 wxid,
      DkWxHelpController		*hc,
      int				 argc,
      wxChar			**argv
    );

    /**	Destructor.
    */
    ~DkWxBmepsFrame();

    /**	Check whether we can close the window.
    	@param	isLast	Flag: Last top level window.
    */
    bool
    canClose(bool isLast);

    /**	Retrieve data from wxConfig.
    */
    void
    retrieveData();

    /**	Save data to wxConfig.
    */
    void
    saveData();

    /**	Menu event handler for File / Quit.
    	@param	event	Event to process.
    */
    void
    OnQuit(wxCommandEvent& event);

    /**	Menu event handler for File / Directory.
    */
    void
    OnChooseDirectory(wxCommandEvent& event);

    /**	Menu event handler for File / Options / Set.
    */
    void
    OnSetOptions(wxCommandEvent& event);

    /**	Menu event handler for File / Options / Reset.
    */
    void
    OnResetOptions(wxCommandEvent& event);


    /**	Menu event handler to run a conversion.
    */
    void
    OnRunConversion(wxCommandEvent& event);

    /**	Menu event handler to show helpt contents.
    */
    void
    OnHelpContents(wxCommandEvent& event);

    /**	Menu event handler to show version number.
    */
    void
    OnAbout(wxCommandEvent& event);

    /**	Idle event handler
    */
    void
    OnIdle(wxIdleEvent & event);

    /**	Run a conversion.
    */
    void
    runConversion(void);

    /**	Check whether GUI is active.
    	@return	Flag, GUI is active.
    */
    bool
    isGuiActive();

    /**	Check setup.
    	@return	Flag to indicate setup ok or not.
    */
    bool
    checkSetup();
};


%%	header end

%%	module start



#include "wxbmeps.h"

/*
	Icons and bitmaps
*/
#include "dkicon.xpm"
#include "choose-dir.xpm"
#include "exit-program.xpm"
#include "run-conversion.xpm"
#include "set-options.xpm"
#include "dk4verswx.h"



$!trace-include



/**	Start of version information.
*/
static wxChar const wxbmpp_version[] = {
  wxT("wxbmpp (part of dktools-")
};



/**	Version number for version information.
*/
static wxChar const wxbmpp_versnumber[] = {
  DKT_VERSION_WX
};



/**	End of version information.
*/
static wxChar const wxbmpp_versend[] = {
  wxT(")")
};



/**	Setting names for string settings.
*/
wxChar const * const dkwxbmeps_string_setting_names[] = {
$!string-table macro=wxT
#
#  0: Current directory
#
wxbmeps.directory
#
#
#
wxbmeps.paper-size
$!end
};



/**	Setting names for double settings.
*/
wxChar const * const dkwxbmeps_double_setting_names[] = {
$!string-table macro=wxT
wxbmeps.area.w
wxbmeps.area.h
wxbmeps.area.border.left
wxbmeps.area.border.right
wxbmeps.area.border.top
wxbmeps.area.border.bottom
wxbmeps.resolution
$!end
};



/**	Setting names for int settings.
*/
wxChar const * const dkwxbmeps_int_setting_names[] = {
$!string-table macro=wxT
wxbmeps.driver
wxbmeps.mode
wxbmeps.size-mode
wxbmeps.color
wxbmeps.predictor
wxbmeps.image-origin-point
wxbmeps.draft
wxbmeps.duplex
wxbmeps.tumble
wxbmeps.ps-level
wxbmeps.dsc
wxbmeps.dct
wxbmeps.keep-aspect-ratio
wxbmeps.bg.red
wxbmeps.bg.green
wxbmeps.bg.blue
wxbmeps.bg.force
wxbmeps.interpolation
wxbmeps.interpolation-for-jpeg
wxbmeps.make
wxbmeps.reduce-bits-per-component
$!end
};



static const wxCmdLineEntryDesc wxbmepsframe_cmd_line_desc[] = {
  {
    wxCMD_LINE_OPTION,
    wxT_2("l"),
    wxT_2("language"),
    wxT_2("Choose output language"),
    wxCMD_LINE_VAL_STRING
  },
  {
    wxCMD_LINE_SWITCH,
    wxT_2("m"),
    wxT_2("make"),
    wxT_2("Run in make mode")
  },
  {
    wxCMD_LINE_SWITCH,
    wxT_2("r"),
    wxT_2("run"),
    wxT_2("Run immediately")
  },
  {
    wxCMD_LINE_PARAM,
    NULL,
    NULL,
    wxT_2("input file"),
    wxCMD_LINE_VAL_STRING,
    wxCMD_LINE_PARAM_OPTIONAL
  },
  { wxCMD_LINE_NONE }
};


/**	Event table for the DkWxBmepsFrame class.
*/
BEGIN_EVENT_TABLE(DkWxBmepsFrame, wxFrame)
    EVT_MENU(DkWxBmeps_Quit,  DkWxBmepsFrame::OnQuit)
    EVT_MENU(DkWxBmeps_Help_Contents, DkWxBmepsFrame::OnHelpContents)
    EVT_MENU(DkWxBmeps_About, DkWxBmepsFrame::OnAbout)
    EVT_MENU(DkWxBmeps_ChooseDirectory, DkWxBmepsFrame::OnChooseDirectory)
    EVT_MENU(DkWxBmeps_SetOptions, DkWxBmepsFrame::OnSetOptions)
    EVT_MENU(DkWxBmeps_ResetOptions, DkWxBmepsFrame::OnResetOptions)
    EVT_MENU(DkWxBmeps_Run, DkWxBmepsFrame::OnRunConversion)
    EVT_IDLE(DkWxBmepsFrame::OnIdle)
END_EVENT_TABLE()



%%	constructor start
DkWxBmepsFrame::DkWxBmepsFrame(
  wxChar const		*applicationName,
  wxChar const * const	*messageTexts,
  dkChar const * const	*m,
  DkWxAppHelper		*applicationHelper,
  int			 wxid,
  DkWxHelpController	*hc,
  int			 argc,
  wxChar 		**argv
) : DkWxFrame(applicationName, applicationHelper, hc, wxid)
{
#if defined(__WXMSW__)
  wxIcon	dkicon_bitmap(wxT("aaaaa"));	/* from resource file */
#else
  wxIcon	dkicon_bitmap(xpm_dkicon);	/* from included xpm */
#endif
  $? "+ DkWxBmepsFrame::DkWxBmepsFrame %d", argc
  ddx = -1;
  ddy = -1;
  odx = -1;
  ody = -1;
  pComm = NULL;
  timeClose = (dk3_time_t)0UL;
  bSetupChecked = false;
  sTexts = messageTexts;
  msg = m;
  bSaveSettings = true;
  bGuiActive = true;
  bCloseScheduled = false;
  bAutostartWanted = false;
  bAutostartDone = false;
  sDirectory = NULL;
  cBlack = NULL;
  cGreen = NULL;
  cRed   = NULL;
  dk3bmeo_init(&bmeo);
  bmeo.app = applicationHelper->getApp();
  dk3bmeo_apply_preferences(&bmeo);
  asPaperSizes = new wxArrayString();
  paperSizes = NULL;
  nPaperSizes = 0;
  currentPaperSize = 0;
  findPaperSizes();
  retrieveData();
%%	constructor end
  pComm = new DkWxCommunicator(
    applicationHelper->getWxEncoding(),
    applicationHelper->getDkEncoding()
  );
  cBlack = new wxColour(0x00, 0x00, 0x00);
  cGreen = new wxColour(0x00, 0x7F, 0x00);
  cRed   = new wxColour(0x7F, 0x00, 0x00);
  if(argc > 1) {	/* Any option or argument, no persistent settings. */
    bSaveSettings = false;
    dk3bmeo_init(&bmeo);
#if VERSION_BEFORE_20131020
    bAutostartWanted = true;
    if(pComm) {		$? ". enable autostart"
      pComm->autostartEnable(true);
    }
#endif
    /* ##### Process command line arguments. */
    {
      int res = -1;
      wxCmdLineParser parser(wxbmepsframe_cmd_line_desc, argc, argv);
      {
        wxLogNull log;
	res = parser.Parse(false);
      }
      if(res == 0) {
        wxString	sLanguage(wxT(""));
	dkChar		bu[1024];
	wxChar const	*ptr;
	if(parser.Found(wxT("r"))) {
	  bAutostartWanted = true;
	  if(pComm) {	$? ". enable autostart"
	    pComm->autostartEnable(true);
	  }
	}
	if(parser.Found(wxT("m"))) {
	  bmeo.make = 1;
	}
	if(parser.Found(wxT("l"), &sLanguage)) {
	  ptr = sLanguage.c_str();
	  if(ptr) {
	    if(applicationHelper->wxToDk(bu, DK3_SIZEOF(bu,dkChar), ptr)) {
	      (void)dk3bmeo_set_language(
	        &bmeo, bu, applicationHelper->getApp()
	      );
	    }
	  }
	}
	if(parser.GetParamCount() > 0) {	$? ". parameters available"
	  wxString	cmdfn;
	  wxChar const	*newfn;
	  cmdfn = parser.GetParam(0);
	  wxFileName fn(cmdfn);
	  fn.Normalize(
	    wxPATH_NORM_LONG | wxPATH_NORM_DOTS
	    | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE
	  );
	  if(fn.FileExists()) {
	    bAutostartWanted = true;
	    if(pComm) {	$? ". enable autostart"
	      pComm->autostartEnable(true);
	    }
	  }
	  cmdfn = fn.GetFullPath();
	  newfn = cmdfn.c_str();
	  if(newfn) {				$? ". newfn (1)"
	    newfn = dk3wxs_dup_app(newfn, applicationHelper->getApp());
	    if(newfn) {				$? ". newfn (2)"
	      dk3_release(sDirectory);
	      sDirectory = newfn;
	    } else {				$? "! newfn (2)"
	    }
	  } else {				$? "! newfn (1)"
	  }
	} else {				$? ". no parameters"
	}
      }
    }
    /* (void)dk3bmeo_check(&bmeo, 0, applicationHelper->getApp(), NULL); */
  }
  $? ". sDirectory  = \"%ls\"", sDirectory
  $? ". make        = %d", bmeo.make
  $? ". driver      = %d", bmeo.dr
  $? ". mode        = %d", bmeo.mode
  $? ". ps level    = %d", bmeo.psl
  $? ". dsc         = %d", bmeo.dsc
  $? ". draft       = %d", bmeo.draft
  $? ". szmode      = %d", bmeo.szmode
  $? ". resolution  = %lg", bmeo.resolution
  $? ". area        = %lg %lg", bmeo.ima.ps.w, bmeo.ima.ps.h
  $? ". keep aspect = %d", bmeo.kar
  $? ". duplex      = %d", bmeo.duplex
  $? ". tumble      = %d", bmeo.tumble
  $? ". origin      = %d", bmeo.io
  $? ". dct         = %d", bmeo.dct
  $? ". predicotr   = %d", bmeo.pred
  $? ". background  = %d %d %d %d", bmeo.bgr, bmeo.bgg, bmeo.bgb, bmeo.fbg
  $? ". interpolate = %d %d", bmeo.ip, bmeo.jip
#if 0
  restorePosition();
#endif
  $? "- DkWxBmepsFrame::DkWxBmepsFrame"
}

%%	module end


DkWxBmepsFrame::~DkWxBmepsFrame()
{
  $? "+ DkWxBmepsFrame::~DkWxBmepsFrame"
  dk3_release(paperSizes);
  dk3_release(sDirectory);
  dk3_cpp_release(pComm);
  dk3_cpp_release(cBlack);
  dk3_cpp_release(cGreen);
  dk3_cpp_release(cRed);
  dk3_cpp_release(asPaperSizes);
  $? "- DkWxBmepsFrame::~DkWxBmepsFrame"
}



void
DkWxBmepsFrame::saveData()
{
  double d[7];
  int i[21];
  $? "+ DkWxBmepsFrame::saveData"
  d[0] = bmeo.ima.ps.w;
  d[1] = bmeo.ima.ps.h;
  d[2] = bmeo.ima.ps.i;
  d[3] = bmeo.ima.ps.o;
  d[4] = bmeo.ima.ps.t;
  d[5] = bmeo.ima.ps.b;
  d[6] = bmeo.resolution;
  i[0] = bmeo.dr;
  i[1] = bmeo.mode;
  i[2] = bmeo.szmode;
  /* i[3] = bmeo.color; */
  i[3] = 0;
  i[4] = bmeo.pred;
  i[5] = bmeo.io;
  i[6] = bmeo.draft;
  i[7] = bmeo.duplex;
  i[8] = bmeo.tumble;
  i[9] = bmeo.psl;
  i[10] = bmeo.dsc;
  i[11] = bmeo.dct;
  i[12] = bmeo.kar;
  i[13] = bmeo.bgr;
  i[14] = bmeo.bgg;
  i[15] = bmeo.bgb;
  i[16] = bmeo.fbg;
  i[17] = bmeo.ip;
  i[18] = bmeo.jip;
  i[19] = bmeo.make;
  i[20] = bmeo.rbpc;
  pHelper->saveMultipleDoubles(dkwxbmeps_double_setting_names, d);
  pHelper->saveMultipleInts(dkwxbmeps_int_setting_names, i);
  if(sDirectory) {
    pHelper->saveString(dkwxbmeps_string_setting_names[0], sDirectory);
  }
  pHelper->saveString(
    dkwxbmeps_string_setting_names[1],
    asPaperSizes->Item(currentPaperSize)
  );
  /* ##### */
  $? "- DkWxBmepsFrame::saveData"
}



void
DkWxBmepsFrame::retrieveData()
{
  double d[7];
  int i[21];
  $? "+ DkWxBmepsFrame::retrieveData"
  d[0] = bmeo.ima.ps.w;
  d[1] = bmeo.ima.ps.h;
  d[2] = bmeo.ima.ps.i;
  d[3] = bmeo.ima.ps.o;
  d[4] = bmeo.ima.ps.t;
  d[5] = bmeo.ima.ps.b;
  d[6] = bmeo.resolution;
  i[0] = bmeo.dr;
  i[1] = bmeo.mode;
  i[2] = bmeo.szmode;
  /* i[3] = bmeo.color; */
  i[3] = 0;
  i[4] = bmeo.pred;
  i[5] = bmeo.io;
  i[6] = bmeo.draft;
  i[7] = bmeo.duplex;
  i[8] = bmeo.tumble;
  i[9] = bmeo.psl;
  i[10] = bmeo.dsc;
  i[11] = bmeo.dct;
  i[12] = bmeo.kar;
  i[13] = bmeo.bgr;
  i[14] = bmeo.bgg;
  i[15] = bmeo.bgb;
  i[16] = bmeo.fbg;
  i[17] = bmeo.ip;
  i[18] = bmeo.jip;
  i[19] = bmeo.make;
  i[20] = bmeo.rbpc;
  pHelper->retrieveMultipleDoubles(dkwxbmeps_double_setting_names, d);
  bmeo.ima.ps.w = d[0];
  bmeo.ima.ps.h = d[1];
  bmeo.ima.ps.i = d[2];
  bmeo.ima.ps.o = d[3];
  bmeo.ima.ps.t = d[4];
  bmeo.ima.ps.b = d[5];
  bmeo.resolution = d[6];
  pHelper->retrieveMultipleInts(dkwxbmeps_int_setting_names, i);
  bmeo.dr = i[0];
  bmeo.mode = i[1];
  bmeo.szmode = i[2];	$? ". szmode = %d", bmeo.szmode
  /* bmeo.color = i[3]; */
  bmeo.pred = i[4];
  bmeo.io = i[5];
  bmeo.draft = i[6];
  bmeo.duplex = i[7];
  bmeo.tumble = i[8];
  bmeo.psl = i[9];
  bmeo.dsc = i[10];
  bmeo.dct = i[11];
  bmeo.kar = i[12];
  bmeo.bgr = i[13];
  bmeo.bgg = i[14];
  bmeo.bgb = i[15];
  bmeo.fbg = i[16];
  bmeo.ip = i[17];
  bmeo.jip = i[18];
  bmeo.make = i[19];
  bmeo.rbpc = i[20];
  currentPaperSize = 0;
  sDirectory = pHelper->retrieveString(dkwxbmeps_string_setting_names[0]);
  {
    wxChar const *psn;
    int		  j;
    psn = pHelper->retrieveString(dkwxbmeps_string_setting_names[1]);
    if(psn) {
      j = asPaperSizes->Index(psn);
      if(j != wxNOT_FOUND) {
        currentPaperSize = (size_t)j;
      }
      dk3_release(psn);
    }
  }
  $? "- DkWxBmepsFrame::retrieveData"
  /* ##### */
}



void
DkWxBmepsFrame::runConversion(void)
{
  DkWxProgressDialog	*pd = NULL;
  DkWxBmepsThread	*pt = NULL;
  $? "+ runConversion"
  if(tStatus) {
    tStatus->SetLabel(sTexts[28]);
    if(cBlack) {
      tStatus->SetForegroundColour(*cBlack);
    }
  }
  if(pComm) {
    pComm->prepareRun();
    pd = new DkWxProgressDialog(
      (DkWxFrame *)this,
      pComm,
      tLogmessages,
      sTexts[32],	/* title */
      sTexts[28],	/* file name */
      sTexts[33],	/* button text */
      sTexts[34],	/* button tool tip */
      sTexts[35]	/* wait text */
    );
    if(pd) {
      pt = new DkWxBmepsThread(
	pComm,
	sTexts,
	msg,
	sDirectory,
	pHelper,
	pHelper->getWxEncoding(),
	pHelper->getDkEncoding(),
	&bmeo
      );
      if(pt) {
	if(pt->checkSetup()) {
	  if(pt->Create() == wxTHREAD_NO_ERROR) {
	    pt->SetPriority(WXTHREAD_DEFAULT_PRIORITY);
	    pt->Run();
	    pd->chooseModalPosition();
	    pd->ShowModal();
	    if(pComm->getLogLevel() <= DK3_LL_WARNING) {
	      bGuiActive = true;
	    }
	  } else {			$? "! pt->Create()"
	    delete(pt);
	    /* ##### ERROR: Failed to create new thread! */
	  }
	} else {
	  /* ##### ERROR: Memory! */
	  delete(pt);
	}
      } else {				$? "! pt"
        /* ##### ERROR: Failed to construct new thread! */
      }
      pd->Destroy();
    } else {				$? "! pd"
      /* ##### ERROR: Failed to create progress dialog! */
    }
  } else {				$? "! pComm"
    /* ##### ERROR: Setup incomplete! */
  }
  $? "- runConversion"
}



void
DkWxBmepsFrame::OnIdle(wxIdleEvent & event)
{
  dk3_time_t	ct;	/* Current time. */
  $? "+ DkWxBmepsFrame::OnIdle"
  if(!bCloseScheduled) {
    if(!bSetupChecked) {
      bSetupChecked = true;
      if(!checkSetup()) {
        bCloseScheduled = true;
	/* ##### Show message: Failed to initialize! */
	Show(false);
	Close();
      }
    }
    if(!bCloseScheduled) {			$? ". no close scheduled"
      if(pComm->autostartCanRun()) {		$? ". can autostart"
        runConversion();
      } else {					$? ". can not autostart"
        if(pComm->autostartIsFinished()) {	$? ". autostart finished"
	  if(!(timeClose)) {
	    if(pComm->getLogLevel() > DK3_LL_WARNING) {
	      dk3sf_time(&timeClose);
	      event.RequestMore();
	      tStatus->SetLabel(sTexts[30]);
	      if((cGreen) && (cBlack)) {
	        tStatus->SetForegroundColour(*cGreen);
	      }
	      Refresh();
	      Update();
	    }
	  }
	}
      }
      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();
        }
      }
    }
  }
  $? "- DkWxBmepsFrame::OnIdle"
}



void
DkWxBmepsFrame::OnChooseDirectory(wxCommandEvent& WXUNUSED(event))
{
  wxChar const	*ptr;
  wxChar const	*np;
  $? "+ DkWxBmepsFrame::OnChooseDirectory"
  if(isGuiActive()) {
    wxDirDialog dd(
      this, sTexts[29],
      ((sDirectory) ? sDirectory : wxEmptyString),
      (wxDD_DIR_MUST_EXIST | wxDD_CHANGE_DIR)
    );
    pHelper->setRelatedPosition(this, &dd, &ddx, &ddy);
    if(dd.ShowModal() == wxID_OK) {
      wxString path = dd.GetPath();
      ptr = path.c_str();
      if(ptr) {
        np = dk3wxs_dup_app(ptr, pHelper->getApp());
	if(np) {
	  dk3_release(sDirectory);
	  sDirectory = np;
	  if(tDirectory) {
	    tDirectory->SetLabel(sDirectory);
	    Refresh();
	    Update();
	  }
	}
      }
    }
    dd.GetPosition(&ddx, &ddy);
  } $? "- DkWxBmepsFrame::OnChooseDirectory"
}



void
DkWxBmepsFrame::OnRunConversion(wxCommandEvent& WXUNUSED(event))
{
  $? "+ DkWxBmepsFrame::OnRunConversion"
  if(isGuiActive()) {
    runConversion();
  }
  $? "- DkWxBmepsFrame::OnRunConversion"
}



bool
DkWxBmepsFrame::isGuiActive()
{
  bool back;
  back = bGuiActive;
  $? "+ DkWxBmepsFrame::isGuiActive"
  if(bCloseScheduled) { back = false; }
  $? "- DkWxBmepsFrame::isGuiActive"
  return back;
}



bool
DkWxBmepsFrame::canClose(bool isLast)
{
  $? "+ DkWxBmepsFrame::canClose %d", (isLast ? 1 : 0)
  if(isLast) {
    if(bSaveSettings) {
      saveData();
    }
  } $? "- DkWxBmepsFrame::canClose 1"
  return true;
}



void
DkWxBmepsFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
  $? "+ DkWxBmepsFrame::OnQuit"
  if(isGuiActive()) {
    bCloseScheduled = true;
    Show(false);
    Close();
  }
  $? "- DkWxBmepsFrame::OnQuit"
}



bool
DkWxBmepsFrame::checkSetup()
{
  bool back = false;
  if(pComm) {
    if((cBlack) && (cGreen) && (cRed)) {
      if((asPaperSizes) && (paperSizes)) {
        back = true;
      }
    }
  }
  return back;
}



void
DkWxBmepsFrame::OnSetOptions(wxCommandEvent& WXUNUSED(event))
{
  int		dke;
  int		wxe;
  $? "+ OnSetOptions"
  dke = pHelper->getDkEncoding();
  wxe = pHelper->getWxEncoding();
  if(isGuiActive()) {
    DkWxBmepsOptionsDialog dlg(
      (DkWxBmepsFrame *)this, sTexts[36], sTexts, asPaperSizes,
      &bmeo, paperSizes, &currentPaperSize, pHelper, dke, wxe
    );
    pHelper->setRelatedPosition(this, &dlg, &odx, &ody);
    dlg.dataIn();
    if(dlg.ShowModal() == wxID_OK) {
      dk3mem_cpy(
        (void *)(&(bmeo.ima.ps)),
	(void *)(&(paperSizes[currentPaperSize])),
	sizeof(dk3_paper_size_t)
      );
      $? "%lg %lg %lg %lg %lg %lg", bmeo.ima.ps.w, bmeo.ima.ps.h, bmeo.ima.ps.i, bmeo.ima.ps.o, bmeo.ima.ps.t, bmeo.ima.ps.b
    }
    dlg.GetPosition(&odx, &ody);
  }
  $? "- OnSetOptions"
}



void
DkWxBmepsFrame::OnResetOptions(wxCommandEvent& WXUNUSED(event))
{
  int	res;
  res = wxMessageBox(
    sTexts[103],
    sTexts[104],
    wxNO_DEFAULT|wxYES_NO
  );
  if(res == wxYES) {
    dk3bmeo_init(&bmeo);
  }
}



void
DkWxBmepsFrame::findPaperSizes()
{
  wxChar			 bu[64];
  dk3_paper_size_collection_t	*psc;
  dk3_named_paper_size_t const	*nsz;
  dk3_paper_size_t		*pps;
  dk3_app_t			*app;
  $? "+ DkWxBmepsFrame::findPaperSizes"
  if(asPaperSizes) {				$? ". asPaperSizes ok"
    app = pHelper->getApp();
    psc = dk3paper_open_app(app);
    if(psc) {					$? ". psc ok"
      dk3paper_reset(psc);
      while((nsz = dk3paper_next(psc)) != NULL) {
        if(nsz->name) {
	  if(pHelper->dkToWx(bu, DK3_SIZEOF(bu,wxChar), nsz->name)) {
	    $? ". register \"%!ds\"", nsz->name
	    asPaperSizes->Add(bu);
	    nPaperSizes++;
	  }
	}
      }
      if(nPaperSizes) {		$? ". nPaperSizes %u", (unsigned)nPaperSizes
        paperSizes = dk3_new_app(dk3_paper_size_t,nPaperSizes,app);
	if(paperSizes) {			$? ". paperSizes ok"
	  pps = paperSizes;
	  dk3paper_reset(psc);
	  while((nsz = dk3paper_next(psc)) != NULL) {
	    if(nsz->name) {
	      if(pHelper->dkToWx(bu, DK3_SIZEOF(bu,wxChar), nsz->name))
	      {				$? ". register \"%!ds\"", nsz->name
	        dk3mem_cpy(
		  (void *)pps,
		  (void *)(&(nsz->size)),
		  sizeof(dk3_paper_size_t)
		);
		pps++;
	      }
	    }
	  }
	}
      }
      dk3paper_close(psc);
    }
  }
  $? "- DkWxBmepsFrame::findPaperSizes"
}



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



void
DkWxBmepsFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) 
{
  if(isGuiActive()) {
    wxString sVersion(wxbmpp_version);
    sVersion.Append(wxbmpp_versnumber);
    sVersion.Append(wxbmpp_versend);
    sVersion.Append(wxT("\nCopyright (c) 2013-2016 - Dirk Krause\n\n"));
    sVersion.Append(sTexts[123]);
    sVersion.Append(wxT("DK tools, wxWidgets, libpng, libjpeg, libtiff, zlib."));
    sVersion.Append(wxT("\n\n"));
    sVersion.Append(sTexts[124]);
    sVersion.Append(wxT("http://dktools.sourceforge.net\n"));
    sVersion.Append(wxT("http://www.wxwidgets.org\n"));
    sVersion.Append(wxT("http://www.libpng.org/pub/png/libpng.html\n"));
    sVersion.Append(wxT("http://www.ijg.org\n"));
    sVersion.Append(wxT("http://www.remotesensing.org/libtiff\n"));
    sVersion.Append(wxT("http://www.zlib.org"));
    wxMessageBox(sVersion, sTexts[122]);
  }
}