summaryrefslogtreecommitdiff
path: root/support/dktools/DkWxBmepsOptionsDialog.wxc
blob: a4c58287dad9cd720ac2aae8997375185ff2d7ca (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
%%	options

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


%%	wx-gui
type		=	dialog
contents	=	sDialog

[wxBoxSizer sDialog]
direction	=	horizontal
contents	=	$stretch(10)
contents	=	verticalSizer
contents	=	$stretch(10)

[wxBoxSizer verticalSizer]
direction	=	vertical
grow		=	yes
contents	=	$stretch(10)
contents	=	sSetup
contents	=	$stretch(10)
contents	=	sButtons	centered
contents	=	$stretch(10)

[wxGridBagSizer sSetup]
grid	 = 5 5
contents = sttGeneral		 0  0  1  5 left
contents = cbMakeMode		+1  0  1  3 left
contents = $space(10,1)		 .  3  1  1 left
contents = $space(1,10)		+1  0  1  5 left
contents = sttOutput		+1  0  1  5 left
contents = $space(30,1)		 .  5  1  1 left
contents = sttOutputDetails	 .  6  1  5 left
contents = sttOutputFormat	+1  0  1  1 right centered-y
contents = cobOutputFormat	 .  1  1  2 left  centered-y
contents = cbDraft		 .  4  1  1 left  centered-y
contents = sttPsLevel		 .  6  1  1 right centered-y
contents = cobPsLevel		 .  7  1  1 left  centered-y
contents = $space(10,1)		 .  8  1  1 left
contents = cbDsc		 .  9  1  1 left  centered-y
contents = $stretch(10)		 . 10  1  1 left
contents = sttOutputType	+1  0  1  1 right centered-y
contents = cobOutputType	 .  1  1  2 left  centered-y
# contents = cbColor		 .  4  1  1 left  centered-y
contents = sttPredictor		 .  6  1  1 right centered-y
contents = cobPredictor		 .  7  1  3 left  centered-y
contents = sttFinishing		+1  0  1  1 right centered-y
contents = cobFinishing		 .  1  1  2 left  centered-y
contents = cbDCT		 .  6  1  4 left  centered-y
contents = cbBpc		+1  6  1  4 left  centered-y
contents = $space(1,10)		+1  0  1  5 left
contents = sttOutputSize	+1  0  1  5 left
contents = sttInterpolation	 .  6  1  5 left
contents = sttResolution	+1  0  1  1 right centered-y
contents = cobResolution	 .  1  1  1 left  centered-y
contents = txtResolution	 .  2  1  2 left  centered-y
contents = cbInterNormal	 .  6  1  5 left  centered-y
contents = sttPaperSize		+1  0  1  1 right centered-y
contents = cobPaperSize		 .  1  1  2 left  centered-y
contents = cbInterJpeg		 .  6  1  5 left  centered-y
contents = $space(1,10)		+1  0  1  1
contents = sttTransparency	+1  6  1  5 left
contents = sttBackground	+1  6  1  2 right centered-y
contents = cvBackground		 .  8  1  1 centered-y
contents = cbForceBackground	+1  6  1  5 left  centered-y


[wxStaticText sttGeneral]
text		=	sTexts[37]

[wxCheckBox cbMakeMode]
# id		=	...
text		=	sTexts[38]
tip		=	sTexts[39]

[wxStaticText sttOutput]
text		=	sTexts[40]

[wxStaticText sttOutputFormat]
text		=	sTexts[41]
text style	=	right

[wxChoice cobOutputFormat]
choices		=	4 saOutputFormat
tip		=	sTexts[91]
grow		=	yes
id		=	DkWxBmeps_OuputFormat

[wxCheckBox cbDraft]
text		=	sTexts[54]
tip		=	sTexts[55]
id		=	DkWxBmeps_Draft

[wxStaticText sttOutputType]
text		=	sTexts[46]

[wxChoice cobOutputType]
choices		=	3 saOutputType
tip		=	sTexts[92]
grow		=	yes
id		=	DkWxBmeps_OutputType

# [wxCheckBox cbColor]
# text		=	sTexts[56]
# tip		=	sTexts[57]

[wxStaticText sttFinishing]
text		=	sTexts[50]

[wxChoice cobFinishing]
choices		=	3 saFinishing
tip		=	sTexts[93]
grow		=	yes

[wxCheckBox cbDCT]
text		=	sTexts[89]
tip		=	sTexts[90]

[wxCheckBox cbBpc]
text		=	sTexts[120]
tip		=	sTexts[121]

[wxStaticText sttOutputSize]
text		=	sTexts[58]

[wxStaticText sttResolution]
text		=	sTexts[59]
text style	=	right

[wxChoice cobResolution]
choices		=	3 saResolution
tip		=	sTexts[94]
id		=	DkWxBmeps_ResolutionType

[wxTextCtrl txtResolution]
text		=	wxT("   ")
tip		=	sTexts[98]


[wxStaticText sttPaperSize]
text		=	sTexts[63]
text style	=	right

[wxChoice cobPaperSize]
choices		=	*asPaperSizes
tip		=	sTexts[95]
grow		=	yes

[wxStaticText sttOutputDetails]
text		=	sTexts[73]

[wxStaticText sttPsLevel]
text		=	sTexts[74]

[wxChoice cobPsLevel]
choices		=	2 saPsLevel
tip		=	sTexts[96]
id		=	DkWxBmeps_PsLevel

[wxCheckBox cbDsc]
text		=	sTexts[82]
tip		=	sTexts[83]

[wxStaticText sttPredictor]
text		=	sTexts[75]
text style	=	right

[wxChoice cobPredictor]
choices		=	6 saPredictor
tip		=	sTexts[97]

[wxStaticText sttInterpolation]
text		=	sTexts[64]

[wxCheckBox cbInterNormal]
text		=	sTexts[65]
tip		=	sTexts[66]
id		=	DkWxBmeps_Interpolation

[wxCheckBox cbInterJpeg]
text		=	sTexts[67]
tip		=	sTexts[68]

[wxStaticText sttTransparency]
text		=	sTexts[69]

[wxStaticText sttBackground]
text		=	sTexts[70]
text style	=	right

[DkWxColorView cvBackground]
constructor	=	pHelper,255,255,255
id		=	wxID_ANY

[wxCheckBox cbForceBackground]
text		=	sTexts[71]
tip		=	sTexts[72]

[wxStdDialogButtonSizer sButtons]
contents	=	bOK
contents	=	bCancel


[wxButton bOK]
id		=	wxID_OK
text		=	sTexts[84]
tip		=	sTexts[85]

[wxButton bCancel]
id		=	wxID_CANCEL
text		=	sTexts[86]
tip		=	sTexts[87]



%%	header start

%%	class start



/**	Options dialog for the wxbmpp program.
*/
class DkWxBmepsOptionsDialog : public wxDialog
{

  private:

    /**	Flag: Already in correction, do not enter correction again.
    */
    bool			 bIsCorrecting;

    /**	Event table.
    */
    DECLARE_EVENT_TABLE()
  
  protected:

    /**	Application helper object.
    */
    DkWxAppHelper		*pHelper;

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

    /**	Paper size names.
    */
    wxArrayString		*arrayStringPaperSizeNames;

    /**	Conversion options.
    */
    dk3_bm_eps_options_t	*bmepsOptions;

    /**	Paper sizes in PS points.
    */
    dk3_paper_size_t		*paperSizes;

    /**	Pointer to variable for selected paper size.
    */
    size_t			*selectedPaperSize;

    /** Encoding of dkChar.
    */
    int				 dke;

    /**	Encoding of wxChar.
    */
    int				 wxe;

    /**	Handler for OK button.
    	@param	event	Event to process.
    */
    void
    OnOK(wxCommandEvent& WXUNUSED(event));

    /**	Handler for Cancel button.
    	@param	event	Event to process.
    */
    void
    OnCancel(wxCommandEvent& WXUNUSED(event));

    /**	Handler for output format change.
    	@param	event	Event to process.
    */
    void
    OnOutputFormat(wxCommandEvent & event);

    /**	Handler for output type change.
    	@param	event	Event to process.
    */
    void
    OnOutputType(wxCommandEvent & event);

    /**	Handler for resolution change.
    	@param	event	Event to process.
    */
    void
    OnResolution(wxCommandEvent & event);

    /**	Handler changed draft setting.
    	@param	event	Event to process.
    */
    void
    OnDraft(wxCommandEvent & event);

    /**	Handler for changed PS level.
    	@param	event	Event to process.
    */
    void
    OnPsLevel(wxCommandEvent & event);

    /**	Handler changed interpolation setting.
    	@param	event	Event to process.
    */
    void
    OnInterpolation(wxCommandEvent & event);

    /**	Correct GUI (enable/disable elements based on last decision).
    */
    void
    correctGUI();


%%	class end
  public:

    /**	Constructor.
    	@param	parent		Parent window.
	@param	title		Dialog box title.
	@param	messageTexts	Localized message texts.
	@param	asPaperSizes	Known paper size names.
	@param	opt	Conversion options.
	@param	pps	Known paper sizes array.
	@param	sps	Size of @arg pps (number of elements in array).
	@param	applicationHelper	Application helper object.
	@param	de	Character encoding used for dkChar strings.
	@param	we	Character encoding used for wxChar strings.
    */
    DkWxBmepsOptionsDialog(
      DkWxBmepsFrame		*parent,
      wxChar const		*title,
      wxChar const * const	*messageTexts,
      wxArrayString		*asPaperSizes,
      dk3_bm_eps_options_t	*opt,
      dk3_paper_size_t		*pps,
      size_t			*sps,
      DkWxAppHelper		*applicationHelper,
      int			 de,
      int			 we
    );

    /**	Transfer data from GUI controls to configuration structure.
    */
    void dataOut();

    /**	Transfer data from configuration structure to GUI controls.
    */
    void dataIn();

    /**	Restrict a number to a range.
    	@param	min	Range minimum.
	@param	max	Range maximum.
	@param	val	Value to use.
	@return	The value fitted into the range.
    */
    int
    intToRange(int min, int max, int val);

    /**	Set a wxChoice selection.
    	@param	ch	Choice to modify.
	@param	val	New selection index.
    */
    void
    setChoice(wxChoice *ch, int val);
};

%%	header end


%%	module start

#include	"wxbmeps.h"



$!trace-include

BEGIN_EVENT_TABLE(DkWxBmepsOptionsDialog, wxDialog)
  EVT_BUTTON(wxID_OK,			DkWxBmepsOptionsDialog::OnOK)
  EVT_BUTTON(wxID_CANCEL,		DkWxBmepsOptionsDialog::OnCancel)
  EVT_CHOICE(DkWxBmeps_OuputFormat,	DkWxBmepsOptionsDialog::OnOutputFormat)
  EVT_CHOICE(DkWxBmeps_OutputType,	DkWxBmepsOptionsDialog::OnOutputType)
  EVT_CHOICE(DkWxBmeps_ResolutionType,	DkWxBmepsOptionsDialog::OnResolution)
  EVT_CHECKBOX(DkWxBmeps_Draft,		DkWxBmepsOptionsDialog::OnDraft)
  EVT_CHOICE(DkWxBmeps_PsLevel,		DkWxBmepsOptionsDialog::OnPsLevel)
  EVT_CHECKBOX(DkWxBmeps_Interpolation,	DkWxBmepsOptionsDialog::OnInterpolation)
END_EVENT_TABLE()



%%	constructor start
DkWxBmepsOptionsDialog::DkWxBmepsOptionsDialog(
  DkWxBmepsFrame	*parent,
  wxChar const		*title,
  wxChar const * const	*messageTexts,
  wxArrayString		*asPaperSizes,
  dk3_bm_eps_options_t	*opt,
  dk3_paper_size_t	*pps,
  size_t		*sps,
  DkWxAppHelper		*applicationHelper,
  int			 de,
  int			 we
) : wxDialog(
  parent,
  wxID_ANY,
  title,
  wxDefaultPosition,
  wxDefaultSize,
  wxDEFAULT_DIALOG_STYLE
)
{
  pHelper = applicationHelper;
  dke = de; wxe = we;
  arrayStringPaperSizeNames = asPaperSizes;
  bmepsOptions = opt;
  paperSizes = pps;
  selectedPaperSize = sps;
  bIsCorrecting = false;
  wxColour cRed(0x7F, 0x00, 0x00);
  wxString saOutputFormat[] = {
    wxString(messageTexts[42]),
    wxString(messageTexts[43]),
    wxString(messageTexts[44]),
    wxString(messageTexts[45])
  };
  wxString saOutputType[] = {
    wxString(messageTexts[47]),
    wxString(messageTexts[48]),
    wxString(messageTexts[49])
  };
  wxString saFinishing[] = {
    wxString(messageTexts[51]),
    wxString(messageTexts[52]),
    wxString(messageTexts[53])
  };
  wxString saResolution[] = {
    wxString(messageTexts[60]),
    wxString(messageTexts[61]),
    wxString(messageTexts[62])
  };
  wxString saPsLevel[] = {
    wxString(wxT("2")),
    wxString(wxT("3"))
  };
  wxString saPredictor[] = {
    wxString(messageTexts[76]),
    wxString(messageTexts[77]),
    wxString(messageTexts[78]),
    wxString(messageTexts[79]),
    wxString(messageTexts[80]),
    wxString(messageTexts[81])
  };
  sTexts = messageTexts;
%%	constructor end
  cvBackground->SetToolTip(messageTexts[88]);
  sttGeneral->SetForegroundColour(cRed);
  sttOutput->SetForegroundColour(cRed);
  sttOutputDetails->SetForegroundColour(cRed);
  sttOutputSize->SetForegroundColour(cRed);
  sttInterpolation->SetForegroundColour(cRed);
  sttTransparency->SetForegroundColour(cRed);
  txtResolution->ChangeValue(sTexts[3]);
}

%%	module end



void
DkWxBmepsOptionsDialog::OnOK(
  wxCommandEvent &	event
)
{
  $? "+ DkWxBmepsOptionsDialog::OnOK"
  dataOut();
  if(IsModal()) {
    EndModal(wxID_OK);
  } else {
    SetReturnCode(wxID_OK);
    Show(false);
  }
  $? "- DkWxBmepsOptionsDialog::OnOK"
}



void
DkWxBmepsOptionsDialog::OnCancel(
  wxCommandEvent &	event
)
{
  if(IsModal()) {
    EndModal(wxID_CANCEL);
  } else {
    SetReturnCode(wxID_CANCEL);
    Show(false);
  }
}



void
DkWxBmepsOptionsDialog::dataOut()
{
  int	i;
  $? "+ DkWxBmepsOptionsDialog::dataOut"
  /* Make mode			cbMakeMode */
  bmepsOptions->make = ((cbMakeMode->GetValue()) ? 1 : 0);
  /* Output format		cobOutputFormat */
  i = cobOutputFormat->GetSelection();
  if((i >= 0) && (i <= DK3_BMEPS_DRIVER_BB)) {
    bmepsOptions->dr = i;
  } else {
    bmepsOptions->dr = 0;
  }
  /* Output type		cobOutputType */
  i = cobOutputType->GetSelection();
  if((i >= 0) && (i <= DK3_BMEPS_MODE_DOCUMENT)) {
    bmepsOptions->mode = i;		$? ". output type %d", i
  } else {
    bmepsOptions->mode = 0;
  }
  /* Finishing			cobFinishing */
  i = cobFinishing->GetSelection();	$? ". finishing %d", i
  switch(i) {
    case 1: {
      bmepsOptions->duplex = 1; bmepsOptions->tumble = 0;
    } break;
    case 2: {
      bmepsOptions->duplex = 1; bmepsOptions->tumble = 1;
    } break;
    default: {
      bmepsOptions->duplex = 0; bmepsOptions->tumble = 0;
    } break;
  }
  /* Draft			cbDraft */
  bmepsOptions->draft = ((cbDraft->GetValue()) ? 1 : 0);
  /* Color			cbColor */
  /* bmepsOptions->color = ((cbColor->GetValue()) ? 1 : 0); */
  /* Resolution choice		cobResolution */
#if VERSION_BEFORE_20140902
  bmepsOptions->szmode = cobResolution->GetSelection();
#else
  switch (bmepsOptions->mode) {
    case DK3_BMEPS_MODE_DOCUMENT: {
      bmepsOptions->szmode = DK3_BMEPS_SIZE_PAPER;
      $? ". szmode = paper"
    } break;
    default: {
      bmepsOptions->szmode = cobResolution->GetSelection();
      $? ". szmode = %d", bmepsOptions->szmode
    } break;
  }
#endif
  /* Resolution value		txtResolution */
  if(bmepsOptions->szmode == DK3_BMEPS_SIZE_SPECIFIED) {
    dkChar	bu[64];
    dkChar	*ptr;
    double	v = 0.0;
    wxString resText = txtResolution->GetValue();
    wxChar const *txt = resText.c_str();
    $? ". szmode: specified"
    if(txt) {					$? ". have txt"
      if(dk3wxs_to_dkstr(bu,DK3_SIZEOF(bu,dkChar),dke,txt,wxe)) {
        ptr = bu;		$? ". dkChar encoding ok \"%s\"", bu
	while(*ptr) {
	  if(*ptr == dkT(',')) { *ptr = dkT('.'); }
	  ptr++;
	}			$? ". bu = \"%!ds\"", bu
        if(dk3sf_scan_double_app(bu,&v,NULL)) {	$? ". sscanf ok"
	  bmepsOptions->resolution = v;		$? ". v = %lf", v
	} else {
	  bmepsOptions->resolution = 0.0;
	}
      } else {
        bmepsOptions->resolution = 0.0;
      }
    } else {
      bmepsOptions->resolution = 0.0;
    }
  } else {		$? ". szmode: other"
    bmepsOptions->resolution = 0.0;
  }
  /* Paper size			cobPaperSize */
  if(selectedPaperSize) {
    *selectedPaperSize = (size_t)(cobPaperSize->GetSelection());
    $? ". paper size index %d", (int)(cobPaperSize->GetSelection())
  }
  /* PS level			cobPsLevel */
  i = cobPsLevel->GetSelection();
  bmepsOptions->psl = ((i == 1) ? 3 : 2);
  /* DSC			cbDsc */
  bmepsOptions->dsc = ((cbDsc->GetValue()) ? 1 : 0);
  /* Predictor			cobPredictor */
  bmepsOptions->pred = cobPredictor->GetSelection();
  /* DCT 			cbDCT */
  bmepsOptions->dct = ((cbDCT->GetValue()) ? 1 : 0);
  /* Bits per component		cbBpc */
  bmepsOptions->rbpc = ((cbBpc->GetValue()) ? 1 : 0);
  /* Image interpolation	cbInterNormal */
  bmepsOptions->ip = ((cbInterNormal->GetValue()) ? 1 : 0);
  /* Interpolation for JPEG	cbInterJpeg */
  bmepsOptions->jip = ((cbInterJpeg->GetValue()) ? 1 : 0);
  /* Background color		cvBackground */
  bmepsOptions->bgr = cvBackground->getRed();
  bmepsOptions->bgg = cvBackground->getGreen();
  bmepsOptions->bgb = cvBackground->getBlue();
  /* Force background color	cbForceBackground*/
  bmepsOptions->fbg = ((cbForceBackground->GetValue()) ? 1 : 0);
  (void)dk3bmeo_check(bmepsOptions, 0, bmepsOptions->app, NULL);
  $? "- DkWxBmepsOptionsDialog::dataOut"
}



void
DkWxBmepsOptionsDialog::dataIn()
{
  /* Make mode			cbMakeMode */
  cbMakeMode->SetValue((bmepsOptions->make) ? true : false);
  /* Output format		cobOutputFormat */
  setChoice(cobOutputFormat, bmepsOptions->dr);
  /* Output type		cobOutputType */
  setChoice(cobOutputType, bmepsOptions->mode);
  /* Finishing			cobFinishing */
  if(bmepsOptions->duplex) {
    if(bmepsOptions->tumble) {
      cobFinishing->SetSelection(2);
    } else {
      cobFinishing->SetSelection(1);
    }
  } else {
    cobFinishing->SetSelection(0);
  }
  /* Draft			cbDraft */
  cbDraft->SetValue((bmepsOptions->draft) ? true : false);
  /* Color			cbColor */
  /* cbColor->SetValue((bmepsOptions->color) ? true : false); */
  /* Resolution choice		cobResolution */
  $? ". szmode: %d", bmepsOptions->szmode
  setChoice(cobResolution, bmepsOptions->szmode);
  /* Resolution value		txtResolution */
  if(bmepsOptions->szmode == 2) {	$? ". szmode: 2"
    txtResolution->ChangeValue(
      wxString::Format(wxT("%lg"), bmepsOptions->resolution)
    );
  } else {
    txtResolution->ChangeValue(sTexts[3]);
  }
  /* Paper size			cobPaperSize */
  if(selectedPaperSize) {
    setChoice(cobPaperSize, (int)(*selectedPaperSize));
  } else {
    cobPaperSize->SetSelection(0);
  }
  /* PS level			cobPsLevel */
  if(bmepsOptions->psl == 3) {
    cobPsLevel->SetSelection(1);
  } else {
    cobPsLevel->SetSelection(0);
  }
  /* DSC			cbDsc */
  cbDsc->SetValue((bmepsOptions->dsc) ? true : false);
  /* Predictor			cobPredictor */
  setChoice(cobPredictor, bmepsOptions->pred);
  /* DCT 			cbDCT */
  cbDCT->SetValue((bmepsOptions->dct) ? true : false);
  /* Reduce bits per component	cbBpc */
  cbBpc->SetValue((bmepsOptions->rbpc) ? true : false);
  /* Image interpolation	cbInterNormal */
  cbInterNormal->SetValue((bmepsOptions->ip) ? true : false);
  /* Interpolation for JPEG	cbInterJpeg */
  cbInterJpeg->SetValue((bmepsOptions->jip) ? true : false);
  /* Background color		cvBackground */
  cvBackground->setRGB(
    intToRange(0,255,bmepsOptions->bgr),
    intToRange(0,255,bmepsOptions->bgg),
    intToRange(0,255,bmepsOptions->bgb)
  );
  /* Force background color	cbForceBackground*/
  cbForceBackground->SetValue((bmepsOptions->fbg) ? true : false);
  correctGUI();
}



int
DkWxBmepsOptionsDialog::intToRange(int min, int max, int val)
{
  int back = val;
  if(back < min) back = min;
  if(back > max) back = max;
  return back;
}



void
DkWxBmepsOptionsDialog::setChoice(wxChoice *ch, int val)
{
  if(ch) {
    unsigned max = ch->GetCount();
    if(val == wxNOT_FOUND) {
      ch->SetSelection(val);
    } else {
      ch->SetSelection(intToRange(0, ((int)max - 1), val));
    }
  }
}



void
DkWxBmepsOptionsDialog::OnOutputFormat(wxCommandEvent & event)
{
  correctGUI();
}



void
DkWxBmepsOptionsDialog::OnOutputType(wxCommandEvent & event)
{
  correctGUI();
}



void
DkWxBmepsOptionsDialog::OnResolution(wxCommandEvent & event)
{
  correctGUI();
}



void
DkWxBmepsOptionsDialog::OnDraft(wxCommandEvent & event)
{
  correctGUI();
}



void
DkWxBmepsOptionsDialog::OnPsLevel(wxCommandEvent & event)
{
  correctGUI();
}



void
DkWxBmepsOptionsDialog::OnInterpolation(wxCommandEvent & event)
{
  correctGUI();
}



void
DkWxBmepsOptionsDialog::correctGUI()
{
  bool	doEnable;
  $? "+ DkWxBmepsOptionsDialog::correctGUI"
  if(!bIsCorrecting) {
    bIsCorrecting = true;
    /* Output type */
    if(cobOutputFormat->GetSelection() == 3) {
      cobOutputType->SetSelection(1);
      cobOutputType->Enable(false);
    } else {
      cobOutputType->Enable(true);
    }
    /* Finishing */
    if(cobOutputType->GetSelection() == 2) {
      cobFinishing->Enable(true);
    } else {
      cobFinishing->Enable(false);
    }
    /* Resolution type */
    switch(cobOutputType->GetSelection()) {
      case 0: {
        cobResolution->Enable(true);
      } break;
      case 1: {
        cobResolution->SetSelection(0);
	cobResolution->Enable(false);
      } break;
      case 2: {
        cobResolution->Enable(false);
      } break;
    }
    /* Resolution text */
    if(cobResolution->GetSelection() == 2) {
      txtResolution->Enable(true);
    } else {
      txtResolution->Enable(false);
    }
    /* Paper size */
    if(cobOutputType->GetSelection() == 2) {
      cobPaperSize->Enable(true);
    } else {
      cobPaperSize->Enable(false);
    }
    /* Draft mode */
    if(cobOutputFormat->GetSelection() == 3) {
      cbDraft->Enable(false);
    } else {
      if(cobOutputType->GetSelection() == 2) {
        cbDraft->Enable(false);
      } else {
        cbDraft->Enable(true);
      }
    }
    /* Color */
    if(cobOutputFormat->GetSelection() == 3) {
      /* cbColor->Enable(false); */
    } else {
      if(cbDraft->GetValue()) {
        /* cbColor->Enable(false); */
      } else {
        /* cbColor->Enable(true); */
      }
    }
    /* PS level and DSC */
    switch(cobOutputFormat->GetSelection()) {
      case 0: case 1: {
        cobPsLevel->Enable(true);
	cbDsc->Enable(true);
      } break;
      default: {
        cobPsLevel->Enable(false);
	cbDsc->Enable(false);
      } break;
    }
    /* Predictor */
    doEnable = false;
    switch(cobOutputFormat->GetSelection()) {
      case 0: case 1: {
        if(cobPsLevel->GetSelection() == 1) {
	  doEnable = true;
	}
      } break;
      case 2: {
        doEnable = true;
      } break;
    }
    if(cbDraft->GetValue()) { doEnable = false; }
    cobPredictor->Enable(doEnable);
    /* Re-use JPEG DCT data */
    if(cobOutputFormat->GetSelection() == 3) {
      cbDCT->Enable(false);
    } else {
      if(cbDraft->GetValue()) {
        cbDCT->Enable(false);
      } else {
        cbDCT->Enable(true);
      }
    }
    /* Normal interpolation */
    if(cobOutputFormat->GetSelection() == 3) {
      cbInterNormal->Enable(false);
    } else {
      if(cbDraft->GetValue()) {
        cbInterNormal->Enable(false);
      } else {
        cbInterNormal->Enable(true);
      }
    }
    /* Interpolation for JPEG */
    if(cobOutputFormat->GetSelection() == 3) {
      cbInterJpeg->Enable(false);
    } else {
      if(cbInterNormal->GetValue()) {
        if(cbDraft->GetValue()) {
          cbInterJpeg->Enable(false);
        } else {
          cbInterJpeg->Enable(true);
        }
      } else {
        cbInterJpeg->Enable(false);
      }
    }
    /* Force background */
    if(cobOutputFormat->GetSelection() == 3) {
      cbForceBackground->Enable(false);
    } else {
      if(cbDraft->GetValue()) {
        cbForceBackground->Enable(false);
      } else {
        cbForceBackground->Enable(true);
      }
    }
    bIsCorrecting = false;
    Refresh();
    Update();
  } $? "- DkWxBmepsOptionsDialog::correctGUI"
}