summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
Diffstat (limited to 'library')
-rw-r--r--library/globalFunctions.cpp32
-rw-r--r--library/globalFunctions.h8
-rw-r--r--library/misc.cpp17
-rw-r--r--library/multithreading.cpp2
-rw-r--r--library/multithreading.h2
5 files changed, 51 insertions, 10 deletions
diff --git a/library/globalFunctions.cpp b/library/globalFunctions.cpp
index 5afb1650..d4579312 100644
--- a/library/globalFunctions.cpp
+++ b/library/globalFunctions.cpp
@@ -92,3 +92,35 @@ wxString& globalFunctions::includeNumberSeparator(wxString& number)
number.insert(i, GlobalResources::thousandsSeparator);
return number;
}
+
+
+int globalFunctions::readInt(ifstream& stream)
+{
+ int result = 0;
+ char* buffer = reinterpret_cast<char*>(&result);
+ stream.read(buffer, sizeof(int));
+ return result;
+}
+
+
+void globalFunctions::writeInt(ofstream& stream, const int number)
+{
+ const char* buffer = reinterpret_cast<const char*>(&number);
+ stream.write(buffer, sizeof(int));
+}
+
+
+int globalFunctions::readInt(wxInputStream& stream)
+{
+ int result = 0;
+ char* buffer = reinterpret_cast<char*>(&result);
+ stream.Read(buffer, sizeof(int));
+ return result;
+}
+
+
+void globalFunctions::writeInt(wxOutputStream& stream, const int number)
+{
+ const char* buffer = reinterpret_cast<const char*>(&number);
+ stream.Write(buffer, sizeof(int));
+}
diff --git a/library/globalFunctions.h b/library/globalFunctions.h
index 55e37c61..7f50f90a 100644
--- a/library/globalFunctions.h
+++ b/library/globalFunctions.h
@@ -4,6 +4,8 @@
#include <string>
#include <algorithm>
#include <wx/string.h>
+#include <fstream>
+#include <wx/stream.h>
using namespace std;
@@ -32,6 +34,12 @@ namespace globalFunctions
double wxStringToDouble(const wxString& number); //Convert wxString to number
wxString& includeNumberSeparator(wxString& number);
+
+ int readInt(ifstream& stream); //read int from file stream
+ void writeInt(ofstream& stream, const int number); //write int to filestream
+
+ int readInt(wxInputStream& stream); //read int from file stream
+ void writeInt(wxOutputStream& stream, const int number); //write int to filestream
}
diff --git a/library/misc.cpp b/library/misc.cpp
index 44dcaf0e..7d798ec0 100644
--- a/library/misc.cpp
+++ b/library/misc.cpp
@@ -2,6 +2,7 @@
#include <fstream>
#include <wx/msgdlg.h>
#include "resources.h"
+#include "globalFunctions.h"
void exchangeEscapeChars(wxString& data)
{
@@ -25,7 +26,7 @@ CustomLocale::~CustomLocale()
ofstream output("lang.dat");
if (output)
{
- output<<currentLanguage<<char(0);
+ globalFunctions::writeInt(output, currentLanguage);
output.close();
}
else
@@ -41,9 +42,7 @@ void CustomLocale::loadLanguageFromCfg() //retrieve language from config file:
ifstream input("lang.dat");
if (input)
{
- char buffer[20];
- input.getline(buffer, 20, char(0));
- language = atoi(buffer);
+ language = globalFunctions::readInt(input);
input.close();
}
else
@@ -65,7 +64,9 @@ void CustomLocale::loadLanguageFile(int language)
case wxLANGUAGE_GERMAN:
languageFile = "german.lng";
break;
-
+ case wxLANGUAGE_FRENCH:
+ languageFile = "french.lng";
+ break;
default:
languageFile = string();
currentLanguage = wxLANGUAGE_ENGLISH;
@@ -87,13 +88,13 @@ void CustomLocale::loadLanguageFile(int language)
//----------
//Linux: 0xa
//Mac: 0xd
- //Win: 0xd 0xa
+ //Win: 0xd 0xa <- language files are in Windows format
while (langFile.getline(temp, bufferSize, 0xd)) //specify delimiter explicitely
{
langFile.get(); //discard the 0xa character
- //wxString formattedString(temp, *wxConvUTF8, bufferSize); //convert UTF8 input to Unicode
- wxString formattedString(temp);
+ //wxString formattedString = wxString::FromUTF8(temp);
+ wxString formattedString = wxString::From8BitData(temp);
exchangeEscapeChars(formattedString);
diff --git a/library/multithreading.cpp b/library/multithreading.cpp
index bb598194..c8826b11 100644
--- a/library/multithreading.cpp
+++ b/library/multithreading.cpp
@@ -145,6 +145,6 @@ void UpdateWhileExecuting::execute(StatusUpdater* statusUpdater)
theWorkerThread->readyToBeginProcessing.Unlock();
while (receivingResult.WaitTimeout(UI_UPDATE_INTERVAL) == wxCOND_TIMEOUT)
- statusUpdater->triggerUI_Refresh(); //ATTENTION: Exception "AbortThisProcess" may be thrown here!!!
+ statusUpdater->triggerUI_Refresh(true); //ATTENTION: Exception "AbortThisProcess" may be thrown here!!!
}
diff --git a/library/multithreading.h b/library/multithreading.h
index 56cff890..f2b5211c 100644
--- a/library/multithreading.h
+++ b/library/multithreading.h
@@ -20,7 +20,7 @@ public:
virtual int reportError(const wxString& text) = 0;
//this method is triggered repeatedly and can be used to refresh the ui by dispatching pending events
- virtual void triggerUI_Refresh() = 0;
+ virtual void triggerUI_Refresh(bool asyncProcessActive = false) = 0;
void requestAbortion() //opportunity to abort must be implemented in a frequently executed method like triggerUI_Refresh()
{ //currently used by the UI status information screen, when button "Abort is pressed"
bgstack15