Patch level : 4.0

Files correlati     : diction.exe
Ricompilazione Demo : [ ]
Commento            :
Supportati tutti i tag xml generati dalla manutenzione dizionari


git-svn-id: svn://10.65.10.50/trunk@14223 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2006-08-01 12:38:52 +00:00
parent 7eea205bad
commit fef078f901
4 changed files with 103 additions and 42 deletions

View File

@ -126,11 +126,11 @@ void TTaskBarIcon::Init()
wxInitAllImageHandlers();
wxImage img(strIcon);
img.Rescale(32,32);
wxBitmap bmp(img);
const wxBitmap bmp(img);
icon.CopyFromBitmap(bmp);
}
else
icon.LoadFile("mondrian", wxBITMAP_TYPE_ICO_RESOURCE);
icon.LoadFile("soap", wxBITMAP_TYPE_ICO_RESOURCE);
SetIcon(icon, a.GetAppName());
}

View File

@ -61,7 +61,16 @@ wxString xml2txt(const wxString& str)
// TDictionary
///////////////////////////////////////////////////////////
WX_DECLARE_STRING_HASH_MAP( wxString, TStringHashTable );
struct TEntry : public wxObject
{
wxString m_eng, m_src;
int m_max;
TEntry& operator=(const TEntry& e)
{ m_eng = e.m_eng; m_src = e.m_src; m_max = e.m_max; return *this; }
};
WX_DECLARE_STRING_HASH_MAP( TEntry, TStringHashTable );
class TDictionary : public TStringHashTable
{
@ -71,7 +80,7 @@ class TDictionary : public TStringHashTable
protected:
void ParseSpaces(const wxString& str, wxString& prefix,
wxString& body, wxString& postfix) const;
void AddEntry(const wxString& ita, const wxString& eng);
void AddEntry(const wxString& ita, const wxString& eng, const wxString& src, int max);
static bool FillCallback(TXmlItem& item, long jolly);
bool Load();
@ -86,6 +95,7 @@ public:
wxString OriginalEntry(size_t i);
wxString TranslatedEntry(size_t i);
const TEntry& GetEntry(size_t i);
void UpdateEntry(size_t i, const wxString& strValue);
@ -113,9 +123,20 @@ void TDictionary::Save()
WriteXmlString(outf, ita);
outf << "</ita>" << eol;
outf << " <eng>";
const wxString& eng = operator[](ita);
WriteXmlString(outf, eng);
const TEntry& e = operator[](ita);
WriteXmlString(outf, e.m_eng);
outf << "</eng>" << eol;
if (!e.m_src.IsEmpty())
{
outf << " <src>";
WriteXmlString(outf, e.m_src);
outf << "</src>" << eol;
}
if (e.m_max > 0)
{
wxString str; str.Printf("%d", e.m_max);
outf << " <max>" << str << "</max>" << eol;
}
outf << " </entry>" << eol;
}
outf << "</dictionary>" << eol;
@ -128,9 +149,14 @@ void TDictionary::SaveIfNeeded()
Save();
}
void TDictionary::AddEntry(const wxString& ita, const wxString& eng)
void TDictionary::AddEntry(const wxString& ita, const wxString& eng, const wxString& src, int max)
{
operator[](ita) = eng;
TEntry e;
e.m_eng = eng;
e.m_src = src;
e.m_max = max;
operator[](ita) = e;
m_sorted.Add(ita);
m_bDirty = true;
}
@ -140,7 +166,8 @@ void TDictionary::UpdateEntry(size_t nEntry, const wxString& strValue)
if (nEntry >= 0 && nEntry < m_sorted.GetCount())
{
const wxString& ita = m_sorted[nEntry];
operator[](ita) = strValue;
TEntry& e = operator[](ita);
e.m_eng = strValue;
Save();
}
}
@ -150,10 +177,18 @@ wxString TDictionary::OriginalEntry(size_t i)
return m_sorted[i];
}
wxString TDictionary::TranslatedEntry(size_t i)
const TEntry& TDictionary::GetEntry(size_t i)
{
const wxString& ita = m_sorted[i];
return operator[](ita);
const TEntry& e = operator[](ita);
return e;
}
wxString TDictionary::TranslatedEntry(size_t i)
{
const TEntry& e = GetEntry(i);
return e.m_eng;
}
wxSocketClient& operator<<(wxSocketClient& sock, const wxChar* str)
@ -169,11 +204,17 @@ bool TDictionary::Load()
m_sorted.Clear();
wxFileInputStream scan(GetFileName());
wxString ita, line;
wxString ita, eng, src, line;
int max;
while (!scan.Eof())
{
scan >> line;
line.Trim(false);
if (line.StartsWith("<entry>"))
{
ita = eng = src = "";
max = 0;
} else
if (line.StartsWith("<ita>"))
{
const int eoi = line.Find("</ita>");
@ -182,8 +223,21 @@ bool TDictionary::Load()
if (line.StartsWith("<eng>") && !ita.IsEmpty())
{
const int eoe = line.Find("</eng>");
const wxString eng = xml2txt(line.Mid(5, eoe-5));
AddEntry(ita, eng);
eng = xml2txt(line.Mid(5, eoe-5));
} else
if (line.StartsWith("<max>"))
{
const int eom = line.Find("</max>");
max = atoi(line.Mid(5, eom-5));
} else
if (line.StartsWith("<src>"))
{
const int eos = line.Find("</src>");
src = xml2txt(line.Mid(5, eos-5));
} else
if (line.StartsWith("</entry>"))
{
AddEntry(ita, eng, src, max);
}
}
m_bDirty = false;
@ -226,17 +280,17 @@ wxString TDictionary::Translate(const wxString& ita)
const TStringHashTable::iterator i = find(body);
if (i != end())
{
const wxString& eng = i->second;
if (eng != "???")
const TEntry& e = i->second;
if (e.m_eng != "???")
{
body = prefix;
body += eng;
body += e.m_eng;
body += postfix;
return body;
}
}
else
AddEntry(ita, "???");
AddEntry(ita, "???", "", 0);
return ita;
}
@ -279,7 +333,7 @@ public:
bool IsCgiName(wxString strFilename) const;
void Add2Columns(TXmlItem& table, const wxChar* href0, const wxChar* td0, const wxChar* td1) const;
void AddEditableRow(TXmlItem& table, const wxChar* txt1, const wxChar* txt2) const;
void AddEditableRow(TXmlItem& table, const wxChar* txt1, const wxChar* txt2, const wxChar* txt3, const wxChar* txt4) const;
void GenerateIndex(TXmlItem& body);
void GenerateFile(wxString& strFilename);
@ -372,7 +426,7 @@ void TDictionaryServer::GenerateIndex(TXmlItem& body)
body.AddChild("br");
}
void TDictionaryServer::AddEditableRow(TXmlItem& table, const wxChar* txt1, const wxChar* txt2) const
void TDictionaryServer::AddEditableRow(TXmlItem& table, const wxChar* txt1, const wxChar* txt2, const wxChar* txt3, const wxChar* txt4) const
{
TXmlItem& tr = table.AddChild("tr");
TXmlItem& td0 = tr.AddChild("td");
@ -381,6 +435,8 @@ void TDictionaryServer::AddEditableRow(TXmlItem& table, const wxChar* txt1, cons
AddLinkButton(td0, "Edit", cgi).SetAttr("width", "100%");
tr.AddChild("td") << txt1;
tr.AddChild("td") << txt2;
tr.AddChild("td") << txt3;
tr.AddChild("td") << txt4;
}
void TDictionaryServer::GenerateFile(wxString& strFilename)
@ -426,12 +482,22 @@ void TDictionaryServer::GenerateFile(wxString& strFilename)
th1 << "Original text";
TXmlItem& th2 = table_th.AddChild("th").SetAttr("width", "47%");
th2 << "Translated text";
TXmlItem& th3 = table_th.AddChild("th");
th3 << "Sources";
TXmlItem& th4 = table_th.AddChild("th");
th4 << "Max. Size";
for (size_t i = 0; i < m_DevotoOli.size(); i++)
{
const wxString& orig = m_DevotoOli.OriginalEntry(i);
if (toupper(orig[0]) == cFilter)
AddEditableRow(table, orig, m_DevotoOli.TranslatedEntry(i));
{
const TEntry& e = m_DevotoOli.GetEntry(i);
wxString str;
if (e.m_max > 0)
str.Printf("%d", e.m_max);
AddEditableRow(table, orig, e.m_eng, e.m_src, str);
}
}
strFilename = GetTempFilename();
@ -478,20 +544,30 @@ void TDictionaryServer::CallCgi(wxString& strFileName)
if (strName == "EditEntry")
{
const size_t i = FindIndex(strArgs);
const TEntry& e = m_DevotoOli.GetEntry(i);
body.AddChild("h2") << "Edit Entry " << strArgs;
TXmlItem& ee = body.AddChild("h2");
ee << "Edit Entry " << strArgs;
TXmlItem& form = body.AddChild("form");
form.SetAttr("method", "post");
form.SetAttr("action", "UpdateEntry.cgi");
form.AddChild("h3") << "Original text:";
TXmlItem& ot = form.AddChild("h3");
ot << "Original text";
if (!e.m_src.IsEmpty())
ot << " (" << e.m_src << ")";
TXmlItem& ita = form.AddChild("textarea");
ita.SetAttr("cols", "80"); ita.SetAttr("rows", "4");
ita << m_DevotoOli.OriginalEntry(i);
form.AddChild("br");
form.AddChild("h3") << "Translated text:";
TXmlItem& tt = form.AddChild("h3");
tt << "Translated text";
if (e.m_max > 0)
tt << wxString::Format(" (Max. %d chars)", e.m_max);
TXmlItem& ent = form.AddChild("input");
ent.SetAttr("type", "hidden"); ent.SetAttr("name", "Entry");
@ -500,7 +576,7 @@ void TDictionaryServer::CallCgi(wxString& strFileName)
TXmlItem& eng = form.AddChild("textarea");
eng.SetAttr("name", "Trans");
eng.SetAttr("cols", "80"); eng.SetAttr("rows", "4");
eng << m_DevotoOli.TranslatedEntry(i);
eng << e.m_eng;
form.AddChild("br");
form.AddChild("br");

View File

@ -239,8 +239,6 @@ wxString decode(const char* data)
#define USERADR 26952
#define AGAADR 26953
#define PRASSIADR 26954
#define PROCOMADR 26955
#define REFKEY (unsigned char*)"CAMPOKEY"
#define VERKEY (unsigned char*)"ìpÙˆ¬cê<"
@ -436,18 +434,6 @@ bool TDongle::hardlock_login(bool test_all_keys)
HL_LOGOUT();
if (HL_LOGIN(AGAADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK)
_type = _aga_dongle;
else
{
HL_LOGOUT();
if (HL_LOGIN(PRASSIADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK)
_type = _prassi_dongle;
else
{
HL_LOGOUT();
if (HL_LOGIN(PROCOMADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK)
_type = _procom_dongle;
}
}
}
HL_LOGOUT();
ok = HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK;

View File

@ -1,3 +1,2 @@
mondrian ICON "soap.ico"
#include "../../wx263/include/wx/msw/wx.rc"
soap ICON "soap.ico"
#include "wx/msw/wx.rc"