/* WARNING: This file was generated by dkct. 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 */ /* Copyright (C) 2015-2017, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file Dk4WxApplicationHelper.cpp The Dk4WxApplicationHelper module. */ #line 721 "Dk4WxApplicationHelper.cpt" #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 752 "Dk4WxApplicationHelper.cpt" /* ************************************************************************ */ /* * * */ /* * Type definitions. * */ /* * * */ /* ************************************************************************ */ #line 758 "Dk4WxApplicationHelper.cpt" /** Pointer to constant wxChar. */ typedef const wxChar *PCWXCHAR; /** Error codes in Initialize(). */ enum { /** No error occured. */ ERROR_NONE = 0, /** Not enough memory. */ ERROR_MEMORY , /** Failed to find host name. */ ERROR_HOSTNAME , /** Failed to find localization settings. */ ERROR_LANG_REG_ENC , /** Failed to find login name. */ ERROR_LOGNAME , /** Failed to find home directory. */ ERROR_HOMEDIR , /** Failed to find path name of executable. */ ERROR_EXECUTABLE , /** Executable file name too long. */ ERROR_EXEC_TOO_LONG , /** Invalid arguments were passed to Initialize(). */ ERROR_ARGUMENTS , }; /* ************************************************************************ */ /* * * */ /* * Variables. * */ /* * * */ /* ************************************************************************ */ #line 812 "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 874 "Dk4WxApplicationHelper.cpt" }; /** Constant text keywords used by module, not localized. */ static const dkChar * const dk4wxah_kwnl_dk[] = { /* 0 */ dkT("dk4wxbase.str"), NULL #line 887 "Dk4WxApplicationHelper.cpt" }; /** Constant text strings used by the module, not localized. */ static const char * const dk4wxah_kwnl_c8[] = { /* 0 */ "C", NULL #line 897 "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 910 "Dk4WxApplicationHelper.cpt" }; /** New final directory names to append. */ static const dkChar * const dk4wxah_new_directories[] = { /* 0 */ dkT("etc"), /* 1 */ dkT("share"), NULL #line 921 "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)!"), NULL #line 954 "Dk4WxApplicationHelper.cpt" }; /* ************************************************************************ */ /* * * */ /* * Internal tool functions, not object-oriented. * */ /* * * */ /* ************************************************************************ */ #line 961 "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 979 "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 1002 "Dk4WxApplicationHelper.cpt" return back; } /* ************************************************************************ */ /* * * */ /* * Constructor, destructor, initialization and cleanup. * */ /* * * */ /* ************************************************************************ */ #line 1010 "Dk4WxApplicationHelper.cpt" Dk4WxApplicationHelper::Dk4WxApplicationHelper() { /* Set all member variables to "resource not available". Real initialization is in the Initialize() method. */ #line 1019 "Dk4WxApplicationHelper.cpt" ppBasicStrings = NULL; pcwxsArgv0 = NULL; pcwxsVendor = NULL; pcdksGroup = NULL; pwxsApp = NULL; pdksHost = NULL; pdksLogname = NULL; pdksHome = NULL; pdksApp = NULL; pdksSysconf = NULL; pdksShare = NULL; pdksLanguage = NULL; pdksRegion = NULL; sStt = NULL; iStt = NULL; sPrSys = NULL; iPrSys = NULL; sPrUser = NULL; iPrUser = NULL; nBasicStrings = 0; iDkEncoding = DK4_ENCODING_ASCII; iWxEncoding = DK4_ENCODING_ASCII; iFiEncoding = DK4_FILE_ENCODING_ASCII; bActive = false; #line 1044 "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 1078 "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 1088 "Dk4WxApplicationHelper.cpt" /* Some default values. */ ppBasicStrings = dk4wxah_basic_strings; nBasicStrings = DK4_SIZEOF(dk4wxah_basic_strings,PCWXCHAR) - 1; #line 1094 "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 1110 "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_ANSI : { iWxEncoding = DK4_ENCODING_ANSI; } break; case DK4_ENCODING_UTF8 : { iWxEncoding = DK4_ENCODING_UTF8; } break; default : { iWxEncoding = DK4_ENCODING_ASCII; } break; } #endif switch (iDkEncoding) { case DK4_ENCODING_ANSI : { iFiEncoding = DK4_ENCODING_ANSI; } break; case DK4_ENCODING_UTF8 : { iFiEncoding = DK4_ENCODING_UTF8; } break; default : { iFiEncoding = DK4_ENCODING_ASCII; } 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 1163 "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 1178 "Dk4WxApplicationHelper.cpt" errc = ERROR_HOMEDIR; goto finished; } pdksHome = dk4str_dup(labuf, erp); if (NULL == pdksHome) { #line 1183 "Dk4WxApplicationHelper.cpt" errc = ERROR_MEMORY; goto finished; } #line 1187 "Dk4WxApplicationHelper.cpt" /* System configuration and data directory. */ res = dk4recwx_wxchar_to_dkchar( labuf, szlabuf, iDkEncoding, argv0, iWxEncoding, erp ); #line 1193 "Dk4WxApplicationHelper.cpt" res = dk4execpath( rebuf, szrebuf, ((0 != res) ? labuf : NULL), erp ); if (0 == res) { #line 1197 "Dk4WxApplicationHelper.cpt" errc = ERROR_EXECUTABLE; goto finished; } #line 1200 "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 1209 "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 1229 "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); 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); 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); if ((NULL == pdksSysconf) || (NULL == pdksShare)) { errc = ERROR_MEMORY; goto finished; } } } #line 1315 "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 1352 "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 : DK4_FILE_ENCODING_ASCII ), pn ); } #line 1378 "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 1387 "Dk4WxApplicationHelper.cpt" /* Finally mark success. */ bActive = back = true; /* Clean up if not successfully. */ finished: if (!(back)) { #line 1396 "Dk4WxApplicationHelper.cpt" switch (errc) { case ERROR_MEMORY : { #line 1398 "Dk4WxApplicationHelper.cpt" msgbtext = dkwxah_msgb_texts[1]; msgbtitle = dkwxah_msgb_texts[0]; } break; case ERROR_HOSTNAME : { #line 1402 "Dk4WxApplicationHelper.cpt" msgbtext = dkwxah_msgb_texts[2]; msgbtitle = dkwxah_msgb_texts[0]; } break; case ERROR_LANG_REG_ENC : { #line 1406 "Dk4WxApplicationHelper.cpt" msgbtext = dkwxah_msgb_texts[3]; msgbtitle = dkwxah_msgb_texts[0]; } break; case ERROR_LOGNAME : { #line 1410 "Dk4WxApplicationHelper.cpt" msgbtext = dkwxah_msgb_texts[4]; msgbtitle = dkwxah_msgb_texts[0]; } break; case ERROR_HOMEDIR : { #line 1414 "Dk4WxApplicationHelper.cpt" msgbtext = dkwxah_msgb_texts[5]; msgbtitle = dkwxah_msgb_texts[0]; } break; case ERROR_EXECUTABLE : { #line 1418 "Dk4WxApplicationHelper.cpt" msgbtext = dkwxah_msgb_texts[6]; msgbtitle = dkwxah_msgb_texts[0]; } break; case ERROR_EXEC_TOO_LONG : { #line 1422 "Dk4WxApplicationHelper.cpt" msgbtext = dkwxah_msgb_texts[7]; msgbtitle = dkwxah_msgb_texts[0]; } break; case ERROR_ARGUMENTS : { #line 1426 "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 1438 "Dk4WxApplicationHelper.cpt" return back; } void Dk4WxApplicationHelper::InternalCleanup(void) { dk4_wx_string_table_t *wxsttptr; dk4_wx_pref_t *pptr; #line 1449 "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_ASCII; iWxEncoding = DK4_ENCODING_ASCII; iFiEncoding = DK4_FILE_ENCODING_ASCII; #endif dk4mem_release(pdksRegion); dk4mem_release(pdksLanguage); dk4mem_release(pdksShare); dk4mem_release(pdksSysconf); dk4mem_release(pdksApp); dk4mem_release(pdksHost); dk4mem_release(pwxsApp); dk4mem_release(pdksLogname); dk4mem_release(pdksHome); #line 1511 "Dk4WxApplicationHelper.cpt" } void Dk4WxApplicationHelper::Cleanup(void) { #line 1519 "Dk4WxApplicationHelper.cpt" { wxCriticalSectionLocker lock(csProtect); InternalCleanup(); } #line 1524 "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 1536 "Dk4WxApplicationHelper.cpt" InternalCleanup(); #line 1538 "Dk4WxApplicationHelper.cpt" } /* ************************************************************************ */ /* * * */ /* * Internal functions. * */ /* * These functions do not attempt synchronization. * */ /* * * */ /* ************************************************************************ */ #line 1546 "Dk4WxApplicationHelper.cpt" bool Dk4WxApplicationHelper::InternalStringToWx( wxChar *dptr, size_t dsz, const dkChar *sptr, dk4_er_t *erp ) { int res = 0; bool back = false; #line 1556 "Dk4WxApplicationHelper.cpt" res = dk4recwx_dkchar_to_wxchar(dptr,dsz,iWxEncoding,sptr,iDkEncoding,erp); if (0 != res) { back = true; } #line 1559 "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 1572 "Dk4WxApplicationHelper.cpt" res = dk4recwx_wxchar_to_dkchar(dptr,dsz,iDkEncoding,sptr,iWxEncoding,erp); if (0 != res) { back = true; } #line 1575 "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 1593 "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 1602 "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 1623 "Dk4WxApplicationHelper.cpt" back = InternalFindDataFile(buf, szbuf, sfn, maxpass, aco); if (back) { back = InternalStringToWx(fnb, szfnb, buf, NULL); } #line 1627 "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 1648 "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 1675 "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 1689 "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 1697 "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 1711 "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 1719 "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 1733 "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 1741 "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 1755 "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 1763 "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 1777 "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 1785 "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 1807 "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 1832 "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 1854 "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 1887 "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 1903 "Dk4WxApplicationHelper.cpt" back = true; for (i = 0; i < sz; i++) { l = 0L; #line 1907 "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 1915 "Dk4WxApplicationHelper.cpt" #line 1916 "Dk4WxApplicationHelper.cpt" #line 1917 "Dk4WxApplicationHelper.cpt" #if DK4_SIZEOF_WXCHAR > 1 #line 1919 "Dk4WxApplicationHelper.cpt" if (0 != dk4strw_is_bool(pptr->value)) { if (0 != dk4strw_is_on(pptr->value)) { array[i] = true; #line 1922 "Dk4WxApplicationHelper.cpt" } else { array[i] = false; #line 1924 "Dk4WxApplicationHelper.cpt" } } else { #line 1926 "Dk4WxApplicationHelper.cpt" back = false; } #else #line 1930 "Dk4WxApplicationHelper.cpt" if (0 != dk4str8_is_bool(pptr->value)) { if (0 != dk4str8_is_on(pptr->value)) { array[i] = true; #line 1933 "Dk4WxApplicationHelper.cpt" } else { array[i] = false; #line 1935 "Dk4WxApplicationHelper.cpt" } } else { back = false; #line 1938 "Dk4WxApplicationHelper.cpt" } #endif } else { #line 1941 "Dk4WxApplicationHelper.cpt" } } } #line 1945 "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 1970 "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 2001 "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 2018 "Dk4WxApplicationHelper.cpt" back = true; for (i = 0; i < sz; i++) { if ((NULL == array[i]) || (ov)) { wxString value = wxEmptyString; if (conf.Read(names[i], &value)) { vptr = value.c_str(); 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 2053 "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 2064 "Dk4WxApplicationHelper.cpt" bool Dk4WxApplicationHelper::FindDataFile( dkChar *fnb, size_t szfnb, dkChar const *sfn, int maxpass, bool aco ) { bool back = false; #line 2077 "Dk4WxApplicationHelper.cpt" if ((NULL != fnb) && (NULL != sfn) && (0 < szfnb)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalFindDataFile(fnb, szfnb, sfn, maxpass, aco); } } #line 2083 "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 2102 "Dk4WxApplicationHelper.cpt" if ((NULL != fnb) && (NULL != sfn) && (0 < szfnb)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalFindDataFile(fnb, szfnb, sfn, maxpass, aco); } } #line 2108 "Dk4WxApplicationHelper.cpt" return back; } #endif int Dk4WxApplicationHelper::GetDkEncoding(void) { int back = DK4_ENCODING_ASCII; #line 2120 "Dk4WxApplicationHelper.cpt" { wxCriticalSectionLocker lock(csProtect); back = iDkEncoding; } #line 2124 "Dk4WxApplicationHelper.cpt" return back; } int Dk4WxApplicationHelper::GetWxEncoding(void) { int back = DK4_ENCODING_ASCII; #line 2134 "Dk4WxApplicationHelper.cpt" { wxCriticalSectionLocker lock(csProtect); back = iWxEncoding; } #line 2138 "Dk4WxApplicationHelper.cpt" return back; } int Dk4WxApplicationHelper::GetFiEncoding(void) { int back = DK4_ENCODING_ASCII; #line 2148 "Dk4WxApplicationHelper.cpt" { wxCriticalSectionLocker lock(csProtect); back = iFiEncoding; } #line 2152 "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 2166 "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 2177 "Dk4WxApplicationHelper.cpt" return back; } const wxChar * Dk4WxApplicationHelper::GetBasicString( size_t numstr ) { const wxChar *back = NULL; #line 2189 "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 2206 "Dk4WxApplicationHelper.cpt" return back; } const wxChar * const * Dk4WxApplicationHelper::GetBasicStrings( size_t *pNumBasicStrings ) { const wxChar * const *back = NULL; #line 2218 "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 2231 "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_ASCII; int dke = DK4_ENCODING_ASCII; bool back = false; #line 2246 "Dk4WxApplicationHelper.cpt" 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 2255 "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_ASCII; int dke = DK4_ENCODING_ASCII; bool back = false; #line 2270 "Dk4WxApplicationHelper.cpt" 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 2279 "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_ASCII; int dke = DK4_ENCODING_ASCII; bool back = false; if ((NULL != dptr) && (NULL != sptr) && (0 < dsz)) { { wxCriticalSectionLocker lock(csProtect); wxe = iWxEncoding; dke = iDkEncoding; } if (DK4_ENCODING_UTF8 != dke) { if (DK4_ENCODING_ANSI != dke) { dke = DK4_ENCODING_ASCII; } } 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 2319 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalSetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2327 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::SetMultiple( const wxChar * const *names, int *array, size_t sz ) { bool back = false; #line 2339 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalSetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2347 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::SetMultiple( const wxChar * const *names, bool *array, size_t sz ) { bool back = false; #line 2359 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalSetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2367 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::SetMultiple( const wxChar * const *names, double *array, size_t sz ) { bool back = false; #line 2379 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalSetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2387 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::SetMultiple( const wxChar * const *names, const wxChar * const *array, size_t sz ) { bool back = false; #line 2399 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalSetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2407 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::GetMultiple( const wxChar * const *names, long *array, size_t sz ) { bool back = false; #line 2419 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalGetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2427 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::GetMultiple( const wxChar * const *names, int *array, size_t sz ) { bool back = false; #line 2439 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalGetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2447 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::GetMultiple( const wxChar * const *names, bool *array, size_t sz ) { bool back = false; #line 2459 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalGetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2467 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::GetMultiple( const wxChar * const *names, double *array, size_t sz ) { bool back = false; #line 2479 "Dk4WxApplicationHelper.cpt" if ((NULL != names) && (NULL != array) && (0 < sz)) { wxCriticalSectionLocker lock(csProtect); if (bActive) { back = InternalGetMultiple(names, array, sz); } else { /* Object not active */ } } #line 2487 "Dk4WxApplicationHelper.cpt" return back; } bool Dk4WxApplicationHelper::GetMultiple( const wxChar * const *names, wxChar **array, size_t sz, bool ov ) { bool back = false; #line 2499 "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 2507 "Dk4WxApplicationHelper.cpt" return back; } /* ************************************************************************ */ /* * * */ /* * Static class functions. * */ /* * * */ /* ************************************************************************ */ #line 2515 "Dk4WxApplicationHelper.cpt" void Dk4WxApplicationHelper::CorrectPosition( int & x, int & y, int & w, int & h ) { wxSize scsz; #line 2524 "Dk4WxApplicationHelper.cpt" scsz = wxGetDisplaySize(); 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 2532 "Dk4WxApplicationHelper.cpt" } void Dk4WxApplicationHelper::CorrectPosition( wxWindow & wnd ) { int x, y, w, h; #line 2543 "Dk4WxApplicationHelper.cpt" wnd.GetPosition(&x, &y); wnd.GetSize(&w, &h); Dk4WxApplicationHelper::CorrectPosition(x, y, w, h); wnd.SetSize(x, y, w, h); #line 2548 "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 2569 "Dk4WxApplicationHelper.cpt" p.GetPosition(&px, &py); p.GetSize(&pw, &ph); 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); c.SetSize(cx, cy, cw, ch); } #line 2645 "Dk4WxApplicationHelper.cpt" } size_t Dk4WxApplicationHelper::StringTableSize(const wxChar * const *sttptr) { size_t back = 0; #line 2654 "Dk4WxApplicationHelper.cpt" if (NULL != sttptr) { while (NULL != *(sttptr++)) { back++; } } #line 2657 "Dk4WxApplicationHelper.cpt" return back; } void Dk4WxApplicationHelper::ReleaseWxcharStringArray( wxChar **array, size_t sz, bool ea ) { wxChar **ap; if ((NULL != array) && (0 < sz)) { ap = array; while (0 < sz--) { dk4mem_release(*array); array++; } if (ea) { dk4mem_free(ap); } } }