summaryrefslogtreecommitdiff
path: root/support/dktools/DkWxTraceOptionsDialog.wxc
blob: 348b9008cb02c29c71d285c2fe76915aea8a4017 (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
%%	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		centered-x
contents	=	$stretch(10)
contents	=	sButtons	centered-x
contents	=	$stretch(10)

[wxGridBagSizer sSetup]
contents	=	sttGeneral	 0   0   1   4	left
contents	=	cbMake		+1   0   1   4	left
contents	=	$space(1,10)	+1   0   1   4	left
contents	=	sttOutput	+1   0   1   4	left
contents	=	cbLinenumbers	+1   0   1   4	left
contents	=	cbUseSplint	+1   0   1   2	left	centered-y
contents	=	chSplintChar	 .   2   1   1	left	centered-y
contents	=	$space(1,10)	+1   0   1   4	left
contents	=	sttDebug	+1   0   1   4	left
contents	=	cbDebug		+1   0   1   4	left
contents	=	$space(20,1)	+1   0   1   1	left
contents	=	cbDebStdout	 .   1   1   3	left
contents	=	cbDebTime	+1   1   1   3	left
contents	=	cbDebTraceKw	+1   1   1   3	left
contents	=	cbDebWide	+1   1   1   3	left
contents	=	cbDebPortable	+1   1   1   3	left

[wxStaticText	sttGeneral]
text		=	sTexts[33]

[wxCheckBox	cbMake]
text		=	sTexts[31]
tip		=	sTexts[32]

[wxStaticText	sttOutput]
text		=	sTexts[34]

[wxCheckBox	cbLinenumbers]
text		=	sTexts[35]
tip		=	sTexts[42]

[wxCheckBox	cbUseSplint]
text		=	sTexts[94]
tip		=	sTexts[95]
id		=	DkWxTrace_UseSplint

[wxChoice	chSplintChar]
choices		=	18 splintCommentChars
tip		=	sTexts[96]
id		=	DkWxTrace_SplintChar

[wxStaticText	sttDebug]
text		=	sTexts[36]

[wxCheckBox	cbDebug]
text		=	sTexts[37]
tip		=	sTexts[43]
id		=	DkWxTrace_Debug

[wxCheckBox	cbDebStdout]
text		=	sTexts[38]
tip		=	sTexts[44]

[wxCheckBox	cbDebTime]
text		=	sTexts[39]
tip		=	sTexts[45]

[wxCheckBox	cbDebTraceKw]
text		=	sTexts[40]
tip		=	sTexts[46]

[wxCheckBox	cbDebWide]
text		=	sTexts[41]
tip		=	sTexts[48]

[wxCheckBox	cbDebPortable]
text		=	sTexts[97]
tip		=	sTexts[98]

[wxStdDialogButtonSizer sButtons]
contents	=	bOK
contents	=	bCancel

[wxButton bOK]
id		=	wxID_OK
text		=	sTexts[26]
tip		=	sTexts[28]

[wxButton bCancel]
id		=	wxID_CANCEL
text		=	sTexts[27]
tip		=	sTexts[29]

%%	header start

%%	class start
/**	Trace options dialog.
*/
class DkWxTraceOptionsDialog : public wxDialog
{
  private:

    /**	Event table.
    */
    DECLARE_EVENT_TABLE()

  protected:

    /**	Color for section heads.
    */
    wxColour			 cRed;

    /**	Parent window.
    */
    DkWxTraceFrame	*pa;

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

    /**	Option set to configure.
    */
    DKCT_OPTION_SET		*options;

    /**	Flag: We are in correction routine.
    */
    int				is_correcting;

%%	class end
  public:

    /**	Constructor.
  	@param	parent		Parent window.
	@param	title		Title text.
	@param	messageTexts	Localized message texts.
	@param	o		Options set to modify using this dialog.
    */
    DkWxTraceOptionsDialog(
      DkWxTraceFrame		*parent,
      wxChar const		*title,
      wxChar const * const	*messageTexts,
      DKCT_OPTION_SET		*o
    );

  protected:

    /**	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 clicking the debug checkbox.
    	@param	event	Event to process.
    */
    void OnChangeDebug(wxCommandEvent & WXUNUSED(event));

    /**	Handler for changing the use splint option.
    	@param	event	Event to process.
    */
    void OnChangeUseSplint(wxCommandEvent & WXUNUSED(event));

  public:

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

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

    /**	Correct GUI depending on cbDebug.
    */
    void correctGUI();
};

%%	header end

%%	module start

#include "dkwxtrace.h"



$!trace-include

BEGIN_EVENT_TABLE(DkWxTraceOptionsDialog, wxDialog)
  EVT_BUTTON(wxID_OK,		    DkWxTraceOptionsDialog::OnOK)
  EVT_BUTTON(wxID_CANCEL,	    DkWxTraceOptionsDialog::OnCancel)
  EVT_CHECKBOX(DkWxTrace_Debug,	    DkWxTraceOptionsDialog::OnChangeDebug)
  EVT_CHECKBOX(DkWxTrace_UseSplint, DkWxTraceOptionsDialog::OnChangeUseSplint)
END_EVENT_TABLE()

%%	constructor start
DkWxTraceOptionsDialog::DkWxTraceOptionsDialog(
  DkWxTraceFrame	*parent,
  wxChar const		*title,
  wxChar const * const	*messageTexts,
  DKCT_OPTION_SET	*o
) : wxDialog(
  parent,
  wxID_ANY,
  title,
  wxDefaultPosition,
  wxDefaultSize,
  wxDEFAULT_DIALOG_STYLE
),
cRed(0x7F, 0x00, 0x00)
{
  wxString	splintCommentChars[] = {
    wxString(messageTexts[76]),
    wxString(messageTexts[77]),
    wxString(messageTexts[78]),
    wxString(messageTexts[79]),
    wxString(messageTexts[80]),
    wxString(messageTexts[81]),
    wxString(messageTexts[82]),
    wxString(messageTexts[83]),
    wxString(messageTexts[84]),
    wxString(messageTexts[85]),
    wxString(messageTexts[86]),
    wxString(messageTexts[87]),
    wxString(messageTexts[88]),
    wxString(messageTexts[89]),
    wxString(messageTexts[90]),
    wxString(messageTexts[91]),
    wxString(messageTexts[92]),
    wxString(messageTexts[93]),
  };
  pa = parent;
  sTexts = messageTexts;
  options = o;
  is_correcting = 0;
%%	constructor end
  if (dkctGUILayoutOK) {
    sttGeneral->SetForegroundColour(cRed);
    sttOutput->SetForegroundColour(cRed);
    sttDebug->SetForegroundColour(cRed);
  }
}

%%	module end

void
DkWxTraceOptionsDialog::OnOK(
  wxCommandEvent &	event
)
{
  dataOut();
  if(IsModal()) {
    EndModal(wxID_OK);
  } else {
    SetReturnCode(wxID_OK);
    Show(false);
  }
}


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



void
DkWxTraceOptionsDialog::OnChangeDebug(
  wxCommandEvent &	event
)
{
  correctGUI();
}



void
DkWxTraceOptionsDialog::OnChangeUseSplint(
  wxCommandEvent &	event
)
{
  correctGUI();
}


void
DkWxTraceOptionsDialog::dataIn()
{
  cbLinenumbers->SetValue((options->lnn) ? true : false);
  cbMake->SetValue((options->mak) ? true : false);
  cbDebug->SetValue((options->deb) ? true : false);
  cbDebStdout->SetValue((options->deb == 2) ? true : false);
  cbDebWide->SetValue((options->win) ? true : false);
  cbDebPortable->SetValue((options->port) ? true : false);
  cbDebTraceKw->SetValue((options->tkw) ? true : false);
  cbDebTime->SetValue((options->ts) ? true : false);
  if ('\0' != options->spls) {
    cbUseSplint->SetValue(true);
    chSplintChar->SetSelection(pa->findSplintCharacterIndex(options->spls));
  } else {
    cbUseSplint->SetValue(false);
    chSplintChar->SetSelection(0);
  }
  correctGUI();
}



void
DkWxTraceOptionsDialog::dataOut()
{
  options->deb = (cbDebug->GetValue()) ? (
    (cbDebStdout->GetValue()) ? 2 : 1
  ) : 0;
  options->lnn = (cbLinenumbers->GetValue()) ? 1 : 0;
  options->mak = (cbMake->GetValue()) ? 1 : 0;
  options->tkw = (cbDebTraceKw->GetValue()) ? 1 : 0;
  options->ts  = (cbDebTime->GetValue()) ? 1 : 0;
  options->win = (cbDebWide->GetValue()) ? 1 : 0;
  options->port = (cbDebPortable->GetValue()) ? 1 : 0;
  if (cbUseSplint->GetValue()) {
    options->spls =
    (char)((sTexts[76 + chSplintChar->GetCurrentSelection()])[0]);
  } else {
    options->spls = '\0';
  }
}


void
DkWxTraceOptionsDialog::correctGUI()
{
  if(!(is_correcting)) {
    is_correcting = 1;
    if(cbDebug) {
      if(cbDebug->GetValue()) {
        if(cbDebStdout) {
	  cbDebStdout->Enable(true);
	}
	if(cbDebTime) {
	  cbDebTime->Enable(true);
	}
	if(cbDebTraceKw) {
	  cbDebTraceKw->Enable(true);
	}
	if(cbDebWide) {
	  cbDebWide->Enable(true);
	}
	if(NULL != cbDebPortable) {
	  cbDebPortable->Enable(true);
	}
      } else {
        if(cbDebStdout) {
	  cbDebStdout->SetValue(false);
	  cbDebStdout->Enable(false);
	}
	if(cbDebTime) {
	  cbDebTime->SetValue(false);
	  cbDebTime->Enable(false);
	}
	if(cbDebTraceKw) {
	  cbDebTraceKw->SetValue(false);
	  cbDebTraceKw->Enable(false);
	}
	if(cbDebWide) {
	  cbDebWide->SetValue(false);
	  cbDebWide->Enable(false);
	}
	if(NULL != cbDebPortable) {
	  cbDebPortable->SetValue(false);
	  cbDebPortable->Enable(false);
	}
      }
    }
    if (cbUseSplint) {
      if (cbUseSplint->GetValue()) {		$? ". enable"
        chSplintChar->Enable(true);
      } else {					$? ". disable"
        chSplintChar->Enable(false);
      }
    }
    is_correcting = 0;
    Refresh();
    Update();
  }
}