summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 16:50:14 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 16:50:14 +0200
commitad0ea7798b82cc3a4dfed4c2fce6f2cb1b6805e4 (patch)
treedcc7dd2ed76fd0900944c07776fcbdbcd665c020 /library
parent1.5 (diff)
downloadFreeFileSync-ad0ea7798b82cc3a4dfed4c2fce6f2cb1b6805e4.tar.gz
FreeFileSync-ad0ea7798b82cc3a4dfed4c2fce6f2cb1b6805e4.tar.bz2
FreeFileSync-ad0ea7798b82cc3a4dfed4c2fce6f2cb1b6805e4.zip
1.6
Diffstat (limited to 'library')
-rw-r--r--library/CustomGrid.cpp257
-rw-r--r--library/CustomGrid.h22
-rw-r--r--library/FreeFileSync.icobin0 -> 94198 bytes
-rw-r--r--library/FreeFileSync.xpm425
-rw-r--r--library/globalFunctions.cpp4
-rw-r--r--library/misc.cpp138
-rw-r--r--library/misc.h52
-rw-r--r--library/multithreading.cpp8
-rw-r--r--library/multithreading.h1
-rw-r--r--library/resources.cpp184
-rw-r--r--library/resources.h96
11 files changed, 1106 insertions, 81 deletions
diff --git a/library/CustomGrid.cpp b/library/CustomGrid.cpp
index 4f8c84ad..053244f5 100644
--- a/library/CustomGrid.cpp
+++ b/library/CustomGrid.cpp
@@ -1,4 +1,7 @@
#include "customGrid.h"
+#include "globalFunctions.h"
+#include "resources.h"
+#include <wx/dc.h>
const unsigned int MinimumRows = 15;
@@ -6,20 +9,21 @@ const unsigned int MinimumRows = 15;
class CustomGridTableBase : public wxGridStringTable
{
public:
- CustomGridTableBase(int numRows, int numCols) : wxGridStringTable(numRows, numCols), gridIdentifier(0), currentUI_ViewPtr(0), lastNrRows(MinimumRows)
- {
- lightBlue = new wxColour(80, 110, 255);
- }
+ CustomGridTableBase(int numRows, int numCols) :
+ wxGridStringTable(numRows, numCols),
+ lightBlue(80, 110, 255),
+ gridIdentifier(0),
+ gridRefUI(0),
+ gridData(0),
+ lastNrRows(MinimumRows) {}
- ~CustomGridTableBase()
- {
- delete lightBlue;
- }
+ ~CustomGridTableBase() {}
- void setGridDataTable(UI_Grid* currentUI_ViewPtr)
+ void setGridDataTable(GridView* gridRefUI, FileCompareResult* gridData)
{
- this->currentUI_ViewPtr = currentUI_ViewPtr;
+ this->gridRefUI = gridRefUI;
+ this->gridData = gridData;
}
void SetGridIdentifier(int id)
@@ -28,12 +32,12 @@ public:
}
//###########################################################################
-//grid standard input output methods, redirected directly to UIGrid to improve performance
+//grid standard input output methods, redirected directly to gridData to improve performance
virtual int GetNumberRows()
{
- if (currentUI_ViewPtr)
- return max(currentUI_ViewPtr->size(), MinimumRows);
+ if (gridRefUI)
+ return max(gridRefUI->size(), MinimumRows);
return MinimumRows; //grid is initialized with this number of rows
}
@@ -42,52 +46,122 @@ public:
return (GetValue(row, col) == wxEmptyString);
}
- virtual wxString GetValue( int row, int col )
+
+ inline
+ wxString evaluateCmpResult(const CompareFilesResult result, const bool selectedForSynchronization)
{
- if (currentUI_ViewPtr)
+ if (selectedForSynchronization)
+ switch (result)
+ {
+ case fileOnLeftSideOnly:
+ return "<|";
+ break;
+ case fileOnRightSideOnly:
+ return "|>";
+ break;
+ case rightFileNewer:
+ return ">>";
+ break;
+ case leftFileNewer:
+ return "<<";
+ break;
+ case filesDifferent:
+ return "!=";
+ break;
+ case filesEqual:
+ return "==";
+ break;
+ default:
+ assert (false);
+ return wxEmptyString;
+ }
+ else return "(-)";
+ }
+
+
+ virtual wxString GetValue(int row, int col)
+ {
+ if (gridRefUI)
{
- if (currentUI_ViewPtr->size() > unsigned(row))
+ if (unsigned(row) < gridRefUI->size())
{
+ const FileCompareLine& gridLine = (*gridData)[(*gridRefUI)[row]];
+ wxString fileSize; //tmp string
+
switch (gridIdentifier)
{
case 1:
- if (4 > col)
+ if (col < 4)
{
- switch (col)
+ if (gridLine.fileDescrLeft.objType == isDirectory)
{
- case 0:
- return (*currentUI_ViewPtr)[row].leftFilename;
- case 1:
- return (*currentUI_ViewPtr)[row].leftRelativePath;
- case 2:
- return (*currentUI_ViewPtr)[row].leftSize;
- case 3:
- return (*currentUI_ViewPtr)[row].leftDate;
+ switch (col)
+ {
+ case 0: //filename
+ return wxEmptyString;
+ case 1: //relative path
+ return gridLine.fileDescrLeft.relFilename;
+ case 2: //file size
+ return _("<Directory>");
+ case 3: //date
+ return gridLine.fileDescrLeft.lastWriteTime;
+ }
+ }
+ else if (gridLine.fileDescrLeft.objType == isFile)
+ {
+ switch (col)
+ {
+ case 0: //filename
+ return gridLine.fileDescrLeft.relFilename.AfterLast(GlobalResources::fileNameSeparator);
+ case 1: //relative path
+ return gridLine.fileDescrLeft.relFilename.BeforeLast(GlobalResources::fileNameSeparator);
+ case 2: //file size
+ return globalFunctions::includeNumberSeparator(fileSize = gridLine.fileDescrLeft.fileSize.ToString());
+ case 3: //date
+ return gridLine.fileDescrLeft.lastWriteTime;
+ }
}
}
break;
case 2:
- if (4 > col)
+ if (col < 4)
{
- switch (col)
+ if (gridLine.fileDescrRight.objType == isDirectory)
{
- case 0:
- return (*currentUI_ViewPtr)[row].rightFilename;
- case 1:
- return (*currentUI_ViewPtr)[row].rightRelativePath;
- case 2:
- return (*currentUI_ViewPtr)[row].rightSize;
- case 3:
- return (*currentUI_ViewPtr)[row].rightDate;
+ switch (col)
+ {
+ case 0: //filename
+ return wxEmptyString;
+ case 1: //relative path
+ return gridLine.fileDescrRight.relFilename;
+ case 2: //file size
+ return _("<Directory>");
+ case 3: //date
+ return gridLine.fileDescrRight.lastWriteTime;
+ }
+ }
+ else if (gridLine.fileDescrRight.objType == isFile)
+ {
+ switch (col)
+ {
+ case 0: //filename
+ return gridLine.fileDescrRight.relFilename.AfterLast(GlobalResources::fileNameSeparator);
+ case 1: //relative path
+ return gridLine.fileDescrRight.relFilename.BeforeLast(GlobalResources::fileNameSeparator);
+ case 2: //file size
+ return globalFunctions::includeNumberSeparator(fileSize = gridLine.fileDescrRight.fileSize.ToString());
+ case 3: //date
+ return gridLine.fileDescrRight.lastWriteTime;
+ }
}
}
break;
case 3:
- if (1 > col)
+ if (col < 1)
{
- return (*currentUI_ViewPtr)[row].cmpResult;
+ return evaluateCmpResult(gridLine.cmpResult, gridLine.selectedForSynchronization);;
}
break;
@@ -96,44 +170,44 @@ public:
}
}
}
- //if data not found in UIgrid table:
+ //if data is not found:
return wxEmptyString;
}
virtual void SetValue( int row, int col, const wxString& value )
{
- assert (false); //should not be used, since values are retrieved directly from currentUI_ViewPtr
+ assert (false); //should not be used, since values are retrieved directly from gridRefUI
}
virtual void Clear()
{
- assert (false); // we don't want to use this, since the visible grid is directly connected to currentUI_ViewPtr}
+ assert (false); // we don't want to use this, since the visible grid is directly connected to gridRefUI}
}
virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 )
{
- assert (false); // we don't want to use this, since the visible grid is directly connected to currentUI_ViewPtr}
+ assert (false); // we don't want to use this, since the visible grid is directly connected to gridRefUI}
return true;
}
virtual bool AppendRows( size_t numRows = 1 )
{
- assert (false); // we don't want to use this, since the visible grid is directly connected to currentUI_ViewPtr}
+ assert (false); // we don't want to use this, since the visible grid is directly connected to gridRefUI}
return true;
}
virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 )
{
- assert (false); // we don't want to use this, since the visible grid is directly connected to currentUI_ViewPtr}
+ assert (false); // we don't want to use this, since the visible grid is directly connected to gridRefUI}
return true;
}
//update dimensions of grid: no need for InsertRows, AppendRows, DeleteRows anymore!!!
void updateGridSizes()
{
- if (currentUI_ViewPtr)
+ if (gridRefUI)
{
int currentNrRows = GetNumberRows();
if (lastNrRows < currentNrRows)
{
- if ( GetView() )
+ if (GetView())
{
wxGridTableMessage msg(this,
wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
@@ -144,7 +218,7 @@ public:
}
else if (lastNrRows > currentNrRows)
{
- if ( GetView() )
+ if (GetView())
{
wxGridTableMessage msg(this,
wxGRIDTABLE_NOTIFY_ROWS_DELETED,
@@ -160,19 +234,20 @@ public:
//###########################################################################
- bool markThisRow(int row)
+ bool markThisRow(int row) //rows that are filtered out are shown in different color
{
- if (currentUI_ViewPtr)
+ if (gridRefUI)
{
- if (unsigned(row) < currentUI_ViewPtr->size())
+ if (unsigned(row) < gridRefUI->size())
{
- if ((*currentUI_ViewPtr)[row].cmpResult == constFilteredOut)
+ if (!(*gridData)[(*gridRefUI)[row]].selectedForSynchronization)
return true;
}
}
return false;
}
+
wxGridCellAttr* GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind)
{
wxGridCellAttr* result = wxGridTableBase::GetAttr(row, col, kind);
@@ -188,7 +263,7 @@ public:
}
if (markThisRow(row))
- result->SetBackgroundColour(*lightBlue);
+ result->SetBackgroundColour(lightBlue);
else
result->SetBackgroundColour(*wxWHITE);
}
@@ -196,16 +271,17 @@ public:
{
result = new wxGridCellAttr;
if (markThisRow(row))
- result->SetBackgroundColour(*lightBlue);
+ result->SetBackgroundColour(lightBlue);
}
return result;
}
private:
- wxColour* lightBlue;
+ wxColour lightBlue;
int gridIdentifier;
- UI_Grid* currentUI_ViewPtr; //(fast) access to underlying grid data :)
+ GridView* gridRefUI; //(very fast) access to underlying grid data :)
+ FileCompareResult* gridData;
int lastNrRows;
};
@@ -213,21 +289,24 @@ private:
//########################################################################################################
-CustomGrid::CustomGrid( wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
- : wxGrid(parent, id, pos, size, style, name),
+CustomGrid::CustomGrid(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name) :
+ wxGrid(parent, id, pos, size, style, name),
scrollbarsEnabled(true),
m_grid1(0), m_grid2(0), m_grid3(0),
gridDataTable(0),
currentSortColumn(-1),
- sortMarker(0) {}
+ sortMarker(0)
+{}
+
CustomGrid::~CustomGrid() {}
+
bool CustomGrid::CreateGrid(int numRows, int numCols, wxGrid::wxGridSelectionModes selmode)
{
//use custom wxGridTableBase class for management of large sets of formatted data.
@@ -255,6 +334,44 @@ void CustomGrid::SetScrollbar(int orientation, int position, int thumbSize, int
}
+//ensure that all grids are properly aligned: add some extra window space to grids that have no horizontal scrollbar
+void CustomGrid::adjustGridHeights() //m_grid1, m_grid2, m_grid3 are not NULL in this context
+{
+ int y1 = 0;
+ int y2 = 0;
+ int y3 = 0;
+ int dummy = 0;
+
+ m_grid1->GetViewStart(&dummy, &y1);
+ m_grid2->GetViewStart(&dummy, &y2);
+ m_grid3->GetViewStart(&dummy, &y3);
+
+ if (y1 != y2 || y2 != y3)
+ {
+ int yMax = max(y1, max(y2, y3));
+
+ if (leadingPanel == 1) //do not handle case (y1 == yMax) here!!! Avoid back coupling!
+ m_grid1->SetMargins(0, 0);
+ else if (y1 < yMax)
+ m_grid1->SetMargins(0, 50);
+
+ if (leadingPanel == 2)
+ m_grid2->SetMargins(0, 0);
+ else if (y2 < yMax)
+ m_grid2->SetMargins(0, 50);
+
+ if (leadingPanel == 3)
+ m_grid3->SetMargins(0, 0);
+ else if (y3 < yMax)
+ m_grid3->SetMargins(0, 50);
+
+ m_grid1->ForceRefresh();
+ m_grid2->ForceRefresh();
+ m_grid3->ForceRefresh();
+ }
+}
+
+
//this method is called when grid view changes: useful for parallel updating of multiple grids
void CustomGrid::DoPrepareDC(wxDC& dc)
{
@@ -266,24 +383,32 @@ void CustomGrid::DoPrepareDC(wxDC& dc)
GetViewStart(&x, &y);
m_grid2->Scroll(x, y);
m_grid3->Scroll(-1, y); //scroll in y-direction only
+ adjustGridHeights(); //keep here to ensure m_grid1, m_grid2, m_grid3 != NULL
}
else if (leadingPanel == 2 && this == m_grid2) //avoid back coupling
{
GetViewStart(&x, &y);
m_grid1->Scroll(x, y);
m_grid3->Scroll(-1, y);
+ adjustGridHeights(); //keep here to ensure m_grid1, m_grid2, m_grid3 != NULL
}
else if (leadingPanel == 3 && this == m_grid3) //avoid back coupling
{
GetViewStart(&x, &y);
m_grid1->Scroll(-1, y);
m_grid2->Scroll(-1, y);
+ adjustGridHeights(); //keep here to ensure m_grid1, m_grid2, m_grid3 != NULL
}
}
+
//these classes will scroll together, hence the name ;)
void CustomGrid::setScrollFriends(CustomGrid* grid1, CustomGrid* grid2, CustomGrid* grid3)
{
+ assert(grid1);
+ assert(grid2);
+ assert(grid3);
+
m_grid1 = grid1;
m_grid2 = grid2;
m_grid3 = grid3;
@@ -300,11 +425,11 @@ void CustomGrid::setScrollFriends(CustomGrid* grid1, CustomGrid* grid2, CustomGr
}
-void CustomGrid::setGridDataTable(UI_Grid* currentUI_ViewPtr)
+void CustomGrid::setGridDataTable(GridView* gridRefUI, FileCompareResult* gridData)
{
//set underlying grid data
assert(gridDataTable);
- gridDataTable->setGridDataTable(currentUI_ViewPtr);
+ gridDataTable->setGridDataTable(gridRefUI, gridData);
}
@@ -322,7 +447,7 @@ void CustomGrid::setSortMarker(const int sortColumn, const wxBitmap* bitmap)
}
-void CustomGrid::DrawColLabel( wxDC& dc, int col )
+void CustomGrid::DrawColLabel(wxDC& dc, int col)
{
assert(0 <= col && col < 4);
diff --git a/library/CustomGrid.h b/library/CustomGrid.h
index 951aadc3..0679c6c7 100644
--- a/library/CustomGrid.h
+++ b/library/CustomGrid.h
@@ -1,27 +1,27 @@
#ifndef CUSTOMGRID_H_INCLUDED
#define CUSTOMGRID_H_INCLUDED
-#include "../ui/mainDialog.h"
#include <vector>
#include <wx/grid.h>
+#include "../FreeFileSync.h"
using namespace std;
-extern int leadingPanel;
-
class CustomGridTableBase;
//##################################################################################
+extern int leadingPanel;
+
class CustomGrid : public wxGrid
{
public:
- CustomGrid( wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxWANTS_CHARS,
- const wxString& name = wxGridNameStr );
+ CustomGrid(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxWANTS_CHARS,
+ const wxString& name = wxGridNameStr);
~CustomGrid();
@@ -37,7 +37,7 @@ public:
void setScrollFriends(CustomGrid* grid1, CustomGrid* grid2, CustomGrid* grid3);
- void setGridDataTable(UI_Grid* currentUI_ViewPtr);
+ void setGridDataTable(GridView* gridRefUI, FileCompareResult* gridData);
void updateGridSizes();
@@ -47,6 +47,8 @@ public:
void DrawColLabel( wxDC& dc, int col );
private:
+ void adjustGridHeights();
+
bool scrollbarsEnabled;
CustomGrid* m_grid1;
diff --git a/library/FreeFileSync.ico b/library/FreeFileSync.ico
new file mode 100644
index 00000000..bceb6ee4
--- /dev/null
+++ b/library/FreeFileSync.ico
Binary files differ
diff --git a/library/FreeFileSync.xpm b/library/FreeFileSync.xpm
new file mode 100644
index 00000000..4165c5a1
--- /dev/null
+++ b/library/FreeFileSync.xpm
@@ -0,0 +1,425 @@
+/* XPM */
+static char * FreeFileSync_xpm[] = {
+"32 32 390 2",
+" c None",
+". c #005927",
+"+ c #046A38",
+"@ c #1B7E4B",
+"# c #318F5A",
+"$ c #308F56",
+"% c #258C4D",
+"& c #128040",
+"* c #036C36",
+"= c #005A31",
+"- c #005D28",
+"; c #1F7D4E",
+"> c #76B08F",
+", c #ADD9B7",
+"' c #B9EABB",
+") c #A5E9A5",
+"! c #8BE38A",
+"~ c #6DDB6D",
+"{ c #4DD04E",
+"] c #2FC136",
+"^ c #19A82F",
+"/ c #078433",
+"( c #005D33",
+"_ c #036B35",
+": c #6FAA8C",
+"< c #D9EEDE",
+"[ c #E0FDDD",
+"} c #BDF3BB",
+"| c #9BE89A",
+"1 c #7DE07C",
+"2 c #5FD85F",
+"3 c #44D143",
+"4 c #32D131",
+"5 c #2AD929",
+"6 c #25E422",
+"7 c #1CE31C",
+"8 c #0CB522",
+"9 c #017235",
+"0 c #0B6F3B",
+"a c #9EC8B0",
+"b c #EEFFEC",
+"c c #CAF5C9",
+"d c #A7EAA7",
+"e c #8AE38A",
+"f c #6EDB6E",
+"g c #51D351",
+"h c #39CF38",
+"i c #2CD32B",
+"j c #26DB26",
+"k c #20E11F",
+"l c #19E719",
+"m c #13EF12",
+"n c #0CFE08",
+"o c #03DB0F",
+"p c #007F31",
+"q c #056B36",
+"r c #98C7AA",
+"s c #E3FEE0",
+"t c #B8EEB7",
+"u c #99E699",
+"v c #7DDF7D",
+"w c #60D760",
+"x c #45D144",
+"y c #33D530",
+"z c #2ADA28",
+"A c #23DC23",
+"B c #1CE41C",
+"C c #16F113",
+"D c #0FF90C",
+"E c #08FA07",
+"F c #02FE02",
+"G c #00FF00",
+"H c #00E20A",
+"I c #007434",
+"J c #005E2F",
+"K c #005E30",
+"L c #005B2E",
+"M c #005D2E",
+"N c #6BAB87",
+"O c #D5FAD2",
+"P c #AAEAAA",
+"Q c #8CE28C",
+"R c #70DB70",
+"S c #53D453",
+"T c #3BD13A",
+"U c #2DD42C",
+"V c #1CB72C",
+"W c #0D9830",
+"X c #078931",
+"Y c #068D2F",
+"Z c #06A527",
+"` c #04CF14",
+" . c #00FC02",
+".. c #00C914",
+"+. c #1A8347",
+"@. c #5ABA6B",
+"#. c #4FBA60",
+"$. c #36AA4A",
+"%. c #299E42",
+"&. c #8FDF92",
+"*. c #81DE81",
+"=. c #65D665",
+"-. c #47D047",
+";. c #33D232",
+">. c #27CE2A",
+",. c #0D8F30",
+"'. c #005A2F",
+"). c #005F33",
+"!. c #008A2C",
+"~. c #00D210",
+"{. c #009629",
+"]. c #369C56",
+"^. c #81E87D",
+"/. c #66DE63",
+"(. c #50D94D",
+"_. c #3BD538",
+":. c #2CD52B",
+"<. c #2DDD2D",
+"[. c #34E034",
+"}. c #2FDB2F",
+"|. c #29D728",
+"1. c #25D228",
+"2. c #098033",
+"3. c #00502E",
+"4. c #006536",
+"5. c #00A820",
+"6. c #00F802",
+"7. c #00D510",
+"8. c #005D31",
+"9. c #1D8945",
+"0. c #60D860",
+"a. c #4AD34A",
+"b. c #36CF36",
+"c. c #2BD42B",
+"d. c #22DC22",
+"e. c #19E419",
+"f. c #0FED0F",
+"g. c #08F608",
+"h. c #05FE03",
+"i. c #05E80B",
+"j. c #009E21",
+"k. c #006832",
+"l. c #005734",
+"m. c #009029",
+"n. c #00EF05",
+"o. c #00832D",
+"p. c #057238",
+"q. c #40C646",
+"r. c #38D137",
+"s. c #1BE41B",
+"t. c #13ED13",
+"u. c #0AF50A",
+"v. c #02FD02",
+"w. c #00DF0C",
+"x. c #008730",
+"y. c #004F30",
+"z. c #00852C",
+"A. c #00F105",
+"B. c #00B41F",
+"C. c #005E32",
+"D. c #1DA434",
+"E. c #2EDA2B",
+"F. c #00A426",
+"G. c #008C27",
+"H. c #00B91B",
+"I. c #098234",
+"J. c #23DB23",
+"K. c #1CE61B",
+"L. c #00C019",
+"M. c #006131",
+"N. c #006233",
+"O. c #006E2B",
+"P. c #00622F",
+"Q. c #006535",
+"R. c #12BD23",
+"S. c #14F511",
+"T. c #00EE07",
+"U. c #00A424",
+"V. c #00612F",
+"W. c #3A8D63",
+"X. c #8ABBA3",
+"Y. c #B3D1C2",
+"Z. c #468F6D",
+"`. c #005E2A",
+" + c #038230",
+".+ c #0AEF0C",
+"++ c #03FF02",
+"@+ c #00F703",
+"#+ c #007931",
+"$+ c #006230",
+"%+ c #509A75",
+"&+ c #BBD6C9",
+"*+ c #FEFEFF",
+"=+ c #FFFFFF",
+"-+ c #E6F2EB",
+";+ c #1F7C4D",
+">+ c #005D35",
+",+ c #009624",
+"'+ c #00FC01",
+")+ c #00ED07",
+"!+ c #00BC1A",
+"~+ c #00812F",
+"{+ c #004E2E",
+"]+ c #378C60",
+"^+ c #B5D5C3",
+"/+ c #FAFFFA",
+"(+ c #FBFFF9",
+"_+ c #ECFCEB",
+":+ c #E1F8E1",
+"<+ c #D8F6D8",
+"[+ c #DBFCD8",
+"}+ c #7BBE8F",
+"|+ c #009022",
+"1+ c #009823",
+"2+ c #007030",
+"3+ c #00492B",
+"4+ c #046734",
+"5+ c #65AE81",
+"6+ c #D0F3D1",
+"7+ c #D8FBD6",
+"8+ c #C3F2C3",
+"9+ c #B7EEB7",
+"0+ c #AEECAE",
+"a+ c #A5EAA5",
+"b+ c #9CE79C",
+"c+ c #94E694",
+"d+ c #89E189",
+"e+ c #198446",
+"f+ c #31895D",
+"g+ c #116C44",
+"h+ c #00502A",
+"i+ c #036230",
+"j+ c #62B878",
+"k+ c #AEF1AC",
+"l+ c #9DE99C",
+"m+ c #8FE38F",
+"n+ c #86E186",
+"o+ c #7CDE7C",
+"p+ c #73DC73",
+"q+ c #6AD96A",
+"r+ c #61D761",
+"s+ c #57D457",
+"t+ c #53D951",
+"u+ c #2CA941",
+"v+ c #005F31",
+"w+ c #549F7A",
+"x+ c #B0D0C1",
+"y+ c #0B6A38",
+"z+ c #0D773D",
+"A+ c #6EDB6F",
+"B+ c #6BDF67",
+"C+ c #5DD65D",
+"D+ c #55D355",
+"E+ c #4BD24B",
+"F+ c #43D143",
+"G+ c #3BD13B",
+"H+ c #34D234",
+"I+ c #2DD42D",
+"J+ c #27D827",
+"K+ c #22DF21",
+"L+ c #1BDB1E",
+"M+ c #027A34",
+"N+ c #167646",
+"O+ c #EDFBEE",
+"P+ c #9FCDAF",
+"Q+ c #0A6E39",
+"R+ c #168C3B",
+"S+ c #2BC034",
+"T+ c #28D828",
+"U+ c #21DD21",
+"V+ c #1EE01E",
+"W+ c #1AE41A",
+"X+ c #15E915",
+"Y+ c #10EE10",
+"Z+ c #0CF30C",
+"`+ c #08F808",
+" @ c #05FB04",
+".@ c #03FE02",
+"+@ c #01A323",
+"@@ c #00592A",
+"#@ c #88C79A",
+"$@ c #DBFFD5",
+"%@ c #88CB97",
+"&@ c #157942",
+"*@ c #006732",
+"=@ c #1FB431",
+"-@ c #24EC22",
+";@ c #0CF40C",
+">@ c #00C515",
+",@ c #005A33",
+"'@ c #309358",
+")@ c #A4ECA3",
+"!@ c #A3EDA0",
+"~@ c #7DD584",
+"{@ c #288E4B",
+"]@ c #006232",
+"^@ c #0F8535",
+"/@ c #36C739",
+"(@ c #35D334",
+"_@ c #29D729",
+":@ c #0FF10F",
+"<@ c #05FB05",
+"[@ c #01FE01",
+"}@ c #00FE00",
+"|@ c #00CB13",
+"1@ c #006135",
+"2@ c #016432",
+"3@ c #5ABF68",
+"4@ c #7AE377",
+"5@ c #71DF6F",
+"6@ c #66DB65",
+"7@ c #39B04A",
+"8@ c #11823A",
+"9@ c #026633",
+"0@ c #00522D",
+"a@ c #036E34",
+"b@ c #129E2E",
+"c@ c #25D826",
+"d@ c #22E221",
+"e@ c #1DE41D",
+"f@ c #19E919",
+"g@ c #15ED15",
+"h@ c #11F210",
+"i@ c #039626",
+"j@ c #008F2A",
+"k@ c #00A323",
+"l@ c #00A522",
+"m@ c #008530",
+"n@ c #00532D",
+"o@ c #0F7F3D",
+"p@ c #4BCE4E",
+"q@ c #49D547",
+"r@ c #41D040",
+"s@ c #3ED63B",
+"t@ c #33D133",
+"u@ c #23BF2E",
+"v@ c #17AF2C",
+"w@ c #12AE2B",
+"x@ c #11B826",
+"y@ c #17D71E",
+"z@ c #18EF15",
+"A@ c #12F211",
+"B@ c #05FC05",
+"C@ c #00B919",
+"D@ c #005C35",
+"E@ c #0F8C35",
+"F@ c #2AD52A",
+"G@ c #27DE25",
+"H@ c #21DE22",
+"I@ c #1EE41D",
+"J@ c #1BEC19",
+"K@ c #17F314",
+"L@ c #12F90F",
+"M@ c #0DFD0A",
+"N@ c #08FD06",
+"O@ c #03FD03",
+"P@ c #00CB12",
+"Q@ c #006C37",
+"R@ c #00562F",
+"S@ c #07912F",
+"T@ c #12E316",
+"U@ c #0DFC0A",
+"V@ c #09FA09",
+"W@ c #01FF01",
+"X@ c #00BE18",
+"Y@ c #006D37",
+"Z@ c #008030",
+"`@ c #00C814",
+" # c #00FA02",
+".# c #00DD0C",
+"+# c #009827",
+"@# c #006437",
+"## c #00852E",
+"$# c #00B11E",
+"%# c #00D111",
+"&# c #00E40A",
+"*# c #00EF06",
+"=# c #00E908",
+"-# c #00D80E",
+";# c #00BD18",
+"># c #009528",
+",# c #006D35",
+"'# c #004F2E",
+")# c #00492C",
+"!# c #006032",
+"~# c #006A32",
+"{# c #006D31",
+"]# c #006B31",
+"^# c #006533",
+"/# c #005631",
+" ",
+" ",
+" . + @ # $ % & * = ",
+" - ; > , ' ) ! ~ { ] ^ / ( ",
+" _ : < [ } | 1 2 3 4 5 6 7 8 9 ",
+" 0 a b c d e f g h i j k l m n o p ",
+" q r s t u v w x y z A B C D E F G H I ",
+" J K L M N O P Q R S T U V W X Y Z ` .G G G ..( ",
+" +.@.#.$.%.&.| *.=.-.;.>.,.'. ).!.~.G G G {. ",
+" ].^./.(._.:.<.[.}.|.1.2.3. 4.5.6.G 7.8. ",
+" 9.0.a.b.c.d.e.f.g.h.i.j.k. l.m.n.G o. ",
+" p.q.r.c.A s.t.u.v.G G G w.x. y.z.A.B. ",
+" C.D.E.A s.t.u.v.G G G G G F. G.H. ",
+" I.J.K.t.u.v.G G G G G L.M. N.O.P. ",
+" Q.R.S.u.v.G G G G T.U.= V.W.X.Y.Z.`. ",
+" +.+++G G G @+L.#+ $+%+&+*+=+=+-+;+ ",
+" >+,+'+G )+!+~+{+ ]+^+/+(+_+:+<+[+}+V. ",
+" N.|+1+2+3+ 4+5+6+7+8+9+0+a+b+c+d+e+ ",
+" f+g+h+ i+j+k+l+m+n+o+p+q+r+s+t+u+v+ ",
+" w+x+y+ z+A+B+C+D+E+F+G+H+I+J+K+L+M+ ",
+" N+O+P+Q+ L R+S+T+U+V+W+X+Y+Z+`+ @.@+@ ",
+" @@#@$@%@&@ *@=@-@;@v.G G G G G G >@,@ ",
+" '@)@!@~@{@]@ ^@/@(@_@s.:@<@[@}@G G |@1@ ",
+" 2@3@4@5@6@7@8@9@0@ a@b@c@d@e@f@g@h@u.i@j@k@l@m@n@ ",
+" o@p@q@r@s@t@u@v@w@x@y@z@A@;@`+B@F G C@D@ ",
+" E@F@G@H@I@J@K@L@M@N@O@[@G G G G P@Q@ ",
+" R@S@T@U@V@B@v.W@G G G G G G G X@Y@ ",
+" Z@`@ #G G G G G G G G .#+#@# ",
+" ( ##$#%#&#*#=#-#;#>#,#'# ",
+" )#!#~#{#]#^#/# ",
+" ",
+" "};
diff --git a/library/globalFunctions.cpp b/library/globalFunctions.cpp
index db7211ef..d91fa8b1 100644
--- a/library/globalFunctions.cpp
+++ b/library/globalFunctions.cpp
@@ -1,5 +1,5 @@
#include "globalFunctions.h"
-#include "../ui/resources.h"
+#include "resources.h"
inline
int globalFunctions::round(const double d)
@@ -89,6 +89,6 @@ double globalFunctions::wxStringToDouble(const wxString& number)
wxString& globalFunctions::includeNumberSeparator(wxString& number)
{
for (int i = number.size() - 3; i > 0; i-= 3)
- number.insert(i, GlobalResources::numberSeparator);
+ number.insert(i, GlobalResources::thousandsSeparator);
return number;
}
diff --git a/library/misc.cpp b/library/misc.cpp
new file mode 100644
index 00000000..2a5c0ec2
--- /dev/null
+++ b/library/misc.cpp
@@ -0,0 +1,138 @@
+#include "misc.h"
+#include <fstream>
+#include <wx/msgdlg.h>
+#include "resources.h"
+
+wxString exchangeEscapeChars(char* temp)
+{
+ wxString output(temp);
+ output.Replace("\\\\", "\\");
+ output.Replace("\\n", "\n");
+ output.Replace("\\t", "\t");
+ output.Replace("\"\"", """");
+ output.Replace("\\\"", "\"");
+ return output;
+}
+
+
+CustomLocale::CustomLocale() :
+ wxLocale(),
+ currentLanguage(wxLANGUAGE_ENGLISH)
+{}
+
+
+CustomLocale::~CustomLocale()
+{
+ //write language to file
+ ofstream output("lang.dat");
+ if (!output)
+ {
+ wxMessageBox(wxString(_("Could not write to ")) + "\"" + "lang.dat" + "\"", _("An exception occured!"), wxOK | wxICON_ERROR);
+ return;
+ }
+ output<<currentLanguage<<char(0);
+ output.close();
+}
+
+
+void CustomLocale::loadLanguageFromCfg() //retrieve language from config file: do NOT put into constructor since working directory has not been set!
+{
+ int language = wxLANGUAGE_ENGLISH;
+
+ //try to load language setting from file
+ ifstream input("lang.dat");
+ if (input)
+ {
+ char buffer[20];
+ input.getline(buffer, 20, char(0));
+ language = atoi(buffer);
+ input.close();
+ }
+ else
+ language = wxLocale::GetSystemLanguage();
+
+ wxLocale::Init(language, wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
+
+ loadLanguageFile(language);
+}
+
+
+void CustomLocale::loadLanguageFile(int language)
+{
+ currentLanguage = language;
+
+ wxString languageFile;
+ switch (language)
+ {
+ case wxLANGUAGE_GERMAN:
+ languageFile = "german.lng";
+ break;
+
+ default:
+ languageFile = "";
+ currentLanguage = wxLANGUAGE_ENGLISH;
+ }
+
+ //load language file into buffer
+ translationDB.clear();
+ char temp[100000];
+ if (!languageFile.IsEmpty())
+ {
+ ifstream langFile(languageFile.c_str());
+ if (langFile)
+ {
+ int rowNumber = 0;
+ TranslationLine currentLine;
+
+ //Delimiter:
+ //----------
+ //Linux: 0xa
+ //Mac: 0xd
+ //Win: 0xd 0xa
+#ifdef FFS_WIN
+ while (langFile.getline(temp, 100000))
+ {
+#elif defined FFS_LINUX
+ while (langFile.getline(temp, 100000, 0xd)) //specify delimiter explicitely
+ {
+ //strangely this approach does NOT work under windows :(
+ langFile.get(); //delimiter 0xd is completely ignored (and also not extracted)
+#else
+ assert (false);
+#endif
+ if (rowNumber%2 == 0)
+ currentLine.original = exchangeEscapeChars(temp);
+ else
+ {
+ currentLine.translation = exchangeEscapeChars(temp);
+ translationDB.insert(currentLine);
+ }
+ ++rowNumber;
+ }
+ langFile.close();
+ }
+ else
+ wxMessageBox(wxString(_("Could not read language file ")) + "\"" + languageFile + "\"", _("An exception occured!"), wxOK | wxICON_ERROR);
+ }
+ else
+ ; //if languageFile is empty language is defaulted to english
+
+ //these global variables need to be redetermined on language selection
+ GlobalResources::decimalPoint = _(".");
+ GlobalResources::thousandsSeparator = _(",");
+}
+
+
+const wxChar* CustomLocale::GetString(const wxChar* szOrigString, const wxChar* szDomain) const
+{
+ TranslationLine currentLine;
+ currentLine.original = szOrigString;
+
+ //look for translation in buffer table
+ Translation::iterator i;
+ if ((i = translationDB.find(currentLine)) != translationDB.end())
+ return (i->translation.c_str());
+ //fallback
+ return (szOrigString);
+}
+
diff --git a/library/misc.h b/library/misc.h
new file mode 100644
index 00000000..a8db4088
--- /dev/null
+++ b/library/misc.h
@@ -0,0 +1,52 @@
+#ifndef MISC_H_INCLUDED
+#define MISC_H_INCLUDED
+
+#include <wx/string.h>
+#include <set>
+#include <wx/intl.h>
+
+using namespace std;
+
+struct TranslationLine
+{
+ wxString original;
+ wxString translation;
+
+ bool operator>(const TranslationLine& b ) const
+ {
+ return (original > b.original);
+ }
+ bool operator<(const TranslationLine& b) const
+ {
+ return (original < b.original);
+ }
+ bool operator==(const TranslationLine& b) const
+ {
+ return (original == b.original);
+ }
+};
+typedef set<TranslationLine> Translation;
+
+
+class CustomLocale : public wxLocale
+{
+public:
+ CustomLocale();
+
+ ~CustomLocale();
+
+ void loadLanguageFromCfg();
+ void loadLanguageFile(int language);
+ int getLanguage()
+ {
+ return currentLanguage;
+ }
+
+ const wxChar* GetString(const wxChar* szOrigString, const wxChar* szDomain = NULL) const;
+
+private:
+ Translation translationDB;
+ int currentLanguage;
+};
+
+#endif // MISC_H_INCLUDED
diff --git a/library/multithreading.cpp b/library/multithreading.cpp
index c5f38605..099836de 100644
--- a/library/multithreading.cpp
+++ b/library/multithreading.cpp
@@ -34,6 +34,8 @@
*/
class WorkerThread : public wxThread
{
+ friend class UpdateWhileExecuting;
+
public:
WorkerThread(UpdateWhileExecuting* handler) :
readyToBeginProcessing(),
@@ -43,8 +45,10 @@ public:
threadHandler(handler)
{ }
+
~WorkerThread() {}
+
ExitCode Entry()
{
readyToBeginProcessing.Lock(); //this lock needs to be called IN the thread => calling it from constructor(Main thread) would be useless
@@ -71,7 +75,7 @@ public:
return 0;
}
-
+private:
wxMutex readyToBeginProcessing;
wxCondition beginProcessing;
@@ -80,8 +84,6 @@ public:
bool threadIsInitialized;
bool threadExitIsRequested;
-
-private:
UpdateWhileExecuting* threadHandler;
};
diff --git a/library/multithreading.h b/library/multithreading.h
index b8481a0f..36b37f2a 100644
--- a/library/multithreading.h
+++ b/library/multithreading.h
@@ -47,6 +47,7 @@ class UpdateWhileExecuting
public:
UpdateWhileExecuting();
+
virtual ~UpdateWhileExecuting();
void waitUntilReady();
diff --git a/library/resources.cpp b/library/resources.cpp
new file mode 100644
index 00000000..73e11575
--- /dev/null
+++ b/library/resources.cpp
@@ -0,0 +1,184 @@
+#include "resources.h"
+#include <wx/wfstream.h>
+#include <wx/zipstrm.h>
+#include <wx/image.h>
+#include <wx/icon.h>
+#include <stdexcept> //for std::runtime_error
+
+#ifdef FFS_WIN
+wxChar GlobalResources::fileNameSeparator = '\\';
+#elif defined FFS_LINUX
+wxChar GlobalResources::fileNameSeparator = '/';
+#else
+assert(false);
+#endif
+
+//these two global variables are language-dependent => cannot be set statically! See CustomLocale
+const wxChar* GlobalResources::decimalPoint = "";
+const wxChar* GlobalResources::thousandsSeparator = "";
+
+
+//command line parameters
+const wxChar* GlobalResources::paramCompare = "cmp";
+const wxChar* GlobalResources::paramCfg = "cfg";
+const wxChar* GlobalResources::paramInclude = "incl";
+const wxChar* GlobalResources::paramExclude = "excl";
+const wxChar* GlobalResources::paramContinueError = "continue";
+const wxChar* GlobalResources::paramRecycler = "recycler";
+const wxChar* GlobalResources::paramSilent = "silent";
+
+const wxChar* GlobalResources::valueSizeDate = "SIZEDATE";
+const wxChar* GlobalResources::valueContent = "CONTENT";
+
+
+map<wxString, wxBitmap*> GlobalResources::bitmapResource;
+
+wxBitmap* GlobalResources::bitmapLeftArrow = 0;
+wxBitmap* GlobalResources::bitmapRightArrow = 0;
+wxBitmap* GlobalResources::bitmapNoArrow = 0;
+wxBitmap* GlobalResources::bitmapStartSync = 0;
+wxBitmap* GlobalResources::bitmapStartSyncDis = 0;
+wxBitmap* GlobalResources::bitmapDelete = 0;
+wxBitmap* GlobalResources::bitmapEmail = 0;
+wxBitmap* GlobalResources::bitmapAbout = 0;
+wxBitmap* GlobalResources::bitmapWebsite = 0;
+wxBitmap* GlobalResources::bitmapExit = 0;
+wxBitmap* GlobalResources::bitmapSync = 0;
+wxBitmap* GlobalResources::bitmapCompare = 0;
+wxBitmap* GlobalResources::bitmapSyncDisabled = 0;
+wxBitmap* GlobalResources::bitmapSwap = 0;
+wxBitmap* GlobalResources::bitmapHelp = 0;
+wxBitmap* GlobalResources::bitmapLeftOnly = 0;
+wxBitmap* GlobalResources::bitmapLeftNewer = 0;
+wxBitmap* GlobalResources::bitmapDifferent = 0;
+wxBitmap* GlobalResources::bitmapRightNewer = 0;
+wxBitmap* GlobalResources::bitmapRightOnly = 0;
+wxBitmap* GlobalResources::bitmapLeftOnlyDeact = 0;
+wxBitmap* GlobalResources::bitmapLeftNewerDeact = 0;
+wxBitmap* GlobalResources::bitmapDifferentDeact = 0;
+wxBitmap* GlobalResources::bitmapRightNewerDeact = 0;
+wxBitmap* GlobalResources::bitmapRightOnlyDeact = 0;
+wxBitmap* GlobalResources::bitmapEqual = 0;
+wxBitmap* GlobalResources::bitmapEqualDeact = 0;
+wxBitmap* GlobalResources::bitmapInclude = 0;
+wxBitmap* GlobalResources::bitmapExclude = 0;
+wxBitmap* GlobalResources::bitmapFilterOn = 0;
+wxBitmap* GlobalResources::bitmapFilterOff = 0;
+wxBitmap* GlobalResources::bitmapWarning = 0;
+wxBitmap* GlobalResources::bitmapSmallUp = 0;
+wxBitmap* GlobalResources::bitmapSmallDown = 0;
+wxBitmap* GlobalResources::bitmapSave = 0;
+wxBitmap* GlobalResources::bitmapFFS = 0;
+wxBitmap* GlobalResources::bitmapDeleteFile = 0;
+wxBitmap* GlobalResources::bitmapGPL = 0;
+wxBitmap* GlobalResources::bitmapStatusPause = 0;
+wxBitmap* GlobalResources::bitmapStatusError = 0;
+wxBitmap* GlobalResources::bitmapStatusSuccess = 0;
+wxBitmap* GlobalResources::bitmapStatusWarning = 0;
+wxBitmap* GlobalResources::bitmapStatusScanning = 0;
+wxBitmap* GlobalResources::bitmapStatusComparing = 0;
+wxBitmap* GlobalResources::bitmapStatusSyncing = 0;
+wxBitmap* GlobalResources::bitmapLogo = 0;
+wxBitmap* GlobalResources::bitmapFinished = 0;
+wxBitmap* GlobalResources::bitmapStatusEdge = 0;
+
+wxAnimation* GlobalResources::animationMoney = 0;
+wxAnimation* GlobalResources::animationSync = 0;
+wxIcon* GlobalResources::programIcon = 0;
+
+
+void GlobalResources::loadResourceFiles()
+{
+ //map, allocate and initialize pictures
+ bitmapResource["left arrow.png"] = (bitmapLeftArrow = new wxBitmap(wxNullBitmap));
+ bitmapResource["right arrow.png"] = (bitmapRightArrow = new wxBitmap(wxNullBitmap));
+ bitmapResource["no arrow.png"] = (bitmapNoArrow = new wxBitmap(wxNullBitmap));
+ bitmapResource["start sync.png"] = (bitmapStartSync = new wxBitmap(wxNullBitmap));
+ bitmapResource["start sync dis.png"] = (bitmapStartSyncDis = new wxBitmap(wxNullBitmap));
+ bitmapResource["delete.png"] = (bitmapDelete = new wxBitmap(wxNullBitmap));
+ bitmapResource["email.png"] = (bitmapEmail = new wxBitmap(wxNullBitmap));
+ bitmapResource["about.png"] = (bitmapAbout = new wxBitmap(wxNullBitmap));
+ bitmapResource["website.png"] = (bitmapWebsite = new wxBitmap(wxNullBitmap));
+ bitmapResource["exit.png"] = (bitmapExit = new wxBitmap(wxNullBitmap));
+ bitmapResource["sync.png"] = (bitmapSync = new wxBitmap(wxNullBitmap));
+ bitmapResource["compare.png"] = (bitmapCompare = new wxBitmap(wxNullBitmap));
+ bitmapResource["sync disabled.png"] = (bitmapSyncDisabled = new wxBitmap(wxNullBitmap));
+ bitmapResource["swap.png"] = (bitmapSwap = new wxBitmap(wxNullBitmap));
+ bitmapResource["help.png"] = (bitmapHelp = new wxBitmap(wxNullBitmap));
+ bitmapResource["leftOnly.png"] = (bitmapLeftOnly = new wxBitmap(wxNullBitmap));
+ bitmapResource["leftNewer.png"] = (bitmapLeftNewer = new wxBitmap(wxNullBitmap));
+ bitmapResource["different.png"] = (bitmapDifferent = new wxBitmap(wxNullBitmap));
+ bitmapResource["rightNewer.png"] = (bitmapRightNewer = new wxBitmap(wxNullBitmap));
+ bitmapResource["rightOnly.png"] = (bitmapRightOnly = new wxBitmap(wxNullBitmap));
+ bitmapResource["leftOnlyDeact.png"] = (bitmapLeftOnlyDeact = new wxBitmap(wxNullBitmap));
+ bitmapResource["leftNewerDeact.png"] = (bitmapLeftNewerDeact = new wxBitmap(wxNullBitmap));
+ bitmapResource["differentDeact.png"] = (bitmapDifferentDeact = new wxBitmap(wxNullBitmap));
+ bitmapResource["rightNewerDeact.png"] = (bitmapRightNewerDeact = new wxBitmap(wxNullBitmap));
+ bitmapResource["rightOnlyDeact.png"] = (bitmapRightOnlyDeact = new wxBitmap(wxNullBitmap));
+ bitmapResource["equal.png"] = (bitmapEqual = new wxBitmap(wxNullBitmap));
+ bitmapResource["equalDeact.png"] = (bitmapEqualDeact = new wxBitmap(wxNullBitmap));
+ bitmapResource["include.png"] = (bitmapInclude = new wxBitmap(wxNullBitmap));
+ bitmapResource["exclude.png"] = (bitmapExclude = new wxBitmap(wxNullBitmap));
+ bitmapResource["filter active.png"] = (bitmapFilterOn = new wxBitmap(wxNullBitmap));
+ bitmapResource["filter not active.png"] = (bitmapFilterOff = new wxBitmap(wxNullBitmap));
+ bitmapResource["warning.png"] = (bitmapWarning = new wxBitmap(wxNullBitmap));
+ bitmapResource["small arrow up.png"] = (bitmapSmallUp = new wxBitmap(wxNullBitmap));
+ bitmapResource["small arrow down.png"] = (bitmapSmallDown = new wxBitmap(wxNullBitmap));
+ bitmapResource["save.png"] = (bitmapSave = new wxBitmap(wxNullBitmap));
+ bitmapResource["FFS.png"] = (bitmapFFS = new wxBitmap(wxNullBitmap));
+ bitmapResource["deleteFile.png"] = (bitmapDeleteFile = new wxBitmap(wxNullBitmap));
+ bitmapResource["gpl.png"] = (bitmapGPL = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusPause.png"] = (bitmapStatusPause = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusError.png"] = (bitmapStatusError = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusSuccess.png"] = (bitmapStatusSuccess = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusWarning.png"] = (bitmapStatusWarning = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusScanning.png"] = (bitmapStatusScanning = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusComparing.png"] = (bitmapStatusComparing = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusSyncing.png"] = (bitmapStatusSyncing = new wxBitmap(wxNullBitmap));
+ bitmapResource["logo.png"] = (bitmapLogo = new wxBitmap(wxNullBitmap));
+ bitmapResource["finished.png"] = (bitmapFinished = new wxBitmap(wxNullBitmap));
+ bitmapResource["statusEdge.png"] = (bitmapStatusEdge = new wxBitmap(wxNullBitmap));
+
+ wxFileInputStream input("Resources.dat");
+ if (!input.IsOk()) throw runtime_error(_("Unable to load Resources.dat!"));
+
+ wxZipInputStream resourceFile(input);
+
+ wxZipEntry* entry;
+ map<wxString, wxBitmap*>::iterator bmp;
+ while ((entry = resourceFile.GetNextEntry()))
+ {
+ wxString name = entry->GetName();
+
+ //just to be sure: search if entry is available in map
+ if ((bmp = bitmapResource.find(name)) != bitmapResource.end())
+ *(bmp->second) = wxBitmap(wxImage(resourceFile, wxBITMAP_TYPE_PNG));
+ }
+
+ //load all the other resource files
+ animationMoney = new wxAnimation(wxNullAnimation);
+ animationSync = new wxAnimation(wxNullAnimation);
+
+ animationMoney->LoadFile("Resources.a01");
+ animationSync->LoadFile("Resources.a02");
+
+#ifdef FFS_WIN
+ programIcon = new wxIcon("winIcon");
+#else
+#include "FreeFileSync.xpm"
+ programIcon = new wxIcon(FreeFileSync_xpm);
+#endif
+}
+
+
+void GlobalResources::unloadResourceFiles()
+{
+ //free bitmap resources
+ for (map<wxString, wxBitmap*>::iterator i = bitmapResource.begin(); i != bitmapResource.end(); ++i)
+ delete i->second;
+
+ //free other resources
+ delete animationMoney;
+ delete animationSync;
+ delete programIcon;
+}
diff --git a/library/resources.h b/library/resources.h
new file mode 100644
index 00000000..de70198f
--- /dev/null
+++ b/library/resources.h
@@ -0,0 +1,96 @@
+#ifndef RESOURCES_H_INCLUDED
+#define RESOURCES_H_INCLUDED
+
+#include <wx/bitmap.h>
+#include <wx/animate.h>
+#include <wx/string.h>
+#include <map>
+
+using namespace std;
+
+class GlobalResources
+{
+public:
+ static void loadResourceFiles();
+ static void unloadResourceFiles();
+
+ static wxChar fileNameSeparator;
+
+ //language dependent global variables: need to be initialized by CustomLocale on program startup and language switch
+ static const wxChar* decimalPoint;
+ static const wxChar* thousandsSeparator;
+
+ //command line parameters
+ static const wxChar* paramCompare;
+ static const wxChar* paramCfg;
+ static const wxChar* paramInclude;
+ static const wxChar* paramExclude;
+ static const wxChar* paramContinueError;
+ static const wxChar* paramRecycler;
+ static const wxChar* paramSilent;
+
+ static const wxChar* valueSizeDate;
+ static const wxChar* valueContent;
+
+ //image resource objects
+ static wxBitmap* bitmapLeftArrow;
+ static wxBitmap* bitmapRightArrow;
+ static wxBitmap* bitmapNoArrow;
+ static wxBitmap* bitmapStartSync;
+ static wxBitmap* bitmapStartSyncDis;
+ static wxBitmap* bitmapDelete;
+ static wxBitmap* bitmapEmail;
+ static wxBitmap* bitmapAbout;
+ static wxBitmap* bitmapWebsite;
+ static wxBitmap* bitmapExit;
+ static wxBitmap* bitmapSync;
+ static wxBitmap* bitmapCompare;
+ static wxBitmap* bitmapSyncDisabled;
+ static wxBitmap* bitmapSwap;
+ static wxBitmap* bitmapHelp;
+ static wxBitmap* bitmapLeftOnly;
+ static wxBitmap* bitmapLeftNewer;
+ static wxBitmap* bitmapDifferent;
+ static wxBitmap* bitmapRightNewer;
+ static wxBitmap* bitmapRightOnly;
+ static wxBitmap* bitmapLeftOnlyDeact;
+ static wxBitmap* bitmapLeftNewerDeact;
+ static wxBitmap* bitmapDifferentDeact;
+ static wxBitmap* bitmapRightNewerDeact;
+ static wxBitmap* bitmapRightOnlyDeact;
+ static wxBitmap* bitmapEqual;
+ static wxBitmap* bitmapEqualDeact;
+ static wxBitmap* bitmapInclude;
+ static wxBitmap* bitmapExclude;
+ static wxBitmap* bitmapFilterOn;
+ static wxBitmap* bitmapFilterOff;
+ static wxBitmap* bitmapWarning;
+ static wxBitmap* bitmapSmallUp;
+ static wxBitmap* bitmapSmallDown;
+ static wxBitmap* bitmapSave;
+ static wxBitmap* bitmapFFS;
+ static wxBitmap* bitmapDeleteFile;
+ static wxBitmap* bitmapGPL;
+ static wxBitmap* bitmapStatusPause;
+ static wxBitmap* bitmapStatusError;
+ static wxBitmap* bitmapStatusSuccess;
+ static wxBitmap* bitmapStatusWarning;
+ static wxBitmap* bitmapStatusScanning;
+ static wxBitmap* bitmapStatusComparing;
+ static wxBitmap* bitmapStatusSyncing;
+ static wxBitmap* bitmapLogo;
+ static wxBitmap* bitmapFinished;
+ static wxBitmap* bitmapStatusEdge;
+
+ static wxAnimation* animationMoney;
+ static wxAnimation* animationSync;
+
+ static wxIcon* programIcon;
+
+private:
+ //resource mapping
+ static map<wxString, wxBitmap*> bitmapResource;
+};
+
+
+#endif // RESOURCES_H_INCLUDED
bgstack15