summaryrefslogtreecommitdiff
path: root/support/dktools/Dk4WxApplicationHelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'support/dktools/Dk4WxApplicationHelper.cpp')
-rw-r--r--support/dktools/Dk4WxApplicationHelper.cpp2539
1 files changed, 0 insertions, 2539 deletions
diff --git a/support/dktools/Dk4WxApplicationHelper.cpp b/support/dktools/Dk4WxApplicationHelper.cpp
deleted file mode 100644
index 4959db750e..0000000000
--- a/support/dktools/Dk4WxApplicationHelper.cpp
+++ /dev/null
@@ -1,2539 +0,0 @@
-/*
-Copyright (C) 2015-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: Dk4WxApplicationHelper.cpt
-*/
-
-/** @file Dk4WxApplicationHelper.cpp The Dk4WxApplicationHelper module.
-*/
-
-
-#line 948 "Dk4WxApplicationHelper.cpt"
-
-#include "dk4conf.h"
-
-#include "Dk4WxApplicationHelper.h"
-
-#include "dk4mem.h"
-#include "dk4enc.h"
-#include "dk4strd.h"
-#include "dk4strx.h"
-#include "dk4recwx.h"
-#include "dk4wxpref.h"
-#include "dk4wxstt.h"
-#include "dk4hnamed.h"
-#include "dk4loc.h"
-#include "dk4user.h"
-#include "dk4mpl.h"
-#include "dk4vers.h"
-#include "dk4exepd.h"
-#include "dk4inst.h"
-#include "dk4pathd.h"
-#if DK4_SIZEOF_WXCHAR > 1
-#include "dk4strw.h"
-#include "dk4maiwdil.h"
-#include "dk4maiwdbl.h"
-#else
-#include "dk4str8.h"
-#include "dk4mai8dil.h"
-#include "dk4mai8dbl.h"
-#endif
-
-
-
-
-
-#line 981 "Dk4WxApplicationHelper.cpt"
-
-
-
-/* ************************************************************************ */
-/* * * */
-/* * Type definitions. * */
-/* * * */
-/* ************************************************************************ */
-
-
-#line 987 "Dk4WxApplicationHelper.cpt"
-
-
-
-/** Pointer to constant wxChar.
-*/
-typedef const wxChar *PCWXCHAR;
-
-
-
-
-
-
-/* ************************************************************************ */
-/* * * */
-/* * Variables. * */
-/* * * */
-/* ************************************************************************ */
-
-
-#line 1002 "Dk4WxApplicationHelper.cpt"
-
-
-
-/** Empty string, returned for all strings not found.
-*/
-static const wxChar dk4wxah_empty_string[] = { wxT("") };
-
-
-
-/** File name separator string
-*/
-static const dkChar dk4wxah_fnsep_str[] = {
-#if DK4_ON_WINDOWS
-dkT("\\")
-#else
-dkT("/")
-#endif
-} ;
-
-
-
-/** Texts used in error message boxes in the Initialize() function.
-*/
-static const wxChar * const dkwxah_msgb_texts[] = {
-/* 0 */
-wxT("Initialization failed!"),
-
-/* 1 */
-wxT("Not enough memory!"),
-
-/* 2 */
-wxT("Failed to find current host name!"),
-
-/* 3 */
-wxT("Failed to find language, region, and encoding settings!"),
-
-/* 4 */
-wxT("Failed to find users login name!"),
-
-/* 5 */
-wxT("Failed to find users home directory!"),
-
-/* 6 */
-wxT("Failed to find executable file name!"),
-
-/* 7 */
-wxT("Executable file name too long!"),
-
-/* 8 */
-wxT("Illegal arguments (NULL pointers) to Initialize() function!"),
-
-NULL
-
-
-#line 1064 "Dk4WxApplicationHelper.cpt"
-};
-
-
-
-/** Constant text keywords used by module, not localized.
-*/
-static const dkChar * const dk4wxah_kwnl_dk[] = {
-/* 0 */
-dkT("dk4wxbase.str"),
-
-NULL
-
-
-#line 1077 "Dk4WxApplicationHelper.cpt"
-};
-
-
-
-/** Constant text strings used by the module, not localized.
-*/
-static const char * const dk4wxah_kwnl_c8[] = {
-/* 0 */
-"C",
-
-NULL
-
-
-#line 1087 "Dk4WxApplicationHelper.cpt"
-};
-
-
-
-/** Final directory names for good installations.
-*/
-static const dkChar * const dk4wxah_final_directories[] = {
-/* 0 */
-dkT("bin"),
-
-/* 1 */
-dkT("sbin"),
-
-/* 2 */
-dkT("libexec"),
-
-/* 3 */
-dkT("lib"),
-
-NULL
-
-
-#line 1100 "Dk4WxApplicationHelper.cpt"
-};
-
-
-
-/** New final directory names to append.
-*/
-static const dkChar * const dk4wxah_new_directories[] = {
-/* 0 */
-dkT("etc"),
-
-/* 1 */
-dkT("share"),
-
-NULL
-
-
-#line 1111 "Dk4WxApplicationHelper.cpt"
-};
-
-
-
-/** Basic strings, replaced by localized texts later.
-*/
-static const wxChar * const dk4wxah_basic_strings[] = {
-/* 0 */
-wxT("Help file not found"),
-
-/* 1 */
-wxT("The file containing online help text was not found on your computer!"),
-
-/* 2 */
-wxT("Processing in progress"),
-
-/* 3 */
-wxT("Cancel"),
-
-/* 4 */
-wxT("Abort current operation"),
-
-/* 5 */
-wxT("Abortion scheduled, wait please!"),
-
-/* 6 */
-wxT("Error"),
-
-/* 7 */
-wxT("Not enough memory (RAM)!"),
-
-/* 8 */
-wxT("Illegal arguments in Dk4WxHelpController constructor (bug)!"),
-
-/* 9 */
-wxT("File not found"),
-
-/* 10 */
-wxT("The file to display was not found!"),
-
-/* 11 */
-wxT("Error"),
-
-/* 12 */
-wxT("Failed to start browser or application for file\n\""),
-
-/* 13 */
-wxT("\"."),
-
-/* 14 */
-wxT("Yes"),
-
-/* 15 */
-wxT("No"),
-
-NULL
-
-
-#line 1160 "Dk4WxApplicationHelper.cpt"
-};
-
-
-
-/* ************************************************************************ */
-/* * * */
-/* * Internal tool functions, not object-oriented. * */
-/* * * */
-/* ************************************************************************ */
-
-
-#line 1167 "Dk4WxApplicationHelper.cpt"
-
-
-
-/** Check whether a directory or file name ends in one of
- the names mentioned in array.
- @param dirname Directory name to check.
- @param array String array containing name ends.
- @return 1 on success with prefix in dirname, 0 on error.
-*/
-static
-int
-dk4wxapplicationhelper_isinsub(dkChar *dirname, const dkChar * const *array)
-{
- dkChar *p1;
- dkChar *p2;
- int cc; /* Flag: Can continue */
- int back = 0; /* Function result */
-
-
-#line 1185 "Dk4WxApplicationHelper.cpt"
- do {
- cc = 0;
- p1 = dirname; p2 = NULL;
- while (dkT('\0') != *p1) {
- if ((dkT('/') == *p1) || (dkT('\\') == *p1)) { p2 = p1; }
- p1++;
- }
- if (NULL != p2) {
- *(p2++) = dkT('\0');
- cc = 1;
-#if DK4_HAVE_CASE_INSENSITIVE_PATHNAMES
- if (0 <= dk4str_array_index(array, p2, 0))
-#else
- if (0 <= dk4str_array_index(array, p2, 1))
-#endif
- {
- back = 1;
- cc = 0;
- }
- } else {
- }
- } while ((1 == cc) && (0 == back));
-
-
-#line 1208 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-/* ************************************************************************ */
-/* * * */
-/* * Constructor, destructor, initialization and cleanup. * */
-/* * * */
-/* ************************************************************************ */
-
-
-#line 1216 "Dk4WxApplicationHelper.cpt"
-
-
-
-Dk4WxApplicationHelper::Dk4WxApplicationHelper()
-{
- /* Set all member variables to "resource not available".
- Real initialization is in the Initialize() method.
- */
-
-
-#line 1225 "Dk4WxApplicationHelper.cpt"
- ppBasicStrings = NULL;
- pcwxsArgv0 = NULL;
- pcwxsVendor = NULL;
- pcdksGroup = NULL;
- pwxsApp = NULL;
- pcdksArgv0 = NULL;
- pdksHost = NULL;
- pdksLogname = NULL;
- pdksHome = NULL;
- pdksApp = NULL;
- pdksSysconf = NULL;
- pdksShare = NULL;
- pwxsShare = NULL;
- pdksLanguage = NULL;
- pdksRegion = NULL;
- sStt = NULL;
- iStt = NULL;
- sPrSys = NULL;
- iPrSys = NULL;
- sPrUser = NULL;
- iPrUser = NULL;
- nBasicStrings = 0;
-#if DK4_ON_WINDOWS
- iDkEncoding = DK4_ENCODING_WIN1252;
- iWxEncoding = DK4_ENCODING_WIN1252;
- iFiEncoding = DK4_FILE_ENCODING_WIN1252;
-#else
- iDkEncoding = DK4_ENCODING_PLAIN;
- iWxEncoding = DK4_ENCODING_PLAIN;
- iFiEncoding = DK4_FILE_ENCODING_PLAIN;
-#endif
- bActive = false;
-
-
-#line 1258 "Dk4WxApplicationHelper.cpt"
-}
-
-
-/*
- We do not need a critical section locker as Initialize()
- is invoked from the applications OnInit() method. At this
- time there is no top level window or worker thread yet.
-*/
-bool
-Dk4WxApplicationHelper::Initialize(
- const wxChar *argv0,
- const wxChar *vendorName,
- const dkChar *groupName,
- dk4_er_t *erp
-)
-{
- dkChar labuf[DK4_MAX_PATH];
- dkChar rebuf[DK4_MAX_PATH];
- wxChar anbuf[DK4_MAX_PATH];
- const wxChar *msgbtext = NULL;
- const wxChar *msgbtitle = NULL;
- dkChar *p1;
- dkChar *p2;
-#if DK4_ON_WINDOWS
- dkChar *p4;
-#endif
- size_t szrebuf = DK4_SIZEOF(rebuf,dkChar);
- size_t szlabuf = DK4_SIZEOF(labuf,dkChar);
- size_t szanbuf = DK4_SIZEOF(anbuf,wxChar);
- int errc = ERROR_NONE;
- int res;
- int pn;
- bool back = false;
-
-
-#line 1292 "Dk4WxApplicationHelper.cpt"
- /* Keep some of the arguments.
- */
- if ((NULL == argv0) || (NULL == vendorName) || (NULL == groupName)) {
- errc = ERROR_ARGUMENTS;
- goto finished;
- }
- pcwxsArgv0 = argv0;
- pcwxsVendor = vendorName;
- pcdksGroup = groupName;
-
-
-#line 1302 "Dk4WxApplicationHelper.cpt"
-
- /* Some default values.
- */
- ppBasicStrings = dk4wxah_basic_strings;
- nBasicStrings = DK4_SIZEOF(dk4wxah_basic_strings,PCWXCHAR) - 1;
-
-
-#line 1308 "Dk4WxApplicationHelper.cpt"
-
- /* Host name.
- */
- if (0 != dk4hostname(labuf, szlabuf, NULL)) {
- p1 = dk4str_chr(labuf, dkT('.'));
- if (NULL != p1) { *p1 = dkT('\0'); }
- pdksHost = dk4str_dup(labuf, NULL);
- if (NULL == pdksHost) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- } else {
- errc = ERROR_HOSTNAME;
- goto finished;
- }
-
-
-#line 1324 "Dk4WxApplicationHelper.cpt"
-
- /* Language and encoding.
- */
- res = dk4loc_get_settings(labuf, szlabuf, rebuf, szrebuf, &iDkEncoding, erp);
- if (0 == res) {
- errc = ERROR_LANG_REG_ENC;
- goto finished;
- }
-#if DK4_SIZEOF_WXCHAR > 1
-#if DK4_SIZEOF_WXCHAR > 2
- iWxEncoding = DK4_ENCODING_32;
-#else
- iWxEncoding = DK4_ENCODING_UTF16;
-#endif
-#else
- switch (iDkEncoding) {
- case DK4_ENCODING_WIN1252 : {
- iWxEncoding = DK4_ENCODING_WIN1252;
- } break;
- case DK4_ENCODING_UTF8 : {
- iWxEncoding = DK4_ENCODING_UTF8;
- } break;
- default : {
-#if DK4_ON_WINDOWS
- iWxEncoding = DK4_ENCODING_WIN1252;
-#else
- iWxEncoding = DK4_ENCODING_PLAIN;
-#endif
- } break;
- }
-#endif
- switch (iDkEncoding) {
- case DK4_ENCODING_WIN1252 : {
- iFiEncoding = DK4_ENCODING_WIN1252;
- } break;
- case DK4_ENCODING_UTF8 : {
- iFiEncoding = DK4_ENCODING_UTF8;
- } break;
- default : {
-#if DK4_ON_WINDOWS
- iFiEncoding = DK4_ENCODING_WIN1252;
-#else
- iFiEncoding = DK4_ENCODING_PLAIN;
-#endif
- } break;
- }
- if (0 < dk4str_len(labuf)) {
- pdksLanguage = dk4str_dup(labuf, erp);
- if (NULL == pdksLanguage) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- }
- if (0 < dk4str_len(rebuf)) {
- pdksRegion = dk4str_dup(rebuf, erp);
- if (NULL == pdksRegion) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- }
-
-
-#line 1385 "Dk4WxApplicationHelper.cpt"
-
- /* Login name and home directory.
- */
- res = dk4user_get_logname(labuf, szlabuf, 0, erp);
- if (0 == res) {
- errc = ERROR_LOGNAME;
- goto finished;
- }
- pdksLogname = dk4str_dup(labuf, erp);
- if (NULL == pdksLogname) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- res = dk4user_get_homedir(labuf, szlabuf, 0, erp);
- if (0 == res) {
-
-#line 1400 "Dk4WxApplicationHelper.cpt"
- errc = ERROR_HOMEDIR;
- goto finished;
- }
- pdksHome = dk4str_dup(labuf, erp);
- if (NULL == pdksHome) {
-
-#line 1405 "Dk4WxApplicationHelper.cpt"
- errc = ERROR_MEMORY;
- goto finished;
- }
-
-
-#line 1409 "Dk4WxApplicationHelper.cpt"
-
- /* System configuration and data directory.
- */
- res = dk4recwx_wxchar_to_dkchar(
- labuf, szlabuf, iDkEncoding, argv0, iWxEncoding, erp
- );
-
-#line 1415 "Dk4WxApplicationHelper.cpt"
- if (0 == res) {
-
-#line 1416 "Dk4WxApplicationHelper.cpt"
- errc = ERROR_EXECUTABLE;
- goto finished;
- }
- pcdksArgv0 = dk4str_dup(labuf, erp);
- if (NULL == pcdksArgv0) {
-
-#line 1421 "Dk4WxApplicationHelper.cpt"
- errc = ERROR_MEMORY;
- goto finished;
- }
- res = dk4execpath(
- rebuf, szrebuf, ((0 != res) ? labuf : NULL), erp
- );
- if (0 == res) {
-
-#line 1428 "Dk4WxApplicationHelper.cpt"
- errc = ERROR_EXECUTABLE;
- goto finished;
- }
-
-#line 1431 "Dk4WxApplicationHelper.cpt"
- p1 = rebuf;
- p2 = NULL;
- while (dkT('\0') != *p1) {
- if (dk4wxah_fnsep_str[0] == *p1) { p2 = p1; }
- /* We must increase this pointer.
- */
- p1++;
- }
- if (NULL == p2) {
-
-#line 1440 "Dk4WxApplicationHelper.cpt"
- errc = ERROR_EXECUTABLE;
- goto finished;
- }
- *(p2++) = dkT('\0');
- /* Binary directory in rebuf, p2 is application name */
-#if DK4_ON_WINDOWS
- /* On Windows, strip .exe suffix.
- */
- p4 = dk4path_get_suffix(p2, NULL);
- if (NULL != p4) { *p4 = dkT('\0'); }
-#endif
- pdksApp = dk4str_dup(p2, NULL);
- if (NULL == pdksApp) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- res = dk4recwx_dkchar_to_wxchar(
- anbuf, szanbuf, iWxEncoding, pdksApp, iDkEncoding, NULL
- );
- if (0 == res) {
-
-#line 1460 "Dk4WxApplicationHelper.cpt"
- errc = ERROR_EXECUTABLE;
- goto finished;
- }
- pwxsApp = dk4strx_dup(anbuf, NULL);
- if (NULL == pwxsApp) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- /* Check whether the binary resides in one of the installation directories */
- res = 0;
- if (0 != dk4path_is_in_subdir(rebuf, dk4inst_get_directory(4), NULL)) {
- res = 1;
- }
- if (0 == res) {
- if (0 != dk4path_is_in_subdir(rebuf, dk4inst_get_directory(5), NULL)) {
- res = 1;
- }
- }
- if (0 == res) {
- if (0 != dk4path_is_in_subdir(rebuf, dk4inst_get_directory(6), NULL)) {
- res = 1;
- }
- }
- if (0 == res) {
- if (0 != dk4path_is_in_subdir(rebuf, dk4inst_get_directory(10), NULL)) {
- res = 1;
- }
- }
- if (0 != res) {
- pdksSysconf = dk4str_dup(dk4inst_get_directory(1), NULL);
- pdksShare = dk4str_dup(dk4inst_get_directory(2), NULL);
- UpdateWxsShare();
- if ((NULL == pdksSysconf) || (NULL == pdksShare)) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- } else {
- dk4str_cpy_s(labuf, szlabuf, rebuf, NULL);
- if (0 != dk4wxapplicationhelper_isinsub(labuf, dk4wxah_final_directories)) {
- res = 0;
- if (0 != dk4str_cpy_s(rebuf, szrebuf, labuf, NULL)) {
- if (0 != dk4str_cat_s(rebuf, szrebuf, dk4wxah_fnsep_str, NULL)) {
- if (0 != dk4str_cat_s(rebuf,szrebuf,dk4wxah_new_directories[0],NULL))
- {
- res = 1;
- }
- }
- }
- if (0 != res) {
- pdksSysconf = dk4str_dup(rebuf, NULL);
- if (NULL == pdksSysconf) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- } else {
- errc = ERROR_EXEC_TOO_LONG;
- goto finished;
- }
- res = 0;
- if (0 != dk4str_cpy_s(rebuf, szrebuf, labuf, NULL)) {
- if (0 != dk4str_cat_s(rebuf, szrebuf, dk4wxah_fnsep_str, NULL)) {
- if (0 != dk4str_cat_s(rebuf,szrebuf,dk4wxah_new_directories[1],NULL))
- {
- res = 1;
- }
- }
- }
- if (0 != res) {
- pdksShare = dk4str_dup(rebuf, NULL);
- UpdateWxsShare();
- if (NULL == pdksShare) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- } else {
- errc = ERROR_EXEC_TOO_LONG;
- goto finished;
- }
- } else {
- pdksSysconf = dk4str_dup(rebuf, NULL);
- pdksShare = dk4str_dup(rebuf, NULL);
- UpdateWxsShare();
- if ((NULL == pdksSysconf) || (NULL == pdksShare)) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- }
- }
-
-
-#line 1549 "Dk4WxApplicationHelper.cpt"
-
- /* Containers and iterators for string tables and preferences.
- */
- sStt = dk4sto_open(NULL);
- if (NULL == sStt) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- dk4sto_set_comp(sStt, dk4wxstt_compare, 0);
- iStt = dk4sto_it_open(sStt, NULL);
- if (NULL == iStt) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- sPrSys = dk4sto_open(NULL);
- if (NULL == sPrSys) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- dk4sto_set_comp(sPrSys, dk4wxpref_compare, 0);
- iPrSys = dk4sto_it_open(sPrSys, NULL);
- if (NULL == iPrSys) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- sPrUser = dk4sto_open(NULL);
- if (NULL == sPrUser) {
- errc = ERROR_MEMORY;
- goto finished;
- }
- dk4sto_set_comp(sPrUser, dk4wxpref_compare, 0);
- iPrUser = dk4sto_it_open(sPrUser, NULL);
- if (NULL == iPrUser) {
- errc = ERROR_MEMORY;
- goto finished;
- }
-
-
-#line 1586 "Dk4WxApplicationHelper.cpt"
-
- /* Read preference files.
- */
- for (pn = 0; pn <= DK4_FS_CONF_MAX; pn++) {
- dk4wxpref_one_pass(
- ((DK4_FS_CONF_SYS_MAX < pn) ? sPrUser : sPrSys),
- ((DK4_FS_CONF_SYS_MAX < pn) ? iPrUser : iPrSys),
- pdksApp,
- pcdksGroup,
- pdksLogname,
- pdksHost,
- pdksLanguage,
- pdksRegion,
- pdksHome,
- pdksSysconf,
- pdksShare,
- iWxEncoding,
- iDkEncoding,
- (
- (DK4_ENCODING_UTF8 == iDkEncoding)
- ? DK4_FILE_ENCODING_UTF8 :
-#if DK4_ON_WINDOWS
- DK4_FILE_ENCODING_WIN1252
-#else
- DK4_FILE_ENCODING_PLAIN
-#endif
- ),
- pn
- );
- }
-
-
-#line 1617 "Dk4WxApplicationHelper.cpt"
-
- /* Localized basic strings.
- */
- ppBasicStrings = InternalGetStringTable(
- dk4wxah_kwnl_dk[0], (DK4_SIZEOF(dk4wxah_basic_strings,PCWXCHAR) - 1)
- );
- if (NULL == ppBasicStrings) { ppBasicStrings = dk4wxah_basic_strings; }
- nBasicStrings = Dk4WxApplicationHelper::StringTableSize(ppBasicStrings);
-
-
-#line 1626 "Dk4WxApplicationHelper.cpt"
-
- /* Finally mark success.
- */
- bActive = back = true;
-
- /* Clean up if not successfully.
- */
- finished:
- if (!(back)) {
-
-#line 1635 "Dk4WxApplicationHelper.cpt"
- switch (errc) {
- case ERROR_MEMORY : {
-
-#line 1637 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[1];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- case ERROR_HOSTNAME : {
-
-#line 1641 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[2];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- case ERROR_LANG_REG_ENC : {
-
-#line 1645 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[3];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- case ERROR_LOGNAME : {
-
-#line 1649 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[4];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- case ERROR_HOMEDIR : {
-
-#line 1653 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[5];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- case ERROR_EXECUTABLE : {
-
-#line 1657 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[6];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- case ERROR_EXEC_TOO_LONG : {
-
-#line 1661 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[7];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- case ERROR_ARGUMENTS : {
-
-#line 1665 "Dk4WxApplicationHelper.cpt"
- msgbtext = dkwxah_msgb_texts[8];
- msgbtitle = dkwxah_msgb_texts[0];
- } break;
- }
- if ((NULL != msgbtext) && (NULL != msgbtitle)) {
- wxMessageBox(
- msgbtext, msgbtitle, (wxOK | wxCENTRE | wxICON_ERROR)
- );
- }
- InternalCleanup();
- }
-
-
-#line 1677 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-void
-Dk4WxApplicationHelper::InternalCleanup(void)
-{
- dk4_wx_string_table_t *wxsttptr;
- dk4_wx_pref_t *pptr;
-
-
-#line 1688 "Dk4WxApplicationHelper.cpt"
- bActive = false; // Object can not longer be used.
- ppBasicStrings = NULL;
- pcwxsArgv0 = NULL;
- pcwxsVendor = NULL;
- pcdksGroup = NULL;
- if (NULL != sPrUser) {
- if (NULL != iPrUser) {
- dk4sto_it_reset(iPrUser);
- do {
- pptr = (dk4_wx_pref_t *)dk4sto_it_next(iPrUser);
- if (NULL != pptr) { dk4wxpref_close(pptr); }
- } while (NULL != pptr);
- dk4sto_it_close(iPrUser);
- iPrUser = NULL;
- }
- dk4sto_close(sPrUser);
- sPrUser = NULL;
- }
- if (NULL != sPrSys) {
- if (NULL != iPrSys) {
- dk4sto_it_reset(iPrSys);
- do {
- pptr = (dk4_wx_pref_t *)dk4sto_it_next(iPrSys);
- if (NULL != pptr) { dk4wxpref_close(pptr); }
- } while (NULL != pptr);
- dk4sto_it_close(iPrSys);
- iPrSys = NULL;
- }
- dk4sto_close(sPrSys);
- sPrSys = NULL;
- }
- if (NULL != sStt) {
- if (NULL != iStt) {
- dk4sto_it_reset(iStt);
- do {
- wxsttptr = (dk4_wx_string_table_t *)dk4sto_it_next(iStt);
- if (NULL != wxsttptr) { dk4wxstt_close(wxsttptr); }
- } while (NULL != wxsttptr);
- dk4sto_it_close(iStt);
- iStt = NULL;
- }
- dk4sto_close(sStt);
- sStt = NULL;
- }
- nBasicStrings = 0;
-#if 0
- /* Leave these integer variables as is.
- */
- iDkEncoding = DK4_ENCODING_PLAIN;
- iWxEncoding = DK4_ENCODING_PLAIN;
- iFiEncoding = DK4_FILE_ENCODING_PLAIN;
-#endif
- dk4mem_release(pdksRegion);
- dk4mem_release(pdksLanguage);
- dk4mem_release(pdksShare);
- dk4mem_release(pwxsShare);
- dk4mem_release(pdksSysconf);
- dk4mem_release(pdksApp);
- dk4mem_release(pdksHost);
- dk4mem_release(pcdksArgv0);
- dk4mem_release(pwxsApp);
- dk4mem_release(pdksLogname);
- dk4mem_release(pdksHome);
-
-
-#line 1752 "Dk4WxApplicationHelper.cpt"
-}
-
-
-
-void
-Dk4WxApplicationHelper::Cleanup(void)
-{
-
-
-#line 1760 "Dk4WxApplicationHelper.cpt"
- {
- wxCriticalSectionLocker lock(csProtect);
- InternalCleanup();
- }
-
-
-#line 1765 "Dk4WxApplicationHelper.cpt"
-}
-
-
-
-/*
- We do not need a critical section locker as the destructor
- is invoked from the applications destructor. At this
- we have no more top level windows or worker threads.
-*/
-Dk4WxApplicationHelper::~Dk4WxApplicationHelper()
-{
-
-
-#line 1777 "Dk4WxApplicationHelper.cpt"
- InternalCleanup();
-
-
-#line 1779 "Dk4WxApplicationHelper.cpt"
-}
-
-
-
-/* ************************************************************************ */
-/* * * */
-/* * Internal functions. * */
-/* * These functions do not attempt synchronization. * */
-/* * * */
-/* ************************************************************************ */
-
-
-#line 1787 "Dk4WxApplicationHelper.cpt"
-
-
-bool
-Dk4WxApplicationHelper::InternalStringToWx(
- wxChar *dptr, size_t dsz, const dkChar *sptr, dk4_er_t *erp
-)
-{
- int res = 0;
- bool back = false;
-
-
-#line 1797 "Dk4WxApplicationHelper.cpt"
- res = dk4recwx_dkchar_to_wxchar(dptr,dsz,iWxEncoding,sptr,iDkEncoding,erp);
- if (0 != res) { back = true; }
-
-
-#line 1800 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalStringToDk(
- dkChar *dptr, size_t dsz, const wxChar *sptr, dk4_er_t *erp
-)
-{
- int res = 0;
- bool back = false;
-
-
-#line 1813 "Dk4WxApplicationHelper.cpt"
- res = dk4recwx_wxchar_to_dkchar(dptr,dsz,iDkEncoding,sptr,iWxEncoding,erp);
- if (0 != res) { back = true; }
-
-
-#line 1816 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalFindDataFile(
- dkChar *fnb,
- size_t szfnb,
- dkChar const *sfn,
- int maxpass,
- bool aco
-)
-{
- int passno = 0;
- int res = 0;
- bool back = false;
-
-
-#line 1834 "Dk4WxApplicationHelper.cpt"
- for (passno = 0; ((passno <= maxpass) && (!(back))); passno++) {
- res = dk4fs_data_one(
- fnb, szfnb, sfn,
- pdksShare, pdksHome, pdksApp, pcdksGroup,
- pdksLanguage, pdksRegion,
- passno, ((aco) ? 1 : 0), NULL
- );
- if (0 != res) { back = true; }
- }
-
-#line 1843 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-
-#if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
-
-bool
-Dk4WxApplicationHelper::InternalFindDataFile(
- wxChar *fnb,
- size_t szfnb,
- dkChar const *sfn,
- int maxpass,
- bool aco
-)
-{
- dkChar buf[DK4_MAX_PATH];
- size_t szbuf = DK4_SIZEOF(buf,dkChar);
- bool back = false;
-
-
-#line 1864 "Dk4WxApplicationHelper.cpt"
- back = InternalFindDataFile(buf, szbuf, sfn, maxpass, aco);
- if (back) {
- back = InternalStringToWx(fnb, szfnb, buf, NULL);
- }
-
-#line 1868 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-#endif
-
-
-
-const wxChar * const *
-Dk4WxApplicationHelper::InternalGetStringTable(
- const dkChar *tableName,
- size_t tableSize
-)
-{
- dkChar fnb[DK4_MAX_PATH];
- dk4_er_t e1;
- dk4_er_t e2;
- const wxChar * const *back = NULL;
- dk4_wx_string_table_t *tabptr = NULL;
- dk4_stream_t *strm = NULL;
- size_t szfnb = DK4_SIZEOF(fnb,dkChar);
-
-
-#line 1889 "Dk4WxApplicationHelper.cpt"
- tabptr = (dk4_wx_string_table_t *)dk4sto_it_find_like(iStt, tableName, 1);
- if (NULL == tabptr) {
- if (InternalFindDataFile(fnb, szfnb, tableName, DK4_FS_DATA_MAX_SYS, 1)) {
- strm = dk4stream_open_file_reader(fnb, NULL);
- if (NULL != strm) {
- tabptr = dk4wxstt_open(tableName, tableSize, NULL);
- if (NULL != tabptr) {
- if (0 != dk4sto_add(sStt, tabptr, NULL)) {
- dk4error_init(&e1);
- dk4error_init(&e2);
- if (!dk4wxstt_apply_stream(tabptr, strm, iWxEncoding, &e1, &e2)) {
- dk4wxstt_shutdown(tabptr);
- }
- } else {
- dk4wxstt_close(tabptr);
- tabptr = NULL;
- }
- }
- dk4stream_close(strm, NULL);
- }
- }
- }
- if (NULL != tabptr) {
- if (tabptr->nstrings >= tableSize) {
- back = (const wxChar * const *)(tabptr->strings);
- }
- }
-
-#line 1916 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalSetMultiple(
- const wxChar * const *names, long *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- size_t i = 0;
- bool back = false;
-
-
-#line 1930 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- back = true;
- for (i = 0; i < sz; i++) {
- if (!(conf.Write(names[i], array[i]))) {
- back = false;
- }
- }
- }
-
-#line 1938 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalSetMultiple(
- const wxChar * const *names, int *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- size_t i = 0;
- bool back = false;
-
-
-#line 1952 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- back = true;
- for (i = 0; i < sz; i++) {
- if (!(conf.Write(names[i], array[i]))) {
- back = false;
- }
- }
- }
-
-#line 1960 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalSetMultiple(
- const wxChar * const *names, bool *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- size_t i = 0;
- bool back = false;
-
-
-#line 1974 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- back = true;
- for (i = 0; i < sz; i++) {
- if (!(conf.Write(names[i], array[i]))) {
- back = false;
- }
- }
- }
-
-#line 1982 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalSetMultiple(
- const wxChar * const *names, double *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- size_t i = 0;
- bool back = false;
-
-
-#line 1996 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- back = true;
- for (i = 0; i < sz; i++) {
- if (!(conf.Write(names[i], array[i]))) {
- back = false;
- }
- }
- }
-
-#line 2004 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalSetMultiple(
- const wxChar * const *names, const wxChar * const *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- size_t i = 0;
- bool back = false;
-
-
-#line 2018 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- back = true;
- for (i = 0; i < sz; i++) {
- if (!(conf.Write(names[i], array[i]))) {
- back = false;
- }
- }
- }
-
-#line 2026 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalGetMultiple(
- const wxChar * const *names, long *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- dk4_wx_pref_t *pptr = NULL;
-#if DK4_SIZEOF_WXCHAR > 1
- const wchar_t *ep = NULL;
-#else
- const char *ep = NULL;
-#endif
- size_t i;
- long l;
- int res;
- bool back = false;
-
-
-#line 2048 "Dk4WxApplicationHelper.cpt"
- back = true;
- for (i = 0; i < sz; i++) {
- l = 0L;
- if (conf.Read(names[i], &l)) {
- array[i] = l;
- } else {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrUser, names[i], 1);
- if (NULL == pptr) {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrSys, names[i], 1);
- }
- if (NULL != pptr) {
-#if DK4_SIZEOF_WXCHAR > 1
- res = dk4ma_input_wc_dec_long(&l, pptr->value, &ep, 1, NULL);
-#else
- res = dk4ma_input_c8_dec_long(&l, pptr->value, &ep, 1, NULL);
-#endif
- if (0 != res) {
- array[i] = l;
- } else {
- back = false;
- }
- }
- }
- }
-
-
-#line 2073 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalGetMultiple(
- const wxChar * const *names, int *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- dk4_wx_pref_t *pptr = NULL;
-#if DK4_SIZEOF_WXCHAR > 1
- const wchar_t *ep = NULL;
-#else
- const char *ep = NULL;
-#endif
- size_t i;
- long l;
- int res;
- bool back = false;
-
-
-#line 2095 "Dk4WxApplicationHelper.cpt"
- back = true;
- for (i = 0; i < sz; i++) {
- l = 0L;
- if (conf.Read(names[i], &l)) {
- if (((long)(INT_MIN) <= l) && ((long)(INT_MAX) >= l)) {
- array[i] = (int)l;
- } else {
- back = false;
- }
- } else {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrUser, names[i], 1);
- if (NULL == pptr) {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrSys, names[i], 1);
- }
- if (NULL != pptr) {
-#if DK4_SIZEOF_WXCHAR > 1
- res = dk4ma_input_wc_dec_long(&l, pptr->value, &ep, 1, NULL);
-#else
- res = dk4ma_input_c8_dec_long(&l, pptr->value, &ep, 1, NULL);
-#endif
- if (0 != res) {
- if (((long)(INT_MIN) <= l) && ((long)(INT_MAX) >= l)) {
- array[i] = (int)l;
- } else {
- back = false;
- }
- } else {
- back = false;
- }
- }
- }
- }
-
-
-#line 2128 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalGetMultiple(
- const wxChar * const *names, bool *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- dk4_wx_pref_t *pptr = NULL;
- size_t i;
- bool l;
- bool back = false;
-
-
-#line 2144 "Dk4WxApplicationHelper.cpt"
- back = true;
- for (i = 0; i < sz; i++) {
- l = 0L;
-
-
-#line 2148 "Dk4WxApplicationHelper.cpt"
- if (conf.Read(names[i], &l)) {
- array[i] = l;
- } else {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrUser, names[i], 1);
- if (NULL == pptr) {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrSys, names[i], 1);
- }
- if (NULL != pptr) {
-
-#line 2156 "Dk4WxApplicationHelper.cpt"
-
-
-#line 2157 "Dk4WxApplicationHelper.cpt"
-
-
-#line 2158 "Dk4WxApplicationHelper.cpt"
-#if DK4_SIZEOF_WXCHAR > 1
-
-
-#line 2160 "Dk4WxApplicationHelper.cpt"
- if (0 != dk4strw_is_bool(pptr->value)) {
- if (0 != dk4strw_is_on(pptr->value)) {
- array[i] = true;
-
-#line 2163 "Dk4WxApplicationHelper.cpt"
- } else {
- array[i] = false;
-
-#line 2165 "Dk4WxApplicationHelper.cpt"
- }
- } else {
-
-#line 2167 "Dk4WxApplicationHelper.cpt"
- back = false;
- }
-#else
-
-
-#line 2171 "Dk4WxApplicationHelper.cpt"
- if (0 != dk4str8_is_bool(pptr->value)) {
- if (0 != dk4str8_is_on(pptr->value)) {
- array[i] = true;
-
-#line 2174 "Dk4WxApplicationHelper.cpt"
- } else {
- array[i] = false;
-
-#line 2176 "Dk4WxApplicationHelper.cpt"
- }
- } else {
- back = false;
-
-#line 2179 "Dk4WxApplicationHelper.cpt"
- }
-#endif
- } else {
-
-#line 2182 "Dk4WxApplicationHelper.cpt"
- }
- }
- }
-
-
-#line 2186 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalGetMultiple(
- const wxChar * const *names, double *array, size_t sz
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- dk4_wx_pref_t *pptr = NULL;
-#if DK4_SIZEOF_WXCHAR > 1
- const wchar_t *ep = NULL;
-#else
- const char *ep = NULL;
-#endif
-#if DK4_HAVE_SETLOCALE
- char *oldloc = NULL;
-#endif
- double l;
- size_t i;
- int res;
- bool back = false;
-
-
-#line 2211 "Dk4WxApplicationHelper.cpt"
- back = true;
- for (i = 0; i < sz; i++) {
- l = 0.0;
- if (conf.Read(names[i], &l)) {
- array[i] = l;
- } else {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrUser, names[i], 1);
- if (NULL == pptr) {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrSys, names[i], 1);
- }
- if (NULL != pptr) {
-#if DK4_HAVE_SETLOCALE
- oldloc = setlocale(LC_NUMERIC, dk4wxah_kwnl_c8[0]);
-#endif
-#if DK4_SIZEOF_WXCHAR > 1
- res = dk4ma_input_wc_double(&l, pptr->value, &ep, 1, NULL);
-#else
- res = dk4ma_input_c8_double(&l, pptr->value, &ep, 1, NULL);
-#endif
-#if DK4_HAVE_SETLOCALE
- if (NULL != oldloc) { setlocale(LC_NUMERIC, oldloc); }
-#endif
- if (0 != res) {
- array[i] = l;
- } else {
- back = false;
- }
- }
- }
- }
-
-
-#line 2242 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalGetMultiple(
- const wxChar * const *names, wxChar **array, size_t sz, bool ov
-)
-{
- wxConfig conf(pwxsApp, pcwxsVendor);
- dk4_wx_pref_t *pptr = NULL;
- const wxChar *vptr = NULL;
- wxChar *nptr = NULL;
- size_t i;
- bool back = false;
-
-
-#line 2259 "Dk4WxApplicationHelper.cpt"
- back = true;
- for (i = 0; i < sz; i++) {
- if ((NULL == array[i]) || (ov)) {
- wxString value = wxEmptyString;
- if (conf.Read(names[i], &value)) {
- wxCStrData valuestrdata = value.c_str();
- vptr = (wxChar const *)valuestrdata;
- if (NULL != vptr) {
- nptr = dk4strx_dup(vptr, NULL);
- if (NULL != nptr) {
- if (NULL != array[i]) { dk4mem_free(array[i]); }
- array[i] = nptr;
- } else {
- back = false;
- }
- } else {
- back = false;
- }
- } else {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrUser, names[i], 1);
- if (NULL == pptr) {
- pptr = (dk4_wx_pref_t *)dk4sto_it_find_like(iPrSys, names[i], 1);
- }
- if (NULL != pptr) {
- nptr = dk4strx_dup(pptr->value, NULL);
- if (nptr) {
- if (NULL != array[i]) { dk4mem_free(array[i]); }
- array[i] = nptr;
- } else {
- back = false;
- }
- }
- }
- }
- }
-
-
-#line 2295 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-/* ************************************************************************ */
-/* * * */
-/* * Public interface. * */
-/* * The methods must * */
-/* * (a) synchronize access attempts from multiple threads and * */
-/* * (b) ensure the object is in a usable state. * */
-/* * * */
-/* ************************************************************************ */
-
-
-#line 2306 "Dk4WxApplicationHelper.cpt"
-
-
-bool
-Dk4WxApplicationHelper::FindDataFile(
- dkChar *fnb,
- size_t szfnb,
- dkChar const *sfn,
- int maxpass,
- bool aco
-)
-{
- bool back = false;
-
-
-#line 2319 "Dk4WxApplicationHelper.cpt"
- if ((NULL != fnb) && (NULL != sfn) && (0 < szfnb)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalFindDataFile(fnb, szfnb, sfn, maxpass, aco);
- }
- }
-
-#line 2325 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-
-#if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
-
-bool
-Dk4WxApplicationHelper::FindDataFile(
- wxChar *fnb,
- size_t szfnb,
- dkChar const *sfn,
- int maxpass,
- bool aco
-)
-{
- bool back = false;
-
-
-#line 2344 "Dk4WxApplicationHelper.cpt"
- if ((NULL != fnb) && (NULL != sfn) && (0 < szfnb)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalFindDataFile(fnb, szfnb, sfn, maxpass, aco);
- }
- }
-
-#line 2350 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-#endif
-
-
-
-int
-Dk4WxApplicationHelper::GetDkEncoding(void)
-{
- int back = DK4_ENCODING_PLAIN;
-
-
-#line 2362 "Dk4WxApplicationHelper.cpt"
-#if DK4_ON_WINDOWS
- back = DK4_ENCODING_WIN1252;
-#endif
- {
- wxCriticalSectionLocker lock(csProtect);
- back = iDkEncoding;
- }
-
-#line 2369 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-int
-Dk4WxApplicationHelper::GetWxEncoding(void)
-{
- int back = DK4_ENCODING_PLAIN;
-
-
-#line 2379 "Dk4WxApplicationHelper.cpt"
-#if DK4_ON_WINDOWS
- back = DK4_ENCODING_WIN1252;
-#endif
- {
- wxCriticalSectionLocker lock(csProtect);
- back = iWxEncoding;
- }
-
-#line 2386 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-int
-Dk4WxApplicationHelper::GetFiEncoding(void)
-{
- int back = DK4_FILE_ENCODING_PLAIN;
-
-
-#line 2396 "Dk4WxApplicationHelper.cpt"
-#if DK4_ON_WINDOWS
- back = DK4_FILE_ENCODING_WIN1252;
-#endif
- {
- wxCriticalSectionLocker lock(csProtect);
- back = iFiEncoding;
- }
-
-#line 2403 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-const wxChar * const *
-Dk4WxApplicationHelper::GetStringTable(
- const dkChar *tableName,
- const wxChar * const *defaultTable
-)
-{
- const wxChar * const *back = NULL;
- size_t sz = 0;
-
-
-#line 2417 "Dk4WxApplicationHelper.cpt"
- if ((NULL != tableName) && (NULL != defaultTable)) {
- sz = Dk4WxApplicationHelper::StringTableSize(defaultTable);
- if (0 < sz) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalGetStringTable(tableName, sz);
- }
- }
- }
- if (NULL == back) { back = defaultTable; }
-
-
-#line 2428 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-const wxChar *
-Dk4WxApplicationHelper::GetBasicString(
- size_t numstr
-)
-{
- const wxChar *back = NULL;
-
-
-#line 2440 "Dk4WxApplicationHelper.cpt"
- {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- if ((NULL != ppBasicStrings) && (0 < nBasicStrings)) {
- if (numstr < nBasicStrings) {
- back = ppBasicStrings[numstr];
- }
- }
- }
- }
- if (NULL == back) {
- if (numstr < (DK4_SIZEOF(dk4wxah_basic_strings,wxChar) - 1)) {
- back = dk4wxah_basic_strings[numstr];
- } else {
- back = dk4wxah_empty_string;
- }
- }
-
-#line 2457 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-const wxChar * const *
-Dk4WxApplicationHelper::GetBasicStrings(
- size_t *pNumBasicStrings
-)
-{
- const wxChar * const *back = NULL;
-
-
-#line 2469 "Dk4WxApplicationHelper.cpt"
- {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = ppBasicStrings;
- if (NULL != pNumBasicStrings) { *pNumBasicStrings = nBasicStrings; }
- }
- }
- if (NULL == back) {
- back = dk4wxah_basic_strings;
- if (NULL != pNumBasicStrings) {
- *pNumBasicStrings = DK4_SIZEOF(dk4wxah_basic_strings,wxChar) - 1;
- }
- }
-
-#line 2482 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::StringToWx(
- wxChar *dptr, size_t dsz, const dkChar *sptr, dk4_er_t *erp
-)
-{
- int res = 0;
- int wxe = DK4_ENCODING_PLAIN;
- int dke = DK4_ENCODING_PLAIN;
- bool back = false;
-
-
-#line 2497 "Dk4WxApplicationHelper.cpt"
-#if DK4_ON_WINDOWS
- wxe = dke = DK4_ENCODING_WIN1252;
-#endif
- if ((NULL != dptr) && (NULL != sptr) && (0 < dsz)) {
- {
- wxCriticalSectionLocker lock(csProtect);
- wxe = iWxEncoding;
- dke = iDkEncoding;
- }
- res = dk4recwx_dkchar_to_wxchar(dptr, dsz, wxe, sptr, dke, erp);
- if (0 != res) { back = true; }
- }
-
-#line 2509 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::StringToDk(
- dkChar *dptr, size_t dsz, const wxChar *sptr, dk4_er_t *erp
-)
-{
- int res = 0;
- int wxe = DK4_ENCODING_PLAIN;
- int dke = DK4_ENCODING_PLAIN;
- bool back = false;
-
-
-#line 2524 "Dk4WxApplicationHelper.cpt"
-#if DK4_ON_WINDOWS
- wxe = dke = DK4_ENCODING_WIN1252;
-#endif
- if ((NULL != dptr) && (NULL != sptr) && (0 < dsz)) {
- {
- wxCriticalSectionLocker lock(csProtect);
- wxe = iWxEncoding;
- dke = iDkEncoding;
- }
- res = dk4recwx_wxchar_to_dkchar(dptr, dsz, dke, sptr, wxe, erp);
- if (0 != res) { back = true; }
- }
-
-#line 2536 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::StringToChar(
- char *dptr, size_t dsz, const wxChar *sptr, dk4_er_t *erp
-)
-{
- int res = 0;
- int wxe = DK4_ENCODING_PLAIN;
- int dke = DK4_ENCODING_PLAIN;
- bool back = false;
-#if DK4_ON_WINDOWS
- wxe = dke = DK4_ENCODING_WIN1252;
-#endif
- if ((NULL != dptr) && (NULL != sptr) && (0 < dsz)) {
- {
- wxCriticalSectionLocker lock(csProtect);
- wxe = iWxEncoding;
- dke = iDkEncoding;
- }
- if (DK4_ENCODING_UTF8 != dke) {
- if (DK4_ENCODING_WIN1252 != dke) {
- dke = DK4_ENCODING_PLAIN;
- }
- }
- res = dk4recwx_wxchar_to_char(dptr, dsz, dke, sptr, wxe, erp);
- if (0 != res) { back = true; }
- }
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::SetMultiple(
- const wxChar * const *names, long *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2579 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalSetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2587 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::SetMultiple(
- const wxChar * const *names, int *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2599 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalSetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2607 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::SetMultiple(
- const wxChar * const *names, bool *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2619 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalSetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2627 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::SetMultiple(
- const wxChar * const *names, double *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2639 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalSetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2647 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::SetMultiple(
- const wxChar * const *names, const wxChar * const *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2659 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalSetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2667 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::GetMultiple(
- const wxChar * const *names, long *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2679 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalGetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2687 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::GetMultiple(
- const wxChar * const *names, int *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2699 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalGetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2707 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::GetMultiple(
- const wxChar * const *names, bool *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2719 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalGetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2727 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::GetMultiple(
- const wxChar * const *names, double *array, size_t sz
-)
-{
- bool back = false;
-
-
-#line 2739 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalGetMultiple(names, array, sz);
- } else {
- /* Object not active */
- }
- }
-
-#line 2747 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::GetMultiple(
- const wxChar * const *names, wxChar **array, size_t sz, bool ov
-)
-{
- bool back = false;
-
-
-#line 2759 "Dk4WxApplicationHelper.cpt"
- if ((NULL != names) && (NULL != array) && (0 < sz)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalGetMultiple(names, array, sz, ov);
- } else {
- /* Object not active */
- }
- }
-
-#line 2767 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::SetString(const wxString & key, const wxString & value)
-{
- bool back = false;
-
-
-#line 2777 "Dk4WxApplicationHelper.cpt"
- {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- wxConfig conf(pwxsApp, pcwxsVendor);
- back = conf.Write(key, value);
- }
- }
-
-
-#line 2785 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-bool
-Dk4WxApplicationHelper::GetString(const wxString & key, wxString *pvalue)
-{
- bool back = false;
-
-
-#line 2795 "Dk4WxApplicationHelper.cpt"
- if (NULL != pvalue) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- wxConfig conf(pwxsApp, pcwxsVendor);
- back = conf.Read(key, pvalue);
- }
- }
-
-
-#line 2803 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-/* ************************************************************************ */
-/* * * */
-/* * Static class functions. * */
-/* * * */
-/* ************************************************************************ */
-
-
-#line 2811 "Dk4WxApplicationHelper.cpt"
-
-
-void
-Dk4WxApplicationHelper::CorrectPosition(
- int & x, int & y, int & w, int & h, bool cn
-)
-{
- wxSize scsz;
-
-
-#line 2820 "Dk4WxApplicationHelper.cpt"
- scsz = wxGetDisplaySize();
- if (cn) {
- /*
- Negative coordinates mean x and y not defined, center window.
- */
- if (0 > x) { x = (scsz.x - w) / 2; }
- if (0 > y) { y = (scsz.y - h) / 2; }
- }
- if (scsz.x < (x + w)) { x = scsz.x - w; }
- if (scsz.y < (y + h)) { y = scsz.y - h; }
- if (0 > x) { x = 0; }
- if (0 > y) { y = 0; }
-
-
-#line 2833 "Dk4WxApplicationHelper.cpt"
-}
-
-
-
-void
-Dk4WxApplicationHelper::CorrectPosition(
- wxWindow & wnd, bool cn
-)
-{
- int x, y, w, h;
-
-
-#line 2844 "Dk4WxApplicationHelper.cpt"
- wnd.GetPosition(&x, &y);
- wnd.GetSize(&w, &h);
- Dk4WxApplicationHelper::CorrectPosition(x, y, w, h, cn);
- wnd.SetSize(x, y, w, h);
-
-
-#line 2849 "Dk4WxApplicationHelper.cpt"
-}
-
-
-
-void
-Dk4WxApplicationHelper::ChooseChildPosition(
- const wxWindow & p, wxWindow & c, bool beside
-)
-{
- wxSize scsz = wxGetDisplaySize();
- int px = 0;
- int py = 0;
- int pw = 0;
- int ph = 0;
- int cx = 0;
- int cy = 0;
- int cw = 0;
- int ch = 0;
- bool done = false;
- bool findy = false;
-
-
-#line 2870 "Dk4WxApplicationHelper.cpt"
-#if 0
- p.GetPosition(&px, &py);
- p.GetSize(&pw, &ph);
-#else
- wxRect re = p.GetScreenRect();
- px = re.GetX();
- py = re.GetY();
- pw = re.GetWidth();
- ph = re.GetHeight();
-#endif
- c.GetSize(&cw, &ch);
- if (beside) {
- /* Attempt right side */
- if (scsz.x > px + pw + cw) {
- cx = px + pw;
- done = true;
- findy = true;
- }
- /* Attempt bottom side */
- if (!done) {
- if (scsz.y > py + ph + ch) {
- cy = py + ph;
- done = true;
- }
- }
- /* Attempt left side */
- if (!done) {
- if (px > cw) {
- cx = px - cw;
- done = true;
- findy = true;
- }
- }
- /* Attempt top side */
- if (!done) {
- if (py < ch) {
- cy = py - ch;
- done = true;
- }
- }
- if (done) {
- if (findy) {
- if (scsz.y > (py + ch)) {
- cy = py;
- } else {
- if (0 <= (py + ph - ch)) {
- cy = py + ph - ch;
- } else {
- cy = py + (ph - ch) / 2;
- if (scsz.y <= (cy + ch)) {
- cy = scsz.y - ch - 1;
- }
- if (0 > cy) {
- cy = 0;
- }
- }
- }
- } else {
- if (scsz.x > (px + cw)) {
- cx = px;
- } else {
- if (0 <= (px + pw - cw)) {
- cx = px + pw - cw;
- } else {
- cx = px + (pw - cw) / 2;
- if (scsz.x <= (cx + cw)) {
- cx = scsz.x - cw - 1;
- }
- if (0 > cx) {
- cx = 0;
- }
- }
- }
- }
- c.SetSize(cx, cy, cw, ch);
- }
- }
- if (!done) {
- cx = px + (pw - cw) / 2;
- cy = py + (ph - ch) / 2;
- Dk4WxApplicationHelper::CorrectPosition(cx, cy, cw, ch, false);
- c.SetSize(cx, cy, cw, ch);
- }
-
-
-#line 2954 "Dk4WxApplicationHelper.cpt"
-}
-
-
-
-size_t
-Dk4WxApplicationHelper::StringTableSize(const wxChar * const *sttptr)
-{
- size_t back = 0;
-
-
-#line 2963 "Dk4WxApplicationHelper.cpt"
- if (NULL != sttptr) {
- while (NULL != *(sttptr++)) { back++; }
- }
-
-#line 2966 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-
-void
-Dk4WxApplicationHelper::ReleaseWxcharStringArray(
- wxChar **array, size_t sz, bool ea
-)
-{
- wxChar **ap;
-
-
-#line 2978 "Dk4WxApplicationHelper.cpt"
- if ((NULL != array) && (0 < sz)) {
- ap = array;
- while (0 < sz--) {
- dk4mem_release(*array);
- array++;
- }
- if (ea) { dk4mem_free(ap); }
- }
-
-
-#line 2987 "Dk4WxApplicationHelper.cpt"
-}
-
-
-
-const
-dkChar *
-Dk4WxApplicationHelper::GetDkArgv0(void)
-{
- return ((const dkChar *)pcdksArgv0);
-}
-
-
-
-const
-dkChar *
-Dk4WxApplicationHelper::GetDkGroupName(void)
-{
- return(pcdksGroup);
-}
-
-
-
-void
-Dk4WxApplicationHelper::UpdateWxsShare(void)
-{
- wxChar buf[DK4_MAX_PATH];
- wxChar *np;
- bool res;
- if (NULL != pdksShare) {
- res = InternalStringToWx(buf, DK4_SIZEOF(buf,wxChar), pdksShare, NULL);
- if (res) {
- np = dk4strx_dup(buf, NULL);
- if (NULL != np) {
- dk4mem_release(pwxsShare);
- pwxsShare = np;
- }
- }
- }
-}
-
-
-
-const
-wxChar *
-Dk4WxApplicationHelper::GetWxsShare(void) const
-{
- return ((wxChar const *)pwxsShare);
-}
-
-
-
-bool
-Dk4WxApplicationHelper::InternalFindHelpFile(
- dkChar *fnb,
- size_t szfnb,
- dkChar const *sfn
-)
-{
- int passno = 0;
- int res = 0;
- bool back = false;
-
-
-#line 3049 "Dk4WxApplicationHelper.cpt"
- for (passno = 0; ((passno <= DK4_FS_DOC_MAX) && (!(back))); passno++) {
- res = dk4fs_doc_one(
- fnb, szfnb, sfn, pdksShare, pdksApp, pcdksGroup,
- pdksLanguage, pdksRegion, passno, NULL
- );
- if (0 != res) {
-
-#line 3055 "Dk4WxApplicationHelper.cpt"
- back = true;
- }
- }
-
-
-#line 3059 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-
-#if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
-
-bool
-Dk4WxApplicationHelper::InternalFindHelpFile(
- wxChar *fnb,
- size_t szfnb,
- dkChar const *sfn
-)
-{
- dkChar buf[DK4_MAX_PATH];
- size_t szbuf = DK4_SIZEOF(buf,dkChar);
- bool back = false;
-
-
-#line 3076 "Dk4WxApplicationHelper.cpt"
- back = InternalFindHelpFile(buf, szbuf, sfn);
- if (back) {
- back = InternalStringToWx(fnb, szfnb, buf, NULL);
- }
-
-
-#line 3081 "Dk4WxApplicationHelper.cpt"
- return back;
-}
-
-#endif
-
-bool
-Dk4WxApplicationHelper::FindHelpFile(
- dkChar *fnb,
- size_t szfnb,
- dkChar const *sfn
-)
-{
- bool back = false;
- if ((NULL != fnb) && (NULL != sfn) && (0 < szfnb)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalFindHelpFile(fnb, szfnb, sfn);
- }
- }
- return back;
-}
-
-#if DK4_SIZEOF_WXCHAR != DK4_CHAR_SIZE
-
-bool
-Dk4WxApplicationHelper::FindHelpFile(
- wxChar *fnb,
- size_t szfnb,
- dkChar const *sfn
-)
-{
- bool back = false;
- if ((NULL != fnb) && (NULL != sfn) && (0 < szfnb)) {
- wxCriticalSectionLocker lock(csProtect);
- if (bActive) {
- back = InternalFindHelpFile(fnb, szfnb, sfn);
- }
- }
- return back;
-}
-
-#endif
-
-
-/* vim: set ai sw=4 ts=4 : */