1 /*
2 Copyright (C) 2018-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: Bmpp4Frame.wxc
12 */
13 
14 /**	@file Bmpp4Frame.cpp The Bmpp4Frame module.
15 */
16 
17 
18 #include <wxbmpp/wxbmpp.h>
19 
20 #if !defined(__WXMSW__)
21 #include "gui-img/icons/dkicon.xpm"
22 #endif
23 
24 #include "gui-img/shared/toolbar/choose-dir.xpm"
25 #include "gui-img/shared/toolbar/run-conversion.xpm"
26 
27 #ifndef	DK4MAIXDBL_H_INCLUDED
28 #include <libdk4maioxd/dk4maixdbl.h>
29 #endif
30 
31 #ifndef	DK4MAOXDBL_H_INCLUDED
32 #include <libdk4maioxd/dk4maoxdbl.h>
33 #endif
34 
35 
36 
37 
38 
39 /*	__CHANGE__ 017: Add further events. */
40 /*	__CHANGE__ 008: Remove OnIdle if no idle processing required. */
41 #if	wxCHECK_VERSION(3,0,0)
42 wxBEGIN_EVENT_TABLE(Bmpp4Frame,wxFrame)
43 #else
44 BEGIN_EVENT_TABLE(Bmpp4Frame,wxFrame)
45 #endif
46 	EVT_MENU(Bmpp4Frame_Quit, Bmpp4Frame::OnQuit)
47 	EVT_MENU(Bmpp4Frame_Help_About, Bmpp4Frame::OnAbout)
48 	EVT_MENU(Bmpp4Frame_Help_Contents, Bmpp4Frame::OnHelpContents)
49 	EVT_MENU(Bmpp4Frame_Choose_Directory, Bmpp4Frame::OnChooseDirectory)
50 	EVT_MENU(Bmpp4Frame_Run_Conversion, Bmpp4Frame::OnRunConversion)
51 	EVT_MENU(Bmpp4Frame_Reset_Options, Bmpp4Frame::OnResetOptions)
52 	EVT_CHOICE(Bmpp4Frame_Output_Type, Bmpp4Frame::OnOutputType)
53 	EVT_CHOICE(Bmpp4Frame_PS_Level, Bmpp4Frame::OnPSLevel)
54 	EVT_CHOICE(Bmpp4Frame_Resolution, Bmpp4Frame::OnResolution)
55 	EVT_CHECKBOX(Bmpp4Frame_Color_Output, Bmpp4Frame::OnColorOutput)
56 	EVT_CHECKBOX(Bmpp4Frame_Change_Interpolation, Bmpp4Frame::OnInterpolationChange)
57 	EVT_IDLE(Bmpp4Frame::OnIdle)
58 #if	wxCHECK_VERSION(3,0,0)
59 wxEND_EVENT_TABLE()
60 #else
61 END_EVENT_TABLE()
62 #endif
63 
64 
65 /**	Option name to restore make setting.
66 */
67 static const wxChar * const i_dir_names[] = {
68 /* 0 */
69 wxT("wxbmpp.location"),
70 
71 NULL
72 
73 };
74 
75 
76 /**	Option name to restore make setting.
77 */
78 static const wxChar * const i_make_names[] = {
79 /* 0 */
80 wxT("wxbmpp.make"),
81 
82 NULL
83 
84 };
85 
86 
87 /**	Names for saving and restoring options.
88 */
89 static const wxChar * const	i_option_names[] = {
90 /* 0 */
91 wxT("wxbmpp.paper.choice"),
92 
93 /* 1 */
94 wxT("wxbmpp.output.type"),
95 
96 /* 2 */
97 wxT("wxbmpp.output.color"),
98 
99 /* 3 */
100 wxT("wxbmpp.ps.level"),
101 
102 /* 4 */
103 wxT("wxbmpp.ps.dsc"),
104 
105 /* 5 */
106 wxT("wxbmpp.ps.lzw"),
107 
108 /* 6 */
109 wxT("wxbmpp.paper.rotate"),
110 
111 /* 7 */
112 wxT("wxbmpp.paper.duplex"),
113 
114 /* 8 */
115 wxT("wxbmpp.resolution.type"),
116 
117 /* 9 */
118 wxT("wxbmpp.image.background.red"),
119 
120 /* 10 */
121 wxT("wxbmpp.image.background.green"),
122 
123 /* 11 */
124 wxT("wxbmpp.image.background.blue"),
125 
126 /* 12 */
127 wxT("wxbmpp.image.bg.enforce"),
128 
129 /* 13 */
130 wxT("wxbmpp.image.interpolation"),
131 
132 /* 14 */
133 wxT("wxbmpp.image.dct"),
134 
135 /* 15 */
136 wxT("wxbmpp.image.dct-interpolation"),
137 
138 /* 16 */
139 wxT("wxbmpp.image.analysis.bpc"),
140 
141 /* 17 */
142 wxT("wxbmpp.image.analysis.color"),
143 
144 /* 18 */
145 wxT("wxbmpp.image.analysis.alpha"),
146 
147 /* 19 */
148 wxT("wxbmpp.image.rgb-to-gray"),
149 
150 /* 20 */
151 wxT("wxbmpp.output.latex"),
152 
153 NULL
154 
155 };
156 
157 
158 #if	0
159 /**	Names for saving and restoring options.
160 */
161 static const wxChar * const	s_option_names[] = {
162 /* 0 */
163 wxT("wxbmpp.paper.name"),
164 
165 NULL
166 
167 };
168 #endif
169 
170 
171 #if	0
172 /**	Names for saving and restoring options.
173 */
174 static const wxChar * const	d_option_names[] = {
175 /* 0 */
176 wxT("wxbmpp.resolution.value"),
177 
178 NULL
179 
180 };
181 #endif
182 
183 
184 
Bmpp4Frame(int wxid,Dk4WxApplicationHelper * applicationHelper,Dk4WxHelpController * hc,wxChar const * const * localizedTexts,wxChar const * const * nlWx,dkChar const * const * nlDk,dk4_gra_conf_t * pgc,wxArrayString * pPapSiz,wxChar * pDir,size_t szPap,bool bRGx,bool bRMa,bool bRLo,bool bMak,bool bRun,dk4_paper_size_t * pSizes)185 Bmpp4Frame::Bmpp4Frame(
186 	int						  wxid,
187 	Dk4WxApplicationHelper	 *applicationHelper,
188 	Dk4WxHelpController		 *hc,
189 	wxChar const * const	 *localizedTexts,
190 	wxChar const * const	 *nlWx,
191 	dkChar const * const	 *nlDk,
192 	dk4_gra_conf_t			 *pgc,
193 	wxArrayString			 *pPapSiz,
194 	wxChar					 *pDir,
195 	size_t					  szPap,
196 	bool					  bRGx,
197 	bool					  bRMa,
198 	bool					  bRLo,
199 	bool					  bMak,
200 	bool					  bRun,
201 	dk4_paper_size_t		 *pSizes
202 ) : Dk4WxFrame(nlWx[0], applicationHelper, hc, wxid),
203 	cRed(127, 0, 0),
204 	cGreen(0, 127, 0),
205 	cBlack(0, 0, 0),
206 	asPaperSizes(*pPapSiz)
207 {
208 	wxString saOutputMode[] = {
209 		wxString(localizedTexts[18]),
210 		wxString(localizedTexts[19]),
211 		wxString(localizedTexts[20]),
212 		wxString(localizedTexts[21]),
213 		wxString(localizedTexts[22]),
214 		wxString(localizedTexts[23])
215 	};
216 	wxString saPsLevel[] = {
217 		wxString(localizedTexts[28]),
218 		wxString(localizedTexts[29])
219 	};
220 	wxString saFinishing[] = {
221 		wxString(localizedTexts[44]),
222 		wxString(localizedTexts[45]),
223 		wxString(localizedTexts[46])
224 	};
225 	wxString saResolution[] = {
226 		wxString(localizedTexts[52]),
227 		wxString(localizedTexts[53]),
228 		wxString(localizedTexts[54])
229 	};
230 	wxString saRgbToGray[] = {
231 		wxString(localizedTexts[76]),
232 		wxString(localizedTexts[77]),
233 		wxString(localizedTexts[78]),
234 		wxString(localizedTexts[79]),
235 		wxString(localizedTexts[80]),
236 		wxString(localizedTexts[81]),
237 		wxString(localizedTexts[82]),
238 		wxString(localizedTexts[83]),
239 		wxString(localizedTexts[84]),
240 		wxString(localizedTexts[85]),
241 		wxString(localizedTexts[86]),
242 		wxString(localizedTexts[87]),
243 		wxString(localizedTexts[88])
244 	};
245 	wxString		slDirname(localizedTexts[70]);
246 
247 	/*	__CHANGE__ 012:	Add further local variables.
248 	*/
249 
250 	/*	__CHANGE__ 012: Initialize further local variables.
251 	*/
252 	bIsCorrecting = false;
253 
254 	sTexts = localizedTexts;
255 	sNlWx  = nlWx;
256 	sNlDk  = nlDk;
257 #if defined(__WXMSW__)
258 	wxIcon	wxbmpp_icon(sNlWx[4]);
259 #else
260 	wxIcon	wxbmpp_icon(xpm_dkicon);
261 #endif
262 
263 	/*	__CHANGE__ 011:	Initialize further class members.
264 	*/
265 	pPaperSizes = pSizes;
266 	DK4_MEMCPY(&graconf,pgc,sizeof(dk4_gra_conf_t));
267 	if (NULL != pDir) {
268 		sDirname = wxString(pDir);
269 		slDirname = sDirname;
270 	}
271 	szPaperSizes		= szPap;
272 	bRestoreGx			= bRGx;
273 	bRestoreMake		= bRMa;
274 	bRestoreLocation	= bRLo;
275 	bMakeMode			= bMak;
276 	bAutorun			= bRun;
277 	if (bAutorun) {
278 		oAsc.SetAutoStart(true);
279 		oAsc.SetAutoExit(true);
280 	}
281 	else {
282 		oAsc.SetAutoStart(false);
283 		oAsc.SetAutoExit(false);
284 	}
285 	bActive = true;
286 	dk4time_get(&firsttime);
287 
288   dkctGUILayoutOK = false;
289   dkctGUIContentsPanel = NULL;
290   mainSizer = NULL;
291   mbMain = NULL;
292   tbMain = NULL;
293   menuFile = NULL;
294   menuConversion = NULL;
295   menuExtras = NULL;
296   menuHelp = NULL;
297   miFileDirectory = NULL;
298   miFileExit = NULL;
299   miConversionRun = NULL;
300   miExtrasOptionReset = NULL;
301   miHelpAbout = NULL;
302   miHelpContents = NULL;
303   bChooseDir = NULL;
304   bRunConversion = NULL;
305   verticalSizer = NULL;
306   contentsSizer = NULL;
307   staticline0 = NULL;
308   lDirectoryName = NULL;
309   staticline1 = NULL;
310   cbMakeMode = NULL;
311   cbColorOutput = NULL;
312   lRgbToGray = NULL;
313   chRgbToGray = NULL;
314   lOutputMode = NULL;
315   chOutputMode = NULL;
316   cbImgInterpolation = NULL;
317   lPsLevel = NULL;
318   chPsLevel = NULL;
319   cbDsc = NULL;
320   cbLzw = NULL;
321   cbAnBpc = NULL;
322   lPaperSize = NULL;
323   chPaperSizes = NULL;
324   cbRotation = NULL;
325   cbAnColor = NULL;
326   lFinishing = NULL;
327   chFinishing = NULL;
328   cbAnAlpha = NULL;
329   lResolution = NULL;
330   chResolution = NULL;
331   tfResolution = NULL;
332   cbSizeLaTeX = NULL;
333   lBackground = NULL;
334   ccBackground = NULL;
335   cbBackground = NULL;
336   cbDct = NULL;
337   cbDctInterpolation = NULL;
338   dkctGUIContentsPanel = new wxPanel(this);
339   if(!(dkctGUIContentsPanel)) {
340     goto dkctGUILayoutFinished;
341   }
342 #if wxUSE_MENUS
343   mbMain = new wxMenuBar(
344   );
345   if(!(mbMain)) {
346     goto dkctGUILayoutFinished;
347   }
348   menuFile = new wxMenu(
349   );
350   if(!(menuFile)) {
351     goto dkctGUILayoutFinished;
352   }
353   miFileDirectory = menuFile->Append(
354     Bmpp4Frame_Choose_Directory,
355     sTexts[65],
356     sTexts[66]
357   );
358   if(!(miFileDirectory)) {
359     goto dkctGUILayoutFinished;
360   }
361   miFileExit = menuFile->Append(
362     Bmpp4Frame_Quit,
363     sTexts[1],
364     sTexts[2]
365   );
366   if(!(miFileExit)) {
367     goto dkctGUILayoutFinished;
368   }
369   mbMain->Append(menuFile, sTexts[0]);
370   menuConversion = new wxMenu(
371   );
372   if(!(menuConversion)) {
373     goto dkctGUILayoutFinished;
374   }
375   miConversionRun = menuConversion->Append(
376     Bmpp4Frame_Run_Conversion,
377     sTexts[68],
378     sTexts[69]
379   );
380   if(!(miConversionRun)) {
381     goto dkctGUILayoutFinished;
382   }
383   mbMain->Append(menuConversion, sTexts[67]);
384   menuExtras = new wxMenu(
385   );
386   if(!(menuExtras)) {
387     goto dkctGUILayoutFinished;
388   }
389   miExtrasOptionReset = menuExtras->Append(
390     Bmpp4Frame_Reset_Options,
391     sTexts[73],
392     sTexts[122]
393   );
394   if(!(miExtrasOptionReset)) {
395     goto dkctGUILayoutFinished;
396   }
397   mbMain->Append(menuExtras, sTexts[72]);
398   menuHelp = new wxMenu(
399   );
400   if(!(menuHelp)) {
401     goto dkctGUILayoutFinished;
402   }
403   miHelpAbout = menuHelp->Append(
404     Bmpp4Frame_Help_About,
405     sTexts[4],
406     sTexts[5]
407   );
408   if(!(miHelpAbout)) {
409     goto dkctGUILayoutFinished;
410   }
411   miHelpContents = menuHelp->Append(
412     Bmpp4Frame_Help_Contents,
413     sTexts[6],
414     sTexts[7]
415   );
416   if(!(miHelpContents)) {
417     goto dkctGUILayoutFinished;
418   }
419   mbMain->Append(menuHelp, sTexts[3]);
420   SetMenuBar(mbMain);
421 #endif
422 #if wxUSE_TOOLBAR
423   tbMain = new wxToolBar(
424     this,
425     wxID_ANY
426   );
427   if(!(tbMain)) {
428     goto dkctGUILayoutFinished;
429   }
430   bChooseDir = tbMain->AddTool(
431     Bmpp4Frame_Choose_Directory,
432     sTexts[65],
433     xpm_choose_dir,
434     wxNullBitmap,
435     wxITEM_NORMAL,
436     sTexts[66]
437   );
438   if(!(bChooseDir)) {
439     goto dkctGUILayoutFinished;
440   }
441   bRunConversion = tbMain->AddTool(
442     Bmpp4Frame_Run_Conversion,
443     sTexts[68],
444     xpm_run_conversion,
445     wxNullBitmap,
446     wxITEM_NORMAL,
447     sTexts[69]
448   );
449   if(!(bRunConversion)) {
450     goto dkctGUILayoutFinished;
451   }
452   tbMain->Realize();
453   SetToolBar(tbMain);
454 #endif
455   mainSizer = new wxBoxSizer(
456     wxHORIZONTAL
457   );
458   if(!(mainSizer)) {
459     goto dkctGUILayoutFinished;
460   }
461   mainSizer->Add(10, 10, 0);
462   verticalSizer = new wxBoxSizer(
463     wxVERTICAL
464   );
465   if(!(verticalSizer)) {
466     goto dkctGUILayoutFinished;
467   }
468   verticalSizer->Add(10, 10, 0);
469   contentsSizer = new wxGridBagSizer(
470     5, 5
471   );
472   if(!(contentsSizer)) {
473     goto dkctGUILayoutFinished;
474   }
475   staticline0 = new wxStaticLine(
476     dkctGUIContentsPanel,
477     wxID_ANY
478   );
479   if(!(staticline0)) {
480     goto dkctGUILayoutFinished;
481   }
482   contentsSizer->Add(
483     staticline0,
484     wxGBPosition(0, 0),
485     wxGBSpan(1, 11),
486     wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxGROW
487   );
488   lDirectoryName = new wxStaticText(
489     dkctGUIContentsPanel,
490     wxID_ANY,
491     slDirname,
492     wxDefaultPosition,
493     wxDefaultSize,
494     wxALIGN_LEFT
495   );
496   if(!(lDirectoryName)) {
497     goto dkctGUILayoutFinished;
498   }
499   contentsSizer->Add(
500     lDirectoryName,
501     wxGBPosition(1, 0),
502     wxGBSpan(1, 11),
503     wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxGROW
504   );
505   staticline1 = new wxStaticLine(
506     dkctGUIContentsPanel,
507     wxID_ANY
508   );
509   if(!(staticline1)) {
510     goto dkctGUILayoutFinished;
511   }
512   contentsSizer->Add(
513     staticline1,
514     wxGBPosition(2, 0),
515     wxGBSpan(1, 11),
516     wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxGROW
517   );
518   cbMakeMode = new wxCheckBox(
519     dkctGUIContentsPanel,
520     wxID_ANY,
521     sTexts[13]
522   );
523   if(!(cbMakeMode)) {
524     goto dkctGUILayoutFinished;
525   }
526   cbMakeMode->SetToolTip(sTexts[14]);
527   contentsSizer->Add(
528     cbMakeMode,
529     wxGBPosition(3, 0),
530     wxGBSpan(1, 7),
531     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
532   );
533   cbColorOutput = new wxCheckBox(
534     dkctGUIContentsPanel,
535     Bmpp4Frame_Color_Output,
536     sTexts[15]
537   );
538   if(!(cbColorOutput)) {
539     goto dkctGUILayoutFinished;
540   }
541   cbColorOutput->SetToolTip(sTexts[16]);
542   contentsSizer->Add(
543     cbColorOutput,
544     wxGBPosition(3, 7),
545     wxGBSpan(1, 1),
546     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
547   );
548   contentsSizer->Add(10, 1, wxGBPosition(3, 8), wxGBSpan(1, 1));
549   lRgbToGray = new wxStaticText(
550     dkctGUIContentsPanel,
551     wxID_ANY,
552     sTexts[89]
553   );
554   if(!(lRgbToGray)) {
555     goto dkctGUILayoutFinished;
556   }
557   contentsSizer->Add(
558     lRgbToGray,
559     wxGBPosition(3, 9),
560     wxGBSpan(1, 1),
561     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
562   );
563   chRgbToGray = new wxChoice(
564     dkctGUIContentsPanel,
565     wxID_ANY,
566     wxDefaultPosition,
567     wxDefaultSize,
568     13,
569     saRgbToGray
570   );
571   if(!(chRgbToGray)) {
572     goto dkctGUILayoutFinished;
573   }
574   chRgbToGray->SetToolTip(sTexts[90]);
575   contentsSizer->Add(
576     chRgbToGray,
577     wxGBPosition(3, 10),
578     wxGBSpan(1, 1),
579     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
580   );
581   lOutputMode = new wxStaticText(
582     dkctGUIContentsPanel,
583     wxID_ANY,
584     sTexts[17]
585   );
586   if(!(lOutputMode)) {
587     goto dkctGUILayoutFinished;
588   }
589   contentsSizer->Add(
590     lOutputMode,
591     wxGBPosition(4, 0),
592     wxGBSpan(1, 1),
593     wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL
594   );
595   chOutputMode = new wxChoice(
596     dkctGUIContentsPanel,
597     Bmpp4Frame_Output_Type,
598     wxDefaultPosition,
599     wxDefaultSize,
600     6,
601     saOutputMode
602   );
603   if(!(chOutputMode)) {
604     goto dkctGUILayoutFinished;
605   }
606   chOutputMode->SetToolTip(sTexts[24]);
607   contentsSizer->Add(
608     chOutputMode,
609     wxGBPosition(4, 1),
610     wxGBSpan(1, 2),
611     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxGROW
612   );
613   cbImgInterpolation = new wxCheckBox(
614     dkctGUIContentsPanel,
615     Bmpp4Frame_Change_Interpolation,
616     sTexts[25]
617   );
618   if(!(cbImgInterpolation)) {
619     goto dkctGUILayoutFinished;
620   }
621   cbImgInterpolation->SetToolTip(sTexts[26]);
622   contentsSizer->Add(
623     cbImgInterpolation,
624     wxGBPosition(4, 7),
625     wxGBSpan(1, 4),
626     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
627   );
628   lPsLevel = new wxStaticText(
629     dkctGUIContentsPanel,
630     wxID_ANY,
631     sTexts[27]
632   );
633   if(!(lPsLevel)) {
634     goto dkctGUILayoutFinished;
635   }
636   contentsSizer->Add(
637     lPsLevel,
638     wxGBPosition(5, 0),
639     wxGBSpan(1, 1),
640     wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL
641   );
642   chPsLevel = new wxChoice(
643     dkctGUIContentsPanel,
644     Bmpp4Frame_PS_Level,
645     wxDefaultPosition,
646     wxDefaultSize,
647     2,
648     saPsLevel
649   );
650   if(!(chPsLevel)) {
651     goto dkctGUILayoutFinished;
652   }
653   chPsLevel->SetToolTip(sTexts[30]);
654   contentsSizer->Add(
655     chPsLevel,
656     wxGBPosition(5, 1),
657     wxGBSpan(1, 1),
658     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
659   );
660   cbDsc = new wxCheckBox(
661     dkctGUIContentsPanel,
662     wxID_ANY,
663     sTexts[31]
664   );
665   if(!(cbDsc)) {
666     goto dkctGUILayoutFinished;
667   }
668   cbDsc->SetToolTip(sTexts[32]);
669   contentsSizer->Add(
670     cbDsc,
671     wxGBPosition(5, 2),
672     wxGBSpan(1, 1),
673     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
674   );
675   cbLzw = new wxCheckBox(
676     dkctGUIContentsPanel,
677     wxID_ANY,
678     sTexts[33]
679   );
680   if(!(cbLzw)) {
681     goto dkctGUILayoutFinished;
682   }
683   cbLzw->SetToolTip(sTexts[34]);
684   contentsSizer->Add(
685     cbLzw,
686     wxGBPosition(5, 3),
687     wxGBSpan(1, 1),
688     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
689   );
690   cbAnBpc = new wxCheckBox(
691     dkctGUIContentsPanel,
692     wxID_ANY,
693     sTexts[48]
694   );
695   if(!(cbAnBpc)) {
696     goto dkctGUILayoutFinished;
697   }
698   cbAnBpc->SetToolTip(sTexts[49]);
699   contentsSizer->Add(
700     cbAnBpc,
701     wxGBPosition(5, 7),
702     wxGBSpan(1, 4),
703     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
704   );
705   lPaperSize = new wxStaticText(
706     dkctGUIContentsPanel,
707     wxID_ANY,
708     sTexts[37]
709   );
710   if(!(lPaperSize)) {
711     goto dkctGUILayoutFinished;
712   }
713   contentsSizer->Add(
714     lPaperSize,
715     wxGBPosition(6, 0),
716     wxGBSpan(1, 1),
717     wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL
718   );
719   chPaperSizes = new wxChoice(
720     dkctGUIContentsPanel,
721     wxID_ANY,
722     wxDefaultPosition,
723     wxDefaultSize,
724     asPaperSizes
725   );
726   if(!(chPaperSizes)) {
727     goto dkctGUILayoutFinished;
728   }
729   chPaperSizes->SetToolTip(sTexts[38]);
730   contentsSizer->Add(
731     chPaperSizes,
732     wxGBPosition(6, 1),
733     wxGBSpan(1, 2),
734     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxGROW
735   );
736   cbRotation = new wxCheckBox(
737     dkctGUIContentsPanel,
738     wxID_ANY,
739     sTexts[39]
740   );
741   if(!(cbRotation)) {
742     goto dkctGUILayoutFinished;
743   }
744   cbRotation->SetToolTip(sTexts[40]);
745   contentsSizer->Add(
746     cbRotation,
747     wxGBPosition(6, 3),
748     wxGBSpan(1, 2),
749     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
750   );
751   cbAnColor = new wxCheckBox(
752     dkctGUIContentsPanel,
753     wxID_ANY,
754     sTexts[57]
755   );
756   if(!(cbAnColor)) {
757     goto dkctGUILayoutFinished;
758   }
759   cbAnColor->SetToolTip(sTexts[58]);
760   contentsSizer->Add(
761     cbAnColor,
762     wxGBPosition(6, 7),
763     wxGBSpan(1, 4),
764     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
765   );
766   lFinishing = new wxStaticText(
767     dkctGUIContentsPanel,
768     wxID_ANY,
769     sTexts[43]
770   );
771   if(!(lFinishing)) {
772     goto dkctGUILayoutFinished;
773   }
774   contentsSizer->Add(
775     lFinishing,
776     wxGBPosition(7, 0),
777     wxGBSpan(1, 1),
778     wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL
779   );
780   chFinishing = new wxChoice(
781     dkctGUIContentsPanel,
782     wxID_ANY,
783     wxDefaultPosition,
784     wxDefaultSize,
785     3,
786     saFinishing
787   );
788   if(!(chFinishing)) {
789     goto dkctGUILayoutFinished;
790   }
791   chFinishing->SetToolTip(sTexts[47]);
792   contentsSizer->Add(
793     chFinishing,
794     wxGBPosition(7, 1),
795     wxGBSpan(1, 2),
796     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxGROW
797   );
798   cbAnAlpha = new wxCheckBox(
799     dkctGUIContentsPanel,
800     wxID_ANY,
801     sTexts[63]
802   );
803   if(!(cbAnAlpha)) {
804     goto dkctGUILayoutFinished;
805   }
806   cbAnAlpha->SetToolTip(sTexts[64]);
807   contentsSizer->Add(
808     cbAnAlpha,
809     wxGBPosition(7, 7),
810     wxGBSpan(1, 4),
811     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
812   );
813   lResolution = new wxStaticText(
814     dkctGUIContentsPanel,
815     wxID_ANY,
816     sTexts[50]
817   );
818   if(!(lResolution)) {
819     goto dkctGUILayoutFinished;
820   }
821   contentsSizer->Add(
822     lResolution,
823     wxGBPosition(8, 0),
824     wxGBSpan(1, 1),
825     wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL
826   );
827   chResolution = new wxChoice(
828     dkctGUIContentsPanel,
829     Bmpp4Frame_Resolution,
830     wxDefaultPosition,
831     wxDefaultSize,
832     3,
833     saResolution
834   );
835   if(!(chResolution)) {
836     goto dkctGUILayoutFinished;
837   }
838   chResolution->SetToolTip(sTexts[51]);
839   contentsSizer->Add(
840     chResolution,
841     wxGBPosition(8, 1),
842     wxGBSpan(1, 2),
843     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxGROW
844   );
845   tfResolution = new wxTextCtrl(
846     dkctGUIContentsPanel,
847     wxID_ANY,
848     sTexts[55]
849   );
850   if(!(tfResolution)) {
851     goto dkctGUILayoutFinished;
852   }
853   contentsSizer->Add(
854     tfResolution,
855     wxGBPosition(8, 3),
856     wxGBSpan(1, 1),
857     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxGROW
858   );
859   cbSizeLaTeX = new wxCheckBox(
860     dkctGUIContentsPanel,
861     wxID_ANY,
862     sTexts[126]
863   );
864   if(!(cbSizeLaTeX)) {
865     goto dkctGUILayoutFinished;
866   }
867   cbSizeLaTeX->SetToolTip(sTexts[127]);
868   contentsSizer->Add(
869     cbSizeLaTeX,
870     wxGBPosition(8, 7),
871     wxGBSpan(1, 4),
872     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
873   );
874   lBackground = new wxStaticText(
875     dkctGUIContentsPanel,
876     wxID_ANY,
877     sTexts[59]
878   );
879   if(!(lBackground)) {
880     goto dkctGUILayoutFinished;
881   }
882   contentsSizer->Add(
883     lBackground,
884     wxGBPosition(9, 0),
885     wxGBSpan(1, 1),
886     wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL
887   );
888   ccBackground = new Dk4WxColourView(
889     dkctGUIContentsPanel,wxID_ANY,applicationHelper, 255, 255, 255
890   );
891   if(!(ccBackground)) {
892     goto dkctGUILayoutFinished;
893   }
894   ccBackground->SetToolTip(sTexts[60]);
895   contentsSizer->Add(
896     ccBackground,
897     wxGBPosition(9, 1),
898     wxGBSpan(1, 1),
899     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
900   );
901   cbBackground = new wxCheckBox(
902     dkctGUIContentsPanel,
903     wxID_ANY,
904     sTexts[61]
905   );
906   if(!(cbBackground)) {
907     goto dkctGUILayoutFinished;
908   }
909   cbBackground->SetToolTip(sTexts[62]);
910   contentsSizer->Add(
911     cbBackground,
912     wxGBPosition(9, 2),
913     wxGBSpan(1, 3),
914     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
915   );
916   cbDct = new wxCheckBox(
917     dkctGUIContentsPanel,
918     wxID_ANY,
919     sTexts[35]
920   );
921   if(!(cbDct)) {
922     goto dkctGUILayoutFinished;
923   }
924   cbDct->SetToolTip(sTexts[36]);
925   contentsSizer->Add(
926     cbDct,
927     wxGBPosition(9, 7),
928     wxGBSpan(1, 4),
929     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
930   );
931   cbDctInterpolation = new wxCheckBox(
932     dkctGUIContentsPanel,
933     wxID_ANY,
934     sTexts[41]
935   );
936   if(!(cbDctInterpolation)) {
937     goto dkctGUILayoutFinished;
938   }
939   cbDctInterpolation->SetToolTip(sTexts[42]);
940   contentsSizer->Add(
941     cbDctInterpolation,
942     wxGBPosition(10, 7),
943     wxGBSpan(1, 4),
944     wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL
945   );
946   verticalSizer->Add(
947     contentsSizer
948   );
949   verticalSizer->Add(10, 10, 0);
950   mainSizer->Add(
951     verticalSizer,
952     1,
953     wxGROW
954   );
955   mainSizer->Add(10, 10, 0);
956   dkctGUIContentsPanel->SetSizer(mainSizer);
957   SetIcon(wxbmpp_icon);
958   dkctGUILayoutOK = true;
959   dkctGUILayoutFinished:
960 #if wxUSE_STATUSBAR
961   if(dkctGUILayoutOK) {
962     CreateStatusBar(1);
963     SetStatusText(sTexts[8]);
964   }
965 #endif
966   if(dkctGUILayoutOK) {
967     mainSizer->Fit(this);
968     mainSizer->SetSizeHints(this);
969   }
970 	if(dkctGUILayoutOK) {
971 		chOutputMode->SetSelection(0);
972 		chPsLevel->SetSelection(0);
973 		chFinishing->SetSelection(0);
974 		chResolution->SetSelection(0);
975 		chPaperSizes->SetSelection(0);
976 		chRgbToGray->SetSelection(0);
977 		CorrectGUI();
978 		SetTitle(nlWx[0]);
979 #if 0
980 		/*	2018-05-27	Test for setActive() method.
981 			This line was added temporarily just to test the
982 			new setActive() method.
983 		*/
984 		ccBackground->SetActive(false);
985 
986 #endif
987 		ccBackground->SetPlaceColourChooser();
988 	}
989 
990 	/*	__CHANGE__ 012:	Release resources allocated by local variables.
991 	*/
992 
993 
994 }
995 
996 
997 
998 
~Bmpp4Frame()999 Bmpp4Frame::~Bmpp4Frame()
1000 {
1001 
1002 
1003 	/*	__CHANGE__ 011:	Release resources allocated by further class members.
1004 	*/
1005 
1006 
1007 }
1008 
1009 
1010 
1011 bool
CanClose(bool isLast)1012 Bmpp4Frame::CanClose(bool isLast)
1013 {
1014 	bool		back	= true;
1015 
1016 
1017 	/*	__CHANGE__ 013: Check for unsaved data.
1018 	*/
1019 	if (isLast) {
1020 		SaveSettings();
1021 	}
1022 
1023 
1024 	return back;
1025 }
1026 
1027 
1028 void
OnQuit(wxCommandEvent & WXUNUSED (event))1029 Bmpp4Frame::OnQuit(wxCommandEvent & WXUNUSED(event))
1030 {
1031 
1032 
1033 	Close();
1034 }
1035 
1036 
1037 
1038 void
OnAbout(wxCommandEvent & WXUNUSED (event))1039 Bmpp4Frame::OnAbout(wxCommandEvent & WXUNUSED(event))
1040 {
1041 	wxString	text(wxT(""));
1042 	wxString	title(wxT(""));
1043 
1044 	/* Construct message text. */
1045 	text.Append(sNlWx[0]);
1046 	text.Append(sNlWx[7]);
1047 #if 0
1048 	text.Append(sNlWx[1]);
1049 #else
1050 	text.Append(DKT_VERSION_WX);
1051 #endif
1052 	text.Append(sNlWx[8]);
1053 	text.Append(sTexts[9]);
1054 	text.Append(sNlWx[2]);
1055 	text.Append(sNlWx[8]);
1056 	text.Append(sNlWx[8]);
1057 	text.Append(sTexts[11]);
1058 	text.Append(sNlWx[8]);
1059 	text.Append(sNlWx[9]);
1060 	text.Append(sNlWx[8]);
1061 	text.Append(sNlWx[8]);
1062 	text.Append(sTexts[12]);
1063 	text.Append(sNlWx[8]);
1064 	text.Append(sNlWx[10]);
1065 	text.Append(sNlWx[8]);
1066 	text.Append(sNlWx[11]);
1067 	text.Append(sNlWx[8]);
1068 	text.Append(sNlWx[12]);
1069 	text.Append(sNlWx[8]);
1070 	text.Append(sNlWx[13]);
1071 	text.Append(sNlWx[8]);
1072 	text.Append(sNlWx[14]);
1073 	text.Append(sNlWx[8]);
1074 	text.Append(sNlWx[15]);
1075 	text.Append(sNlWx[8]);
1076 
1077 	/* Construct dialog box title. */
1078 	title.Append(sTexts[10]);
1079 	title.Append(sNlWx[0]);
1080 
1081 	/* Show dialog box. */
1082 	wxMessageBox(text, title);
1083 
1084 	/*	__CHANGE__ 019:	Create better about box.
1085 	*/
1086 
1087 }
1088 
1089 
1090 
1091 void
OnHelpContents(wxCommandEvent & WXUNUSED (event))1092 Bmpp4Frame::OnHelpContents(wxCommandEvent & WXUNUSED(event))
1093 {
1094 
1095 	DisplayContents();
1096 
1097 }
1098 
1099 
1100 /*	__CHANGE__ 017:	Event handlers for further events.
1101 */
1102 
1103 
1104 void
OnChooseDirectory(wxCommandEvent & WXUNUSED (event))1105 Bmpp4Frame::OnChooseDirectory(wxCommandEvent & WXUNUSED(event))
1106 {
1107 
1108 	wxDirDialog dd(
1109 		this, sTexts[71], sDirname, (wxDD_DIR_MUST_EXIST | wxDD_CHANGE_DIR)
1110 	);
1111 	pAppHelp->ChooseChildPosition(*this, dd, false);
1112 	if(dd.ShowModal() == wxID_OK) {
1113 		sDirname = dd.GetPath();
1114 		lDirectoryName->SetLabel(sDirname);
1115 #if 0
1116 		lDirectoryName->(wxALIGN_CENTRE_HORIZONTAL);
1117 #endif
1118 		Refresh();
1119 		Update();
1120 	}
1121 	else {
1122 	}
1123 
1124 }
1125 
1126 
1127 
1128 void
OnResetOptions(wxCommandEvent & WXUNUSED (event))1129 Bmpp4Frame::OnResetOptions(wxCommandEvent & WXUNUSED(event))
1130 {
1131 	wxString	sA4(wxT("a4"));
1132 	int		 	res;
1133 
1134 	res = wxMessageBox(
1135 		sTexts[75], sTexts[74], (wxNO_DEFAULT | wxYES_NO | wxICON_QUESTION)
1136 	);
1137 	if (wxYES == res) {
1138 		dk4gra_conf_init(&graconf);
1139 		res = asPaperSizes.Index(sA4);
1140 		if (wxNOT_FOUND != res) {
1141 			chPaperSizes->SetSelection(res);
1142 			dk4mem_cpy(
1143 				&(graconf.media),
1144 				&(pPaperSizes[res]),
1145 				sizeof(dk4_paper_size_t),
1146 				NULL
1147 			);
1148 			graconf.media.name = NULL;
1149 			graconf.psi = (size_t)res;
1150 			graconf.have_psi = 1;
1151 		}
1152 		ConfigurationToGUI();
1153 		CorrectGUI();
1154 	}
1155 
1156 }
1157 
1158 
1159 
1160 bool
CheckPaperSizeForDocuments(void)1161 Bmpp4Frame::CheckPaperSizeForDocuments(void)
1162 {
1163 	bool		 back	= true;
1164 	if (DK4_GRA_PURPOSE_DOCUMENT == graconf.purpose) {
1165 		if (graconf.media.w < (graconf.media.i + graconf.media.o)) {
1166 			back = false;
1167 		}
1168 		if (graconf.media.h < (graconf.media.b + graconf.media.t)) {
1169 			back = false;
1170 		}
1171 	}
1172 	return back;
1173 }
1174 
1175 
1176 
1177 bool
RunConversion(void)1178 Bmpp4Frame::RunConversion(void)
1179 {
1180 	wxString	errorString(wxT(""));
1181 	bool		back	=	false;
1182 
1183 
1184 	/*	Transfer GUI state to grahpics output configuration
1185 		if not specified on the command line.
1186 	*/
1187 	if (bRestoreGx) {
1188 		ConfigurationFromGUI();
1189 	}
1190 	if (!(bAutorun)) {
1191 		bMakeMode = ((0 != cbMakeMode->GetValue()) ? (true) : (false));
1192 	}
1193 	/*
1194 		Check for usable paper size
1195 	*/
1196 	if (CheckPaperSizeForDocuments()) {
1197 		/*
1198 			Do conversion operations in idle events or modal dialog.
1199 		*/
1200 		Bmpp4Progress	dPro(
1201 			this, pAppHelp, sTexts, sDirname, &graconf, bMakeMode, &errorString
1202 		);
1203 		if (dPro.PrepareProcessing()) {
1204 
1205 			pAppHelp->ChooseChildPosition(*this, dPro);
1206 			if (wxID_OK == dPro.ShowModal()) {
1207 				back = true;
1208 			}
1209 			else {
1210 				/* ERRROR: Aborted or errors */
1211 				wxMessageBox(
1212 					errorString, sTexts[102],
1213 					(wxOK | wxCENTRE | wxICON_ERROR),
1214 					this
1215 				);
1216 			}
1217 
1218 		}
1219 		else {
1220 			/* ERROR: Failed to prepare processing */
1221 			wxMessageBox(
1222 				errorString, sTexts[102],
1223 				(wxOK | wxCENTRE | wxICON_ERROR),
1224 				this
1225 			);
1226 		}
1227 
1228 		dPro.Cleanup();
1229 
1230 	}
1231 	else {
1232 		/* ERROR: Unusable paper size */
1233 		wxMessageBox(
1234 			sTexts[111], sTexts[102],
1235 			(wxOK | wxCENTRE | wxICON_ERROR),
1236 			this
1237 		);
1238 	}
1239 
1240 
1241 	return back;
1242 }
1243 
1244 
1245 
1246 void
OnRunConversion(wxCommandEvent & WXUNUSED (event))1247 Bmpp4Frame::OnRunConversion(wxCommandEvent & WXUNUSED(event))
1248 {
1249 
1250 	(void)RunConversion();
1251 
1252 }
1253 
1254 
1255 
1256 void
OnOutputType(wxCommandEvent & WXUNUSED (event))1257 Bmpp4Frame::OnOutputType(wxCommandEvent & WXUNUSED(event))
1258 {
1259 
1260 	CorrectGUI();
1261 
1262 }
1263 
1264 
1265 
1266 void
OnPSLevel(wxCommandEvent & WXUNUSED (event))1267 Bmpp4Frame::OnPSLevel(wxCommandEvent & WXUNUSED(event))
1268 {
1269 
1270 	CorrectGUI();
1271 
1272 }
1273 
1274 
1275 
1276 void
OnResolution(wxCommandEvent & WXUNUSED (event))1277 Bmpp4Frame::OnResolution(wxCommandEvent & WXUNUSED(event))
1278 {
1279 
1280 	CorrectGUI();
1281 
1282 }
1283 
1284 
1285 
1286 void
OnInterpolationChange(wxCommandEvent & WXUNUSED (event))1287 Bmpp4Frame::OnInterpolationChange(wxCommandEvent & WXUNUSED(event))
1288 {
1289 
1290 	CorrectGUI();
1291 
1292 }
1293 
1294 
1295 
1296 void
OnColorOutput(wxCommandEvent & WXUNUSED (event))1297 Bmpp4Frame::OnColorOutput(wxCommandEvent & WXUNUSED(event))
1298 {
1299 
1300 	CorrectGUI();
1301 
1302 }
1303 
1304 
1305 
1306 /*	__CHANGE__ 014:	Implementation of further methods.
1307 */
1308 
1309 
1310 void
SaveSettings(void)1311 Bmpp4Frame::SaveSettings(void)
1312 {
1313 	int		ival[21];
1314 	size_t	i;
1315 
1316 	if (bRestoreGx) {
1317 		for (i = 0; i < DK4_SIZEOF(ival,int); i++) { ival[i] = 0; }
1318 		ival[ 0] = chPaperSizes->GetSelection();
1319 		ival[ 1] = chOutputMode->GetSelection();
1320 		ival[ 2] = cbColorOutput->GetValue();
1321 		ival[ 3] = chPsLevel->GetSelection();
1322 		ival[ 4] = cbDsc->GetValue();
1323 		ival[ 5] = cbLzw->GetValue();
1324 		ival[ 6] = cbRotation->GetValue();
1325 		ival[ 7] = chFinishing->GetSelection();
1326 		ival[ 8] = chResolution->GetSelection();
1327 		ival[ 9] = ccBackground->Red();
1328 		ival[10] = ccBackground->Green();
1329 		ival[11] = ccBackground->Blue();
1330 		ival[12] = cbBackground->GetValue();
1331 		ival[13] = cbImgInterpolation->GetValue();
1332 		ival[14] = cbDct->GetValue();
1333 		ival[15] = cbDctInterpolation->GetValue();
1334 		ival[16] = cbAnBpc->GetValue();
1335 		ival[17] = cbAnColor->GetValue();
1336 		ival[18] = cbAnAlpha->GetValue();
1337 		ival[19] = chRgbToGray->GetSelection();
1338 		ival[20] = cbSizeLaTeX->GetValue();
1339 		pAppHelp->SetMultiple(i_option_names, ival, 21);
1340 	}
1341 	if (bRestoreMake) {
1342 		ival[0] = cbMakeMode->GetValue();
1343 		pAppHelp->SetMultiple(i_make_names, ival, 1);
1344 	}
1345 	if (bRestoreLocation) {
1346 		pAppHelp->SetString(i_dir_names[0], sDirname);
1347 	}
1348 
1349 }
1350 
1351 
1352 
1353 void
RestoreSettings(void)1354 Bmpp4Frame::RestoreSettings(void)
1355 {
1356 	int		ival[21];
1357 	size_t	i;
1358 
1359 	if (bRestoreGx) {
1360 		for (i = 0; i < DK4_SIZEOF(ival,int); i++) { ival[i] = 0; }
1361 		ival[ 0] = 0;
1362 		ival[ 1] = 0;
1363 		ival[ 2] = 1;
1364 		ival[ 3] = 1;
1365 		ival[ 4] = 1;
1366 		ival[ 5] = 0;
1367 		ival[ 6] = 1;
1368 		ival[ 7] = 1;
1369 		ival[ 8] = 0;
1370 		ival[ 9] = 255;
1371 		ival[10] = 255;
1372 		ival[11] = 255;
1373 		ival[12] = 0;
1374 		ival[13] = 1;
1375 		ival[14] = 1;
1376 		ival[15] = 0;
1377 		ival[16] = 1;
1378 		ival[17] = 1;
1379 		ival[18] = 1;
1380 		ival[19] = 0;
1381 		ival[20] = 1;
1382 		pAppHelp->GetMultiple(i_option_names, ival, 21);
1383 		if ((0 <= ival[0]) && ((int)szPaperSizes > ival[0])) {
1384 			chPaperSizes->SetSelection(ival[0]);
1385 		}
1386 		if (0 <= ival[1]) { chOutputMode->SetSelection(ival[1]); }
1387 		cbColorOutput->SetValue((0 != ival[2]) ? (true) : (false));
1388 		if (0 <= ival[3]) { chPsLevel->SetSelection(ival[3]); }
1389 		cbDsc->SetValue((0 != ival[4]) ? (true) : (false));
1390 		cbLzw->SetValue((0 != ival[5]) ? (true) : (false));
1391 		cbRotation->SetValue((0 != ival[6]) ? (true) : (false));
1392 		if (0 <= ival[7]) { chFinishing->SetSelection(ival[7]); }
1393 		if (0 <= ival[8]) { chResolution->SetSelection(ival[8]); }
1394 		ccBackground->SetRGB(ival[9], ival[10], ival[11]);
1395 		cbBackground->SetValue((0 != ival[12]) ? (true) : (false));
1396 		cbImgInterpolation->SetValue((0 != ival[13]) ? (true) : (false));
1397 		cbDct->SetValue((0 != ival[14]) ? (true) : (false));
1398 		cbDctInterpolation->SetValue((0 != ival[15]) ? (true) : (false));
1399 		cbAnBpc->SetValue((0 != ival[16]) ? (true) : (false));
1400 		cbAnColor->SetValue((0 != ival[17]) ? (true) : (false));
1401 		cbAnAlpha->SetValue((0 != ival[18]) ? (true) : (false));
1402 		if (0 <= ival[19]) { chRgbToGray->SetSelection(ival[19]); }
1403 		cbSizeLaTeX->SetValue((0 != ival[20]) ? (true) : (false));
1404 	}
1405 	else {
1406 		ConfigurationToGUI();
1407 	}
1408 	if (bRestoreMake) {
1409 		for (i = 0; i < DK4_SIZEOF(ival,int); i++) { ival[i] = 0; }
1410 		ival[ 0] = 0;
1411 		pAppHelp->GetMultiple(i_make_names, ival, 1);
1412 		cbMakeMode->SetValue((0 != ival[0]) ? (true) : (false));
1413 		bMakeMode = ((0 != ival[0]) ? true : false);
1414 	}
1415 	else {
1416 		cbMakeMode->SetValue(bMakeMode ? (1) : (0));
1417 	}
1418 	if (bRestoreLocation) {
1419 		if (pAppHelp->GetString(i_dir_names[0], &sDirname)) {
1420 			lDirectoryName->SetLabel(sDirname);
1421 			Refresh();
1422 			Update();
1423 		}
1424 	}
1425 
1426 }
1427 
1428 
1429 
1430 void
CorrectGUI(void)1431 Bmpp4Frame::CorrectGUI(void)
1432 {
1433 
1434 	if (!bIsCorrecting) {
1435 		/*
1436 			Avoid recursive calls
1437 		*/
1438 		bIsCorrecting = true;
1439 
1440 		/*
1441 			Enable or disable PS specific components
1442 		*/
1443 		switch (chOutputMode->GetSelection()) {
1444 			case 0 : case 1 : case 2 : {	/* PDF */
1445 				chPsLevel->Enable(false);
1446 				cbDsc->Enable(false);
1447 				cbLzw->Enable(false);
1448 			} break;
1449 			default : {						/* PS or EPS */
1450 				chPsLevel->Enable(true);
1451 				cbDsc->Enable(true);
1452 				if (0 == chPsLevel->GetSelection()) {	/* PS 2 */
1453 					cbLzw->Enable(true);
1454 				}
1455 				else {									/* PS 3 */
1456 					cbLzw->Enable(false);
1457 				}
1458 			} break;
1459 		}
1460 
1461 		/*
1462 			Enable or disable job specific components
1463 		*/
1464 		switch (chOutputMode->GetSelection()) {
1465 			case 2: case 5: {	/* document */
1466 				chFinishing->Enable(true);
1467 				cbRotation->Enable(true);
1468 				chPaperSizes->Enable(true);
1469 				cbSizeLaTeX->Enable(false);
1470 			} break;
1471 			default: {			/* not a document */
1472 				chFinishing->Enable(false);
1473 				cbRotation->Enable(false);
1474 				chPaperSizes->Enable(false);
1475 				cbSizeLaTeX->Enable(true);
1476 			} break;
1477 		}
1478 
1479 		/*
1480 			Enable or disable resolution text input field
1481 		*/
1482 		switch(chResolution->GetSelection()) {
1483 			case 2: {
1484 				tfResolution->Enable(true);
1485 			} break;
1486 			default: {
1487 				tfResolution->Enable(false);
1488 			} break;
1489 		}
1490 
1491 		/*
1492 			Enable or disable Interpolation DCT
1493 		*/
1494 		if (0 != cbImgInterpolation->GetValue()) {
1495 			cbDctInterpolation->Enable(true);
1496 		}
1497 		else {
1498 			cbDctInterpolation->Enable(false);
1499 		}
1500 
1501 		/*
1502 			Enable or disable RGB to gray method selection
1503 		*/
1504 		if (0 != cbColorOutput->GetValue()) {
1505 			chRgbToGray->Enable(false);
1506 		}
1507 		else {
1508 			chRgbToGray->Enable(true);
1509 		}
1510 
1511 		/*
1512 			Mark as done
1513 		*/
1514 		bIsCorrecting = false;
1515 		/*
1516 			Update GUI
1517 		*/
1518 		Refresh();
1519 		Update();
1520 	}
1521 
1522 }
1523 
1524 
1525 
1526 void
ConfigurationToGUI(void)1527 Bmpp4Frame::ConfigurationToGUI(void)
1528 {
1529 	wxChar	b1[64];								/* Conversion buffer */
1530 	wxChar	b2[DK4_SIZEOF(b1,wxChar)];			/* Conversion buffer */
1531 	size_t	szb		=	DK4_SIZEOF(b1,wxChar);	/* Size of b1 and b2 (elems) */
1532 	size_t	papi	=	0;						/* Paper size index */
1533 	int		res		=	0;						/* Operation result */
1534 
1535 	/*	Output mode
1536 	*/
1537 	switch (graconf.driver) {
1538 		case DK4_GRA_DRIVER_PS : {
1539 			switch (graconf.purpose) {
1540 				case DK4_GRA_PURPOSE_DOCUMENT : {
1541 					chOutputMode->SetSelection(5);
1542 				} break;
1543 				default : {
1544 					chOutputMode->SetSelection(4);
1545 				} break;
1546 			}
1547 		} break;
1548 		case DK4_GRA_DRIVER_EPS : {
1549 			chOutputMode->SetSelection(3);
1550 		} break;
1551 		default : {
1552 			switch (graconf.purpose) {
1553 				case DK4_GRA_PURPOSE_DOCUMENT : {
1554 					chOutputMode->SetSelection(2);
1555 				} break;
1556 				case DK4_GRA_PURPOSE_IMAGE : {
1557 					chOutputMode->SetSelection(1);
1558 				} break;
1559 				default : {		/* DK4_GRA_PURPOSE_OBJECT */
1560 					chOutputMode->SetSelection(0);
1561 				} break;
1562 			}
1563 		} break;
1564 	}
1565 	/*	PS level
1566 	*/
1567 	chPsLevel->SetSelection((3 == graconf.ps_level) ? (1) : (0));
1568 	/*	DSC
1569 	*/
1570 	cbDsc->SetValue((0 != graconf.ps_dsc) ? (1) : (0));
1571 	/*	LZW
1572 	*/
1573 	cbLzw->SetValue((0 != graconf.ps_lzw) ? (1) : (0));
1574 	/*	Paper size
1575 	*/
1576 	if ((0 != graconf.have_psi) && (szPaperSizes > graconf.psi)) {
1577 		chPaperSizes->SetSelection((int)(graconf.psi));
1578 	}
1579 	else {
1580 		if (0 != graconf.have_psi) {
1581 			chPaperSizes->SetSelection((int)(graconf.psi));
1582 		}
1583 		else {
1584 			res = dk4paper_find_nearest(
1585 				&papi, pPaperSizes, szPaperSizes, &(graconf.media), NULL
1586 			);
1587 			if ((0 != res) && ((dk4_um_t)(INT_MAX) >= (dk4_um_t)papi)) {
1588 				chPaperSizes->SetSelection((int)papi);
1589 			}
1590 			else {
1591 				chPaperSizes->SetSelection(0);
1592 			}
1593 		}
1594 	}
1595 	/*	Rotate
1596 	*/
1597 	cbRotation->SetValue((0 != graconf.img_rot) ? 1 : 0);
1598 	/*	Finishing
1599 	*/
1600 	if (0 != graconf.doc_tumble) {
1601 		chFinishing->SetSelection(2);
1602 	}
1603 	else {
1604 		chFinishing->SetSelection((0 != graconf.doc_duplex) ? (1) : (0));
1605 	}
1606 	/*	Resolution
1607 	*/
1608 	if ((0.0 < graconf.xres) && (0.0 < graconf.yres)) {
1609 		chResolution->SetSelection(2);
1610 		/*	2018-03-28
1611 			The buffer overflow reported from wxWidgets libraries
1612 			magically disappeared after rebuilding the entire project
1613 			with debug messages.
1614 			May be rebuilding one module was missing before.
1615 		*/
1616 
1617 		if (0 != dk4ma_write_wx_double(b1,szb,graconf.xres,0,1,NULL)) {
1618 
1619 			if (0 != dk4ma_write_wx_double(b2,szb,graconf.yres,0,1,NULL)) {
1620 
1621 				tfResolution->SetValue(wxString(b1) + wxT(" ") + wxString(b2));
1622 
1623 			}
1624 			else {
1625 			}
1626 		}
1627 		else {
1628 		}
1629 
1630 	}
1631 	else {
1632 		chResolution->SetSelection((graconf.img_ign_res) ? (1) : (0));
1633 	}
1634 	/*	Background
1635 	*/
1636 	if ((0 <= graconf.img_bg_r) && (256 > graconf.img_bg_r)) {
1637 	if ((0 <= graconf.img_bg_g) && (256 > graconf.img_bg_g)) {
1638 	if ((0 <= graconf.img_bg_b) && (256 > graconf.img_bg_b)) {
1639 		ccBackground->SetRGB(
1640 			graconf.img_bg_r, graconf.img_bg_g, graconf.img_bg_b
1641 		);
1642 	}
1643 	}
1644 	}
1645 	/*
1646 		Enforce background
1647 	*/
1648 	cbBackground->SetValue((0 != graconf.img_bg_f) ? (1) : (0));
1649 	/*
1650 		Color
1651 	*/
1652 	cbColorOutput->SetValue((0 != graconf.color) ? (1) : (0));
1653 	/*
1654 		Interpolation
1655 	*/
1656 	cbImgInterpolation->SetValue((0 != graconf.img_int) ? (1) : (0));
1657 	/*
1658 		DCT
1659 	*/
1660 	cbDct->SetValue((0 != graconf.img_dct) ? (1) : (0));
1661 	/*
1662 		DCT interpolation
1663 	*/
1664 	cbDctInterpolation->SetValue((0 != graconf.img_dct_int) ? (1) : (0));
1665 	/*
1666 		Analzse bpc
1667 	*/
1668 	cbAnBpc->SetValue((0 != graconf.img_an_bpc) ? (1) : (0));
1669 	/*
1670 		Analzse color
1671 	*/
1672 	cbAnColor->SetValue((0 != graconf.img_an_color) ? (1) : (0));
1673 	/*
1674 		Analyze alpha
1675 	*/
1676 	cbAnAlpha->SetValue((0 != graconf.img_an_alpha) ? (1) : (0));
1677 	/*
1678 		RGB to gray method
1679 	*/
1680 	if (0 <= graconf.ctx.rgb_to_gray) {
1681 		chRgbToGray->SetSelection(graconf.ctx.rgb_to_gray);
1682 	}
1683 	/*	Restrict size for LaTeX
1684 	*/
1685 	cbSizeLaTeX->SetValue((0 != graconf.restrict_size) ? (1) : (0));
1686 
1687 }
1688 
1689 
1690 
1691 void
ConfigurationFromGUI(void)1692 Bmpp4Frame::ConfigurationFromGUI(void)
1693 {
1694 	wxChar			 buffer[128];
1695 	wxChar const	*ep;
1696 	wxChar			*p1		=	NULL;
1697 	wxChar			*p2		=	NULL;
1698 	double			 xres	=	-1.0;
1699 	double			 yres	=	-1.0;
1700 	size_t			 szbu	= DK4_SIZEOF(buffer,wxChar);
1701 	int				 choiceindex;
1702 	int				 ok		=	0;
1703 
1704 	/*	Output mode
1705 	*/
1706 	switch (chOutputMode->GetSelection()) {
1707 		case 0 : {
1708 			graconf.driver = DK4_GRA_DRIVER_PDF;
1709 			graconf.purpose = DK4_GRA_PURPOSE_OBJECT;
1710 		} break;
1711 		case 1 : {
1712 			graconf.driver = DK4_GRA_DRIVER_PDF;
1713 			graconf.purpose = DK4_GRA_PURPOSE_IMAGE;
1714 		} break;
1715 		case 2 : {
1716 			graconf.driver = DK4_GRA_DRIVER_PDF;
1717 			graconf.purpose = DK4_GRA_PURPOSE_DOCUMENT;
1718 		} break;
1719 		case 3 : {
1720 			graconf.driver = DK4_GRA_DRIVER_EPS;
1721 			graconf.purpose = DK4_GRA_PURPOSE_IMAGE;
1722 		} break;
1723 		case 4 : {
1724 			graconf.driver = DK4_GRA_DRIVER_PS;
1725 			graconf.purpose = DK4_GRA_PURPOSE_IMAGE;
1726 		} break;
1727 		case 5 : {
1728 			graconf.driver = DK4_GRA_DRIVER_PS;
1729 			graconf.purpose = DK4_GRA_PURPOSE_DOCUMENT;
1730 		} break;
1731 		default : {
1732 			graconf.driver = DK4_GRA_DRIVER_PDF;
1733 			graconf.purpose = DK4_GRA_PURPOSE_OBJECT;
1734 		} break;
1735 	}
1736 	/*	PS level
1737 	*/
1738 	switch (chPsLevel->GetSelection()) {
1739 		case 0 : {
1740 			graconf.ps_level = 2;
1741 		} break;
1742 		default : {
1743 			graconf.ps_level = 3;
1744 		} break;
1745 	}
1746 	/*	DSC
1747 	*/
1748 	graconf.ps_dsc = ((0 != cbDsc->GetValue()) ? 1 : 0);
1749 	/*
1750 		LZW
1751 	*/
1752 	graconf.ps_lzw = ((0 != cbLzw->GetValue()) ? 1 : 0);
1753 	/*
1754 		Paper size
1755 	*/
1756 	choiceindex = chPaperSizes->GetSelection();
1757 	if ((0 <= choiceindex) && (szPaperSizes > (size_t)choiceindex)) {
1758 		dk4mem_cpy(
1759 			&(graconf.media),
1760 			&(pPaperSizes[choiceindex]),
1761 			sizeof(dk4_paper_size_t),
1762 			NULL
1763 		);
1764 	}
1765 	/*
1766 		Rotate
1767 	*/
1768 	graconf.img_rot = ((0 != cbRotation->GetValue()) ? 1 : 0);
1769 	/*
1770 		Finishing
1771 	*/
1772 	switch (chFinishing->GetSelection()) {
1773 		case 2 : {
1774 			graconf.doc_duplex = 1;
1775 			graconf.doc_tumble = 1;
1776 		} break;
1777 		case 1 : {
1778 			graconf.doc_duplex = 1;
1779 			graconf.doc_tumble = 0;
1780 		} break;
1781 		default : {
1782 			graconf.doc_duplex = 0;
1783 			graconf.doc_tumble = 0;
1784 		} break;
1785 	}
1786 	/*	Resolution
1787 	*/
1788 	switch (chResolution->GetSelection()) {
1789 		case 2 : {	/* specify */
1790 			/* ##### TODO: Implementation: Retrieve values from text field */
1791 			wxCStrData  valuestrdata = tfResolution->GetValue().c_str();
1792 			if (
1793 				0 != dk4strx_cpy_s(
1794 					buffer, szbu, (wxChar const *)valuestrdata, NULL
1795 				)
1796 			) {
1797 				p1 = dk4strx_start(buffer, NULL);
1798 				if (NULL != p1) {
1799 					p2 = dk4strx_next(p1, NULL);
1800 					ep = NULL;
1801 					if (0 != dk4ma_input_wx_double(&xres, p1, &ep, 1, NULL)) {
1802 						ok		= 1;
1803 						yres	= xres;
1804 					}
1805 					if (NULL != p2) {
1806 					ep = NULL;
1807 						if (0 == dk4ma_input_wx_double(&yres,p2,&ep,1,NULL)) {
1808 							ok = 0;
1809 						}
1810 					}
1811 					if (1 == ok) {
1812 						if ((0.0 < xres) && (0.0 < yres)) {
1813 							graconf.xres = xres;
1814 							graconf.yres = yres;
1815 						}
1816 					}
1817 				}
1818 			}
1819 			graconf.img_ign_res = 0;
1820 		} break;
1821 		case 1 : {	/* ignore */
1822 			graconf.img_ign_res = 1;
1823 			graconf.xres = graconf.yres = 72.0;
1824 		} break;
1825 		default : {	/* chunk */
1826 			graconf.img_ign_res = 0;
1827 			graconf.xres = graconf.yres = -1.0;
1828 		} break;
1829 	}
1830 	/*	Background
1831 	*/
1832 	graconf.img_bg_r = ccBackground->Red();
1833 	graconf.img_bg_g = ccBackground->Green();
1834 	graconf.img_bg_b = ccBackground->Blue();
1835 	/*
1836 		Enforce background
1837 	*/
1838 	graconf.img_bg_f = ((0 != cbBackground->GetValue()) ? 1 : 0);
1839 	/*
1840 		Color
1841 	*/
1842 	graconf.color = ((0 != cbColorOutput->GetValue()) ? 1 : 0);
1843 	/*
1844 		Interpolation
1845 	*/
1846 	graconf.img_int = ((0 != cbImgInterpolation->GetValue()) ? 1 : 0);
1847 	/*
1848 		DCT
1849 	*/
1850 	graconf.img_dct = ((0 != cbDct->GetValue()) ? 1 : 0);
1851 	/*
1852 		DCT interpolation
1853 	*/
1854 	graconf.img_dct_int = ((0 != cbDctInterpolation->GetValue()) ? 1 : 0);
1855 	/*
1856 		Analzse bpc
1857 	*/
1858 	graconf.img_an_bpc = ((0 != cbAnBpc->GetValue()) ? 1 : 0);
1859 	/*
1860 		Analzse color
1861 	*/
1862 	graconf.img_an_color = ((0 != cbAnColor->GetValue()) ? 1 : 0);
1863 	/*
1864 		Analyze alpha
1865 	*/
1866 	graconf.img_an_alpha = ((0 != cbAnAlpha->GetValue()) ? 1 : 0);
1867 	/*
1868 		Size restriction for LaTeX
1869 	*/
1870 	graconf.restrict_size = ((0 != cbSizeLaTeX->GetValue()) ? 1 : 0);
1871 	/*
1872 		RGB to gray method
1873 	*/
1874 	switch (chRgbToGray->GetSelection()) {
1875 		case 12 : {
1876 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_CHANNEL_BLUE;
1877 		} break;
1878 		case 11 : {
1879 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_CHANNEL_GREEN;
1880 		} break;
1881 		case 10 : {
1882 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_CHANNEL_RED;
1883 		} break;
1884 		case  9 : {
1885 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_MAX_DECOMPOSITION;
1886 		} break;
1887 		case  8 : {
1888 			graconf.ctx.rgb_to_gray =
1889 			DK4_CS_CONV_RGB_TO_GRAY_MEDIUM_DECOMPOSITION;
1890 		} break;
1891 		case  7 : {
1892 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_MIN_DECOMPOSITION;
1893 		} break;
1894 		case  6 : {
1895 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_DESATURATION;
1896 		} break;
1897 		case  5 : {
1898 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_AVERAGE;
1899 		} break;
1900 		case  4 : {
1901 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_VERY_FAST;
1902 		} break;
1903 		case  3 : {
1904 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_FAST;
1905 		} break;
1906 		case  2 : {
1907 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_ITU_BT709;
1908 		} break;
1909 		case  1 : {
1910 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_LUMA;
1911 		} break;
1912 		default : {
1913 			graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_ITU_BT601;
1914 		} break;
1915 	}
1916 
1917 }
1918 
1919 
1920 
1921 void
OnIdle(wxIdleEvent & event)1922 Bmpp4Frame::OnIdle(wxIdleEvent & event)
1923 {
1924 #if	TRACE_DEBUG
1925 	static unsigned long		number	=	0UL;
1926 	dk4_time_t					timer;
1927 #endif
1928 	bool						rqm		=	false;
1929 	bool						success;
1930 
1931 #if	TRACE_DEBUG
1932 	dk4time_get(&timer);
1933 #endif
1934 
1935 	if (bActive) {
1936 		if (bAutorun) {
1937 			switch (oAsc.GetReaction()) {
1938 				case Dk4WxAutostartController::REACTION_START : {
1939 					oAsc.StartProcessing();
1940 					success = RunConversion();
1941 					rqm = true;
1942 					if (success) {
1943 						lDirectoryName->SetLabel(sTexts[91]);
1944 						lDirectoryName->SetForegroundColour(cGreen);
1945 					}
1946 					else {
1947 #if	0
1948 						oAsc.SetAutoExit(false);
1949 						rqm = false;
1950 #endif
1951 						lDirectoryName->SetLabel(sTexts[92]);
1952 						lDirectoryName->SetForegroundColour(cRed);
1953 					}
1954 					lDirectoryName->Refresh();
1955 					lDirectoryName->Update();
1956 					oAsc.EndProcessing();
1957 				} break;
1958 				case Dk4WxAutostartController::REACTION_MORE : {
1959 					rqm = true;
1960 				} break;
1961 				case Dk4WxAutostartController::REACTION_EXIT : {
1962 					bActive = false;
1963 					Show(false);
1964 					Close();
1965 					rqm = false;
1966 				} break;
1967 				default : {		/* includes DK4WX_AUTOSTART_REACTION_IGNORE */
1968 
1969 				} break;
1970 			}
1971 		}
1972 		else {
1973 		}
1974 	}
1975 	else {
1976 	}
1977 #if	TRACE_DEBUG
1978 	dk4time_get(&timer);
1979 #endif
1980 
1981 	if (rqm) {
1982 		event.RequestMore();
1983 	}
1984 	event.Skip();
1985 }
1986 
1987 
1988 /* vim: set ai sw=4 ts=4 : */
1989