/* Copyright (C) 2011-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: DkWxAppHelper.cpt */ /** @file DkWxAppHelper.cpp The DkWxAppHelper module. */ #line 345 "DkWxAppHelper.cpt" #include #include "DkWxAppHelper.h" #include "dk3wxs.h" #line 356 "DkWxAppHelper.cpt" /** Storage entry for wxChar string table. */ typedef struct { wxChar const **array; /**< String table contents. */ dkChar const *name; /**< String table name. */ size_t nelem; /**< Number of elements. */ } DkAppHelperWxStringTable; /** Pointer to constant wxChar string. */ typedef wxChar const *wxConstPtr; /** Basic texts issued by wxWidgets applications. */ static wxChar const * const dkwxapphelper_defwxappstr[] = { /* 0 */ wxT("Error worse than Panic"), /* 1 */ wxT("Panic"), /* 2 */ wxT("Fatal error"), /* 3 */ wxT("Error"), /* 4 */ wxT("Warning"), /* 5 */ wxT("Information"), /* 6 */ wxT("Progress"), /* 7 */ wxT("Debug"), /* 8 */ wxT("Ignore"), /* 9 */ wxT("Not enough memory!"), /* 10 */ wxT("Help file not found!"), /* 11 */ wxT("Failed to initialize application structure!"), /* 12 */ wxT("Failed to recode command line!"), NULL #line 431 "DkWxAppHelper.cpt" }; /** String table file containing localized versions of the texts in \a dkwxapphelper_defwxappstr. */ static dkChar const dkwxapphelper_sttname[] = { dkT("dkwx.str") }; /** Compare two string table entries. @param l Left entry. @param r Right entry. @param cr Comparison criteria (0=entry/entry, 1=entr/name). @return Comparison result. */ static int dkwxah_string_table_compare(void const *l, void const *r, int cr) { int back = 0; DkAppHelperWxStringTable const *pl; DkAppHelperWxStringTable const *pr; if(l) { if(r) { pl = (DkAppHelperWxStringTable const *)l; pr = (DkAppHelperWxStringTable const *)r; switch(cr) { case 1: { if(pl->name) { back = dk3str_cmp(pl->name, (dkChar const *)r); } else { back = -1; } } break; default: { if(pl->name) { if(pr->name) { back = dk3str_cmp(pl->name, pr->name); } else { back = 1;} } else { if(pr->name) { back = -1; } } } break; } } else { back = 1; } } else { if(r) { back = -1; } } if(back < -1) { back = -1; } if(back > 1) { back = 1; } return back; } /** Close string table. @param p String table to close. */ static void dkwxah_string_table_close(DkAppHelperWxStringTable *p) { wxChar const **ptr; size_t i; #line 496 "DkWxAppHelper.cpt" if(p) { if(p->array) { if(p->nelem) { #line 499 "DkWxAppHelper.cpt" ptr = p->array; for(i = 0; i < p->nelem; i++) { if(*ptr) { #line 502 "DkWxAppHelper.cpt" } dk3_release(*ptr); ptr++; } } dk3_delete(p->array); } dk3_release(p->name); dk3_delete(p); } #line 512 "DkWxAppHelper.cpt" } #if DK3_ON_WINDOWS || DK3_HAVE_BACKSLASH /** Separator character for file names. */ #define SEP wxT('\\') #else /** Separator character for file names. */ #define SEP wxT('/') #endif /** Non-localized keywords, 8-bit characters. */ static char const * const dkwxapphelper_c8_kw[] = { /* 0 */ "UTF-8", /* 1 */ "utf8", NULL }; DkWxAppHelper::DkWxAppHelper( wxChar const *arg0, wxChar const *vName, dkChar const *groupName ) { dkChar dkcb[DK3_MAX_PATH]; dkChar *newargv[2]; wxChar *ptr; wxChar const *cptr; wxChar const * const *ptrGetNumBasicStrings; #line 551 "DkWxAppHelper.cpt" newargv[0] = NULL; app = NULL; sStringTables = NULL; iStringTables = NULL; basicStrings = NULL; nBasicStrings = 0; cmdName = NULL; appName = NULL; vendorName = NULL; errorCode = ERROR_NONE; dkEncoding = DK3_ENCODING_PLAIN; wxEncoding = DK3_ENCODING_PLAIN; if(DK3_CHAR_SIZE > 1) { if(DK3_CHAR_SIZE > 2) { dkEncoding = DK3_ENCODING_UNICODE; } else { dkEncoding = DK3_ENCODING_UTF16; } } else { /* dkChar is 1 byte. */ #if DK3_ON_WINDOWS #else char *ptr; ptr = getenv("LANG"); if(ptr) { ptr = dk3str_c8_chr(ptr, '.'); if(ptr) { ptr++; if(dk3str_c8_casecmp(dkwxapphelper_c8_kw[0], ptr) == 0) { dkEncoding = DK3_ENCODING_UTF8; } else { if(dk3str_c8_casecmp(dkwxapphelper_c8_kw[1], ptr) == 0) { dkEncoding = DK3_ENCODING_UTF8; } } } } #endif } if(sizeof(wxChar) > 1) { if(sizeof(wxChar) > 2) { wxEncoding = DK3_ENCODING_UNICODE; } else { wxEncoding = DK3_ENCODING_UTF16; } } else { #if DK3_ON_WINDOWS #else char *ptr; ptr = getenv("LANG"); if(ptr) { ptr = dk3str_c8_chr(ptr, '.'); if(ptr) { ptr++; if(dk3str_c8_casecmp(dkwxapphelper_c8_kw[0], ptr) == 0) { wxEncoding = DK3_ENCODING_UTF8; } else { if(dk3str_c8_casecmp(dkwxapphelper_c8_kw[1], ptr) == 0) { wxEncoding = DK3_ENCODING_UTF8; } } } } #endif } if(dk3wxs_to_dkstr(dkcb,DK3_SIZEOF(dkcb,dkChar),dkEncoding,arg0,wxEncoding)) { newargv[0] = dkcb, newargv[1] = 0; app = dk3app_open_gui(1, newargv, groupName); if(app) { sStringTables = dk3sto_open_app(app); if(sStringTables) { dk3sto_set_comp(sStringTables, dkwxah_string_table_compare, 0); iStringTables = dk3sto_it_open(sStringTables); if(iStringTables) { } } } } else { errorCode = ERROR_ENCODE_ARG0; } cmdName = dk3wxs_dup_app(arg0, app); if(cmdName) { cptr = dk3wxs_rchr(cmdName, SEP); if(cptr) { cptr++; } else { cptr = cmdName; } appName = dk3wxs_dup_app(cptr, app); if(appName) { ptr = dk3wxs_rchr(appName, '.'); if(ptr) { *ptr = wxT('\0'); } } } vendorName = dk3wxs_dup_app(vName, app); /* Finally retrieve the basic application strings. */ ptrGetNumBasicStrings = dkwxapphelper_defwxappstr; while(*(ptrGetNumBasicStrings++)) { nBasicStrings++; } basicStrings = getStringTable( dkwxapphelper_defwxappstr, dkwxapphelper_sttname ); reportProblemsIfAny(); #line 661 "DkWxAppHelper.cpt" } DkWxAppHelper::~DkWxAppHelper() { #line 668 "DkWxAppHelper.cpt" DkAppHelperWxStringTable *e; basicStrings = NULL; if(sStringTables) { if(iStringTables) { dk3sto_it_reset(iStringTables); do { e = (DkAppHelperWxStringTable *)dk3sto_it_next(iStringTables); if(e) { dkwxah_string_table_close(e); } } while(e != NULL); dk3sto_it_close(iStringTables); } dk3sto_close(sStringTables); } sStringTables = NULL; iStringTables = NULL; if(app) { dk3app_close(app); app = NULL; } dk3_release(cmdName); dk3_release(appName); dk3_release(vendorName); #line 690 "DkWxAppHelper.cpt" } int DkWxAppHelper::checkSetup() const { int back = 0; #line 699 "DkWxAppHelper.cpt" if(app) { #line 700 "DkWxAppHelper.cpt" if(sStringTables) { #line 701 "DkWxAppHelper.cpt" if(iStringTables) { #line 702 "DkWxAppHelper.cpt" if(cmdName) { #line 703 "DkWxAppHelper.cpt" if(appName) { #line 704 "DkWxAppHelper.cpt" if(vendorName) { #line 705 "DkWxAppHelper.cpt" back = 1; } else { #line 707 "DkWxAppHelper.cpt" } } else { #line 709 "DkWxAppHelper.cpt" } } else { #line 711 "DkWxAppHelper.cpt" } } else { #line 713 "DkWxAppHelper.cpt" } } else { #line 715 "DkWxAppHelper.cpt" } } else { #line 717 "DkWxAppHelper.cpt" } #line 718 "DkWxAppHelper.cpt" return back; } wxChar const * const * DkWxAppHelper::getStringTable( wxChar const * const *dt, dkChar const *tn ) { #if 0 wxChar const * const *back = NULL; wxChar const * *wxptr; DkAppHelperWxStringTable *tp = NULL; FILE *fipo = NULL; dkChar const *oldsource = NULL; #if 0 dkChar dkb[4096]; #endif dkChar fnb[DK3_MAX_PATH]; wxChar wxb[4096]; char il[4096]; unsigned long lineno = 0UL; unsigned long oldline = 0UL; size_t nelem = 0; size_t i = 0; int cc = 1; int ok = 0; #line 749 "DkWxAppHelper.cpt" if((dt) && (tn)) { #line 750 "DkWxAppHelper.cpt" if(checkSetup()) { #line 751 "DkWxAppHelper.cpt" tp = (DkAppHelperWxStringTable *)dk3sto_it_find_like( iStringTables, (void *)tn, 1 ); if(!(tp)) { #line 755 "DkWxAppHelper.cpt" if(dk3app_find_data_file(app, tn, fnb, DK3_SIZEOF(fnb,dkChar))) { #line 756 "DkWxAppHelper.cpt" fipo = dk3sf_fopen_app(fnb, dk3app_not_localized(22), app); if(fipo) { #line 758 "DkWxAppHelper.cpt" wxptr = (wxChar const **)dt; nelem = 0; while(*(wxptr++)) { nelem++; } if(nelem) { #line 761 "DkWxAppHelper.cpt" tp = dk3_new_app(DkAppHelperWxStringTable,1,app); if(tp) { #line 763 "DkWxAppHelper.cpt" ok = 0; tp->array = NULL; tp->nelem = nelem; tp->name = dk3str_dup_app(tn, app); if(tp->name) { #line 768 "DkWxAppHelper.cpt" tp->array = dk3_new_app(wxConstPtr,nelem,app); if(tp->array) { #line 770 "DkWxAppHelper.cpt" wxptr = tp->array; tp->nelem = nelem; for(i = 0; i < nelem; i++) { *(wxptr++) = NULL; } if(dk3sto_add(sStringTables, (void *)tp)) { #line 774 "DkWxAppHelper.cpt" ok = 1; oldsource = dk3app_get_source_file(app); oldline = dk3app_get_source_line(app); dk3app_set_source_file(app, fnb); dk3app_set_source_line(app, 0UL); lineno = 0UL; wxptr = tp->array; nelem = 0; do { #line 782 "DkWxAppHelper.cpt" cc = 0; if(fgets(il, sizeof(il), fipo)) { #line 784 "DkWxAppHelper.cpt" dk3app_set_source_line(app, ++lineno); cc = 1; if(il[0] != '#') { #line 787 "DkWxAppHelper.cpt" dk3app_squeeze_line(il); if(dk3wxs_from_utf8(wxb,DK3_SIZEOF(wxb,wxChar),il)) { *wxptr = dk3wxs_dup_app(wxb, app); if(!(*wxptr)) { #line 792 "DkWxAppHelper.cpt" ok = 0; } wxptr++; } else { ok = 0; #line 799 "DkWxAppHelper.cpt" } } else { #line 801 "DkWxAppHelper.cpt" } if(nelem >= tp->nelem) { cc = 0; } } else { #line 804 "DkWxAppHelper.cpt" } } while((cc) && (ok)); if(nelem < tp->nelem) { ok = 0; } dk3app_set_source_file(app, oldsource); dk3app_set_source_line(app, oldline); } else { #line 812 "DkWxAppHelper.cpt" } } else { #line 814 "DkWxAppHelper.cpt" } } else { #line 816 "DkWxAppHelper.cpt" } if(ok) { back = (wxChar const * const *)(tp->array); } else { dkwxah_string_table_close(tp); } } else { #line 823 "DkWxAppHelper.cpt" } } else { #line 825 "DkWxAppHelper.cpt" } fclose(fipo); } else { #line 828 "DkWxAppHelper.cpt" } } else { #line 830 "DkWxAppHelper.cpt" } } else { #line 832 "DkWxAppHelper.cpt" } if(tp) { #line 834 "DkWxAppHelper.cpt" back = (wxChar const * const *)(tp->array); } } else { #line 837 "DkWxAppHelper.cpt" } } else { #line 839 "DkWxAppHelper.cpt" } if(!(back)) { back = dt; } #line 843 "DkWxAppHelper.cpt" #else dkChar fnb[DK3_MAX_PATH]; /* Full file name. */ char il[4096]; /* Input line */ wxChar wxb[sizeof(il)]; wxChar const * const *back = NULL; DkAppHelperWxStringTable *tp; /* String table if exists. */ wxChar const * *wxptr; /* Traverse dt array. */ FILE *fipo; /* Read input file. */ #if VERSION_BEFORE_20150821 unsigned long lineno; /* Current line. */ #endif size_t nelem; /* Number of elements in dt. */ size_t i; /* Current string to process. */ int res; /* Search result. */ int cc; /* Flag: Can continue. */ int ok; /* Flag: All strings read succes. */ #line 860 "DkWxAppHelper.cpt" if((dt) && (tn)) { #line 861 "DkWxAppHelper.cpt" if(checkSetup()) { #line 862 "DkWxAppHelper.cpt" tp = (DkAppHelperWxStringTable *)dk3sto_it_find_like( iStringTables, (void *)tn, 1 ); if(!(tp)) { #line 866 "DkWxAppHelper.cpt" res = dk3app_find_data_file(app,tn,fnb,DK3_SIZEOF(fnb,dkChar)); #line 868 "DkWxAppHelper.cpt" if(res) { #line 869 "DkWxAppHelper.cpt" fipo = dk3sf_fopen_app(fnb, dk3app_not_localized(22), app); if(fipo) { #line 871 "DkWxAppHelper.cpt" wxptr = (wxChar const **)dt; nelem = 0; while(*(wxptr++)) { nelem++; } if(nelem) { tp = dk3_new_app(DkAppHelperWxStringTable,1,app); if(tp) { tp->array = NULL; tp->nelem = nelem; tp->name = NULL; tp->name = dk3str_dup_app(tn, app); if(tp->name) { tp->array = dk3_new_app(wxConstPtr,nelem,app); if(tp->array) { wxptr = tp->array; tp->nelem = nelem; for(i = 0; i < nelem; i++) { *(wxptr++) = NULL; } wxptr = tp->array; nelem = 0; #if VERSION_BEFORE_20150821 lineno = 0UL; #endif #if VERSION_BEFORE_20150821 cc = 1; #endif ok = 1; do { cc = 0; if(fgets(il, sizeof(il), fipo)) { cc = 1; #line 898 "DkWxAppHelper.cpt" if(il[0] != '#') { #line 899 "DkWxAppHelper.cpt" dk3app_squeeze_line(il); if(dk3wxs_from_utf8(wxb,DK3_SIZEOF(wxb,wxChar),il)) { *wxptr = dk3wxs_dup_app(wxb, app); if(*wxptr) { nelem++; if(nelem >= tp->nelem) { cc = 0; } } else { ok = 0; cc = 0; } wxptr++; } else { #line 912 "DkWxAppHelper.cpt" ok = 0; cc = 0; } } else { #line 915 "DkWxAppHelper.cpt" } } } while(cc); if(nelem < tp->nelem) { ok = 0; #line 920 "DkWxAppHelper.cpt" #line 921 "DkWxAppHelper.cpt" } if(ok) { #line 923 "DkWxAppHelper.cpt" if(!dk3sto_add(sStringTables, (void *)tp)) { dkwxah_string_table_close(tp); #line 925 "DkWxAppHelper.cpt" tp = NULL; } } else { #line 928 "DkWxAppHelper.cpt" dkwxah_string_table_close(tp); tp = NULL; } } else { dkwxah_string_table_close(tp); tp = NULL; } } else { dkwxah_string_table_close(tp); tp = NULL; } } else { #line 940 "DkWxAppHelper.cpt" } } fclose(fipo); } else { #line 944 "DkWxAppHelper.cpt" } } else { #line 946 "DkWxAppHelper.cpt" } } if(tp) { #line 949 "DkWxAppHelper.cpt" back = (wxChar const * const *)(tp->array); } } else { #line 952 "DkWxAppHelper.cpt" } } else { #line 954 "DkWxAppHelper.cpt" } if(!(back)) { #line 956 "DkWxAppHelper.cpt" back = dt; } #line 958 "DkWxAppHelper.cpt" #endif return back; } size_t DkWxAppHelper::retrieveMultipleInts( wxChar const * const *names, int *values ) const { size_t back = 0; wxChar const * const *nptr; int *vptr; long l; #line 974 "DkWxAppHelper.cpt" if((appName) && (vendorName) && (names) && (values)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { nptr = names; vptr = values; while(*nptr) { l = 0L; if(conf->Read(*nptr, &l)) { *vptr = (int)l; back++; } nptr++; vptr++; } delete(conf); } } #line 989 "DkWxAppHelper.cpt" return back; } size_t DkWxAppHelper::retrieveMultipleLongs( wxChar const * const *names, long *values ) const { size_t back = 0; wxChar const * const *nptr; long *vptr; long l; #line 1005 "DkWxAppHelper.cpt" if((appName) && (vendorName) && (names) && (values)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { nptr = names; vptr = values; while(*nptr) { l = 0L; if(conf->Read(*nptr, &l)) { *vptr = l; back++; } nptr++; vptr++; } delete(conf); } } #line 1021 "DkWxAppHelper.cpt" return back; } size_t DkWxAppHelper::retrieveMultipleDoubles( wxChar const * const *names, double *values ) const { size_t back = 0; double d; wxChar const * const *nptr; double *vptr; #line 1036 "DkWxAppHelper.cpt" if((appName) && (vendorName) && (names) && (values)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { nptr = names; vptr = values; while(*nptr) { d = 0.0; if(conf->Read(*nptr, &d)) { *vptr = d; back++; } nptr++; vptr++; } delete(conf); } } #line 1051 "DkWxAppHelper.cpt" return back; } size_t DkWxAppHelper::saveMultipleInts( wxChar const * const *names, int *values ) const { size_t back = 0; wxChar const * const *nptr; int *vptr; long l; #line 1066 "DkWxAppHelper.cpt" if((appName) && (vendorName) && (names) && (values)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { #line 1069 "DkWxAppHelper.cpt" nptr = names; vptr = values; while(*nptr) { #line 1071 "DkWxAppHelper.cpt" l = (long)(*vptr); if(conf->Write(*nptr, l)) { back++; } nptr++; vptr++; } delete(conf); } } #line 1080 "DkWxAppHelper.cpt" return back; } size_t DkWxAppHelper::saveMultipleLongs( wxChar const * const *names, long *values ) const { size_t back = 0; wxChar const * const *nptr; long *vptr; long l; #line 1096 "DkWxAppHelper.cpt" if((appName) && (vendorName) && (names) && (values)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { nptr = names; vptr = values; while(*nptr) { l = *vptr; if(conf->Write(*nptr, l)) { back++; } nptr++; vptr++; } delete(conf); } } #line 1111 "DkWxAppHelper.cpt" return back; } size_t DkWxAppHelper::saveMultipleDoubles( wxChar const * const *names, double *values ) const { size_t back = 0; double d; wxChar const * const *nptr; double *vptr; #line 1127 "DkWxAppHelper.cpt" if((appName) && (vendorName) && (names) && (values)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { nptr = names; vptr = values; while(*nptr) { d = *vptr; if(conf->Write(*nptr, d)) { back++; } nptr++; vptr++; } delete(conf); } } #line 1141 "DkWxAppHelper.cpt" return back; } wxChar const * DkWxAppHelper::retrieveString( wxChar const *name ) const { wxChar const *back = NULL; wxChar const *ptr; #line 1154 "DkWxAppHelper.cpt" if((name) && (appName) && (vendorName)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { wxString str; if(conf->Read(name, &str)) { wxCStrData strdata = str.c_str(); ptr = (wxChar const *)strdata; if(ptr) { back = dk3wxs_dup_app(ptr, app); } } delete(conf); } } #line 1168 "DkWxAppHelper.cpt" return back; } int DkWxAppHelper::saveString( wxChar const *name, wxChar const *value ) const { int back = 0; #line 1181 "DkWxAppHelper.cpt" if((name) && (value) && (appName) && (vendorName)) { wxConfig *conf = new wxConfig(appName, vendorName); if(conf) { conf->Write(name, value); delete(conf); } } #line 1188 "DkWxAppHelper.cpt" return back; } int DkWxAppHelper::getWxEncoding() const { #line 1197 "DkWxAppHelper.cpt" return wxEncoding; } int DkWxAppHelper::getDkEncoding() const { #line 1206 "DkWxAppHelper.cpt" return dkEncoding; } int DkWxAppHelper::getC8Encoding() const { int back; #line 1216 "DkWxAppHelper.cpt" back = dkEncoding; if(DK3_ENCODING_UTF8 != back) { back = DK3_ENCODING_PLAIN; } #line 1220 "DkWxAppHelper.cpt" return back; } dk3_app_t * DkWxAppHelper::getApp() const { #line 1229 "DkWxAppHelper.cpt" return app; } int DkWxAppHelper::findDataFile(wxChar const *fn, wxChar *fnb, size_t szfnb) { dkChar shnDk[DK3_MAX_PATH]; dkChar ffnDk[DK3_MAX_PATH]; int back = 0; #line 1241 "DkWxAppHelper.cpt" if((fn) && (fnb) && (szfnb)) { #line 1242 "DkWxAppHelper.cpt" if(checkSetup()) { #line 1243 "DkWxAppHelper.cpt" if(dk3wxs_to_dkstr( shnDk, DK3_SIZEOF(shnDk,dkChar), dkEncoding, fn, wxEncoding ) ) { if(app) { #line 1249 "DkWxAppHelper.cpt" if(dk3app_find_data_file(app,shnDk,ffnDk,DK3_SIZEOF(ffnDk,dkChar))) { if(dk3wxs_from_dkstr(fnb, szfnb, wxEncoding, ffnDk, dkEncoding)) { back = 1; #line 1252 "DkWxAppHelper.cpt" } else { #line 1253 "DkWxAppHelper.cpt" } } else { #line 1255 "DkWxAppHelper.cpt" } } else { #line 1257 "DkWxAppHelper.cpt" } } else { #line 1259 "DkWxAppHelper.cpt" } } } #line 1262 "DkWxAppHelper.cpt" return back; } wxChar const * DkWxAppHelper::getBasicString(size_t i) const { wxChar const *back = NULL; #line 1272 "DkWxAppHelper.cpt" if(basicStrings) { if(i < nBasicStrings) { back = basicStrings[i]; } } #line 1277 "DkWxAppHelper.cpt" return back; } wxChar const * const * DkWxAppHelper::getBasicStrings() const { #line 1286 "DkWxAppHelper.cpt" return basicStrings; } size_t DkWxAppHelper::getBasicStringNumbers() const { #line 1295 "DkWxAppHelper.cpt" return nBasicStrings; } bool DkWxAppHelper::wxToDk(dkChar *bu, size_t sz, wxChar const *src) const { bool back = false; #line 1305 "DkWxAppHelper.cpt" if((bu) && (sz) && (src)) { if(dk3wxs_to_dkstr(bu, sz, dkEncoding, src, wxEncoding)) { back = true; } } #line 1310 "DkWxAppHelper.cpt" return back; } bool DkWxAppHelper::wxToC8(char *bu, size_t sz, wxChar const *src) const { bool back = false; #line 1320 "DkWxAppHelper.cpt" if((bu) && (sz) && (src)) { if(dk3wxs_to_c8(bu, sz, getC8Encoding(), src, wxEncoding)) { back = true; } } #line 1325 "DkWxAppHelper.cpt" return back; } bool DkWxAppHelper::wxToC8(char *bu, size_t sz, wxString & str) const { bool back = false; wxChar const *ptr; #line 1336 "DkWxAppHelper.cpt" if((bu) && (sz)) { wxCStrData strdata = str.c_str(); ptr = (wxChar const *)strdata; if(ptr) { back = wxToC8(bu, sz, ptr); } } #line 1343 "DkWxAppHelper.cpt" return back; } bool DkWxAppHelper::dkToWx(wxChar *bu, size_t sz, dkChar const *src) const { bool back = false; #line 1353 "DkWxAppHelper.cpt" if((bu) && (sz) && (src)) { if(dk3wxs_from_dkstr(bu, sz, wxEncoding, src, dkEncoding)) { back = true; } } #line 1358 "DkWxAppHelper.cpt" return back; } void DkWxAppHelper::setRelatedPosition( wxWindow *parent, wxWindow *child, int *pcx, int *pcy ) const { int px = 0; /* Parent x position. */ int py = 0; /* Parent y position. */ int pw = 0; /* Parent width. */ int ph = 0; /* Parent height. */ int cx = 0; /* Child x position. */ int cy = 0; /* Child y position. */ int cw = 0; /* Child width. */ int ch = 0; /* Child height. */ wxSize scsz; /* Screen size. */ scsz = wxGetDisplaySize(); parent->GetPosition(&px, &py); parent->GetSize(&pw, &ph); child->GetSize(&cw, &ch); cx = px + (pw - cw) / 2; cy = py + (ph - ch) / 2; if((cx + cw) > scsz.x) { cx = scsz.x - cw; } if((cy + ch) > scsz.y) { cy = scsz.y - ch; } if(cx < 0) { cx = 0; } if(cy < 0) { cy = 0; } if((pcx) && (pcy)) { if(((*pcx) >= 0) && ((*pcy) >= 0)) { cx = *pcx; cy = *pcy; } } child->SetSize(cx, cy, cw, ch); } void DkWxAppHelper::reportProblemsIfAny(void) { bool didReport = false; if (!didReport) { if (NULL == app) { didReport = true; switch (errorCode) { case ERROR_ENCODE_ARG0 : { /* ERROR: Failed to encode arg0 to dkChar */ showErrorMessage(3, 12); } break; default : { /* ERROR: Failed to initialize application structure */ showErrorMessage(3, 11); } break; } } } if (!didReport) { if (NULL != app) { if ((NULL == sStringTables) || (NULL == iStringTables)) { didReport = true; /* ERROR: Memory */ showErrorMessage(3, 9); } } } if (!didReport) { if ((NULL == cmdName) || (NULL == appName) || (NULL == vendorName)) { /* ERROR: Memory */ showErrorMessage(3, 9); } } } void DkWxAppHelper::showErrorMessage(size_t i_title, size_t i_text) { const wxChar *str_title = NULL; const wxChar *str_text = NULL; if (NULL != basicStrings) { str_title = basicStrings[i_title]; str_text = basicStrings[i_text]; } else { str_title = dkwxapphelper_defwxappstr[i_title]; str_text = dkwxapphelper_defwxappstr[i_text]; } wxMessageBox(str_text, str_title, (wxOK | wxCENTRE | wxICON_ERROR)); }