1 /*
2 Copyright (C) 2015-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: Dk4WxApplicationHelper.cpt
12 */
13 
14 #ifndef DK4WXAPPLICATIONHELPER_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4WXAPPLICATIONHELPER_H_INCLUDED 1
17 
18 
19 /**	@file	Dk4WxApplicationHelper.h	The Dk4WxApplicationHelper
20 	class.
21 */
22 
23 #ifndef DK4CONF_H_INCLUDED
24 #if DK4_BUILDING_DKTOOLS4
25 #include "dk4conf.h"
26 #else
27 #include <dktools-4/dk4conf.h>
28 #endif
29 #endif
30 
31 #ifndef	DK4_SIZEOF_WXCHAR
32 #ifndef	DK4WXCS_H_INCLUDED
33 #if DK4_BUILDING_DKTOOLS4
34 #include "dk4wxcs.h"
35 #else
36 #include <dktools-4/dk4wxcs.h>
37 #endif
38 #endif
39 #endif
40 
41 #ifndef DK4TYPES_H_INCLUDED
42 #if DK4_BUILDING_DKTOOLS4
43 #include <libdk4base/dk4types.h>
44 #else
45 #include <dktools-4/dk4types.h>
46 #endif
47 #endif
48 
49 #ifndef DK4CONST_H_INCLUDED
50 #if DK4_BUILDING_DKTOOLS4
51 #include <libdk4base/dk4const.h>
52 #else
53 #include <dktools-4/dk4const.h>
54 #endif
55 #endif
56 
57 #ifndef DK4ERROR_H_INCLUDED
58 #if DK4_BUILDING_DKTOOLS4
59 #include <libdk4base/dk4error.h>
60 #else
61 #include <dktools-4/dk4error.h>
62 #endif
63 #endif
64 
65 #ifndef DK4STO_H_INCLUDED
66 #if DK4_BUILDING_DKTOOLS4
67 #include <libdk4c/dk4sto.h>
68 #else
69 #include <dktools-4/dk4sto.h>
70 #endif
71 #endif
72 
73 #ifndef DK4WXCS_H_INCLUDED
74 #if DK4_BUILDING_DKTOOLS4
75 #include "dk4wxcs.h"
76 #else
77 #include <dktools-4/dk4wxcs.h>
78 #endif
79 #endif
80 
81 #ifndef DK4FSH_H_INCLUDED
82 #if DK4_BUILDING_DKTOOLS4
83 #include <libdk4c/dk4fs.h>
84 #else
85 #include <dktools-4/dk4fs.h>
86 #endif
87 #endif
88 
89 #ifndef WX_WXPREC_H_INCLUDED
90 #include <wx/wxprec.h>
91 #define WX_WXPREC_H_INCLUDED 1
92 #endif
93 
94 #ifdef __BORLANDC__
95 #pragma hdrstop
96 #endif
97 
98 #ifndef WX_PRECOMP
99 #ifndef WX_WX_H_INCLUDED
100 #include <wx/wx.h>
101 #define	WX_WX_H_INCLUDED 1
102 #endif
103 #endif
104 
105 #ifndef WX_CONFIG_H_INCLUDED
106 #include <wx/config.h>
107 #define	WX_CONFIG_H_INCLUDED 1
108 #endif
109 
110 #ifndef WX_FILENAME_H_INCLUDED
111 #include <wx/filename.h>
112 #define	WX_FILENAME_H_INCLUDED 1
113 #endif
114 
115 #ifndef WX_THREAD_H_INCLUDED
116 #include <wx/thread.h>
117 #define	WX_THREAD_H_INCLUDED 1
118 #endif
119 
120 #ifndef DK4WXSTT_H_INCLUDED
121 #if DK4_BUILDING_DKTOOLS4
122 #include <libdk4wx/dk4wxstt.h>
123 #else
124 #include <dktools-4/dk4wxstt.h>
125 #endif
126 #endif
127 
128 
129 /**	Application helper.
130 	Each application should have one application helper object
131 	as the member of the wxApp-derived application class.
132 	In the applications OnInit() method call the Initialize() method.
133 */
134 class Dk4WxApplicationHelper
135 {
136   protected:
137 
138     /**	Synchronization for access from multiple threads.
139     */
140     wxCriticalSection		csProtect;
141 
142     /**	The basic strings for GUIs.
143     */
144     const wxChar * const	*ppBasicStrings;
145 
146     /**	Software vendor name.
147     */
148     const wxChar		*pcwxsVendor;
149 
150     /**	First command line argument.
151     */
152     const wxChar		*pcwxsArgv0;
153 
154     /**	Application group name.
155     */
156     const dkChar		*pcdksGroup;
157 
158     /**	Application name.
159     */
160     wxChar			*pwxsApp;
161 
162     /**	The /usr/share equivalent directory.
163     */
164     wxChar			*pwxsShare;
165 
166     /**	First command line argument (allocated).
167     */
168     dkChar			*pcdksArgv0;
169 
170     /**	Host name.
171     */
172     dkChar			*pdksHost;
173 
174     /**	Users login name.
175     */
176     dkChar			*pdksLogname;
177 
178     /**	Home directory.
179     */
180     dkChar			*pdksHome;
181 
182     /**	Application name.
183     */
184     dkChar			*pdksApp;
185 
186     /**	System configuration directory.
187     */
188     dkChar			*pdksSysconf;
189 
190     /**	Data directory.
191     */
192     dkChar			*pdksShare;
193 
194     /**	Users language.
195     */
196     dkChar			*pdksLanguage;
197 
198     /**	Users region.
199     */
200     dkChar			*pdksRegion;
201 
202     /**	String tables storage.
203     */
204     dk4_sto_t			*sStt;
205 
206     /**	String tables storage iterator.
207     */
208     dk4_sto_it_t		*iStt;
209 
210     /**	System preferences storage.
211     */
212     dk4_sto_t			*sPrSys;
213 
214     /**	System preferences storage iterator.
215     */
216     dk4_sto_it_t		*iPrSys;
217 
218     /**	User preferences storage.
219     */
220     dk4_sto_t			*sPrUser;
221 
222     /**	User preferences storage iterator.
223     */
224     dk4_sto_it_t		*iPrUser;
225 
226     /**	Number of strings in the ppBasicStrings array.
227     */
228     size_t			 nBasicStrings;
229 
230     /**	Encoding for dkChar strings.
231     */
232     int				 iDkEncoding;
233 
234     /**	Encoding for wxChar strings.
235     */
236     int				 iWxEncoding;
237 
238     /**	Expected encoding for file input.
239     */
240     int				 iFiEncoding;
241 
242     /**	Flag: Controller is set up and can be used.
243     */
244     bool			bActive;
245 
246   protected:
247 
248     /**	Clean up internal data structures.
249     */
250     void
251     InternalCleanup(void);
252 
253 
254     /**	Search for data file.
255 	@param	fnb	File name buffer.
256 	@param	szfnb	Buffer size (number of dkChar).
257 	@param	sfn	Short file name.
258 	@param	maxpass	Maximum pass number for search.
259 	@param	aco	Flag: Allow compressed versions.
260 	@return	True if the file was found (name in fnb), false otherwise.
261     */
262     bool
263     InternalFindDataFile(
264       dkChar 		*fnb,
265       size_t		 szfnb,
266       dkChar const	*sfn,
267       int		 maxpass,
268       bool		 aco
269     );
270 
271 #if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
272 
273     /**	Search for data file.
274 	@param	fnb	File name buffer.
275 	@param	szfnb	Buffer size (number of wxChar).
276 	@param	sfn	Short file name.
277 	@param	maxpass	Maximum pass number for search.
278 	@param	aco	Flag: Allow compressed versions.
279 	@return	True if the file was found (name in fnb), false otherwise.
280     */
281     bool
282     InternalFindDataFile(
283       wxChar 		*fnb,
284       size_t		 szfnb,
285       dkChar const	*sfn,
286       int		 maxpass,
287       bool		 aco
288     );
289 
290 #endif
291 
292     /**	Search for documentation or help file.
293 	@param	fnb	File name buffer.
294 	@param	szfnb	Buffer size (number of dkChar).
295 	@param	sfn	Short file name.
296 
297 	The method searches for the file <i>sfn</i> in the
298 	following directories, first file found is returned:
299 	- /usr/share/<i>group</i>/help/<i>program</i>/<i>language</i>/<i>region</i>
300 	- /usr/share/doc/<i>group</i>/help/<i>program</i>/<i>language</i>/<i>region</i>
301 	- /usr/share/<i>group</i>/help/<i>program</i>/<i>language</i>
302 	- /usr/share/doc/<i>group</i>/help/<i>program</i>/<i>language</i>
303 	- /usr/share/<i>group</i>/help/<i>program</i>/en
304 	- /usr/share/doc/<i>group</i>/help/<i>program</i>/en
305 	- /usr/share/<i>group</i>/help/<i>program</i>
306 	- /usr/share/doc/<i>group</i>/help/<i>program</i>
307 
308 	For a relocated installation replace /usr/share by ${datadir}.
309 
310 	@return	True if the file was found (name in fnb), false otherwise.
311     */
312     bool
313     InternalFindHelpFile(
314       dkChar 		*fnb,
315       size_t		 szfnb,
316       dkChar const	*sfn
317     );
318 
319 #if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
320 
321     /**	Search for documentation or help file.
322 	@param	fnb	File name buffer.
323 	@param	szfnb	Buffer size (number of dkChar).
324 	@param	sfn	Short file name.
325 	@return	True if the file was found (name in fnb), false otherwise.
326     */
327     bool
328     InternalFindHelpFile(
329       wxChar 		*fnb,
330       size_t		 szfnb,
331       dkChar const	*sfn
332     );
333 
334 #endif
335 
336     /**	Convert dkChar string to wxChar string.
337 	@param	dptr	Result buffer.
338 	@param	dsz	Buffer size (number of wxChar).
339 	@param	sptr	Source string.
340 	@param	erp	Error report, may be NULL.
341 
342 	Error codes:
343 	- DK4_E_INVALID_ARGUMENTS<br>
344 	  if dptr or sptr is NULL or dsz is 0,
345 	- DK4_E_BUFFER_TOO_SMALL<br>
346 	  if dptr is too small,
347 	- DK4_E_SYNTAX<br>
348 	  if a non-recodable character was found.
349     */
350     bool
351     InternalStringToWx(
352       wxChar *dptr, size_t dsz, const dkChar *sptr, dk4_er_t *erp
353     );
354 
355     /**	Convert wxChar string to dkChar string.
356 	@param	dptr	Result buffer.
357 	@param	dsz	Result buffer size (number of dkChar).
358 	@param	sptr	Source string.
359 	@param	erp	Error report, may be NULL.
360 
361 	Error codes:
362 	- DK4_E_INVALID_ARGUMENTS<br>
363 	  if dptr or sptr is NULL or dsz is 0,
364 	- DK4_E_BUFFER_TOO_SMALL<br>
365 	  if dptr is too small,
366 	- DK4_E_SYNTAX<br>
367 	  if a non-recodable character was found.
368     */
369     bool
370     InternalStringToDk(
371       dkChar *dptr, size_t dsz, const wxChar *sptr, dk4_er_t *erp
372     );
373 
374     /**	Retrieve a string table.
375     	@param	tableName	Short string table file name.
376 	@param	tableSize	Minimum number of elements required in table.
377 	@return	Pointer to string table found or NULL.
378     */
379     const wxChar * const *
380     InternalGetStringTable(
381       const dkChar		*tableName,
382       size_t			 tableSize
383     );
384 
385     /**	Save multiple long values.
386 	@param	names	Entry names array, sz elements.
387 	@param	array	Values, sz elements.
388 	@param	sz	Array size for names and array.
389 	@return	True on success, false on error.
390     */
391     bool
392     InternalSetMultiple(const wxChar * const *names, long *array, size_t sz);
393 
394     /**	Save multiple int values.
395 	@param	names	Entry names array, sz elements.
396 	@param	array	Values, sz elements.
397 	@param	sz	Array size for names and array.
398 	@return	True on success, false on error.
399     */
400     bool
401     InternalSetMultiple(const wxChar * const *names, int *array, size_t sz);
402 
403     /**	Save multiple bool values.
404 	@param	names	Entry names array, sz elements.
405 	@param	array	Values, sz elements.
406 	@param	sz	Array size for names and array.
407 	@return	True on success, false on error.
408     */
409     bool
410     InternalSetMultiple(const wxChar * const *names, bool *array, size_t sz);
411 
412     /**	Save multiple double values.
413 	@param	names	Entry names array, sz elements.
414 	@param	array	Values, sz elements.
415 	@param	sz	Array size for names and array.
416 	@return	True on success, false on error.
417     */
418     bool
419     InternalSetMultiple(const wxChar * const *names, double *array, size_t sz);
420 
421     /**	Save multiple string values.
422 	@param	names	Entry names array, sz elements.
423 	@param	array	Values, sz elements.
424 	@param	sz	Array size for names and array.
425 	@return	True on success, false on error.
426     */
427     bool
428     InternalSetMultiple(
429       const wxChar * const *names, const wxChar * const *array, size_t sz
430     );
431 
432     /**	Retrieve multiple long values.
433 	@param	names	Entry names array, sz elements.
434 	@param	array	Values, sz elements.
435 	@param	sz	Array size for names and array.
436 	@return	True on success, false on error.
437     */
438     bool
439     InternalGetMultiple(const wxChar * const *names, long *array, size_t sz);
440 
441     /**	Retrieve multiple int values.
442 	@param	names	Entry names array, sz elements.
443 	@param	array	Values, sz elements.
444 	@param	sz	Array size for names and array.
445 	@return	True on success, false on error.
446     */
447     bool
448     InternalGetMultiple(const wxChar * const *names, int *array, size_t sz);
449 
450     /**	Retrieve multiple bool values.
451 	@param	names	Entry names array, sz elements.
452 	@param	array	Values, sz elements.
453 	@param	sz	Array size for names and array.
454 	@return	True on success, false on error.
455     */
456     bool
457     InternalGetMultiple(const wxChar * const *names, bool *array, size_t sz);
458 
459     /**	Retrieve multiple double values.
460 	@param	names	Entry names array, sz elements.
461 	@param	array	Values, sz elements.
462 	@param	sz	Array size for names and array.
463 	@return	True on success, false on error.
464     */
465     bool
466     InternalGetMultiple(const wxChar * const *names, double *array, size_t sz);
467 
468     /**	Retrieve multiple string values.
469 	@param	names	Entry names array, sz elements.
470 	@param	array	Values, sz elements.
471 	@param	sz	Array size for names and array.
472 	@param	ov	Flag: Overwrite existing strings.
473 	Memory for already existing strings is freed, memory for the new
474 	found string is allocated if the flag is set. Existing strings
475 	are left untouched if the flag is not set.
476 	@return	True on success, false on error.
477     */
478     bool
479     InternalGetMultiple(
480       const wxChar * const *names, wxChar **array, size_t sz, bool ov = true
481     );
482 
483     /**	Create copy of pdksShare to pwxsShare.
484     */
485     void
486     UpdateWxsShare(void);
487 
488   public:
489 
490     /**	Error codes in Initialize().
491     */
492     enum {
493     			/**	No error occured.
494     			*/
495       ERROR_NONE	=	0,
496 
497     			/**	Not enough memory.
498     			*/
499       ERROR_MEMORY ,
500 
501     			/**	Failed to find host name.
502     			*/
503       ERROR_HOSTNAME ,
504 
505     			/**	Failed to find localization settings.
506     			*/
507       ERROR_LANG_REG_ENC ,
508 
509     			/**	Failed to find login name.
510     			*/
511       ERROR_LOGNAME ,
512 
513     			/**	Failed to find home directory.
514     			*/
515       ERROR_HOMEDIR ,
516 
517     			/**	Failed to find path name of executable.
518     			*/
519       ERROR_EXECUTABLE ,
520 
521     			/**	Executable file name too long.
522     			*/
523       ERROR_EXEC_TOO_LONG ,
524 
525     			/**	Invalid arguments were passed to Initialize().
526     			*/
527       ERROR_ARGUMENTS ,
528     };
529 
530     /**	Default constructor.
531     */
532     Dk4WxApplicationHelper();
533 
534     /**	Destructor.
535     */
536     ~Dk4WxApplicationHelper();
537 
538     /**	Initialize before used, called from the applications OnInit() method.
539 	If this method returns false, the OnInit() method should return
540 	false too.
541 	@param	argv0		First command line argument.
542 	@param	vendorName	Software vendor name.
543 	@param	groupName	Application group name.
544 	@param	erp		Error report, may be NULL.
545 	@return	True if initialized successfully, false otherwise.
546 
547 	Error codes:
548 	- DK4_E_NOT_FOUND<br>
549 	  if the system function(s) failed to find the name of the
550 	  file currently executed or the users home directory
551 	  or the users home directory or login name,
552 	- DK4_E_SYSTEM<br>
553 	  if the function failed to find the current working directory,
554 	- DK4_E_SYNTAX<br>
555 	  if there are string conversion problems,
556 	- DK4_E_BUFFER_TOO_SMALL<br>
557 	  if the internal buffer is too small to hold the file name
558 	  of the executed file, the users home directory, login name
559 	  or a conversion buffer is too small,
560 	- DK4_E_SYNTAX<br>
561 	  if a Windows registry entry differs from the expected type.
562 	- DK4_E_MATH_OVERFLOW<br>
563 	  if a numeric overflow occured in a memory allocation size
564 	  calculation,
565 	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
566 	  if a memory allocation attempt failed due to insufficient memory.
567 
568     */
569     bool
570     Initialize(
571       const wxChar	*argv0,
572       const wxChar	*vendorName,
573       const dkChar	*groupName,
574       dk4_er_t		*erp		= NULL
575     );
576 
577     /**	Clean up internal data structures.
578 	You should call this from the applications OnExit() method.
579     */
580     void
581     Cleanup(void);
582 
583     /**	Search for data file.
584 	@param	fnb	File name buffer.
585 	@param	szfnb	Buffer size (number of dkChar).
586 	@param	sfn	Short file name.
587 	@param	maxpass	Maximum pass number for search.
588 	@param	aco	Flag: Allow compressed versions.
589 	@return	True if the file was found (name in fnb), false otherwise.
590     */
591     bool
592     FindDataFile(
593       dkChar 		*fnb,
594       size_t		 szfnb,
595       dkChar const	*sfn,
596       int		 maxpass	= DK4_FS_DATA_MAX_SYS,
597       bool		 aco		= false
598     );
599 
600 #if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
601 
602     /**	Search for data file.
603 	@param	fnb	File name buffer.
604 	@param	szfnb	Buffer size (number of wxChar).
605 	@param	sfn	Short file name.
606 	@param	maxpass	Maximum pass number for search.
607 	@param	aco	Flag: Allow compressed versions.
608 	@return	True if the file was found (name in fnb), false otherwise.
609     */
610     bool
611     FindDataFile(
612       wxChar 		*fnb,
613       size_t		 szfnb,
614       dkChar const	*sfn,
615       int		 maxpass	= DK4_FS_DATA_MAX_SYS,
616       bool		 aco		= false
617     );
618 
619 #endif
620 
621     /**	Search for documentation or help file.
622 	@param	fnb	File name buffer.
623 	@param	szfnb	Buffer size (number of dkChar).
624 	@param	sfn	Short file name.
625 	@return	True if the file was found (name in fnb), false otherwise.
626     */
627     bool
628     FindHelpFile(
629       dkChar 		*fnb,
630       size_t		 szfnb,
631       dkChar const	*sfn
632     );
633 
634 #if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
635 
636     /**	Search for documentation or help file.
637 	@param	fnb	File name buffer.
638 	@param	szfnb	Buffer size (number of dkChar).
639 	@param	sfn	Short file name.
640 	@return	True if the file was found (name in fnb), false otherwise.
641     */
642     bool
643     FindHelpFile(
644       wxChar 		*fnb,
645       size_t		 szfnb,
646       dkChar const	*sfn
647     );
648 
649 #endif
650 
651     /**	Retrieve dkChar encoding.
652 	@return	Encoding.
653     */
654     int
655     GetDkEncoding(void);
656 
657     /**	Retrieve wxChar encoding.
658 	@return	Encoding.
659     */
660     int
661     GetWxEncoding(void);
662 
663     /**	Retrieve expected input encoding when reading files.
664 	@return	Encoding.
665     */
666     int
667     GetFiEncoding(void);
668 
669     /**	Retrieve a string table.
670     	@param	tableName	Short string table file name.
671 	@param	defaultTable	Default strings to use if not found.
672 	@return	Pointer to string table found or defaultTable.
673     */
674     const wxChar * const *
675     GetStringTable(
676       const dkChar		*tableName,
677       const wxChar * const	*defaultTable
678     );
679 
680     /**	Retrieve one of the basic strings.
681 	@param	numstr	Index of string in basic strings array.
682 	@return	String pointer on success, NULL on error (index out of range).
683     */
684     const wxChar *
685     GetBasicString(size_t numstr);
686 
687     /**	Retrieve entire basic strings array.
688 	@param	pNumBasicStrings	Address of variable to store the
689 	array length, may be NULL.
690 	@return	Pointer to array of basic strings.
691     */
692     const wxChar * const	*
693     GetBasicStrings(size_t *pNumBasicStrings = NULL);
694 
695     /**	Convert dkChar string to wxChar string.
696 	@param	dptr	Result buffer.
697 	@param	dsz	Buffer size (number of wxChar).
698 	@param	sptr	Source string.
699 	@param	erp	Error report, may be NULL.
700 
701 	Error codes:
702 	- DK4_E_INVALID_ARGUMENTS<br>
703 	  if dptr or sptr is NULL or dsz is 0,
704 	- DK4_E_BUFFER_TOO_SMALL<br>
705 	  if dptr is too small,
706 	- DK4_E_SYNTAX<br>
707 	  if a non-recodable character was found.
708     */
709     bool
710     StringToWx(
711       wxChar *dptr, size_t dsz, const dkChar *sptr, dk4_er_t *erp = NULL
712     );
713 
714     /**	Convert wxChar string to dkChar string.
715 	@param	dptr	Result buffer.
716 	@param	dsz	Result buffer size (number of dkChar).
717 	@param	sptr	Source string.
718 	@param	erp	Error report, may be NULL.
719 
720 	Error codes:
721 	- DK4_E_INVALID_ARGUMENTS<br>
722 	  if dptr or sptr is NULL or dsz is 0,
723 	- DK4_E_BUFFER_TOO_SMALL<br>
724 	  if dptr is too small,
725 	- DK4_E_SYNTAX<br>
726 	  if a non-recodable character was found.
727     */
728     bool
729     StringToDk(
730       dkChar *dptr, size_t dsz, const wxChar *sptr, dk4_er_t *erp = NULL
731     );
732 
733     /**	Convert wxChar string to char string.
734 	@param	dptr	Result buffer.
735 	@param	dsz	Result buffer size (number of char).
736 	@param	sptr	Source string.
737 	@param	erp	Error report, may be NULL.
738 
739 	Error codes:
740 	- DK4_E_INVALID_ARGUMENTS<br>
741 	  if dptr or sptr is NULL or dsz is 0,
742 	- DK4_E_BUFFER_TOO_SMALL<br>
743 	  if dptr is too small,
744 	- DK4_E_SYNTAX<br>
745 	  if a non-recodable character was found.
746     */
747     bool
748     StringToChar(
749       char *dptr, size_t dsz, const wxChar *sptr, dk4_er_t *erp = NULL
750     );
751 
752     /**	Save multiple long values.
753 	@param	names	Entry names array, sz elements.
754 	@param	array	Values, sz elements.
755 	@param	sz	Array size for names and array.
756 	@return	True on success, false on error.
757     */
758     bool
759     SetMultiple(const wxChar * const *names, long *array, size_t sz);
760 
761     /**	Save multiple int values.
762 	@param	names	Entry names array, sz elements.
763 	@param	array	Values, sz elements.
764 	@param	sz	Array size for names and array.
765 	@return	True on success, false on error.
766     */
767     bool
768     SetMultiple(const wxChar * const *names, int *array, size_t sz);
769 
770     /**	Save multiple bool values.
771 	@param	names	Entry names array, sz elements.
772 	@param	array	Values, sz elements.
773 	@param	sz	Array size for names and array.
774 	@return	True on success, false on error.
775     */
776     bool
777     SetMultiple(const wxChar * const *names, bool *array, size_t sz);
778 
779     /**	Save multiple double values.
780 	@param	names	Entry names array, sz elements.
781 	@param	array	Values, sz elements.
782 	@param	sz	Array size for names and array.
783 	@return	True on success, false on error.
784     */
785     bool
786     SetMultiple(const wxChar * const *names, double *array, size_t sz);
787 
788     /**	Save multiple string values.
789 	@param	names	Entry names array, sz elements.
790 	@param	array	Values, sz elements.
791 	@param	sz	Array size for names and array.
792 	@return	True on success, false on error.
793     */
794     bool
795     SetMultiple(
796       const wxChar * const *names, const wxChar * const *array, size_t sz
797     );
798 
799     /**	Retrieve multiple long values.
800 	@param	names	Entry names array, sz elements.
801 	@param	array	Values, sz elements.
802 	@param	sz	Array size for names and array.
803 	@return	True on success, false on error.
804     */
805     bool
806     GetMultiple(const wxChar * const *names, long *array, size_t sz);
807 
808     /**	Retrieve multiple int values.
809 	@param	names	Entry names array, sz elements.
810 	@param	array	Values, sz elements.
811 	@param	sz	Array size for names and array.
812 	@return	True on success, false on error.
813     */
814     bool
815     GetMultiple(const wxChar * const *names, int *array, size_t sz);
816 
817     /**	Retrieve multiple bool values.
818 	@param	names	Entry names array, sz elements.
819 	@param	array	Values, sz elements.
820 	@param	sz	Array size for names and array.
821 	@return	True on success, false on error.
822     */
823     bool
824     GetMultiple(const wxChar * const *names, bool *array, size_t sz);
825 
826     /**	Retrieve multiple double values.
827 	@param	names	Entry names array, sz elements.
828 	@param	array	Values, sz elements.
829 	@param	sz	Array size for names and array.
830 	@return	True on success, false on error.
831     */
832     bool
833     GetMultiple(const wxChar * const *names, double *array, size_t sz);
834 
835     /**	Retrieve multiple string values.
836 	@param	names	Entry names array, sz elements.
837 	@param	array	Values, sz elements.
838 	@param	sz	Array size for names and array.
839 	@param	ov	Flag: Overwrite existing strings.
840 	Memory for already existing strings is freed, memory for the new
841 	found string is allocated if the flag is set. Existing strings
842 	are left untouched if the flag is not set.
843 	@return	True on success, false on error.
844     */
845     bool
846     GetMultiple(
847       const wxChar * const *names, wxChar **array, size_t sz, bool ov = true
848     );
849 
850     /**	Save one key value pair of strings.
851     	@param	key	Key string.
852 	@param	value	Value string.
853 	@return	True on success, false on error.
854     */
855     bool
856     SetString(const wxString & key, const wxString & value);
857 
858     /**	Retrieve one string value.
859     	@param	key	Key string.
860 	@param	pvalue	Address of value string.
861 	@return	True on success, false on error.
862     */
863     bool
864     GetString(const wxString & key, wxString *pvalue);
865 
866     /**	Get argv[0] command line argument as dkChar string.
867     	@return	Valid pointer on success, NULL on error.
868     */
869     const
870     dkChar *
871     GetDkArgv0(void);
872 
873     /**	Get group name.
874     	@return	Valid pointer on success, NULL on error.
875     */
876     const
877     dkChar *
878     GetDkGroupName(void);
879 
880 	/**	Get /usr/share equivalent directory.
881 		@return	Valid pointer on success, NULL on error.
882 	*/
883 	const
884 	wxChar *
885 	GetWxsShare(void) const ;
886 
887     /**	Correct top level frame position.
888     	Negative x or y values can occur for two purposes:
889 	* When restoring saved positions negative values indicate
890 	  that no position was saved yet. The window should be centered.
891 	  Set cn=true for this interpretation.
892 	* If the position was calculated relatively to another window
893 	  or frame the window should not exceed the screen. The negative
894 	  value should be corrected to 0.
895 	  Set cn=false for this interpretation.
896 	@param	x	Window x position.
897 	@param	y	Window y position.
898 	@param	w	Window width.
899 	@param	h	Window height.
900 	@param	cn	Flag: Center window on screen for negative x or y.
901     */
902     static
903     void
904     CorrectPosition(int & x, int & y, int & w, int & h, bool cn = true);
905 
906     /**	Correct position of a top level window (frame or dialog).
907     	Negative x or y values can occur for two purposes:
908 	* When restoring saved positions negative values indicate
909 	  that no position was saved yet. The window should be centered.
910 	  Set cn=true for this interpretation.
911 	* If the position was calculated relatively to another window
912 	  or frame the window should not exceed the screen. The negative
913 	  value should be corrected to 0.
914 	  Set cn=false for this interpretation.
915 	@param	w	Window to correct.
916 	@param	cn	Flag: Center window on screen for negative x or y.
917     */
918     static
919     void
920     CorrectPosition(wxWindow & w, bool cn = true);
921 
922     /**	Choose position for a child top level window (frame or dialog).
923 	@param	p	Parent window, unchanged.
924 	@param	c	Child window, position is set.
925 	@param	beside	Flag: Position child beside parent, not on top.
926     */
927     static
928     void
929     ChooseChildPosition(
930       const wxWindow & p, wxWindow & c, bool beside = false
931     );
932 
933     /**	Find string table size (number of strings in table).
934 	@param	sttptr	String table to find size for.
935 	@return	Size of string table.
936     */
937     static
938     size_t
939     StringTableSize(const wxChar * const *sttptr);
940 
941     /**	Release array of wxChar strings.
942 	@param	array	Array, array contents is to release.
943 	@param	sz	Array size.
944 	@param	ea	Flag: After releasing contents, release array itself.
945     */
946     static
947     void
948     ReleaseWxcharStringArray(wxChar **array, size_t sz, bool ea = false);
949 
950 };
951 
952 
953 
954 /* vim: set ai sw=4 ts=4 : */
955 
956 
957 #endif
958