summaryrefslogtreecommitdiff
path: root/support/dktools/Bmpp4Progress.h
blob: 01ce6b78a6cf45acd7c5a46319d51ef0ab5804be (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
/*
Copyright (C) 2018-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/

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

#ifndef BMPP4PROGRESS_H_INCLUDED
/** Avoid multiple inclusions. */
#define BMPP4PROGRESS_H_INCLUDED 1


#line 49 "Bmpp4Progress.wxc"

/**	@file	Bmpp4Progress.h	Progress dialog shown while processing.
*/

#ifndef	DK4GRCO_H_INCLUDED
#include <dk4grco.h>
#endif

#ifndef	DK4STO_H_INCLUDED
#include <dk4sto.h>
#endif



/**	One input file to process.
*/
typedef struct {
	wxChar			*infilename;	/**< Input file name, allocated. */
	wxChar			*shortifn;		/**< Short file name, in filename. */
	dkChar			*dkifn;			/**< Input file name allocated. */
	dkChar			*dkofn;			/**< Output file name, allocated. */
	unsigned char	 mcheck;		/**< Flag: Do make-operation check. */
} one_file_t;




#line 76 "Bmpp4Progress.wxc"
class Bmpp4Progress : public wxDialog
{
	private:

#if	wxCHECK_VERSION(3,0,0)
		wxDECLARE_EVENT_TABLE();
#else
		DECLARE_EVENT_TABLE()
#endif

	protected:


		/**	Decision for next step to execute.
		*/
		enum	{
			STEP_REPORT_ERROR	=	-1 , /**< Error occured initialization. */
			STEP_START_NEW_FILE	=	0 ,	 /**< Retrieve next file name. */
			STEP_GENERATE_OUTPUT ,		 /**< Generate output for one frame. */
			STEP_WRITE_FILE ,			 /**< Write output to file. */
		};


		/**	Protect variables against concurrent access.
		*/
		wxCriticalSection		csProtect;

		/**	Graphics output configuration.
		*/
		dk4_gra_conf_t			 graconf;

		/**	Coordinates transformation.
		*/
		double					 cotra[8];

		/**	Directory name to process.
		*/
		wxString				sDirname;

		/**	Current file processed.
		*/
		one_file_t				*curof;

		/**	Bitmap image to read from.
		*/
		dk4_bif_t				*pBif;

		/**	Graphics object to create.
		*/
		dk4_gra_t				*pGra;

		/**	Application helper for encoding changes.
		*/
		Dk4WxApplicationHelper	*pAppHelp;

		/**	Localized texts for wxbmpp application.
		*/
		wxChar const * const	*sTexts;

		/**	String containing all the error messages.
		*/
		wxString				*pErrors;

		/**	Collection of file names to process.
		*/
		dk4_sto_t				*sFiles;

		/**	Iterator through file name collection.
		*/
		dk4_sto_it_t			*iFiles;

		/**	Current file to process.
		*/
		one_file_t				*currentFile;

		/**	Number of files in sFiles.
		*/
		size_t					 szFiles;

		/**	Number of files already processed from sFiles.
		*/
		size_t					 usedFiles;

		/**	Current frame number to process next.
		*/
		size_t					 currentFrame;

		/**	Image width.
		*/
		size_t					 w;

		/**	Image height.
		*/
		size_t					 h;

		/**	Flags to use for document when opening graphics output.
		*/
		int						 docfl;

		/**	Flags to use for pages when opening graphics output.
		*/
		int						 pagefl;

		/**	Value to show in progress bar.
		*/
		int						 gaugeValue;

		/**	Next step type, one from enumeration.
		*/
		int						 nst;

		/**	No errors occured for current file.
		*/
		int						 graOkForFile;

		/**	Flag: Critical variables are currently in use.
		*/
		bool					 bInUse;

		/**	Indicate successful processing without errors.
		*/
		bool					 bSuccess;

		/**	Run in make operating mode on directories.
		*/
		bool					 bMakeMode;

		/**	Flag: Memory error already reported.
		*/
		bool					 bRepMem;

	protected:

		/**	Execute one processing step.
			@param	cc	Flag: Can continue.
			@param	rqm	Flag: Require more idle events.
			@param	upd	Flag: Update dialog after step.
		*/
		void
		ProcessingStep(bool & cc, bool & rqm, bool & upd);

		/**	Execute one processing step.
			@param	cc	Flag: Can continue.
			@param	rqm	Flag: Require more idle events.
			@param	upd	Flag: Update dialog after step.
		*/
		void
		ProcessingNewFile(bool & cc, bool & rqm, bool & upd);

		/**	Execute one processing step.
			@param	cc	Flag: Can continue.
			@param	rqm	Flag: Require more idle events.
			@param	upd	Flag: Update dialog after step.
		*/
		void
		ProcessingGenerateOutput(bool & cc, bool & rqm, bool & upd);

		/**	Execute one processing step.
			@param	cc	Flag: Can continue.
			@param	rqm	Flag: Require more idle events.
			@param	upd	Flag: Update dialog after step.
		*/
		void
		ProcessingWriteOutput(bool & upd);

		/**	Add one input file name to storage.
			@param	infilename	Input candidate file.
			@param	checkmake	Flag: Check whether output file exists.
			@param	ok			Success variable to reset on errors.
		*/
		void
		AddNameToStorage(
			wxString &	infilename,
			bool		checkmake,
			bool &		ok
		);

		/**	Check whether a file name is suitable as input file.
			@param	infilename	Input file name to check.
			@return	True if the file can be used, false otherwise.
		*/
		bool
		CheckNameSuffix(wxChar const *infilename);

    /**	Flag: GUI ok.
    */
    bool dkctGUILayoutOK;

    /**	GUI element sDialog.
    */
#line 12 "Bmpp4Progress.wxc"
    wxBoxSizer *sDialog;

    /**	GUI element verticalSizer.
    */
#line 18 "Bmpp4Progress.wxc"
    wxBoxSizer *verticalSizer;

    /**	GUI element lFilename.
    */
#line 31 "Bmpp4Progress.wxc"
    wxStaticText *lFilename;

    /**	GUI element lProcessingStep.
    */
#line 34 "Bmpp4Progress.wxc"
    wxStaticText *lProcessingStep;

    /**	GUI element gProgress.
    */
#line 37 "Bmpp4Progress.wxc"
    wxGauge *gProgress;

    /**	GUI element bCancel.
    */
#line 42 "Bmpp4Progress.wxc"
    wxButton *bCancel;


#line 261 "Bmpp4Progress.wxc"

	public:

		/**	Constructor.
			@param	parent			Parent window.
			@param	pAH				Application helper.
			@param	localizedTexts	Localized texts in users language.
			@param	dirname			Directory or file to process.
			@param	grco			Graphics configuration.
			@param	makemode		Bool: Operate like "make".
			@param	errStr			Error string to store error messages.
		*/
		Bmpp4Progress(
			wxFrame					*parent,
			Dk4WxApplicationHelper	*pAH,
			wxChar const * const	*localizedTexts,
			wxString				 dirname,
			dk4_gra_conf_t const	*grco,
			bool					 makemode,
			wxString				*errStr
		);

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

		/**	Prepare data structures for processing.
			@return	True on success, false on error.
		*/
		bool
		PrepareProcessing(void);

		/**	Clean up data structures after processing.
		*/
		void
		Cleanup(void);

		/**	Idle event handler, do processing step.
			@param	event	Event to process.
		*/
		void
		OnIdle(wxIdleEvent & event);

		/**	Cancel button handler, abort processing.
			@param	event	Event to process.
		*/
		void
		OnCancel(wxCommandEvent & event);

		bool
		CanEnterCriticalSection(void);

		void
		LeaveCriticalSection(void);

};




#line 321 "Bmpp4Progress.wxc"

/* vim: set ai sw=4 ts=4 : */


#endif