MeOS version 3.5.785.

Use AGPL instead of GPL
This commit is contained in:
erikmelin 2017-08-30 13:31:32 +02:00
parent bb75f47626
commit a13eef041a
182 changed files with 23561 additions and 18356 deletions

145
LICENSE
View File

@ -1,5 +1,5 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
@ -7,17 +7,15 @@
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
@ -72,7 +60,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@ -631,44 +629,33 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -31,10 +31,10 @@
#include "Localizer.h"
#include "gdiconstants.h"
double getLocalScale(const string &fontName, string &faceName);
string getMeosCompectVersion();
double getLocalScale(const wstring &fontName, wstring &faceName);
wstring getMeosCompectVersion();
static void generateStyles(ostream &fout, bool withTbl, const list<TextInfo> &TL,
static void generateStyles(const gdioutput &gdi, ostream &fout, bool withTbl, const list<TextInfo> &TL,
map< pair<gdiFonts, string>, pair<string, string> > &styles) {
fout << "<style type=\"text/css\">\n";
fout << "body {background-color: rgb(250,250,255)}\n";
@ -59,7 +59,7 @@ static void generateStyles(ostream &fout, bool withTbl, const list<TextInfo> &TL
if (!it->font.empty() || (font == italicMediumPlus)
|| (font == fontMediumPlus)) {
if (styles.find(make_pair(font, it->font)) != styles.end()) {
if (styles.find(make_pair(font, gdi.narrow(it->font))) != styles.end()) {
++it;
continue;
}
@ -92,20 +92,20 @@ static void generateStyles(ostream &fout, bool withTbl, const list<TextInfo> &TL
break;
}
string faceName;
wstring faceName;
double scale = 1.0;
if (it->font.empty()) {
faceName = "arial,sans-serif";
faceName = L"arial,sans-serif";
}
else
scale = getLocalScale(it->font, faceName);
fout << element << "." << style
<< "{font-family:" << faceName << ";font-size:"
<< "{font-family:" << gdi.narrow(faceName) << ";font-size:"
<< itos(int(floor(scale * baseSize + 0.5)))
<< "px;font-weight:normal;white-space:nowrap}\n";
styles[make_pair(font, it->font)] = make_pair(element, style);
styles[make_pair(font, gdi.narrow(it->font))] = make_pair(element, style);
}
++it;
}
@ -187,7 +187,7 @@ static void getStyle(const map< pair<gdiFonts, string>, pair<string, string> > &
}
}
bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshTimeOut) const
bool gdioutput::writeHTML(const wstring &file, const wstring &title, int refreshTimeOut) const
{
ofstream fout(file.c_str());
@ -207,7 +207,7 @@ bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshT
fout << "<title>" << toUTF8(title) << "</title>\n";
map< pair<gdiFonts, string>, pair<string, string> > styles;
generateStyles(fout, false, TL, styles);
generateStyles(*this, fout, false, TL, styles);
fout << "</head>\n";
@ -246,7 +246,7 @@ bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshT
xp + "px;top:" + yp + "px\"";
}
string starttag, endtag;
getStyle(styles, it->getGdiFont(), it->font, estyle, starttag, endtag);
getStyle(styles, it->getGdiFont(), narrow(it->font), estyle, starttag, endtag);
if (!it->text.empty())
fout << starttag << toUTF8(encodeXML(it->text)) << endtag << endl;
@ -264,8 +264,8 @@ bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshT
char bf1[256];
char bf2[256];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
GetTimeFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
//fout << "Skapad av <i>MeOS</i>: " << bf1 << " "<< bf2 << "\n";
fout << toUTF8(lang.tl("Skapad av ")) + "<a href=\"http://www.melin.nu/meos\" target=\"_blank\"><i>MeOS</i></a>: " << bf1 << " "<< bf2 << "\n";
fout << "</p>\n";
@ -276,10 +276,10 @@ bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshT
return false;
}
string html_table_code(const string &in)
wstring html_table_code(const wstring &in)
{
if (in.size()==0)
return "&nbsp;";
return L"&nbsp;";
else {
return encodeXML(in);
}
@ -292,7 +292,7 @@ bool sortTL_X(const TextInfo *a, const TextInfo *b)
bool gdioutput::writeTableHTML(const wstring &file,
const string &title, int refreshTimeOut) const
const wstring &title, int refreshTimeOut) const
{
ofstream fout(file.c_str());
@ -303,7 +303,7 @@ bool gdioutput::writeTableHTML(const wstring &file,
}
bool gdioutput::writeTableHTML(ostream &fout,
const string &title,
const wstring &title,
bool simpleFormat,
int refreshTimeOut) const {
@ -317,7 +317,7 @@ bool gdioutput::writeTableHTML(ostream &fout,
fout << "<title>" << toUTF8(title) << "</title>\n";
map< pair<gdiFonts, string>, pair<string, string> > styles;
generateStyles(fout, true, TL, styles);
generateStyles(*this, fout, true, TL, styles);
fout << "</head>\n";
@ -332,16 +332,15 @@ bool gdioutput::writeTableHTML(ostream &fout,
++it;
}
map<int, int>::iterator mit=tableCoordinates.begin();
int k=0;
while (mit!=tableCoordinates.end()) {
mit->second=k++;
int kr = 0;
map<int, int>::iterator mit = tableCoordinates.begin();
while (mit != tableCoordinates.end()) {
mit->second = kr++;
++mit;
}
tableCoordinates[MaxX]=k;
tableCoordinates[MaxX] = kr;
vector<bool> sizeSet(k+1, false);
vector<bool> sizeSet(kr + 1, false);
fout << "<table cellspacing=\"0\" border=\"0\">\n";
@ -492,7 +491,7 @@ bool gdioutput::writeTableHTML(ostream &fout,
gdiFonts font = row[k]->getGdiFont();
string starttag, endtag;
getStyle(styles, font, row[k]->font, "", starttag, endtag);
getStyle(styles, font, narrow(row[k]->font), "", starttag, endtag);
fout << starttag << toUTF8(html_table_code(row[k]->text)) << endtag << "</td>" << endl;
@ -508,11 +507,11 @@ bool gdioutput::writeTableHTML(ostream &fout,
fout << "<br><p>";
char bf1[256];
char bf2[256];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
string meos = getMeosCompectVersion();
GetTimeFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
wstring meos = getMeosCompectVersion();
fout << toUTF8(lang.tl("Skapad av ")) + "<a href=\"http://www.melin.nu/meos\" target=\"_blank\"><i>MeOS "
<< meos << "</i></a>: " << bf1 << " "<< bf2 << "\n";
<< toUTF8(meos) << "</i></a>: " << bf1 << " "<< bf2 << "\n";
fout << "</p><br>\n";
}
fout << "</body>\n";

View File

@ -31,45 +31,45 @@
MeOSFeatures::MeOSFeatures(void)
{
addHead("General");
add(DrawStartList, "SL", "Prepare start lists");
add(Bib, "BB", "Bibs");
add(Clubs, "CL", "Clubs");
add(EditClub, "CC", "Edit Clubs").require(Clubs);
add(DrawStartList, L"SL", "Prepare start lists");
add(Bib, L"BB", "Bibs");
add(Clubs, L"CL", "Clubs");
add(EditClub, L"CC", "Edit Clubs").require(Clubs);
add(InForest, "RF", "Track runners in forest");
add(Network, "NW", "Several MeOS Clients in a network");
add(InForest, L"RF", "Track runners in forest");
add(Network, L"NW", "Several MeOS Clients in a network");
addHead("MeOS Features");
add(Speaker, "SP", "Använd speakerstöd");
add(SeveralStages, "ST", "Several stages");
add(Economy, "EC", "Economy and fees").require(EditClub).require(Clubs);
add(Vacancy, "VA", "Vacancies and entry cancellations").require(DrawStartList);
add(TimeAdjust, "TA", "Manual time penalties and adjustments");
add(RunnerDb, "RD", "Club and runner database").require(Clubs);
add(Speaker, L"SP", "Använd speakerstöd");
add(SeveralStages, L"ST", "Several stages");
add(Economy, L"EC", "Economy and fees").require(EditClub).require(Clubs);
add(Vacancy, L"VA", "Vacancies and entry cancellations").require(DrawStartList);
add(TimeAdjust, L"TA", "Manual time penalties and adjustments");
add(RunnerDb, L"RD", "Club and runner database").require(Clubs);
addHead("Teams and forking");
add(ForkedIndividual, "FO", "Forked individual courses");
add(Patrol, "PT", "Patrols");
add(Relay, "RL", "Relays");
add(MultipleRaces, "MR", "Several races for a runner").require(Relay);
add(ForkedIndividual, L"FO", "Forked individual courses");
add(Patrol, L"PT", "Patrols");
add(Relay, L"RL", "Relays");
add(MultipleRaces, L"MR", "Several races for a runner").require(Relay);
addHead("Rogaining");
add(Rogaining, "RO", "Rogaining");
add(PointAdjust, "PA", "Manual point reductions and adjustments").require(Rogaining);
add(Rogaining, L"RO", "Rogaining");
add(PointAdjust, L"PA", "Manual point reductions and adjustments").require(Rogaining);
}
MeOSFeatures::FeatureDescriptor &MeOSFeatures::add(Feature feat, const char *code, const char *descr) {
MeOSFeatures::FeatureDescriptor &MeOSFeatures::add(Feature feat, const wchar_t *code, const char *descr) {
assert(codeToIx.count(code) == 0);
assert(featureToIx.count(feat) == 0);
featureToIx[feat] = desc.size();
string codeS = code;
wstring codeS = code;
codeToIx[codeS] = desc.size();
desc.push_back(FeatureDescriptor(feat, codeS, descr));
return desc.back();
}
MeOSFeatures::FeatureDescriptor &MeOSFeatures::addHead(const char *descr) {
desc.push_back(FeatureDescriptor(_Head, "-", descr));
desc.push_back(FeatureDescriptor(_Head, L"-", descr));
return desc.back();
}
@ -86,7 +86,7 @@ const string &MeOSFeatures::getHead(int featureIx) const {
}
MeOSFeatures::FeatureDescriptor::FeatureDescriptor(Feature featIn,
string codeIn,
wstring codeIn,
string descIn) :
feat(featIn), code(codeIn), desc(descIn)
{
@ -146,7 +146,7 @@ const string &MeOSFeatures::getDescription(Feature f) const {
return desc[getIndex(f)].desc;
}
const string &MeOSFeatures::getCode(Feature f) const {
const wstring &MeOSFeatures::getCode(Feature f) const {
return desc[getIndex(f)].code;
}
@ -157,32 +157,32 @@ int MeOSFeatures::getIndex(Feature f) const {
return res->second;
}
string MeOSFeatures::serialize() const {
wstring MeOSFeatures::serialize() const {
if (features.empty())
return "NONE";
return L"NONE";
string st;
wstring st;
for (set<Feature>::const_iterator it = features.begin(); it != features.end(); ++it) {
if (!st.empty())
st += "+";
st += L"+";
st += getCode(*it);
}
return st;
}
void MeOSFeatures::deserialize(const string &input, oEvent &oe) {
void MeOSFeatures::deserialize(const wstring &input, oEvent &oe) {
features.clear();
if (input == "NONE")
if (input == L"NONE")
return;
else if (input.empty()) {
loadDefaults(oe);
}
vector<string> ff;
split(input, "+", ff);
vector<wstring> ff;
split(input, L"+", ff);
for (size_t k = 0; k < ff.size(); k++) {
map<string, int>::iterator res = codeToIx.find(ff[k]);
map<wstring, int>::iterator res = codeToIx.find(ff[k]);
if (res != codeToIx.end())
features.insert(desc[res->second].feat);
}

View File

@ -55,20 +55,20 @@ public:
private:
struct FeatureDescriptor {
Feature feat;
string code;
wstring code;
string desc;
set<Feature> dependsOn;
FeatureDescriptor &require(Feature f) {
dependsOn.insert(f);
return *this;
}
FeatureDescriptor(Feature feat, string code, string desc);
FeatureDescriptor(Feature feat, wstring code, string desc);
};
vector<FeatureDescriptor> desc;
map<Feature, int> featureToIx;
map<string, int> codeToIx;
FeatureDescriptor &add(Feature feat, const char *code, const char *desc);
map<wstring, int> codeToIx;
FeatureDescriptor &add(Feature feat, const wchar_t *code, const char *desc);
FeatureDescriptor &addHead(const char *desc);
set<Feature> features;
@ -95,9 +95,9 @@ public:
bool isHead(int featureIx) const;
const string &getHead(int featureIx) const;
const string &getDescription(Feature f) const;
const string &getCode(Feature f) const;
const wstring &getCode(Feature f) const;
string serialize() const;
void deserialize(const string &input, oEvent &oe);
wstring serialize() const;
void deserialize(const wstring &input, oEvent &oe);
};

View File

@ -61,13 +61,13 @@ struct PageInfo {
bool invertHeightY,
vector<RenderedPage> &pages);
string pageInfo(const RenderedPage &page) const;
wstring pageInfo(const RenderedPage &page) const;
};
/** A rendered page ready to print. */
struct RenderedPage {
int nPage; // This page number
string info;
wstring info;
vector<PrintTextInfo> text;
vector<RectangleInfo> rectangles;
__int64 checkSum;
@ -84,8 +84,8 @@ struct PrinterObject {
void freePrinter();
string Device;
string Driver;
wstring Device;
wstring Driver;
DEVMODE DevMode;
set<__int64> printedPages;
int nPagesPrinted;

View File

@ -39,6 +39,9 @@
#include "oEvent.h"
extern gdioutput *gdi_main;
RunnerDB::RunnerDB(oEvent *oe_): oe(oe_)
{
loadedFromServer = false;
@ -58,21 +61,86 @@ RunnerDBEntry::RunnerDBEntry()
memset(this, 0, sizeof(RunnerDBEntry));
}
RunnerWDBEntry::RunnerWDBEntry()
{
name[0] = 0;
}
void RunnerWDBEntry::initName() const {
if (name[0] == 0) {
memset(name, 0, sizeof(wchar_t) * baseNameLength);
const RunnerDBEntry &db = dbe();
if (db.isUTF()) {
int len = strlen(db.name);
len = min(len+1, baseNameLengthUTF-1);
int wlen = MultiByteToWideChar(CP_UTF8, 0, db.name, len, name, baseNameLength);
if (wlen == 0)
wlen = baseNameLength;
name[wlen-1] = 0;
}
else {
const wstring &wn = gdi_main->recodeToWide(db.name);
wcsncpy_s(name, wn.c_str(), baseNameLength-1);
}
}
}
void RunnerWDBEntry::recode(const RunnerDBEntry &dest) const {
initName();
RunnerDBEntry &d = const_cast<RunnerDBEntry &>(dest);
const int blen = min<int>(wcslen(name)+1, baseNameLength);
int res = WideCharToMultiByte(CP_UTF8, 0, name, blen, d.name, baseNameLengthUTF-1, 0, 0);
assert(res < baseNameLengthUTF);
if (res == 0 && blen > 0)
res = baseNameLengthUTF-1;
d.name[res] = 0;
d.setUTF();
}
RunnerDBEntryV1::RunnerDBEntryV1()
{
memset(this, 0, sizeof(RunnerDBEntryV1));
}
void RunnerDBEntry::getName(string &n) const
RunnerDBEntryV2::RunnerDBEntryV2()
{
memset(this, 0, sizeof(RunnerDBEntryV2));
}
void RunnerWDBEntry::getName(wstring &n) const
{
initName();
n=name;
}
void RunnerDBEntry::setName(const char *n)
void RunnerWDBEntry::setName(const wchar_t *n)
{
memcpy(name, n, min<int>(strlen(n)+1, baseNameLength));
const int blen = min<int>(wcslen(n)+1, baseNameLength);
memset(name, 0, sizeof(wchar_t) * baseNameLength);
memcpy(name, n, sizeof(wchar_t) * blen);
name[baseNameLength-1]=0;
RunnerDBEntry &d = dbe();
int res = WideCharToMultiByte(CP_UTF8, 0, name, blen, d.name, baseNameLengthUTF-1, 0, 0);
d.setUTF();
assert(res < baseNameLengthUTF);
if (res == 0 && blen > 0) {
res = baseNameLengthUTF-1;
d.name[res] = 0;
name[0] = 0;
initName();
}
d.name[res] = 0;
}
void RunnerWDBEntry::setNameUTF(const char *n)
{
const int blen = min<int>(strlen(n)+1, baseNameLength);
RunnerDBEntry &d = dbe();
memcpy(d.name, n, blen);
d.name[baseNameLength-1]=0;
d.setUTF();
name[0] = 0;
}
string RunnerDBEntry::getNationality() const
@ -95,46 +163,99 @@ string RunnerDBEntry::getSex() const
n[0] = sex;
return n;
}
string RunnerDBEntry::getGivenName() const
wstring RunnerWDBEntry::getNationality() const
{
const RunnerDBEntry &d = dbe();
if (d.national[0] < 30)
return _EmptyWString;
wstring n(L" ");
n[0] = d.national[0];
n[1] = d.national[1];
n[2] = d.national[2];
return n;
}
wstring RunnerWDBEntry::getSex() const
{
if (dbe().sex == 0)
return _EmptyWString;
wstring n(L"W");
n[0] = dbe().sex;
return n;
}
wstring RunnerWDBEntry::getGivenName() const
{
initName();
return ::getGivenName(name);
}
string RunnerDBEntry::getFamilyName() const
wstring RunnerWDBEntry::getFamilyName() const
{
initName();
return ::getFamilyName(name);
}
__int64 RunnerDBEntry::getExtId() const
__int64 RunnerWDBEntry::getExtId() const
{
return extId;
return dbe().extId;
}
void RunnerDBEntry::setExtId(__int64 id)
void RunnerWDBEntry::setExtId(__int64 id)
{
extId = id;
dbe().extId = id;
}
void RunnerDBEntry::init(const RunnerDBEntryV1 &dbe)
void RunnerDBEntryV2::init(const RunnerDBEntryV1 &dbe)
{
memcpy(this, &dbe, sizeof(RunnerDBEntryV1));
extId = 0;
}
RunnerDBEntry *RunnerDB::addRunner(const char *name,
__int64 extId,
int club, int card)
void RunnerDBEntry::init(const RunnerDBEntryV2 &dbe)
{
rdb.push_back(RunnerDBEntry());
RunnerDBEntry &e=rdb.back();
e.cardNo = card;
e.clubNo = club;
e.setName(name);
e.extId = extId;
memcpy(name, dbe.name, 32);
if (!check(e) ) {
cardNo = dbe.cardNo;
clubNo = dbe.clubNo;
national[0] = dbe.national[0];
national[1] = dbe.national[1];
national[2] = dbe.national[2];
sex = dbe.sex;
birthYear = dbe.birthYear;
reserved = dbe.reserved;
extId = dbe.extId;
}
void RunnerWDBEntry::init(RunnerDB *p, size_t ixin) {
owner = p;
ix = ixin;
}
RunnerWDBEntry *RunnerDB::addRunner(const wchar_t *name,
__int64 extId,
int club, int card)
{
assert(rdb.size() == rwdb.size());
rdb.push_back(RunnerDBEntry());
rwdb.push_back(RunnerWDBEntry());
rwdb.back().init(this, rdb.size()-1);
RunnerWDBEntry &e=rwdb.back();
RunnerDBEntry &en=rdb.back();
en.cardNo = card;
en.clubNo = club;
e.setName(name);
en.extId = extId;
if (!check(en) ) {
rdb.pop_back();
rwdb.pop_back();
return 0;
} else {
if (card>0)
@ -142,20 +263,55 @@ RunnerDBEntry *RunnerDB::addRunner(const char *name,
if (!idhash.empty())
idhash[extId] = rdb.size()-1;
if (!nhash.empty())
nhash.insert(pair<string, int>(canonizeName(e.name), rdb.size()-1));
nhash.insert(pair<wstring, int>(canonizeName(e.name), rdb.size()-1));
}
return &e;
}
RunnerWDBEntry *RunnerDB::addRunner(const char *nameUTF,
__int64 extId,
int club, int card)
{
assert(rdb.size() == rwdb.size());
rdb.push_back(RunnerDBEntry());
rwdb.push_back(RunnerWDBEntry());
rwdb.back().init(this, rdb.size()-1);
RunnerWDBEntry &e=rwdb.back();
RunnerDBEntry &en=rdb.back();
en.cardNo = card;
en.clubNo = club;
e.setNameUTF(nameUTF);
en.extId = extId;
if (!check(en) ) {
rdb.pop_back();
rwdb.pop_back();
return 0;
} else {
if (card>0)
rhash[card]=rdb.size()-1;
if (!idhash.empty())
idhash[extId] = rdb.size()-1;
if (!nhash.empty()) {
wstring wn;
e.getName(wn);
nhash.insert(pair<wstring, int>(canonizeName(wn.c_str()), rdb.size()-1));
}
}
return &e;
}
int RunnerDB::addClub(oClub &c, bool createNewId) {
//map<int,int>::iterator it = chash.find(c.getId());
//if (it == chash.end()) {
if (createNewId) {
oDBClubEntry ce(c, cdb.size(), this);
cdb.push_back(ce);
int b = 0;
while(++b<0xFFFF) {
int newId = 10000 + rand() & 0xFFFF;
int off = (rand() & 0xFFFF);
int newId = 10000 + off;
int dummy;
if (!chash.lookup(newId, dummy)) {
cdb.back().Id = newId;
@ -240,7 +396,7 @@ void RunnerDB::compactifyClubs()
oDBClubEntry &ref = cdb[k];
vector<int> compacted;
for (size_t j=k+1;j<cdb.size(); j++) {
if (_stricmp(ref.getName().c_str(),
if (_wcsicmp(ref.getName().c_str(),
cdb[j].getName().c_str())==0)
compacted.push_back(j);
}
@ -265,27 +421,27 @@ void RunnerDB::compactifyClubs()
}
}
RunnerDBEntry *RunnerDB::getRunnerByCard(int card) const
RunnerWDBEntry *RunnerDB::getRunnerByCard(int card) const
{
if (card == 0)
return 0;
int value;
if (rhash.lookup(card, value))
return (RunnerDBEntry *)&rdb[value];
return (RunnerWDBEntry *)&rwdb[value];
return 0;
}
RunnerDBEntry *RunnerDB::getRunnerByIndex(size_t index) const {
RunnerWDBEntry *RunnerDB::getRunnerByIndex(size_t index) const {
if (index >= rdb.size())
throw meosException("Index out of bounds");
return (RunnerDBEntry *)&rdb[index];
return (RunnerWDBEntry *)&rwdb[index];
}
RunnerDBEntry *RunnerDB::getRunnerById(__int64 extId) const
RunnerWDBEntry *RunnerDB::getRunnerById(__int64 extId) const
{
if (extId == 0)
return 0;
@ -295,21 +451,21 @@ RunnerDBEntry *RunnerDB::getRunnerById(__int64 extId) const
int value;
if (idhash.lookup(extId, value))
return (RunnerDBEntry *)&rdb[value];
return (RunnerWDBEntry *)&rwdb[value];
return 0;
}
RunnerDBEntry *RunnerDB::getRunnerByName(const string &name, int clubId,
int expectedBirthYear) const
RunnerWDBEntry *RunnerDB::getRunnerByName(const wstring &name, int clubId,
int expectedBirthYear) const
{
if (expectedBirthYear>0 && expectedBirthYear<100)
expectedBirthYear = extendYear(expectedBirthYear);
setupNameHash();
vector<int> ix;
string cname(canonizeName(name.c_str()));
multimap<string, int>::const_iterator it = nhash.find(cname);
wstring cname(canonizeName(name.c_str()));
multimap<wstring, int>::const_iterator it = nhash.find(cname);
while (it != nhash.end() && cname == it->first) {
ix.push_back(it->second);
@ -321,7 +477,7 @@ RunnerDBEntry *RunnerDB::getRunnerByName(const string &name, int clubId,
if (clubId == 0) {
if (ix.size() == 1)
return (RunnerDBEntry *)&rdb[ix[0]];
return (RunnerWDBEntry *)&rwdb[ix[0]];
else
return 0; // Not uniquely defined.
}
@ -335,19 +491,19 @@ RunnerDBEntry *RunnerDB::getRunnerByName(const string &name, int clubId,
if (ix2.empty())
return 0;
else if (ix2.size() == 1)
return (RunnerDBEntry *)&rdb[ix2[0]];
return (RunnerWDBEntry *)&rwdb[ix2[0]];
else if (expectedBirthYear > 0) {
int bestMatch = 0;
int bestYear = 0;
for (size_t k = 0;k<ix2.size(); k++) {
const RunnerDBEntry &re = rdb[ix2[k]];
if (abs(re.birthYear-expectedBirthYear) < abs(bestYear-expectedBirthYear)) {
const RunnerWDBEntry &re = rwdb[ix2[k]];
if (abs(re.dbe().birthYear-expectedBirthYear) < abs(bestYear-expectedBirthYear)) {
bestMatch = ix2[k];
bestYear = re.birthYear;
bestYear = re.dbe().birthYear;
}
}
if (bestYear>0)
return (RunnerDBEntry *)&rdb[bestMatch];
return (RunnerWDBEntry *)&rwdb[bestMatch];
}
return 0;
@ -370,8 +526,10 @@ void RunnerDB::setupNameHash() const
return;
for (size_t k=0; k<rdb.size(); k++) {
if (!rdb[k].isRemoved())
nhash.insert(pair<string, int>(canonizeName(rdb[k].name), k));
if (!rdb[k].isRemoved()) {
rwdb[k].initName();
nhash.insert(pair<wstring, int>(canonizeName(rwdb[k].name), k));
}
}
}
@ -380,13 +538,13 @@ void RunnerDB::setupCNHash() const
if (!cnhash.empty())
return;
vector<string> split;
vector<wstring> split;
for (size_t k=0; k<cdb.size(); k++) {
if (cdb[k].isRemoved())
continue;
canonizeSplitName(cdb[k].getName(), split);
for (size_t j = 0; j<split.size(); j++)
cnhash.insert(pair<string, int>(split[j], k));
cnhash.insert(pair<wstring, int>(split[j], k));
}
}
@ -396,16 +554,16 @@ static bool isVowel(int c) {
c=='å' || c=='ä' || c=='ö';
}
void RunnerDB::canonizeSplitName(const string &name, vector<string> &split)
void RunnerDB::canonizeSplitName(const wstring &name, vector<wstring> &split)
{
split.clear();
const char *cname = name.c_str();
const wchar_t *cname = name.c_str();
int k = 0;
for (k=0; cname[k]; k++)
if (cname[k] != ' ')
break;
char out[128];
wchar_t out[128];
int outp;
while (cname[k]) {
outp = 0;
@ -439,7 +597,7 @@ void RunnerDB::canonizeSplitName(const string &name, vector<string> &split)
}
}
bool RunnerDB::getClub(int clubId, string &club) const
bool RunnerDB::getClub(int clubId, wstring &club) const
{
//map<int,int>::const_iterator it = chash.find(clubId);
@ -465,16 +623,16 @@ oClub *RunnerDB::getClub(int clubId) const
return 0;
}
oClub *RunnerDB::getClub(const string &name) const
oClub *RunnerDB::getClub(const wstring &name) const
{
setupCNHash();
vector<string> names;
vector<wstring> names;
canonizeSplitName(name, names);
vector< vector<int> > ix(names.size());
set<int> iset;
for (size_t k = 0; k<names.size(); k++) {
multimap<string, int>::const_iterator it = cnhash.find(names[k]);
multimap<wstring, int>::const_iterator it = cnhash.find(names[k]);
while (it != cnhash.end() && names[k] == it->first) {
ix[k].push_back(it->second);
@ -504,15 +662,15 @@ oClub *RunnerDB::getClub(const string &name) const
// Exact compare
for (set<int>::iterator it = iset.begin(); it != iset.end(); ++it) {
pClub pc = pClub(&cdb[*it]);
if (_stricmp(pc->getName().c_str(), name.c_str())==0)
if (_wcsicmp(pc->getName().c_str(), name.c_str())==0)
return pc;
}
string cname = canonizeName(name.c_str());
wstring cname = canonizeName(name.c_str());
// Looser compare
for (set<int>::iterator it = iset.begin(); it != iset.end(); ++it) {
pClub pc = pClub(&cdb[*it]);
if (strcmp(canonizeName(pc->getName().c_str()), cname.c_str()) == 0 )
if (wcscmp(canonizeName(pc->getName().c_str()), cname.c_str()) == 0 )
return pc;
}
@ -542,11 +700,11 @@ oClub *RunnerDB::getClub(const string &name) const
return 0;
}
void RunnerDB::saveClubs(const char *file)
void RunnerDB::saveClubs(const wstring &file)
{
xmlparser xml(0);
xmlparser xml;
xml.openOutputT(file, true, "meosclubs");
xml.openOutputT(file.c_str(), true, "meosclubs");
vector<oDBClubEntry>::iterator it;
@ -595,14 +753,14 @@ void RunnerDB::setDataDate(const string &date)
dataTime = 0;
}
void RunnerDB::saveRunners(const char *file)
void RunnerDB::saveRunners(const wstring &file)
{
int f=-1;
_sopen_s(&f, file, _O_BINARY|_O_CREAT|_O_TRUNC|_O_WRONLY,
_wsopen_s(&f, file.c_str(), _O_BINARY|_O_CREAT|_O_TRUNC|_O_WRONLY,
_SH_DENYWR, _S_IREAD|_S_IWRITE);
if (f!=-1) {
int version = 5460002;
int version = 5460003;
_write(f, &version, 4);
_write(f, &dataDate, 4);
_write(f, &dataTime, 4);
@ -613,9 +771,9 @@ void RunnerDB::saveRunners(const char *file)
else throw std::exception("Could not save runner database.");
}
void RunnerDB::loadClubs(const char *file)
void RunnerDB::loadClubs(const wstring &file)
{
xmlparser xml(0);
xmlparser xml;
xml.read(file);
@ -640,10 +798,13 @@ void RunnerDB::loadClubs(const char *file)
oDBClubEntry c(oe, cdb.size(), this);
c.set(*it);
int value;
if (c.getId() == 0)
continue;
//if (chash.find(c.getId()) == chash.end()) {
if (!chash.lookup(c.getId(), value)) {
chash[c.getId()]=cdb.size();
cdb.push_back(c);
freeCIx = max(c.getId()+1, freeCIx);;
}
}
}
@ -652,7 +813,7 @@ void RunnerDB::loadClubs(const char *file)
bool checkClubs = false;
if (checkClubs) {
vector<string> problems;
vector<wstring> problems;
for (size_t k=0; k<cdb.size(); k++) {
pClub pc = &cdb[k];
@ -660,17 +821,17 @@ void RunnerDB::loadClubs(const char *file)
if (!pc2)
problems.push_back(pc->getName());
else if (pc != pc2)
problems.push_back(pc->getName() + "-" + pc2->getName());
problems.push_back(pc->getName() + L"-" + pc2->getName());
}
problems.begin();
}
}
void RunnerDB::loadRunners(const char *file)
void RunnerDB::loadRunners(const wstring &file)
{
string ex=string("Bad runner database. ")+file;
wstring ex = L"Bad runner database. " + file;
int f=-1;
_sopen_s(&f, file, _O_BINARY|_O_RDONLY,
_wsopen_s(&f, file.c_str(), _O_BINARY|_O_RDONLY,
_SH_DENYWR, _S_IREAD|_S_IWRITE);
if (f!=-1) {
@ -684,23 +845,52 @@ void RunnerDB::loadRunners(const char *file)
}
int nentry = 0;
if (len % sizeof(RunnerDBEntry) == 12) {
nentry = (len-12) / sizeof(RunnerDBEntry);
if (len % sizeof(RunnerDBEntryV2) == 12 || len % sizeof(RunnerDBEntry) == 12) {
int version;
_read(f, &version, 4);
_read(f, &dataDate, 4);
_read(f, &dataTime, 4);
bool migrateV2 = false;
if (version == 5460002) {
migrateV2 = true;
nentry = (len-12) / sizeof(RunnerDBEntryV2);
}
else if (version == 5460003) {
nentry = (len-12) / sizeof(RunnerDBEntry);
}
// Else unknown version: fail
rdb.resize(nentry);
if (rdb.empty()) {
_close(f);
return;
}
int version;
_read(f, &version, 4);
_read(f, &dataDate, 4);
_read(f, &dataTime, 4);
_read(f, &rdb[0], len-12);
_close(f);
rwdb.resize(rdb.size());
if (!migrateV2) {
_read(f, &rdb[0], len-12);
_close(f);
}
else {
vector<RunnerDBEntryV2> rdbV2(nentry);
_read(f, &rdbV2[0], len-12);
_close(f);
for (int k=0;k<nentry;k++) {
rdb[k].init(rdbV2[k]);
rwdb[k].init(this, k);
if (!check(rdb[k]))
throw meosException(ex);
}
}
for (int k=0;k<nentry;k++) {
rwdb[k].init(this, k);
if (!check(rdb[k]))
throw std::exception(ex.c_str());
throw meosException(ex);
}
}
else {
@ -718,10 +908,14 @@ void RunnerDB::loadRunners(const char *file)
_read(f, &rdbV1[0], len);
_close(f);
rwdb.resize(rdb.size());
RunnerDBEntryV2 tmp;
for (int k=0;k<nentry;k++) {
rdb[k].init(rdbV1[k]);
tmp.init(rdbV1[k]);
rdb[k].init(tmp);
rwdb[k].init(this, k);
if (!check(rdb[k]))
throw std::exception(ex.c_str());
throw meosException(ex);
}
}
@ -738,13 +932,13 @@ void RunnerDB::loadRunners(const char *file)
}
}
}
else throw std::exception(ex.c_str());
else throw meosException(ex);
}
bool RunnerDB::check(const RunnerDBEntry &rde) const
{
if (rde.cardNo<0 || rde.cardNo>99999999
|| rde.name[baseNameLength-1]!=0 || rde.clubNo<0)
|| rde.name[baseNameLengthUTF-1]!=0 || rde.clubNo<0)
return false;
return true;
}
@ -752,9 +946,9 @@ bool RunnerDB::check(const RunnerDBEntry &rde) const
void RunnerDB::updateAdd(const oRunner &r, map<int, int> &clubIdMap)
{
if (r.getExtIdentifier() > 0) {
RunnerDBEntry *dbe = getRunnerById(int(r.getExtIdentifier()));
RunnerWDBEntry *dbe = getRunnerById(int(r.getExtIdentifier()));
if (dbe) {
dbe->cardNo = r.CardNo;
dbe->dbe().cardNo = r.CardNo;
return; // Do not change too much in runner from national database
}
}
@ -790,29 +984,29 @@ void RunnerDB::updateAdd(const oRunner &r, map<int, int> &clubIdMap)
}
}
RunnerDBEntry *dbe = getRunnerByCard(r.getCardNo());
RunnerWDBEntry *dbe = getRunnerByCard(r.getCardNo());
if (dbe == 0) {
dbe = addRunner(r.getName().c_str(), 0, localClubId, r.getCardNo());
if (dbe)
dbe->birthYear = r.getDCI().getInt("BirthYear");
dbe->dbe().birthYear = r.getDCI().getInt("BirthYear");
}
else {
if (dbe->getExtId() == 0) { // Only update entries not in national db.
dbe->setName(r.getName().c_str());
dbe->clubNo = localClubId;
dbe->birthYear = r.getDCI().getInt("BirthYear");
dbe->dbe().clubNo = localClubId;
dbe->dbe().birthYear = r.getDCI().getInt("BirthYear");
}
}
}
void RunnerDB::getAllNames(vector<string> &givenName, vector<string> &familyName)
void RunnerDB::getAllNames(vector<wstring> &givenName, vector<wstring> &familyName)
{
givenName.reserve(rdb.size());
familyName.reserve(rdb.size());
for (size_t k=0;k<rdb.size(); k++) {
string gname(rdb[k].getGivenName());
string fname(rdb[k].getFamilyName());
for (size_t k=0;k<rwdb.size(); k++) {
wstring gname(rwdb[k].getGivenName());
wstring fname(rwdb[k].getFamilyName());
if (!gname.empty())
givenName.push_back(gname);
if (!fname.empty())
@ -839,15 +1033,32 @@ void RunnerDB::clearRunners()
idhash.clear();
rhash.clear();
rdb.clear();
rwdb.clear();
if (runnerTable)
runnerTable->clear();
}
const vector<oDBClubEntry> &RunnerDB::getClubDB() const {
const vector<oDBClubEntry> &RunnerDB::getClubDB(bool checkProblems) const {
if (checkProblems) {
for (size_t k = 0; k < cdb.size(); k++) {
int v = -1;
if (cdb[k].isRemoved())
continue;
// Mark id duplacates as removed
if (!chash.lookup(cdb[k].getId(), v) || v != k) {
const_cast<oDBClubEntry &>(cdb[k]).Removed = true;
}
}
}
return cdb;
}
const vector<RunnerDBEntry> &RunnerDB::getRunnerDB() const {
const vector<RunnerWDBEntry> &RunnerDB::getRunnerDB() const {
return rwdb;
}
const vector<RunnerDBEntry> &RunnerDB::getRunnerDBN() const {
return rdb;
}
@ -858,7 +1069,7 @@ void RunnerDB::prepareLoadFromServer(int nrunner, int nclub) {
rdb.reserve(nrunner);
}
void RunnerDB::fillClubs(vector< pair<string, size_t> > &out) const {
void RunnerDB::fillClubs(vector< pair<wstring, size_t> > &out) const {
out.reserve(cdb.size());
for (size_t k = 0; k<cdb.size(); k++) {
if (!cdb[k].isRemoved()) {
@ -929,7 +1140,7 @@ void RunnerDB::releaseTables() {
Table *RunnerDB::getRunnerTB()//Table mode
{
if (runnerTable == 0) {
Table *table=new Table(oe, 20, "Löpardatabasen", "runnerdb");
Table *table=new Table(oe, 20, L"Löpardatabasen", "runnerdb");
table->addColumn("Index", 70, true, true);
table->addColumn("Id", 70, true, true);
@ -996,7 +1207,7 @@ Table *RunnerDB::getClubTB()//Table mode
bool canEdit = !oe->isClient();
if (clubTable == 0) {
Table *table = new Table(oe, 20, "Klubbdatabasen", "clubdb");
Table *table = new Table(oe, 20, L"Klubbdatabasen", "clubdb");
table->addColumn("Id", 70, true, true);
table->addColumn("Ändrad", 70, false);
@ -1034,34 +1245,37 @@ void oDBRunnerEntry::addTableRow(Table &table) const {
if (!db)
throw meosException("Not initialized");
RunnerDBEntry &r = db->rdb[index];
int row = 0;
table.set(row++, it, TID_INDEX, itos(index+1), false, cellEdit);
RunnerWDBEntry &r = db->rwdb[index];
RunnerDBEntry &rn = r.dbe();
char bf[16];
oBase::converExtIdentifierString(r.extId, bf);
int row = 0;
table.set(row++, it, TID_INDEX, itow(index+1), false, cellEdit);
wchar_t bf[16];
oBase::converExtIdentifierString(rn.extId, bf);
table.set(row++, it, TID_ID, bf, false, cellEdit);
r.initName();
table.set(row++, it, TID_NAME, r.name, canEdit, cellEdit);
const pClub pc = db->getClub(r.clubNo);
const pClub pc = db->getClub(rn.clubNo);
if (pc)
table.set(row++, it, TID_CLUB, pc->getName(), canEdit, cellSelection);
else
table.set(row++, it, TID_CLUB, "", canEdit, cellSelection);
table.set(row++, it, TID_CLUB, L"", canEdit, cellSelection);
table.set(row++, it, TID_CARD, r.cardNo > 0 ? itos(r.cardNo) : "", canEdit, cellEdit);
char nat[4] = {r.national[0],r.national[1],r.national[2], 0};
table.set(row++, it, TID_CARD, rn.cardNo > 0 ? itow(rn.cardNo) : L"", canEdit, cellEdit);
wchar_t nat[4] = {wchar_t(rn.national[0]), wchar_t(rn.national[1]), wchar_t(rn.national[2]), 0};
table.set(row++, it, TID_NATIONAL, nat, canEdit, cellEdit);
char sex[2] = {r.sex, 0};
wchar_t sex[2] = {wchar_t(rn.sex), 0};
table.set(row++, it, TID_SEX, sex, canEdit, cellEdit);
table.set(row++, it, TID_YEAR, itos(r.birthYear), canEdit, cellEdit);
table.set(row++, it, TID_YEAR, itow(rn.birthYear), canEdit, cellEdit);
oClass *val = 0;
bool found = false;
if (r.extId != 0)
found = db->runnerInEvent.lookup(r.extId, val);
if (rn.extId != 0)
found = db->runnerInEvent.lookup(rn.extId, val);
if (canEdit)
table.setTableProp(Table::CAN_DELETE|Table::CAN_INSERT|Table::CAN_PASTE);
@ -1069,9 +1283,9 @@ void oDBRunnerEntry::addTableRow(Table &table) const {
table.setTableProp(0);
if (!found)
table.set(row++, it, TID_ENTER, "@+", false, cellAction);
table.set(row++, it, TID_ENTER, L"@+", false, cellAction);
else
table.set(row++, it, TID_ENTER, val ? val->getName() : "", false, cellEdit);
table.set(row++, it, TID_ENTER, val ? val->getName() : L"", false, cellEdit);
}
const RunnerDBEntry &oDBRunnerEntry::getRunner() const {
@ -1080,12 +1294,13 @@ const RunnerDBEntry &oDBRunnerEntry::getRunner() const {
return db->rdb[index];
}
bool oDBRunnerEntry::inputData(int id, const string &input,
int inputId, string &output, bool noUpdate)
bool oDBRunnerEntry::inputData(int id, const wstring &input,
int inputId, wstring &output, bool noUpdate)
{
if (!db)
throw meosException("Not initialized");
RunnerDBEntry &r = db->rdb[index];
RunnerWDBEntry &r = db->rwdb[index];
RunnerDBEntry &rd = db->rdb[index];
switch(id) {
case TID_NAME:
@ -1094,58 +1309,60 @@ bool oDBRunnerEntry::inputData(int id, const string &input,
db->nhash.clear();
return true;
case TID_CARD:
db->rhash.remove(r.cardNo);
r.cardNo = atoi(input.c_str());
db->rhash.insert(r.cardNo, index);
if (r.cardNo)
output = itos(r.cardNo);
db->rhash.remove(rd.cardNo);
rd.cardNo = _wtoi(input.c_str());
db->rhash.insert(rd.cardNo, index);
if (rd.cardNo)
output = itow(rd.cardNo);
else
output = "";
output = L"";
return true;
case TID_NATIONAL:
if (input.empty()) {
r.national[0] = 0;
r.national[1] = 0;
r.national[2] = 0;
rd.national[0] = 0;
rd.national[1] = 0;
rd.national[2] = 0;
}
else if (input.size() >= 2) {
for (size_t i = 0; i < 3; i++) {
rd.national[i] = i < input.size() ? input[i] : 0;
}
}
else if (input.size() >= 2)
memcpy(r.national, input.c_str(), 3);
output = r.getNationality();
break;
case TID_SEX:
r.sex = input[0];
rd.sex = char(input[0]);
output = r.getSex();
break;
case TID_YEAR:
r.birthYear = short(atoi(input.c_str()));
output = itos(r.getBirthYear());
rd.birthYear = short(_wtoi(input.c_str()));
output = itow(r.getBirthYear());
break;
case TID_CLUB:
r.clubNo = inputId;
rd.clubNo = inputId;
output = input;
break;
}
return false;
}
void oDBRunnerEntry::fillInput(int id, vector< pair<string, size_t> > &out, size_t &selected)
void oDBRunnerEntry::fillInput(int id, vector< pair<wstring, size_t> > &out, size_t &selected)
{
RunnerDBEntry &r = db->rdb[index];
if (id==TID_CLUB) {
db->fillClubs(out);
out.push_back(make_pair("-", 0));
out.push_back(make_pair(L"-", 0));
selected = r.clubNo;
}
}
void oDBRunnerEntry::remove() {
RunnerDBEntry &r = db->rdb[index];
RunnerWDBEntry &r = db->rwdb[index];
r.remove();
db->idhash.remove(r.extId);
string cname(canonizeName(r.name));
multimap<string, int>::const_iterator it = db->nhash.find(cname);
db->idhash.remove(r.dbe().extId);
wstring cname(canonizeName(r.name));
multimap<wstring, int>::const_iterator it = db->nhash.find(cname);
while (it != db->nhash.end() && cname == it->first) {
if (it->second == index) {
@ -1155,10 +1372,10 @@ void oDBRunnerEntry::remove() {
++it;
}
if (r.cardNo > 0) {
if (r.dbe().cardNo > 0) {
int ix = -1;
if (db->rhash.lookup(r.cardNo, ix) && ix == index) {
db->rhash.remove(r.cardNo);
if (db->rhash.lookup(r.dbe().cardNo, ix) && ix == index) {
db->rhash.remove(r.dbe().cardNo);
}
}
}
@ -1169,6 +1386,9 @@ bool oDBRunnerEntry::canRemove() const {
oDBRunnerEntry *RunnerDB::addRunner() {
rdb.push_back(RunnerDBEntry());
rwdb.push_back(RunnerWDBEntry());
rwdb.back().init(this, rdb.size() -1);
oRDB.push_back(oDBRunnerEntry(oe));
oRDB.back().init(this, rdb.size() - 1);
@ -1208,10 +1428,10 @@ void oDBClubEntry::remove() {
Removed = true;
db->chash.remove(getId());
vector<string> split;
vector<wstring> split;
db->canonizeSplitName(getName(), split);
for (size_t j = 0; j<split.size(); j++) {
multimap<string, int>::const_iterator it = db->cnhash.find(split[j]);
multimap<wstring, int>::const_iterator it = db->cnhash.find(split[j]);
while (it != db->cnhash.end() && split[j] == it->first) {
if (it->second == index) {
db->cnhash.erase(it);
@ -1230,3 +1450,12 @@ int oDBClubEntry::getTableId() const {
return index + 1;
}
// Link to narrow DB Entry
const RunnerDBEntry &RunnerWDBEntry::dbe() const {
return owner->rdb[ix];
}
// Link to narrow DB Entry
RunnerDBEntry &RunnerWDBEntry::dbe() {
return owner->rdb[ix];
}

View File

@ -4,7 +4,13 @@
#include <map>
#include "inthashmap.h"
#include "oclub.h"
#ifdef OLD
#include <hash_set>
#else
#include <unordered_set>
#endif
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
@ -27,14 +33,15 @@
************************************************************************/
const int baseNameLength=32;
const int baseNameLength=40;
const int baseNameLengthUTF=56;
//Has 0-clearing constructor. Must not contain any
//dynamic data etc.
struct RunnerDBEntryV1 {
RunnerDBEntryV1();
char name[baseNameLength];
char name[32];
int cardNo;
int clubNo;
char national[3];
@ -43,13 +50,13 @@ struct RunnerDBEntryV1 {
short int reserved;
};
struct RunnerDBEntry {
struct RunnerDBEntryV2 {
// Init from old struct
void init(const RunnerDBEntryV1 &dbe);
RunnerDBEntry();
RunnerDBEntryV2();
/** Binary compatible with V1*/
char name[baseNameLength];
char name[32];
int cardNo;
int clubNo;
char national[3];
@ -57,24 +64,79 @@ struct RunnerDBEntry {
short int birthYear;
short int reserved;
/** End of V1*/
__int64 extId;
void getName(string &name) const;
void setName(const char *name);
bool isRemoved() const {return (reserved & 1) == 1;}
void remove() {reserved |= 1;}
string getGivenName() const;
string getFamilyName() const;
bool isUTF() const {return (reserved & 2) == 2;}
void setUTF() {reserved |= 2;}
};
struct RunnerDBEntry {
// Init from old struct
void init(const RunnerDBEntryV2 &dbe);
RunnerDBEntry();
// 8 it versions
string getNationality() const;
int getBirthYear() const {return birthYear;}
string getSex() const;
char name[baseNameLengthUTF];
int cardNo;
int clubNo;
char national[3];
char sex;
short int birthYear;
short int reserved;
/** End of V1*/
__int64 extId;
bool isRemoved() const {return (reserved & 1) == 1;}
void remove() {reserved |= 1;}
bool isUTF() const {return (reserved & 2) == 2;}
void setUTF() {reserved |= 2;}
};
class RunnerDB;
struct RunnerWDBEntry {
private:
RunnerDB *owner;
size_t ix;
public:
// Init from old struct
void init(RunnerDB *p, size_t ix);
RunnerWDBEntry();
// Link to narrow DB Entry
const RunnerDBEntry &dbe() const;
RunnerDBEntry &dbe();
void initName() const;
void recode(const RunnerDBEntry &dest) const;
mutable wchar_t name[baseNameLength];
void getName(wstring &name) const;
void setName(const wchar_t *name);
void setNameUTF(const char *name);
wstring getGivenName() const;
wstring getFamilyName() const;
wstring getNationality() const;
int getBirthYear() const {return dbe().birthYear;}
wstring getSex() const;
__int64 getExtId() const;
void setExtId(__int64 id);
bool isRemoved() const {return (reserved & 1) == 1;}
void remove() {reserved |= 1;}
bool isRemoved() const {return (dbe().reserved & 1) == 1;}
void remove() {dbe().reserved |= 1;}
};
typedef vector<RunnerDBEntry> RunnerDBVector;
@ -100,6 +162,8 @@ private:
void setupCNHash() const;
vector<RunnerDBEntry> rdb;
vector<RunnerWDBEntry> rwdb;
vector<oDBClubEntry> cdb;
vector<oDBRunnerEntry> oRDB;
@ -116,12 +180,12 @@ private:
int freeCIx;
// Name hash
mutable multimap<string, int> nhash;
mutable multimap<wstring, int> nhash;
// Club name hash
mutable multimap<string, int> cnhash;
mutable multimap<wstring, int> cnhash;
static void canonizeSplitName(const string &name, vector<string> &split);
static void canonizeSplitName(const wstring &name, vector<wstring> &split);
bool loadedFromServer;
@ -131,7 +195,7 @@ private:
/** Time when database was updated. The format is HH:MM:SS */
int dataTime;
void fillClubs(vector< pair<string, size_t> > &out) const;
void fillClubs(vector< pair<wstring, size_t> > &out) const;
public:
@ -161,46 +225,50 @@ public:
/** Prepare for loading runner from server*/
void prepareLoadFromServer(int nrunner, int nclub);
const vector<RunnerDBEntry>& getRunnerDB() const;
const vector<oDBClubEntry>& getClubDB() const;
const vector<RunnerWDBEntry>& getRunnerDB() const;
const vector<RunnerDBEntry>& getRunnerDBN() const;
const vector<oDBClubEntry>& getClubDB(bool checkProblems) const;
void clearRunners();
void clearClubs();
/** Add a club. Create a new Id if necessary*/
int addClub(oClub &c, bool createNewId);
RunnerDBEntry *addRunner(const char *name, __int64 extId,
int club, int card);
RunnerWDBEntry *addRunner(const wchar_t *name, __int64 extId,
int club, int card);
RunnerWDBEntry *addRunner(const char *nameUTF, __int64 extId,
int club, int card);
oDBRunnerEntry *addRunner();
oClub *addClub();
RunnerDBEntry *getRunnerByIndex(size_t index) const;
RunnerDBEntry *getRunnerById(__int64 extId) const;
RunnerDBEntry *getRunnerByCard(int card) const;
RunnerDBEntry *getRunnerByName(const string &name, int clubId,
RunnerWDBEntry *getRunnerByIndex(size_t index) const;
RunnerWDBEntry *getRunnerById(__int64 extId) const;
RunnerWDBEntry *getRunnerByCard(int card) const;
RunnerWDBEntry *getRunnerByName(const wstring &name, int clubId,
int expectedBirthYear) const;
bool getClub(int clubId, string &club) const;
bool getClub(int clubId, wstring &club) const;
oClub *getClub(int clubId) const;
oClub *getClub(const string &name) const;
oClub *getClub(const wstring &name) const;
void saveClubs(const char *file);
void saveRunners(const char *file);
void loadRunners(const char *file);
void loadClubs(const char *file);
void saveClubs(const wstring &file);
void saveRunners(const wstring &file);
void loadRunners(const wstring &file);
void loadClubs(const wstring &file);
void updateAdd(const oRunner &r, map<int, int> &clubIdMap);
void importClub(oClub &club, bool matchName);
void compactifyClubs();
void getAllNames(vector<string> &givenName, vector<string> &familyName);
void getAllNames(vector<wstring> &givenName, vector<wstring> &familyName);
RunnerDB(oEvent *);
~RunnerDB(void);
friend class oDBRunnerEntry;
friend class oDBClubEntry;
friend struct RunnerWDBEntry;
};
class oDBRunnerEntry : public oBase {
@ -220,9 +288,9 @@ public:
const RunnerDBEntry &getRunner() const;
void addTableRow(Table &table) const;
bool inputData(int id, const string &input,
int inputId, string &output, bool noUpdate);
void fillInput(int id, vector< pair<string, size_t> > &out, size_t &selected);
bool inputData(int id, const wstring &input,
int inputId, wstring &output, bool noUpdate);
void fillInput(int id, vector< pair<wstring, size_t> > &out, size_t &selected);
oDBRunnerEntry(oEvent *oe);
virtual ~oDBRunnerEntry();
@ -230,7 +298,7 @@ public:
void remove();
bool canRemove() const;
string getInfo() const {return "Database Runner";}
wstring getInfo() const {return L"Database Runner";}
};

File diff suppressed because it is too large Load Diff

View File

@ -73,9 +73,9 @@ struct SICard
SIPunch CheckPunch;
DWORD nPunch;
SIPunch Punch[192];
char FirstName[21];
char LastName[21];
char Club[41];
wchar_t FirstName[21];
wchar_t LastName[21];
wchar_t Club[41];
char readOutTime[32];
bool PunchOnly;
bool convertedTime;
@ -110,7 +110,7 @@ struct SI_StationInfo
{
SI_StationInfo();
HANDLE ThreadHandle;
string ComPort;
wstring ComPort;
HANDLE hComm;
COMMTIMEOUTS TimeOuts;
@ -142,19 +142,19 @@ struct SI_StationInfo
class SportIdent
{
protected:
bool ReadSI6Block(HANDLE hComm, BYTE *data);
bool ReadSystemData(SI_StationInfo *si, int retry=2);
bool ReadSystemDataV2(SI_StationInfo &si);
bool readSI6Block(HANDLE hComm, BYTE *data);
bool readSystemData(SI_StationInfo *si, int retry=2);
bool readSystemDataV2(SI_StationInfo &si);
CRITICAL_SECTION SyncObj;
DWORD ZeroTime; //Used to analyse times. Seconds 0-24h (0-24*3600)
int ReadByte_delay(BYTE &byte, HANDLE hComm);
int ReadBytes_delay(BYTE *byte, DWORD buffSize, DWORD len, HANDLE hComm);
int ReadBytesDLE_delay(BYTE *byte, DWORD buffSize, DWORD len, HANDLE hComm);
int readByte_delay(BYTE &byte, HANDLE hComm);
int readBytes_delay(BYTE *byte, DWORD buffSize, DWORD len, HANDLE hComm);
int readBytesDLE_delay(BYTE *byte, DWORD buffSize, DWORD len, HANDLE hComm);
int ReadByte(BYTE &byte, HANDLE hComm);
int ReadBytes(BYTE *byte, DWORD len, HANDLE hComm);
int ReadBytesDLE(BYTE *byte, DWORD len, HANDLE hComm);
int readByte(BYTE &byte, HANDLE hComm);
int readBytes(BYTE *byte, DWORD len, HANDLE hComm);
int readBytesDLE(BYTE *byte, DWORD len, HANDLE hComm);
// Returns zero on failure, number of bytes used on success.
int analyzeStation(BYTE *db, SI_StationData &si);
@ -163,26 +163,26 @@ protected:
int n_SI_Info; //Number of structures..
SI_StationInfo *Current_SI_Info; //Current SI_Info in use (for thread startup);
WORD CalcCRC(BYTE *data, DWORD length);
bool CheckCRC(BYTE *bf);
void SetCRC(BYTE *bf);
WORD calcCRC(BYTE *data, DWORD length);
bool checkCRC(BYTE *bf);
void setCRC(BYTE *bf);
bool GetCard5Data(BYTE *data, SICard &card);
bool GetCard6Data(BYTE *data, SICard &card);
bool GetCard9Data(BYTE *data, SICard &card);
bool getCard5Data(BYTE *data, SICard &card);
bool getCard6Data(BYTE *data, SICard &card);
bool getCard9Data(BYTE *data, SICard &card);
DWORD GetExtCardNumber(BYTE *data) const;
void GetSI5Data(HANDLE hComm);
void GetSI5DataExt(HANDLE hComm);
void getSI5Data(HANDLE hComm);
void getSI5DataExt(HANDLE hComm);
void GetSI6Data(HANDLE hComm);
void GetSI6DataExt(HANDLE hComm);
void GetSI9DataExt(HANDLE hComm);
void getSI6Data(HANDLE hComm);
void getSI6DataExt(HANDLE hComm);
void getSI9DataExt(HANDLE hComm);
void AnalyseSI5Time(BYTE *data, DWORD &time, DWORD &control);
bool AnalysePunch(BYTE *data, DWORD &time, DWORD &control);
void AnalyseTPunch(BYTE *data, DWORD &time, DWORD &control);
void analyseSI5Time(BYTE *data, DWORD &time, DWORD &control);
bool analysePunch(BYTE *data, DWORD &time, DWORD &control);
void analyseTPunch(BYTE *data, DWORD &time, DWORD &control);
//Card read waiting to be processed.
list<SICard> ReadCards;
@ -196,27 +196,27 @@ protected:
int MonitorTCPSI(WORD port, int localZeroTime);
public:
SI_StationInfo *findStation(const string &com);
SI_StationInfo *findStation(const wstring &com);
void getInfoString(const string &com, vector<string> &info);
bool IsPortOpen(const string &com);
void SetZeroTime(DWORD zt);
bool AutoDetect(list<int> &ComPorts);
void StopMonitorThread();
void getInfoString(const wstring &com, vector<wstring> &info);
bool isPortOpen(const wstring &com);
void setZeroTime(DWORD zt);
bool autoDetect(list<int> &ComPorts);
void stopMonitorThread();
void StartMonitorThread(const char *com);
bool GetCard(SICard &sic);
void startMonitorThread(const wchar_t *com);
bool getCard(SICard &sic);
void addCard(const SICard &sic);
void AddPunch(DWORD Time, int Station, int Card, int Mode=0);
void addPunch(DWORD Time, int Station, int Card, int Mode=0);
void EnumrateSerialPorts(list<int> &ports);
void CloseCom(const char *com);
bool OpenCom(const char *com);
void closeCom(const wchar_t *com);
bool openCom(const wchar_t *com);
bool tcpAddPort(int port, DWORD zeroTime);
bool OpenComListen(const char *com, DWORD BaudRate);
bool openComListen(const wchar_t *com, DWORD BaudRate);
SportIdent(HWND hWnd, DWORD Id);
virtual ~SportIdent();

View File

@ -4,6 +4,7 @@
#include "stdafx.h"
const wstring _EmptyWString=L"";
const string _EmptyString="";
const string _VacantName="Vakant";
const string _UnkownName="N.N.";

View File

@ -32,24 +32,24 @@
#include <crtdbg.h>
using namespace std;
bool getUserFile(char *fileNamePath, const char *fileName);
bool getDesktopFile(char *fileNamePath, const char *fileName, const char *subFolder = 0);
bool getMeOSFile(char *FileNamePath, const char *FileName);
bool getUserFile(wchar_t *fileNamePath, const wchar_t *fileName);
bool getDesktopFile(wchar_t *fileNamePath, const wchar_t *fileName, const wchar_t *subFolder = 0);
bool getMeOSFile(wchar_t *FileNamePath, const wchar_t *FileName);
class gdioutput;
gdioutput *createExtraWindow(const string &tag, const string &title, int max_x = 0, int max_y = 0);
gdioutput *createExtraWindow(const string &tag, const wstring &title, int max_x = 0, int max_y = 0);
gdioutput *getExtraWindow(const string &tag, bool toForeGround);
string uniqueTag(const char *base);
void LoadPage(const string &name);
string getTempFile();
string getTempPath();
void removeTempFile(const string &file); // Delete a temporyary
void registerTempFile(const string &tempFile); //Register a file/folder as temporary => autmatic removal on exit.
wstring getTempFile();
wstring getTempPath();
void removeTempFile(const wstring &file); // Delete a temporyary
void registerTempFile(const wstring &tempFile); //Register a file/folder as temporary => autmatic removal on exit.
const extern string _EmptyString;
const extern string _VacantName;
const extern string _UnkownName;
const extern wstring _EmptyWString;
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)

View File

@ -150,7 +150,7 @@ int AutomaticCB(gdioutput *gdi, int type, void *data)
void TabAuto::syncCallback(gdioutput &gdi)
{
string msg;
wstring msg;
try {
list<AutoMachine *>::iterator it;
for (it=machines.begin(); it!=machines.end(); ++it) {
@ -159,11 +159,14 @@ void TabAuto::syncCallback(gdioutput &gdi)
am->process(gdi, oe, SyncDataUp);
}
}
catch (meosException &ex) {
msg = ex.wwhat();
}
catch(std::exception &ex) {
msg=ex.what();
msg = gdi.widen(ex.what());
}
catch(...) {
msg="Ett okänt fel inträffade.";
msg = L"Ett okänt fel inträffade.";
}
if (!msg.empty()) {
gdi.alert(msg);
@ -234,7 +237,7 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
int nRunner=gdi.getTextNo("nRunner");
if (nRunner>0 &&
gdi.ask("Vill du dumpa aktuellt tävling och skapa en testtävling?")) {
gdi.ask(L"Vill du dumpa aktuellt tävling och skapa en testtävling?")) {
oe->generateTestCompetition(nClass, nRunner, gdi.isChecked("UseRelay"));
gdi.getTabs().get(TCmpTab)->loadPage(gdi);
return 0;
@ -242,9 +245,9 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
#endif
}
else if (bu.id == "BrowseFolder") {
const char *edit = bu.getExtra();
string currentPath = gdi.getText(edit);
string newPath = gdi.browseForFolder(currentPath, 0);
const wchar_t *edit = bu.getExtra();
wstring currentPath = gdi.getText(gdi.narrow(edit));
wstring newPath = gdi.browseForFolder(currentPath, 0);
if (!newPath.empty())
gdi.setText(edit, newPath);
}
@ -261,18 +264,18 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
}
else if (bu.id == "BrowseFile") {
static int index = 0;
vector< pair<string, string> > ext;
ext.push_back(make_pair("Webbdokument", "*.html;*.htm"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Webbdokument", L"*.html;*.htm"));
string file = gdi.browseForSave(ext, "html", index);
wstring file = gdi.browseForSave(ext, L"html", index);
if (!file.empty())
gdi.setText("ExportFile", file);
}
else if (bu.id == "BrowseScript") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Skript", "*.bat;*.exe;*.js"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Skript", L"*.bat;*.exe;*.js"));
string file = gdi.browseForOpen(ext, "bat");
wstring file = gdi.browseForOpen(ext, L"bat");
if (!file.empty())
gdi.setText("ExportScript", file);
}
@ -315,7 +318,7 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
}
else if (bu.id=="StartResult") {
#ifndef MEOSDB
string minute=gdi.getText("Interval");
wstring minute=gdi.getText("Interval");
int t=convertAbsoluteTimeMS(minute);
if (t<2 || t>7200) {
@ -366,13 +369,13 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
}
else if (bu.id=="StartSplits") {
string ivt = gdi.getText("Interval");
wstring ivt = gdi.getText("Interval");
int iv = gdi.getTextNo("Interval");
const string &file=gdi.getText("FileName");
const wstring &file=gdi.getText("FileName");
if (!ivt.empty() && (iv < 1 || iv > 7200)) {
throw meosException("Ogiltigt antal sekunder: X#" + gdi.getText("Interval"));
throw meosException(L"Ogiltigt antal sekunder: X#" + gdi.getText("Interval"));
}
if (file.empty()) {
@ -427,11 +430,11 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
}
else if (bu.id=="StartPunch") {
string minute=gdi.getText("Interval");
int t=atoi(minute.c_str());
wstring minute=gdi.getText("Interval");
int t=_wtoi(minute.c_str());
if (t<1 || t>7200) {
throw meosException("Ogiltigt antal sekunder: X#" + minute);
throw meosException(L"Ogiltigt antal sekunder: X#" + minute);
}
else {
PunchMachine *pm=dynamic_cast<PunchMachine*>(getMachine(bu.getExtraInt()));
@ -474,13 +477,13 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
}
}
else if (bu.id == "SelectAll") {
const char *ctrl = bu.getExtra();
const wchar_t *ctrl = bu.getExtra();
set<int> lst;
lst.insert(-1);
gdi.setSelection(ctrl, lst);
}
else if (bu.id == "SelectNone") {
const char *ctrl= bu.getExtra();
const wchar_t *ctrl= bu.getExtra();
set<int> lst;
gdi.setSelection(ctrl, lst);
}
@ -491,17 +494,17 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
oe->tryPrewarningSounds(pwm->waveFolder, rand()%400+1);
}
else if ( bu.id == "WaveBrowse") {
string wf=gdi.browseForFolder(gdi.getText("WaveFolder"), 0);
wstring wf=gdi.browseForFolder(gdi.getText("WaveFolder"), 0);
if (wf.length()>0)
gdi.setText("WaveFolder", wf);
}
else if ( bu.id == "BrowseSplits") {
int index=0;
vector< pair<string, string> > ext;
ext.push_back(make_pair("Sträcktider", "*.xml"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Sträcktider", L"*.xml"));
string wf = gdi.browseForSave(ext, "xml", index);
wstring wf = gdi.browseForSave(ext, L"xml", index);
if (!wf.empty())
gdi.setText("FileName", wf);
@ -652,13 +655,13 @@ void AutoMachine::settingsTitle(gdioutput &gdi, char *title) {
gdi.dropLine(0.5);
}
void AutoMachine::startCancelInterval(gdioutput &gdi, char *startCommand, bool created, IntervalType type, const string &interval) {
void AutoMachine::startCancelInterval(gdioutput &gdi, char *startCommand, bool created, IntervalType type, const wstring &intervalIn) {
gdi.pushX();
gdi.fillRight();
if (type == IntervalMinute)
gdi.addInput("Interval", interval, 7, 0, "Tidsintervall (MM:SS):");
gdi.addInput("Interval", intervalIn, 7, 0, L"Tidsintervall (MM:SS):");
else if (type == IntervalSecond)
gdi.addInput("Interval", interval, 7, 0, "Tidsintervall (sekunder):");
gdi.addInput("Interval", intervalIn, 7, 0, L"Tidsintervall (sekunder):");
gdi.dropLine(1);
gdi.addButton(startCommand, "Starta automaten", AutomaticCB).setExtra(getId());
gdi.addButton(created ? "Stop":"Cancel", "Avbryt", AutomaticCB).setExtra(getId());
@ -679,7 +682,7 @@ void AutoMachine::startCancelInterval(gdioutput &gdi, char *startCommand, bool c
void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Resultatutskrift / export");
string time=created ? "10:00" : getTimeMS(interval);
wstring time=created ? L"10:00" : getTimeMSW(interval);
startCancelInterval(gdi, "StartResult", created, IntervalMinute, time);
if (created) {
@ -697,7 +700,7 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addCheckbox("DoExport", "Exportera", AutomaticCB, doExport);
gdi.dropLine(-1);
int cx = gdi.getCX();
gdi.addInput("ExportFile", exportFile, 32, 0, "Fil att exportera till:");
gdi.addInput("ExportFile", exportFile, 32, 0, L"Fil att exportera till:");
gdi.dropLine(0.7);
gdi.addButton("BrowseFile", "Bläddra...", AutomaticCB);
gdi.setCX(cx);
@ -706,7 +709,7 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addCheckbox("HTMLRefresh", "HTML med AutoRefresh", 0, htmlRefresh != 0);
gdi.dropLine(1.2);
gdi.setCX(cx);
gdi.addInput("ExportScript", exportScript, 32, 0, "Skript att köra efter export:");
gdi.addInput("ExportScript", exportScript, 32, 0, L"Skript att köra efter export:");
gdi.dropLine(0.7);
gdi.addButton("BrowseScript", "Bläddra...", AutomaticCB);
gdi.dropLine(3);
@ -725,14 +728,14 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addString("", 1, "Listval");
gdi.dropLine();
gdi.fillRight();
gdi.addListBox("Classes", 150,300,0,"","", true);
gdi.addListBox("Classes", 150,300,0, L"", L"", true);
gdi.pushX();
gdi.fillDown();
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
gdi.addItem("Classes", oe.fillClasses(d, oEvent::extraNone, oEvent::filterNone));
gdi.setSelection("Classes", classesToPrint);
gdi.addSelection("ListType", 200, 100, 0, "Lista");
gdi.addSelection("ListType", 200, 100, 0, L"Lista");
oe.fillListTypes(gdi, "ListType", 1);
if (notShown) {
notShown = false;
@ -749,9 +752,9 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
else
gdi.selectItemByData("ListType", listInfo.getListCode());
gdi.addSelection("LegNumber", 140, 300, 0, "Sträcka:");
gdi.addSelection("LegNumber", 140, 300, 0, L"Sträcka:");
set<int> clsUnused;
vector< pair<string, size_t> > out;
vector< pair<wstring, size_t> > out;
oe.fillLegNumbers(clsUnused, listInfo.isTeamList(), true, out);
gdi.addItem("LegNumber", out);
gdi.selectItemByData("LegNumber", listInfo.getLegNumberCoded());
@ -764,13 +767,13 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addCheckbox("OnlyChanged", "Skriv endast ut ändade sidor", 0, po.onlyChanged);
gdi.popX();
gdi.addButton("SelectAll", "Välj allt", AutomaticCB, "").setExtra("Classes");
gdi.addButton("SelectAll", "Välj allt", AutomaticCB, "").setExtra(L"Classes");
gdi.popX();
gdi.addButton("SelectNone", "Välj inget", AutomaticCB, "").setExtra("Classes");
gdi.addButton("SelectNone", "Välj inget", AutomaticCB, "").setExtra(L"Classes");
}
else {
gdi.fillDown();
gdi.addString("", 1, "Lista av typ 'X'#" + listInfo.getName());
gdi.addString("", 1, L"Lista av typ 'X'#" + listInfo.getName());
gdi.addCheckbox("OnlyChanged", "Skriv endast ut ändade sidor", 0, po.onlyChanged);
}
}
@ -781,10 +784,10 @@ void PrintResultMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast)
return;
if (ast!=SyncDataUp) {
string printError;
wstring printError;
lock = true;
try {
gdioutput gdiPrint("print", gdi.getScale(), gdi.getEncoding());
gdioutput gdiPrint("print", gdi.getScale(), gdi.getCP());
gdiPrint.clearPage(false);
oe->generateList(gdiPrint, true, listInfo, false);
if (doPrint) {
@ -793,17 +796,17 @@ void PrintResultMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast)
gdiPrint.print(po, oe);
}
catch (const meosException &ex) {
printError = ex.what();
printError = ex.wwhat();
if (printError.empty())
printError = "Printing failed (X: Y) Z#Auto#0#Unknown";
printError = L"Printing failed (X: Y) Z#Auto#0#Unknown";
}
}
if (doExport) {
if (!exportFile.empty()) {
if (structuredExport)
gdiPrint.writeTableHTML(gdi.toWide(exportFile), oe->getName(), htmlRefresh);
gdiPrint.writeTableHTML(exportFile, oe->getName(), htmlRefresh);
else
gdiPrint.writeHTML(gdi.toWide(exportFile), oe->getName(), htmlRefresh);
gdiPrint.writeHTML(exportFile, oe->getName(), htmlRefresh);
if (!exportScript.empty()) {
ShellExecute(NULL, NULL, exportScript.c_str(), exportFile.c_str(), NULL, SW_HIDE);
@ -858,28 +861,28 @@ void PrintResultMachine::status(gdioutput &gdi)
void PrewarningMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Förvarningsröst");
startCancelInterval(gdi, "StartPrewarning", created, IntervalNone, "");
startCancelInterval(gdi, "StartPrewarning", created, IntervalNone, L"");
gdi.addString("", 10, "help:computer_voice");
gdi.pushX();
gdi.fillRight();
gdi.addInput("WaveFolder", waveFolder, 32, 0, "Ljudfiler, baskatalog.");
gdi.addInput("WaveFolder", waveFolder, 32, 0, L"Ljudfiler, baskatalog.");
gdi.fillDown();
gdi.dropLine();
gdi.addButton("WaveBrowse", "Bläddra...", AutomaticCB);
gdi.popX();
gdi.addListBox("Controls", 100, 200, 0, "", "", true);
gdi.addListBox("Controls", 100, 200, 0, L"", L"", true);
gdi.pushX();
gdi.fillDown();
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
oe.fillControls(d, oEvent::CTCourseControl);
gdi.addItem("Controls", d);
gdi.setSelection("Controls", controls);
gdi.popX();
gdi.addButton("SelectAll", "Välj alla", AutomaticCB, "").setExtra("Controls");
gdi.addButton("SelectAll", "Välj alla", AutomaticCB, "").setExtra(L"Controls");
gdi.popX();
}
@ -923,7 +926,7 @@ void PrewarningMachine::status(gdioutput &gdi)
void PunchMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Test av stämplingsinläsningar");
string time=created ? "10" : itos(interval);
wstring time=created ? L"10" : itow(interval);
startCancelInterval(gdi, "StartPunch", created, IntervalSecond, time);
gdi.addString("", 10, "help:simulate");
@ -934,15 +937,15 @@ void PunchMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addString("", 0, "Radiotider, kontroll:");
gdi.dropLine(-0.2);
gdi.addInput("Radio", "", 6, 0);
gdi.addInput("Radio", L"", 6, 0);
gdi.fillDown();
gdi.popX();
gdi.dropLine(5);
gdi.addString("", 1, "Generera testtävling");
gdi.fillRight();
gdi.addInput("nRunner", "100", 10, 0, "Antal löpare");
gdi.addInput("nClass", "10", 10, 0, "Antal klasser");
gdi.addInput("nRunner", L"100", 10, 0, L"Antal löpare");
gdi.addInput("nClass", L"10", 10, 0, L"Antal klasser");
gdi.dropLine();
gdi.addCheckbox("UseRelay", "Med stafettklasser");
gdi.addButton("GenerateCMP", "Generera testtävling", AutomaticCB);
@ -978,7 +981,7 @@ void PunchMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast)
if (!sic.empty()) {
if (!radio) si.addCard(sic);
}
else gdi.addInfoBox("", "Failed to generate card.", interval*2);
else gdi.addInfoBox("", L"Failed to generate card.", interval*2);
if (radio && !sic.empty()) {
pRunner r=oe->getRunnerByCardNo(sic.CardNumber, 0, false);
@ -994,11 +997,11 @@ void PunchMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast)
}
void SplitsMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
string time = "";
wstring time;
if (interval>0)
time = itos(interval);
time = itow(interval);
else if (created)
time = "30";
time = L"30";
settingsTitle(gdi, "Sträcktider / WinSplits");
startCancelInterval(gdi, "StartSplits", created, IntervalSecond, time);
@ -1012,7 +1015,7 @@ void SplitsMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.dropLine();
gdi.fillRight();
gdi.addInput("FileName", file, 30, 0, "Filnamn:");
gdi.addInput("FileName", file, 30, 0, L"Filnamn:");
gdi.dropLine(0.9);
gdi.addButton("BrowseSplits", "Bläddra...", AutomaticCB);
@ -1027,7 +1030,7 @@ void SplitsMachine::status(gdioutput &gdi)
if (!file.empty()) {
gdi.fillRight();
gdi.pushX();
gdi.addString("", 0, "Fil: X#" + file);
gdi.addString("", 0, L"Fil: X#" + file);
if (interval>0){
gdi.popX();
@ -1064,7 +1067,7 @@ void SaveMachine::status(gdioutput &gdi) {
if (!baseFile.empty()) {
gdi.fillRight();
gdi.pushX();
gdi.addString("", 0, "Destination: X#" + baseFile);
gdi.addString("", 0, L"Destination: X#" + baseFile);
if (interval>0){
gdi.popX();
@ -1085,7 +1088,7 @@ void SaveMachine::status(gdioutput &gdi) {
void SaveMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast) {
if (interval>0 && ast==SyncTimer) {
if (!baseFile.empty()) {
string file = baseFile + "meos_backup_" + oe->getDate() + "_" + itos(saveIter++) + ".xml";
wstring file = baseFile + L"meos_backup_" + oe->getDate() + L"_" + itow(saveIter++) + L".xml";
oe->autoSynchronizeLists(true);
oe->save(file);
}
@ -1094,33 +1097,33 @@ void SaveMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast) {
void SaveMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Säkerhetskopiering");
string time=created ? "10:00" : getTimeMS(interval);
wstring time=created ? L"10:00" : getTimeMSW(interval);
startCancelInterval(gdi, "StartBackup", created, IntervalMinute, time);
int cx = gdi.getCX();
gdi.addInput("BaseFile", baseFile, 32, 0, "Mapp:");
gdi.addInput("BaseFile", baseFile, 32, 0, L"Mapp:");
gdi.dropLine(0.7);
gdi.addButton("BrowseFolder", "Bläddra...", AutomaticCB).setExtra("BaseFile");
gdi.addButton("BrowseFolder", "Bläddra...", AutomaticCB).setExtra(L"BaseFile");
gdi.setCX(cx);
}
void SaveMachine::saveSettings(gdioutput &gdi) {
string minute=gdi.getText("Interval");
wstring minute=gdi.getText("Interval");
int t=convertAbsoluteTimeMS(minute);
if (t<2 || t>7200) {
throw meosException("Intervallet måste anges på formen MM:SS.");
}
string f = gdi.getText("BaseFile");
wstring f = gdi.getText("BaseFile");
if (f.empty()) {
throw meosException("Filnamnet får inte vara tomt");
}
if (*f.rbegin() != '\\' && *f.rbegin() != '/')
f += "\\";
f += L"\\";
string sample = f + "sample.txt";
wstring sample = f + L"sample.txt";
ofstream fout(sample.c_str(), ios_base::trunc|ios_base::out);
bool bad = false;
if (fout.bad())
@ -1129,10 +1132,10 @@ void SaveMachine::saveSettings(gdioutput &gdi) {
fout << "foo" << endl;
fout.close();
bad = fout.bad();
remove(sample.c_str());
_wremove(sample.c_str());
}
if (bad)
throw meosException("Ogiltig destination X#" + f);
throw meosException(L"Ogiltig destination X#" + f);
baseFile = f;
interval = t;

View File

@ -55,7 +55,7 @@ protected:
void settingsTitle(gdioutput &gdi, char *title);
enum IntervalType {IntervalNone, IntervalMinute, IntervalSecond};
void startCancelInterval(gdioutput &gdi, char *startCommand, bool created, IntervalType type, const string &interval);
void startCancelInterval(gdioutput &gdi, char *startCommand, bool created, IntervalType type, const wstring &interval);
public:
static AutoMachine *getMachine(int id);
@ -84,8 +84,8 @@ class PrintResultMachine :
public AutoMachine
{
protected:
string exportFile;
string exportScript;
wstring exportFile;
wstring exportScript;
bool doExport;
bool doPrint;
bool structuredExport;
@ -146,7 +146,7 @@ class SaveMachine :
public AutoMachine
{
protected:
string baseFile;
wstring baseFile;
int saveIter;
public:
SaveMachine *clone() const {
@ -168,7 +168,7 @@ class PrewarningMachine :
public AutoMachine
{
protected:
string waveFolder;
wstring waveFolder;
set<int> controls;
set<int> controlsSI;
public:
@ -184,9 +184,9 @@ class MySQLReconnect :
public AutoMachine
{
protected:
string error;
string timeError;
string timeReconnect;
wstring error;
wstring timeError;
wstring timeReconnect;
HANDLE hThread;
public:
void settings(gdioutput &gdi, oEvent &oe, bool created);
@ -194,7 +194,7 @@ public:
void status(gdioutput &gdi);
void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast);
bool stop();
MySQLReconnect(const string &error);
MySQLReconnect(const wstring &error);
virtual ~MySQLReconnect();
friend class TabAuto;
};
@ -219,7 +219,7 @@ class SplitsMachine :
public AutoMachine
{
protected:
string file;
wstring file;
set<int> classes;
int leg;
public:

File diff suppressed because it is too large Load Diff

View File

@ -61,8 +61,8 @@ class TabClass :
bool EditChanged;
int ClassId;
int currentStage;
string storedNStage;
string storedStart;
wstring storedNStage;
wstring storedStart;
oEvent::PredefinedTypes storedPredefined;
bool showForkingGuide;
@ -85,13 +85,13 @@ class TabClass :
int lastSeedMethod;
bool lastSeedPreventClubNb;
bool lastSeedReverse;
string lastSeedGroups;
wstring lastSeedGroups;
int lastPairSize;
string lastFirstStart;
string lastInterval;
string lastNumVac;
string lastScaleFactor;
string lastMaxAfter;
wstring lastFirstStart;
wstring lastInterval;
wstring lastNumVac;
wstring lastScaleFactor;
wstring lastMaxAfter;
bool lastHandleBibs;
// Generate a table with class settings
@ -108,7 +108,7 @@ class TabClass :
void showClassSelection(gdioutput &gdi, int &bx, int &by, GUICALLBACK classesCB) const;
// Set simultaneous start in a class
void simultaneous(int classId, string time);
void simultaneous(int classId, const wstring &time);
void updateFairForking(gdioutput &gdi, pClass pc) const;
void selectCourses(gdioutput &gdi, int legNo);
@ -116,12 +116,12 @@ class TabClass :
void defineForking(gdioutput &gdi, bool clearSettings);
vector< vector<int> > forkingSetup;
static const char *getCourseLabel(bool pool);
static const wchar_t *getCourseLabel(bool pool);
void getClassSettingsTable(gdioutput &gdi, GUICALLBACK cb);
void saveClassSettingsTable(gdioutput &gdi, set<int> &classModifiedFee, bool &modifiedBib);
static string getBibCode(AutoBibType bt, const string &key);
static wstring getBibCode(AutoBibType bt, const wstring &key);
void setParallelOptions(const string &sdKey, gdioutput &gdi, pClass pc, int legno);
@ -136,7 +136,7 @@ class TabClass :
void readDrawInfo(gdioutput &gdi, DrawInfo &drawInfo);
void writeDrawInfo(gdioutput &gdi, const DrawInfo &drawInfo);
static vector< pair<string, size_t> > getPairOptions();
static vector< pair<wstring, size_t> > getPairOptions();
public:
void clearCompetitionData();

View File

@ -78,12 +78,11 @@ void TabClub::readFeeFilter(gdioutput &gdi) {
gdi.getSelectedItem("ClassType", lbi);
if (lbi.data == -5)
typeS = "*";
typeS = L"*";
else if (lbi.data > 0)
typeS = "::" + itos(lbi.data);
typeS = L"::" + itow(lbi.data);
else
typeS = lbi.text;
}
void TabClub::selectClub(gdioutput &gdi, pClub pc)
@ -123,7 +122,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
if (bi.id=="Save") {
}
else if (bi.id == "EraseClubs") {
if (gdi.ask("Vill du ta bort alla klubbar från tävlingen? Alla deltagare blir klubblösa.")) {
if (gdi.ask(L"Vill du ta bort alla klubbar från tävlingen? Alla deltagare blir klubblösa.")) {
oClub::clearClubs(*oe);
}
}
@ -140,7 +139,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
int pay, paid;
{
map<int, int> ppm;
map<int, string> dpm;
map<int, wstring> dpm;
oClub::definedPayModes(*oe, dpm);
pc->generateInvoice(gdi, pay, paid, dpm, ppm);
}
@ -159,7 +158,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
gdi.clearPage(false);
gdi.addString("", boldLarge, "Skapa fakturor");
gdi.addSelection("Type", 300, 100, 0, "Val av export:");
gdi.addSelection("Type", 300, 100, 0, L"Val av export:");
gdi.addItem("Type", lang.tl("Skriv ut alla"), oEvent::IPTAllPrint);
gdi.addItem("Type", lang.tl("Exportera alla till HTML"), oEvent::IPTAllHTML);
@ -183,7 +182,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
else if (bi.id=="DoAllInvoice") {
ListBoxInfo lbi;
gdi.getSelectedItem("Type", lbi);
string path;
wstring path;
if (lbi.data > 10)
path = gdi.browseForFolder(path, 0);
gdi.clearPage(false);
@ -208,14 +207,17 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
}
}
else if (bi.id=="ImportAnswer") {
vector< pair<string, string> > ft;
ft.push_back(make_pair("Textfiler", "*.txt"));
string file = gdi.browseForOpen(ft, "txt");
vector< pair<wstring, wstring> > ft;
ft.push_back(make_pair(L"Textfiler", L"*.txt"));
wstring file = gdi.browseForOpen(ft, L"txt");
if (!file.empty()) {
gdi.clearPage(true);
try {
importAcceptedInvoice(gdi, file);
}
catch (meosException &ex) {
gdi.addString("", 0, ex.wwhat()).setColor(colorRed);
}
catch (std::exception &ex) {
gdi.addString("", 0, ex.what()).setColor(colorRed);
}
@ -244,7 +246,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
}
else if (bi.id=="Summary") {
gdi.clearPage(false);
string nn;
wstring nn;
oe->printInvoices(gdi, oEvent::IPTAllPrint, nn, true);
gdi.addButton(gdi.getWidth()+20, 15, gdi.scaleLength(120), "Cancel",
"Återgå", ClubsCB, "", true, false);
@ -260,12 +262,12 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
gdi.clearPage(false);
gdi.addString("", boldText, "Slå ihop klubb");
char bf[256];
sprintf_s(bf, lang.tl("help:12352").c_str(), pc->getName().c_str(), pc->getId());
wchar_t bf[256];
swprintf_s(bf, lang.tl("help:12352").c_str(), pc->getName().c_str(), pc->getId());
gdi.addStringUT(10, bf);
gdi.addSelection("NewClub", 200, 300, 0, "Ny klubb:");
gdi.addSelection("NewClub", 200, 300, 0, L"Ny klubb:");
oe->fillClubs(gdi, "NewClub");
gdi.selectItemByData("NewClub", pc->getId());
gdi.removeSelected("NewClub");
@ -302,7 +304,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
if (firstInvoice == 0)
firstInvoice = oe->getPropertyInt("FirstInvoice", 1000);
gdi.addInput("FirstInvoice", itos(firstInvoice), 5, 0, "Första fakturanummer:");
gdi.addInput("FirstInvoice", itow(firstInvoice), 5, 0, L"Första fakturanummer:");
gdi.dropLine();
gdi.addString("", boldText, "Organisatör");
@ -335,12 +337,12 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
gdi.fillRight();
gdi.addString("", 0, "Koordinater (mm) för adressfält:");
string xc = oe->getPropertyString("addressxpos", "125");
string yc = oe->getPropertyString("addressypos", "50");
wstring xc = oe->getPropertyString("addressxpos", L"125");
wstring yc = oe->getPropertyString("addressypos", L"50");
gdi.addStringUT(0, "x:");
gdi.addInput("XC", xc + " [mm]", 6);
gdi.addInput("XC", xc + L" [mm]", 6);
gdi.addStringUT(0, "y:");
gdi.addInput("YC", yc + " [mm]", 6);
gdi.addInput("YC", yc + L" [mm]", 6);
gdi.fillDown();
gdi.popX();
@ -365,7 +367,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
int fn = gdi.getTextNo("FirstInvoice");
if (fn != firstInvoice && oClub::getFirstInvoiceNumber(*oe) > 0) {
if (gdi.ask("Tilldela nya fakturanummer till alla klubbar?")) {
if (gdi.ask(L"Tilldela nya fakturanummer till alla klubbar?")) {
oe->setProperty("FirstInvoice", fn);
oClub::assignInvoiceNumber(*oe, true);
}
@ -393,9 +395,9 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
gdi.dropLine();
gdi.pushX();
gdi.addSelection("ClassType", 150, 300, 0, "Klass / klasstyp:");
vector< pair<string, size_t> > types;
vector< pair<string, size_t> > classes;
gdi.addSelection("ClassType", 150, 300, 0, L"Klass / klasstyp:");
vector< pair<wstring, size_t> > types;
vector< pair<wstring, size_t> > classes;
oe->fillClassTypes(types);
oe->fillClasses(classes, oEvent::extraNone, oEvent::filterNone);
@ -412,9 +414,9 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
gdi.dropLine(-1);
int px = gdi.getCX();
gdi.addInput("BaseFee", oe->formatCurrency(baseFee), 8, 0, "Avgift:");
gdi.addInput("FirstDate", firstDate, 10, 0, "Undre datumgräns:", "ÅÅÅÅ-MM-DD");
gdi.addInput("LastDate", lastDate, 10, 0, "Övre datumgräns:", "ÅÅÅÅ-MM-DD");
gdi.addInput("BaseFee", oe->formatCurrency(baseFee), 8, 0, L"Avgift:");
gdi.addInput("FirstDate", firstDate, 10, 0, L"Undre datumgräns:", L"ÅÅÅÅ-MM-DD");
gdi.addInput("LastDate", lastDate, 10, 0, L"Övre datumgräns:", L"ÅÅÅÅ-MM-DD");
manualFees(gdi, useManualFee);
@ -424,8 +426,8 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
gdi.addCheckbox("FilterAge", "Åldersfilter:", ClubsCB, filterAge);
gdi.dropLine(-1);
gdi.addInput("LowLimit", lowAge > 0 ? itos(lowAge) : "", 5, 0, "Undre gräns (år):");
gdi.addInput("HighLimit", highAge > 0 ? itos(highAge) : "", 5, 0, "Övre gräns (år):");
gdi.addInput("LowLimit", lowAge > 0 ? itow(lowAge) : L"", 5, 0, L"Undre gräns (år):");
gdi.addInput("HighLimit", highAge > 0 ? itow(highAge) : L"", 5, 0, L"Övre gräns (år):");
ageFilter(gdi, filterAge, useManualFee);
gdi.popX();
@ -480,7 +482,7 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
vector<pRunner> filtered;
oe->sortRunners(ClassStartTimeClub);
string fdate, ldate;
wstring fdate, ldate;
int lage = 0, hage = 0;
if (useManualFee) {
@ -526,9 +528,9 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
else
fee = di.getInt("Fee");
string info = filtered[k]->getClass() + ", " + filtered[k]->getCompleteIdentification();
wstring info = filtered[k]->getClass() + L", " + filtered[k]->getCompleteIdentification();
gdi.addStringUT(0, info + " (" + oe->formatCurrency(fee) + ")");
gdi.addStringUT(0, info + L" (" + oe->formatCurrency(fee) + L")");
if (count % 5 == 0)
gdi.dropLine();
}
@ -551,15 +553,15 @@ int TabClub::clubCB(gdioutput &gdi, int type, void *data)
gdi.print(oe);
}
else if (bi.id=="PDF") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Portable Document Format (PDF)", "*.pdf"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Portable Document Format (PDF)", L"*.pdf"));
int index;
string file=gdi.browseForSave(ext, "pdf", index);
wstring file=gdi.browseForSave(ext, L"pdf", index);
if (!file.empty()) {
pdfwriter pdf;
pdf.generatePDF(gdi, gdi.toWide(file), lang.tl("Faktura"), oe->getDCI().getString("Organizer"), gdi.getTL());
pdf.generatePDF(gdi, file, lang.tl("Faktura"), oe->getDCI().getString("Organizer"), gdi.getTL());
gdi.openDoc(file.c_str());
}
}
@ -668,28 +670,28 @@ bool TabClub::loadPage(gdioutput &gdi)
return true;
}
void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
void TabClub::importAcceptedInvoice(gdioutput &gdi, const wstring &file) {
gdi.addString("", boldLarge, "Hämta svar om elektroniska fakturor");
gdi.fillDown();
gdi.dropLine(2);
csvparser csv;
list< vector<string> > data;
list< vector<wstring> > data;
csv.parse(file, data);
list< vector<string> >::iterator it;
map<int, pair<bool, string> > hasAccepted;
list< vector<wstring> >::iterator it;
map<int, pair<bool, wstring> > hasAccepted;
for (it = data.begin(); it != data.end(); ++it) {
if (it->size() == 3) {
int id = atoi((*it)[0].c_str());
bool accepted = trim((*it)[1]) == "OK";
int id = _wtoi((*it)[0].c_str());
bool accepted = trim((*it)[1]) == L"OK";
pClub pc = oe->getClub(id);
if (pc) {
hasAccepted[id].first = accepted;
if ( hasAccepted[id].second.empty())
hasAccepted[id].second = (*it)[2];
else
hasAccepted[id].second += ", " + (*it)[2];
hasAccepted[id].second += L", " + (*it)[2];
}
else
gdi.addString("", 0, "Okänd klubb med id X#" + itos(id)).setColor(colorRed);
@ -707,7 +709,7 @@ void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
bool anyAccepted = false;
int count = 0;
for (size_t k = 0; k < clubs.size(); k++) {
map<int, pair<bool, string> >::iterator res = hasAccepted.find(clubs[k]->getId());
map<int, pair<bool, wstring> >::iterator res = hasAccepted.find(clubs[k]->getId());
if (res != hasAccepted.end() && res->second.first) {
if (!anyAccepted) {
@ -717,10 +719,10 @@ void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
gdi.popX();
anyAccepted = true;
}
clubs[k]->getDI().setString("Invoice", "A");
clubs[k]->getDI().setString("Invoice", L"A");
gdi.addStringUT(0, itos(++count) + ".");
gdi.setCX(margin);
gdi.addStringUT(0, clubs[k]->getName() + ", " + res->second.second);
gdi.addStringUT(0, clubs[k]->getName() + L", " + res->second.second);
gdi.dropLine();
gdi.popX();
}
@ -729,7 +731,7 @@ void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
bool anyNotAccepted = false;
count = 0;
for (size_t k = 0; k < clubs.size(); k++) {
map<int, pair<bool, string> >::iterator res = hasAccepted.find(clubs[k]->getId());
map<int, pair<bool, wstring> >::iterator res = hasAccepted.find(clubs[k]->getId());
if (res != hasAccepted.end() && !res->second.first) {
if (!anyNotAccepted) {
@ -739,10 +741,10 @@ void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
gdi.popX();
anyNotAccepted = true;
}
clubs[k]->getDI().setString("Invoice", "P");
clubs[k]->getDI().setString("Invoice", L"P");
gdi.addStringUT(0, itos(++count) + ".");
gdi.setCX(margin);
gdi.addStringUT(0, clubs[k]->getName() + ", " + res->second.second);
gdi.addStringUT(0, clubs[k]->getName() + L", " + res->second.second);
gdi.dropLine();
gdi.popX();
@ -752,10 +754,10 @@ void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
bool anyNoAnswer = false;
count = 0;
for (size_t k = 0; k < clubs.size(); k++) {
string email = clubs[k]->getDCI().getString("EMail");
wstring email = clubs[k]->getDCI().getString("EMail");
bool hasMail = !email.empty() && email.find_first_of('@') != email.npos;
map<int, pair<bool, string> >::iterator res = hasAccepted.find(clubs[k]->getId());
map<int, pair<bool, wstring> >::iterator res = hasAccepted.find(clubs[k]->getId());
if (res == hasAccepted.end() ) {
if (!anyNoAnswer) {
@ -772,7 +774,7 @@ void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
if (hasMail)
gdi.addStringUT(0, clubs[k]->getName());
else
gdi.addString("", 0, "X (Saknar e-post)#" + clubs[k]->getName());
gdi.addString("", 0, L"X (Saknar e-post)#" + clubs[k]->getName());
gdi.dropLine();
gdi.popX();

View File

@ -28,15 +28,15 @@ class TabClub :
{
int clubCB(gdioutput &gdi, int type, void *data);
string firstDate;
string lastDate;
wstring firstDate;
wstring lastDate;
bool filterAge;
bool onlyNoFee;
bool useManualFee;
int highAge;
int lowAge;
int baseFee;
string typeS;
wstring typeS;
int firstInvoice;
@ -50,7 +50,7 @@ protected:
public:
void selectClub(gdioutput &gdi, pClub pc);
void importAcceptedInvoice(gdioutput &gdi, const string &file);
void importAcceptedInvoice(gdioutput &gdi, const wstring &file);
const char * getTypeStr() const {return "TClubTab";}
TabType getType() const {return TClubTab;}

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,14 @@ class ImportFormats;
class TabCompetition :
public TabBase
{
string eventorBase;
string iofExportVersion;
enum FlowOperation {
FlowContinue,
FlowCancel,
FlowAborted
};
wstring eventorBase;
wstring iofExportVersion;
void textSizeControl(gdioutput &gdi) const;
bool showConnectionPage;
@ -48,14 +54,14 @@ class TabCompetition :
list<PrefsEditor> prefsEditor;
oFreeImport fi;
string entryText;
wstring entryText;
vector<oEntryBlock> entries;
void loadConnectionPage(gdioutput &gdi);
string defaultServer;
string defaultName;
string defaultPwd;
string defaultPort;
wstring defaultServer;
wstring defaultName;
wstring defaultPwd;
wstring defaultPort;
void copyrightLine(gdioutput &gdi) const;
void loadAboutPage(gdioutput &gdi) const;
@ -65,30 +71,30 @@ class TabCompetition :
int lastChangeClassType;
struct {
string name;
string careOf;
string street;
string city;
string zipCode;
string account;
string email;
wstring name;
wstring careOf;
wstring street;
wstring city;
wstring zipCode;
wstring account;
wstring email;
} eventor;
int getOrganizer(bool updateEvent);
void getAPIKey(vector< pair<string, string> > &key) const;
void getAPIKey(vector< pair<wstring, wstring> > &key) const;
void getEventorCompetitions(gdioutput &gdi,
const string &fromDate,
const wstring &fromDate,
vector<CompetitionInfo> &events) const;
void saveSettings(gdioutput &gdi);
void loadSettings(gdioutput &gdi);
void getEventorCmpData(gdioutput &gdi, int id,
const string &eventFile,
const string &clubFile,
const string &classFile,
const string &entryFile,
const string &dbFile) const;
const wstring &eventFile,
const wstring &clubFile,
const wstring &classFile,
const wstring &entryFile,
const wstring &dbFile) const;
void loadMultiEvent(gdioutput &gdi);
void saveMultiEvent(gdioutput &gdi);
@ -117,7 +123,9 @@ class TabCompetition :
void newCompetitionGuide(gdioutput &gdi, int step);
void entryForm(gdioutput &gdi, bool isGuide);
void saveEntries(gdioutput &gdi, bool removeRemoved, bool isGuide);
FlowOperation saveEntries(gdioutput &gdi, bool removeRemoved, bool isGuide);
FlowOperation checkStageFilter(gdioutput &gdi, const wstring &fname, set<int> &filter);
void setExportOptionsStatus(gdioutput &gdi, int format) const;
void selectStartlistOptions(gdioutput &gdi);
@ -137,7 +145,7 @@ public:
void saveMeosFeatures(gdioutput &gdi, bool write);
void updateFeatureStatus(gdioutput &gdi);
void setEventorServer(const string &server);
void setEventorServer(const wstring &server);
void setEventorUTC(bool useUTC);
int competitionCB(gdioutput &gdi, int type, void *data);

View File

@ -59,13 +59,13 @@ void TabControl::selectControl(gdioutput &gdi, pControl pc)
pc->getStatus() == oControl::StatusFinish) {
gdi.selectItemByData("Controls", pc->getId());
gdi.selectItemByData("Status", oControl::StatusOK);
gdi.setText("ControlID", "-", true);
gdi.setText("ControlID", makeDash(L"-"), true);
gdi.setText("Code", "");
gdi.setText("Code", L"");
gdi.setText("Name", pc->getName());
gdi.setText("TimeAdjust", "00:00");
gdi.setText("MinTime", "-");
gdi.setText("Point", "");
gdi.setText("TimeAdjust", L"00:00");
gdi.setText("MinTime", makeDash(L"-"));
gdi.setText("Point", L"");
controlId = pc->getId();
gdi.enableInput("Remove");
@ -88,7 +88,7 @@ void TabControl::selectControl(gdioutput &gdi, pControl pc)
else if (numVisitExp > 0) {
info = "Förväntat antal besökare: X#" + itos(numVisitExp);
}
gdi.setText("ControlID", itos(pc->getId()), true);
gdi.setText("ControlID", itow(pc->getId()), true);
gdi.setText("Info", lang.tl(info), true);
gdi.setText("Code", pc->codeNumbers());
@ -120,14 +120,14 @@ void TabControl::selectControl(gdioutput &gdi, pControl pc)
else {
gdi.selectItemByData("Controls", -1);
gdi.selectItemByData("Status", oControl::StatusOK);
gdi.setText("Code", "");
gdi.setText("Name", "");
gdi.setText("Code", L"");
gdi.setText("Name", L"");
controlId = 0;
gdi.setText("ControlID", "-", true);
gdi.setText("TimeAdjust", "00:00");
gdi.setText("ControlID", makeDash(L"-"), true);
gdi.setText("TimeAdjust", L"00:00");
if (gdi.hasField("Point"))
gdi.setText("Point", "");
gdi.setText("Point", L"");
gdi.disableInput("Remove");
gdi.disableInput("Save");
@ -178,7 +178,7 @@ void TabControl::save(gdioutput &gdi)
pc->setName(gdi.getText("Name"));
pc->synchronize();
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
@ -226,12 +226,12 @@ void TabControl::courseTable(Table &table) const {
table.addRow(ix++, &it);
int row = 0;
table.set(row++, it, TID_ID, itos(it.getId()), false);
table.set(row++, it, TID_ID, itow(it.getId()), false);
table.set(row++, it, TID_MODIFIED, it.getTimeStamp(), false);
table.set(row++, it, TID_COURSE, crs[k]->getName(), false);
table.set(row++, it, TID_INDEX, itos(used), false);
table.set(row++, it, TID_RUNNER, itos(runnersPerCourse[crs[k]->getId()]), false);
table.set(row++, it, TID_INDEX, itow(used), false);
table.set(row++, it, TID_RUNNER, itow(runnersPerCourse[crs[k]->getId()]), false);
}
}
}
@ -280,7 +280,7 @@ void TabControl::visitorTable(Table &table) const {
table.addRow(ix++, &it);
int row = 0;
table.set(row++, it, TID_ID, itos(it.getId()), false);
table.set(row++, it, TID_ID, itow(it.getId()), false);
table.set(row++, it, TID_MODIFIED, it.getTimeStamp(), false);
pRunner r = it.getOwner();
@ -289,8 +289,8 @@ void TabControl::visitorTable(Table &table) const {
table.set(row++, it, TID_COURSE, r->getCourseName(), false);
}
else {
table.set(row++, it, TID_RUNNER, "-", false);
table.set(row++, it, TID_COURSE, "-", false);
table.set(row++, it, TID_RUNNER, L"-", false);
table.set(row++, it, TID_COURSE, L"-", false);
}
table.set(row++, it, TID_FEE, punch->isUsedInCourse() ?
lang.tl("Ja") : lang.tl("Nej"), false);
@ -298,7 +298,7 @@ void TabControl::visitorTable(Table &table) const {
table.set(row++, it, TID_STATUS, punch->getTime(), false);
table.set(row++, it, TID_CONTROL, punch->getType(), false);
table.set(row++, it, TID_CODES, j>0 ? p[j-1]->getType() : "-", true);
table.set(row++, it, TID_CODES, j>0 ? p[j-1]->getType() : L"-", true);
}
}
}
@ -318,11 +318,11 @@ int TabControl::controlCB(gdioutput &gdi, int type, void *data)
pControl pc = oe->getControl(controlId, false);
rogaining = pc && pc->getStatus() == oControl::StatusRogaining;
}
pControl pc = oe->addControl(0,oe->getNextControlNumber(), "");
pControl pc = oe->addControl(0,oe->getNextControlNumber(), L"");
if (rogaining)
pc->setStatus(oControl::StatusRogaining);
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
selectControl(gdi, pc);
@ -340,7 +340,7 @@ int TabControl::controlCB(gdioutput &gdi, int type, void *data)
else
oe->removeControl(cid);
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
selectControl(gdi, 0);
@ -354,7 +354,7 @@ int TabControl::controlCB(gdioutput &gdi, int type, void *data)
else if (bi.id=="Visitors") {
save(gdi);
Table *table=new Table(oe, 20, "Kontroll X#" + itos(controlId), "controlvisitor");
Table *table=new Table(oe, 20, L"Kontroll X#" + itow(controlId), "controlvisitor");
table->addColumn("Id", 70, true, true);
table->addColumn("Ändrad", 70, false);
@ -378,7 +378,7 @@ int TabControl::controlCB(gdioutput &gdi, int type, void *data)
gdi.refresh();
}
else if (bi.id=="Courses") {
Table *table=new Table(oe, 20, "Kontroll X#" + itos(controlId), "controlcourse");
Table *table=new Table(oe, 20, L"Kontroll X#" + itow(controlId), "controlcourse");
table->addColumn("Id", 70, true, true);
table->addColumn("Ändrad", 70, false);
@ -456,7 +456,7 @@ bool TabControl::loadPage(gdioutput &gdi)
gdi.addListBox("Controls", 250, 530, ControlsCB).isEdit(false).ignore(true);
gdi.setTabStops("Controls", 40, 160);
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
@ -472,14 +472,14 @@ bool TabControl::loadPage(gdioutput &gdi)
gdi.popX();
gdi.fillRight();
gdi.addInput("Name", "", 16, 0, "Kontrollnamn:");
gdi.addInput("Name", L"", 16, 0, L"Kontrollnamn:");
gdi.addSelection("Status", 150, 100, ControlsCB, "Status:", "Ange om kontrollen fungerar och hur den ska användas.");
gdi.addSelection("Status", 150, 100, ControlsCB, L"Status:", L"Ange om kontrollen fungerar och hur den ska användas.");
oe->fillControlStatus(gdi, "Status");
gdi.addInput("TimeAdjust", "", 6, 0, "Tidsjustering:");
gdi.addInput("TimeAdjust", L"", 6, 0, L"Tidsjustering:");
gdi.fillDown();
gdi.addInput("MinTime", "", 6, 0, "Minsta sträcktid:");
gdi.addInput("MinTime", L"", 6, 0, L"Minsta sträcktid:");
gdi.popX();
gdi.dropLine(0.5);
@ -488,10 +488,10 @@ bool TabControl::loadPage(gdioutput &gdi)
gdi.fillRight();
gdi.dropLine(0.5);
gdi.addInput("Code", "", 16, 0, "Stämpelkod(er):");
gdi.addInput("Code", L"", 16, 0, L"Stämpelkod(er):");
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Rogaining)) {
gdi.addInput("Point", "", 6, 0, "Rogaining-poäng:");
gdi.addInput("Point", L"", 6, 0, L"Rogaining-poäng:");
}
gdi.popX();
gdi.dropLine(3.5);

View File

@ -60,11 +60,11 @@ void LoadClassPage(gdioutput &gdi);
void TabCourse::selectCourse(gdioutput &gdi, pCourse pc)
{
if (gdi.hasField("Rogaining")) {
gdi.setText("TimeLimit", "");
gdi.setText("TimeLimit", L"");
gdi.disableInput("TimeLimit");
gdi.setText("PointLimit", "");
gdi.setText("PointLimit", L"");
gdi.disableInput("PointLimit");
gdi.setText("PointReduction", "");
gdi.setText("PointReduction", L"");
gdi.disableInput("PointReduction");
gdi.check("ReductionPerMinute", false);
gdi.disableInput("ReductionPerMinute");
@ -74,7 +74,7 @@ void TabCourse::selectCourse(gdioutput &gdi, pCourse pc)
if (pc) {
pc->synchronize();
string uis = pc->getControlsUI();
wstring uis = pc->getControlsUI();
gdi.setText("Controls", uis);
gdi.setText("CourseExpanded", encodeCourse(uis, pc->useFirstAsStart(), pc->useLastAsFinish()), true);
@ -95,16 +95,16 @@ void TabCourse::selectCourse(gdioutput &gdi, pCourse pc)
if ( rt > 0 ) {
gdi.selectItemByData("Rogaining", 1);
gdi.enableInput("TimeLimit");
gdi.setText("TimeLimit", formatTimeHMS(rt));
gdi.setText("TimeLimit", formatTimeHMSW(rt));
gdi.enableInput("PointReduction");
gdi.setText("PointReduction", itos(pc->getRogainingPointsPerMinute()));
gdi.setText("PointReduction", itow(pc->getRogainingPointsPerMinute()));
gdi.enableInput("ReductionPerMinute");
gdi.check("ReductionPerMinute", pc->getDCI().getInt("RReductionMethod") != 0);
}
else if (rp > 0) {
gdi.selectItemByData("Rogaining", 2);
gdi.enableInput("PointLimit");
gdi.setText("PointLimit", itos(rp));
gdi.setText("PointLimit", itow(rp));
}
}
@ -117,11 +117,11 @@ void TabCourse::selectCourse(gdioutput &gdi, pCourse pc)
vector<pClass> cls;
vector<pCourse> crs;
oe->getClasses(cls, true);
string usedInClasses;
wstring usedInClasses;
for (size_t k = 0; k < cls.size(); k++) {
int nleg = max<int>(cls[k]->getNumStages(), 1);
int nlegwithcrs = 0;
vector<string> usage;
vector<wstring> usage;
set<int> allClassCrs;
for (int j = 0; j < nleg; j++) {
cls[k]->getCourses(j, crs);
@ -139,35 +139,35 @@ void TabCourse::selectCourse(gdioutput &gdi, pCourse pc)
}
}
}
string add;
wstring add;
if (usage.size() == nleg ||
usage.size() == nlegwithcrs ||
(usage.size() == nlegwithcrs && nlegwithcrs > 0) ||
(!usage.empty() && allClassCrs.size() == 1)) {
add = cls[k]->getName();
}
else if (!usage.empty()) {
add = cls[k]->getName();
add += " (";
add += L" (";
for (size_t i = 0; i < usage.size(); i++) {
if (i > 0)
add += ", ";
add += L", ";
add += usage[i];
}
add += ")";
add += L")";
}
if (!add.empty()) {
if (!usedInClasses.empty())
usedInClasses += ", ";
usedInClasses += L", ";
usedInClasses += add;
}
}
gdi.setText("CourseUse", usedInClasses, true);
pCourse shortens = pc->getLongerVersion();
if (shortens)
gdi.setTextTranslate("Shortens", "Avkortar: X#" + shortens->getName(), true);
gdi.setTextTranslate("Shortens", L"Avkortar: X#" + shortens->getName(), true);
else
gdi.setText("Shortens", "", true);
gdi.setText("Shortens", L"", true);
gdi.enableEditControls(true);
@ -188,22 +188,22 @@ void TabCourse::selectCourse(gdioutput &gdi, pCourse pc)
}
}
else {
gdi.setText("Name", "");
gdi.setText("Controls", "");
gdi.setText("CourseExpanded", "");
gdi.setText("Name", L"");
gdi.setText("Controls", L"");
gdi.setText("CourseExpanded", L"");
gdi.setText("Length", "");
gdi.setText("Climb", "");
gdi.setText("NumberMaps", "");
gdi.setText("Length", L"");
gdi.setText("Climb", L"");
gdi.setText("NumberMaps", L"");
gdi.check("FirstAsStart", false);
gdi.check("LastAsFinish", false);
courseId = 0;
gdi.disableInput("Remove");
gdi.disableInput("Save");
gdi.selectItemByData("Courses", -1);
gdi.setText("CourseProblem", "", true);
gdi.setText("CourseUse", "", true);
gdi.setText("Shortens", "", true);
gdi.setText("CourseProblem", L"", true);
gdi.setText("CourseUse", L"", true);
gdi.setText("Shortens", L"", true);
gdi.check("WithLoops", false);
gdi.clearList("CommonControl");
gdi.setInputStatus("CommonControl", false);
@ -213,6 +213,7 @@ void TabCourse::selectCourse(gdioutput &gdi, pCourse pc)
gdi.enableEditControls(false);
}
gdi.refreshFast();
gdi.setInputStatus("DrawCourse", pc != 0);
}
@ -228,7 +229,7 @@ void TabCourse::save(gdioutput &gdi, int canSwitchViewMode)
DWORD cid = courseId;
pCourse pc;
string name=gdi.getText("Name");
wstring name=gdi.getText("Name");
if (name.empty()) {
gdi.alert("Banan måste ha ett namn.");
@ -257,13 +258,13 @@ void TabCourse::save(gdioutput &gdi, int canSwitchViewMode)
}
}
if (hasRes) {
firstAsStart = gdi.ask("ask:firstasstart");
firstAsStart = gdi.ask(L"ask:firstasstart");
}
}
pc->setName(name);
bool changedCourse = pc->importControls(gdi.getText("Controls"), true);
bool changedCourse = pc->importControls(gdi.narrow(gdi.getText("Controls")), true);
pc->setLength(gdi.getTextNo("Length"));
pc->getDI().setInt("Climb", gdi.getTextNo("Climb"));
pc->setNumberMaps(gdi.getTextNo("NumberMaps"));
@ -293,8 +294,8 @@ void TabCourse::save(gdioutput &gdi, int canSwitchViewMode)
if (gdi.hasField("Rogaining")) {
string t;
pc->setMaximumRogainingTime(convertAbsoluteTimeMS(gdi.getText("TimeLimit")));
pc->setMinimumRogainingPoints(atoi(gdi.getText("PointLimit").c_str()));
int pr = atoi(gdi.getText("PointReduction").c_str());
pc->setMinimumRogainingPoints(_wtoi(gdi.getText("PointLimit").c_str()));
int pr = _wtoi(gdi.getText("PointReduction").c_str());
pc->setRogainingPointsPerMinute(pr);
if (pr > 0) {
int rmethod = gdi.isChecked("ReductionPerMinute") ? 1 : 0;
@ -309,7 +310,7 @@ void TabCourse::save(gdioutput &gdi, int canSwitchViewMode)
if (canSwitchViewMode != 2 && changedCourse && pc->getLegLengths().size() > 2) {
if (canSwitchViewMode == 1) {
if(gdi.ask("ask:updatelegs")) {
if(gdi.ask(L"ask:updatelegs")) {
gdi.sendCtrlMessage("LegLengths");
return;
}
@ -344,7 +345,7 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
return 0;
}
gdi.clearPage(false);
gdi.addString("", boldLarge, "Redigera sträcklängder för X#" + pc->getName());
gdi.addString("", boldLarge, L"Redigera sträcklängder för X#" + pc->getName());
gdi.dropLine();
int w = gdi.scaleLength(120);
int xp = gdi.getCX() + w;
@ -355,15 +356,15 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
for (int i = 0; i <= pc->getNumControls(); i++) {
int len = pc->getLegLength(i);
pControl cbegin = pc->getControl(i-1);
string begin = i == 0 ? lang.tl("Start") : (cbegin ? cbegin->getName() : "");
wstring begin = i == 0 ? lang.tl("Start") : (cbegin ? cbegin->getName() : L"");
pControl cend = pc->getControl(i);
string end = i == pc->getNumControls() ? lang.tl("Mål") : (cend ? cend->getName() : "");
wstring end = i == pc->getNumControls() ? lang.tl("Mål") : (cend ? cend->getName() : L"");
gdi.pushX();
gdi.fillRight();
gdi.addStringUT(0, begin + MakeDash(" - ") + end + ":").xlimit = w-10;
gdi.addStringUT(0, begin + makeDash(L" - ") + end + L":").xlimit = w-10;
gdi.setCX(xp);
gdi.fillDown();
gdi.addInput("c" + itos(i), len > 0 ? itos(len) : "", 8);
gdi.addInput("c" + itos(i), len > 0 ? itow(len) : L"", 8);
gdi.popX();
if (i < pc->getNumControls()) {
RECT rc;
@ -388,12 +389,12 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
loadPage(gdi);
}
else if (bi.id=="BrowseCourse") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Alla banfiler", "*.xml;*.csv;*.txt"));
ext.push_back(make_pair("Banor, OCAD semikolonseparerat", "*.csv;*.txt"));
ext.push_back(make_pair("Banor, IOF (xml)", "*.xml"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Alla banfiler", L"*.xml;*.csv;*.txt"));
ext.push_back(make_pair(L"Banor, OCAD semikolonseparerat", L"*.csv;*.txt"));
ext.push_back(make_pair(L"Banor, IOF (xml)", L"*.xml"));
string file=gdi.browseForOpen(ext, "csv");
wstring file=gdi.browseForOpen(ext, L"csv");
if (file.length()>0)
gdi.setText("FileName", file);
@ -402,15 +403,15 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
gdi.print(oe);
}
else if (bi.id=="PDF") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Portable Document Format (PDF)", "*.pdf"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Portable Document Format (PDF)", L"*.pdf"));
int index;
string file=gdi.browseForSave(ext, "pdf", index);
wstring file=gdi.browseForSave(ext, L"pdf", index);
if (!file.empty()) {
pdfwriter pdf;
pdf.generatePDF(gdi, gdi.toWide(file), "Report", "MeOS", gdi.getTL());
pdf.generatePDF(gdi, file, L"Report", L"MeOS", gdi.getTL());
gdi.openDoc(file.c_str());
}
}
@ -431,12 +432,12 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
}
else if (bi.id == "ExportCourses") {
int FilterIndex=0;
vector< pair<string, string> > ext;
ext.push_back(make_pair("IOF CourseData, version 3.0 (xml)", "*.xml"));
string save = gdi.browseForSave(ext, "xml", FilterIndex);
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"IOF CourseData, version 3.0 (xml)", L"*.xml"));
wstring save = gdi.browseForSave(ext, L"xml", FilterIndex);
if (save.length()>0) {
IOF30Interface iof30(oe, false);
xmlparser xml(gdi.getEncoding() == ANSI ? 0 : &gdi);
xmlparser xml;
xml.openOutput(save.c_str(), false);
iof30.writeCourses(xml);
xml.closeOut();
@ -446,7 +447,7 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
setupCourseImport(gdi, CourseCB);
}
else if (bi.id=="DoImportCourse") {
string filename = gdi.getText("FileName");
wstring filename = gdi.getText("FileName");
if (filename.empty())
return 0;
gdi.disableInput("DoImportCourse");
@ -475,7 +476,7 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
throw meosException("Ingen bana vald.");
vector<pClass> cls;
oe->getClasses(cls, true);
string clsNames;
wstring clsNames;
bool hasAsked = false;
courseDrawClasses.clear();
for (size_t k = 0; k < cls.size(); k++) {
@ -483,19 +484,19 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
continue;
if (!hasAsked &&oe->classHasResults(cls[k]->getId())) {
hasAsked = true;
if (!gdi.ask("warning:drawresult"))
if (!gdi.ask(L"warning:drawresult"))
return 0;
}
courseDrawClasses.push_back(ClassDrawSpecification(cls[k]->getId(), 0, -1, -1, 0));
if (!clsNames.empty())
clsNames += ", ";
clsNames += L", ";
clsNames += cls[k]->getName();
}
if (courseDrawClasses.empty())
throw meosException("Ingen klass använder banan.");
gdi.clearPage(false);
gdi.addString("", boldLarge, "Lotta klasser med banan X#" + crs->getName());
gdi.addString("", boldLarge, L"Lotta klasser med banan X#" + crs->getName());
gdi.addStringUT(0, clsNames);
gdi.dropLine();
gdi.pushX();
@ -504,13 +505,13 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
int firstStart = 3600;
int interval = 2*60;
int vac = 1;
gdi.addInput("FirstStart", oe->getAbsTime(firstStart), 10, 0, "Första start:");
gdi.addInput("Interval", formatTime(interval), 10, 0, "Startintervall (min):");
gdi.addInput("Vacances", itos(vac), 10, 0, "Antal vakanser:");
gdi.addInput("FirstStart", oe->getAbsTime(firstStart), 10, 0, L"Första start:");
gdi.addInput("Interval", formatTimeW(interval), 10, 0, L"Startintervall (min):");
gdi.addInput("Vacances", itow(vac), 10, 0, L"Antal vakanser:");
gdi.fillDown();
gdi.popX();
gdi.dropLine(3);
gdi.addSelection("Method", 200, 200, 0, "Metod:");
gdi.addSelection("Method", 200, 200, 0, L"Metod:");
gdi.addItem("Method", lang.tl("Lottning"), DMRandom);
gdi.addItem("Method", lang.tl("SOFT-lottning"), DMSOFT);
@ -524,8 +525,8 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
gdi.refresh();
}
else if (bi.id == "DoDrawCourse") {
string firstStart = gdi.getText("FirstStart");
string minInterval = gdi.getText("Interval");
wstring firstStart = gdi.getText("FirstStart");
wstring minInterval = gdi.getText("Interval");
int vacances = gdi.getTextNo("Vacances");
int fs = oe->getRelativeTime(firstStart);
int iv = convertAbsoluteTimeMS(minInterval);
@ -567,8 +568,8 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
}
else if (bi.id=="Add") {
if (courseId>0) {
string ctrl = gdi.getText("Controls");
string name = gdi.getText("Name");
wstring ctrl = gdi.getText("Controls");
wstring name = gdi.getText("Name");
pCourse pc = oe->getCourse(courseId);
if (pc && !name.empty() && !ctrl.empty() && pc->getControlsUI() != ctrl) {
if (name == pc->getName()) {
@ -578,9 +579,9 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
++name[len-1]; // course 1 -> course 2, course 1a -> course 1b
}
else
name += " 2";
name += L" 2";
}
if (gdi.ask("Vill du lägga till banan 'X' (Y)?#" + name + "#" + ctrl)) {
if (gdi.ask(L"Vill du lägga till banan 'X' (Y)?#" + name + L"#" + ctrl)) {
pc = oe->addCourse(name);
courseId = pc->getId();
gdi.setText("Name", name);
@ -630,9 +631,9 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
addedCourse = false;
}
else if (bi.id=="Rogaining") {
string t;
wstring t;
t = gdi.getText("TimeLimit");
if (!t.empty() && t != "-")
if (!t.empty() && _wtoi(t.c_str()) > 0)
time_limit = t;
t = gdi.getText("PointLimit");
if (!t.empty())
@ -641,7 +642,7 @@ int TabCourse::courseCB(gdioutput &gdi, int type, void *data)
if (!t.empty())
point_reduction = t;
string tl, pl, pr;
wstring tl, pl, pr;
if (bi.data == 1) {
tl = time_limit;
pr = point_reduction;
@ -697,9 +698,9 @@ bool TabCourse::loadPage(gdioutput &gdi) {
DWORD ClassID=0, RunnerID=0;
time_limit = "01:00:00";
point_limit = "10";
point_reduction = "1";
time_limit = L"01:00:00";
point_limit = L"10";
point_reduction = L"1";
gdi.getData("ClassID", ClassID);
gdi.getData("RunnerID", RunnerID);
@ -712,7 +713,7 @@ bool TabCourse::loadPage(gdioutput &gdi) {
gdi.pushY();
gdi.fillDown();
gdi.addListBox("Courses", 250, 360, CourseCB, "Banor (antal kontroller)").isEdit(false).ignore(true);
gdi.addListBox("Courses", 250, 360, CourseCB, L"Banor (antal kontroller)").isEdit(false).ignore(true);
gdi.setTabStops("Courses", 240);
oe->fillCourses(gdi, "Courses");
@ -738,9 +739,9 @@ bool TabCourse::loadPage(gdioutput &gdi) {
gdi.dropLine(0.5);
gdi.pushX();
gdi.fillRight();
gdi.addInput("Name", "", 20, 0, "Namn:");
gdi.addInput("Name", L"", 20, 0, L"Namn:");
gdi.fillDown();
gdi.addInput("NumberMaps", "", 6, 0, "Antal kartor:");
gdi.addInput("NumberMaps", L"", 6, 0, L"Antal kartor:");
gdi.popX();
@ -751,7 +752,7 @@ bool TabCourse::loadPage(gdioutput &gdi) {
mlen = max(allCrs[k]->getControlsUI().length()/2+5, mlen);
}
gdi.addInput("Controls", "", max(48u, mlen), CourseCB, "Kontroller:");
gdi.addInput("Controls", L"", max(48u, mlen), CourseCB, L"Kontroller:");
gdi.dropLine(0.3);
gdi.addString("CourseExpanded", 0, "...").setColor(colorDarkGreen);
gdi.dropLine(0.5);
@ -759,8 +760,8 @@ bool TabCourse::loadPage(gdioutput &gdi) {
gdi.dropLine(1);
gdi.fillRight();
gdi.addInput("Climb", "", 8, 0, "Climb (m):");
gdi.addInput("Length", "", 8, 0, "Längd (m):");
gdi.addInput("Climb", L"", 8, 0, L"Climb (m):");
gdi.addInput("Length", L"", 8, 0, L"Längd (m):");
gdi.dropLine(0.9);
gdi.fillDown();
gdi.addButton("LegLengths", "Redigera sträcklängder...", CourseCB).isEdit(true);
@ -779,7 +780,7 @@ bool TabCourse::loadPage(gdioutput &gdi) {
gdi.addString("", 0, "Varvningskontroll:");
gdi.fillDown();
gdi.dropLine(-0.2);
gdi.addSelection("CommonControl", 50, 200, 0, "", "En bana med slingor tillåter deltagaren att ta slingorna i valfri ordning");
gdi.addSelection("CommonControl", 50, 200, 0, L"", L"En bana med slingor tillåter deltagaren att ta slingorna i valfri ordning");
gdi.dropLine(0.2);
gdi.popX();
@ -789,7 +790,7 @@ bool TabCourse::loadPage(gdioutput &gdi) {
gdi.setCX(gdi.getCX()+ gdi.scaleLength(20));
gdi.addString("", 0, "Avkortad banvariant:");
gdi.dropLine(-0.2);
gdi.addSelection("ShortCourse", 150, 200, 0, "", "info_shortening");
gdi.addSelection("ShortCourse", 150, 200, 0, L"", L"info_shortening");
gdi.addString("Shortens", 0, "");
gdi.fillDown();
@ -814,9 +815,9 @@ bool TabCourse::loadPage(gdioutput &gdi) {
gdi.setCX(gdi.getCX()+gdi.scaleLength(20));
gdi.dropLine(-0.8);
int cx = gdi.getCX();
gdi.addInput("PointLimit", "", 8, 0, "Poänggräns:").isEdit(false);
gdi.addInput("TimeLimit", "", 8, 0, "Tidsgräns:").isEdit(false);
gdi.addInput("PointReduction", "", 8, 0, "Poängavdrag (per minut):").isEdit(false);
gdi.addInput("PointLimit", L"", 8, 0, L"Poänggräns:").isEdit(false);
gdi.addInput("TimeLimit", L"", 8, 0, L"Tidsgräns:").isEdit(false);
gdi.addInput("PointReduction", L"", 8, 0, L"Poängavdrag (per minut):").isEdit(false);
gdi.dropLine(3.5);
rc.right = gdi.getCX() + 5;
gdi.setCX(cx);
@ -849,16 +850,16 @@ bool TabCourse::loadPage(gdioutput &gdi) {
return true;
}
void TabCourse::runCourseImport(gdioutput& gdi, const string &filename,
void TabCourse::runCourseImport(gdioutput& gdi, const wstring &filename,
oEvent *oe, bool addClasses) {
csvparser csv;
if (csv.iscsv(filename.c_str())) {
if (csv.iscsv(filename)) {
gdi.fillRight();
gdi.pushX();
gdi.addString("", 0, "Importerar OCAD csv-fil...");
gdi.refreshFast();
if (csv.ImportOCAD_CSV(*oe, filename.c_str(), addClasses)) {
if (csv.importOCAD_CSV(*oe, filename, addClasses)) {
gdi.addString("", 1, "Klart.").setColor(colorGreen);
}
else gdi.addString("", 0, "Operationen misslyckades.").setColor(colorRed);
@ -867,7 +868,8 @@ void TabCourse::runCourseImport(gdioutput& gdi, const string &filename,
gdi.fillDown();
}
else {
oe->importXML_EntryData(gdi, filename.c_str(), addClasses, false);
set<int> noFilter;
oe->importXML_EntryData(gdi, filename.c_str(), addClasses, false, noFilter);
}
if (addClasses) {
// There is specific course-class matching inside the import of each format,
@ -877,7 +879,7 @@ void TabCourse::runCourseImport(gdioutput& gdi, const string &filename,
oe->getClasses(cls, false);
oe->getCourses(crs);
map<string, pCourse> name2Course;
map<wstring, pCourse> name2Course;
map<int, vector<pClass> > course2Class;
for (size_t k = 0; k < crs.size(); k++)
name2Course[crs[k]->getName()] = crs[k];
@ -887,7 +889,7 @@ void TabCourse::runCourseImport(gdioutput& gdi, const string &filename,
cls[k]->getCourses(-1, usedCrs);
if (usedCrs.empty()) {
map<string, pCourse>::iterator res = name2Course.find(cls[k]->getName());
map<wstring, pCourse>::iterator res = name2Course.find(cls[k]->getName());
if (res != name2Course.end()) {
usedCrs.push_back(res->second);
if (cls[k]->getNumStages()==0) {
@ -933,15 +935,15 @@ void TabCourse::runCourseImport(gdioutput& gdi, const string &filename,
for (size_t k = 0; k < cls.size(); k++) {
vector<pCourse> usedCrs;
cls[k]->getCourses(-1, usedCrs);
string c;
wstring c;
for (size_t j = 0; j < usedCrs.size(); j++) {
if (j>0)
c += ", ";
c += L", ";
c += usedCrs[j]->getName();
}
TextInfo &ci = gdi.addStringUT(yp, xp, 0, cls[k]->getName(), w);
if (c.empty()) {
c = MakeDash("-");
c = makeDash(L"-");
ci.setColor(colorRed);
}
gdi.addStringUT(yp, xp + w, 0, c);
@ -952,16 +954,16 @@ void TabCourse::runCourseImport(gdioutput& gdi, const string &filename,
gdi.addString("", 1, "Banor");
yp = gdi.getCY();
for (size_t k = 0; k < crs.size(); k++) {
string c;
wstring c;
vector<pClass> usedCls = course2Class[crs[k]->getId()];
for (size_t j = 0; j < usedCls.size(); j++) {
if (j>0)
c += ", ";
c += L", ";
c += usedCls[j]->getName();
}
TextInfo &ci = gdi.addStringUT(yp, xp, 0, crs[k]->getName(), w);
if (c.empty()) {
c = MakeDash("-");
c = makeDash(L"-");
ci.setColor(colorRed);
}
gdi.addStringUT(yp, xp + w, 0, c);
@ -991,7 +993,7 @@ void TabCourse::setupCourseImport(gdioutput& gdi, GUICALLBACK cb) {
gdi.fillRight();
gdi.pushX();
gdi.addInput("FileName", "", 48, 0, "Filnamn:");
gdi.addInput("FileName", L"", 48, 0, L"Filnamn:");
gdi.dropLine();
gdi.fillDown();
gdi.addButton("BrowseCourse", "Bläddra...", CourseCB);
@ -1011,11 +1013,11 @@ void TabCourse::setupCourseImport(gdioutput& gdi, GUICALLBACK cb) {
gdi.popX();
}
void TabCourse::fillCourseControls(gdioutput &gdi, const string &ctrl) {
void TabCourse::fillCourseControls(gdioutput &gdi, const wstring &ctrl) {
vector<int> nr;
oCourse::splitControls(ctrl, nr);
oCourse::splitControls(gdi.narrow(ctrl), nr);
vector< pair<string, size_t> > item;
vector< pair<wstring, size_t> > item;
map<int, int> used;
for (size_t k = 0; k < nr.size(); k++) {
pControl pc = oe->getControl(nr[k], false);
@ -1032,7 +1034,7 @@ void TabCourse::fillCourseControls(gdioutput &gdi, const string &ctrl) {
for (map<int, int>::iterator it = used.begin(); it != used.end(); ++it) {
if (it->second >= i && !added.count(it->first)) {
added.insert(it->first);
item.push_back(make_pair(itos(it->first), it->first));
item.push_back(make_pair(itow(it->first), it->first));
}
}
}
@ -1042,7 +1044,7 @@ void TabCourse::fillCourseControls(gdioutput &gdi, const string &ctrl) {
}
void TabCourse::fillOtherCourses(gdioutput &gdi, oCourse &crs) {
vector< pair<string, size_t> > ac;
vector< pair<wstring, size_t> > ac;
oe->fillCourses(ac, true);
set<int> skipped;
skipped.insert(crs.getId());
@ -1053,7 +1055,7 @@ void TabCourse::fillOtherCourses(gdioutput &gdi, oCourse &crs) {
longer = longer->getLongerVersion();
}
vector< pair<string, size_t> > out;
vector< pair<wstring, size_t> > out;
for (size_t k = 0; k < ac.size(); k++) {
if (!skipped.count(ac[k].second))
out.push_back(ac[k]);
@ -1069,24 +1071,24 @@ void TabCourse::saveLegLengths(gdioutput &gdi) {
return;
pc->synchronize(false);
string lstr;
wstring lstr;
bool gotAny = false;
for (int i = 0; i <= pc->getNumControls(); i++) {
string t = trim(gdi.getText("c" + itos(i)));
wstring t = trim(gdi.getText("c" + itos(i)));
if (t.empty())
t = "0";
t = L"0";
else
gotAny = true;
if (i == 0)
lstr = t;
else
lstr += ";" + t;
lstr += L";" + t;
}
if (!gotAny)
lstr = "";
lstr = L"";
pc->importLegLengths(lstr, true);
pc->importLegLengths(gdi.narrow(lstr), true);
pc->synchronize(true);
}
@ -1103,25 +1105,28 @@ void TabCourse::clearCompetitionData() {
addedCourse = false;
}
void TabCourse::refreshCourse(const string &text, gdioutput &gdi) {
void TabCourse::refreshCourse(const wstring &text, gdioutput &gdi) {
bool firstAsStart = gdi.isChecked("FirstAsStart");
bool lastAsFinish = gdi.isChecked("LastAsFinish");
string controls = encodeCourse(text, firstAsStart, lastAsFinish);
wstring controls = encodeCourse(text, firstAsStart, lastAsFinish);
if (controls != gdi.getText("CourseExpanded"))
gdi.setText("CourseExpanded", controls, true);
}
string TabCourse::encodeCourse(const string &in, bool firstStart, bool lastFinish) {
wstring TabCourse::encodeCourse(const wstring &in, bool firstStart, bool lastFinish) {
vector<int> newC;
oCourse::splitControls(in, newC);
string dash = MakeDash("-");
string out;
string ins;
wide2String(in, ins);
oCourse::splitControls(ins, newC);
wstring dash = makeDash(L"-");
wstring out;
out.reserve(in.length() * 2);
string bf;
wstring bf;
for (size_t i = 0; i < newC.size(); ++i) {
if (i == 0) {
out += lang.tl("Start");
if (firstStart)
out += "(" + itos(newC[i]) + ")";
out += L"(" + itow(newC[i]) + L")";
else
out += dash + formatControl(newC[i], bf);
@ -1136,7 +1141,7 @@ string TabCourse::encodeCourse(const string &in, bool firstStart, bool lastFinis
if (i+1 == newC.size()) {
if (lastFinish)
out += lang.tl("Mål") + "(" + itos(newC[i]) + ")";
out += lang.tl("Mål") + L"(" + itow(newC[i]) + L")";
else
out += formatControl(newC[i], bf) + dash + lang.tl("Mål");
}
@ -1147,12 +1152,12 @@ string TabCourse::encodeCourse(const string &in, bool firstStart, bool lastFinis
return out;
}
const string &TabCourse::formatControl(int id, string &bf) const {
const wstring &TabCourse::formatControl(int id, wstring &bf) const {
pControl ctrl = oe->getControl(id, false);
if (ctrl) {
bf = ctrl->getString();
return bf;
}
else
return itos(id);
return itow(id);
}

View File

@ -35,11 +35,11 @@ class TabCourse :
int courseCB(gdioutput &gdi, int type, void *data);
bool addedCourse;
string time_limit;
string point_limit;
string point_reduction;
wstring time_limit;
wstring point_limit;
wstring point_reduction;
void fillCourseControls(gdioutput &gdi, const string &ctrl);
void fillCourseControls(gdioutput &gdi, const wstring &ctrl);
void fillOtherCourses(gdioutput &gdi, oCourse &crs);
void saveLegLengths(gdioutput &gdi);
@ -48,10 +48,10 @@ class TabCourse :
DrawMethod getDefaultMethod() const;
string encodeCourse(const string &in, bool firstStart, bool lastFinish);
void refreshCourse(const string &text, gdioutput &gdi);
wstring encodeCourse(const wstring &in, bool firstStart, bool lastFinish);
void refreshCourse(const wstring &text, gdioutput &gdi);
const string &formatControl(int id, string &bf) const;
const wstring &formatControl(int id, wstring &bf) const;
protected:
void clearCompetitionData();
@ -68,7 +68,7 @@ public:
TabCourse(oEvent *oe);
~TabCourse(void);
static void runCourseImport(gdioutput& gdi, const string &filename,
static void runCourseImport(gdioutput& gdi, const wstring &filename,
oEvent *oe, bool addClasses);
static void setupCourseImport(gdioutput& gdi, GUICALLBACK cb);

View File

@ -134,7 +134,7 @@ int NoStartRunnerCB(gdioutput *gdi, int type, void *data)
ti->highlight=false;
ti->active=false;
ti->color=RGB(255,0,0);
gdi->setText(ti->id, "Ej start", true);
gdi->setText(ti->id, L"Ej start", true);
}
}
return 0;
@ -213,8 +213,8 @@ void TabList::generateList(gdioutput &gdi)
oe->generateList(gdi, !noReEvaluate, currentList, false);
}
catch (const meosException &ex) {
string err = lang.tl(ex.what());
gdi.addString("", 1, "List Error: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 1, L"List Error: X#" + err).setColor(colorRed);
}
gdi.setOffset(oX, oY, false);
@ -300,37 +300,38 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
gdi.print(oe);
}
else if (bi.id=="HTML") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Strukturerat webbdokument (html)", "*.html;*.htm"));
ext.push_back(make_pair("Formaterat webbdokument (html)", "*.html;*.htm"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Strukturerat webbdokument (html)", L"*.html;*.htm"));
ext.push_back(make_pair(L"Formaterat webbdokument (html)", L"*.html;*.htm"));
string file=gdi.browseForSave(ext, "html", index);
wstring file=gdi.browseForSave(ext, L"html", index);
if (!file.empty()) {
if (index == 1)
gdi.writeTableHTML(gdi.toWide(file), oe->getName(), 0);
gdi.writeTableHTML(file, oe->getName(), 0);
else {
assert(index == 2);
gdi.writeHTML(gdi.toWide(file), oe->getName(), 0);
gdi.writeHTML(file, oe->getName(), 0);
}
gdi.openDoc(file.c_str());
}
}
else if (bi.id=="Copy") {
ostringstream fout;
gdi.writeTableHTML(fout, "MeOS", true, 0);
gdi.writeTableHTML(fout, L"MeOS", true, 0);
string res = fout.str();
gdi.copyToClipboard(res, false, "");
gdi.copyToClipboard(res, L"");
}
else if (bi.id=="PDF") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Portable Document Format (PDF)", "*.pdf"));
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Portable Document Format (PDF)", L"*.pdf"));
string file=gdi.browseForSave(ext, "pdf", index);
wstring file=gdi.browseForSave(ext, L"pdf", index);
if (!file.empty()) {
pdfwriter pdf;
pdf.generatePDF(gdi, gdi.toWide(file), oe->getName() + ", " + currentList.getName(), oe->getDCI().getString("Organizer"), gdi.getTL());
pdf.generatePDF(gdi, file, oe->getName() + L", " + currentList.getName(),
oe->getDCI().getString("Organizer"), gdi.getTL());
gdi.openDoc(file.c_str());
}
}
@ -339,7 +340,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
gdioutput *gdi_new;
TabList *tl_new = this;
if (!ownWindow) {
gdi_new = createExtraWindow(uniqueTag("list"), MakeDash("MeOS - " + currentList.getName()), gdi.getWidth() + 64 + gdi.scaleLength(120));
gdi_new = createExtraWindow(uniqueTag("list"), makeDash(L"MeOS - ") + currentList.getName(), gdi.getWidth() + 64 + gdi.scaleLength(120));
if (gdi_new) {
TabList &tl = dynamic_cast<TabList &>(*gdi_new->getTabs().get(TListTab));
tl.currentList = currentList;
@ -377,7 +378,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
}
else if (bi.id == "Remember") {
oListParam &par = currentList.getParam();
string baseName = par.getDefaultName();
wstring baseName = par.getDefaultName();
baseName = oe->getListContainer().makeUniqueParamName(baseName);
par.setName(baseName);
oe->synchronize(false);
@ -399,7 +400,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
if (gdi.getSelectedItem("SavedInstance", lbi)) {
const oListParam &par = oe->getListContainer().getParam(lbi.data);
gdi.clearPage(true);
gdi.addString("", boldLarge, "Döp om X#" + par.getName());
gdi.addString("", boldLarge, L"Döp om X#" + par.getName());
gdi.setData("ParamIx", lbi.data);
gdi.dropLine();
gdi.fillRight();
@ -413,7 +414,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
else if (bi.id == "DoRenameSaved") {
int ix = int(gdi.getData("ParamIx"));
oListParam &par = oe->getListContainer().getParam(ix);
string name = gdi.getText("Name");
wstring name = gdi.getText("Name");
par.setName(name);
loadPage(gdi);
}
@ -423,11 +424,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
//oe->getListContainer().mergeParam(0, lbi.data);
const oListParam &par = oe->getListContainer().getParam(lbi.data);
gdi.clearPage(true);
gdi.addString("", boldLarge, "Slå ihop X#" + par.getName());
gdi.addString("", boldLarge, L"Slå ihop X#" + par.getName());
gdi.setData("ParamIx", lbi.data);
gdi.dropLine();
gdi.addListBox("Merge", 350, 250, 0, "Slå ihop med:");
vector < pair<string, size_t> > cand;
gdi.addListBox("Merge", 350, 250, 0, L"Slå ihop med:");
vector < pair<wstring, size_t> > cand;
oe->getListContainer().getMergeCandidates(lbi.data, cand);
gdi.addItem("Merge", cand);
gdi.addCheckbox("ShowTitle", "Visa rubrik mellan listorna", 0, false);
@ -558,7 +559,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
lastResultClassSelection = par.selection;
par.filterMaxPer = gdi.getTextNo("ClassLimit");
par.inputNumber = gdi.getTextNo("InputNumber");
lastInputNumber = itos(par.inputNumber);
lastInputNumber = itow(par.inputNumber);
par.pageBreak = gdi.isChecked("PageBreak");
par.listCode = (EStdListType)currentListType;
@ -981,7 +982,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
else if (bi.id == "ImportCustom") {
MetaListContainer &lc = oe->getListContainer();
vector< pair<string, int> > installedLists;
vector< pair<wstring, int> > installedLists;
set<string> installedId;
for (int k = 0; k < lc.getNumLists(); k++) {
if (lc.isExternal(k)) {
@ -993,7 +994,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
}
}
vector< pair<string, pair<string, string> > > lists;
vector< pair<wstring, pair<string, wstring> > > lists;
lc.enumerateLists(lists);
if (lists.empty() && installedLists.empty()) {
bi.id = "BrowseList";
@ -1061,11 +1062,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
gdi.refresh();
}
else if (bi.id == "BrowseList") {
vector< pair<string, string> > filter;
filter.push_back(make_pair("xml-data", "*.xml;*.meoslist"));
string file = gdi.browseForOpen(filter, "xml");
vector< pair<wstring, wstring> > filter;
filter.push_back(make_pair(L"xml-data", L"*.xml;*.meoslist"));
wstring file = gdi.browseForOpen(filter, L"xml");
if (!file.empty()) {
xmlparser xml(0);
xmlparser xml;
xml.read(file);
xmlobject xlist = xml.getObject(0);
oe->synchronize();
@ -1075,13 +1076,6 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
loadPage(gdi);
}
}
else if (bi.id == "ResultListFT_ONATT") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Semikolonseparerad", "*.csv;*.txt"));
string file=gdi.browseForSave(ext, "txt", index);
if (!file.empty())
oe->exportONattResults(gdi, file);
}
else if (bi.id == "EditInForest") {
TabRunner &rt = dynamic_cast<TabRunner &>(*gdi.getTabs().get(TRunnerTab));
rt.showInForestList(gdi);
@ -1140,11 +1134,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
else if (type == GUI_LINK) {
TextInfo ti = *(TextInfo *)data;
if (ti.id == "CustomList") {
vector< pair<string, pair<string, string> > > lists;
vector< pair<wstring, pair<string, wstring> > > lists;
oe->getListContainer().enumerateLists(lists);
size_t ix = ti.getExtraSize();
if (ix < lists.size()) {
xmlparser xml(0);
xmlparser xml;
xml.read(lists[ix].second.second);
xmlobject xlist = xml.getObject(0);
@ -1159,11 +1153,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
}
else if (ti.id == "RemoveList") {
vector< pair<string, pair<string, string> > > lists;
vector< pair<wstring, pair<string, wstring> > > lists;
oe->getListContainer().enumerateLists(lists);
size_t ix = ti.getExtraSize();
if (ix < lists.size()) {
if (gdi.ask("Vill du ta bort 'X'?#" + lists[ix].first)) {
if (gdi.ask(L"Vill du ta bort 'X'?#" + lists[ix].first)) {
DeleteFile(lists[ix].second.second.c_str());
}
}
@ -1173,7 +1167,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
}
else if (ti.id == "RemoveInstalled") {
int ix = ti.getExtraInt();
if (gdi.ask("Vill du ta bort 'X'?#" + oe->getListContainer().getList(ix).getListName())) {
if (gdi.ask(L"Vill du ta bort 'X'?#" + oe->getListContainer().getList(ix).getListName())) {
oe->synchronize(false);
oe->getListContainer().removeList(ix);
@ -1199,12 +1193,12 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
}
void TabList::enableFromTo(oEvent &oe, gdioutput &gdi, bool from, bool to) {
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
oe.fillControls(d, oEvent::CTCourseControl);
if (from) {
gdi.enableInput("ResultSpecialFrom");
vector< pair<string, size_t> > ds;
vector< pair<wstring, size_t> > ds;
ds.push_back(make_pair(lang.tl("Start"), 0));
ds.insert(ds.end(), d.begin(), d.end());
gdi.addItem("ResultSpecialFrom", ds);
@ -1261,7 +1255,7 @@ void TabList::selectGeneralList(gdioutput &gdi, EStdListType type)
//gdi.enableInput("LegNumber");
//oe->fillLegNumbers(gdi, "LegNumber", li.isTeamList(), true);
set<int> clsUnused;
vector< pair<string, size_t> > out;
vector< pair<wstring, size_t> > out;
oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out);
gdi.addItem("LegNumber", out);
gdi.setInputStatus("LegNumber", !out.empty());
@ -1276,7 +1270,7 @@ void TabList::selectGeneralList(gdioutput &gdi, EStdListType type)
void TabList::makeClassSelection(gdioutput &gdi) {
gdi.fillDown();
gdi.addListBox("ListSelection", 250, 300, ListsCB, "Urval:", "", true);
gdi.addListBox("ListSelection", 250, 300, ListsCB, L"Urval:", L"", true);
gdi.pushX();
gdi.fillRight();
@ -1295,7 +1289,7 @@ void TabList::loadGeneralList(gdioutput &gdi)
gdi.addString("", boldLarge, "Skapa generell lista");
gdi.dropLine(0.8);
gdi.pushY();
gdi.addSelection("ListType", 250, 300, ListsCB, "Lista:");
gdi.addSelection("ListType", 250, 300, ListsCB, L"Lista:");
oe->fillListTypes(gdi, "ListType", 0);
makeClassSelection(gdi);
@ -1313,11 +1307,11 @@ void TabList::loadGeneralList(gdioutput &gdi)
if (lastLimitPer == -1) {
lastLimitPer = oe->getPropertyInt("classlimit", 0);
}
string lastClassLimit;
wstring lastClassLimit;
if (lastLimitPer > 0)
lastClassLimit = itos(lastLimitPer);
lastClassLimit = itow(lastLimitPer);
gdi.addInput("ClassLimit", lastClassLimit, 5, 0, "Begränsa antal per klass:");
gdi.addInput("ClassLimit", lastClassLimit, 5, 0, L"Begränsa antal per klass:");
gdi.dropLine();
makeFromTo(gdi);
@ -1333,10 +1327,10 @@ void TabList::loadGeneralList(gdioutput &gdi)
gdi.popX();
gdi.dropLine(3);
*/
gdi.addSelection("LegNumber", 140, 300, ListsCB, "Sträcka:");
gdi.addSelection("LegNumber", 140, 300, ListsCB, L"Sträcka:");
gdi.disableInput("LegNumber");
gdi.addInput("InputNumber", lastInputNumber, 5, 0, "Listparameter:", "Ett värde vars tolkning beror på listan.");
gdi.addInput("InputNumber", lastInputNumber, 5, 0, L"Listparameter:", L"Ett värde vars tolkning beror på listan.");
gdi.disableInput("InputNumber");
gdi.popX();
@ -1347,7 +1341,7 @@ void TabList::loadGeneralList(gdioutput &gdi)
gdi.dropLine(3);
gdi.addInput("Title", "", 32, ListsCB, "Egen listrubrik:");
gdi.addInput("Title", L"", 32, ListsCB, L"Egen listrubrik:");
gdi.dropLine();
gdi.fillRight();
@ -1372,10 +1366,10 @@ void TabList::makeFromTo(gdioutput &gdi) {
gdi.fillRight();
gdi.pushX();
gdi.addSelection("ResultSpecialFrom", 140, 300, ListsCB, "Från kontroll:");
gdi.addSelection("ResultSpecialFrom", 140, 300, ListsCB, L"Från kontroll:");
gdi.disableInput("ResultSpecialFrom");
gdi.addSelection("ResultSpecialTo", 140, 300, ListsCB, "Till kontroll:");
gdi.addSelection("ResultSpecialTo", 140, 300, ListsCB, L"Till kontroll:");
gdi.disableInput("ResultSpecialTo");
gdi.popX();
@ -1388,14 +1382,14 @@ void TabList::settingsResultList(gdioutput &gdi)
oe->sanityCheck(gdi, true);
gdi.fillDown();
gdi.clearPage(false);
gdi.addString("", boldLarge, MakeDash("Resultatlista - inställningar"));
gdi.addString("", boldLarge, makeDash(L"Resultatlista - inställningar"));
//gdi.addSelection("ListType", 200, 300, ListsCB, "Lista");
//oe->fillListTypes(gdi, "ListType", 0);
const int boxHeight = 380;
gdi.pushY();
gdi.fillDown();
gdi.addListBox("ListSelection", 200, boxHeight, ListsCB, "Urval:", "", true);
gdi.addListBox("ListSelection", 200, boxHeight, ListsCB, L"Urval:", L"", true);
gdi.dropLine(0.5);
gdi.fillRight();
@ -1414,8 +1408,8 @@ void TabList::settingsResultList(gdioutput &gdi)
gdi.addListBox("ResultType", 180, boxHeight, ListsCB);
vector< pair<string, size_t> > lists;
vector< pair<string, size_t> > dlists;
vector< pair<wstring, size_t> > lists;
vector< pair<wstring, size_t> > dlists;
const MetaListContainer &lc = oe->getListContainer();
lc.getLists(dlists, false, true, !oe->hasTeam());
set<int> usedListIx;
@ -1427,20 +1421,20 @@ void TabList::settingsResultList(gdioutput &gdi)
}
lists.reserve(dlists.size() + 10);
lists.push_back(make_pair(lang.tl("Individuell"), 1));
lists.push_back(make_pair(lang.tl(L"Individuell"), 1));
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Patrol))
lists.push_back(make_pair(lang.tl("Patrull"), 2));
lists.push_back(make_pair(lang.tl(L"Patrull"), 2));
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Relay)) {
lists.push_back(make_pair(lang.tl("Stafett - total"), 3));
lists.push_back(make_pair(lang.tl("Stafett - sammanställning"), 4));
lists.push_back(make_pair(lang.tl(L"Stafett - total"), 3));
lists.push_back(make_pair(lang.tl(L"Stafett - sammanställning"), 4));
lists.push_back(make_pair(lang.tl("Stafett - sträcka"),
lists.push_back(make_pair(lang.tl(L"Stafett - sträcka"),
getListIx(tag2ListIx, usedListIx, "legresult", 5)));
}
lists.push_back(make_pair(lang.tl("Allmänna resultat"), 6));
lists.push_back(make_pair(lang.tl(L"Allmänna resultat"), 6));
size_t startIx = lists.size();
for (size_t k = 0; k < dlists.size(); k++) {
@ -1479,28 +1473,28 @@ void TabList::settingsResultList(gdioutput &gdi)
if (lastLimitPer == -1) {
lastLimitPer = oe->getPropertyInt("classlimit", 0);
}
string lastClassLimit;
wstring lastClassLimit;
if (lastLimitPer > 0)
lastClassLimit = itos(lastLimitPer);
lastClassLimit = itow(lastLimitPer);
gdi.addInput("ClassLimit", lastClassLimit, 5, 0);
gdi.popX();
gdi.dropLine(2);
gdi.addString("", 0, "Listparameter:");
gdi.dropLine(-0.2);
gdi.addInput("InputNumber", lastInputNumber, 5, 0, "", "Ett värde vars tolkning beror på listan.");
gdi.addInput("InputNumber", lastInputNumber, 5, 0, L"", L"Ett värde vars tolkning beror på listan.");
gdi.disableInput("InputNumber");
gdi.popX();
gdi.dropLine(2);
makeFromTo(gdi);
gdi.addSelection("LegNumber", 140, 300, ListsCB, "Sträcka:");
gdi.addSelection("LegNumber", 140, 300, ListsCB, L"Sträcka:");
gdi.disableInput("LegNumber");
gdi.popX();
gdi.dropLine(3);
gdi.addInput("Title", "", 32, ListsCB, "Egen listrubrik:");
gdi.addInput("Title", L"", 32, ListsCB, L"Egen listrubrik:");
gdi.popX();
gdi.dropLine(3.5);
@ -1694,7 +1688,7 @@ bool TabList::loadPage(gdioutput &gdi)
gdi.dropLine(3);
gdi.fillDown();
vector< pair<string, size_t> > savedParams;
vector< pair<wstring, size_t> > savedParams;
lc.getListParam(savedParams);
if (savedParams.size() > 0) {
gdi.addString("", 1, "Sparade listval");
@ -1788,7 +1782,7 @@ bool TabList::loadPage(gdioutput &gdi)
int v = k;
if (v>12)
v=(v-11)*10;
gdi.addItem("ClassLimit", itos(v), v);
gdi.addItem("ClassLimit", itow(v), v);
}
gdi.selectItemByData("ClassLimit", oe->getPropertyInt("classlimit", 0));
@ -1867,15 +1861,15 @@ void TabList::splitPrintSettings(oEvent &oe, gdioutput &gdi, bool setupPrinter,
if (returnMode == TSITab) {
int printLen = oe.getPropertyInt("NumSplitsOnePage", 3);
vector< pair<string, size_t> > nsp;
vector< pair<wstring, size_t> > nsp;
for (size_t j = 1; j < 8; j++)
nsp.push_back(make_pair(itos(j), j));
gdi.addSelection("NumPerPage", 90, 200, ListsCB, "Max antal brickor per sida");
nsp.push_back(make_pair(itow(j), j));
gdi.addSelection("NumPerPage", 90, 200, ListsCB, L"Max antal brickor per sida");
gdi.addItem("NumPerPage", nsp);
gdi.selectItemByData("NumPerPage", printLen);
int maxWait = oe.getPropertyInt("SplitPrintMaxWait", 60);
gdi.addInput("MaxWaitTime", itos(maxWait), 8, 0, "Längsta tid i sekunder att vänta med utskrift");
gdi.addInput("MaxWaitTime", itow(maxWait), 8, 0, L"Längsta tid i sekunder att vänta med utskrift");
enableWideFormat(gdi, wideFormat);
}
@ -1891,13 +1885,13 @@ void TabList::splitPrintSettings(oEvent &oe, gdioutput &gdi, bool setupPrinter,
}
void TabList::saveExtraLines(oEvent &oe, const char *dataField, gdioutput &gdi) {
vector< pair<string, int> > lines;
vector< pair<wstring, int> > lines;
for (int k = 0; k < 5; k++) {
string row = "row"+itos(k);
string key = "font"+itos(k);
ListBoxInfo lbi;
gdi.getSelectedItem(key, lbi);
string r = gdi.getText(row);
wstring r = gdi.getText(row);
lines.push_back(make_pair(r, lbi.data));
}
oe.setExtraLines(dataField, lines);
@ -1907,8 +1901,8 @@ void TabList::customTextLines(oEvent &oe, const char *dataField, gdioutput &gdi)
gdi.dropLine(2.5);
gdi.addString("", boldText, "Egna textrader");
vector< pair<string, size_t> > fonts;
vector< pair<string, int> > lines;
vector< pair<wstring, size_t> > fonts;
vector< pair<wstring, int> > lines;
MetaListPost::getAllFonts(fonts);
oe.getExtraLines(dataField, lines);
@ -1917,7 +1911,7 @@ void TabList::customTextLines(oEvent &oe, const char *dataField, gdioutput &gdi)
gdi.fillRight();
gdi.pushX();
string row = "row"+itos(k);
gdi.addInput(row, "", 24);
gdi.addInput(row, L"", 24);
string key = "font"+itos(k);
gdi.addSelection(key, 100, 100);
gdi.addItem(key, fonts);
@ -1968,7 +1962,7 @@ EStdListType TabList::getTypeFromResultIndex(int ix) const {
void TabList::setResultOptionsFromType(gdioutput &gdi, int data) {
bool builtIn = data < CUSTOM_OFFSET;
string info, title;
wstring info, title;
bool hasResMod = false;
oListInfo li;
EStdListType type = getTypeFromResultIndex(data);
@ -1993,7 +1987,7 @@ void TabList::setResultOptionsFromType(gdioutput &gdi, int data) {
set<int> clsUnused;
vector< pair<string, size_t> > out;
vector< pair<wstring, size_t> > out;
oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out);
gdi.addItem("LegNumber", out);
@ -2019,7 +2013,7 @@ void TabList::setResultOptionsFromType(gdioutput &gdi, int data) {
gdi.enableInput("LegNumber");
//oe->fillLegNumbers(gdi, "LegNumber", li.isTeamList(), true);
set<int> clsUnused;
vector< pair<string, size_t> > out;
vector< pair<wstring, size_t> > out;
oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out);
gdi.addItem("LegNumber", out);
if (!out.empty() && lastLeg >= 0)

View File

@ -34,7 +34,7 @@ protected:
EStdListType currentListType;
oListInfo currentList;
string SelectedList;
string lastInputNumber;
wstring lastInputNumber;
int lastLimitPer;
bool lastInterResult;
bool lastSplitState;

View File

@ -107,21 +107,21 @@ void TabRunner::enableControlButtons(gdioutput &gdi, bool enable, bool vacant)
void TabRunner::selectRunner(gdioutput &gdi, pRunner r) {
if (!r) {
runnerId=0;
gdi.setText("Name", "");
gdi.setText("Bib", "");
gdi.setText("Name", L"");
gdi.setText("Bib", L"");
gdi.selectItemByData("RCourse", 0);
updateNumShort(gdi, 0, 0);
//Don't clear club and class
gdi.setText("CardNo", "");
gdi.setText("CardNo", L"");
gdi.enableInput("Start");
gdi.setText("Start", "-");
gdi.setText("Start", makeDash(L"-"));
gdi.enableInput("Finish");
gdi.setText("Finish", "-");
gdi.setText("Finish", makeDash(L"-"));
gdi.setText("Time", "-");
gdi.setText("Points", "");
gdi.setText("Time", makeDash(L"-"));
gdi.setText("Points", L"");
gdi.selectItemByData("Status", 0);
gdi.clearList("Punches");
@ -139,17 +139,17 @@ void TabRunner::selectRunner(gdioutput &gdi, pRunner r) {
if (gdi.hasField("EditTeam"))
gdi.disableInput("EditTeam");
gdi.setText("RunnerInfo", "", true);
gdi.setText("RunnerInfo", L"", true);
gdi.setText("TimeAdjust", "-");
gdi.setText("PointAdjust", "");
gdi.setText("TimeAdjust", makeDash(L"-"));
gdi.setText("PointAdjust", L"");
if (gdi.hasField("StatusIn")) {
gdi.selectFirstItem("StatusIn");
gdi.setText("PlaceIn", "");
gdi.setText("TimeIn", "-");
gdi.setText("PlaceIn", L"");
gdi.setText("TimeIn", makeDash(L"-"));
if (gdi.hasField("PointIn"))
gdi.setText("PointIn", "");
gdi.setText("PointIn", L"");
}
return;
@ -175,7 +175,7 @@ void TabRunner::selectRunner(gdioutput &gdi, pRunner r) {
runnerId=r->getId();
gdi.setText("Name", r->getNameRaw());
string bib = r->getBib();
wstring bib = r->getBib();
if (gdi.hasField("Bib")) {
gdi.setText("Bib", bib);
@ -196,10 +196,10 @@ void TabRunner::selectRunner(gdioutput &gdi, pRunner r) {
gdi.setText("Team", r->getTeam()->getName());
}
else
gdi.setText("Team", "");
gdi.setText("Team", L"");
}
gdi.setText("TimeAdjust", getTimeMS(r->getTimeAdjustment()));
gdi.setText("TimeAdjust", getTimeMSW(r->getTimeAdjustment()));
gdi.setText("PointAdjust", -r->getPointAdjustment());
#ifdef _DEBUG
@ -248,25 +248,23 @@ void TabRunner::selectRunner(gdioutput &gdi, pRunner r) {
lastRace=0;
}
else {
char bf[32];
gdi.clearList("MultiR");
gdi.enableInput("MultiR");
for (int k=0;k<numMulti+1;k++) {
sprintf_s(bf, lang.tl("Lopp %d").c_str(), k+1);
gdi.addItem("MultiR", bf, k);
gdi.addItem("MultiR", lang.tl("Lopp X#" + itos(k+1)), k);
}
gdi.selectItemByData("MultiR", r->getRaceNo());
}
}
oe->fillCourses(gdi, "RCourse", true);
string crsName = r->getCourse(false) ? r->getCourse(false)->getName() + " " : "";
wstring crsName = r->getCourse(false) ? r->getCourse(false)->getName() + L" " : L"";
gdi.addItem("RCourse", crsName + lang.tl("[Klassens bana]"), 0);
gdi.selectItemByData("RCourse", r->getCourseId());
updateNumShort(gdi, r->getCourse(false), r);
int cno = parent->getCardNo();
gdi.setText("CardNo", cno>0 ? itos(cno) : "");
gdi.setText("CardNo", cno>0 ? itow(cno) : L"");
warnDuplicateCard(gdi, cno, r);
@ -300,7 +298,7 @@ void TabRunner::selectRunner(gdioutput &gdi, pRunner r) {
gdi.setInputStatus("Finish", canSetFinish(r));
gdi.setText("Time", r->getRunningTimeS());
gdi.setText("Points", itos(r->getRogainingPoints(false)));
gdi.setText("Points", itow(r->getRogainingPoints(false)));
gdi.selectItemByData("Status", r->getStatus());
gdi.setText("RunnerInfo", lang.tl(r->getProblemDescription()), true);
@ -311,7 +309,7 @@ void TabRunner::selectRunner(gdioutput &gdi, pRunner r) {
if (ip > 0)
gdi.setText("PlaceIn", ip);
else
gdi.setText("PlaceIn", MakeDash("-"));
gdi.setText("PlaceIn", makeDash(L"-"));
gdi.setText("TimeIn", r->getInputTimeS());
if (gdi.hasField("PointIn"))
@ -370,7 +368,7 @@ int runnerSearchCB(gdioutput *gdi, int type, void *data)
int TabRunner::searchCB(gdioutput &gdi, int type, void *data) {
static DWORD editTick = 0;
string expr;
wstring expr;
bool showNow = false;
bool filterMore = false;
@ -386,7 +384,7 @@ int TabRunner::searchCB(gdioutput &gdi, int type, void *data) {
if (timeToFill < 50 || (filterMore && (timeToFill * lastFilter.size())/nr < 50))
showNow = true;
else {// Delay filter
gdi.addTimeoutMilli(500, "Search: " + expr, runnerSearchCB).setExtra((void *)inputId);
gdi.addTimeoutMilli(500, "Search", runnerSearchCB).setData(inputId, expr);
}
}
}
@ -394,10 +392,10 @@ int TabRunner::searchCB(gdioutput &gdi, int type, void *data) {
TimerInfo &ti = *(TimerInfo *)(data);
if (inputId != int(ti.getExtra()))
if (inputId != ti.getData())
return 0;
expr = ti.id.substr(8);
expr = ti.getDataString();
filterMore = expr.length() > lastSearchExpr.length() &&
expr.substr(0, lastSearchExpr.length()) == lastSearchExpr;
showNow = true;
@ -415,12 +413,12 @@ int TabRunner::searchCB(gdioutput &gdi, int type, void *data) {
InputInfo &ii = *(InputInfo *)(data);
if (ii.text == getSearchString()) {
((InputInfo *)gdi.setText("SearchText", ""))->setFgColor(colorDefault);
((InputInfo *)gdi.setText("SearchText", L""))->setFgColor(colorDefault);
}
}
if (showNow) {
stdext::hash_set<int> filter;
unordered_set<int> filter;
if (type == GUI_TIMER)
gdi.setWaitCursor(true);
@ -431,8 +429,8 @@ int TabRunner::searchCB(gdioutput &gdi, int type, void *data) {
lastSearchExpr = expr;
// Filter more
if (filter.empty()) {
vector< pair<string, size_t> > runners;
runners.push_back(make_pair(lang.tl("Ingen matchar 'X'#" + expr), -1));
vector< pair<wstring, size_t> > runners;
runners.push_back(make_pair(lang.tl(L"Ingen matchar 'X'#" + expr), -1));
gdi.addItem("Runners", runners);
}
else
@ -447,14 +445,14 @@ int TabRunner::searchCB(gdioutput &gdi, int type, void *data) {
bool formMode = currentMode == 0;
vector< pair<string, size_t> > runners;
vector< pair<wstring, size_t> > runners;
oe->fillRunners(runners, !formMode, formMode ? 0 : oEvent::RunnerFilterShowAll, filter);
if (filter.size() == runners.size()){
}
else if (filter.empty()) {
runners.clear();
runners.push_back(make_pair(lang.tl("Ingen matchar 'X'#" + expr), -1));
runners.push_back(make_pair(lang.tl(L"Ingen matchar 'X'#" + expr), -1));
}
filter.swap(lastFilter);
@ -482,7 +480,7 @@ pRunner TabRunner::save(gdioutput &gdi, int runnerId, bool willExit) {
if (create)
return 0;
string name=gdi.getText("Name");
wstring name=gdi.getText("Name");
if (name.empty())
throw std::exception("Alla deltagare måste ha ett namn.");
@ -506,7 +504,7 @@ pRunner TabRunner::save(gdioutput &gdi, int runnerId, bool willExit) {
int classId = 0;
if (signed(lbi.data)<=0 && oe->getNumClasses() == 0) {
if (gdi.ask("Vill du skapa en ny klass?")) {
if (gdi.ask(L"Vill du skapa en ny klass?")) {
pClass pc=oe->addClass(oe->getAutoClassName());
pc->synchronize();
classId = pc->getId();
@ -536,7 +534,7 @@ pRunner TabRunner::save(gdioutput &gdi, int runnerId, bool willExit) {
if (cardNoChanged && cardNo>0) {
pRunner warnCardDupl = warnDuplicateCard(cardNo, r);
if (warnCardDupl) {
gdi.alert("Varning: Brickan X används redan av Y.#" + itos(cardNo) + "#" + warnCardDupl->getCompleteIdentification());
gdi.alert(L"Varning: Brickan X används redan av Y.#" + itow(cardNo) + L"#" + warnCardDupl->getCompleteIdentification());
}
}
@ -546,8 +544,8 @@ pRunner TabRunner::save(gdioutput &gdi, int runnerId, bool willExit) {
r->setName(name, true);
if (gdi.hasField("Bib")) {
const string &bib = gdi.getText("Bib");
char pat[32];
const wstring &bib = gdi.getText("Bib");
wchar_t pat[32];
int num = oClass::extractBibPattern(bib, pat);
r->setBib(bib, num, num>0, false);
}
@ -555,19 +553,19 @@ pRunner TabRunner::save(gdioutput &gdi, int runnerId, bool willExit) {
bool noSetStatus = false;
if (cardNo > 0 && r->getCard() &&
r->getCard()->getCardNo() != cardNo && r->getCardNo() != cardNo) {
if (gdi.ask("Vill du koppla isär X från inläst bricka Y?#" + r->getName() +
"#" + r->getCard()->getCardNoString())) {
if (gdi.ask(L"Vill du koppla isär X från inläst bricka Y?#" + r->getName() +
L"#" + r->getCard()->getCardNoString())) {
r->setStatus(StatusUnknown, true, false, false);
r->setCard(0);
r->setFinishTime(0);
r->synchronize(true);
gdi.setText("Finish", "");
gdi.setText("Finish", makeDash(L"-"));
noSetStatus = true;
}
}
if (cardNo > 0 && cardNo != r->getCardNo() && oe->hasNextStage()) {
if (gdi.ask("Vill du använda den nya brickan till alla etapper?")) {
if (gdi.ask(L"Vill du använda den nya brickan till alla etapper?")) {
r->setTransferCardNoNextStage(true);
}
}
@ -618,7 +616,7 @@ pRunner TabRunner::save(gdioutput &gdi, int runnerId, bool willExit) {
bool readStatusIn = true;
if (r->getClassId() != classId && r->getInputStatus() != StatusNotCompetiting && r->hasInputData()) {
if (gdi.ask("Vill du sätta resultatet från tidigare etapper till <Deltar ej>?")) {
if (gdi.ask(L"Vill du sätta resultatet från tidigare etapper till <Deltar ej>?")) {
r->resetInputData();
readStatusIn = false;
}
@ -682,9 +680,9 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
if (bi.id=="Search") {
ListBoxInfo lbi;
gdi.getSelectedItem("Runners", lbi);
string searchText = gdi.getText("SearchText");
wstring searchText = gdi.getText("SearchText");
bool formMode = currentMode == 0;
stdext::hash_set<int> foo;
unordered_set<int> foo;
fillRunnerList(gdi);
//oe->fillRunners(gdi, "Runners", !formMode, formMode ? 0 : oEvent::RunnerFilterShowAll);
pRunner r=oe->findRunner(searchText, lbi.data, foo, foo);
@ -726,7 +724,7 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
}
}
else if (bi.id == "Window") {
gdioutput *gdi_new = createExtraWindow(uniqueTag("kiosk"), MakeDash("MeOS - " + oe->getName()), gdi.getWidth() + 64 + gdi.scaleLength(120));
gdioutput *gdi_new = createExtraWindow(uniqueTag("kiosk"), makeDash(L"MeOS - ") + oe->getName(), gdi.getWidth() + 64 + gdi.scaleLength(120));
if (gdi_new) {
TabRunner &tr = dynamic_cast<TabRunner &>(*gdi_new->getTabs().get(TRunnerTab));
tr.currentMode = currentMode;
@ -736,7 +734,7 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
}
}
else if (bi.id == "Kiosk") {
if (gdi.ask("ask:kiosk")) {
if (gdi.ask(L"ask:kiosk")) {
oe->setReadOnly();
oe->updateTabs();
loadPage(gdi);
@ -804,27 +802,31 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
loadPage(gdi);
}
else if (bi.id=="SetDNS") {
for (size_t k=0; k<unknown.size(); k++)
if (unknown[k]->getStatus()==StatusUnknown)
for (size_t k=0; k<unknown.size(); k++) {
if (unknown[k]->getStatus()==StatusUnknown) {
unknown[k]->setStatus(StatusDNS, true, false);
unknown[k]->synchronize(true);
}
}
//Reevaluate and synchronize all
oe->reEvaluateAll(set<int>(), true);
clearInForestData();
showInForestList(gdi);
}
else if (bi.id=="SetUnknown") {
for (size_t k=0; k<known_dns.size(); k++)
if (known_dns[k]->getStatus()==StatusDNS)
for (size_t k=0; k<known_dns.size(); k++) {
if (known_dns[k]->getStatus()==StatusDNS) {
known_dns[k]->setStatus(StatusUnknown, true, false);
known_dns[k]->synchronize(true);
}
}
//Reevaluate and synchronize all
oe->reEvaluateAll(set<int>(), true);
clearInForestData();
showInForestList(gdi);
}
else if (bi.id == "RemoveVacant") {
if (gdi.ask("Vill du radera alla vakanser från tävlingen?")) {
if (gdi.ask(L"Vill du radera alla vakanser från tävlingen?")) {
oe->removeVacanies(0);
gdi.disableInput(bi.id.c_str());
}
@ -840,7 +842,7 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
pRunner r=oe->getRunner(runnerId, 0);
if (!r) return 0;
gdioutput gdiprint(2.0, gdi.getEncoding(), gdi.getHWND(), splitPrinter);
gdioutput gdiprint(2.0, gdi.getHWND(), splitPrinter, gdi.getCP());
if (bi.getExtraInt() == 0)
r->printSplits(gdiprint);
else
@ -872,10 +874,10 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
}
else if (bi.id=="Add") {
if (runnerId>0) {
string name = gdi.getText("Name");
wstring name = gdi.getText("Name");
pRunner r = oe->getRunner(runnerId, 0);
if (!name.empty() && r && r->getName() != name && r->getNameRaw() != name) {
if (gdi.ask("Vill du lägga till deltagaren 'X'?#" + name)) {
if (gdi.ask(L"Vill du lägga till deltagaren 'X'?#" + name)) {
r = oe->addRunner(name, 0, 0, 0,0, false);
runnerId = r->getId();
}
@ -903,7 +905,7 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
if (!runnerId)
return 0;
if (gdi.ask("Vill du verkligen ta bort löparen?")) {
if (gdi.ask(L"Vill du verkligen ta bort löparen?")) {
if (oe->isRunnerUsed(runnerId))
gdi.alert("Löparen ingår i ett lag och kan inte tas bort.");
else {
@ -922,7 +924,7 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
pRunner r = oe->getRunner(runnerId, 0);
r = r->getMultiRunner(0);
if (r && gdi.ask("Bekräfta att deltagaren har lämnat återbud.")) {
if (r && gdi.ask(L"Bekräfta att deltagaren har lämnat återbud.")) {
if (r->getStartTime()>0) {
pRunner newRunner = oe->addRunnerVacant(r->getClassId());
newRunner->cloneStartTime(r);
@ -1070,11 +1072,11 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
}
}
string crsName;
wstring crsName;
if (crsToUse) {
crsToUse->fillCourse(gdi, "Course");
autoGrowCourse(gdi);
crsName = crsToUse->getName() + " ";
crsName = crsToUse->getName() + L" ";
}
else {
gdi.clearList("Course");
@ -1187,14 +1189,14 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
if (r==0)
return -1;
char bf[1024];
sprintf_s(bf, lang.tl("Bekräfta att %s byter klass till %s.").c_str(),
r->getName().c_str(), vacancy->getClass().c_str());
if (gdi.ask(string("#") + bf)) {
wchar_t bf[1024];
swprintf_s(bf, lang.tl("Bekräfta att %s byter klass till %s.").c_str(),
r->getName().c_str(), vacancy->getClass().c_str());
if (gdi.ask(wstring(L"#") + bf)) {
vacancy->synchronize();
if (!vacancy->isVacant())
throw std::exception("Starttiden är upptagen.");
throw meosException("Starttiden är upptagen.");
oRunner temp(oe, 0);
temp.setTemporary();
@ -1213,7 +1215,7 @@ int TabRunner::runnerCB(gdioutput &gdi, int type, void *data)
r->setStartNo(vacancy->getStartNo(), false);
if (oe->hasPrevStage()) {
if (gdi.ask("Vill du sätta resultatet från tidigare etapper till <Deltar ej>?"))
if (gdi.ask(L"Vill du sätta resultatet från tidigare etapper till <Deltar ej>?"))
r->resetInputData();
}
@ -1281,7 +1283,7 @@ int TabRunner::vacancyCB(gdioutput &gdi, int type, void *data)
if (!r->isVacant())
throw std::exception("Starttiden är upptagen.");
string name = gdi.getText("Name");
wstring name = gdi.getText("Name");
if (name.empty())
throw std::exception("Alla deltagare måste ha ett namn.");
@ -1291,7 +1293,7 @@ int TabRunner::vacancyCB(gdioutput &gdi, int type, void *data)
if (cardNo!=r->getCardNo() && oe->checkCardUsed(gdi, *r, cardNo))
return 0;
string club = gdi.getText("Club");
wstring club = gdi.getText("Club");
int birthYear = 0;
pClub pc = oe->getClubCreate(0, club);
@ -1305,7 +1307,7 @@ int TabRunner::vacancyCB(gdioutput &gdi, int type, void *data)
if (gdi.hasField("Fee")) {
ListBoxInfo lbi;
if (gdi.getSelectedItem("Fee", lbi) && lbi.data == -1) {
lastFee = "@";
lastFee = L"@";
// Use class default fee
}
else {
@ -1316,7 +1318,7 @@ int TabRunner::vacancyCB(gdioutput &gdi, int type, void *data)
}
}
r->getDI().setDate("EntryDate", getLocalDate());
r->getDI().setDate("EntryDate", getLocalDateW());
r->addClassDefaultFee(false);
int cardFee = 0;
@ -1341,7 +1343,7 @@ int TabRunner::vacancyCB(gdioutput &gdi, int type, void *data)
}
if (oe->hasPrevStage()) {
if (gdi.ask("Vill du sätta resultatet från tidigare etapper till <Deltar ej>?"))
if (gdi.ask(L"Vill du sätta resultatet från tidigare etapper till <Deltar ej>?"))
r->resetInputData();
}
@ -1378,7 +1380,7 @@ int TabRunner::vacancyCB(gdioutput &gdi, int type, void *data)
tsi.storedInfo.storedClub = gdi.getText("Club");
ListBoxInfo lbi;
if (gdi.getSelectedItem("Fee", lbi) && lbi.data == -1) {
tsi.storedInfo.storedFee = "@";
tsi.storedInfo.storedFee = L"@";
// Use class default fee
}
else
@ -1411,7 +1413,7 @@ void TabRunner::showRunnerReport(gdioutput &gdi)
if (!ownWindow && !oe->isReadOnly())
addToolbar(gdi);
else if (oe->isReadOnly())
gdi.addString("", fontLarge, MakeDash("MeOS - Resultatkiosk")).setColor(colorDarkBlue);
gdi.addString("", fontLarge, makeDash(L"MeOS - Resultatkiosk")).setColor(colorDarkBlue);
gdi.dropLine();
@ -1476,14 +1478,14 @@ void TabRunner::showRunnerReport(gdioutput &gdi)
selHasRes = true;
}
string tInfo = t->getName();
wstring tInfo = t->getName();
if (t->statusOK()) {
tInfo += ", " + t->getRunningTimeS() + lang.tl(".S Placering: ") + t->getPlaceS();
tInfo += L", " + t->getRunningTimeS() + lang.tl(".S Placering: ") + t->getPlaceS();
if (t->getTimeAfter(-1) > 0)
tInfo += ", +" + formatTime(t->getTimeAfter(-1));
tInfo += L", +" + formatTimeW(t->getTimeAfter(-1));
}
else if (t->getStatus() != StatusUnknown) {
tInfo += " " + t->getStatusS();
tInfo += L" " + t->getStatusS();
}
gdi.addStringUT(fontMediumPlus, t->getClass());
@ -1527,21 +1529,21 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
gdi.addStringUT(boldLarge, r->getCompleteIdentification());
}
else {
string s;
wstring s;
if (r->getTeam())
s += r->getClassRef()->getLegNumber(r->getLegNumber());
s += ": " + r->getName();
s += L": " + r->getName();
gdi.addStringUT(boldText, s);
}
string str;
wstring str;
if (r->getTeam() == 0) {
str = oe->formatListString(lRunnerTimeStatus, r);
}
else {
str = oe->formatListString(lTeamLegTimeStatus, r);
str += " (" + oe->formatListString(lRunnerTimeStatus, r) + ")";
str += L" (" + oe->formatListString(lRunnerTimeStatus, r) + L")";
}
gdi.dropLine(0.3);
@ -1551,12 +1553,12 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
oe->getNumClassRunners(r->getClassId(), r->getLegNumber(), total, finished, dns);
if (r->getTeam() == 0) {
gdi.addString("", fontMediumPlus, "Tid: X, nuvarande placering Y/Z.#" + str + "#" + r->getPlaceS() + "#" + itos(finished));
gdi.addString("", fontMediumPlus, L"Tid: X, nuvarande placering Y/Z.#" + str + L"#" + r->getPlaceS() + L"#" + itow(finished));
}
else {
int place = r->getTeam()->getLegPlace(r->getLegNumber(), false);
if (place > 0 && place < 10000) {
gdi.addString("", fontMediumPlus, "Tid: X, nuvarande placering Y/Z.#" + str + "#" + itos(place) + "#" + itos(finished));
gdi.addString("", fontMediumPlus, L"Tid: X, nuvarande placering Y/Z.#" + str + L"#" + itow(place) + L"#" + itow(finished));
}
else {
gdi.addStringUT(fontMediumPlus, str).setColor(colorRed);
@ -1571,19 +1573,19 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
gdi.fillRight();
if (r->getStartTime() > 0)
gdi.addString("", fontMedium, "Starttid: X #" + r->getStartTimeCompact());
gdi.addString("", fontMedium, L"Starttid: X #" + r->getStartTimeCompact());
if (r->getFinishTime() > 0)
gdi.addString("", fontMedium, "Måltid: X #" + r->getFinishTimeS());
gdi.addString("", fontMedium, L"Måltid: X #" + r->getFinishTimeS());
const string &after = oe->formatListString(lRunnerTimeAfter, r);
const wstring &after = oe->formatListString(lRunnerTimeAfter, r);
if (!after.empty()) {
gdi.addString("", fontMedium, "Tid efter: X #" + after);
gdi.addString("", fontMedium, L"Tid efter: X #" + after);
}
const string &lost = oe->formatListString(lRunnerMissedTime, r);
const wstring &lost = oe->formatListString(lRunnerMissedTime, r);
if (!lost.empty()) {
gdi.addString("", fontMedium, "Bomtid: X #" + lost).setColor(colorDarkRed);
gdi.addString("", fontMedium, L"Bomtid: X #" + lost).setColor(colorDarkRed);
}
gdi.popX();
@ -1619,17 +1621,17 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
int end = crs->useLastAsFinish() ? nc - 1 : nc;
int start = crs->useFirstAsStart() ? 1 : 0;
for (int k = start; k<=end; k++) {
string name = crs->getControlOrdinal(k);
wstring name = crs->getControlOrdinal(k);
if ( k < end) {
pControl ctrl = crs->getControl(k);
if (ctrl && ctrl->getFirstNumber() > 0)
name += " (" + itos(ctrl->getFirstNumber()) + ")";
gdi.addString("", yp, cx, boldText, "Kontroll X#" + name, limit);
name += L" (" + itow(ctrl->getFirstNumber()) + L")";
gdi.addString("", yp, cx, boldText, L"Kontroll X#" + name, limit);
}
else
gdi.addStringUT(yp, cx, boldText, name, limit);
string split = r->getSplitTimeS(k, false);
wstring split = r->getSplitTimeS(k, false);
int bestTime = 0;
if ( k < int(after.size()) && after[k] >= 0)
@ -1638,11 +1640,11 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
GDICOLOR color = colorDefault;
if (k < int(after.size()) ) {
if (after[k] > 0)
split += " (" + itos(place[k]) + ", +" + getTimeMS(after[k]) + ")";
split += L" (" + itow(place[k]) + L", +" + getTimeMSW(after[k]) + L")";
else if (place[k] == 1)
split += lang.tl(" (sträckseger)");
else if (place[k] > 0)
split += " " + itos(place[k]);
split += L" " + itow(place[k]);
if (after[k] >= 0 && after[k]<=int(bestTime * 0.03))
color = colorLightGreen;
@ -1651,14 +1653,14 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
if (k>0 && k < int(placeAcc.size())) {
split = r->getPunchTimeS(k, false);
string pl = placeAcc[k] > 0 ? itos(placeAcc[k]) : "-";
wstring pl = placeAcc[k] > 0 ? itow(placeAcc[k]) : L"-";
if (k < int(afterAcc.size()) ) {
if (afterAcc[k] > 0)
split += " (" + pl + ", +" + getTimeMS(afterAcc[k]) + ")";
split += L" (" + pl + L", +" + getTimeMSW(afterAcc[k]) + L")";
else if (placeAcc[k] == 1)
split += lang.tl(" (ledare)");
else if (placeAcc[k] > 0)
split += " " + pl;
split += L" " + pl;
}
gdi.addStringUT(yp + 2*lh, cx, fontMedium, split, limit).setColor(colorDarkBlue);
}
@ -1693,15 +1695,15 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
int lastT = r->getStartTime();
for (size_t k = 0; k < punches.size(); k++) {
string name = punches[k]->getType();
string realName;
if (atoi(name.c_str()) > 0) {
wstring name = punches[k]->getType();
wstring realName;
if (_wtoi(name.c_str()) > 0) {
const pCourse rCrs = r->getCourse(false);
if (rCrs) {
vector<pControl> crsCtrl;
rCrs->getControls(crsCtrl);
for(size_t j = 0; j < crsCtrl.size(); j++) {
if (crsCtrl[j]->hasNumber(atoi(name.c_str()))) {
if (crsCtrl[j]->hasNumber(_wtoi(name.c_str()))) {
if (crsCtrl[j]->hasName())
realName = crsCtrl[j]->getName();
@ -1710,7 +1712,7 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
}
}
if (realName.empty())
gdi.addString("", yp, cx, boldText, "Kontroll X#" + name, limit);
gdi.addString("", yp, cx, boldText, L"Kontroll X#" + name, limit);
else
gdi.addStringUT(yp, cx, boldText, realName, limit);
}
@ -1720,7 +1722,7 @@ void TabRunner::runnerReport(gdioutput &gdi, int id, bool compact) {
int t = punches[k]->getAdjustedTime();
if (t>0) {
int st = r->getStartTime();
gdi.addString("", yp + lh, cx, normalText, "Klocktid: X#" + oe->getAbsTime(t), limit);
gdi.addString("", yp + lh, cx, normalText, L"Klocktid: X#" + oe->getAbsTime(t), limit);
if (st > 0 && t > st) {
string split = formatTimeHMS(t-st);
if (lastT>0 && st != lastT && lastT < t)
@ -1807,7 +1809,7 @@ void TabRunner::showVacancyList(gdioutput &gdi, const string &method, int classI
TabSI &tsi = dynamic_cast<TabSI &>(*gdi.getTabs().get(TSITab));
tsi.storedInfo.checkAge();
gdi.addInput("CardNo", tsi.storedInfo.storedCardNo, 8, VacancyCB, "Bricka:");
gdi.addInput("CardNo", tsi.storedInfo.storedCardNo, 8, VacancyCB, L"Bricka:");
tsi.setCardNumberField("CardNo");
//Remember to clear SI-link when page is cleared.
@ -1818,9 +1820,9 @@ void TabRunner::showVacancyList(gdioutput &gdi, const string &method, int classI
gdi.addCheckbox("RentCard", "Hyrd", 0, tsi.storedInfo.rentState);
gdi.dropLine(-1.2);
gdi.addInput("Name", tsi.storedInfo.storedName, 16, 0, "Namn:");
gdi.addInput("Name", tsi.storedInfo.storedName, 16, 0, L"Namn:");
gdi.addCombo("Club", 220, 300, 0, "Klubb:");
gdi.addCombo("Club", 220, 300, 0, L"Klubb:");
oe->fillClubs(gdi, "Club");
gdi.setText("Club", tsi.storedInfo.storedClub);
@ -1828,11 +1830,11 @@ void TabRunner::showVacancyList(gdioutput &gdi, const string &method, int classI
if (!tsi.storedInfo.storedFee.empty())
lastFee = tsi.storedInfo.storedFee;
gdi.addCombo("Fee", 60, 150, SportIdentCB, "Avgift:");
gdi.addCombo("Fee", 60, 150, SportIdentCB, L"Avgift:");
oe->fillFees(gdi, "Fee", true);
gdi.autoGrow("Fee");
if (!lastFee.empty() && lastFee != "@") {
if (!lastFee.empty() && lastFee != L"@") {
gdi.setText("Fee", lastFee);
}
else {
@ -1981,13 +1983,13 @@ void TabRunner::listRunners(gdioutput &gdi, const vector<pRunner> &r, bool filte
gdi.addStringUT(yp, xp+550, 0, "(" + itos(c) + ")", 190);
}
else {
TextInfo &ti = gdi.addStringUT(yp, xp+550, 0, "(" + itos(c) + ", " + lang.tl("reused card") + ")", 100);
string tt;
TextInfo &ti = gdi.addStringUT(yp, xp+550, 0, L"(" + itow(c) + lang.tl(", reused card") + L")", 100);
wstring tt;
for (size_t j = 0; j < out.size(); j++) {
if (out[j] == r[k]->getMultiRunner(0))
continue;
if (!tt.empty())
tt += ", ";
tt += L", ";
tt += out[j]->getName();
}
gdi.addToolTip(ti.id, tt, 0, &ti.textRect);
@ -2011,13 +2013,13 @@ void TabRunner::cellAction(gdioutput &gdi, DWORD id, oBase *obj)
gdi.addString("", fontMediumPlus, "Para ihop bricka X med en deltagare#" + itos(c->getCardNo())).setColor(colorDarkGreen);
gdi.dropLine(0.5);
string name = c->getOwner() ? c->getOwner()->getName() : MakeDash("-");
gdi.addString("", 0, "Nuvarande innehavare: X.#" + name);
wstring name = c->getOwner() ? c->getOwner()->getName() : makeDash(L"-");
gdi.addString("", 0, L"Nuvarande innehavare: X.#" + name);
gdi.dropLine(1);
gdi.pushX();
gdi.fillRight();
gdi.addListBox("Card", 150, 300, 0, "Vald bricka:");
gdi.addListBox("Card", 150, 300, 0, L"Vald bricka:");
c->fillPunches(gdi, "Card", 0);
gdi.disableInput("Card");
@ -2026,7 +2028,7 @@ void TabRunner::cellAction(gdioutput &gdi, DWORD id, oBase *obj)
gdi.popX();
gdi.fillDown();
gdi.addListBox("Runners", 350, 300, 0, "Deltagare:");
gdi.addListBox("Runners", 350, 300, 0, L"Deltagare:");
gdi.setTabStops("Runners", 200, 300);
oe->fillRunners(gdi, "Runners", true, oEvent::RunnerFilterShowAll);
if (c->getOwner())
@ -2034,7 +2036,7 @@ void TabRunner::cellAction(gdioutput &gdi, DWORD id, oBase *obj)
gdi.popX();
gdi.fillRight();
gdi.addInput("SearchText", "", 15).setBgColor(colorLightCyan);
gdi.addInput("SearchText", L"", 15).setBgColor(colorLightCyan);
gdi.addButton("Search", "Sök deltagare", RunnerCB, "Sök på namn, bricka eller startnummer.");
gdi.popX();
@ -2056,8 +2058,8 @@ void disablePunchCourseAdd(gdioutput &gdi)
gdi.selectItemByData("Course", -1);
}
const string &TabRunner::getSearchString() const {
return lang.tl("Sök (X)#Ctrl+F");
const wstring &TabRunner::getSearchString() const {
return lang.tl(L"Sök (X)#Ctrl+F");
}
void disablePunchCourseChange(gdioutput &gdi)
@ -2065,7 +2067,7 @@ void disablePunchCourseChange(gdioutput &gdi)
gdi.disableInput("SaveC");
gdi.disableInput("RemoveC");
gdi.disableInput("PTime");
gdi.setText("PTime", "");
gdi.setText("PTime", L"");
gdi.selectItemByData("Punches", -1);
}
@ -2112,9 +2114,9 @@ int TabRunner::punchesCB(gdioutput &gdi, int type, void *data)
if (!punch)
throw meosException("Punch not found.");
string ptime=punch->getTime();//;card->getPunchTime(punch);
wstring ptime=punch->getTime();
if (ptime!="") {
if (!ptime.empty()) {
gdi.enableInput("SaveC");
gdi.setText("PTime", ptime);
}
@ -2124,7 +2126,7 @@ int TabRunner::punchesCB(gdioutput &gdi, int type, void *data)
else {
gdi.disableInput("SaveC");
gdi.disableInput("RemoveC");
gdi.setText("PTime", "");
gdi.setText("PTime", L"");
}
disablePunchCourseAdd(gdi);
}
@ -2149,7 +2151,7 @@ int TabRunner::punchesCB(gdioutput &gdi, int type, void *data)
pCard card=r->getCard();
if (!card){
if (!gdi.ask("ask:addpunches"))
if (!gdi.ask(L"ask:addpunches"))
return 0;
card=oe->allocateCard(r);
@ -2295,8 +2297,8 @@ bool TabRunner::loadPage(gdioutput &gdi)
gdi.registerEvent("SearchRunner", runnerSearchCB).setKeyCommand(KC_FIND);
gdi.registerEvent("SearchRunnerBack", runnerSearchCB).setKeyCommand(KC_FINDBACK);
gdi.addInput("SearchText", getSearchString(), 13, runnerSearchCB, "",
"Sök på namn, bricka eller startnummer.").isEdit(false)
gdi.addInput("SearchText", getSearchString(), 13, runnerSearchCB, L"",
L"Sök på namn, bricka eller startnummer.").isEdit(false)
.setBgColor(colorLightCyan).ignore(true);
gdi.dropLine(-0.2);
//gdi.addButton("Search", "Sök", RunnerCB, "Sök på namn, bricka eller startnummer.");
@ -2321,24 +2323,24 @@ bool TabRunner::loadPage(gdioutput &gdi)
gdi.dropLine(1);
gdi.fillRight();
gdi.pushX();
gdi.addInput("Name", "", 16, 0, "Namn:");
gdi.addInput("Name", L"", 16, 0, L"Namn:");
if (oe->hasBib(true, false)) {
gdi.addInput("Bib", "", 4, 0, "Nr", "Nummerlapp");
gdi.addInput("Bib", L"", 4, 0, L"Nr", L"Nummerlapp");
}
gdi.popX();
gdi.dropLine(3);
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Clubs)) {
gdi.fillDown();
gdi.addCombo("Club", 220, 300, 0, "Klubb:");
gdi.addCombo("Club", 220, 300, 0, L"Klubb:");
oe->fillClubs(gdi, "Club");
gdi.pushX();
}
if (oe->hasTeam()) {
gdi.fillRight();
gdi.addInput("Team", "", 16, 0, "Lag:").isEdit(false);
gdi.addInput("Team", L"", 16, 0, L"Lag:").isEdit(false);
gdi.disableInput("Team");
gdi.fillDown();
gdi.dropLine(0.9);
@ -2347,14 +2349,14 @@ bool TabRunner::loadPage(gdioutput &gdi)
}
gdi.fillRight();
gdi.addSelection("RClass", 150, 300, RunnerCB, "Klass:");
gdi.addSelection("RClass", 150, 300, RunnerCB, L"Klass:");
oe->fillClasses(gdi, "RClass", oEvent::extraNone, oEvent::filterNone);
gdi.addItem("RClass", lang.tl("Ingen klass"), 0);
gdi.fillDown();
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy))
gdi.addInput("Fee", "", 6, 0, "Avgift:");
gdi.addInput("Fee", L"", 6, 0, L"Avgift:");
else
gdi.dropLine(3);
@ -2375,14 +2377,14 @@ bool TabRunner::loadPage(gdioutput &gdi)
if (numSL > 0)
gdi.fillRight();
gdi.addSelection("RCourse", numSL == 0 ? 220 : 180, 300, RunnerCB, "Bana:");
gdi.addSelection("RCourse", numSL == 0 ? 220 : 180, 300, RunnerCB, L"Bana:");
oe->fillCourses(gdi, "RCourse", true);
gdi.addItem("RCourse", lang.tl("[Klassens bana]"), 0);
if (numSL > 0) {
gdi.fillDown();
gdi.addSelection("NumShort", 60, 300, RunnerCB, "Avkortning:");
vector< pair<string, size_t> > data;
gdi.addSelection("NumShort", 60, 300, RunnerCB, L"Avkortning:");
vector< pair<wstring, size_t> > data;
if (numSL == 1) {
data.push_back(make_pair(lang.tl("Nej"), 0));
data.push_back(make_pair(lang.tl("Ja"), 1));
@ -2390,7 +2392,7 @@ bool TabRunner::loadPage(gdioutput &gdi)
else {
data.push_back(make_pair(lang.tl("Nej"), 0));
for (int i = 1; i <= numSL; i++) {
data.push_back(make_pair(itos(i), i));
data.push_back(make_pair(itow(i), i));
}
}
gdi.addItem("NumShort", data);
@ -2399,15 +2401,15 @@ bool TabRunner::loadPage(gdioutput &gdi)
gdi.pushX();
gdi.fillRight();
gdi.addInput("CardNo", "", 8, RunnerCB, "Bricka:");
gdi.addInput("CardNo", L"", 8, RunnerCB, L"Bricka:");
gdi.dropLine(1);
gdi.addCheckbox("RentCard", "Hyrd", 0, false);
gdi.dropLine(2);
gdi.popX();
gdi.addInput("Start", "", 8, 0, "Starttid:");
gdi.addInput("Finish", "", 8, 0, "Måltid:");
gdi.addInput("Start", L"", 8, 0, L"Starttid:");
gdi.addInput("Finish", L"", 8, 0, L"Måltid:");
const bool timeAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::TimeAdjust);
const bool pointAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::PointAdjust);
@ -2416,25 +2418,25 @@ bool TabRunner::loadPage(gdioutput &gdi)
gdi.dropLine(3);
gdi.popX();
if (timeAdjust) {
gdi.addInput("TimeAdjust", "", 8, 0, "Tidstillägg:");
gdi.addInput("TimeAdjust", L"", 8, 0, L"Tidstillägg:");
}
if (pointAdjust) {
gdi.addInput("PointAdjust", "", 8, 0, "Poängavdrag:");
gdi.addInput("PointAdjust", L"", 8, 0, L"Poängavdrag:");
}
}
gdi.dropLine(3);
gdi.popX();
gdi.addInput("Time", "", 8, 0, "Tid:").isEdit(false).ignore(true);
gdi.addInput("Time", L"", 8, 0, L"Tid:").isEdit(false).ignore(true);
gdi.disableInput("Time");
if (oe->hasRogaining()) {
gdi.addInput("Points", "", 5, 0, "Poäng:").isEdit(false).ignore(true);
gdi.addInput("Points", L"", 5, 0, L"Poäng:").isEdit(false).ignore(true);
gdi.disableInput("Points");
}
gdi.fillDown();
gdi.addSelection("Status", 100, 80, 0, "Status:", "tooltip_explain_status");
gdi.addSelection("Status", 100, 80, 0, L"Status:", L"tooltip_explain_status");
oe->fillStatus(gdi, "Status");
gdi.autoGrow("Status");
gdi.popX();
@ -2458,16 +2460,16 @@ bool TabRunner::loadPage(gdioutput &gdi)
gdi.dropLine(0.3);
gdi.fillRight();
gdi.addSelection("StatusIn", 100, 160, 0, "Status:", "tooltip_explain_status");
gdi.addSelection("StatusIn", 100, 160, 0, L"Status:", L"tooltip_explain_status");
oe->fillStatus(gdi, "StatusIn");
gdi.selectItemByData("Status", 0);
gdi.addInput("PlaceIn", "", 5, 0, "Placering:");
gdi.addInput("PlaceIn", L"", 5, 0, L"Placering:");
int xmax = gdi.getCX() + dx;
gdi.setCX(ccx);
gdi.dropLine(3);
gdi.addInput("TimeIn", "", 5, 0, "Tid:");
gdi.addInput("TimeIn", L"", 5, 0, L"Tid:");
if (oe->hasRogaining()) {
gdi.addInput("PointIn", "", 5, 0, "Poäng:");
gdi.addInput("PointIn", L"", 5, 0, L"Poäng:");
}
gdi.dropLine(3);
RECT rc;
@ -2499,12 +2501,12 @@ bool TabRunner::loadPage(gdioutput &gdi)
gdi.setCX(hx + gdi.scaleLength(5));
gdi.dropLine(2.5);
gdi.addListBox("Punches", 150, 300, PunchesCB, "Stämplingar:").ignore(true);
gdi.addListBox("Punches", 150, 300, PunchesCB, L"Stämplingar:").ignore(true);
gdi.addButton("RemoveC", "Ta bort stämpling >>", RunnerCB);
gdi.pushX();
gdi.fillRight();
gdi.addInput("PTime", "", 8, 0, "", "Stämplingstid");
gdi.addInput("PTime", L"", 8, 0, L"", L"Stämplingstid");
gdi.fillDown();
gdi.addButton("SaveC", "Spara tid", PunchesCB);
gdi.popX();
@ -2515,7 +2517,7 @@ bool TabRunner::loadPage(gdioutput &gdi)
gdi.newColumn();
gdi.dropLine(2.5);
gdi.fillDown();
gdi.addListBox("Course", 140, 300, PunchesCB, "Banmall:").ignore(true);
gdi.addListBox("Course", 140, 300, PunchesCB, L"Banmall:").ignore(true);
gdi.addButton("AddC", "<< Lägg till stämpling", PunchesCB);
gdi.addButton("AddAllC", "<< Lägg till alla", PunchesCB);
@ -2609,7 +2611,7 @@ void TabRunner::fillRunnerList(gdioutput &gdi) {
oe->fillRunners(gdi, "Runners", !formMode, formMode ? 0 : oEvent::RunnerFilterShowAll);
timeToFill = GetTickCount() - timeToFill;
if (formMode) {
lastSearchExpr = "";
lastSearchExpr = L"";
((InputInfo *)gdi.setText("SearchText", getSearchString()))->setFgColor(colorGreyBlue);
lastFilter.clear();
}
@ -2668,13 +2670,13 @@ void TabRunner::warnDuplicateCard(gdioutput &gdi, int cno, pRunner r) {
InputInfo &cardNo = dynamic_cast<InputInfo &>(gdi.getBaseInfo("CardNo"));
if (warnCardDupl) {
cardNo.setBgColor(colorLightRed);
gdi.updateToolTip("CardNo", "Brickan används av X.#" + warnCardDupl->getCompleteIdentification());
gdi.updateToolTip("CardNo", L"Brickan används av X.#" + warnCardDupl->getCompleteIdentification());
cardNo.refresh();
}
else {
if (cardNo.getBgColor() != colorDefault) {
cardNo.setBgColor(colorDefault);
gdi.updateToolTip("CardNo", "");
gdi.updateToolTip("CardNo", L"");
cardNo.refresh();
}
}

View File

@ -31,7 +31,7 @@ class TabRunner :
private:
void addToolbar(gdioutput &gdi);
const string &getSearchString() const;
const wstring &getSearchString() const;
void setCardNo(gdioutput &gdi, int cardNo);
@ -41,8 +41,8 @@ private:
void selectRunner(gdioutput &gdi, pRunner r);
string lastSearchExpr;
stdext::hash_set<int> lastFilter;
wstring lastSearchExpr;
unordered_set<int> lastFilter;
DWORD timeToFill;
int inputId;
int searchCB(gdioutput &gdi, int type, void *data);
@ -59,7 +59,7 @@ private:
int cardModeStartY;
int lastRace;
string lastFee;
wstring lastFee;
int runnerId;
bool ownWindow;
bool listenToPunches;

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,7 @@ private:
vector<PunchInfo> punches;
vector<SICard> cards;
vector<string> filterDate;
vector<wstring> filterDate;
int runnerMatchedId;
bool printErrorShown;
@ -76,7 +76,7 @@ private:
SIMode mode;
int currentAssignIndex;
void printSIInfo(gdioutput &gdi, const string &port) const;
void printSIInfo(gdioutput &gdi, const wstring &port) const;
void assignCard(gdioutput &gdi, const SICard &sic);
void entryCard(gdioutput &gdi, const SICard &sic);
@ -85,12 +85,12 @@ private:
void generateEntryLine(gdioutput &gdi, pRunner r);
int lastClassId;
int lastClubId;
string lastFee;
wstring lastFee;
int inputId;
void showCheckCardStatus(gdioutput &gdi, const string &cmd);
string getCardInfo(bool param, vector<int> &count) const;
wstring getCardInfo(bool param, vector<int> &count) const;
// Formatting for card tick off
bool checkHeader;
int cardPosX;
@ -177,12 +177,12 @@ public:
bool checkpPrintQueue(gdioutput &gdi);
struct StoredStartInfo {
string storedName;
string storedCardNo;
string storedClub;
string storedFee;
string storedPhone;
string storedStartTime;
wstring storedName;
wstring storedCardNo;
wstring storedClub;
wstring storedFee;
wstring storedPhone;
wstring storedStartTime;
bool allStages;
bool rentState;
bool hasPaid;

View File

@ -40,11 +40,13 @@
#include "TabSpeaker.h"
#include "TabList.h"
#include "speakermonitor.h"
#include "meosexception.h"
#include <cassert>
//Base position for speaker buttons
#define SPEAKER_BASE_X 40
vector<string> getExtraWindows();
TabSpeaker::TabSpeaker(oEvent *poe):TabBase(poe)
{
@ -124,16 +126,27 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
gdi.pushX();
gdi.fillRight();
gdi.addListBox("Classes", 200, 300, 0,"Klasser","", true);
gdi.addListBox("Classes", 200, 300, 0,L"Klasser", L"", true);
auto pos = gdi.getPos();
gdi.setCY(gdi.getHeight());
gdi.popX();
gdi.fillRight();
gdi.addButton("AllClass", "Alla", tabSpeakerCB);
gdi.addButton("NoClass", "Inga", tabSpeakerCB);
oe->fillClasses(gdi, "Classes", oEvent::extraNone, oEvent::filterNone);
gdi.setSelection("Classes", classesToWatch);
gdi.addListBox("Controls", 200, 300, 0, "Kontroller","", true);
gdi.fillRight();
gdi.setPos(pos);
gdi.addListBox("Controls", 200, 300, 0, L"Kontroller", L"", true);
gdi.pushX();
gdi.fillDown();
vector< pair<string, size_t> > d;
vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTCourseControl);
gdi.addItem("Controls", d);
@ -145,6 +158,15 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
gdi.refresh();
}
else if (bu.id == "AllClass") {
set<int> lst;
lst.insert(-1);
gdi.setSelection("Classes", lst);
}
else if (bu.id == "NoClass") {
set<int> lst;
gdi.setSelection("Classes", lst);
}
else if (bu.id=="ZoomIn") {
gdi.scaleSize(1.05);
}
@ -174,7 +196,7 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
gdi.fillRight();
gdi.pushX();
gdi.addString("", 0, "Klass:");
gdi.addSelection("Class", 200, 200, tabSpeakerCB, "", "Välj klass");
gdi.addSelection("Class", 200, 200, tabSpeakerCB, L"", L"Välj klass");
oe->fillClasses(gdi, "Class", oEvent::extraNone, oEvent::filterNone);
gdi.addButton("ClosePri", "Stäng", tabSpeakerCB);
gdi.dropLine(2);
@ -186,7 +208,7 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
loadPage(gdi);
}
else if (bu.id == "LiveResult") {
gdioutput *gdi_new = createExtraWindow(uniqueTag("list"), MakeDash("MeOS - Live"), gdi.getWidth() + 64 + gdi.scaleLength(120));
gdioutput *gdi_new = createExtraWindow(uniqueTag("list"), makeDash(L"MeOS - Live"), gdi.getWidth() + 64 + gdi.scaleLength(120));
gdi_new->clearPage(false);
gdi_new->addString("", boldLarge, "Liveresultat");
@ -228,22 +250,61 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
}
else if (bu.id == "Events") {
gdi.restore("classes");
/*
shownEvents.clear();
events.clear();
*/
classId = -1;
drawTimeLine(gdi);
}
else if (bu.id == "Window") {
oe->setupTimeLineEvents(0);
gdioutput *gdi_new = createExtraWindow(uniqueTag("speaker"), MakeDash("MeOS - Speakerstöd"), gdi.getWidth() + 64 + gdi.scaleLength(120));
gdioutput *gdi_new = createExtraWindow(uniqueTag("speaker"), makeDash(L"MeOS - Speakerstöd"), gdi.getWidth() + 64 + gdi.scaleLength(120));
if (gdi_new) {
TabSpeaker &tl = dynamic_cast<TabSpeaker &>(*gdi_new->getTabs().get(TSpeakerTab));
tl.ownWindow = true;
tl.loadPage(*gdi_new);
//oe->renderTimeLineEvents(*gdi_new);
}
loadPage(gdi);
}
else if (bu.id == "SaveWindows") {
if (!gdi.ask(L"ask:savespeaker"))
return 0;
vector<string> tags = getExtraWindows();
vector< multimap<string, wstring> > speakerSettings;
for (size_t i = 0; i < tags.size(); i++) {
if (tags[i] != "main" && tags[i].substr(0, 7) != "speaker")
continue;
gdioutput *gdi = getExtraWindow(tags[i], false);
if (gdi) {
TabBase *tb = gdi->getTabs().get(TabType::TSpeakerTab);
if (tb) {
speakerSettings.push_back(multimap<string, wstring>());
((TabSpeaker *)tb)->getSettings(*gdi, speakerSettings.back());
}
}
}
saveSettings(speakerSettings);
}
else if (bu.id == "LoadWindows") {
if (!gdi.ask(L"ask:loadspeaker"))
return 0;
vector< multimap<string, wstring> > speakerSettings;
loadSettings(speakerSettings);
if (speakerSettings.empty())
throw meosException("Inställningarna är ogiltiga");
for (size_t k = 1; k < speakerSettings.size(); k++) {
gdioutput *gdi_new = createExtraWindow(uniqueTag("speaker"), makeDash(L"MeOS - Speakerstöd"), gdi.getWidth() + 64 + gdi.scaleLength(120));
if (gdi_new) {
TabSpeaker &tl = dynamic_cast<TabSpeaker &>(*gdi_new->getTabs().get(TSpeakerTab));
tl.ownWindow = true;
tl.importSettings(*gdi_new, speakerSettings[k]);
tl.loadPage(*gdi_new);
}
}
importSettings(gdi, speakerSettings[0]);
loadPage(gdi);
}
else if (bu.id=="StoreTime") {
storeManualTime(gdi);
@ -260,13 +321,11 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
if (controlsToWatch.empty())
controlsToWatch.insert(-2); // Non empty but no control
controlsToWatchSI.clear();
for (set<int>::iterator it=controlsToWatch.begin();it!=controlsToWatch.end();++it) {
pControl pc=oe->getControl(*it, false);
if (pc) {
pc->setRadio(true);
pc->synchronize(true);
controlsToWatchSI.insert(pc->Numbers, pc->Numbers+pc->nNumbers);
}
}
oe->setProperty("SpeakerShortNames", (int)gdi.isChecked("ShortNames"));
@ -288,7 +347,8 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
}
else if (bu.id.substr(0, 4)=="ctrl") {
bool shortNames = oe->getPropertyInt("SpeakerShortNames", false) != 0;
int ctrl = atoi(bu.id.substr(4, string::npos).c_str());
int ctrl = atoi(bu.id.substr(4,
string::npos).c_str());
int ctrlPrev = bu.getExtraInt();
selectedControl[classId].setControl(ctrl, ctrlPrev);
gdi.restore("speaker");
@ -305,10 +365,29 @@ void TabSpeaker::drawTimeLine(gdioutput &gdi) {
gdi.fillRight();
gdi.pushX();
gdi.dropLine(0.3);
const bool multiDay = oe->hasPrevStage();
gdi.dropLine(0.1);
if (multiDay) {
gdi.dropLine(0.2);
gdi.addString("", 0, "Resultat:");
gdi.dropLine(-0.2);
gdi.addSelection("MultiStage", 100, 100, tabSpeakerCB);
gdi.setCX(gdi.getCX() + gdi.getLineHeight()*2);
gdi.addItem("MultiStage", lang.tl("Etappresultat"), 0);
gdi.addItem("MultiStage", lang.tl("Totalresultat"), 1);
gdi.selectItemByData("MultiStage", getSpeakerMonitor()->useTotalResults() ? 1 : 0);
}
gdi.dropLine(0.2);
gdi.addString("", 0, "Filtrering:");
gdi.dropLine(-0.2);
gdi.addSelection("DetailLevel", 160, 100, tabSpeakerCB);
gdi.setCX(gdi.getCX() + gdi.getLineHeight()*2);
gdi.addItem("DetailLevel", lang.tl("Alla händelser"), oTimeLine::PLow);
gdi.addItem("DetailLevel", lang.tl("Viktiga händelser"), oTimeLine::PMedium);
gdi.addItem("DetailLevel", lang.tl("Avgörande händelser"), oTimeLine::PHigh);
@ -322,22 +401,22 @@ void TabSpeaker::drawTimeLine(gdioutput &gdi) {
gdi.addItem("WatchNumber", lang.tl("X senaste#10"), 10);
gdi.addItem("WatchNumber", lang.tl("X senaste#20"), 20);
gdi.addItem("WatchNumber", lang.tl("X senaste#50"), 50);
gdi.addItem("WatchNumber", "Alla", 0);
gdi.addItem("WatchNumber", L"Alla", 0);
gdi.selectItemByData("WatchNumber", watchNumber);
gdi.dropLine(2);
gdi.popX();
string cls;
wstring cls;
for (set<int>::iterator it = classesToWatch.begin(); it != classesToWatch.end(); ++it) {
pClass pc = oe->getClass(*it);
if (pc) {
if (!cls.empty())
cls += ", ";
cls += L", ";
cls += oe->getClass(*it)->getName();
}
}
gdi.fillDown();
gdi.addString("", 1, "Bevakar händelser i X#" + cls);
gdi.addString("", 1, L"Bevakar händelser i X#" + cls);
gdi.dropLine();
gdi.setRestorePoint("TimeLine");
@ -566,7 +645,7 @@ void TabSpeaker::splitAnalysis(gdioutput &gdi, int xp, int yp, pRunner r)
vector<int> delta;
r->getSplitAnalysis(delta);
string timeloss = lang.tl("Bommade kontroller: ");
wstring timeloss = lang.tl("Bommade kontroller: ");
pCourse pc = 0;
bool first = true;
const int charlimit = 90;
@ -579,16 +658,16 @@ void TabSpeaker::splitAnalysis(gdioutput &gdi, int xp, int yp, pRunner r)
}
if (!first)
timeloss += " | ";
timeloss += L" | ";
else
first = false;
timeloss += pc->getControlOrdinal(j) + ". " + formatTime(delta[j]);
timeloss += pc->getControlOrdinal(j) + L". " + formatTimeW(delta[j]);
}
if (timeloss.length() > charlimit || (!timeloss.empty() && !first && j+1 == delta.size())) {
gdi.addStringUT(yp, xp, 0, timeloss).setColor(colorDarkRed);
yp += gdi.getLineHeight();
timeloss = "";
timeloss = L"";
}
}
if (first) {
@ -645,9 +724,10 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
if (!keepLegs) {
gdi.setData("CurrentY", cy);
gdi.addSelection(cx, cy+2, "Leg", int(bw/gdi.getScale())-5, 100, tabSpeakerCB);
bool total = selectedControl[pc->getId()].isTotal();
if (leg == 0 && stages[0].first != 0) {
leg = stages[0].first;
selectedControl[pc->getId()].setLeg(selectedControl[pc->getId()].isTotal(), leg);
selectedControl[pc->getId()].setLeg(total, leg);
}
if (stages.size() > 1) {
@ -667,7 +747,7 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
gdi.addItem("Leg", lang.tl("Totalresultat"), 1000 + stages[0].first);
}
gdi.selectItemByData("Leg", leg);
gdi.selectItemByData("Leg", leg + (total ? 1000 : 0));
gdi.setRestorePoint("LegSelection");
}
else {
@ -712,7 +792,7 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
char bf[16];
sprintf_s(bf, "ctrl%d", cid);
string name = course->getRadioName(cid);
wstring name = course->getRadioName(cid);
/*if (controls[k]->hasName()) {
name = "#" + controls[k]->getName();
if (controls[k]->getNumberDuplicates() > 1)
@ -724,9 +804,9 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
name = "#" + name;
}
*/
string tooltip = lang.tl("kontroll X (Y)#" + itos(k+1) +"#" + itos(controls[k]->getFirstNumber()));
wstring tooltip = lang.tl("kontroll X (Y)#" + itos(k+1) +"#" + itos(controls[k]->getFirstNumber()));
capitalize(tooltip);
ButtonInfo &bi = gdi.addButton(cx, cy, bw, bf, "#" + name, tabSpeakerCB, "#" + tooltip, false, false);
ButtonInfo &bi = gdi.addButton(cx, cy, bw, bf, L"#" + name, tabSpeakerCB, L"#" + tooltip, false, false);
bi.setExtra(previousControl);
previousControl = cid;
cx+=bw;
@ -752,6 +832,32 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
gdi.popX();
}
int TabSpeaker::deducePreviousControl(int classId, int leg, int control) {
pClass pc = oe->getClass(classId);
if (pc == 0)
return -1;
vector<oClass::TrueLegInfo> stages;
pc->getTrueStages(stages);
pCourse course = deduceSampleCourse(pc, stages, leg);
vector<pControl> controls;
if (course)
course->getControls(controls);
int previousControl = 0;
for (size_t k = 0; k < controls.size(); k++) {
int cid = course->getCourseControlId(k);
if (controlsToWatch.count(cid)) {
if (cid == control)
return previousControl;
previousControl = cid;
}
}
if (control == oPunch::PunchFinish)
return previousControl;
return -1;
}
int TabSpeaker::processListBox(gdioutput &gdi, const ListBoxInfo &bu)
{
if (bu.id=="Leg") {
@ -769,6 +875,10 @@ int TabSpeaker::processListBox(gdioutput &gdi, const ListBoxInfo &bu)
shortNames);
}
}
else if (bu.id == "MultiStage") {
getSpeakerMonitor()->useTotalResults(gdi.isChecked(bu.id));
updateTimeLine(gdi);
}
else if (bu.id == "DetailLevel") {
watchLevel = oTimeLine::Priority(bu.data);
shownEvents.clear();
@ -817,7 +927,7 @@ bool TabSpeaker::loadPage(gdioutput &gdi)
pClass pc=oe->getClass(*it);
if (pc) {
gdi.addButton(cx, cy, bw, classid, "#" + pc->getName(), tabSpeakerCB, "", false, false);
gdi.addButton(cx, cy, bw, classid, L"#" + pc->getName(), tabSpeakerCB, L"", false, false);
cx+=bw;
cb++;
@ -844,7 +954,7 @@ bool TabSpeaker::loadPage(gdioutput &gdi)
} else db += bw;
gdi.addButton(cx+db, cy, bw/5, "ZoomIn", "+", tabSpeakerCB, "Zooma in (Ctrl + '+')", false, false);
db += bw/5+2;
gdi.addButton(cx+db, cy, bw/5, "ZoomOut", MakeDash("-"), tabSpeakerCB, "Zooma ut (Ctrl + '-')", false, false);
gdi.addButton(cx+db, cy, bw/5, "ZoomOut", makeDash(L"-"), tabSpeakerCB, L"Zooma ut (Ctrl + '-')", false, false);
db += bw/5+2;
}
gdi.addButton(cx+db, cy, bw-2, "Settings", "Inställningar...", tabSpeakerCB, "Välj vilka klasser och kontroller som bevakas", false, false);
@ -884,7 +994,41 @@ bool TabSpeaker::loadPage(gdioutput &gdi)
cb = 1, cx = basex, db = 0;
cy += gdi.getButtonHeight()+4;
} else db += bw;
if (getExtraWindows().size() == 1) {
wstring sf = getSpeakerSettingsFile();
if (fileExist(sf.c_str())) {
gdi.addButton(cx + db, cy, bw - 2, "LoadWindows", "Återskapa", tabSpeakerCB, "Återskapa tidigare sparade fönster- och speakerinställningar", false, false);
if (++cb > nbtn) {
cb = 1, cx = basex, db = 0;
cy += gdi.getButtonHeight() + 4;
}
else db += bw;
}
}
else {
gdi.addButton(cx + db, cy, bw - 2, "SaveWindows", "Spara", tabSpeakerCB, "Spara fönster- och speakerinställningar på datorn", false, false);
if (++cb > nbtn) {
cb = 1, cx = basex, db = 0;
cy += gdi.getButtonHeight() + 4;
}
else db += bw;
}
}
if (classId == -1) {
string btn = "Events";
if (gdi.hasField(btn))
gdi.sendCtrlMessage(btn);
}
else if (classId > 0) {
string btn = "cid" + itos(classId);
if (gdi.hasField(btn))
gdi.sendCtrlMessage(btn);
}
gdi.setRestorePoint("classes");
gdi.refresh();
return true;
@ -894,7 +1038,6 @@ void TabSpeaker::clearCompetitionData()
{
controlsToWatch.clear();
classesToWatch.clear();
controlsToWatchSI.clear();
selectedControl.clear();
classId=0;
lastControl.clear();
@ -915,9 +1058,9 @@ void TabSpeaker::manualTimePage(gdioutput &gdi) const
gdi.fillRight();
gdi.pushX();
gdi.addInput("Control", lastControl, 5, 0, "Kontroll");
gdi.addInput("Runner", "", 6, 0, "Löpare");
gdi.addInput("Time", "", 8, 0, "Tid");
gdi.addInput("Control", lastControl, 5, 0, L"Kontroll");
gdi.addInput("Runner", L"", 6, 0, L"Löpare");
gdi.addInput("Time", L"", 8, 0, L"Tid");
gdi.dropLine();
gdi.addButton("StoreTime", "Spara", tabSpeakerCB).setDefault();
gdi.addButton("Cancel", "Avbryt", tabSpeakerCB).setCancel();
@ -940,11 +1083,11 @@ void TabSpeaker::storeManualTime(gdioutput &gdi)
throw std::exception("Kontrollnummer måste anges.");
lastControl=gdi.getText("Control");
const string &r_str=gdi.getText("Runner");
string time=gdi.getText("Time");
const wstring &r_str=gdi.getText("Runner");
wstring time=gdi.getText("Time");
if (time.empty())
time=getLocalTimeOnly();
if (time.empty())
time=getLocalTimeOnlyW();
int itime=oe->getRelativeTime(time);
@ -952,15 +1095,15 @@ void TabSpeaker::storeManualTime(gdioutput &gdi)
throw std::exception("Ogiltig tid.");
pRunner r=oe->getRunnerByBibOrStartNo(r_str, false);
int r_no = atoi(r_str.c_str());
int r_no = _wtoi(r_str.c_str());
if (!r)
r=oe->getRunnerByCardNo(r_no, itime);
string Name;
wstring Name;
int sino=r_no;
if (r) {
Name=r->getName();
sino=r->getCardNo();
Name = r->getName();
sino = r->getCardNo();
}
else
Name = lang.tl("Okänd");
@ -973,7 +1116,7 @@ void TabSpeaker::storeManualTime(gdioutput &gdi)
oe->addFreePunch(itime, punch, sino, true);
gdi.restore("manual", false);
gdi.addString("", 0, "Löpare: X, kontroll: Y, kl Z#" + Name + "#" + oPunch::getType(punch) + "#" + oe->getAbsTime(itime));
gdi.addString("", 0, L"Löpare: X, kontroll: Y, kl Z#" + Name + L"#" + oPunch::getType(punch) + L"#" + oe->getAbsTime(itime));
manualTimePage(gdi);
}
@ -1046,3 +1189,150 @@ SpeakerMonitor *TabSpeaker::getSpeakerMonitor() {
return speakerMonitor;
}
void TabSpeaker::getSettings(gdioutput &gdi, multimap<string, wstring> &settings) {
RECT rc;
gdi.getWindowsPosition(rc);
settings.insert(make_pair("left", itow(rc.left)));
settings.insert(make_pair("right", itow(rc.right)));
settings.insert(make_pair("top", itow(rc.top)));
settings.insert(make_pair("bottom", itow(rc.bottom)));
for (auto clsId : classesToWatch) {
pClass cls = oe->getClass(clsId);
if (cls)
settings.insert(make_pair("class", cls->getName()));
if (classId == clsId) {
settings.insert(make_pair("currentClass", cls->getName()));
if (selectedControl.count(clsId)) {
int cControl = selectedControl[clsId].getControl();
int cLeg = selectedControl[clsId].getLeg();
bool cTotal = selectedControl[clsId].isTotal();
settings.insert(make_pair("currentControl", itow(cControl)));
settings.insert(make_pair("currentLeg", itow(cLeg)));
settings.insert(make_pair("currentTotal", itow(cTotal)));
}
}
}
if (classId == -1) {
settings.insert(make_pair("currentClass", L"@Events"));
}
for (auto ctrl : controlsToWatch) {
settings.insert(make_pair("control", itow(ctrl)));
}
}
int get(const multimap<string, wstring> &settings, const char *p) {
auto res = settings.find(p);
if (res != settings.end())
return _wtoi(res->second.c_str());
return 0;
}
void TabSpeaker::importSettings(gdioutput &gdi, multimap<string, wstring> &settings) {
classId = 0;
classesToWatch.clear();
controlsToWatch.clear();
selectedControl.clear();
int ctrl = 0, leg = 0, total = 0;
for (auto s : settings) {
if (s.first == "currentClass") {
if (s.second == L"@Events") {
classId = -1;
}
else {
pClass cls = oe->getClass(s.second);
classId = cls ? cls->getId() : 0;
if (classId > 0) {
ctrl = get(settings, "currentControl");
leg = get(settings, "currentLeg");
total = get(settings, "currentTotal");
}
}
}
else if (s.first == "class") {
pClass cls = oe->getClass(s.second);
if (cls)
classesToWatch.insert(cls->getId());
}
else if (s.first == "control") {
int ctrl = _wtoi(s.second.c_str());
pControl pc = oe->getControl(ctrl);
if (pc) {
controlsToWatch.insert(pc->getId());
}
}
}
int previousControl = deducePreviousControl(classId, leg, ctrl);
if (previousControl != -1) {
selectedControl[classId].setLeg(total != 0, leg);
selectedControl[classId].setControl(ctrl, previousControl);
}
RECT rc;
if (settings.find("left") == settings.end() ||
settings.find("right") == settings.end() ||
settings.find("top") == settings.end() ||
settings.find("bottom") == settings.end())
throw meosException("Inställningarna är ogiltiga");
rc.left = get(settings, "left");
rc.right = get(settings, "right");
rc.top = get(settings, "top");
rc.bottom = get(settings, "bottom");
RECT desktop;
gdi.getVirtualScreenSize(desktop);
if (rc.right > rc.left && rc.bottom > rc.top &&
rc.right > 50 && rc.left < (desktop.right - 50) &&
rc.bottom > 50 && rc.top < (desktop.bottom - 50))
gdi.setWindowsPosition(rc);
}
wstring TabSpeaker::getSpeakerSettingsFile() {
wchar_t path[260];
getUserFile(path, L"speaker.xml");
return path;
}
void TabSpeaker::loadSettings(vector< multimap<string, wstring> > &settings) {
settings.clear();
xmlparser reader;
reader.read(getSpeakerSettingsFile());
xmlobject sp = reader.getObject("Speaker");
if (!sp)
return;
xmlList xmlsettings;
sp.getObjects(xmlsettings);
for (auto s : xmlsettings) {
settings.push_back(multimap<string, wstring>());
xmlList allS;
s.getObjects(allS);
for (auto prop : allS) {
settings.back().insert(make_pair(prop.getName(), prop.getw()));
}
}
}
void TabSpeaker::saveSettings(const vector< multimap<string, wstring> > &settings) {
xmlparser d;
d.openOutput(getSpeakerSettingsFile().c_str(), false);
d.startTag("Speaker");
for (auto s : settings) {
d.startTag("SpeakerWindow");
for (auto prop : s) {
d.write(prop.first.c_str(), prop.second);
}
d.endTag();
}
d.endTag();
d.closeOut();
}

View File

@ -57,7 +57,6 @@ class TabSpeaker :
private:
set<int> controlsToWatch;
set<int> classesToWatch;
set<int> controlsToWatchSI;
int lastControlToWatch;
int lastClassToWatch;
@ -70,7 +69,7 @@ private:
void generateControlList(gdioutput &gdi, int classId);
void generateControlListForLeg(gdioutput &gdi, int classId, int leg);
string lastControl;
wstring lastControl;
void manualTimePage(gdioutput &gdi) const;
void storeManualTime(gdioutput &gdi);
@ -80,6 +79,7 @@ private:
//Map CourseNo -> selected Control.
//map<int, int> selectedControl;
map<int, spkClassSelection> selectedControl;
int deducePreviousControl(int classId, int leg, int control);
bool ownWindow;
@ -93,6 +93,11 @@ private:
SpeakerMonitor *getSpeakerMonitor();
void getSettings(gdioutput &gdi, multimap<string, wstring> &settings);
void importSettings(gdioutput &gdi, multimap<string, wstring> &settings);
static void loadSettings(vector< multimap<string, wstring> > &settings);
static void saveSettings(const vector< multimap<string, wstring> > &settings);
static wstring getSpeakerSettingsFile();
public:
bool onClear(gdioutput &gdi);
@ -103,7 +108,6 @@ public:
//Clear selection data
void clearCompetitionData();
int processButton(gdioutput &gdi, const ButtonInfo &bu);
int processListBox(gdioutput &gdi, const ListBoxInfo &bu);
int handleEvent(gdioutput &gdi, const EventInfo &ei);

View File

@ -70,7 +70,7 @@ int teamSearchCB(gdioutput *gdi, int type, void *data)
int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
static DWORD editTick = 0;
string expr;
wstring expr;
bool showNow = false;
bool filterMore = false;
@ -86,7 +86,7 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
if (timeToFill < 50 || (filterMore && (timeToFill * lastFilter.size())/nr < 50))
showNow = true;
else {// Delay filter
gdi.addTimeoutMilli(500, "Search: " + expr, teamSearchCB).setExtra((void *)inputId);
gdi.addTimeoutMilli(500, "Search", teamSearchCB).setData(inputId, expr);
}
}
}
@ -94,10 +94,10 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
TimerInfo &ti = *(TimerInfo *)(data);
if (inputId != int(ti.getExtra()))
if (inputId != ti.getData())
return 0;
expr = ti.id.substr(8);
expr = ti.getDataString();
filterMore = expr.length() > lastSearchExpr.length() &&
expr.substr(0, lastSearchExpr.length()) == lastSearchExpr;
showNow = true;
@ -115,12 +115,12 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
InputInfo &ii = *(InputInfo *)(data);
if (ii.text == getSearchString()) {
((InputInfo *)gdi.setText("SearchText", ""))->setFgColor(colorDefault);
((InputInfo *)gdi.setText("SearchText", L""))->setFgColor(colorDefault);
}
}
if (showNow) {
stdext::hash_set<int> filter;
unordered_set<int> filter;
if (type == GUI_TIMER)
gdi.setWaitCursor(true);
@ -131,8 +131,8 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
lastSearchExpr = expr;
// Filter more
if (filter.empty()) {
vector< pair<string, size_t> > runners;
runners.push_back(make_pair(lang.tl("Ingen matchar 'X'#" + expr), -1));
vector< pair<wstring, size_t> > runners;
runners.push_back(make_pair(lang.tl(L"Ingen matchar 'X'#" + expr), -1));
gdi.addItem("Teams", runners);
}
else
@ -142,21 +142,21 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
oe->findTeam(expr, 0, filter);
lastSearchExpr = expr;
vector< pair<string, size_t> > runners;
vector< pair<wstring, size_t> > runners;
oe->fillTeams(runners);
if (filter.size() == runners.size()){
}
else if (filter.empty()) {
runners.clear();
runners.push_back(make_pair(lang.tl("Ingen matchar 'X'#" + expr), -1));
runners.push_back(make_pair(lang.tl(L"Ingen matchar 'X'#" + expr), -1));
}
else {
vector< pair<string, size_t> > runners2;
vector< pair<wstring, size_t> > runners2;
for (size_t k = 0; k<runners.size(); k++) {
if (filter.count(runners[k].second) == 1) {
runners2.push_back(make_pair(string(), runners[k].second));
runners2.push_back(make_pair(wstring(), runners[k].second));
runners2.back().first.swap(runners[k].first);
}
}
@ -197,7 +197,7 @@ void TabTeam::selectTeam(gdioutput &gdi, pTeam t)
if (ip > 0)
gdi.setText("PlaceIn", ip);
else
gdi.setText("PlaceIn", MakeDash("-"));
gdi.setText("PlaceIn", makeDash(L"-"));
gdi.setText("TimeIn", t->getInputTimeS());
if (gdi.hasField("PointIn"))
@ -221,10 +221,10 @@ void TabTeam::selectTeam(gdioutput &gdi, pTeam t)
if (gdi.hasField("StatusIn")) {
gdi.selectFirstItem("StatusIn");
gdi.setText("PlaceIn", "");
gdi.setText("TimeIn", "-");
gdi.setText("PlaceIn", L"");
gdi.setText("TimeIn", makeDash(L"-"));
if (gdi.hasField("PointIn"))
gdi.setText("PointIn", "");
gdi.setText("PointIn", L"");
}
loadTeamMembers(gdi, lbi.data, 0, 0);
@ -237,21 +237,21 @@ void TabTeam::selectTeam(gdioutput &gdi, pTeam t)
void TabTeam::updateTeamStatus(gdioutput &gdi, pTeam t)
{
if (!t) {
gdi.setText("Name", "");
gdi.setText("Name", L"");
if (gdi.hasField("StartNo"))
gdi.setText("StartNo", "");
gdi.setText("StartNo", L"");
if (gdi.hasField("Club"))
gdi.setText("Club", "");
gdi.setText("Club", L"");
bool hasFee = gdi.hasField("Fee");
if (hasFee) {
gdi.setText("Fee", "");
gdi.setText("Fee", L"");
}
gdi.setText("Start", "-");
gdi.setText("Finish", "-");
gdi.setText("Time", "-");
gdi.setText("Start", makeDash(L"-"));
gdi.setText("Finish", makeDash(L"-"));
gdi.setText("Time", makeDash(L"-"));
gdi.selectItemByData("Status", 0);
gdi.setText("TimeAdjust", "-");
gdi.setText("PointAdjust", "-");
gdi.setText("TimeAdjust", makeDash(L"-"));
gdi.setText("PointAdjust", makeDash(L"-"));
return;
}
@ -270,7 +270,7 @@ void TabTeam::updateTeamStatus(gdioutput &gdi, pTeam t)
gdi.setText("Start", t->getStartTimeS());
gdi.setText("Finish",t->getFinishTimeS());
gdi.setText("Time", t->getRunningTimeS());
gdi.setText("TimeAdjust", getTimeMS(t->getTimeAdjustment()));
gdi.setText("TimeAdjust", getTimeMSW(t->getTimeAdjustment()));
gdi.setText("PointAdjust", -t->getPointAdjustment());
gdi.selectItemByData("Status", t->getStatus());
}
@ -280,7 +280,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
return 0;
DWORD tid=teamId;
string name=gdi.getText("Name");
wstring name=gdi.getText("Name");
if (name.empty()) {
gdi.alert("Alla lag måste ha ett namn.");
@ -301,15 +301,15 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
if (t) {
t->setName(name, true);
if (gdi.hasField("StartNo")) {
const string &bib = gdi.getText("StartNo");
const wstring &bib = gdi.getText("StartNo");
if (bib != t->getBib()) {
bibModified = true;
char pat[32];
wchar_t pat[32];
int no = oClass::extractBibPattern(bib, pat);
t->setBib(bib, no, no > 0, false);
}
}
string start = gdi.getText("Start");
wstring start = gdi.getText("Start");
t->setStartTimeS(start);
if (t->getRunner(0))
t->getRunner(0)->setStartTimeS(start);
@ -364,7 +364,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
bool readStatusIn = true;
if (newClass && t->getInputStatus() != StatusNotCompetiting && t->hasInputData()) {
if (gdi.ask("Vill du sätta resultatet från tidigare etapper till <Deltar ej>?")) {
if (gdi.ask(L"Vill du sätta resultatet från tidigare etapper till <Deltar ej>?")) {
t->resetInputData();
readStatusIn = false;
}
@ -373,7 +373,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
if (newClass && !bibModified) {
pClass pc = oe->getClass(classId);
if (pc) {
pair<int, string> snoBib = pc->getNextBib();
pair<int, wstring> snoBib = pc->getNextBib();
if (snoBib.first > 0) {
t->setBib(snoBib.second, snoBib.first, true, false);
}
@ -412,7 +412,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
if (pc->getLegRunner(i)==i) {
const string name=gdi.getText(bf);
const wstring name=gdi.getText(bf);
if (name.empty()) { //Remove
t->removeRunner(gdi, true, i);
}
@ -532,7 +532,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
ListBoxInfo lbi;
gdi.getSelectedItem("Teams", lbi);
oe->fillTeams(gdi, "Teams");
stdext::hash_set<int> foo;
unordered_set<int> foo;
pTeam t=oe->findTeam(gdi.getText("SearchText"), lbi.data, foo);
if (t) {
@ -574,8 +574,8 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
int leg = bi.getExtraInt();
gdi.fillRight();
gdi.addInput("DirName", "", 16, TeamCB, "Namn:");
gdi.addInput("DirCard", "", 8, TeamCB, "Bricka:");
gdi.addInput("DirName", L"", 16, TeamCB, L"Namn:");
gdi.addInput("DirCard", L"", 8, TeamCB, L"Bricka:");
TabSI &tsi = dynamic_cast<TabSI &>(*gdi.getTabs().get(TSITab));
tsi.setCardNumberField("DirCard");
@ -598,7 +598,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
return 0;
int leg = bi.getExtraInt();
string name = gdi.getText("DirName");
wstring name = gdi.getText("DirName");
int storedId = gdi.getBaseInfo("DirName").getExtraInt();
int card = gdi.getTextNo("DirCard");
@ -618,7 +618,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
pRunner old = oe->getRunnerByCardNo(card, 0, true, true);
if (old && r != old) {
throw meosException("Brickan används av X.#" + old->getName() );
throw meosException(L"Brickan används av X.#" + old->getName() );
}
@ -663,9 +663,9 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
}
else if (bi.id == "Browse") {
const char *target = (const char *)bi.getExtra();
vector< pair<string, string> > ext;
ext.push_back(make_pair("Laguppställning", "*.csv;*.txt"));
string fileName = gdi.browseForOpen(ext, "csv");
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"Laguppställning", L"*.csv;*.txt"));
wstring fileName = gdi.browseForOpen(ext, L"csv");
if (!fileName.empty())
gdi.setText(target, fileName);
}
@ -679,11 +679,11 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
gdi.fillRight();
gdi.pushX();
gdi.dropLine();
gdi.addSelection("ForkKey", 100, 400, 0, "Gafflingsnyckel:");
gdi.addSelection("ForkKey", 100, 400, 0, L"Gafflingsnyckel:");
int nf = pc->getNumForks();
vector< pair<string, size_t> > keys;
vector< pair<wstring, size_t> > keys;
for (int f = 0; f < nf; f++) {
keys.push_back( make_pair(itos(f+1), f));
keys.push_back( make_pair(itow(f+1), f));
}
int currentKey = max(t->getStartNo()-1, 0) % nf;
gdi.addItem("ForkKey", keys);
@ -761,7 +761,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
gdi.dropLine();
gdi.fillDown();
gdi.addString("", fontMediumPlus, "Välj löpare för sträcka X#" + pc->getLegNumber(leg));
gdi.addString("", fontMediumPlus, L"Välj löpare för sträcka X#" + pc->getLegNumber(leg));
gdi.setData("Leg", leg);
gdi.setRestorePoint("DirectEntry");
@ -776,9 +776,9 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
gdi.getTargetDimension(w, h);
w = max(w, gdi.getWidth());
int limit = max(w - gdi.scaleLength(150), gdi.getCX() + gdi.scaleLength(200));
set< pair<string, int> > rToList;
set< pair<wstring, int> > rToList;
set<int> usedR;
string anon = lang.tl("N.N.");
wstring anon = lang.tl("N.N.");
set<int> clubs;
for (int i = 0; i < t->getNumRunners(); i++) {
@ -829,7 +829,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
}
vector< pair<string, size_t> > otherR;
vector< pair<wstring, size_t> > otherR;
for (size_t i = 0; i < clsR.size(); i++) {
if (clsR[i]->getRaceNo() > 0)
@ -838,10 +838,10 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
continue;
if (usedR.count(clsR[i]->getId()))
continue;
const string &club = clsR[i]->getClub();
string id = clsR[i]->getName() + ", " + clsR[i]->getClass();
const wstring &club = clsR[i]->getClub();
wstring id = clsR[i]->getName() + L", " + clsR[i]->getClass();
if (!club.empty())
id += " (" + club + ")";
id += L" (" + club + L")";
otherR.push_back(make_pair(id, clsR[i]->getId()));
}
@ -876,10 +876,10 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
else if (bi.id=="Add") {
if (teamId>0) {
string name = gdi.getText("Name");
wstring name = gdi.getText("Name");
pTeam t = oe->getTeam(teamId);
if (!name.empty() && t && t->getName() != name) {
if (gdi.ask("Vill du lägga till laget 'X'?#" + name)) {
if (gdi.ask(L"Vill du lägga till laget 'X'?#" + name)) {
t = oe->addTeam(name);
teamId = t->getId();
}
@ -903,7 +903,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
pClass pc = oe->getClass(clsId);
if (pc) {
pair<int, string> snoBib = pc->getNextBib();
pair<int, wstring> snoBib = pc->getNextBib();
if (snoBib.first > 0) {
t->setBib(snoBib.second, snoBib.first, true, false);
}
@ -930,7 +930,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
if (!t || t->isRemoved()) {
selectTeam(gdi, 0);
}
else if (gdi.ask("Vill du verkligen ta bort laget?")) {
else if (gdi.ask(L"Vill du verkligen ta bort laget?")) {
vector<int> runners;
vector<int> noRemove;
for (int k = 0; k < t->getNumRunners(); k++) {
@ -1025,7 +1025,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
if (r) {
sprintf_s(bf, "SI%d", i);
int cno = r->getCardNo();
gdi.setText(bf, cno > 0 ? itos(cno) : "");
gdi.setText(bf, cno > 0 ? itow(cno) : L"");
warnDuplicateCard(gdi, bf, cno, r, rCache);
}
}
@ -1084,9 +1084,9 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
matched = true;
}
else if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::RunnerDb)) {
const RunnerDBEntry *rdb = oe->getRunnerDatabase().getRunnerByCard(cno);
const RunnerWDBEntry *rdb = oe->getRunnerDatabase().getRunnerByCard(cno);
if (rdb) {
string name;
wstring name;
rdb->getName(name);
gdi.setText("DirName", name)->setExtra(0);
matched = true;
@ -1103,7 +1103,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
if (pc) {
for(unsigned i=0;i<pc->getNumStages();i++){
if (ii.id == "SI" + itos(i)) {
int cardNo = atoi(ii.text.c_str());
int cardNo = _wtoi(ii.text.c_str());
pTeam t = oe->getTeam(teamId);
if (t) {
vector<pRunner> rc;
@ -1172,26 +1172,26 @@ void TabTeam::loadTeamMembers(gdioutput &gdi, int ClassId, int ClubId, pTeam t)
sprintf_s(bf, "R%d", i);
gdi.pushX();
bool hasSI = false;
gdi.addStringUT(yp, numberPos, 0, pc->getLegNumber(i)+".");
gdi.addStringUT(yp, numberPos, 0, pc->getLegNumber(i) + L".");
if (pc->getLegRunner(i)==i) {
gdi.addInput(xp + dx[0], yp, bf, "", 18, TeamCB);//Name
gdi.addInput(xp + dx[0], yp, bf, L"", 18, TeamCB);//Name
gdi.addButton(xp + dx[1], yp-2, gdi.scaleLength(28), "DR" + itos(i), "<>", TeamCB, "Knyt löpare till sträckan.", false, false); // Change
sprintf_s(bf_si, "SI%d", i);
hasSI = true;
gdi.addInput(xp + dx[2], yp, bf_si, "", 5, TeamCB).setExtra(i); //Si
gdi.addInput(xp + dx[2], yp, bf_si, L"", 5, TeamCB).setExtra(i); //Si
gdi.addCheckbox(xp + dx[3], yp + gdi.scaleLength(10), "RENT"+itos(i), "", 0, false); //Rentcard
}
else {
//gdi.addInput(bf, "", 24);
gdi.addInput(xp + dx[0], yp, bf, "", 18, 0);//Name
gdi.addInput(xp + dx[0], yp, bf, L"", 18, 0);//Name
gdi.disableInput(bf);
}
gdi.addButton(xp + dx[4], yp-2, gdi.scaleLength(38), "MR" + itos(i), "...", TeamCB, "Redigera deltagaren.", false, false); // Change
gdi.addString(("STATUS"+itos(i)).c_str(), yp+gdi.scaleLength(5), xp + dx[5], 0, "#MMMMMMMMMMMMMMMM");
gdi.setText("STATUS"+itos(i), "", false);
gdi.setText("STATUS"+itos(i), L"", false);
gdi.dropLine(0.5);
gdi.popX();
@ -1203,18 +1203,18 @@ void TabTeam::loadTeamMembers(gdioutput &gdi, int ClassId, int ClubId, pTeam t)
if (hasSI) {
int cno = r->getCardNo();
gdi.setText(bf_si, cno > 0 ? itos(cno) : "");
gdi.setText(bf_si, cno > 0 ? itow(cno) : L"");
warnDuplicateCard(gdi, bf_si, cno, r, rCache);
gdi.check("RENT" + itos(i), r->getDCI().getInt("CardFee") != 0);
}
string sid = "STATUS"+itos(i);
if (r->statusOK()) {
TextInfo * ti = (TextInfo *)gdi.setText(sid, "OK, " + r->getRunningTimeS(), false);
TextInfo * ti = (TextInfo *)gdi.setText(sid, L"OK, " + r->getRunningTimeS(), false);
if (ti)
ti->setColor(colorGreen);
}
else if (r->getStatus() != StatusUnknown) {
TextInfo * ti = (TextInfo *)gdi.setText(sid, r->getStatusS() + ", " + r->getRunningTimeS(), false);
TextInfo * ti = (TextInfo *)gdi.setText(sid, r->getStatusS() + L", " + r->getRunningTimeS(), false);
if (ti)
ti->setColor(colorRed);
}
@ -1229,20 +1229,20 @@ void TabTeam::loadTeamMembers(gdioutput &gdi, int ClassId, int ClubId, pTeam t)
if (numF>1 && t) {
gdi.addString ("", 1, "Gafflingsnyckel X#" + itos(1+(max(t->getStartNo()-1, 0) % numF))).setColor(colorGreen);
string crsList;
wstring crsList;
bool hasCrs = false;
for (size_t k = 0; k < pc->getNumStages(); k++) {
pCourse crs = pc->getCourse(k, t->getStartNo());
string cS;
wstring cS;
if (crs != 0) {
cS = crs->getName();
hasCrs = true;
}
else
cS = MakeDash("-");
cS = makeDash(L"-");
if (!crsList.empty())
crsList += ", ";
crsList += L", ";
crsList += cS;
if (hasCrs && crsList.length() > 50) {
@ -1295,14 +1295,14 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.registerEvent("SearchRunner", teamSearchCB).setKeyCommand(KC_FIND);
gdi.registerEvent("SearchRunnerBack", teamSearchCB).setKeyCommand(KC_FINDBACK);
gdi.addInput("SearchText", "", 17, teamSearchCB, "", "Sök på namn, bricka eller startnummer.").isEdit(false).setBgColor(colorLightCyan).ignore(true);
gdi.addInput("SearchText", L"", 17, teamSearchCB, L"", L"Sök på namn, bricka eller startnummer.").isEdit(false).setBgColor(colorLightCyan).ignore(true);
gdi.dropLine(-0.2);
gdi.addButton("ShowAll", "Visa alla", TeamCB).isEdit(false);
gdi.dropLine(2);
gdi.popX();
gdi.fillDown();
gdi.addListBox("Teams", 250, 440, TeamCB, "", "").isEdit(false).ignore(true);
gdi.addListBox("Teams", 250, 440, TeamCB, L"", L"").isEdit(false).ignore(true);
gdi.setInputFocus("Teams");
fillTeamList(gdi);
@ -1312,17 +1312,17 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.newColumn();
gdi.fillDown();
gdi.pushX();
gdi.addInput("Name", "", 24, 0, "Lagnamn:");
gdi.addInput("Name", L"", 24, 0, L"Lagnamn:");
gdi.fillRight();
bool drop = false;
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Bib)) {
gdi.addInput("StartNo", "", 4, 0, "Nr:", "Nummerlapp");
gdi.addInput("StartNo", L"", 4, 0, L"Nr:", L"Nummerlapp");
drop = oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy);
}
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Clubs)) {
gdi.addCombo("Club", 180, 300, 0, "Klubb:");
gdi.addCombo("Club", 180, 300, 0, L"Klubb:");
oe->fillClubs(gdi, "Club");
drop = true;
}
@ -1332,12 +1332,12 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.popX();
}
gdi.addSelection("RClass", 170, 300, TeamCB, "Klass:");
gdi.addSelection("RClass", 170, 300, TeamCB, L"Klass:");
oe->fillClasses(gdi, "RClass", oEvent::extraNone, oEvent::filterNone);
gdi.addItem("RClass", lang.tl("Ny klass"), 0);
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy))
gdi.addInput("Fee", "", 5, 0, "Avgift:");
gdi.addInput("Fee", L"", 5, 0, L"Avgift:");
gdi.popX();
gdi.fillDown();
@ -1346,8 +1346,8 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.pushX();
gdi.fillRight();
gdi.addInput("Start", "", 8, 0, "Starttid:");
gdi.addInput("Finish", "", 8, 0, "Måltid:");
gdi.addInput("Start", L"", 8, 0, L"Starttid:");
gdi.addInput("Finish", L"", 8, 0, L"Måltid:");
const bool timeAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::TimeAdjust);
const bool pointAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::PointAdjust);
@ -1356,10 +1356,10 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.dropLine(3);
gdi.popX();
if (timeAdjust) {
gdi.addInput("TimeAdjust", "", 8, 0, "Tidstillägg:");
gdi.addInput("TimeAdjust", L"", 8, 0, L"Tidstillägg:");
}
if (pointAdjust) {
gdi.addInput("PointAdjust", "", 8, 0, "Poängavdrag:");
gdi.addInput("PointAdjust", L"", 8, 0, L"Poängavdrag:");
}
}
@ -1377,11 +1377,11 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.pushX();
gdi.fillRight();
gdi.addInput("Time", "", 6, 0, "Tid:").isEdit(false).ignore(true);
gdi.addInput("Time", L"", 6, 0, L"Tid:").isEdit(false).ignore(true);
gdi.disableInput("Time");
gdi.fillDown();
gdi.addSelection("Status", 100, 160, 0, "Status:", "tooltip_explain_status");
gdi.addSelection("Status", 100, 160, 0, L"Status:", L"tooltip_explain_status");
oe->fillStatus(gdi, "Status");
gdi.popX();
@ -1403,16 +1403,16 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.dropLine(0.3);
gdi.fillRight();
gdi.addSelection("StatusIn", 100, 160, 0, "Status:", "tooltip_explain_status");
gdi.addSelection("StatusIn", 100, 160, 0, L"Status:", L"tooltip_explain_status");
oe->fillStatus(gdi, "StatusIn");
gdi.selectItemByData("Status", 0);
gdi.addInput("PlaceIn", "", 5, 0, "Placering:");
gdi.addInput("PlaceIn", L"", 5, 0, L"Placering:");
int xmax = gdi.getCX() + dx;
gdi.setCX(ccx);
gdi.dropLine(3);
gdi.addInput("TimeIn", "", 5, 0, "Tid:");
gdi.addInput("TimeIn", L"", 5, 0, L"Tid:");
if (oe->hasRogaining()) {
gdi.addInput("PointIn", "", 5, 0, "Poäng:");
gdi.addInput("PointIn", L"", 5, 0, L"Poäng:");
}
gdi.dropLine(3);
RECT rc;
@ -1471,14 +1471,14 @@ void TabTeam::fillTeamList(gdioutput &gdi) {
timeToFill = GetTickCount();
oe->fillTeams(gdi, "Teams");
timeToFill = GetTickCount() - timeToFill;
lastSearchExpr = "";
lastSearchExpr = L"";
((InputInfo *)gdi.setText("SearchText", getSearchString()))->setFgColor(colorGreyBlue);
lastFilter.clear();
}
const string &TabTeam::getSearchString() const {
return lang.tl("Sök (X)#Ctrl+F");
const wstring &TabTeam::getSearchString() const {
return lang.tl(L"Sök (X)#Ctrl+F");
}
void TabTeam::addToolbar(gdioutput &gdi) const {
@ -1505,9 +1505,9 @@ void TabTeam::showTeamImport(gdioutput &gdi) {
gdi.pushX();
gdi.fillRight();
gdi.addInput("FileName", "", 40, 0, "Filnamn:");
gdi.addInput("FileName", L"", 40, 0, L"Filnamn:");
gdi.dropLine(0.9);
gdi.addButton("Browse", "Bläddra", TeamCB).setExtra("FileName");
gdi.addButton("Browse", "Bläddra", TeamCB).setExtra(L"FileName");
gdi.dropLine(3);
gdi.popX();
gdi.fillDown();
@ -1521,12 +1521,12 @@ void TabTeam::showTeamImport(gdioutput &gdi) {
}
void TabTeam::doTeamImport(gdioutput &gdi) {
string file = gdi.getText("FileName");
wstring file = gdi.getText("FileName");
bool useExisting = gdi.isChecked("OnlyExisting");
csvparser csv;
map<string, int> classNameToNumber;
map<wstring, int> classNameToNumber;
vector<pClass> cls;
oe->getClasses(cls, true);
for (size_t k = 0; k < cls.size();k++) {
@ -1539,16 +1539,16 @@ void TabTeam::doTeamImport(gdioutput &gdi) {
gdi.dropLine();
for (size_t k = 0; k < teamLineup.size(); k++) {
string tdesc = teamLineup[k].teamClass +", " + teamLineup[k].teamName;
wstring tdesc = teamLineup[k].teamClass + L", " + teamLineup[k].teamName;
if (!teamLineup[k].teamClub.empty())
tdesc += ", " + teamLineup[k].teamClub;
tdesc += L", " + teamLineup[k].teamClub;
gdi.addStringUT(1, tdesc);
for (size_t j = 0; j < teamLineup[k].members.size(); j++) {
TeamLineup::TeamMember &member = teamLineup[k].members[j];
if (member.name.empty())
continue;
string mdesc = " " + itos(j+1) + ". ";
wstring mdesc = L" " + itow(j+1) + L". ";
bool warn = false;
if (useExisting) {
@ -1556,28 +1556,28 @@ void TabTeam::doTeamImport(gdioutput &gdi) {
if (r != 0)
mdesc += r->getCompleteIdentification();
else {
mdesc += member.name + lang.tl(" (ej funnen)");
mdesc += member.name + lang.tl(L" (ej funnen)");
warn = true;
}
}
else {
mdesc += member.name + " (" + itos(member.cardNo) + ") " + member.club;
mdesc += member.name + L" (" + itow(member.cardNo) + L") " + member.club;
}
if (!member.course.empty()) {
if (oe->getCourse(member.course))
mdesc += " : " + member.course;
mdesc += L" : " + member.course;
else {
mdesc += " : " + lang.tl("Banan saknas");
mdesc += L" : " + lang.tl(L"Banan saknas");
warn = true;
}
}
if (!member.cls.empty()) {
if (oe->getClass(member.cls))
mdesc += " [" + member.cls + "]";
mdesc += L" [" + member.cls + L"]";
else {
mdesc += " " + lang.tl("Klassen saknas");
mdesc += L" " + lang.tl(L"Klassen saknas");
warn = true;
}
}
@ -1642,14 +1642,14 @@ void TabTeam::saveTeamImport(gdioutput &gdi, bool useExisting) {
loadPage(gdi);
}
pRunner TabTeam::findRunner(const string &name, int cardNo) const {
string n = canonizeName(name.c_str());
pRunner TabTeam::findRunner(const wstring &name, int cardNo) const {
wstring n = canonizeName(name.c_str());
if (cardNo != 0) {
vector<pRunner> pr;
oe->getRunnersByCard(cardNo, pr);
for (size_t k = 0; k < pr.size(); k++) {
string a = canonizeName(pr[k]->getName().c_str());
wstring a = canonizeName(pr[k]->getName().c_str());
if (a == n)
return pr[k];
}
@ -1658,7 +1658,7 @@ pRunner TabTeam::findRunner(const string &name, int cardNo) const {
vector<pRunner> pr;
oe->getRunners(0, 0, pr, false);
for (size_t k = 0; k < pr.size(); k++) {
string a = canonizeName(pr[k]->getName().c_str());
wstring a = canonizeName(pr[k]->getName().c_str());
if (a == n)
return pr[k];
}
@ -1675,7 +1675,7 @@ void TabTeam::showAddTeamMembers(gdioutput &gdi) {
gdi.pushX();
gdi.fillDown();
gdi.addInput("Name", lang.tl("N.N."), 24, 0, "Anonymt namn:");
gdi.addInput("Name", lang.tl("N.N."), 24, 0, L"Anonymt namn:");
gdi.fillDown();
gdi.addCheckbox("OnlyRequired", "Endast på obligatoriska sträckor", 0, true);
gdi.addCheckbox("WithFee", "Med anmälningsavgift (lagets klubb)", 0, true);
@ -1692,7 +1692,7 @@ void TabTeam::doAddTeamMembers(gdioutput &gdi) {
oe->getTeams(0, t, true);
bool onlyReq = gdi.isChecked("OnlyRequired");
bool withFee = gdi.isChecked("WithFee");
string nn = gdi.getText("Name");
wstring nn = gdi.getText("Name");
for (size_t k = 0; k < t.size(); k++) {
pTeam mt = t[k];
@ -1737,14 +1737,14 @@ void TabTeam::doAddTeamMembers(gdioutput &gdi) {
}
void TabTeam::showRunners(gdioutput &gdi, const char *title,
const set< pair<string, int> > &rToList,
const set< pair<wstring, int> > &rToList,
int limitX, set<int> &usedR) {
if (rToList.empty())
return;
bool any = false;
for(set< pair<string, int> >::const_iterator it = rToList.begin(); it != rToList.end(); ++it) {
for(set< pair<wstring, int> >::const_iterator it = rToList.begin(); it != rToList.end(); ++it) {
if (usedR.count(it->second))
continue;
usedR.insert(it->second);
@ -1761,7 +1761,7 @@ void TabTeam::showRunners(gdioutput &gdi, const char *title,
gdi.popX();
}
gdi.addString("SelectR", 0, "#" + it->first, TeamCB).setExtra(it->second);
gdi.addString("SelectR", 0, L"#" + it->first, TeamCB).setExtra(it->second);
}
if (any) {
@ -1780,16 +1780,16 @@ void TabTeam::processChangeRunner(gdioutput &gdi, pTeam t, int leg, pRunner r) {
}
else if (oldR) {
if (r->getTeam()) {
ans = gdi.askCancel("Vill du att X och Y byter sträcka?#" +
r->getName() + "#" + oldR->getName());
ans = gdi.askCancel(L"Vill du att X och Y byter sträcka?#" +
r->getName() + L"#" + oldR->getName());
}
else {
ans = gdi.askCancel("Vill du att X tar sträckan istället för Y?#" +
r->getName() + "#" + oldR->getName());
ans = gdi.askCancel(L"Vill du att X tar sträckan istället för Y?#" +
r->getName() + L"#" + oldR->getName());
}
}
else {
ans = gdi.askCancel("Vill du att X går in i laget?#" + r->getName());
ans = gdi.askCancel(L"Vill du att X går in i laget?#" + r->getName());
}
if (ans == gdioutput::AnswerNo)
@ -1884,14 +1884,14 @@ bool TabTeam::warnDuplicateCard(gdioutput &gdi, string id, int cno, pRunner r, v
InputInfo &cardNo = dynamic_cast<InputInfo &>(gdi.getBaseInfo(id.c_str()));
if (warnCardDupl) {
cardNo.setBgColor(colorLightRed);
gdi.updateToolTip(id, "Brickan används av X.#" + warnCardDupl->getCompleteIdentification());
gdi.updateToolTip(id, L"Brickan används av X.#" + warnCardDupl->getCompleteIdentification());
cardNo.refresh();
return warnCardDupl->getTeam() == r->getTeam();
}
else {
if (cardNo.getBgColor() != colorDefault) {
cardNo.setBgColor(colorDefault);
gdi.updateToolTip(id, "");
gdi.updateToolTip(id, L"");
cardNo.refresh();
}
return false;

View File

@ -30,8 +30,8 @@ class TabTeam :
private:
bool save(gdioutput &gdi, bool dontReloadTeams);
string lastSearchExpr;
stdext::hash_set<int> lastFilter;
wstring lastSearchExpr;
unordered_set<int> lastFilter;
DWORD timeToFill;
int inputId;
int searchCB(gdioutput &gdi, int type, void *data);
@ -45,7 +45,7 @@ private:
int shownRunners;
int shownDistinctRunners;
const string &getSearchString() const;
const wstring &getSearchString() const;
void fillTeamList(gdioutput &gdi);
void addToolbar(gdioutput &gdi) const;
@ -59,13 +59,13 @@ private:
void doAddTeamMembers(gdioutput &gdi);
void showRunners(gdioutput &gdi, const char *title,
const set< pair<string, int> > &rToList,
const set< pair<wstring, int> > &rToList,
int limitX, set<int> &usedR);
void processChangeRunner(gdioutput &gdi, pTeam t, int leg, pRunner r);
pRunner findRunner(const string &name, int cardNo) const;
pRunner findRunner(const wstring &name, int cardNo) const;
vector<TeamLineup> teamLineup;
// Returns true if the warning concerns the same team

View File

@ -42,7 +42,7 @@ const Table *TableSortIndex::table = 0;
int Table::uniqueId = 1;
Table::Table(oEvent *oe_, int rowH,
const string &name, const string &iName)
const wstring &name, const string &iName)
{
id = uniqueId++;
commandLock = false;
@ -111,7 +111,7 @@ void Table::clearCellSelection(gdioutput *gdi) {
int Table::addColumn(const string &Title, int width, bool isnum, bool formatRight) {
ColInfo ri;
strcpy_s(ri.name, lang.tl(Title).c_str());
wcscpy_s(ri.name, lang.tl(Title).c_str());
ri.baseWidth = width;
ri.width = 0;
ri.padWidthZeroSort = 0;
@ -125,7 +125,7 @@ int Table::addColumn(const string &Title, int width, bool isnum, bool formatRigh
int Table::addColumnPaddedSort(const string &title, int width, int padding, bool formatRight) {
ColInfo ri;
strcpy_s(ri.name, lang.tl(title).c_str());
wcscpy_s(ri.name, lang.tl(title).c_str());
ri.baseWidth = width;
ri.width = 0;
ri.padWidthZeroSort = padding;
@ -204,7 +204,7 @@ void Table::addRow(int rowId, oBase *object)
for (unsigned i=0;i<nTitles;i++) {
Data[0].cells[i].contents=Titles[i].name;
Data[1].cells[i].contents="...";
Data[1].cells[i].contents = L"...";
Data[0].cells[i].canEdit=false;
Data[0].cells[i].type=cellEdit;
@ -227,7 +227,7 @@ void Table::addRow(int rowId, oBase *object)
Data.push_back(tr);
}
void Table::set(int column, oBase &owner, int id, const string &data, bool canEdit, CellType type)
void Table::set(int column, oBase &owner, int id, const wstring &data, bool canEdit, CellType type)
{
if (dataPointer >= Data.size() || dataPointer<2)
throw std::exception("Internal table error: wrong data pointer");
@ -241,14 +241,14 @@ void Table::set(int column, oBase &owner, int id, const string &data, bool canEd
cell.type=type;
}
void Table::filter(int col, const string &filt, bool forceFilter)
void Table::filter(int col, const wstring &filt, bool forceFilter)
{
const string &oldFilter=Titles[col].filter;
const wstring &oldFilter=Titles[col].filter;
vector<TableSortIndex> baseIndex;
if (filt==oldFilter && (!forceFilter || filt.empty()))
return;
else if (strncmp(oldFilter.c_str(), filt.c_str(), oldFilter.length())==0) {
else if (wcsncmp(oldFilter.c_str(), filt.c_str(), oldFilter.length())==0) {
//Filter more...
baseIndex.resize(2);
baseIndex[0]=sortIndex[0];
@ -272,8 +272,8 @@ void Table::filter(int col, const string &filt, bool forceFilter)
return;
}
char filt_lc[1024];
strcpy_s(filt_lc, filt.c_str());
wchar_t filt_lc[1024];
wcscpy_s(filt_lc, filt.c_str());
CharLowerBuff(filt_lc, filt.length());
sortIndex.resize(2);
@ -309,7 +309,7 @@ void Table::sort(int col)
bool hasDeci = false;
for(size_t k=2; k<sortIndex.size(); k++){
Data[sortIndex[k].index].key.clear();
const char *str = Data[sortIndex[k].index].cells[col].contents.c_str();
const wchar_t *str = Data[sortIndex[k].index].cells[col].contents.c_str();
int i = 0;
while (str[i] != 0 && str[i] != ':' && str[i] != ',' && str[i] != '.')
@ -324,7 +324,7 @@ void Table::sort(int col)
while (str[i] != 0 && (str[i] < '0' || str[i] > '9'))
i++;
int key = atoi(str + i);
int key = _wtoi(str + i);
Data[sortIndex[k].index].intKey = key;
if (key == 0)
Data[sortIndex[k].index].key = Data[sortIndex[k].index].cells[col].contents;
@ -333,7 +333,7 @@ void Table::sort(int col)
if (hasDeci) { // Times etc.
for(size_t k=2; k<sortIndex.size(); k++){
Data[sortIndex[k].index].key.clear();
const char *str = Data[sortIndex[k].index].cells[col].contents.c_str();
const wchar_t *str = Data[sortIndex[k].index].cells[col].contents.c_str();
int i = 0;
while (str[i] != 0 && (str[i] < '0' || str[i] > '9'))
@ -370,8 +370,8 @@ void Table::sort(int col)
else {
if (Titles[col].padWidthZeroSort) {
for (size_t k=2; k<sortIndex.size(); k++) {
string &key = Data[sortIndex[k].index].key;
const string &contents = Data[sortIndex[k].index].cells[col].contents;
wstring &key = Data[sortIndex[k].index].key;
const wstring &contents = Data[sortIndex[k].index].cells[col].contents;
if (contents.length() < unsigned(Titles[col].padWidthZeroSort)) {
key.resize(Titles[col].padWidthZeroSort+1);
int cl = Titles[col].padWidthZeroSort-contents.length();
@ -382,32 +382,31 @@ void Table::sort(int col)
}
else
key = contents;
//key = Data[sortIndex[k].index].cells[col].contents;
const BYTE *strBuff = (const BYTE *)key.c_str();
CharUpperBuff(LPSTR(strBuff), key.size());
const wchar_t *strBuff = (const wchar_t *)key.c_str();
CharUpperBuff(LPWSTR(strBuff), key.size());
int &intKey = Data[sortIndex[k].index].intKey;
intKey = unsigned(strBuff[0])<<16;
if (key.length() > 1) {
intKey |= unsigned(strBuff[1])<<8;
intKey |= unsigned(strBuff[2]);
intKey |= unsigned(strBuff[1]);
}
}
}
else {
for (size_t k=2; k<sortIndex.size(); k++) {
string &key = Data[sortIndex[k].index].key;
wstring &key = Data[sortIndex[k].index].key;
key = Data[sortIndex[k].index].cells[col].contents;
const BYTE *strBuff = (const BYTE *)key.c_str();
CharUpperBuff(LPSTR(strBuff), key.size());
const wchar_t *strBuff = (const wchar_t *)key.c_str();
CharUpperBuff(LPWSTR(strBuff), key.size());
int &intKey = Data[sortIndex[k].index].intKey;
if ( ((strBuff[0]|strBuff[1]) & 128) == 0) {
if ( ((strBuff[0]|strBuff[1]) & ~127) == 0) {
intKey = unsigned(strBuff[0])<<16;
if (key.length() > 1) {
intKey |= unsigned(strBuff[1])<<8;
intKey |= unsigned(strBuff[2]);
//intKey |= unsigned(strBuff[2]);
}
}
else {
@ -717,15 +716,13 @@ int tblSelectionCB(gdioutput *gdi, int type, void *data)
return 0;
}
void Table::selection(gdioutput &gdi, const string &text, int data) {
void Table::selection(gdioutput &gdi, const wstring &text, int data) {
if (size_t(selectionRow) >= Data.size() || size_t(selectionCol) >= Titles.size())
throw std::exception("Index out of bounds.");
TableCell &cell = Data[selectionRow].cells[selectionCol];
int id = Data[selectionRow].id;
string output = cell.contents;
cell.owner->inputData(cell.id, text, data, output, false);
cell.contents = output;
cell.owner->inputData(cell.id, text, data, cell.contents, false);
reloadRow(id);
RECT rc;
getRowRect(selectionRow, rc);
@ -740,11 +737,11 @@ bool Table::keyCommand(gdioutput &gdi, KeyCommandCode code) {
commandLock = true;
try {
if (code == KC_COPY)
if (code == KC_COPY && hEdit == 0)
exportClipboard(gdi);
else if (code == KC_PASTE) {
else if (code == KC_PASTE && hEdit == 0) {
importClipboard(gdi);
}else if (code == KC_DELETE) {
}else if (code == KC_DELETE && hEdit == 0) {
deleteSelection(gdi);
}
else if (code == KC_REFRESH) {
@ -758,7 +755,7 @@ bool Table::keyCommand(gdioutput &gdi, KeyCommandCode code) {
gdi.refresh();
}
else if (code == KC_PRINT) {
gdioutput gdiPrint("temp", gdi.getScale(), gdi.getEncoding());
gdioutput gdiPrint("temp", gdi.getScale(), gdi.getCP());
gdiPrint.clearPage(false);
gdiPrint.print(getEvent(), this);
}
@ -778,7 +775,7 @@ bool Table::deleteSelection(gdioutput &gdi) {
int r1, r2;
getRowRange(r1, r2);
if (r1 != -1 && r2 != -1 && r1<=r2) {
if (!gdi.ask("Vill du radera X rader från tabellen?#" + itos(r2-r1+1)))
if (!gdi.ask(L"Vill du radera X rader från tabellen?#" + itow(r2-r1+1)))
return false;
gdi.setWaitCursor(true);
int failed = deleteRows(r1, r2);
@ -794,6 +791,9 @@ void Table::hide(gdioutput &gdi) {
try {
destroyEditControl(gdi);
}
catch (meosException &ex) {
gdi.alert(ex.wwhat());
}
catch (std::exception &ex) {
gdi.alert(ex.what());
}
@ -866,7 +866,7 @@ bool Table::mouseLeftDown(gdioutput &gdi, int x, int y) {
editRow=highRow;
editCol=highCol;
hEdit=CreateWindowEx(0, "EDIT", Titles[highCol].filter.c_str(),
hEdit=CreateWindowEx(0, L"EDIT", Titles[highCol].filter.c_str(),
WS_TABSTOP|WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL|WS_BORDER,
rc.left+105, rc.top, tableWidth-105, (rc.bottom-rc.top-1), gdi.getTarget(),
0, hInst, 0);
@ -929,7 +929,7 @@ bool Table::editCell(gdioutput &gdi, int row, int col) {
selectionRow = row;
selectionCol = col;
vector< pair<string, size_t> > out;
vector< pair<wstring, size_t> > out;
size_t selected = 0;
cell.owner->fillInput(cell.id, out, selected);
@ -952,7 +952,7 @@ bool Table::editCell(gdioutput &gdi, int row, int col) {
return true;
}
else if (cell.type==cellEdit) {
hEdit=CreateWindowEx(0, "EDIT", cell.contents.c_str(),
hEdit=CreateWindowEx(0, L"EDIT", cell.contents.c_str(),
WS_TABSTOP|WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL|WS_BORDER,
rc.left, rc.top, rc.right-rc.left+1, (rc.bottom-rc.top), gdi.getTarget(),
0, hInst, 0);
@ -1019,7 +1019,7 @@ void Table::initEmpty() {
}
void drawSymbol(gdioutput &gdi, HDC hDC, int height,
const TextInfo &ti, const string &symbol, bool highLight) {
const TextInfo &ti, const wstring &symbol, bool highLight) {
int cx = ti.xp - gdi.GetOffsetX() + ti.xlimit/2;
int cy = ti.yp - gdi.GetOffsetY() + height/2 - 2;
int h = int(height * 0.4);
@ -1169,8 +1169,8 @@ void Table::draw(gdioutput &gdi, HDC hDC, int dx, int dy, const RECT &screen)
ti.format = 0;
gdi.formatString(ti, hDC);
SetTextColor(hDC, RGB(255,255,255));
char bf[256];
string info = lang.tl(string("sortering: X, antal rader: Y#") + Titles[currentSortColumn].name + "#" + itos(sortIndex.size()-2));
wchar_t bf[256];
wstring info = lang.tl(wstring(L"sortering: X, antal rader: Y#") + Titles[currentSortColumn].name + L"#" + itow(sortIndex.size()-2));
//sprintf_s(bf, .c_str(),
// Titles[currentSortColumn].name, int(sortIndex.size())-2);
rc.left=rc.right+30;
@ -1189,12 +1189,12 @@ void Table::draw(gdioutput &gdi, HDC hDC, int dx, int dy, const RECT &screen)
rc.right=rc.left+100;
rc.top=dy+3+2*rowHeight-gdi.OffsetY;
rc.bottom=rc.top+rowHeight;
char tbf[2];
wchar_t tbf[2];
tbf[0]=Titles[editCol].name[0];
tbf[1]=0;
CharLower(tbf);
string filter = lang.tl("Urval %c%s:")+" ";
sprintf_s(bf, filter.c_str(), tbf[0],
wstring filter = lang.tl("Urval %c%s: ");
swprintf_s(bf, filter.c_str(), tbf[0],
Titles[editCol].name+1, int(sortIndex.size())-2);
DrawText(hDC, bf, -1, &rc, DT_RIGHT|DT_NOPREFIX);
@ -1205,7 +1205,7 @@ void Table::draw(gdioutput &gdi, HDC hDC, int dx, int dy, const RECT &screen)
yp=dy+rowHeight;
if (firstRow<=2 && lastRow>=1) {
string filterText = lang.tl("Urval...");
wstring filterText = lang.tl("Urval...");
for (int k=firstCol;k<lastCol;k++) {
int xp=xpos[k];
@ -1508,7 +1508,7 @@ void Table::print(gdioutput &gdi, HDC hDC, int dx, int dy)
int i=columns[j];
TextInfo ti;
ti.format = boldSmall;
ti.text = Titles[i].name;
ti.text = Titles[i].name;
gdi.calcStringSize(ti, hDC);
widths[j] = max<int>(widths[j], ti.textRect.right-ti.textRect.left);
rh = max<int>(rh, ti.textRect.bottom-ti.textRect.top);
@ -1518,7 +1518,7 @@ void Table::print(gdioutput &gdi, HDC hDC, int dx, int dy)
for (size_t j=0;j<columns.size();j++) {
for (size_t k=2; k<sortIndex.size(); k++) {
TableRow &tr=Data[sortIndex[k].index];
const string &ct = tr.cells[columns[j]].contents;
const wstring &ct = tr.cells[columns[j]].contents;
if (!ct.empty()) {
skip[j] = false;
TextInfo ti;
@ -1584,14 +1584,14 @@ bool Table::tabFocus(gdioutput &gdi, int direction)
return false;
}
void Table::setTableText(gdioutput &gdi, int editRow, int editCol, const string &bf) {
void Table::setTableText(gdioutput &gdi, int editRow, int editCol, const wstring &bf) {
if (size_t(editRow) >= Data.size() || size_t(editCol) >= Data[editRow].cells.size())
throw std::exception("Index out of bounds");
string output;
wstring output;
TableCell &cell=Data[editRow].cells[editCol];
cell.owner->inputData(cell.id, bf, 0, output, false);
cell.contents=output;
cell.contents = output;
if (hEdit != 0)
DestroyWindow(hEdit);
hEdit=0;
@ -1601,7 +1601,7 @@ void Table::setTableText(gdioutput &gdi, int editRow, int editCol, const string
InvalidateRect(gdi.getTarget(), &rc, false);
}
const string &Table::getTableText(gdioutput &gdi, int editRow, int editCol) {
const wstring &Table::getTableText(gdioutput &gdi, int editRow, int editCol) {
if (size_t(editRow) >= Data.size() || size_t(editCol) >= Data[editRow].cells.size())
throw std::exception("Index out of bounds");
@ -1616,23 +1616,16 @@ bool Table::enter(gdioutput &gdi)
{
if (hEdit) {
if (unsigned(editRow)<Data.size() && unsigned(editCol)<Titles.size()) {
char bf[1024];
wchar_t bf[1024];
GetWindowText(hEdit, bf, 1024);
if (editRow>=2) {
{
string cmd;
if (gdi.getRecorder().recording())
cmd = "setTableText(" + itos(editRow) + ", " + itos(editCol) + ", \"" + string(bf) + "\");";
setTableText(gdi, editRow, editCol, bf);
gdi.getRecorder().record(cmd);
return true;
}/*
catch(const std::exception &ex) {
string msg(ex.what());
gdi.alert(msg);
}*/
string cmd;
if (gdi.getRecorder().recording())
cmd = "setTableText(" + itos(editRow) + ", " + itos(editCol) + ", \"" + gdi.narrow(bf) + "\");";
setTableText(gdi, editRow, editCol, bf);
gdi.getRecorder().record(cmd);
return true;
}
else if (editRow==1) {//Filter
filter(editCol, bf);
@ -1673,7 +1666,7 @@ bool Table::inputChange(gdioutput &gdi, HWND hdt)
if (hEdit==hdt) {
if (drawFilterLabel) {
char bf[256];
wchar_t bf[256];
GetWindowText(hEdit, bf, 256);
filter(editCol, bf);
updateDimension(gdi);
@ -1802,7 +1795,7 @@ void Table::resetColumns()
columns[k] = k;
for (size_t k=0;k<nTitles;k++)
filter(k, "", false);
filter(k, L"", false);
doAutoSelectColumns = false;
}
@ -1835,32 +1828,32 @@ void Table::update()
commandLock = false; // Reset lock
}
void Table::getExportData(int col1, int col2, int row1, int row2, string &html, string &txt) const
void Table::getExportData(int col1, int col2, int row1, int row2, wstring &html, wstring &txt) const
{
html = "<html><table>";
txt = "";
html = L"<html><table>";
txt = L"";
for (size_t k = row1; k<=size_t(row2); k++) {
if ( k >= sortIndex.size())
throw std::exception("Index out of range");
const TableRow &tr = Data[sortIndex[k].index];
html += "<tr>";
html += L"<tr>";
for (size_t j = col1; j<= size_t(col2); j++) {
if ( j >= columns.size())
throw std::exception("Index out of range");
int col = columns[j];
const TableCell &cell = tr.cells[col];
html += "<td>" + cell.contents + "</td>";
html += L"<td>" + cell.contents + L"</td>";
if (j == col1)
txt += cell.contents;
else
txt += "\t" + cell.contents;
txt += L"\t" + cell.contents;
}
txt += "\r\n";
html += "</tr>";
txt += L"\r\n";
html += L"</tr>";
}
html += "</table></html>";
html += L"</table></html>";
}
void Table::getRowRange(int &rowLo, int &rowHi) const {
@ -1889,8 +1882,8 @@ void Table::getColRange(int &colLo, int &colHi) const {
void Table::exportClipboard(gdioutput &gdi)
{
string str;// = "<html><table><tr><td>a</td><td>b</td></tr></table></html>";
string txt;
wstring str;// = "<html><table><tr><td>a</td><td>b</td></tr></table></html>";
wstring txt;
int col1 = -1, col2 = -1;
getColRange(col1, col2);
@ -1916,7 +1909,8 @@ void Table::exportClipboard(gdioutput &gdi)
getExportData(min(col1, col2), max(col1, col2),
min(row1, row2), max(row1, row2), str, txt);
gdi.copyToClipboard(str, true, txt);
string htmlUTF = gdi.toUTF8(str);
gdi.copyToClipboard(htmlUTF, txt);
/*if (OpenClipboard(gdi.getHWND()) != false) {
@ -1985,23 +1979,35 @@ void Table::importClipboard(gdioutput &gdi)
if (!canPaste())
throw std::exception("Operationen stöds ej");
string str;
wstring str;
if (OpenClipboard(gdi.getHWND()) != false) {
HANDLE data = GetClipboardData(CF_TEXT);
HANDLE data = GetClipboardData(CF_UNICODETEXT);
if (data) {
LPVOID lptstr = GlobalLock(data);
if (lptstr) {
str = string(((char*)lptstr));
str = wstring(((wchar_t*)lptstr));
GlobalUnlock(data);
}
}
else {
data = GetClipboardData(CF_TEXT);
if (data) {
LPVOID lptstr = GlobalLock(data);
if (lptstr) {
string strn = string(((char*)lptstr));
str = gdi.recodeToWide(strn);
GlobalUnlock(data);
}
}
}
CloseClipboard();
}
if (!str.empty()) {
// Parse raw data
vector< vector<string> > table(1);
const char *ptr = str.c_str();
string word;
vector< vector<wstring> > table(1);
const wchar_t *ptr = str.c_str();
wstring word;
while (*ptr) {
if (*ptr != '\t' && *ptr != '\r' && *ptr != '\n') {
word.append(ptr, 1);
@ -2012,7 +2018,7 @@ void Table::importClipboard(gdioutput &gdi)
}
else if (*ptr == '\n') {
table.back().push_back(word);
table.push_back(vector<string>());
table.push_back(vector<wstring>());
word.clear();
}
++ptr;
@ -2036,7 +2042,7 @@ void Table::importClipboard(gdioutput &gdi)
throw std::exception("Antalet columner i urklippet är större än antalet kolumner i tabellen.");
if (upperRow == -1) {
if (!gdi.ask("Vill du klistra in X nya rader i tabellen?#"+itos(table.size())))
if (!gdi.ask(L"Vill du klistra in X nya rader i tabellen?#"+itow(table.size())))
return;
rowS = sortIndex.size(); // Add new rows
}
@ -2060,7 +2066,7 @@ void Table::importClipboard(gdioutput &gdi)
if (col1 != col2 && (col2 - col1 +1 ) != tw)
wrongSize = true;
if (wrongSize && !gdi.ask("Selektionens storlek matchar inte urklippets storlek. Klistra in i alla fall?"))
if (wrongSize && !gdi.ask(L"Selektionens storlek matchar inte urklippets storlek. Klistra in i alla fall?"))
return;
rowS = row1;
@ -2091,17 +2097,17 @@ void Table::importClipboard(gdioutput &gdi)
int col = columns[colS + j];
TableCell &cell=tr.cells[col];
string output;
wstring output;
size_t index = 0;
if (cell.type==cellSelection || cell.type==cellCombo) {
vector< pair<string, size_t> > out;
vector< pair<wstring, size_t> > out;
size_t selected = 0;
cell.owner->fillInput(cell.id, out, selected);
index = -1;
for (size_t i = 0; i<out.size() && index == -1; i++) {
if (_stricmp(out[i].first.c_str(), table[k][j].c_str()) == 0)
if (_wcsicmp(out[i].first.c_str(), table[k][j].c_str()) == 0)
index = out[i].second;
}
}
@ -2115,6 +2121,9 @@ void Table::importClipboard(gdioutput &gdi)
cell.contents = output;
}
}
catch (const meosException &ex) {
wstring msg(ex.wwhat());
}
catch(const std::exception &ex) {
string msg(ex.what());
}
@ -2181,8 +2190,8 @@ void Table::autoAdjust(gdioutput &gdi) {
HDC hDC = GetDC(gdi.getTarget());
RECT rc = {0,0,0,0};
TextInfo ti;
string filterText = lang.tl("Urval...");
string filterName = lang.tl("Namn");
wstring filterText = lang.tl("Urval...");
wstring filterName = lang.tl("Namn");
ti.format = 0;
gdi.formatString(ti, hDC);
int sum = 0;
@ -2198,7 +2207,7 @@ void Table::autoAdjust(gdioutput &gdi) {
if (r==0 && c.contents == filterName)
w = max(w, 100);
const string &str = r != 1 ? c.contents : filterText;
const wstring &str = r != 1 ? c.contents : filterText;
int len = str.length();
if (len == minlen) {
sameCount++;
@ -2209,7 +2218,7 @@ void Table::autoAdjust(gdioutput &gdi) {
if (len > minlen - diff) {
sameCount = 0;
if (Titles[k].isnumeric && r>2)
DrawText(hDC, (str + "55").c_str(), len, &rc, DT_CALCRECT|DT_NOPREFIX);
DrawText(hDC, (str + L"55").c_str(), len, &rc, DT_CALCRECT|DT_NOPREFIX);
else
DrawText(hDC, str.c_str(), len, &rc, DT_CALCRECT|DT_NOPREFIX);
w = max<int>(w, rc.right - rc.left);
@ -2255,11 +2264,11 @@ void Table::autoSelectColumns() {
empty[k] = false;
}
else {
const string &first = Data.size() > 3 ?
Data[2].cells[k].contents : _EmptyString;
const wstring &first = Data.size() > 3 ?
Data[2].cells[k].contents : _EmptyWString;
for (size_t r = 2; r<Data.size(); r++) {
const string &c = Data[r].cells[k].contents;
const wstring &c = Data[r].cells[k].contents;
if (!c.empty() && c != first) {
nonEmpty++;
empty[k] = false;
@ -2272,10 +2281,10 @@ void Table::autoSelectColumns() {
if (nonEmpty > 1) {
columns.clear();
string id = lang.tl("Id");
string mod = lang.tl("Ändrad");
wstring id = lang.tl("Id");
wstring mod = lang.tl("Ändrad");
for (size_t k = 0; k<empty.size(); k++) {
if (!empty[k] && strcmp(Titles[k].name, id.c_str()) != 0 && strcmp(Titles[k].name, mod.c_str()) != 0)
if (!empty[k] && wcscmp(Titles[k].name, id.c_str()) != 0 && wcscmp(Titles[k].name, mod.c_str()) != 0)
columns.push_back(k);
}
}

View File

@ -48,7 +48,7 @@ struct TableUpdateInfo {
class TableCell
{
string contents;
wstring contents;
RECT absPos;
DWORD id;
@ -64,13 +64,13 @@ class TableCell
class TableRow
{
protected:
string key;
wstring key;
int intKey;
vector<TableCell> cells;
int id;
string *SortString;
wstring *SortString;
int sInt;
int ypos;
@ -107,7 +107,7 @@ class gdioutput;
struct ColInfo
{
char name[64];
wchar_t name[64];
mutable int width;
int baseWidth;
bool isnumeric;
@ -115,7 +115,7 @@ struct ColInfo
bool formatRight;
RECT title;
RECT condition;
string filter;
wstring filter;
};
struct TableSortIndex;
@ -137,7 +137,7 @@ protected:
int id;
bool clearOnHide;
bool commandLock;
string tableName;
wstring tableName;
string internalName;
vector<ColInfo> Titles;
vector<int> xpos;
@ -228,7 +228,7 @@ protected:
bool destroyEditControl(gdioutput &gdi);
void getExportData(int col1, int col2, int row1, int row2,
string &html, string &txt) const;
wstring &html, wstring &txt) const;
// Delete rows in selected range. Return number of rows that could not be removed
int deleteRows(int row1, int row2);
@ -246,8 +246,8 @@ protected:
bool compareRow(int indexA, int indexB) const;
public:
void setTableText(gdioutput &gdi, int editRow, int editCol, const string &bf);
const string &getTableText(gdioutput &gdi, int editRow, int editCol);
void setTableText(gdioutput &gdi, int editRow, int editCol, const wstring &bf);
const wstring &getTableText(gdioutput &gdi, int editRow, int editCol);
int getTableId() const {return id;}
static void resetTableIds() {uniqueId = 1;}
@ -264,14 +264,14 @@ public:
void clearCellSelection(gdioutput *gdi);
/// Return translated table name
const string& getTableName() const {return tableName;}
const wstring& getTableName() const {return tableName;}
/// Get the internal identifier of the table
const string& getInternalName() const {return internalName;}
bool hasAutoSelect() const {return doAutoSelectColumns;}
void updateDimension(gdioutput &gdi);
void selection(gdioutput &gdi, const string &text, int data);
void selection(gdioutput &gdi, const wstring &text, int data);
enum {
CAN_PASTE = 1,
@ -302,7 +302,7 @@ public:
struct ColSelection {
ColSelection() : selected(false), index(0) {}
string name;
wstring name;
bool selected;
int index;
};
@ -327,7 +327,7 @@ public:
bool keyCommand(gdioutput &gdi, KeyCommandCode code);
void sort(int col);
void filter(int col, const string &filt, bool forceFilter=false);
void filter(int col, const wstring &filt, bool forceFilter=false);
int addColumn(const string &Title, int width, bool isnum, bool formatRight = false);
int addColumnPaddedSort(const string &title, int width, int padding, bool formatRight = false);
@ -336,7 +336,7 @@ public:
TableRow *getRowById(int rowId);
void addRow(int rowId, oBase *object);
void set(int column, oBase &owner, int id, const string &data,
void set(int column, oBase &owner, int id, const wstring &data,
bool canEdit=true, CellType type=cellEdit);
//Reload a row from data
@ -351,7 +351,7 @@ public:
void update();
Table(oEvent *oe_, int rowHeight,
const string &name, const string &tname);
const wstring &name, const string &tname);
~Table(void);
friend struct TableSortIndex;

View File

@ -96,15 +96,15 @@ string TimeStamp::getStamp() const
return bf;
}
string TimeStamp::getStampString() const
wstring TimeStamp::getStampString() const
{
__int64 ft64=(__int64(Time)+minYearConstant*365*24*3600)*10000000;
FILETIME &ft=*(FILETIME*)&ft64;
SYSTEMTIME st;
FileTimeToSystemTime(&ft, &st);
char bf[32];
sprintf_s(bf, "%d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
wchar_t bf[32];
swprintf_s(bf, L"%d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
return bf;
}

View File

@ -36,7 +36,7 @@ class TimeStamp
public:
void setStamp(string s);
string getStamp() const;
string getStampString() const;
wstring getStampString() const;
int getAge() const;
unsigned int getModificationTime() const {return Time;}

View File

@ -29,6 +29,7 @@
#include "TabSI.h"
#include "meos_util.h"
#include "socket.h"
#include "meosexception.h"
const int SYNC_FACTOR = 4;
@ -48,7 +49,7 @@ AutoTask::AutoTask(HWND hWnd, oEvent &oeIn, gdioutput &gdiIn) : hWndMain(hWnd),
void AutoTask::autoSave() {
if (!oe.empty()) {
string msg;
wstring msg;
try {
if (oe.getNumRunners() > 500)
gdi.setWaitCursor(true);
@ -66,18 +67,21 @@ void AutoTask::autoSave() {
}
}
}
catch (meosException &ex) {
msg = ex.wwhat();
}
catch(std::exception &ex) {
msg=ex.what();
msg = gdi.widen(ex.what());
}
catch(...) {
msg="Ett okänt fel inträffade.";
msg = L"Ett okänt fel inträffade.";
}
if (!msg.empty()) {
gdi.alert(msg);
}
else
gdi.addInfoBox("", "Tävlingsdata har sparats.", 10);
gdi.addInfoBox("", L"Tävlingsdata har sparats.", 10);
gdi.setWaitCursor(false);
@ -102,7 +106,7 @@ void AutoTask::interfaceTimeout(const vector<gdioutput *> &windows) {
return;
lock = true;
string msg;
wstring msg;
try {
DWORD tick = GetTickCount();
for (size_t k = 0; k<windows.size(); k++) {
@ -116,11 +120,14 @@ void AutoTask::interfaceTimeout(const vector<gdioutput *> &windows) {
if (tabSI)
while(tabSI->checkpPrintQueue(gdi));
}
catch (meosException &ex) {
msg = ex.wwhat();
}
catch(std::exception &ex) {
msg=ex.what();
msg = gdi.widen(ex.what());
}
catch(...) {
msg="Ett okänt fel inträffade.";
msg = L"Ett okänt fel inträffade.";
}
if (!msg.empty()) {
gdi.alert(msg);
@ -246,7 +253,7 @@ bool AutoTask::synchronizeImpl(const vector<gdioutput *> &windows) {
}
}
string msg;
wstring msg;
bool ret = false;
try {
if (doSync || (tabAuto && tabAuto->synchronize)) {
@ -265,11 +272,14 @@ bool AutoTask::synchronizeImpl(const vector<gdioutput *> &windows) {
try {
windows[k]->makeEvent("DataUpdate", "autosync", 0, 0, false);
}
catch (meosException &ex) {
msg = ex.wwhat();
}
catch(std::exception &ex) {
msg = ex.what();
msg = gdi.widen(ex.what());
}
catch(...) {
msg = "Ett okänt fel inträffade.";
msg = L"Ett okänt fel inträffade.";
}
}
}
@ -281,11 +291,14 @@ bool AutoTask::synchronizeImpl(const vector<gdioutput *> &windows) {
}
oe.resetSQLChanged(false, true);
}
catch (meosException &ex) {
msg = ex.wwhat();
}
catch (std::exception &ex) {
msg = ex.what();
msg = gdi.widen(ex.what());
}
catch (...) {
msg = "Ett okänt fel inträffade.";
msg = L"Ett okänt fel inträffade.";
}
currentRevision = oe.getRevision();
@ -326,12 +339,16 @@ bool AutoTask::advancePunchInformationImpl(const vector<gdioutput *> &windows) {
return ret;
}
}
catch (meosException &ex) {
wstring msg = ex.wwhat();
OutputDebugString(msg.c_str());
}
catch (std::exception &ex) {
OutputDebugString(ex.what());
//msg = ex.what();
wstring str;
string2Wide(ex.what(), str);
OutputDebugString(str.c_str());
}
catch (...) {
//msg = "Ett okänt fel inträffade.";
}
return false;

View File

@ -52,7 +52,7 @@ public:
// True if there are rented cards
bool hasRentedCard;
vector<string> classWithoutCourse;
vector<wstring> classWithoutCourse;
void clear();

File diff suppressed because one or more lines are too long

View File

@ -48,16 +48,16 @@ struct PunchInfo {
struct TeamLineup {
struct TeamMember {
string name;
string club;
wstring name;
wstring club;
int cardNo;
string course;
string cls;
wstring course;
wstring cls;
};
string teamName;
string teamClass;
string teamClub;
wstring teamName;
wstring teamClass;
wstring teamClub;
vector<TeamMember> members;
};
@ -71,13 +71,13 @@ protected:
string ErrorMessage;
// Returns true if a SI-manager line is identified
bool checkSimanLine(const oEvent &oe, const vector<char *> &sp, SICard &cards);
bool checkSimanLine(const oEvent &oe, const vector<wstring> &sp, SICard &cards);
// Check and setup header for SIConfig import
void checkSIConfigHeader(const vector<char *> &sp);
void checkSIConfigHeader(const vector<wstring> &sp);
// Return true if SIConfig line was detected
bool checkSIConfigLine(const oEvent &oe, const vector<char *> &sp, SICard &card);
bool checkSIConfigLine(const oEvent &oe, const vector<wstring> &sp, SICard &card);
enum SIConfigFields {
sicSIID,
@ -97,40 +97,42 @@ protected:
};
map<SIConfigFields, int> siconfigmap;
const char *getSIC(SIConfigFields sic, const vector<char *> &sp) const;
const wchar_t *getSIC(SIConfigFields sic, const vector<wstring> &sp) const;
// Check and process a punch line
static int selectPunchIndex(const string &competitionDate, const vector<char *> &sp,
static int selectPunchIndex(const wstring &competitionDate, const vector<wstring> &sp,
int &cardIndex, int &timeIndex, int &dateIndex,
string &processedTime, string &date);
wstring &processedTime, wstring &date);
public:
void parse(const string &file, list< vector<string> > &dataOutput);
//void parse(const wstring &file, list< vector<string> > &dataOutput);
void parse(const wstring &file, list< vector<wstring> > &dataOutput);
void importTeamLineup(const string &file,
const map<string, int> &classNameToNumber,
void importTeamLineup(const wstring &file,
const map<wstring, int> &classNameToNumber,
vector<TeamLineup> &teams);
bool openOutput(const char *file);
bool openOutput(const wstring &file);
bool closeOutput();
bool OutputRow(vector<string> &out);
bool OutputRow(const string &row);
int nimport;
bool ImportOCAD_CSV(oEvent &event, const char *file, bool addClasses);
bool ImportOS_CSV(oEvent &event, const char *file);
bool ImportRAID(oEvent &event, const char *file);
bool importOCAD_CSV(oEvent &oe, const wstring &file, bool addClasses);
bool importOS_CSV(oEvent &oe, const wstring &file);
bool importRAID(oEvent &oe, const wstring &file);
bool importOE_CSV(oEvent &oe, const wstring &file);
bool importPunches(const oEvent &oe, const char *file,
bool importPunches(const oEvent &oe, const wstring &file,
vector<PunchInfo> &punches);
bool importCards(const oEvent &oe, const char *file,
bool importCards(const oEvent &oe, const wstring &file,
vector<SICard> &punches);
int split(char *line, vector<char *> &split);
int split(wchar_t *line, vector<wchar_t *> &split);
bool ImportOE_CSV(oEvent &event, const char *file);
int iscsv(const char *file);
int iscsv(const wstring &file);
csvparser();
virtual ~csvparser();

File diff suppressed because it is too large Load Diff

BIN
code/dll/libharu.dll Normal file

Binary file not shown.

BIN
code/dll/libmySQL.dll Normal file

Binary file not shown.

BIN
code/dll/mysqlpp.dll Normal file

Binary file not shown.

BIN
code/dll_debug/libharu.dll Normal file

Binary file not shown.

BIN
code/dll_debug/libmySQL.dll Normal file

Binary file not shown.

BIN
code/dll_debug/mysqlpp.dll Normal file

Binary file not shown.

View File

@ -26,6 +26,7 @@
#include "Localizer.h"
#include "meos_util.h"
#include "progress.h"
#include "meosexception.h"
#include <sys/stat.h>
#include <io.h>
@ -93,7 +94,7 @@ void Download::shutDown()
}
//If unsuccessful ending thread, do it violently
if (hThread) {
OutputDebugString("Terminate thread...\n");
OutputDebugString(L"Terminate thread...\n");
TerminateThread(HANDLE(hThread), 0);
CloseHandle(HANDLE(hThread));
}
@ -112,64 +113,65 @@ void Download::initThread()
}
void Download::initInternet() {
hInternet = InternetOpen("MeOS", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
hInternet = InternetOpen(L"MeOS", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hInternet==NULL) {
DWORD ec = GetLastError();
string error = lang.tl("Error: X#" + getErrorMessage(ec));
throw std::exception(error.c_str());
wstring error = lang.tl(L"Error: X#" + getErrorMessage(ec));
throw meosException(error);
}
DWORD dwTimeOut = 120 * 1000;
DWORD dwTimeOut = 180 * 1000;
InternetSetOption(hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD));
InternetSetOption(hInternet, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD));
}
void Download::downloadFile(const string &url, const string &file, const vector< pair<string, string> > &headers)
void Download::downloadFile(const wstring &url, const wstring &file, const vector< pair<wstring, wstring> > &headers)
{
if (hURL || !hInternet)
throw std::exception("Not inititialized");
success = false;
string hdr;
for (size_t k = 0; k<headers.size(); k++)
hdr += headers[k].first + ": " + headers[k].second + "\r\n";
string url2 = url;
wstring hdr;
wstring row;
for (size_t k = 0; k<headers.size(); k++) {
hdr += headers[k].first + L": " + headers[k].second + L"\r\n";
}
wstring url2 = url;
hURL = InternetOpenUrl(hInternet, url2.c_str(), hdr.empty() ? 0 : hdr.c_str(), hdr.length(), INTERNET_FLAG_DONT_CACHE, 0);
if (!hURL) {
int err = GetLastError();
string msg2 = getErrorMessage(err);
wstring msg2 = getErrorMessage(err);
DWORD em = 0, blen = 256;
char bf2[256];
wchar_t bf2[256];
InternetGetLastResponseInfo(&em, bf2, &blen);
string msg = "Failed to connect to: " + url;
msg += " " + msg2;
wstring msg = L"Failed to connect to: " + url2;
msg += L" " + msg2;
if (bf2[0] != 0)
msg += " (" + string(bf2) + ")";
throw std::exception(msg.c_str());
msg += L" (" + wstring(bf2) + L")";
throw meosException(msg.c_str());
}
DWORD dwContentLen = 0;
DWORD dwBufLen = sizeof(dwContentLen);
BOOL success = HttpQueryInfo(hURL,
BOOL vsuccess = HttpQueryInfo(hURL,
HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwContentLen, &dwBufLen, 0);
if (success)
if (vsuccess)
setBytesToDownload(dwContentLen);
else
setBytesToDownload(0);
DWORD dwStatus = 0;
dwBufLen = sizeof(dwStatus);
success = HttpQueryInfo(hURL, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
vsuccess = HttpQueryInfo(hURL, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwStatus, &dwBufLen, 0);
if (success) {
if (vsuccess) {
if (dwStatus >= 400) {
char bf[256];
switch (dwStatus) {
@ -198,14 +200,14 @@ void Download::downloadFile(const string &url, const string &file, const vector<
}
}
fileno=_open(file.c_str(), O_BINARY|O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE);
fileno=_wopen(file.c_str(), O_BINARY|O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE);
if (fileno==-1) {
fileno=0;
endDownload();
char bf[256];
sprintf_s(bf, "Error opening '%s' for writing", file.c_str());
throw std::exception(bf);
wchar_t bf[256];
swprintf_s(bf, L"Error opening '%s' for writing", file.c_str());
throw meosException(bf);
}
bytesLoaded = 0;
@ -266,16 +268,16 @@ bool Download::successful()
return success;
}
void Download::postFile(const string &url, const string &file, const string &fileOut,
const vector< pair<string, string> > &headers, ProgressWindow &pw) {
void Download::postFile(const wstring &url, const wstring &file, const wstring &fileOut,
const vector< pair<wstring, wstring> > &headers, ProgressWindow &pw) {
SetLastError(0);
DWORD_PTR dw = 0;
URL_COMPONENTS uc;
memset(&uc, 0, sizeof(uc));
uc.dwStructSize = sizeof(uc);
char host[128];
char path[128];
char extra[256];
wchar_t host[128];
wchar_t path[128];
wchar_t extra[256];
uc.lpszExtraInfo = extra;
uc.dwExtraInfoLength = sizeof(extra);
uc.lpszHostName = host;
@ -291,10 +293,10 @@ void Download::postFile(const string &url, const string &file, const string &fil
port = uc.nPort;
HINTERNET hConnect = InternetConnect(hInternet, host, port,
NULL, NULL, INTERNET_SERVICE_HTTP, 0, dw);
bool success = false;
bool vsuccess = false;
int errorCode = 0;
try {
success = httpSendReqEx(hConnect, path, headers, file, fileOut, pw, errorCode);
vsuccess = httpSendReqEx(hConnect, path, headers, file, fileOut, pw, errorCode);
}
catch (std::exception &) {
InternetCloseHandle(hConnect);
@ -302,20 +304,20 @@ void Download::postFile(const string &url, const string &file, const string &fil
}
InternetCloseHandle(hConnect);
if (!success) {
if (!vsuccess) {
if (errorCode != 0)
errorCode = GetLastError();
string error = errorCode != 0 ? getErrorMessage(errorCode) : "";
wstring error = errorCode != 0 ? getErrorMessage(errorCode) : L"";
if (error.empty())
error = "Ett okänt fel inträffade.";
throw std::exception(error.c_str());
error = L"Ett okänt fel inträffade.";
throw meosException(error);
}
}
bool Download::httpSendReqEx(HINTERNET hConnect, const string &dest,
const vector< pair<string, string> > &headers,
const string &upFile, const string &outFile,
bool Download::httpSendReqEx(HINTERNET hConnect, const wstring &dest,
const vector< pair<wstring, wstring> > &headers,
const wstring &upFile, const wstring &outFile,
ProgressWindow &pw,
int &errorCode) const {
errorCode = 0;
@ -323,16 +325,16 @@ bool Download::httpSendReqEx(HINTERNET hConnect, const string &dest,
memset(&BufferIn, 0, sizeof(BufferIn));
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );
HINTERNET hRequest = HttpOpenRequest (hConnect, "POST", dest.c_str(), NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
HINTERNET hRequest = HttpOpenRequest (hConnect, L"POST", dest.c_str(), NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
DWORD dwBytesRead = 0;
DWORD dwBytesWritten = 0;
BYTE pBuffer[4*1024]; // Read from file in 4K chunks
string hdr;
wstring hdr;
for (size_t k = 0; k<headers.size(); k++) {
if (!trim(headers[k].second).empty()) {
hdr += headers[k].first + ": " + headers[k].second + "\r\n";
hdr += headers[k].first + L": " + headers[k].second + L"\r\n";
}
}
@ -409,10 +411,10 @@ bool Download::httpSendReqEx(HINTERNET hConnect, const string &dest,
DWORD dwStatus = 0;
DWORD dwBufLen = sizeof(dwStatus);
int success = HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
int vsuccess = HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwStatus, &dwBufLen, 0);
if (success) {
if (vsuccess) {
if (dwStatus >= 400) {
char bf[256];
switch (dwStatus) {
@ -441,16 +443,16 @@ bool Download::httpSendReqEx(HINTERNET hConnect, const string &dest,
}
}
int fileno = _open(outFile.c_str(), O_BINARY|O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE);
int rfileno = _wopen(outFile.c_str(), O_BINARY|O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE);
do {
dwBytesRead=0;
if (InternetReadFile(hRequest, pBuffer, sizeof(pBuffer)-1, &dwBytesRead)) {
_write(fileno, pBuffer, dwBytesRead);
_write(rfileno, pBuffer, dwBytesRead);
}
} while(dwBytesRead>0);
_close(fileno);
_close(rfileno);
InternetCloseHandle(hRequest);
return true;

View File

@ -60,19 +60,19 @@ private:
bool success;
void initThread();
bool httpSendReqEx(HINTERNET hConnect, const string &dest, const vector< pair<string, string> > &headers,
const string &upFile, const string &outFile, ProgressWindow &pw, int &errroCode) const;
bool httpSendReqEx(HINTERNET hConnect, const wstring &dest, const vector< pair<wstring, wstring> > &headers,
const wstring &upFile, const wstring &outFile, ProgressWindow &pw, int &errroCode) const;
public:
void postFile(const string &url, const string &file, const string &fileOut,
const vector< pair<string, string> > &headers, ProgressWindow &pw);
void postFile(const wstring &url, const wstring &file, const wstring &fileOut,
const vector< pair<wstring, wstring> > &headers, ProgressWindow &pw);
int processMessages();
bool successful();
bool isWorking();
void setBytesToDownload(DWORD btd);
void endDownload();
void downloadFile(const string &url, const string &file, const vector< pair<string, string> > &headers);
void downloadFile(const wstring &url, const wstring &file, const vector< pair<wstring, wstring> > &headers);
void initInternet();
void shutDown();
bool createDownloadThread();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -42,16 +42,15 @@ class GDIImplFontSet {
HFONT pfItalic;
void deleteFonts();
string gdiName;
wstring gdiName;
mutable vector<double> avgWidthCache;
int charSet;
public:
static float baseSize(int format, float scale);
void getInfo(FontInfo &fi) const;
GDIImplFontSet();
virtual ~GDIImplFontSet();
void init(double scale, int charSet, const string &font, const string &gdiName);
void init(double scale, const wstring &font, const wstring &gdiName);
void selectFont(HDC hDC, int format) const;
HFONT getGUIFont() const {return pfMedium;}
HFONT getFont(int format) const;
@ -63,12 +62,12 @@ private:
int width;
int height;
double relScale;
string face;
wstring face;
public:
GDIImplFontEnum();
virtual ~GDIImplFontEnum();
const string &getFace() const {return face;}
const wstring &getFace() const {return face;}
double getRelScale() const {return relScale;}
friend int CALLBACK enumFontProc(const LOGFONT* logFont, const TEXTMETRIC *metric, DWORD id, LPARAM lParam);

File diff suppressed because it is too large Load Diff

View File

@ -35,9 +35,17 @@
#include <set>
#include <map>
#include <vector>
#ifdef OLD
#include <hash_set>
#include <hash_map>
#else
#include <unordered_map>
#include <unordered_set>
#endif
#include <algorithm>
#include "subcommand.h"
class Toolbar;
@ -68,15 +76,15 @@ enum gdiFonts;
#define NOTIMEOUT 0x0AAAAAAA
typedef list<ToolInfo> ToolList;
/*
enum FontEncoding {
ANSI, Russian, EastEurope, Hebrew
};
};*/
/*
FontEncoding interpetEncoding(const string &enc);
*/
struct FontInfo {
const string *name;
const wstring *name;
HFONT normal;
HFONT bold;
HFONT italic;
@ -92,12 +100,9 @@ protected:
// Flag set to true when clearPage is called.
bool hasCleared;
bool useTables;
FontEncoding fontEncoding;
// Set to true when in test mode
bool isTestMode;
int getCharSet() const;
bool highContrast;
void deleteFonts();
@ -134,13 +139,13 @@ protected:
list<TextInfo>::iterator itTL;
list<ButtonInfo> BI;
stdext::hash_map<HWND, ButtonInfo *> biByHwnd;
unordered_map<HWND, ButtonInfo *> biByHwnd;
list<InputInfo> II;
stdext::hash_map<HWND, InputInfo *> iiByHwnd;
unordered_map<HWND, InputInfo *> iiByHwnd;
list<ListBoxInfo> LBI;
stdext::hash_map<HWND, ListBoxInfo *> lbiByHwnd;
unordered_map<HWND, ListBoxInfo *> lbiByHwnd;
list<DataStore> DataInfo;
list<EventInfo> Events;
@ -176,10 +181,10 @@ protected:
HBRUSH Background;
map<string, GDIImplFontSet> fonts;
map<wstring, GDIImplFontSet> fonts;
const GDIImplFontSet &getCurrentFont() const;
const GDIImplFontSet &getFont(const string &font) const;
const GDIImplFontSet &loadFont(const string &font);
const GDIImplFontSet &getFont(const wstring &font) const;
const GDIImplFontSet &loadFont(const wstring &font);
mutable const GDIImplFontSet *currentFontSet;
int MaxX;
@ -198,7 +203,7 @@ protected:
bool manualUpdate;
LRESULT ProcessMsgWrp(UINT iMessage, LPARAM lParam, WPARAM wParam);
void getWindowText(HWND hWnd, string &text);
void getWindowText(HWND hWnd, wstring &text);
double scale;
HFONT getGUIFont() const;
@ -207,9 +212,9 @@ protected:
mutable bool lastActive;
mutable bool lastHighlight;
mutable DWORD lastColor;
mutable string lastFont;
mutable wstring lastFont;
void initCommon(double scale, const string &font);
void initCommon(double scale, const wstring &font);
void processButtonMessage(ButtonInfo &bi, DWORD wParam);
void processEditMessage(InputInfo &bi, DWORD wParam);
@ -222,7 +227,7 @@ protected:
FixedTabs *tabs;
string currentFont;
wstring currentFont;
vector< GDIImplFontEnum > enumeratedFonts;
double autoSpeed;
@ -242,20 +247,20 @@ protected:
struct ScreenStringInfo {
RECT rc;
string str;
wstring str;
bool reached;
ScreenStringInfo(const RECT &r, const string &s) {
ScreenStringInfo(const RECT &r, const wstring &s) {
rc = r;
str = s;
reached = false;
}
};
string listDescription;
wstring listDescription;
mutable map<pair<int, int>, ScreenStringInfo> screenXYToString;
mutable map<string, pair<int, int> > stringToScreenXY;
mutable map<wstring, pair<int, int> > stringToScreenXY;
mutable pair<int, int> snapshotMaxXY;
bool hasAnyTimer;
@ -264,7 +269,15 @@ protected:
// Recorder, the second member is true if the recorder is owned and should be deleted
pair<Recorder *, bool> recorder;
list< pair<const SubCommand *, string> > subCommands;
int defaultCodePage;
public:
// Return the bounding dimension of the desktop
void getVirtualScreenSize(RECT &rc);
void getWindowsPosition(RECT &rc) const;
void setWindowsPosition(const RECT &rc);
void initRecorder(Recorder *rec);
Recorder &getRecorder();
@ -277,6 +290,9 @@ public:
string dbClick(const string &id, int extra);
void dbDblClick(const string &id, int data);
void dbRegisterSubCommand(const SubCommand *cmd, const string &action);
void runSubCommand();
// Add the next answer for a dialog popup
void dbPushDialogAnswer(const string &answer);
mutable list<string> cmdAnswers;
@ -291,13 +307,16 @@ public:
bool isTest() const {return isTestMode;}
const string &getTag() const {return tag;}
bool hasTag(const string &t) const {return tag == t;}
const wstring &toWide(const string &input) const;
const wstring &recodeToWide(const string &input) const;
const string &recodeToNarrow(const wstring &input) const;
static const wstring &widen(const string &input);
static const string &narrow(const wstring &input);
const string &toUTF8(const string &input) const;
const string &toUTF8(const wstring &input) const;
void setEncoding(FontEncoding encoding);
FontEncoding getEncoding() const;
//void setEncoding(FontEncoding encoding);
//FontEncoding getEncoding() const;
void getFontInfo(const TextInfo &ti, FontInfo &fi) const;
@ -307,9 +326,9 @@ public:
const list<TextInfo> &getTL() const {return TL;}
void getEnumeratedFonts(vector< pair<string, size_t> > &output) const;
const string &getFontName(int id);
double getRelativeFontScale(gdiFonts font, const char *fontFace) const;
void getEnumeratedFonts(vector< pair<wstring, size_t> > &output) const;
const wstring &getFontName(int id);
double getRelativeFontScale(gdiFonts font, const wchar_t *fontFace) const;
bool isFullScreen() const {return fullScreen;}
void setFullScreen(bool useFullScreen);
@ -334,11 +353,11 @@ public:
double getScale() const {return scale;}
void enableEditControls(bool enable);
void enableEditControls(bool enable, bool processAll = false);
bool hasEditControl() const;
void setFont(int size, const string &font, FontEncoding encoding);
void setFont(int size, const wstring &font);
int getButtonHeight() const;
int scaleLength(int input) const {return int(scale*input + 0.5);}
@ -348,7 +367,7 @@ public:
void tableCB(ButtonInfo &bu, Table *t);
char *getExtra(const char *id) const;
wchar_t *getExtra(const char *id) const;
int getExtraInt(const char *id) const;
void enableTables();
@ -356,10 +375,10 @@ public:
void pasteText(const char *id);
bool writeHTML(const wstring &file, const string &title, int refreshTimeOut) const;
bool writeTableHTML(const wstring &file, const string &title, int refreshTimeOut) const;
bool writeHTML(const wstring &file, const wstring &title, int refreshTimeOut) const;
bool writeTableHTML(const wstring &file, const wstring &title, int refreshTimeOut) const;
bool writeTableHTML(ostream &fout,
const string &title,
const wstring &title,
bool simpleFormat,
int refreshTimeOut) const;
@ -369,12 +388,15 @@ public:
void destroyPrinterDC(PrinterObject &po);
void setSelection(const string &id, const set<int> &selection);
void setSelection(const wstring &id, const set<int> &selection) {
setSelection(narrow(id), selection);
}
void getSelection(const string &id, set<int> &selection);
HWND getTarget() const {return hWndTarget;}
HWND getMain() const {return hWndAppMain;}
string browseForFolder(const string &folderStart, const char *descr);
void scrollToBottom();
void scrollTo(int x, int y);
void setOffset(int x, int y, bool update);
@ -384,18 +406,20 @@ public:
void addTable(Table *table, int x, int y);
Table &getTable() const; //Get the (last) table. If needed, add support for named tables...
ToolInfo &addToolTip(const string &id, const string &tip, HWND hWnd, RECT *rc=0);
ToolInfo &addToolTip(const string &id, const wstring &tip, HWND hWnd, RECT *rc=0);
ToolInfo *getToolTip(const string &id);
ToolInfo &updateToolTip(const string &id, const string &tip);
ToolInfo &updateToolTip(const string &id, const wstring &tip);
HWND getToolTip(){return hWndToolTip;}
void init(HWND hWnd, HWND hMainApp, HWND hTab);
bool openDoc(const char *doc);
string browseForSave(const vector< pair<string, string> > &filter,
const string &defext, int &FilterIndex);
string browseForOpen(const vector< pair<string, string> > &filter,
const string &defext);
bool openDoc(const wchar_t *doc);
wstring browseForSave(const vector< pair<wstring, wstring> > &filter,
const wstring &defext, int &FilterIndex);
wstring browseForOpen(const vector< pair<wstring, wstring> > &filter,
const wstring &defext);
wstring browseForFolder(const wstring &folderStart, const wchar_t *descr);
bool clipOffset(int PageX, int PageY, int &MaxOffsetX, int &MaxOffsetY);
RectangleInfo &addRectangle(RECT &rc, GDICOLOR Color = GDICOLOR(-1),
@ -431,7 +455,7 @@ public:
void drawBoxText(HDC hDC, RECT &tr, InfoBox &Box, bool highligh);
void drawBoxes(HDC hDC, RECT &rc);
void drawBox(HDC hDC, InfoBox &Box, RECT &pos);
void addInfoBox(string id, string text, int TimeOut=0, GUICALLBACK cb=0);
void addInfoBox(string id, wstring text, int TimeOut=0, GUICALLBACK cb=0);
HWND getHWND() const {return hWndTarget;}
void updateObjectPositions();
void drawBackground(HDC hDC, RECT &rc);
@ -446,18 +470,17 @@ public:
int GetOffsetY(){return OffsetY;}
int GetOffsetX(){return OffsetX;}
void RenderString(TextInfo &ti, const string &text, HDC hDC);
void RenderString(TextInfo &ti, const wstring &text, HDC hDC);
void RenderString(TextInfo &ti, HDC hDC=0);
void calcStringSize(TextInfo &ti, HDC hDC=0) const;
void formatString(const TextInfo &ti, HDC hDC) const;
static string getTimerText(TextInfo *tit, DWORD T);
static string getTimerText(int ZeroTime, int format);
static wstring getTimerText(TextInfo *tit, DWORD T);
static wstring getTimerText(int ZeroTime, int format);
void fadeOut(string Id, int ms);
void setWaitCursor(bool wait);
void setWindowTitle(const string &title);
void setWindowTitle(const wstring &title);
bool selectFirstItem(const string &name);
void removeString(string Id);
void refresh() const;
@ -473,10 +496,13 @@ public:
int getHeight() const {return MaxY;}
void getTargetDimension(int &x, int &y) const;
pair<int, int> getPos() const { return make_pair(CurrentX, CurrentY); }
void setPos(const pair<int, int> &p) { CurrentX = p.first; CurrentY = p.second; }
void setCX(int cx){CurrentX=cx;}
void setCY(int cy){CurrentY=cy;}
int getLineHeight() const {return lineHeight;}
int getLineHeight(gdiFonts font, const char *face) const;
int getLineHeight(gdiFonts font, const wchar_t *face) const;
BaseInfo *setInputFocus(const string &id, bool select=false);
InputInfo *getInputFocus();
@ -506,10 +532,12 @@ public:
}
enum AskAnswer {AnswerNo = 0, AnswerYes = 1, AnswerCancel = 2};
bool ask(const string &s);
AskAnswer askCancel(const string &s);
bool ask(const wstring &s);
AskAnswer askCancel(const wstring &s);
void alert(const string &msg) const;
void alert(const wstring &msg) const;
void fillDown(){Direction=1;}
void fillRight(){Direction=0;}
void fillNone(){Direction=-1;}
@ -531,38 +559,51 @@ public:
pair<int, bool> getSelectedItem(const string &id);
pair<int, bool> getSelectedItem(const char *id);
bool addItem(const string &id, const string &text, size_t data = 0);
bool addItem(const string &id, const vector< pair<string, size_t> > &items);
void filterOnData(const string &id, const stdext::hash_set<int> &filter);
bool addItem(const string &id, const wstring &text, size_t data = 0);
bool addItem(const string &id, const vector< pair<wstring, size_t> > &items);
void filterOnData(const string &id, const unordered_set<int> &filter);
bool clearList(const string &id);
bool hasField(const string &id) const;
const string &getText(const char *id, bool acceptMissing = false) const;
/*const wstring &getText(const wchar_t *id, bool acceptMissing = false) const {
return getText(toNarrow(id).c_str(), acceptMissing);
}*/
const wstring &getText(const char *id, bool acceptMissing = false) const;
BaseInfo &getBaseInfo(const char *id) const;
BaseInfo &getBaseInfo(const wchar_t *id) const {
return getBaseInfo(narrow(id).c_str());
}
int getTextNo(const char *id, bool acceptMissing = false) const;
int getTextNo(const string &id, bool acceptMissing = false) const
{return getTextNo(id.c_str(), acceptMissing);}
const string &getText(const string &id, bool acceptMissing = false) const
const wstring &getText(const string &id, bool acceptMissing = false) const
{return getText(id.c_str(), acceptMissing);}
// Insert text and notify "focusList"
bool insertText(const string &id, const string &text);
// Insert text and notify "focusList"
bool insertText(const string &id, const wstring &text);
void copyToClipboard(const string &html, bool convertToUTF8,
const string &txt) const;
// The html version should be UTF-8.
void copyToClipboard(const string &html,
const wstring &txt) const;
BaseInfo *setTextTranslate(const char *id, const string &text, bool update=false);
BaseInfo *setTextTranslate(const char *id, const char *text, bool update=false);
BaseInfo *setTextTranslate(const string &id, const string &text, bool update=false);
BaseInfo *setTextTranslate(const char *id, const wstring &text, bool update=false);
BaseInfo *setTextTranslate(const char *id, const wchar_t *text, bool update=false);
BaseInfo *setTextTranslate(const string &id, const wstring &text, bool update=false);
BaseInfo *setText(const char *id, const string &text, bool update=false);
BaseInfo *setText(const char *id, const wstring &text, bool update=false);
BaseInfo *setText(const wchar_t *id, const wstring &text, bool update=false) {
return setText(narrow(id), text, update);
}
BaseInfo *setText(const char *id, int number, bool update=false);
BaseInfo *setTextZeroBlank(const char *id, int number, bool update=false);
BaseInfo *setText(const string &id, const string &text, bool update=false)
BaseInfo *setText(const string &id, const wstring &text, bool update=false)
{return setText(id.c_str(), text, update);}
BaseInfo *setTextZeroBlank(const char *id, int number, bool update=false);
BaseInfo *setText(const string &id, int number, bool update=false)
{return setText(id.c_str(), number, update);}
@ -579,6 +620,23 @@ public:
void scaleSize(double scale);
ButtonInfo &addButton(const string &id, const wstring &text, GUICALLBACK cb = 0,
const wstring &tooltip = L"");
ButtonInfo &addButton(int x, int y, const string &id, const wstring &text,
GUICALLBACK cb = 0, const wstring &tooltop=L"");
ButtonInfo &addButton(int x, int y, int w, const string &id, const wstring &text,
GUICALLBACK cb, const wstring &tooltop, bool absPos, bool hasState);
ButtonInfo &addCheckbox(const string &id, const wstring &text, GUICALLBACK cb=0,
bool Checked=true, const wstring &tooltip = L"");
ButtonInfo &addCheckbox(int x, int y, const string &id,
const wstring &text, GUICALLBACK cb=0,
bool checked=true, const wstring &tooltop = L"", bool absPos=false);
/// XXX Temporary
ButtonInfo &addButton(const string &id, const string &text, GUICALLBACK cb = 0, const string &tooltip="");
ButtonInfo &addButton(int x, int y, const string &id, const string &text,
@ -588,48 +646,67 @@ public:
ButtonInfo &addCheckbox(const string &id, const string &text, GUICALLBACK cb=0, bool Checked=true, const string &Help="");
ButtonInfo &addCheckbox(int x, int y, const string &id, const string &text, GUICALLBACK cb=0, bool Checked=true, const string &Help="", bool AbsPos=false);
/// XXX
bool isChecked(const string &id);
void check(const string &id, bool state, bool keepOriginalState = false);
bool isInputChanged(const string &exclude);
InputInfo &addInput(const string &id, const string &text="", int length=16, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
InputInfo &addInput(int x, int y, const string &id, const string &text, int length, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
InputInfo &addInput(const string &id, const wstring &text = L"", int length=16, GUICALLBACK cb=0,
const wstring &Explanation = L"", const wstring &tooltip=L"");
InputInfo &addInput(int x, int y, const string &id, const wstring &text, int length,
GUICALLBACK cb=0, const wstring &Explanation = L"", const wstring &tooltip=L"");
InputInfo *replaceSelection(const char *id, const string &text);
InputInfo *replaceSelection(const char *id, const wstring &text);
InputInfo &addInputBox(const string &id, int width, int height, const string &text,
GUICALLBACK cb, const string &Explanation);
InputInfo &addInputBox(const string &id, int width, int height, const wstring &text,
GUICALLBACK cb, const wstring &explanation);
InputInfo &addInputBox(const string &id, int x, int y, int width, int height,
const string &text, GUICALLBACK cb, const string &Explanation);
const wstring &text, GUICALLBACK cb, const wstring &explanation);
ListBoxInfo &addListBox(const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="", bool multiple=false);
ListBoxInfo &addListBox(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="", bool multiple=false);
ListBoxInfo &addListBox(const string &id, int width, int height, GUICALLBACK cb=0, const wstring &explanation=L"", const wstring &tooltip=L"", bool multiple=false);
ListBoxInfo &addListBox(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const wstring &explanation=L"", const wstring &tooltip=L"", bool multiple=false);
ListBoxInfo &addSelection(const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
ListBoxInfo &addSelection(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
ListBoxInfo &addSelection(const string &id, int width, int height, GUICALLBACK cb=0, const wstring &explanation=L"", const wstring &tooltip=L"");
ListBoxInfo &addSelection(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const wstring &explanation=L"", const wstring &tooltip=L"");
ListBoxInfo &addCombo(const string &id, int width, int height, GUICALLBACK cb=0, const wstring &explanation=L"", const wstring &tooltip=L"");
ListBoxInfo &addCombo(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const wstring &explanation=L"", const wstring &tooltip=L"");
ListBoxInfo &addCombo(const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
ListBoxInfo &addCombo(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
// Grows a listbox, selection, combo in X-direction to fit current contents. Returns true if changed.
bool autoGrow(const char *id);
void setListDescription(const string &desc);
void setListDescription(const wstring &desc);
// Wide versions
TextInfo &addString(const string &id, int format, const wstring &text, GUICALLBACK cb=0);
TextInfo &addString(const string &id, int yp, int xp, int format, const wstring &text,
int xlimit=0, GUICALLBACK cb=0, const wchar_t *fontFace = 0);
TextInfo &addString(const char *id, int format, const wstring &text, GUICALLBACK cb=0);
TextInfo &addString(const char *id, int yp, int xp, int format, const wstring &text,
int xlimit=0, GUICALLBACK cb=0, const wchar_t *fontFace = 0);
// Untranslated versions
TextInfo &addStringUT(int yp, int xp, int format, const wstring &text,
int xlimit=0, GUICALLBACK cb=0, const wchar_t *fontFace = 0);
TextInfo &addStringUT(int format, const wstring &text, GUICALLBACK cb=0);
// Temporary XXX
TextInfo &addString(const string &id, int format, const string &text, GUICALLBACK cb=0);
TextInfo &addString(const string &id, int yp, int xp, int format, const string &text,
int xlimit=0, GUICALLBACK cb=0, const char *fontFace = 0);
int xlimit=0, GUICALLBACK cb=0, const wchar_t *fontFace = 0);
TextInfo &addString(const char *id, int format, const string &text, GUICALLBACK cb=0);
TextInfo &addString(const char *id, int yp, int xp, int format, const string &text,
int xlimit=0, GUICALLBACK cb=0, const char *fontFace = 0);
int xlimit=0, GUICALLBACK cb=0, const wchar_t *fontFace = 0);
// Untranslated versions
TextInfo &addStringUT(int yp, int xp, int format, const string &text,
int xlimit=0, GUICALLBACK cb=0, const char *fontFace = 0);
int xlimit=0, GUICALLBACK cb=0, const wchar_t *fontFace = 0);
TextInfo &addStringUT(int format, const string &text, GUICALLBACK cb=0);
// XXX Temporary
TextInfo &addTimer(int yp, int xp, int format, DWORD ZeroTime,
int xlimit=0, GUICALLBACK cb=0, int TimeOut=NOTIMEOUT, const char *fontFace = 0);
int xlimit=0, GUICALLBACK cb=0, int TimeOut=NOTIMEOUT, const wchar_t *fontFace = 0);
TextInfo &addTimeout(int TimeOut, GUICALLBACK cb);
void removeTimeoutMilli(const string &id);
@ -641,13 +718,13 @@ public:
void closeWindow();
void setDBErrorState(bool state);
int getCP() const {return defaultCodePage;}
friend int TablesCB(gdioutput *gdi, int type, void *data);
friend class Table;
friend gdioutput *createExtraWindow(const string &tag, const string &title, int max_x, int max_y);
friend gdioutput *createExtraWindow(const string &tag, const wstring &title, int max_x, int max_y);
gdioutput(const string &tag, double _scale, FontEncoding encoding);
gdioutput(double _scale, FontEncoding encoding, HWND hWndTarget, const PrinterObject &defprn);
gdioutput(const string &tag, double _scale, int defaultCodePage);
gdioutput(double _scale, HWND hWndTarget, const PrinterObject &defprn, int defaultCodePage);
virtual ~gdioutput();
};

View File

@ -56,13 +56,13 @@ public:
InvalidateRect(getControlWindow(), 0, true);
}
BaseInfo &setExtra(const char *e) {extra=(void *)e; dataString = true; return *this;}
BaseInfo &setExtra(const wchar_t *e) {extra=(void *)e; dataString = true; return *this;}
BaseInfo &setExtra(int e) {extra = (void *)(e); return *this;}
BaseInfo &setExtra(size_t e) {extra = (void *)(e); return *this;}
bool isExtraString() const {return dataString;}
char *getExtra() const {assert(extra == 0 || dataString); return (char *)extra;}
wchar_t *getExtra() const {assert(extra == 0 || dataString); return (wchar_t *)extra;}
int getExtraInt() const {return int(extra);}
size_t getExtraSize() const {return size_t(extra);}
@ -149,7 +149,7 @@ public:
}
TextInfo &setColor(GDICOLOR c) {color = c; return *this;}
TextInfo &changeFont(const string &fnt) {font = fnt; return *this;} //Note: size not updated
TextInfo &changeFont(const wstring &fnt) {font = fnt; return *this;} //Note: size not updated
int getHeight() {return int(textRect.bottom-textRect.top);}
gdiFonts getGdiFont() const {return gdiFonts(format & 0xFF);}
@ -157,8 +157,8 @@ public:
TextInfo &setAbsPrintPos(int x, int y) {
absPrintX = x; absPrintY = y; return *this;
}
string text;
string font;
wstring text;
wstring font;
int xp;
int yp;
@ -204,7 +204,7 @@ public:
int xp;
int yp;
int width;
string text;
wstring text;
HWND hWnd;
bool AbsPos;
bool fixedRightTop;
@ -234,7 +234,7 @@ class InputInfo : public BaseInfo
{
public:
InputInfo();
string text;
wstring text;
bool changed() const {return text!=original;}
void ignore(bool ig) {ignoreCheck=ig;}
@ -249,7 +249,7 @@ public:
HWND getControlWindow() const {return hWnd;}
InputInfo &setSynchData(string *variable) {updateLastData = variable; return *this;}
InputInfo &setSynchData(wstring *variable) {updateLastData = variable; return *this;}
int getX() const {return xp;}
int getY() const {return yp;}
@ -258,7 +258,7 @@ private:
HWND hWnd;
GUICALLBACK callBack;
void synchData() const {if (updateLastData) *updateLastData = text;}
string *updateLastData;
wstring *updateLastData;
int xp;
int yp;
double width;
@ -268,8 +268,8 @@ private:
GDICOLOR fgColor;
bool isEditControl;
bool writeLock;
string original;
string focusText; // Test when got focus
wstring original;
wstring focusText; // Test when got focus
bool ignoreCheck; // True if changed-state should be ignored
friend class gdioutput;
};
@ -282,7 +282,7 @@ public:
originalProc(0), lbiSync(0), multipleSelection(false),
xp(0), yp(0), width(0), height(0), data(0), lastTabStop(0),
updateLastData(0) {}
string text;
wstring text;
size_t data;
int index;
bool changed() const {return text!=original;}
@ -313,7 +313,7 @@ private:
bool multipleSelection;
bool isEditControl;
bool writeLock;
string original;
wstring original;
int originalIdx;
bool ignoreCheck; // True if changed-state should be ignored
@ -355,12 +355,22 @@ public:
class TimerInfo : public BaseInfo
{
private:
DWORD data;
DWORD dataInt;
wstring dataString;
gdioutput *parent;
TimerInfo(gdioutput *gdi, GUICALLBACK cb) : parent(gdi), callBack(cb) {}
public:
BaseInfo &setExtra(void *e) {return BaseInfo::setExtra((const char *)e);}
BaseInfo &setExtra(const wchar_t *e) {return BaseInfo::setExtra(e);}
BaseInfo &setExtra(int e) {return BaseInfo::setExtra(e);}
void setData(DWORD d, const wstring &s) {dataInt = d; dataString = s;}
const wstring &getDataString() {
return dataString;
}
DWORD getData() {
return dataInt;
}
GUICALLBACK callBack;
friend class gdioutput;
@ -374,7 +384,7 @@ class InfoBox : public BaseInfo
{
public:
InfoBox() : callBack(0), HasCapture(0), HasTCapture(0), TimeOut(0) {}
string text;
wstring text;
GUICALLBACK callBack;
RECT TextRect;

View File

@ -29,13 +29,16 @@
#include "meosexception.h"
#include "localizer.h"
GeneralResultCtr::GeneralResultCtr(const char *tagIn, const string &nameIn, GeneralResult *ptrIn) {
extern gdioutput *gdi_main;
GeneralResultCtr::GeneralResultCtr(const char *tagIn, const wstring &nameIn, GeneralResult *ptrIn) {
name = nameIn;
tag = tagIn;
ptr = ptrIn;
}
GeneralResultCtr::GeneralResultCtr(string &file, DynamicResult *ptrIn) {
GeneralResultCtr::GeneralResultCtr(wstring &file, DynamicResult *ptrIn) {
ptr = ptrIn;
name = ptrIn->getName(false);
tag = ptrIn->getTag();
@ -116,8 +119,8 @@ struct GRSortInfo {
else if (score != other.score)
return score < other.score;
const string &as = tr->getBib();
const string &bs = other.tr->getBib();
const wstring &as = tr->getBib();
const wstring &bs = other.tr->getBib();
if (as != bs)
return compareBib(as, bs);
else
@ -780,8 +783,8 @@ int DynamicResult::deducePoints(oRunner &runner) const {
}
void DynamicResult::save(const string &file) const {
xmlparser xml(0);
void DynamicResult::save(const wstring &file) const {
xmlparser xml;
xml.openOutput(file.c_str(), true);
save(xml);
xml.closeOut();
@ -792,12 +795,12 @@ extern oEvent *gEvent;
void DynamicResult::save(xmlparser &xml) const {
xml.startTag("MeOSResultCalculationSet");
xml.write("Name", name);
xml.write("Tag", tag);
xml.write("Tag", gdioutput::widen(tag));
xml.write("Description", description);
if (origin.empty())
origin = gEvent->getName() + " (" + getLocalDate() + ")";
origin = gEvent->getName() + L" (" + getLocalDateW() + L")";
xml.write("Origin", origin);
xml.write("Date", getLocalTime());
xml.write("Date", getLocalTimeW());
// xml.write("Tag", tag);
// xml.write("UID", getUniqueId());
@ -821,8 +824,8 @@ void DynamicResult::clear() {
}
}
void DynamicResult::load(const string &file) {
xmlparser xml(0);
void DynamicResult::load(const wstring &file) {
xmlparser xml;
xml.read(file.c_str());
xmlobject xDef = xml.getObject("MeOSResultCalculationSet");
load(xDef);
@ -864,7 +867,7 @@ void DynamicResult::compile(bool forceRecompile) const {
}
parser.clear();
pair<string, string> err;
pair<wstring, wstring> err;
for (size_t k = 0; k < methods.size(); k++) {
if (!methods[k].source.empty()) {
try {
@ -872,14 +875,14 @@ void DynamicResult::compile(bool forceRecompile) const {
}
catch (const meosException &ex) {
if (err.first.empty()) {
err.first = method2SymbName[DynamicMethods(k)].second;
err.second = lang.tl(ex.what());
err.first = gdioutput::widen(method2SymbName[DynamicMethods(k)].second);
err.second = lang.tl(ex.wwhat());
}
}
}
}
if (!err.first.empty()) {
throw meosException("Error in result module X, method Y (Z)#" + name + "#" + err.first + "#" + err.second);
throw meosException(L"Error in result module X, method Y (Z)#" + name + L"#" + err.first + L"#" + err.second);
}
}
@ -985,11 +988,11 @@ void DynamicResult::declareSymbols(DynamicMethods m, bool clear) const {
}
}
void DynamicResult::getSymbols(vector< pair<string, size_t> > &symb) const {
void DynamicResult::getSymbols(vector< pair<wstring, size_t> > &symb) const {
parser.getSymbols(symb);
}
void DynamicResult::getSymbolInfo(int ix, string &name, string &desc) const {
void DynamicResult::getSymbolInfo(int ix, wstring &name, wstring &desc) const {
parser.getSymbolInfo(ix, name, desc);
}
@ -1062,7 +1065,7 @@ void DynamicResult::prepareCommon(oAbstractRunner &runner) const {
parser.addSymbol("ClubId", 0);
parser.addSymbol("DistrictId", 0);
}
parser.addSymbol("Bib", atoi(runner.getBib().c_str()));
parser.addSymbol("Bib", _wtoi(runner.getBib().c_str()));
}
void DynamicResult::prepareCalculations(oTeam &team) const {
@ -1255,6 +1258,7 @@ void DynamicResult::storeOutput(vector<int> &times, vector<int> &numbers) const
}
int checksum(const string &str);
int checksum(const wstring &str);
long long DynamicResult::getHashCode() const {
long long hc = 1;
@ -1272,11 +1276,11 @@ string DynamicResult::undecorateTag(const string &inputTag) {
return inputTag;
}
string DynamicResult::getName(bool withAnnotation) const {
wstring DynamicResult::getName(bool withAnnotation) const {
if (annotation.empty() || !withAnnotation)
return name;
else
return name + " (" + annotation + ")";
return name + L" (" + annotation + L")";
}
void DynamicResult::debugDumpVariables(gdioutput &gdi, bool includeSymbols) const {

View File

@ -132,11 +132,11 @@ private:
vector<MethodInfo> methods;
mutable bool isCompiled;
mutable Parser parser;
string name;
wstring name;
string tag;
string description;
string annotation;
mutable string origin;
wstring description;
wstring annotation;
mutable wstring origin;
string timeStamp;
bool builtIn;
mutable bool readOnly;
@ -161,8 +161,8 @@ public:
long long getHashCode() const;
void getSymbols(vector< pair<string, size_t> > &symb) const;
void getSymbolInfo(int ix, string &name, string &desc) const;
void getSymbols(vector< pair<wstring, size_t> > &symb) const;
void getSymbolInfo(int ix, wstring &name, wstring &desc) const;
void declareSymbols(DynamicMethods m, bool clear) const;
@ -200,16 +200,16 @@ public:
void setTag(const string &t) {tag = t;}
void setBuiltIn() {builtIn = true;}
bool isBuiltIn() const {return builtIn;}
string getName(bool withAnnotation) const;
void setName(const string &n) {name = n;}
void setAnnotation(const string &a) {annotation = a;}
const string &getDescription() const {return description;}
void setDescription(const string &n) {description = n;}
wstring getName(bool withAnnotation) const;
void setName(const wstring &n) {name = n;}
void setAnnotation(const wstring &a) {annotation = a;}
const wstring &getDescription() const {return description;}
void setDescription(const wstring &n) {description = n;}
void save(const string &file) const;
void save(const wstring &file) const;
void save(xmlparser &xml) const;
void load(const string &file);
void load(const wstring &file);
void load(const xmlobject &xDef);
void compile(bool forceRecompile) const;

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,7 @@ int ImportFormats::getDefault(oEvent &oe) {
return oe.getPropertyString("Language", "English") == "Français" ? FrenchFederationMapping : Default;
}
*/
void ImportFormats::getExportFormats(vector< pair<string, size_t> > &types, bool exportFilter) {
void ImportFormats::getExportFormats(vector< pair<wstring, size_t> > &types, bool exportFilter) {
types.clear();
string v;
@ -56,18 +56,18 @@ void ImportFormats::getExportFormats(vector< pair<string, size_t> > &types, bool
types.push_back(make_pair(lang.tl("Webbdokument (html)"), HTML));
}
void ImportFormats::getExportFilters(bool exportFilters, vector< pair<string, string> > &ext) {
string v;
void ImportFormats::getExportFilters(bool exportFilters, vector< pair<wstring, wstring> > &ext) {
wstring v;
if (exportFilters)
v = "Resultat";
v = L"Resultat";
else
v = "Startlista";
v = L"Startlista";
ext.push_back(make_pair("IOF " + v + ", version 3.0 (xml)", "*.xml"));
ext.push_back(make_pair("IOF " + v + ", version 2.0.3 (xml)", "*.xml"));
ext.push_back(make_pair("OE Semikolonseparerad (csv)", "*.csv"));
ext.push_back(make_pair("OE/French Federation of Orienteering (csv)", "*.csv"));
ext.push_back(make_pair("Webbdokument (html)", "*.html"));
ext.push_back(make_pair(L"IOF " + v + L", version 3.0 (xml)", L"*.xml"));
ext.push_back(make_pair(L"IOF " + v + L", version 2.0.3 (xml)", L"*.xml"));
ext.push_back(make_pair(L"OE Semikolonseparerad (csv)", L"*.csv"));
ext.push_back(make_pair(L"OE/French Federation of Orienteering (csv)", L"*.csv"));
ext.push_back(make_pair(L"Webbdokument (html)", L"*.html"));
}
ImportFormats::ExportFormats ImportFormats::getDefaultExportFormat(oEvent &oe) {
@ -80,13 +80,13 @@ ImportFormats::ExportFormats ImportFormats::setExportFormat(oEvent &oe, int raw)
return (ExportFormats)raw;
}
void ImportFormats::getOECSVLanguage(vector< pair<string, size_t> > &typeLanguages) {
typeLanguages.push_back(make_pair("English", 1));
typeLanguages.push_back(make_pair("Svenska", 2));
typeLanguages.push_back(make_pair("Deutsch", 3));
typeLanguages.push_back(make_pair("Dansk", 4));
typeLanguages.push_back(make_pair("Français", 5));
typeLanguages.push_back(make_pair("Russian", 6));
void ImportFormats::getOECSVLanguage(vector< pair<wstring, size_t> > &typeLanguages) {
typeLanguages.push_back(make_pair(L"English", 1));
typeLanguages.push_back(make_pair(L"Svenska", 2));
typeLanguages.push_back(make_pair(L"Deutsch", 3));
typeLanguages.push_back(make_pair(L"Dansk", 4));
typeLanguages.push_back(make_pair(L"Français", 5));
typeLanguages.push_back(make_pair(L"Russian", 6));
}
int ImportFormats::getDefaultCSVLanguage(oEvent &oe) {

View File

@ -41,9 +41,9 @@ public:
HTML = 5
};
static void getExportFormats(vector< pair<string, size_t> > &types, bool exportFilter);
static void getExportFormats(vector< pair<wstring, size_t> > &types, bool exportFilter);
static void getExportFilters(bool exportFilters, vector< pair<string, string> > &ext);
static void getExportFilters(bool exportFilters, vector< pair<wstring, wstring> > &ext);
static ExportFormats getDefaultExportFormat(oEvent &oe);
@ -55,7 +55,7 @@ public:
return option;
}
static void getOECSVLanguage(vector< pair<string, size_t> > &typeLanguages);
static void getOECSVLanguage(vector< pair<wstring, size_t> > &typeLanguages);
static int getDefaultCSVLanguage(oEvent &oe);

View File

@ -32,16 +32,17 @@
#include "gdioutput.h"
void base64_encode(const vector<BYTE> &input, string &output);
extern gdioutput *gdi_main;
// Encode a vector vector int {{1}, {1,2,3}, {}, {4,5}} as "1;1,2,3;;4,5"
static void packIntInt(vector< vector<int> > v, string &def) {
static void packIntInt(vector< vector<int> > v, wstring &def) {
for (size_t j = 0; j < v.size(); j++) {
if (j>0)
def += ";";
def += L";";
for (size_t k = 0; k < v[j].size(); k++) {
if (k>0)
def += ",";
def += itos(v[j][k]);
def += L",";
def += itow(v[j][k]);
}
}
}
@ -92,7 +93,7 @@ InfoTeam::InfoTeam(int id) : InfoBaseCompetitor(id) {
}
bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls) {
bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls, const set<int> &ctrls) {
bool changed = false;
if (oe.getName() != name) {
name = oe.getName();
@ -121,18 +122,18 @@ bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls) {
oe.getControls(ctrl, true);
set<int> knownId;
for (size_t k = 0; k < ctrl.size(); k++) {
if (ctrl[k]->isValidRadio()) {
vector<int> ids;
ctrl[k]->getCourseControls(ids);
for (size_t j = 0; j < ids.size(); j++) {
int id = ids[j];
knownId.insert(id);
map<int, InfoRadioControl>::iterator res = controls.find(id);
if (res == controls.end())
res = controls.insert(make_pair(id, InfoRadioControl(id))).first;
if (res->second.synchronize(*ctrl[k], ids.size() > 1 ? j+1 : 0))
needCommit(res->second);
}
vector<int> ids;
ctrl[k]->getCourseControls(ids);
for (size_t j = 0; j < ids.size(); j++) {
int wid = ids[j];
if (!ctrls.count(ids[j]))
continue;
knownId.insert(wid);
map<int, InfoRadioControl>::iterator res = controls.find(wid);
if (res == controls.end())
res = controls.insert(make_pair(wid, InfoRadioControl(wid))).first;
if (res->second.synchronize(*ctrl[k], ids.size() > 1 ? j+1 : 0))
needCommit(res->second);
}
}
@ -150,14 +151,14 @@ bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls) {
vector<pClass> cls;
oe.getClasses(cls, false);
for (size_t k = 0; k < cls.size(); k++) {
int id = cls[k]->getId();
if (!includeCls.count(id))
int wid = cls[k]->getId();
if (!includeCls.count(wid))
continue;
knownId.insert(id);
map<int, InfoClass>::iterator res = classes.find(id);
knownId.insert(wid);
map<int, InfoClass>::iterator res = classes.find(wid);
if (res == classes.end())
res = classes.insert(make_pair(id, InfoClass(id))).first;
if (res->second.synchronize(*cls[k]))
res = classes.insert(make_pair(wid, InfoClass(wid))).first;
if (res->second.synchronize(*cls[k], ctrls))
needCommit(res->second);
}
@ -175,11 +176,11 @@ bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls) {
vector<pClub> clb;
oe.getClubs(clb, false);
for (size_t k = 0; k < clb.size(); k++) {
int id = clb[k]->getId();
knownId.insert(id);
map<int, InfoOrganization>::iterator res = organizations.find(id);
int wid = clb[k]->getId();
knownId.insert(wid);
map<int, InfoOrganization>::iterator res = organizations.find(wid);
if (res == organizations.end())
res = organizations.insert(make_pair(id, InfoOrganization(id))).first;
res = organizations.insert(make_pair(wid, InfoOrganization(wid))).first;
if (res->second.synchronize(*clb[k]))
needCommit(res->second);
}
@ -200,11 +201,11 @@ bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls) {
for (size_t k = 0; k < t.size(); k++) {
if (!includeCls.count(t[k]->getClassId()))
continue;
int id = t[k]->getId();
knownId.insert(id);
map<int, InfoTeam>::iterator res = teams.find(id);
int wid = t[k]->getId();
knownId.insert(wid);
map<int, InfoTeam>::iterator res = teams.find(wid);
if (res == teams.end())
res = teams.insert(make_pair(id, InfoTeam(id))).first;
res = teams.insert(make_pair(wid, InfoTeam(wid))).first;
if (res->second.synchronize(*t[k]))
needCommit(res->second);
}
@ -225,11 +226,11 @@ bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls) {
for (size_t k = 0; k < r.size(); k++) {
if (!includeCls.count(r[k]->getClassId()))
continue;
int id = r[k]->getId();
knownId.insert(id);
map<int, InfoCompetitor>::iterator res = competitors.find(id);
int wid = r[k]->getId();
knownId.insert(wid);
map<int, InfoCompetitor>::iterator res = competitors.find(wid);
if (res == competitors.end())
res = competitors.insert(make_pair(id, InfoCompetitor(id))).first;
res = competitors.insert(make_pair(wid, InfoCompetitor(wid))).first;
if (res->second.synchronize(*this, *r[k]))
needCommit(res->second);
}
@ -253,9 +254,9 @@ void InfoCompetition::needCommit(InfoBase &obj) {
}
bool InfoRadioControl::synchronize(oControl &c, int number) {
string n = c.hasName() ? c.getName() : c.getString();
wstring n = c.hasName() ? c.getName() : c.getString();
if (number > 0)
n = n + "-" + itos(number);
n = n + L"-" + itow(number);
if (n == name)
return false;
else {
@ -266,13 +267,13 @@ bool InfoRadioControl::synchronize(oControl &c, int number) {
}
void InfoRadioControl::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
vector< pair<string, wstring> > prop;
prop.push_back(make_pair("id", itow(getId())));
xml.write("ctrl", prop, name);
}
bool InfoClass::synchronize(oClass &c) {
const string &n = c.getName();
bool InfoClass::synchronize(oClass &c, const set<int> &ctrls) {
const wstring &n = c.getName();
int no = c.getSortIndex();
bool mod = false;
vector< vector<int> > rc;
@ -290,7 +291,7 @@ bool InfoClass::synchronize(oClass &c) {
vector<pControl> ctrl;
pc->getControls(ctrl);
for (size_t j = 0; j < ctrl.size(); j++) {
if (ctrl[j]->isValidRadio()) {
if (ctrls.count(pc->getCourseControlId(j))) {
rc.back().push_back(pc->getCourseControlId(j));
}
}
@ -310,8 +311,7 @@ bool InfoClass::synchronize(oClass &c) {
vector<pControl> ctrl;
pc->getControls(ctrl);
for (size_t j = 0; j < ctrl.size(); j++) {
if (ctrl[j]->isValidRadio()) {
//rc.back().push_back(pc->getCourseControlId(ctrl[j]->getId());
if (ctrls.count(pc->getCourseControlId(j))) {
rc.back().push_back(pc->getCourseControlId(j));
}
}
@ -335,17 +335,17 @@ bool InfoClass::synchronize(oClass &c) {
}
void InfoClass::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
prop.push_back(make_pair("ord", itos(sortOrder)));
string def;
vector< pair<string, wstring> > prop;
prop.push_back(make_pair("id", itow(getId())));
prop.push_back(make_pair("ord", itow(sortOrder)));
wstring def;
packIntInt(radioControls, def);
prop.push_back(make_pair("radio", def));
xml.write("cls", prop, name);
}
bool InfoOrganization::synchronize(oClub &c) {
const string &n = c.getDisplayName();
const wstring &n = c.getDisplayName();
if (n == name)
return false;
else {
@ -356,13 +356,13 @@ bool InfoOrganization::synchronize(oClub &c) {
}
void InfoOrganization::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
vector< pair<string, wstring> > prop;
prop.push_back(make_pair("id", itow(getId())));
xml.write("org", prop, name);
}
void InfoCompetition::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
vector< pair<string, wstring> > prop;
prop.push_back(make_pair("date", date));
prop.push_back(make_pair("organizer", organizer));
prop.push_back(make_pair("homepage", homepage));
@ -370,17 +370,17 @@ void InfoCompetition::serialize(xmlbuffer &xml, bool diffOnly) const {
}
void InfoBaseCompetitor::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("org", itos(organizationId)));
prop.push_back(make_pair("cls", itos(classId)));
prop.push_back(make_pair("stat", itos(status)));
prop.push_back(make_pair("st", itos(startTime)));
prop.push_back(make_pair("rt", itos(runningTime)));
vector< pair<string, wstring> > prop;
prop.push_back(make_pair("org", itow(organizationId)));
prop.push_back(make_pair("cls", itow(classId)));
prop.push_back(make_pair("stat", itow(status)));
prop.push_back(make_pair("st", itow(startTime)));
prop.push_back(make_pair("rt", itow(runningTime)));
xml.write("base", prop, name);
}
bool InfoBaseCompetitor::synchronizeBase(oAbstractRunner &bc) {
const string &n = bc.getName();
const wstring &n = bc.getName();
bool ch = false;
if (n != name) {
name = n;
@ -468,8 +468,8 @@ bool InfoCompetitor::synchronize(const InfoCompetition &cmp, oRunner &r) {
}
void InfoCompetitor::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > sprop;
sprop.push_back(make_pair("id", itos(getId())));
vector< pair<string, wstring> > sprop;
sprop.push_back(make_pair("id", itow(getId())));
xmlbuffer &subTag = xml.startTag("cmp", sprop);
InfoBaseCompetitor::serialize(subTag, diffOnly);
if (radioTimes.size() > 0 && (!diffOnly || changeRadio)) {
@ -528,11 +528,11 @@ bool InfoTeam::synchronize(oTeam &t) {
}
void InfoTeam::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
vector< pair<string, wstring> > prop;
prop.push_back(make_pair("id", itow(getId())));
xmlbuffer &sub = xml.startTag("tm", prop);
InfoBaseCompetitor::serialize(sub, diffOnly);
string def;
wstring def;
packIntInt(competitors, def);
prop.clear();
sub.write("r", prop, def);
@ -629,7 +629,7 @@ void base64_encode(const vector<BYTE> &input, string &encoded_data) {
encoded_data[output_length - 1 - i] = '=';
}
xmlbuffer &xmlbuffer::startTag(const char *tag, const vector< pair<string, string> > &prop) {
xmlbuffer &xmlbuffer::startTag(const char *tag, const vector< pair<string, wstring> > &prop) {
blocks.push_back(block());
blocks.back().tag = tag;
blocks.back().prop = prop;
@ -645,11 +645,23 @@ void xmlbuffer::write(const char *tag,
const string &value) {
blocks.push_back(block());
blocks.back().tag = tag;
for (size_t k = 0; k < prop.size(); k++)
blocks.back().prop.push_back(make_pair(prop[k].first, gdi_main->widen(prop[k].second)));
blocks.back().value = gdi_main->widen(value);
}
void xmlbuffer::write(const char *tag,
const vector< pair<string, wstring> > &prop,
const wstring &value) {
blocks.push_back(block());
blocks.back().tag = tag;
blocks.back().prop = prop;
blocks.back().value = value;
}
void xmlbuffer::startXML(xmlparser &xml, const string &dest) {
void xmlbuffer::startXML(xmlparser &xml, const wstring &dest) {
xml.openOutput(dest.c_str(), false);
if (complete) {
xml.startTag("MOPComplete", "xmlns", "http://www.melin.nu/mop");
@ -667,9 +679,9 @@ bool xmlbuffer::commit(xmlparser &xml, int count) {
xml.write(block.tag.c_str(), block.prop, block.value);
}
else {
vector<string> p2;
vector<wstring> p2;
for (size_t k = 0; k< block.prop.size(); k++) {
p2.push_back(block.prop[k].first);
p2.push_back(gdi_main->widen(block.prop[k].first));
p2.push_back(block.prop[k].second);
}
xml.startTag(block.tag.c_str(), p2);

View File

@ -42,8 +42,8 @@ class xmlbuffer {
private:
struct block {
string tag;
vector<pair<string, string>> prop;
string value;
vector< pair<string, wstring> > prop;
wstring value;
vector<xmlbuffer> subValues;
};
@ -51,16 +51,21 @@ private:
bool complete;
public:
void setComplete(bool c) {complete = c;}
xmlbuffer &startTag(const char *tag, const vector< pair<string, string> > &prop);
xmlbuffer &startTag(const char *tag, const vector< pair<string, wstring> > &prop);
void endTag();
void write(const char *tag,
const vector< pair<string, string> > &prop,
const string &value);
void write(const char *tag,
const vector< pair<string, wstring> > &prop,
const wstring &value);
size_t size() const {return blocks.size();}
bool commit(xmlparser &xml, int count);
void startXML(xmlparser &xml, const string &dest);
void startXML(xmlparser &xml, const wstring &dest);
};
class InfoBase
@ -93,7 +98,7 @@ typedef InfoBase * pInfoBase;
class InfoRadioControl : public InfoBase {
protected:
string name;
wstring name;
bool synchronize(oControl &c, int number);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
@ -105,11 +110,11 @@ class InfoRadioControl : public InfoBase {
class InfoClass : public InfoBase {
protected:
string name;
wstring name;
int sortOrder;
vector< vector<int> > radioControls;
vector<int> linearLegNumberToActual;
bool synchronize(oClass &c);
bool synchronize(oClass &c, const set<int> &ctrls);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
InfoClass(int id);
@ -120,7 +125,7 @@ class InfoClass : public InfoBase {
class InfoOrganization : public InfoBase {
protected:
string name;
wstring name;
bool synchronize(oClub &c);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
@ -141,7 +146,7 @@ struct RadioTime {
class InfoBaseCompetitor : public InfoBase {
protected:
string name;
wstring name;
int organizationId;
int classId;
@ -185,10 +190,10 @@ class InfoTeam : public InfoBaseCompetitor {
class InfoCompetition : public InfoBase {
private:
string name;
string date;
string organizer;
string homepage;
wstring name;
wstring date;
wstring organizer;
wstring homepage;
protected:
bool forceComplete;
@ -206,7 +211,7 @@ protected:
public:
const vector<int> &getControls(int classId, int legNumber) const;
bool synchronize(oEvent &oe, const set<int> &classes);
bool synchronize(oEvent &oe, const set<int> &classes, const set<int> &ctrls);
void getCompleteXML(xmlbuffer &xml);
void getDiffXML(xmlbuffer &xml);

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,7 @@ class oClass;
class oDataInterface;
class oDataConstInterface;
class oAbstractRunner;
struct RunnerDBEntry;
struct RunnerWDBEntry;
class RunnerDB;
typedef oRunner * pRunner;
@ -78,13 +78,13 @@ class IOF30Interface {
double taxable;
double percentage; // Eventor / OLA stupidity
string currency;
wstring currency;
string fromTime;
string toTime;
wstring fromTime;
wstring toTime;
string fromBirthDate;
string toBirthDate;
wstring fromBirthDate;
wstring toBirthDate;
bool includes(const FeeInfo &fo) const {
if (toBirthDate != fo.toBirthDate || fromBirthDate != fo.fromBirthDate)
@ -102,20 +102,20 @@ class IOF30Interface {
void add(FeeInfo &fi);
string getDateKey() const {return fromTime + " - " + toTime;}
wstring getDateKey() const {return fromTime + L" - " + toTime;}
FeeInfo() : fee(0), taxable(0), percentage(0) {}
const bool operator<(const FeeInfo &fi) const {
return fee < fi.fee || (fee == fi.fee && taxable < fi.taxable);
}
private:
bool includeFrom(const string &a, const string &b) const {
bool includeFrom(const wstring &a, const wstring &b) const {
if ( a > b || (b.empty() && !a.empty()) )
return false;
return true;
}
bool includeTo(const string &a, const string &b) const {
bool includeTo(const wstring &a, const wstring &b) const {
if ( (!a.empty() && a < b) || (b.empty() && !a.empty()) )
return false;
return true;
@ -130,12 +130,15 @@ class IOF30Interface {
vector<FeeStatistics> feeStatistics;
static void getAgeLevels(const vector<FeeInfo> &fees, const vector<int> &ix,
int &normalIx, int &redIx, string &youthLimit, string &seniorLimit);
int &normalIx, int &redIx, wstring &youthLimit, wstring &seniorLimit);
bool matchStageFilter(const set<int> &stageFilter, const xmlList &races);
void readEvent(gdioutput &gdi, const xmlobject &xo,
map<int, vector<LegInfo> > &teamClassConfig);
pRunner readPersonEntry(gdioutput &gdi, xmlobject &xo, pTeam team,
const map<int, vector<LegInfo> > &teamClassConfig,
const set<int> &stageFilter,
map<int, vector< pair<int, int> > > &personId2TeamLeg);
pRunner readPerson(gdioutput &gdi, const xmlobject &xo);
pClub readOrganization(gdioutput &gdi, const xmlobject &xo, bool saveToDB);
@ -143,7 +146,8 @@ class IOF30Interface {
map<int, vector<LegInfo> > &teamClassConfig);
pTeam readTeamEntry(gdioutput &gdi, xmlobject &xTeam,
map<int, pair<string, int> > &bibPatterns,
const set<int> &stageFilter,
map<int, pair<wstring, int> > &bibPatterns,
const map<int, vector<LegInfo> > &teamClassConfig,
map<int, vector< pair<int, int> > > &personId2TeamLeg);
@ -151,26 +155,28 @@ class IOF30Interface {
const map<int, vector<LegInfo> > &teamClassConfig);
pTeam readTeamStart(gdioutput &gdi, pClass pc, xmlobject &xTeam,
map<int, pair<string, int> > &bibPatterns,
map<int, pair<wstring, int> > &bibPatterns,
const map<int, vector<LegInfo> > &teamClassConfig);
pTeam getCreateTeam(gdioutput &gdi, const xmlobject &xTeam, bool &newTeam);
static int getIndexFromLegPos(int leg, int legorder, const vector<LegInfo> &setup);
void prescanEntry(xmlobject & xo, set<int>& stages);
void setupClassConfig(int classId, const xmlobject &xTeam, map<int, vector<LegInfo> > &teamClassConfig);
void setupRelayClasses(const map<int, vector<LegInfo> > &teamClassConfig);
void setupRelayClass(pClass pc, const vector<LegInfo> &teamClassConfig);
int parseISO8601Time(const xmlobject &xo);
string getCurrentTime() const;
wstring getCurrentTime() const;
static void getNationality(const xmlobject &xCountry, oDataInterface &di);
static void getAmount(const xmlobject &xAmount, double &amount, string &currency);
static void getAssignedFee(const xmlobject &xFee, double &fee, double &paid, double &taxable, double &percentage, string &currency);
static void getAmount(const xmlobject &xAmount, double &amount, wstring &currency);
static void getAssignedFee(const xmlobject &xFee, double &fee, double &paid, double &taxable, double &percentage, wstring &currency);
static void getFee(const xmlobject &xFee, FeeInfo &fee);
static void getFeeAmounts(const xmlobject &xFee, double &fee, double &taxable, double &percentage, string &currency);
static void getFeeAmounts(const xmlobject &xFee, double &fee, double &taxable, double &percentage, wstring &currency);
void writeFees(xmlparser &xml, const oRunner &r) const;
@ -178,7 +184,7 @@ class IOF30Interface {
void writeAssignedFee(xmlparser &xml, const oAbstractRunner &tr, int paidForCard) const;
void writeRentalCardService(xmlparser &xml, int cardFee, bool paid) const;
void getProps(vector<string> &props) const;
void getProps(vector<wstring> &props) const;
void writeClassResult(xmlparser &xml, const oClass &c, const vector<pRunner> &r,
const vector<pTeam> &t);
@ -219,9 +225,9 @@ class IOF30Interface {
int getStageNumber();
bool readXMLCompetitorDB(const xmlobject &xCompetitor);
void writeXMLCompetitorDB(xmlparser &xml, const RunnerDBEntry &rde) const;
void writeXMLCompetitorDB(xmlparser &xml, const RunnerWDBEntry &rde) const;
int getStartIndex(const string &startId);
int getStartIndex(const wstring &startId);
bool readControl(const xmlobject &xControl);
pCourse readCourse(const xmlobject &xcrs);
@ -229,31 +235,31 @@ class IOF30Interface {
void readCourseGroups(xmlobject xClassCourse, vector< vector<pCourse> > &crs);
void bindClassCourse(oClass &pc, const vector< vector<pCourse> > &crs);
static string constructCourseName(const xmlobject &xcrs);
static string constructCourseName(const string &family, const string &name);
static wstring constructCourseName(const xmlobject &xcrs);
static wstring constructCourseName(const wstring &family, const wstring &name);
void classAssignmentObsolete(gdioutput &gdi, xmlList &xAssignment, const map<string, pCourse> &courses,
const map<string, vector<pCourse> > &coursesFamilies);
void classAssignmentObsolete(gdioutput &gdi, xmlList &xAssignment, const map<wstring, pCourse> &courses,
const map<wstring, vector<pCourse> > &coursesFamilies);
void classCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses,
const map<string, vector<pCourse> > &coursesFamilies);
const map<wstring, pCourse> &courses,
const map<wstring, vector<pCourse> > &coursesFamilies);
void personCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses);
const map<wstring, pCourse> &courses);
void teamCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses);
const map<wstring, pCourse> &courses);
void assignTeamCourse(gdioutput &gdi, oTeam &t, xmlList &xAssignment,
const map<string, pCourse> &courses);
const map<wstring, pCourse> &courses);
pCourse findCourse(gdioutput &gdi, const map<string, pCourse> &courses,
pCourse findCourse(gdioutput &gdi, const map<wstring, pCourse> &courses,
xmlobject &xPAssignment);
string writeControl(xmlparser &xml, const oControl &c, set<string> &writtenId);
wstring writeControl(xmlparser &xml, const oControl &c, set<wstring> &writtenId);
void writeCourseInfo(xmlparser &xml, const oCourse &c);
void writeFullCourse(xmlparser &xml, const oCourse &c,
const map<int, string> &ctrlId2ExportId);
const map<int, wstring> &ctrlId2ExportId);
public:
IOF30Interface(oEvent *oe, bool forceSplitFee);
@ -261,7 +267,11 @@ public:
void readEventList(gdioutput &gdi, xmlobject &xo);
void readEntryList(gdioutput &gdi, xmlobject &xo, bool removeNonexisting, int &entRead, int &entFail, int &entRemoved);
/** Scan the entry list to find specification of stage numbers*/
void prescanEntryList(xmlobject & xo, set<int>& definedStages);
void readEntryList(gdioutput &gdi, xmlobject &xo, bool removeNonexisting,
const set<int> &stageFilter, int &entRead, int &entFail, int &entRemoved);
void readStartList(gdioutput &gdi, xmlobject &xo, int &entRead, int &entFail);

BIN
code/lib/RestBed.lib Normal file

Binary file not shown.

BIN
code/lib/zlibstat_vc15.lib Normal file

Binary file not shown.

BIN
code/lib_db/RestBed.lib Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -765,6 +765,11 @@ HPDF_EXPORT(HPDF_Image)
HPDF_LoadU3DFromFile (HPDF_Doc pdf,
const char *filename);
HPDF_EXPORT(HPDF_Image)
HPDF_LoadU3DFromMem (HPDF_Doc pdf,
const HPDF_BYTE *buffer,
HPDF_UINT size);
HPDF_EXPORT(HPDF_Image)
HPDF_Image_LoadRaw1BitImageFromMem (HPDF_Doc pdf,
const HPDF_BYTE *buf,

View File

@ -142,7 +142,7 @@
#define HPDF_MAX_WORDSPACE 300
#define HPDF_MIN_CHARSPACE -30
#define HPDF_MAX_CHARSPACE 300
#define HPDF_MAX_FONTSIZE 300
#define HPDF_MAX_FONTSIZE 600
#define HPDF_MAX_ZOOMSIZE 10
#define HPDF_MAX_LEADING 300
#define HPDF_MAX_LINEWIDTH 100

View File

@ -28,6 +28,7 @@ HPDF_EXPORT(HPDF_JavaScript) HPDF_CreateJavaScript(HPDF_Doc pdf, const char *cod
HPDF_EXPORT(HPDF_U3D) HPDF_LoadU3DFromFile (HPDF_Doc pdf, const char *filename);
HPDF_EXPORT(HPDF_Image) HPDF_LoadU3DFromMem (HPDF_Doc pdf, const HPDF_BYTE *buffer, HPDF_UINT size);
HPDF_EXPORT(HPDF_Dict) HPDF_Create3DView (HPDF_MMgr mmgr, const char *name);
HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_Add3DView(HPDF_U3D u3d, HPDF_Dict view);
HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_SetDefault3DView(HPDF_U3D u3d, const char *name);

View File

@ -1,4 +1,4 @@
This product is made available subject to the terms of GNU General Public License Version 3. A copy of the GPL license can be found at http://www.melin.nu/meos/license.html
This product is made available subject to the terms of GNU Affero Public License Version 3.
------------------------------------
Third Party Code. Additional copyright notices and license terms applicable to portions of the Software are set forth in the thirdpartylicense.txt file.
@ -7,13 +7,12 @@ Third Party Code. Additional copyright notices and license terms applicable to p
All trademarks and registered trademarks mentioned herein are the property of their respective owners.
------------------------------------
Copyright 2007-2013 Melin Software HB.
Copyright 2007-2017 Melin Software HB.
------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
@ -21,17 +20,15 @@ Copyright 2007-2013 Melin Software HB.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@ -40,44 +37,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
@ -86,7 +73,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@ -563,35 +550,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@ -649,40 +646,29 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -89,7 +89,7 @@ void ListEditor::show(gdioutput &gdi) {
int by = gdi.getCY();
if (currentList)
gdi.addString("", boldLarge, MakeDash("Listredigerare - X#") + currentList->getListName());
gdi.addString("", boldLarge, makeDash(L"Listredigerare - X#") + currentList->getListName());
else
gdi.addString("", boldLarge, "Listredigerare");
@ -106,7 +106,7 @@ void ListEditor::show(gdioutput &gdi) {
if (savedFileName.empty())
gdi.addButton("SaveFile", "Spara som fil", editListCB);
else {
gdi.addButton("SaveFile", "Spara fil", editListCB, "#" + savedFileName);
gdi.addButton("SaveFile", L"Spara fil", editListCB, L"#" + savedFileName);
gdi.addButton("SaveFileCopy", "Spara som...", editListCB);
}
@ -228,6 +228,10 @@ void ListEditor::show(gdioutput &gdi) {
oe->generateList(gdi, false, li, true);
}
catch (meosException &ex) {
gdi.addString("", 1, "Listan kan inte visas").setColor(colorRed);
gdi.addString("", 0, ex.wwhat());
}
catch (std::exception &ex) {
gdi.addString("", 1, "Listan kan inte visas").setColor(colorRed);
gdi.addString("", 0, ex.what());
@ -256,20 +260,20 @@ void ListEditor::showLine(gdioutput &gdi, const vector<MetaListPost> &line, int
}
ButtonInfo &ListEditor::addButton(gdioutput &gdi, const MetaListPost &mlp, int x, int y, int lineIx, int ix) const {
string cap;
if (mlp.getType() == "String") {
cap = "Text: X#" + mlp.getText();
wstring cap;
if (mlp.getType() == L"String") {
cap = L"Text: X#" + mlp.getText();
}
else {
const string &text = mlp.getText();
const wstring &text = mlp.getText();
if (text.length() > 0) {
if (text[0] == '@') {
vector<string> part;
split(text.substr(1), ";", part);
unsplit(part, "|", cap);
vector<wstring> part;
split(text.substr(1), L";", part);
unsplit(part, L"|", cap);
}
else
cap = text + "#" + lang.tl(mlp.getType());
cap = text + L"#" + lang.tl(mlp.getType());
}
else {
cap = mlp.getType();
@ -319,10 +323,10 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
if (ChooseColor(&cc)) {
data.setExtra((int)cc.rgbResult);
string co;
wstring co;
for (ix = 0; ix < 16; ix++) {
char bf[16];
sprintf_s(bf, "%x ", staticColor[ix]);
wchar_t bf[16];
swprintf_s(bf, L"%x ", staticColor[ix]);
co += bf;
}
oe->setProperty("Colors", co);
@ -403,14 +407,14 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
EPostType ptype = EPostType(lbi.data);
string str = gdi.getText("Text");
wstring str = gdi.getText("Text");
if (ptype != lString) {
if (!str.empty() && str.find_first_of('X') == string::npos && str[0]!='@') {
throw meosException("Texten ska innehålla tecknet X, som byts ut mot tävlingsspecifik data");
}
}
string t1 = mlp.getType();
wstring t1 = mlp.getType();
EPostType newType = EPostType(lbi.data);
mlp.setType(newType);
if (t1 != mlp.getType())
@ -461,7 +465,7 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
}
}
else if (bi.id == "ApplyListProp") {
string name = gdi.getText("Name");
wstring name = gdi.getText("Name");
if (name.empty())
throw meosException("Namnet kan inte vara tomt");
@ -482,7 +486,7 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
if (gdi.getSelectedItem("SubType", lbi))
list.setSubListType(oListInfo::EBaseType(lbi.data));
vector< pair<string, bool> > filtersIn;
vector< pair<wstring, bool> > filtersIn;
vector< bool > filtersOut;
list.getFilters(filtersIn);
for (size_t k = 0; k < filtersIn.size(); k++)
@ -490,7 +494,7 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
list.setFilters(filtersOut);
vector< pair<string, bool> > subFiltersIn;
vector< pair<wstring, bool> > subFiltersIn;
vector< bool > subFiltersOut;
list.getSubFilters(subFiltersIn);
for (size_t k = 0; k < subFiltersIn.size(); k++)
@ -550,13 +554,13 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
bool copy = bi.id == "SaveFileCopy";
string fileName = copy ? "" : savedFileName;
wstring fileName = copy ? L"" : savedFileName;
if (fileName.empty()) {
int ix = 0;
vector< pair<string, string> > ext;
ext.push_back(make_pair("xml-data", "*.xml"));
fileName = gdi.browseForSave(ext, "xml", ix);
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"xml-data", L"*.xml"));
fileName = gdi.browseForSave(ext, L"xml", ix);
if (fileName.empty())
return 0;
}
@ -572,15 +576,15 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
if (!checkSave(gdi))
return 0;
vector< pair<string, string> > ext;
ext.push_back(make_pair("xml-data", "*.xml"));
string fileName = gdi.browseForOpen(ext, "xml");
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"xml-data", L"*.xml"));
wstring fileName = gdi.browseForOpen(ext, L"xml");
if (fileName.empty())
return 0;
MetaList *tmp = new MetaList();
try {
tmp->setListName(lang.tl("Ny lista"));
tmp->setListName(lang.tl(L"Ny lista"));
tmp->load(fileName);
}
catch(...) {
@ -608,12 +612,12 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
gdi.setData("ListEditorClz", this);
gdi.pushX();
vector< pair<string, size_t> > lists;
vector< pair<wstring, size_t> > lists;
oe->getListContainer().getLists(lists, true, false, false);
reverse(lists.begin(), lists.end());
gdi.fillRight();
gdi.addSelection("OpenList", 250, 400, editListCB, "Välj lista:");
gdi.addSelection("OpenList", 250, 400, editListCB, L"Välj lista:");
gdi.addItem("OpenList", lists);
gdi.selectFirstItem("OpenList");
@ -709,12 +713,12 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
if (lbi.id == "AlignType") {
gdi.setInputStatus("AlignText", lbi.data == lString);
if (lbi.data == lString) {
int ix = lbi.text.find_first_of(":");
int ix = lbi.text.find_first_of(L":");
if (ix != lbi.text.npos)
gdi.setText("AlignText", lbi.text.substr(ix+1));
}
else
gdi.setText("AlignText", "");
gdi.setText("AlignText", L"");
}
else if (lbi.id == "Type") {
EPostType type = EPostType(lbi.data);
@ -727,12 +731,12 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
gdi.disableInput("UseLeg");
gdi.enableInput("Leg");
if (gdi.getText("Leg").empty())
gdi.setText("Leg", "0");
gdi.setText("Leg", L"0");
}
else {
gdi.enableInput("UseLeg");
if (gdi.getTextNo("Leg") == 0) {
gdi.setText("Leg", "");
gdi.setText("Leg", L"");
gdi.enableInput("UseLeg");
gdi.enableInput("UseResultModule", true);
gdi.check("UseLeg", false);
@ -742,14 +746,14 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
}
else if (lbi.id == "SubType") {
oListInfo::EBaseType subType = oListInfo::EBaseType(lbi.data);
vector< pair<string, bool> > subfilters;
vector< pair<wstring, bool> > subfilters;
currentList->getSubFilters(subfilters);
for (size_t k = 0; k < subfilters.size(); k++) {
gdi.setInputStatus("subfilter" + itos(k), subType != oListInfo::EBaseTypeNone);
}
}
else if (lbi.id == "ResultType") {
vector< pair<string, size_t> > types;
vector< pair<wstring, size_t> > types;
int currentType = 0;
currentList->getSortOrder(lbi.data != 0, types, currentType);
if (lbi.data == 0) {
@ -811,7 +815,7 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.dropLine(3);
gdi.popX();
vector< pair<string, size_t> > types;
vector< pair<wstring, size_t> > types;
int currentType;
mlp.getTypes(types, currentType);
EPostType storedType = EPostType(currentType);
@ -833,21 +837,21 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.pushX();
gdi.fillRight();
int boxY = gdi.getCY();
gdi.addSelection("Type", 290, 500, editListCB, "Typ:");
gdi.addSelection("Type", 290, 500, editListCB, L"Typ:");
gdi.addItem("Type", types);
gdi.selectItemByData("Type", currentType);
gdi.addInput("Text", mlp.getText(), 16, 0, "Egen text:", "Använd symbolen X där MeOS ska fylla i typens data.");
gdi.addInput("Text", mlp.getText(), 16, 0, L"Egen text:", L"Använd symbolen X där MeOS ska fylla i typens data.");
int boxX = gdi.getCX();
gdi.popX();
gdi.fillRight();
gdi.dropLine(3);
currentList->getAlignTypes(mlp, types, currentType);
sort(types.begin(), types.end());
gdi.addSelection("AlignType", 290, 500, editListCB, "Justera mot:");
gdi.addSelection("AlignType", 290, 500, editListCB, L"Justera mot:");
gdi.addItem("AlignType", types);
gdi.selectItemByData("AlignType", currentType);
gdi.addInput("AlignText", mlp.getAlignText(), 16, 0, "Text:");
gdi.addInput("AlignText", mlp.getAlignText(), 16, 0, L"Text:");
if (currentType != lString)
gdi.disableInput("AlignText");
gdi.popX();
@ -855,7 +859,7 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.fillRight();
gdi.addCheckbox("BlockAlign", "Justera blockvis:", 0, mlp.getAlignBlock());
gdi.dropLine(-0.2);
gdi.addInput("BlockSize", itos(mlp.getBlockWidth()), 5, 0, "", "Blockbredd");
gdi.addInput("BlockSize", itow(mlp.getBlockWidth()), 5, 0, L"", L"Blockbredd");
gdi.dropLine(2.1);
gdi.popX();
gdi.fillRight();
@ -871,9 +875,9 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.dropLine(-0.2);
gdi.setCX(gdi.getCX() + gdi.getLineHeight() * 5);
if (storedType == lResultModuleNumber || storedType == lResultModuleTime || storedType == lResultModuleTimeTeam || storedType == lResultModuleNumberTeam)
gdi.addInput("Leg", leg>=0 ? itos(leg) : "0", 4);
gdi.addInput("Leg", leg>=0 ? itow(leg) : L"0", 4);
else
gdi.addInput("Leg", leg>=0 ? itos(leg + 1) : "", 4);
gdi.addInput("Leg", leg>=0 ? itow(leg + 1) : L"", 4);
if (storedType == lResultModuleNumber || storedType == lResultModuleTime || storedType == lResultModuleTimeTeam || storedType == lResultModuleNumberTeam) {
gdi.check("UseLeg", true);
@ -897,13 +901,13 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.addString("", 1, "Formateringsregler");
gdi.dropLine(0.5);
gdi.fillRight();
gdi.addInput("MinIndeent", itos(mlp.getMinimalIndent()), 7, 0, "Minsta intabbning:");
gdi.addInput("MinIndeent", itow(mlp.getMinimalIndent()), 7, 0, L"Minsta intabbning:");
vector< pair<string, size_t> > fonts;
vector< pair<wstring, size_t> > fonts;
int currentFont;
mlp.getFonts(fonts, currentFont);
gdi.addSelection("Fonts", 150, 500, 0, "Format:");
gdi.addSelection("Fonts", 150, 500, 0, L"Format:");
gdi.addItem("Fonts", fonts);
gdi.selectItemByData("Fonts", currentFont);
int maxX = gdi.getCX();
@ -911,7 +915,7 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.popX();
gdi.dropLine(3);
gdi.addSelection("TextAdjust", 150, 100, 0, "Textjustering:");
gdi.addSelection("TextAdjust", 150, 100, 0, L"Textjustering:");
gdi.addItem("TextAdjust", lang.tl("Vänster"), 0);
gdi.addItem("TextAdjust", lang.tl("Höger"), textRight);
gdi.addItem("TextAdjust", lang.tl("Centrera"), textCenter);
@ -954,13 +958,13 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.refresh();
}
const char *ListEditor::getIndexDescription(EPostType type) {
const wchar_t *ListEditor::getIndexDescription(EPostType type) {
if (type == lResultModuleTime || type == lResultModuleTimeTeam)
return "Index in X[index]#OutputTimes";
return L"Index in X[index]#OutputTimes";
else if (type == lResultModuleNumber || type == lResultModuleNumberTeam)
return "Index in X[index]#OutputNumbers";
return L"Index in X[index]#OutputNumbers";
else
return "Applicera för specifik sträcka:";
return L"Applicera för specifik sträcka:";
}
void ListEditor::editListProp(gdioutput &gdi, bool newList) {
@ -993,39 +997,39 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.fillRight();
gdi.pushX();
gdi.addInput("Name", list.getListName(), 20, 0, "Listnamn:");
gdi.addInput("Name", list.getListName(), 20, 0, L"Listnamn:");
if (newList) {
gdi.dropLine(3.5);
gdi.popX();
}
vector< pair<string, size_t> > types;
vector< pair<wstring, size_t> > types;
int currentType = 0;
int maxX = gdi.getCX();
list.getBaseType(types, currentType);
gdi.addSelection("BaseType", 150, 400, 0, "Listtyp:");
gdi.addSelection("BaseType", 150, 400, 0, L"Listtyp:");
gdi.addItem("BaseType", types);
gdi.selectItemByData("BaseType", currentType);
gdi.autoGrow("BaseType");
list.getResultModule(*oe, types, currentType);
gdi.addSelection("ResultType", 150, 400, editListCB, "Resultatuträkning:");
gdi.addSelection("ResultType", 150, 400, editListCB, L"Resultatuträkning:");
gdi.addItem("ResultType", types);
gdi.autoGrow("ResultType");
gdi.selectItemByData("ResultType", currentType);
list.getSortOrder(false, types, currentType);
gdi.addSelection("SortOrder", 170, 400, 0, "Global sorteringsordning:");
gdi.addSelection("SortOrder", 170, 400, 0, L"Global sorteringsordning:");
gdi.addItem("SortOrder", types);
gdi.autoGrow("SortOrder");
gdi.selectItemByData("SortOrder", currentType);
list.getSubType(types, currentType);
gdi.addSelection("SubType", 150, 400, editListCB, "Sekundär typ:");
gdi.addSelection("SubType", 150, 400, editListCB, L"Sekundär typ:");
gdi.addItem("SubType", types);
gdi.selectItemByData("SubType", currentType);
oListInfo::EBaseType subType = oListInfo::EBaseType(currentType);
@ -1043,7 +1047,7 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.fillDown();
gdi.addString("", 1, "Filter");
gdi.dropLine(0.5);
vector< pair<string, bool> > filters;
vector< pair<wstring, bool> > filters;
list.getFilters(filters);
gdi.fillRight();
int xp = gdi.getCX();
@ -1065,7 +1069,7 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.fillDown();
gdi.addString("", 1, "Underfilter");
gdi.dropLine(0.5);
vector< pair<string, bool> > subfilters;
vector< pair<wstring, bool> > subfilters;
list.getSubFilters(subfilters);
gdi.fillRight();
xp = gdi.getCX();
@ -1091,8 +1095,8 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.addString("", 1, "Typsnitt");
gdi.dropLine(0.5);
gdi.fillRight();
const char *expl[4] = {"Rubrik", "Underrubrik", "Lista", "Underlista"};
vector< pair<string, size_t> > fonts;
const wchar_t *expl[4] = {L"Rubrik", L"Underrubrik", L"Lista", L"Underlista"};
vector< pair<wstring, size_t> > fonts;
gdi.getEnumeratedFonts(fonts);
sort(fonts.begin(), fonts.end());
@ -1104,10 +1108,10 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.setText(id, list.getFontFace(k));
gdi.setCX(gdi.getCX()+20);
int f = list.getFontFaceFactor(k);
string ff = f == 0 ? "100 %" : itos(f) + " %";
gdi.addInput("FontFactor" + itos(k), ff, 4, 0, "Skalfaktor", "Relativ skalfaktor för typsnittets storlek i procent");
wstring ff = f == 0 ? L"100 %" : itow(f) + L" %";
gdi.addInput("FontFactor" + itos(k), ff, 4, 0, L"Skalfaktor", L"Relativ skalfaktor för typsnittets storlek i procent");
f = list.getExtraSpace(k);
gdi.addInput("ExtraSpace" + itos(k), itos(f), 4, 0, "Avstånd", "Extra avstånd ovanför textblock");
gdi.addInput("ExtraSpace" + itos(k), itow(f), 4, 0, L"Avstånd", L"Extra avstånd ovanför textblock");
if (k == 1) {
gdi.dropLine(3);
gdi.popX();
@ -1172,7 +1176,7 @@ void ListEditor::makeDirty(gdioutput &gdi, DirtyFlag inside, DirtyFlag outside)
bool ListEditor::checkSave(gdioutput &gdi) {
if (dirtyInt || dirtyExt) {
gdioutput::AskAnswer answer = gdi.askCancel("Vill du spara ändringar?");
gdioutput::AskAnswer answer = gdi.askCancel(L"Vill du spara ändringar?");
if (answer == gdioutput::AnswerCancel)
return false;

View File

@ -39,11 +39,11 @@ private:
MetaList *currentList;
void setCurrentList(MetaList *lst);
int currentIndex;
string savedFileName;
wstring savedFileName;
bool dirtyExt;
bool dirtyInt;
SaveType lastSaved;
const char *getIndexDescription(EPostType type);
const wchar_t *getIndexDescription(EPostType type);
void showLine(gdioutput &gdi, const vector<MetaListPost> &line, int ix) const;
int editList(gdioutput &gdi, int type, BaseInfo &data);

View File

@ -32,13 +32,13 @@
#include "liveresult.h"
LiveResult::LiveResult(oEvent *oe) : oe(oe), active(false), lastTime(0), rToWatch(0) {
baseFont = oe->getPropertyString("LiveResultFont", "Consolas");
baseFont = oe->getPropertyString("LiveResultFont", L"Consolas");
showResultList = -1;
timerScale = 1.0;
}
string LiveResult::getFont(const gdioutput &gdi, double relScale) const {
wstring LiveResult::getFont(const gdioutput &gdi, double relScale) const {
int h,w;
gdi.getTargetDimension(w, h);
if (!gdi.isFullScreen())
@ -47,9 +47,9 @@ string LiveResult::getFont(const gdioutput &gdi, double relScale) const {
double fact = min(h/180.0, w/300.0);
double size = relScale * fact;
char ss[32];
sprintf_s(ss, "%f", size);
string font = baseFont + ";" + ss;
wchar_t ss[32];
swprintf_s(ss, L"%f", size);
wstring font = baseFont + L";" + ss;
return font;
}
@ -65,11 +65,11 @@ void LiveResult::showDefaultView(gdioutput &gdi) {
rc.right = w - 30;
rc.bottom = h - 22;
string font = getFont(gdi, 1.0);
wstring font = getFont(gdi, 1.0);
gdi.addRectangle(rc, colorLightYellow, true);
gdi.addString("timing", 50, w / 2, textCenter|boldHuge, "MeOS Timing", 0, 0, font.c_str());
gdi.addString("timing", 50, w / 2, textCenter|boldHuge, L"MeOS Timing", 0, 0, font.c_str());
TextInfo &ti = gdi.addString("measure", 0, 0, boldHuge, "55:55:55", 0, 0, font.c_str());
TextInfo &ti = gdi.addString("measure", 0, 0, boldHuge, L"55:55:55", 0, 0, font.c_str());
int tw = ti.textRect.right - ti.textRect.left;
timerScale = double(w) * 0.8 / double(tw);
gdi.removeString("measure");
@ -234,19 +234,19 @@ void LiveResult::handle(gdioutput &gdi, BaseInfo &bu, GuiEventType type) {
startFinishTime[newRToWatch->getId()].first = fp->getAdjustedTime();
isDuel = false;
if (rToWatch.size() == 1) {
string font = getFont(gdi, timerScale);
wstring font = getFont(gdi, timerScale);
BaseInfo *bi = gdi.setText("timing", newRToWatch->getName(), false);
dynamic_cast<TextInfo &>(*bi).changeFont(getFont(gdi, 0.7));
gdi.addTimer(h/2, w/2, boldHuge|textCenter|timeWithTenth, 0, 0, 0, NOTIMEOUT, font.c_str());
screenSize = 1;
}
else if (rToWatch.size() == 2) {
string font = getFont(gdi, timerScale * 0.6);
wstring font = getFont(gdi, timerScale * 0.6);
pRunner r0 = oe->getRunner(rToWatch[0], 0);
pRunner r1 = oe->getRunner(rToWatch[1], 0);
string n = (r0 ? r0->getName(): "-") + " / " + (r1 ? r1->getName() : "-");
wstring n = (r0 ? r0->getName(): L"-") + L" / " + (r1 ? r1->getName() : L"-");
bool duel = r0 && r1 && fromPunch == oPunch::PunchStart &&
r0->getTeam() != 0 &&
r0->getTeam() == r1->getTeam();
@ -257,13 +257,13 @@ void LiveResult::handle(gdioutput &gdi, BaseInfo &bu, GuiEventType type) {
ti.changeFont(getFont(gdi, 0.5));
}
else {
BaseInfo *bi = gdi.setText("timing", "", false);
BaseInfo *bi = gdi.setText("timing", L"", false);
TextInfo &ti = dynamic_cast<TextInfo &>(*bi);
string sfont = getFont(gdi, 0.5);
wstring sfont = getFont(gdi, 0.5);
TextInfo &ti2 = gdi.addString("n1", ti.yp, gdi.scaleLength(20), boldHuge,
"#" + (r0 ? r0->getName() : string("")), 0, 0, sfont.c_str());
L"#" + (r0 ? r0->getName() : wstring(L"")), 0, 0, sfont.c_str());
gdi.addString("n2", ti.yp + ti2.getHeight() + 4, gdi.getWidth(), boldHuge | textRight,
"#" + (r1 ? r1->getName() : string("")), 0, 0, sfont.c_str());
L"#" + (r1 ? r1->getName() : wstring(L"")), 0, 0, sfont.c_str());
}
int id1 = rToWatch[0];
int id2 = rToWatch[1];
@ -312,14 +312,14 @@ void LiveResult::handle(gdioutput &gdi, BaseInfo &bu, GuiEventType type) {
if (screenSize == 1) {
gdi.restore("LiveResult", false);
string font = getFont(gdi, timerScale);
gdi.addString("", h/2, w/2, boldHuge|textCenter, formatTime(rt), 0, 0, font.c_str()).setColor(colorGreen);
wstring font = getFont(gdi, timerScale);
gdi.addString("", h/2, w/2, boldHuge|textCenter, formatTimeW(rt), 0, 0, font.c_str()).setColor(colorGreen);
gdi.addTimeout(5, 0).setHandler(this);
}
else if (screenSize == 2) {
string id = "timer" + itos(runner2ScreenPos[rToFinish->getId()]);
BaseInfo *bi = gdi.setText(id, formatTime(rt), false);
string font = getFont(gdi, timerScale * 0.6);
BaseInfo *bi = gdi.setText(id, formatTimeW(rt), false);
wstring font = getFont(gdi, timerScale * 0.6);
if (bi) {
TextInfo &ti = dynamic_cast<TextInfo &>(*bi);
@ -359,7 +359,7 @@ void LiveResult::handle(gdioutput &gdi, BaseInfo &bu, GuiEventType type) {
int h,w;
gdi.getTargetDimension(w, h);
gdi.fillDown();
BaseInfo *bi = gdi.setTextTranslate("timing", "MeOS Timing", false);
BaseInfo *bi = gdi.setTextTranslate("timing", L"MeOS Timing", false);
TextInfo &ti = dynamic_cast<TextInfo &>(*bi);
ti.changeFont(getFont(gdi, 0.7));
gdi.refreshFast();
@ -372,7 +372,7 @@ void LiveResult::handle(gdioutput &gdi, BaseInfo &bu, GuiEventType type) {
if (size_t(showResultList) >= results.size())
return;
Result &res = results[showResultList];
string font = getFont(gdi, 0.7);
wstring font = getFont(gdi, 0.7);
int y = resYPos;
pRunner r = oe->getRunner(res.runnerId, 0);
if (!r) {
@ -384,11 +384,11 @@ void LiveResult::handle(gdioutput &gdi, BaseInfo &bu, GuiEventType type) {
gdi.getTargetDimension(w, h);
gdi.takeShownStringsSnapshot();
TextInfo &ti = gdi.addStringUT(y, 30, fontLarge, itos(res.place) + ".", 0, 0, font.c_str());
TextInfo &ti = gdi.addStringUT(y, 30, fontLarge, itow(res.place) + L".", 0, 0, font.c_str());
int ht = ti.textRect.bottom - ti.textRect.top;
gdi.addStringUT(y, 30 + ht * 2 , fontLarge, r->getName(), 0, 0, font.c_str());
//int w = gdi.getWidth();
gdi.addStringUT(y, w - 4 * ht, fontLarge, formatTime(res.time), 0, 0, font.c_str());
gdi.addStringUT(y, w - 4 * ht, fontLarge, formatTimeW(res.time), 0, 0, font.c_str());
gdi.refreshSmartFromSnapshot(false);
resYPos += int (ht * 1.1);
showResultList++;

View File

@ -38,12 +38,12 @@ class LiveResult : public GuiHandler {
int screenSize;
bool isDuel;
string baseFont;
wstring baseFont;
void showDefaultView(gdioutput &gdi);
map<int, pair<int, int> > startFinishTime;
int showResultList;
int resYPos;
string getFont(const gdioutput &gdi, double relScale) const;
wstring getFont(const gdioutput &gdi, double relScale) const;
double timerScale;
struct Result {
int place;

View File

@ -21,19 +21,37 @@
************************************************************************/
#include "stdafx.h"
#include "localizer.h"
#include <fstream>
#include <vector>
#include "meos_util.h"
#include "random.h"
#include "oFreeImport.h"
#include "meos_util.h"
const string &toUTF8(const wstring &winput) {
string &output = StringCache::getInstance().get();
size_t alloc = winput.length()*2;
output.resize(alloc);
WideCharToMultiByte(CP_UTF8, 0, winput.c_str(), winput.length()+1, (char *)output.c_str(), alloc, 0, 0);
output.resize(strlen(output.c_str()));
return output;
}
const wstring &fromUTF(const string &input) {
wstring &output = StringCache::getInstance().wget();
output.resize(input.length()+2, 0);
int res = MultiByteToWideChar(CP_UTF8, 0, input.c_str(), -1, &output[0], output.size() * sizeof(wchar_t));
output.resize(res-1);
return output;
}
class LocalizerImpl
{
string language;
map<string, string> table;
map<string, string> unknown;
void loadTable(const vector<string> &raw, const string &language);
wstring language;
map<wstring, wstring> table;
map<wstring, wstring> unknown;
void loadTable(const vector<string> &raw, const wstring &language);
mutable oWordList *givenNames;
public:
@ -42,12 +60,12 @@ public:
void translateAll(const LocalizerImpl &all);
const string &translate(const string &str, bool &found);
const wstring &translate(const wstring &str, bool &found);
void saveUnknown(const string &file);
void saveTable(const string &file);
void loadTable(const string &file, const string &language);
void loadTable(int resource, const string &language);
void saveUnknown(const wstring &file);
void saveTable(const wstring &file);
void loadTable(const wstring &file, const wstring &language);
void loadTable(int resource, const wstring &language);
void clear();
LocalizerImpl(void);
@ -90,9 +108,9 @@ void Localizer::LocalizerInternal::set(Localizer &lio) {
li.user = this;
}
vector<string> Localizer::LocalizerInternal::getLangResource() const {
vector<string> v;
for (map<string, string>::const_iterator it = langResource.begin(); it !=langResource.end(); ++it)
vector<wstring> Localizer::LocalizerInternal::getLangResource() const {
vector<wstring> v;
for (map<wstring, wstring>::const_iterator it = langResource.begin(); it !=langResource.end(); ++it)
v.push_back(it->first);
return v;
@ -113,9 +131,9 @@ LocalizerImpl::~LocalizerImpl(void)
delete givenNames;
}
const string &Localizer::LocalizerInternal::tl(const string &str) const {
const wstring &Localizer::LocalizerInternal::tl(const wstring &str) const {
bool found;
const string *ret = &impl->translate(str, found);
const wstring *ret = &impl->translate(str, found);
if (found || !implBase)
return *ret;
@ -123,16 +141,16 @@ const string &Localizer::LocalizerInternal::tl(const string &str) const {
return *ret;
}
const string &LocalizerImpl::translate(const string &str, bool &found)
const wstring &LocalizerImpl::translate(const wstring &str, bool &found)
{
found = false;
static int i = 0;
const int bsize = 17;
static string value[bsize];
static wstring value[bsize];
int len = str.length();
if (len==0)
return str;
return _EmptyWString;
if (str[0]=='#') {
i = (i + 1)%bsize;
@ -149,14 +167,14 @@ const string &LocalizerImpl::translate(const string &str, bool &found)
k++;
if (k<str.length()) {
string sub = str.substr(k);
wstring sub = str.substr(k);
i = (i + 1)%bsize;
value[i] = str.substr(0, k) + translate(sub, found);
return value[i];
}
}
map<string, string>::const_iterator it = table.find(str);
map<wstring, wstring>::const_iterator it = table.find(str);
if (it != table.end()) {
found = true;
return it->second;
@ -164,13 +182,13 @@ const string &LocalizerImpl::translate(const string &str, bool &found)
int subst = str.find_first_of('#');
if (subst != str.npos) {
string s = translate(str.substr(0, subst), found);
vector<string> split_vec;
split(str.substr(subst+1), "#", split_vec);
split_vec.push_back("");
const char *subsymb = "XYZW";
wstring s = translate(str.substr(0, subst), found);
vector<wstring> split_vec;
split(str.substr(subst+1), L"#", split_vec);
split_vec.push_back(L"");
const wchar_t *subsymb = L"XYZW";
size_t subpos = 0;
string ret;
wstring ret;
size_t lastpos = 0;
for (size_t k = 0; k<s.size(); k++) {
if (subpos>=split_vec.size() || subpos>=4)
@ -195,12 +213,12 @@ const string &LocalizerImpl::translate(const string &str, bool &found)
}
char last = str[len-1];
wchar_t last = str[len-1];
if (last != ':' && last != '.' && last != ' ' && last != ',' &&
last != ';' && last != '<' && last != '>' && last != '-' && last != 0x96) {
#ifdef _DEBUG
if (str.length()>1)
unknown[str] = "";
unknown[str] = L"";
#endif
found = false;
i = (i + 1)%bsize;
@ -208,11 +226,11 @@ const string &LocalizerImpl::translate(const string &str, bool &found)
return value[i];
}
string suffix;
wstring suffix;
int pos = str.find_last_not_of(last);
while(pos>0) {
char last = str[pos];
wchar_t last = str[pos];
if (last != ':' && last != ' ' && last != ',' && last != '.' &&
last != ';' && last != '<' && last != '>' && last != '-' && last != 0x96)
break;
@ -222,7 +240,7 @@ const string &LocalizerImpl::translate(const string &str, bool &found)
suffix = str.substr(pos+1);
string key = str.substr(0, str.length()-suffix.length());
wstring key = str.substr(0, str.length()-suffix.length());
it = table.find(key);
if (it != table.end()) {
i = (i + 1)%bsize;
@ -232,7 +250,7 @@ const string &LocalizerImpl::translate(const string &str, bool &found)
}
#ifdef _DEBUG
if (key.length() > 1)
unknown[key] = "";
unknown[key] = L"";
#endif
found = false;
@ -240,30 +258,30 @@ const string &LocalizerImpl::translate(const string &str, bool &found)
value[i] = str;
return value[i];
}
const string newline = "\n";
const wstring newline = L"\n";
void LocalizerImpl::saveUnknown(const string &file)
void LocalizerImpl::saveUnknown(const wstring &file)
{
if (!unknown.empty()) {
ofstream fout(file.c_str(), ios::trunc|ios::out);
for (map<string, string>::iterator it = unknown.begin(); it!=unknown.end(); ++it) {
string value = it->second;
string key = it->first;
for (map<wstring, wstring>::iterator it = unknown.begin(); it!=unknown.end(); ++it) {
wstring value = it->second;
wstring key = it->first;
if (value.empty()) {
value = key;
int nl = value.find(newline);
int n2 = value.find(".");
int n2 = value.find(L".");
if (nl!=string::npos || n2!=string::npos) {
while (nl!=string::npos) {
value.replace(nl, newline.length(), "\\n");
value.replace(nl, newline.length(), L"\\n");
nl = value.find(newline);
}
key = "help:" + itos(value.length()) + itos(value.find_first_of("."));
key = L"help:" + itow(value.length()) + itow(value.find_first_of('.'));
}
}
fout << key << " = " << value << endl;
fout << toUTF8(key) << " = " << toUTF8(value) << endl;
}
}
}
@ -271,8 +289,8 @@ void LocalizerImpl::saveUnknown(const string &file)
const oWordList &LocalizerImpl::getGivenNames() const {
if (givenNames == 0) {
char bf[260];
getUserFile(bf, "given.mwd");
wchar_t bf[260];
getUserFile(bf, L"wgiven.mwd");
givenNames = new oWordList();
try {
givenNames->load(bf);
@ -283,29 +301,29 @@ const oWordList &LocalizerImpl::getGivenNames() const {
#ifndef MEOSDB
void Localizer::LocalizerInternal::loadLangResource(const string &name) {
map<string,string>::iterator it = langResource.find(name);
void Localizer::LocalizerInternal::loadLangResource(const wstring &name) {
map<wstring,wstring>::iterator it = langResource.find(name);
if (it == langResource.end())
throw std::exception("Unknown language");
string &res = it->second;
wstring &res = it->second;
int i = atoi(res.c_str());
int i = _wtoi(res.c_str());
if (i > 0)
impl->loadTable(i, name);
else
impl->loadTable(res, name);
}
void Localizer::LocalizerInternal::addLangResource(const string &name, const string &resource) {
void Localizer::LocalizerInternal::addLangResource(const wstring &name, const wstring &resource) {
langResource[name] = resource;
if (implBase == 0) {
implBase = new LocalizerImpl();
implBase->loadTable(atoi(resource.c_str()), name);
implBase->loadTable(_wtoi(resource.c_str()), name);
}
}
void Localizer::LocalizerInternal::debugDump(const string &untranslated, const string &translated) const {
void Localizer::LocalizerInternal::debugDump(const wstring &untranslated, const wstring &translated) const {
if (implBase) {
impl->translateAll(*implBase);
}
@ -314,7 +332,7 @@ void Localizer::LocalizerInternal::debugDump(const string &untranslated, const s
}
void LocalizerImpl::translateAll(const LocalizerImpl &all) {
map<string, string>::const_iterator it;
map<wstring, wstring>::const_iterator it;
bool f;
for (it = all.table.begin(); it != all.table.end(); ++it) {
translate(it->first, f);
@ -324,25 +342,25 @@ void LocalizerImpl::translateAll(const LocalizerImpl &all) {
}
}
void LocalizerImpl::saveTable(const string &file)
void LocalizerImpl::saveTable(const wstring &file)
{
ofstream fout((language+"_"+file).c_str(), ios::trunc|ios::out);
for (map<string, string>::iterator it = table.begin(); it!=table.end(); ++it) {
string value = it->second;
ofstream fout(language+L"_"+file, ios::trunc|ios::out);
for (map<wstring, wstring>::iterator it = table.begin(); it!=table.end(); ++it) {
wstring value = it->second;
int nl = value.find(newline);
while (nl!=string::npos) {
value.replace(nl, newline.length(), "\\n");
value.replace(nl, newline.length(), L"\\n");
nl = value.find(newline);
}
fout << it->first << " = " << value << endl;
fout << toUTF8(it->first) << " = " << toUTF8(value) << endl;
}
}
void LocalizerImpl::loadTable(int id, const string &language)
void LocalizerImpl::loadTable(int id, const wstring &language)
{
string sname = "#"+itos(id);
const char *name = sname.c_str();
HRSRC hResInfo = FindResource(0, name, "#300");
wstring sname = L"#"+itow(id);
const wchar_t *name = sname.c_str();
HRSRC hResInfo = FindResource(0, name, L"#300");
HGLOBAL hGlobal = LoadResource(0, hResInfo);
if (hGlobal==0)
@ -375,7 +393,7 @@ void LocalizerImpl::loadTable(int id, const string &language)
loadTable(raw, language);
}
void LocalizerImpl::loadTable(const string &file, const string &language)
void LocalizerImpl::loadTable(const wstring &file, const wstring &language)
{
clear();
ifstream fin(file.c_str(), ios::in);
@ -407,7 +425,7 @@ void LocalizerImpl::loadTable(const string &file, const string &language)
}
void LocalizerImpl::loadTable(const vector<string> &raw, const string &language)
void LocalizerImpl::loadTable(const vector<string> &raw, const wstring &language)
{
vector<int> order(raw.size());
for (size_t k = 0; k<raw.size(); k++)
@ -418,6 +436,7 @@ void LocalizerImpl::loadTable(const vector<string> &raw, const string &language)
table.clear();
this->language = language;
string nline = "\n";
for (size_t k=0;k<raw.size();k++) {
const string &s = raw[order[k]];
int pos = s.find_first_of('=');
@ -437,11 +456,26 @@ void LocalizerImpl::loadTable(const vector<string> &raw, const string &language)
int nl = value.find("\\n");
while (nl!=string::npos) {
value.replace(nl, 2, newline);
value.replace(nl, 2, nline);
nl = value.find("\\n");
}
table[key] = value;
static int translate = 0;
if (translate) {
wstring output, okey;
output.reserve(value.size()+1);
output.resize(value.size(), 0);
MultiByteToWideChar(1251, MB_PRECOMPOSED, value.c_str(), value.size(), &output[0], output.size() * sizeof(wchar_t));
okey.reserve(key.size()+1);
okey.resize(key.size(), 0);
MultiByteToWideChar(1252, MB_PRECOMPOSED, key.c_str(), key.size(), &okey[0], okey.size() * sizeof(wchar_t));
table[okey] = output;
}
else
table[fromUTF(key)] = fromUTF(value);
}
}
@ -455,6 +489,15 @@ void LocalizerImpl::clear()
}
bool Localizer::capitalizeWords() const {
return tl("Lyssna") == "Listen";
return tl("Lyssna") == L"Listen";
}
const wstring &Localizer::tl(const string &str) const {
if (str.length() == 0)
return _EmptyWString;
wstring key(str.begin(), str.end());
for (size_t k = 0; k < key.size(); k++) {
key[k] = 0xFF&key[k];
}
return linternal->tl(key);
}

View File

@ -31,7 +31,7 @@ class oWordList;
class Localizer {
class LocalizerInternal {
private:
map<string, string> langResource;
map<wstring, wstring> langResource;
LocalizerImpl *impl;
LocalizerImpl *implBase;
@ -40,14 +40,14 @@ class Localizer {
public:
void debugDump(const string &untranslated, const string &translated) const;
void debugDump(const wstring &untranslated, const wstring &translated) const;
vector<string> getLangResource() const;
void loadLangResource(const string &name);
void addLangResource(const string &name, const string &resource);
vector<wstring> getLangResource() const;
void loadLangResource(const wstring &name);
void addLangResource(const wstring &name, const wstring &resource);
/** Translate string */
const string &tl(const string &str) const;
const wstring &tl(const wstring &str) const;
void set(Localizer &li);
@ -64,7 +64,9 @@ public:
bool capitalizeWords() const;
LocalizerInternal &get() {return *linternal;}
const string &tl(const string &str) const {return linternal->tl(str);};
const wstring &tl(const string &str) const;
const wstring &tl(const wstring &str) const {return linternal->tl(str);}
//const wstring &tlw(const wstring &str) const;
void init() {linternal = new LocalizerInternal();}
void unload() {delete linternal; linternal = 0;}

View File

@ -64,6 +64,8 @@
#include "meosexception.h"
#include "parser.h"
#include "restbed/restbed"
gdioutput *gdi_main=0;
oEvent *gEvent=0;
SportIdent *gSI=0;
@ -90,7 +92,7 @@ void Setup(bool overwrite, bool overwriteAll);
// Global Variables:
HINSTANCE hInst; // current instance
CHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
TCHAR szWorkSpaceClass[MAX_LOADSTRING]; // The title bar text
@ -102,7 +104,7 @@ LRESULT CALLBACK WorkSpaceWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
void registerToolbar(HINSTANCE hInstance);
extern const char *szToolClass;
extern const wchar_t *szToolClass;
HHOOK g_hhk; //- handle to the hook procedure.
@ -145,9 +147,9 @@ void LoadPage(gdioutput &gdi, TabType type) {
}
// Path to settings file
static char settings[260];
static wchar_t settings[260];
// Startup path
static char programPath[MAX_PATH];
static wchar_t programPath[MAX_PATH];
void mainMessageLoop(HACCEL hAccelTable, DWORD time) {
MSG msg;
@ -172,13 +174,41 @@ void mainMessageLoop(HACCEL hAccelTable, DWORD time) {
}
}
void post_method_handler(const shared_ptr< restbed::Session > session)
{
using namespace restbed;
const auto request = session->get_request();
size_t content_length = request->get_header("Content-Length", 0);
session->fetch(content_length, [request](const shared_ptr< Session > session, const Bytes & body)
{
fprintf(stdout, "%.*s\n", (int)body.size(), body.data());
session->close(restbed::OK, "Hello, World!", { { "Content-Length", "13" },{ "Connection", "close" } });
});
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
atexit(dumpLeaks); //
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
/*{
using namespace restbed;
auto resource = make_shared< Resource >();
resource->set_path("/resource");
resource->set_method_handler("GET", post_method_handler);
Service service;
auto settings = make_shared< Settings >();
settings->set_port(1984);
service.publish(resource);
service.start(settings);
}*/
if (strstr(lpCmdLine, "-s") != 0) {
Setup(true, false);
@ -188,7 +218,6 @@ int APIENTRY WinMain(HINSTANCE hInstance,
enableTests = true;
}
for (int k = 0; k < 100; k++) {
RunnerStatusOrderMap[k] = 0;
}
@ -206,8 +235,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
GetCurrentDirectory(MAX_PATH, programPath);
getUserFile(settings, "meospref.xml");
getUserFile(settings, L"meoswpref.xml");
Parser::test();
int rInit = (GetTickCount() / 100);
@ -217,45 +245,57 @@ int APIENTRY WinMain(HINSTANCE hInstance,
HACCEL hAccelTable;
gdi_main = new gdioutput("main", 1.0, ANSI);
gdi_main = new gdioutput("main", 1.0, 0);
gdi_extra.push_back(gdi_main);
try {
gEvent = new oEvent(*gdi_main);
}
catch (meosException &ex) {
gdi_main->alert(wstring(L"Failed to create base event: ") + ex.wwhat());
return 0;
}
catch (std::exception &ex) {
gdi_main->alert(string("Failed to create base event: ") + ex.what());
return 0;
}
gEvent->loadProperties(settings);
lang.get().addLangResource("English", "104");
lang.get().addLangResource("Svenska", "103");
lang.get().addLangResource("Deutsch", "105");
lang.get().addLangResource("Dansk", "106");
lang.get().addLangResource("Français", "110");
lang.get().addLangResource("Russian (ISO 8859-5)", "107");
lang.get().addLangResource("English (ISO 8859-2)", "108");
lang.get().addLangResource("English (ISO 8859-8)", "109");
if (fileExist("extra.lng")) {
lang.get().addLangResource("Extraspråk", "extra.lng");
if (fileExist(settings)) {
gEvent->loadProperties(settings);
}
else {
char lpath[260];
getUserFile(lpath, "extra.lng");
if (fileExist(lpath))
lang.get().addLangResource("Extraspråk", lpath);
wchar_t oldSettings[260];
// Read from older version
getUserFile(oldSettings, L"meospref.xml");
gEvent->loadProperties(oldSettings);
}
string defLang = gEvent->getPropertyString("Language", "Svenska");
lang.get().addLangResource(L"English", L"104");
lang.get().addLangResource(L"Svenska", L"103");
lang.get().addLangResource(L"Deutsch", L"105");
lang.get().addLangResource(L"Dansk", L"106");
lang.get().addLangResource(L"Français", L"110");
lang.get().addLangResource(L"Russian (ISO 8859-5)", L"107");
lang.get().addLangResource(L"English (ISO 8859-2)", L"108");
lang.get().addLangResource(L"English (ISO 8859-8)", L"109");
if (fileExist(L"extra.lng")) {
lang.get().addLangResource(L"Extraspråk", L"extra.lng");
}
else {
wchar_t lpath[260];
getUserFile(lpath, L"extra.lng");
if (fileExist(lpath))
lang.get().addLangResource(L"Extraspråk", lpath);
}
wstring defLang = gEvent->getPropertyString("Language", L"Svenska");
// Backward compatibility
if (defLang=="103")
defLang = "Svenska";
else if (defLang=="104")
defLang = "English";
if (defLang==L"103")
defLang = L"Svenska";
else if (defLang==L"104")
defLang = L"English";
gEvent->setProperty("Language", defLang);
@ -263,58 +303,78 @@ int APIENTRY WinMain(HINSTANCE hInstance,
lang.get().loadLangResource(defLang);
}
catch (std::exception &) {
lang.get().loadLangResource("Svenska");
lang.get().loadLangResource(L"Svenska");
}
try {
char listpath[MAX_PATH];
getUserFile(listpath, "");
vector<string> res;
expandDirectory(listpath, "*.lxml", res);
expandDirectory(listpath, "*.listdef", res);
wchar_t listpath[MAX_PATH];
getUserFile(listpath, L"");
vector<wstring> res;
expandDirectory(listpath, L"*.lxml", res);
expandDirectory(listpath, L"*.listdef", res);
#
#ifdef _DEBUG
expandDirectory(".\\Lists\\", "*.lxml", res);
expandDirectory(".\\Lists\\", "*.listdef", res);
expandDirectory(L".\\Lists\\", L"*.lxml", res);
expandDirectory(L".\\Lists\\", L"*.listdef", res);
#endif
string err;
wstring err;
for (size_t k = 0; k<res.size(); k++) {
try {
xmlparser xml(0);
xmlparser xml;
strcpy_s(listpath, res[k].c_str());
wcscpy_s(listpath, res[k].c_str());
xml.read(listpath);
xmlobject xlist = xml.getObject(0);
gEvent->getListContainer().load(MetaListContainer::InternalList, xlist, true);
}
catch (std::exception &ex) {
string errLoc = "Kunde inte ladda X\n\n(Y)#" + string(listpath) + "#" + lang.tl(ex.what());
catch (meosException &ex) {
wstring errLoc = L"Kunde inte ladda X\n\n(Y)#" + wstring(listpath) + L"#" + lang.tl(ex.wwhat());
if (err.empty())
err = lang.tl(errLoc);
else
err += "\n" + lang.tl(errLoc);
err += L"\n" + lang.tl(errLoc);
}
catch (std::exception &ex) {
wstring errLoc = L"Kunde inte ladda X\n\n(Y)#" + wstring(listpath) + L"#" + lang.tl(ex.what());
if (err.empty())
err = lang.tl(errLoc);
else
err += L"\n" + lang.tl(errLoc);
}
}
if (!err.empty())
gdi_main->alert(err);
}
catch (meosException &ex) {
gdi_main->alert(ex.wwhat());
}
catch (std::exception &ex) {
gdi_main->alert(ex.what());
//exit(1);
}
gEvent->openRunnerDatabase("database");
strcpy_s(szTitle, "MeOS");
strcpy_s(szWindowClass, "MeosMainClass");
strcpy_s(szWorkSpaceClass, "MeosWorkSpace");
gEvent->openRunnerDatabase(L"database");
wcscpy_s(szTitle, L"MeOS");
wcscpy_s(szWindowClass, L"MeosMainClass");
wcscpy_s(szWorkSpaceClass, L"MeosWorkSpace");
MyRegisterClass(hInstance);
registerToolbar(hInstance);
string encoding = lang.tl("encoding");
string encoding = gdi_main->narrow(lang.tl("encoding"));
/*FontEncoding interpetEncoding(const string &enc) {
if (enc == "RUSSIAN")
return Russian;
else if (enc == "EASTEUROPE")
return EastEurope;
else if (enc == "HEBREW")
return Hebrew;
else
return ANSI;
}*/
gdi_main->setFont(gEvent->getPropertyInt("TextSize", 0),
gEvent->getPropertyString("TextFont", "Arial"), interpetEncoding(encoding));
gEvent->getPropertyString("TextFont", L"Arial"));
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow)) {
@ -342,13 +402,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
initMySQLCriticalSection(true);
// Main message loop:
mainMessageLoop(hAccelTable, 0);
/*while (GetMessage(&msg, NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
*/
tabAutoRegister(0);
tabList->clear();
delete tabList;
@ -380,7 +434,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
removeTempFiles();
#ifdef _DEBUG
lang.get().debugDump("untranslated.txt", "translated.txt");
lang.get().debugDump(L"untranslated.txt", L"translated.txt");
#endif
StringCache::getInstance().clear();
@ -670,7 +724,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
hWnd = CreateWindowEx(0, szWorkSpaceClass, "WorkSpace", WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
hWnd = CreateWindowEx(0, szWorkSpaceClass, L"WorkSpace", WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
50, 200, 200, 100, hWndMain, NULL, hInstance, NULL);
if (!hWnd)
@ -701,6 +755,15 @@ string uniqueTag(const char *base) {
}
}
vector<string> getExtraWindows() {
vector<string> res;
for (size_t k = 0; k < gdi_extra.size(); k++) {
if (gdi_extra[k])
res.push_back(gdi_extra[k]->getTag());
}
return res;
}
gdioutput *getExtraWindow(const string &tag, bool toForeGround) {
for (size_t k = 0; k<gdi_extra.size(); k++) {
if (gdi_extra[k] && gdi_extra[k]->hasTag(tag)) {
@ -712,7 +775,7 @@ gdioutput *getExtraWindow(const string &tag, bool toForeGround) {
return 0;
}
gdioutput *createExtraWindow(const string &tag, const string &title, int max_x, int max_y) {
gdioutput *createExtraWindow(const string &tag, const wstring &title, int max_x, int max_y) {
if (getExtraWindow(tag, false) != 0)
throw meosException("Window already exists");
@ -754,9 +817,9 @@ gdioutput *createExtraWindow(const string &tag, const string &title, int max_x,
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
gdioutput *gdi = new gdioutput(tag, 1.0, gdi_main->getEncoding());
gdioutput *gdi = new gdioutput(tag, 1.0, 0);
gdi->setFont(gEvent->getPropertyInt("TextSize", 0),
gEvent->getPropertyString("TextFont", "Arial"), gdi_main->getEncoding());
gEvent->getPropertyString("TextFont", L"Arial"));
gdi->init(hWnd, hWnd, 0);
gdi->isTestMode = gdi_main->isTestMode;
@ -884,7 +947,7 @@ void createTabs(bool force, bool onlyMain, bool skipTeam, bool skipSpeaker,
TCITEMW ti;
//char bf[256];
//strcpy_s(bf, lang.tl(it->name).c_str());
ti.pszText=(LPWSTR)gdi_main->toWide(lang.tl(it->name)).c_str();
ti.pszText=(LPWSTR)lang.tl(it->name).c_str();
ti.mask=TCIF_TEXT;
it->setId(id++);
@ -933,7 +996,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ic.dwSize=sizeof(ic);
ic.dwICC=ICC_TAB_CLASSES ;
InitCommonControlsEx(&ic);
hMainTab=CreateWindowEx(0, WC_TABCONTROL, "tabs", WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, 0, 0, 300, 20, hWnd, 0, hInst, 0);
hMainTab=CreateWindowEx(0, WC_TABCONTROL, L"tabs", WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, 0, 0, 300, 20, hWnd, 0, hInst, 0);
createTabs(true, true, false, false, false, false, false, false);
SetTimer(hWnd, 4, 10000, 0); //Connection check
@ -1029,6 +1092,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
it->loadPage(*gdi_main);
gdi_main->getRecorder().record(cmd);
}
catch (meosException &ex) {
gdi_main->alert(ex.wwhat());
}
catch(std::exception &ex) {
gdi_main->alert(ex.what());
}
@ -1057,12 +1123,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
//queue by different thread. Read and process this card.
{
SICard sic;
while (gSI && gSI->GetCard(sic))
while (gSI && gSI->getCard(sic))
InsertSICard(*gdi_main, sic);
break;
}
case WM_USER+1:
MessageBox(hWnd, "Kommunikationen med en SI-enhet avbröts.", "SportIdent", MB_OK);
MessageBox(hWnd, lang.tl(L"Kommunikationen med en SI-enhet avbröts.").c_str(), L"SportIdent", MB_OK);
break;
case WM_USER + 3:
@ -1097,7 +1163,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_CLOSE:
if (!gEvent || gEvent->empty() || gdi_main->ask("Vill du verkligen stänga MeOS?"))
if (!gEvent || gEvent->empty() || gdi_main->ask(L"Vill du verkligen stänga MeOS?"))
DestroyWindow(hWnd);
break;
@ -1109,15 +1175,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
try {
gEvent->save();
}
catch (meosException &ex) {
MessageBox(hWnd, lang.tl(ex.wwhat()).c_str(), L"Fel när tävlingen skulle sparas", MB_OK);
}
catch(std::exception &ex) {
MessageBox(hWnd, lang.tl(ex.what()).c_str(), "Fel när tävlingen skulle sparas", MB_OK);
MessageBox(hWnd, lang.tl(ex.what()).c_str(), L"Fel när tävlingen skulle sparas", MB_OK);
}
try {
gEvent->saveRunnerDatabase("database", true);
gEvent->saveRunnerDatabase(L"database", true);
}
catch (meosException &ex) {
MessageBox(hWnd, lang.tl(ex.wwhat()).c_str(), L"Fel när löpardatabas skulle sparas", MB_OK);
}
catch(std::exception &ex) {
MessageBox(hWnd, lang.tl(ex.what()).c_str(), "Fel när löpardatabas skulle sparas", MB_OK);
MessageBox(hWnd, lang.tl(ex.what()).c_str(), L"Fel när löpardatabas skulle sparas", MB_OK);
}
if (gEvent)
@ -1357,6 +1429,10 @@ LRESULT CALLBACK WorkSpaceWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
switch(nScrollCode)
{
case SB_ENDSCROLL:
InvalidateRect(hWnd, 0, false);
return 0;
// User clicked shaft left of the scroll box.
case SB_PAGEUP:
xInc = -80;
@ -1469,7 +1545,7 @@ LRESULT CALLBACK WorkSpaceWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
scrollVertical(gdi, dy, hWnd);
}
else
MessageBox(hWnd, "Runtime exception", 0, MB_OK);
MessageBox(hWnd, L"Runtime exception", 0, MB_OK);
break;
case WM_ACTIVATE: {
@ -1555,13 +1631,13 @@ LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
namespace setup {
const int nFiles=7;
const char *fileList[nFiles]={"baseclass.xml",
"family.mwd",
"given.mwd",
"club.mwd",
"class.mwd",
"database.clubs",
"database.persons"};
const wchar_t *fileList[nFiles]={L"baseclass.xml",
L"wfamily.mwd",
L"wgiven.mwd",
L"wclub.mwd",
L"wclass.mwd",
L"database.wclubs",
L"database.wpersons"};
}
void Setup(bool overwrite, bool overwriteAll)
@ -1571,27 +1647,27 @@ void Setup(bool overwrite, bool overwriteAll)
return;
isSetup=true; //Run at most once.
vector<pair<string, bool> > toInstall;
vector<pair<wstring, bool> > toInstall;
for(int k=0;k<setup::nFiles;k++) {
toInstall.push_back(make_pair(string(setup::fileList[k]), overwriteAll));
toInstall.push_back(make_pair(wstring(setup::fileList[k]), overwriteAll));
}
char dir[260];
wchar_t dir[260];
GetCurrentDirectory(260, dir);
vector<string> dyn;
expandDirectory(dir, "*.lxml", dyn);
expandDirectory(dir, "*.listdef", dyn);
expandDirectory(dir, "*.meos", dyn);
vector<wstring> dyn;
expandDirectory(dir, L"*.lxml", dyn);
expandDirectory(dir, L"*.listdef", dyn);
expandDirectory(dir, L"*.meos", dyn);
for (size_t k = 0; k < dyn.size(); k++)
toInstall.push_back(make_pair(dyn[k], true));
char bf[260];
wchar_t bf[260];
for(size_t k=0; k<toInstall.size(); k++) {
const string src = toInstall[k].first.c_str();
char filename[128];
char ext[32];
_splitpath_s(src.c_str(), NULL, 0, NULL,0, filename, 128, ext, 32);
string fullFile = string(filename) + ext;
const wstring src = toInstall[k].first;
wchar_t filename[128];
wchar_t ext[32];
_wsplitpath_s(src.c_str(), NULL, 0, NULL,0, filename, 128, ext, 32);
wstring fullFile = wstring(filename) + ext;
getUserFile(bf, fullFile.c_str());
bool canOverwrite = overwrite && toInstall[k].second;
@ -1601,92 +1677,92 @@ void Setup(bool overwrite, bool overwriteAll)
void exportSetup()
{
char bf[260];
wchar_t bf[260];
for(int k=0;k<setup::nFiles;k++) {
getUserFile(bf, setup::fileList[k]);
CopyFile(bf, setup::fileList[k], false);
}
}
bool getMeOSFile(char *FileNamePath, const char *FileName) {
char Path[MAX_PATH];
bool getMeOSFile(wchar_t *FileNamePath, const wchar_t *FileName) {
wchar_t Path[MAX_PATH];
strcpy_s(Path, programPath);
int i=strlen(Path);
wcscpy_s(Path, programPath);
int i=wcslen(Path);
if (Path[i-1]!='\\')
strcat_s(Path, MAX_PATH, "\\");
wcscat_s(Path, MAX_PATH, L"\\");
strcat_s(Path, FileName);
strcpy_s(FileNamePath, MAX_PATH, Path);
wcscat_s(Path, FileName);
wcscpy_s(FileNamePath, MAX_PATH, Path);
return true;
}
bool getUserFile(char *FileNamePath, const char *FileName)
bool getUserFile(wchar_t *FileNamePath, const wchar_t *FileName)
{
char Path[MAX_PATH];
char AppPath[MAX_PATH];
wchar_t Path[MAX_PATH];
wchar_t AppPath[MAX_PATH];
if (SHGetSpecialFolderPath(hWndMain, Path, CSIDL_APPDATA, 1)!=NOERROR) {
int i=strlen(Path);
int i=wcslen(Path);
if (Path[i-1]!='\\')
strcat_s(Path, MAX_PATH, "\\");
wcscat_s(Path, MAX_PATH, L"\\");
strcpy_s(AppPath, MAX_PATH, Path);
strcat_s(AppPath, MAX_PATH, "Meos\\");
wcscpy_s(AppPath, MAX_PATH, Path);
wcscat_s(AppPath, MAX_PATH, L"Meos\\");
CreateDirectory(AppPath, NULL);
Setup(false, false);
strcpy_s(FileNamePath, MAX_PATH, AppPath);
strcat_s(FileNamePath, MAX_PATH, FileName);
wcscpy_s(FileNamePath, MAX_PATH, AppPath);
wcscat_s(FileNamePath, MAX_PATH, FileName);
//return true;
}
else strcpy_s(FileNamePath, MAX_PATH, FileName);
else wcscpy_s(FileNamePath, MAX_PATH, FileName);
return true;
}
bool getDesktopFile(char *fileNamePath, const char *fileName, const char *subFolder)
bool getDesktopFile(wchar_t *fileNamePath, const wchar_t *fileName, const wchar_t *subFolder)
{
char Path[MAX_PATH];
char AppPath[MAX_PATH];
wchar_t Path[MAX_PATH];
wchar_t AppPath[MAX_PATH];
if (SHGetSpecialFolderPath(hWndMain, Path, CSIDL_DESKTOPDIRECTORY, 1)!=NOERROR) {
int i=strlen(Path);
int i=wcslen(Path);
if (Path[i-1]!='\\')
strcat_s(Path, MAX_PATH, "\\");
wcscat_s(Path, MAX_PATH, L"\\");
strcpy_s(AppPath, MAX_PATH, Path);
strcat_s(AppPath, MAX_PATH, "Meos\\");
wcscpy_s(AppPath, MAX_PATH, Path);
wcscat_s(AppPath, MAX_PATH, L"Meos\\");
CreateDirectory(AppPath, NULL);
if (subFolder) {
strcat_s(AppPath, MAX_PATH, subFolder);
strcat_s(AppPath, MAX_PATH, "\\");
wcscat_s(AppPath, MAX_PATH, subFolder);
wcscat_s(AppPath, MAX_PATH, L"\\");
CreateDirectory(AppPath, NULL);
}
strcpy_s(fileNamePath, MAX_PATH, AppPath);
strcat_s(fileNamePath, MAX_PATH, fileName);
wcscpy_s(fileNamePath, MAX_PATH, AppPath);
wcscat_s(fileNamePath, MAX_PATH, fileName);
}
else strcpy_s(fileNamePath, MAX_PATH, fileName);
else wcscpy_s(fileNamePath, MAX_PATH, fileName);
return true;
}
static set<string> tempFiles;
static string tempPath;
static set<wstring> tempFiles;
static wstring tempPath;
string getTempPath() {
char tempFile[MAX_PATH];
wstring getTempPath() {
wchar_t tempFile[MAX_PATH];
if (tempPath.empty()) {
char path[MAX_PATH];
wchar_t path[MAX_PATH];
GetTempPath(MAX_PATH, path);
GetTempFileName(path, "meos", 0, tempFile);
GetTempFileName(path, L"meos", 0, tempFile);
DeleteFile(tempFile);
if (CreateDirectory(tempFile, NULL))
tempPath = tempFile;
@ -1696,15 +1772,15 @@ string getTempPath() {
return tempPath;
}
void registerTempFile(const string &tempFile) {
void registerTempFile(const wstring &tempFile) {
tempFiles.insert(tempFile);
}
string getTempFile() {
wstring getTempFile() {
getTempPath();
char tempFile[MAX_PATH];
if (GetTempFileName(tempPath.c_str(), "ix", 0, tempFile)) {
wchar_t tempFile[MAX_PATH];
if (GetTempFileName(tempPath.c_str(), L"ix", 0, tempFile)) {
tempFiles.insert(tempFile);
return tempFile;
}
@ -1712,16 +1788,16 @@ string getTempFile() {
throw std::exception("Failed to create temporary file.");
}
void removeTempFile(const string &file) {
void removeTempFile(const wstring &file) {
DeleteFile(file.c_str());
tempFiles.erase(file);
}
void removeTempFiles() {
vector<string> dir;
for (set<string>::iterator it = tempFiles.begin(); it!= tempFiles.end(); ++it) {
char c = *it->rbegin();
if (c == '/' || c=='\\')
vector<wstring> dir;
for (set<wstring>::iterator it = tempFiles.begin(); it!= tempFiles.end(); ++it) {
wchar_t c = *it->rbegin();
if (c == '/' || c == '\\')
dir.push_back(*it);
else
DeleteFile(it->c_str());

View File

@ -27,7 +27,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@ -58,7 +58,7 @@
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='test|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='test|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='test|Win32'">true</LinkIncremental>

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
************************************************************************/
#pragma once
#include <vector>
#include <map>
@ -58,31 +59,53 @@ string getLocalTime();
string getLocalDate();
string getLocalTimeOnly();
wstring convertSystemTimeW(const SYSTEMTIME &st);
wstring convertSystemTimeOnlyW(const SYSTEMTIME &st);
wstring convertSystemDateW(const SYSTEMTIME &st);
wstring getLocalTimeW();
wstring getLocalDateW();
wstring getLocalTimeOnlyW();
// Get a day number after a fixed day some time ago...
int getRelativeDay();
/// Get time and date in a format that forms a part of a filename
string getLocalTimeFileName();
wstring getLocalTimeFileName();
const wstring &getTimeMSW(int m);
const wstring &formatTimeW(int rt);
const wstring &formatTimeHMSW(int rt);
const string &getTimeMS(int m);
const string &formatTime(int rt);
const string &formatTimeN(int rt);
const string &formatTimeHMS(int rt);
string formatTimeIOF(int rt, int zeroTime);
wstring formatTimeIOF(int rt, int zeroTime);
int convertDateYMS(const string &m, bool checkValid);
int convertDateYMS(const string &m, SYSTEMTIME &st, bool checkValid);
int convertDateYMS(const wstring &m, bool checkValid);
int convertDateYMS(const wstring &m, SYSTEMTIME &st, bool checkValid);
// Convert a "general" time string to a MeOS compatible time string
void processGeneralTime(const string &generalTime, string &meosTime, string &meosDate);
void processGeneralTime(const wstring &generalTime, wstring &meosTime, wstring &meosDate);
// Format number date 20160421 -> 2016-04-21 (if iso) or according to a custom format otherwise
string formatDate(int m, bool useIsoFormat);
wstring formatDateW(int m, bool useIsoFormat);
__int64 SystemTimeToInt64Second(const SYSTEMTIME &st);
SYSTEMTIME Int64SecondToSystemTime(__int64 time);
#define NOTIME 0x7FFFFFFF
//Returns a time converted from +/-MM:SS or NOTIME, in seconds
int convertAbsoluteTimeMS(const wstring &m);
// Parses a time on format HH:MM:SS+01:00Z or HHMMSS+0100Z (but ignores time zone)
int convertAbsoluteTimeISO(const wstring &m);
//Returns a time converted from +/-MM:SS or NOTIME, in seconds
int convertAbsoluteTimeMS(const string &m);
// Parses a time on format HH:MM:SS+01:00Z or HHMMSS+0100Z (but ignores time zone)
@ -93,41 +116,61 @@ int convertAbsoluteTimeISO(const string &m);
@param daysZeroTime -1 do not support days syntax, positive interpret days w.r.t the specified zero time.
*/
int convertAbsoluteTimeHMS(const string &m, int daysZeroTime);
/** Returns a time converted from HH:MM:SS or -1, in seconds
@param m time to convert
@param daysZeroTime -1 do not support days syntax, positive interpret days w.r.t the specified zero time.
*/
int convertAbsoluteTimeHMS(const wstring &m, int daysZeroTime);
const vector<string> &split(const string &line, const string &separators, vector<string> &split_vector);
const string &unsplit(const vector<string> &split_vector, const string &separators, string &line);
const string &MakeDash(const string &t);
const string &MakeDash(const char *t);
string FormatRank(int rank);
const vector<wstring> &split(const wstring &line, const wstring &separators, vector<wstring> &split_vector);
const wstring &unsplit(const vector<wstring> &split_vector, const wstring &separators, wstring &line);
const wstring &makeDash(const wstring &t);
const wstring &makeDash(const wchar_t *t);
wstring formatRank(int rank);
const string &itos(int i);
string itos(unsigned long i);
string itos(unsigned int i);
string itos(__int64 i);
const wstring &itow(int i);
wstring itow(unsigned long i);
wstring itow(unsigned int i);
wstring itow(__int64 i);
///Lower case match (filt_lc must be lc)
bool filterMatchString(const string &c, const char *filt_lc);
bool matchNumber(int number, const char *key);
bool filterMatchString(const wstring &c, const wchar_t *filt_lc);
bool matchNumber(int number, const wchar_t *key);
int getMeosBuild();
string getMeosDate();
string getMeosFullVersion();
string getMajorVersion();
string getMeosCompectVersion();
wstring getMeosDate();
wstring getMeosFullVersion();
wstring getMajorVersion();
wstring getMeosCompectVersion();
void getSupporters(vector<string> &supp);
int countWords(const char *p);
int countWords(const wchar_t *p);
wstring trim(const wstring &s);
string trim(const string &s);
bool fileExist(const char *file);
bool fileExist(const wchar_t *file);
bool stringMatch(const string &a, const string &b);
bool stringMatch(const wstring &a, const wstring &b);
const char *decodeXML(const char *in);
const string &decodeXML(const string &in);
const string &encodeXML(const string &in);
const wstring &encodeXML(const wstring &in);
const wstring &encodeHTML(const wstring &in);
/** Extend a year from 03 -> 2003, 97 -> 1997 etc */
int extendYear(int year);
@ -136,27 +179,30 @@ int extendYear(int year);
int getThisYear();
/** Translate a char to lower/stripped of accents etc.*/
int toLowerStripped(int c);
int toLowerStripped(wchar_t c);
/** Canonize a person/club name */
const char *canonizeName(const char *name);
//const char *canonizeName(const char *name);
const wchar_t *canonizeName(const wchar_t *name);
/** String distance between 0 and 1. 0 is equal*/
double stringDistance(const char *a, const char *b);
//double stringDistance(const char *a, const char *b);
double stringDistance(const wchar_t *a, const wchar_t *b);
/** Get a number suffix, Start 1 -> 1. Zero for none*/
int getNumberSuffix(const string &str);
int getNumberSuffix(const wstring &str);
/// Extract any number from a string and return the number, prefix and suffix
int extractAnyNumber(const string &str, string &prefix, string &suffix);
int extractAnyNumber(const wstring &str, wstring &prefix, wstring &suffix);
/** Compare classnames, match H21 Elit with H21E and H21 E */
bool compareClassName(const string &a, const string &b);
bool compareClassName(const wstring &a, const wstring &b);
/** Get WinAPI error from code */
string getErrorMessage(int code);
wstring getErrorMessage(int code);
class HLS {
private:
@ -175,46 +221,52 @@ public:
DWORD HLStoRGB() const;
};
#ifndef MEOSDB
void unzip(const char *zipfilename, const char *password, vector<string> &extractedFiles);
int zip(const char *zipfilename, const char *password, const vector<string> &files);
#endif
void unzip(const wchar_t *zipfilename, const char *password, vector<wstring> &extractedFiles);
int zip(const wchar_t *zipfilename, const char *password, const vector<wstring> &files);
bool isAscii(const wstring &s);
bool isNumber(const wstring &s);
bool isAscii(const string &s);
bool isNumber(const string &s);
int convertDynamicBase(const string &s, long long &out);
void convertDynamicBase(long long val, int base, char out[16]);
int convertDynamicBase(const wstring &s, long long &out);
void convertDynamicBase(long long val, int base, wchar_t out[16]);
/// Find all files in dir matching given file pattern
bool expandDirectory(const char *dir, const char *pattern, vector<string> &res);
bool expandDirectory(const wchar_t *dir, const wchar_t *pattern, vector<wstring> &res);
enum PersonSex {sFemale = 1, sMale, sBoth, sUnknown};
PersonSex interpretSex(const string &sex);
PersonSex interpretSex(const wstring &sex);
string encodeSex(PersonSex sex);
wstring encodeSex(PersonSex sex);
string makeValidFileName(const string &input, bool strict);
wstring makeValidFileName(const wstring &input, bool strict);
/** Initial capital letter. */
void capitalize(string &str);
void capitalize(wstring &str);
/** Initial capital letter for each word. */
void capitalizeWords(string &str);
void capitalizeWords(wstring &str);
string getTimeZoneString(const string &date);
/*
void capitalize(string &str);
void capitalizeWords(string &str);*/
wstring getTimeZoneString(const wstring &date);
/** Return bias in seconds. UTC = local time + bias. */
int getTimeZoneInfo(const string &date);
int getTimeZoneInfo(const wstring &date);
/** Compare bib numbers (which may contain non-digits, e.g. A-203, or 301a, 301b)*/
bool compareBib(const string &b1, const string &b2);
bool compareBib(const wstring &b1, const wstring &b2);
/** Split a name into Given, Family, and return Given.*/
string getGivenName(const string &name);
wstring getGivenName(const wstring &name);
/** Split a name into Given, Family, and return Family.*/
string getFamilyName(const string &name);
wstring getFamilyName(const wstring &name);
/** Simple file locking class to prevent opening in different MeOS session. */
class MeOSFileLock {
@ -228,9 +280,12 @@ public:
~MeOSFileLock() {unlockFile();}
void unlockFile();
void lockFile(const string &file);
void lockFile(const wstring &file);
};
namespace MeOSUtil {
extern int useHourFormat;
}
void string2Wide(const string &in, wstring &out);
void wide2String(const wstring &in, string &out);

View File

@ -40,6 +40,25 @@
using namespace mysqlpp;
wstring fromUTF(const string w) {
const int buff_pre_alloc = 1024*8;
static wchar_t buff[buff_pre_alloc];
int len = w.length();
len = min(len+1, buff_pre_alloc-10);
int wlen = MultiByteToWideChar(CP_UTF8, 0, w.c_str(), len, buff, buff_pre_alloc);
buff[wlen-1] = 0;
return buff;
}
string toString(const wstring &w) {
string &output = StringCache::getInstance().get();
size_t alloc = w.length()*4+4;
output.resize(alloc);
WideCharToMultiByte(CP_UTF8, 0, w.c_str(), w.length()+1, (char *)output.c_str(), alloc, 0, 0);
output.resize(strlen(output.c_str()));
return output;
}
MeosSQL::MeosSQL(void)
{
monitorId=0;
@ -120,6 +139,14 @@ string limitLength(const string &in, size_t max) {
return in.substr(0, max);
}
string limitLength(const wstring &in, size_t max) {
if (in.length() < max)
return toString(in);
else
return toString(in.substr(0, max));
}
bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
errorMessage.clear();
CmpDataBase="";
@ -168,6 +195,16 @@ bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
Query query = con.query();
try{
mysqlpp::Query queryset = con.query();
queryset << "SET NAMES UTF8";
queryset.execute();
}
catch (const mysqlpp::Exception& ){
}
query.reset();
try{
query << C_START("oEvent")
<< C_STRING("Name", 128)
@ -212,12 +249,12 @@ bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
if (int(row["Version"]) <= oe->dbVersion) {
CompetitionInfo ci;
ci.Name = row["Name"];
ci.Annotation = row["Annotation"];
ci.Name = fromUTF((string)row["Name"]);
ci.Annotation = fromUTF((string)row["Annotation"]);
ci.Id = row["Id"];
ci.Date = row["Date"];
ci.FullPath = row["NameId"];
ci.NameId = row["NameId"];
ci.Date = fromUTF((string)row["Date"]);
ci.FullPath = fromUTF((string)row["NameId"]);
ci.NameId = fromUTF((string)row["NameId"]);
ci.Server = oe->MySQLServer;
ci.ServerPassword = oe->MySQLPassword;
ci.ServerUser = oe->MySQLUser;
@ -227,12 +264,12 @@ bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
}
else {
CompetitionInfo ci;
ci.Name = row["Name"];
ci.Date = row["Date"];
ci.Annotation = row["Annotation"];
ci.Name = fromUTF(string(row["Name"]));
ci.Date = fromUTF(string(row["Date"]));
ci.Annotation = fromUTF(string(row["Annotation"]));
ci.Id=0;
ci.Server="bad";
ci.FullPath=row["NameId"];
ci.FullPath=fromUTF(string(row["NameId"]));
oe->cinfo.push_front(ci);
}
}
@ -299,7 +336,7 @@ bool MeosSQL::createRunnerDB(oEvent *oe, Query &query)
query.reset();
query << C_START_noid("dbRunner")
<< C_STRING("Name", 31) << C_INT("CardNo")
<< C_STRING("Name", 40) << C_INT("CardNo")
<< C_INT("Club") << C_STRING("Nation", 3)
<< C_STRING("Sex", 1) << C_INT("BirthYear")
<< C_INT64("ExtId") << C_END_noindex();
@ -387,7 +424,7 @@ bool MeosSQL::openDB(oEvent *oe)
return 0;
}
monitorId=0;
string dbname=oe->CurrentNameId;
string dbname(oe->currentNameId.begin(), oe->currentNameId.end());//WCS
try {
Query query = con.query();
@ -647,6 +684,14 @@ bool MeosSQL::reConnect()
return false;
}
try{
mysqlpp::Query queryset = con.query();
queryset << "SET NAMES UTF8";
queryset.execute();
}
catch (const mysqlpp::Exception& ){
}
return true;
}
@ -663,8 +708,8 @@ OpFailStatus MeosSQL::SyncUpdate(oEvent *oe)
mysqlpp::Query queryset = con.query();
queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", "
<< " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime)
<< " WHERE Id=" << oe->Id;
@ -699,8 +744,8 @@ OpFailStatus MeosSQL::SyncUpdate(oEvent *oe)
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", "
<< " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime) << ", "
<< " BuildVersion=" << buildVersion << ", "
<< " Lists=" << quote << listEnc
@ -794,13 +839,14 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
if (CmpDataBase.empty())
return opStatusFail;
int errorCount = 0;
int totErrorCount = 0;
ProgressWindow pw(oe->hWnd());
try {
const vector<oDBClubEntry> &cdb = oe->runnerDB->getClubDB();
const vector<oDBClubEntry> &cdb = oe->runnerDB->getClubDB(true);
size_t size = cdb.size();
const vector<RunnerDBEntry> &rdb = oe->runnerDB->getRunnerDB();
const vector<RunnerDBEntry> &rdb = oe->runnerDB->getRunnerDBN();
const vector<RunnerWDBEntry> &rwdb = oe->runnerDB->getRunnerDB();
if (cdb.size() + rdb.size() > 2000)
pw.init();
@ -819,14 +865,16 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
mysqlpp::Query query = con.query();
string setId = "Id=" + itos(cdb[k].Id) + ", ";
query << "INSERT INTO dbClub SET " << setId << "Name=" << quote << cdb[k].name
query << "INSERT INTO dbClub SET " << setId << "Name=" << quote << toString(cdb[k].name)
<< cdb[k].getDCI().generateSQLSet(true);
try {
query.execute();
errorCount = 0;
}
catch (const mysqlpp::Exception& ex) {
errorMessage = ex.what();
totErrorCount++;
if (++errorCount > 5)
throw;
}
@ -839,6 +887,9 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
for (size_t k = 0; k<size; k++) {
if (rdb[k].isRemoved())
continue;
if (!rdb[k].isUTF()) {
rwdb[k].recode(rdb[k]);
}
mysqlpp::Query query = con.query();
query << "INSERT INTO dbRunner SET " <<
@ -847,7 +898,17 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
", CardNo=" << rdb[k].cardNo << ", Sex=" << quote << rdb[k].getSex() <<
", Nation=" << quote << rdb[k].getNationality() << ", BirthYear=" << rdb[k].birthYear;
query.execute();
try {
query.execute();
errorCount = 0;
}
catch (const mysqlpp::Exception& ex) {
totErrorCount++;
errorMessage = ex.what();
if (++errorCount > 5)
throw;
}
if (k%200 == 150)
pw.setProgress(s1 + (k*s2)/size);
}
@ -903,7 +964,8 @@ bool MeosSQL::storeData(oDataInterface odi, const Row &row, unsigned long &revis
odi.getVariableString(varstring);
list<oVariableString>::iterator it_string;
for(it_string=varstring.begin(); it_string!=varstring.end(); it_string++) {
if (it_string->store(row[it_string->name].c_str()))
wstring w(fromUTF(row[it_string->name].c_str()));
if (it_string->store(w.c_str()))
updated = true;
}
}
@ -949,11 +1011,11 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
Row row;
if (row=res.at(0)){
oe->Name = row["Name"];
oe->Annotation = row["Annotation"];
oe->Date = row["Date"];
oe->Name = fromUTF(string(row["Name"]));
oe->Annotation = fromUTF(string(row["Annotation"]));
oe->Date = fromUTF(string(row["Date"]));
oe->ZeroTime = row["ZeroTime"];
strcpy_s(oe->CurrentNameId, row["NameId"].c_str());
oe->currentNameId = fromUTF(string(row["NameId"]));
}
con.select_db(CmpDataBase);
@ -988,7 +1050,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
cnt = query.store("SELECT COUNT(*) FROM dbRunner WHERE Modified>'" + time + "'");
int modrunner = cnt.at(0).at(0);
bool skipDB = modclub==0 && modrunner==0 && nClubDB == oe->runnerDB->getClubDB().size() &&
bool skipDB = modclub==0 && modrunner==0 && nClubDB == oe->runnerDB->getClubDB(false).size() &&
nRunnerDB == oe->runnerDB->getRunnerDB().size();
if (skipDB) {
@ -1024,11 +1086,11 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
Row row;
if (row=res.at(0)) {
oe->Name = row["Name"];
oe->Annotation = row["Annotation"];
oe->Date = row["Date"];
oe->Name = fromUTF(string(row["Name"]));
oe->Annotation = fromUTF(string(row["Annotation"]));
oe->Date = fromUTF(string(row["Date"]));
oe->ZeroTime = row["ZeroTime"];
strcpy_s(oe->CurrentNameId, row["NameId"].c_str());
oe->currentNameId = fromUTF(string(row["NameId"]));
oe->sqlUpdated = row["Modified"];
oe->counter = row["Counter"];
@ -1049,7 +1111,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
oDataInterface odi=oe->getDI();
storeData(odi, row, oe->dataRevision);
oe->changed = false;
oe->setCurrency(-1, "", "", false); // Set currency tmp data
oe->setCurrency(-1, L"", L"", false); // Set currency tmp data
oe->getMeOSFeatures().deserialize(oe->getDCI().getString("Features"), *oe);
}
}
@ -1302,7 +1364,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
oClub t(oe, row["Id"]);
string n = row["Name"];
t.internalSetName(n);
t.internalSetName(fromUTF(n));
storeData(t.getDI(), row, oe->dataRevision);
oe->runnerDB->addClub(t, false);
@ -1328,24 +1390,25 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
if (res) {
Row row;
while (row = res.fetch_row()) {
string name = row["Name"];
string name = (string)row["Name"];
string ext = row["ExtId"];
string club = row["Club"];
string card = row["CardNo"];
string sex = row["Sex"];
string nat = row["Nation"];
string birth = row["BirthYear"];
RunnerDBEntry *db = oe->runnerDB->addRunner(name.c_str(), _atoi64(ext.c_str()),
atoi(club.c_str()), atoi(card.c_str()));
RunnerWDBEntry *db = oe->runnerDB->addRunner(name.c_str(), _atoi64(ext.c_str()),
atoi(club.c_str()), atoi(card.c_str()));
if (db) {
RunnerDBEntry &dbn = db->dbe();
if (sex.length()==1)
db->sex = sex[0];
db->birthYear = short(atoi(birth.c_str()));
dbn.sex = sex[0];
dbn.birthYear = short(atoi(birth.c_str()));
if (nat.length()==3) {
db->national[0] = nat[0];
db->national[1] = nat[1];
db->national[2] = nat[2];
dbn.national[0] = nat[0];
dbn.national[1] = nat[1];
dbn.national[2] = nat[2];
}
}
@ -1370,7 +1433,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
void MeosSQL::storeClub(const Row &row, oClub &c)
{
string n = row["Name"];
c.internalSetName(n);
c.internalSetName(fromUTF(n));
c.sqlUpdated = row["Modified"];
c.counter = row["Counter"];
@ -1385,8 +1448,8 @@ void MeosSQL::storeClub(const Row &row, oClub &c)
void MeosSQL::storeControl(const Row &row, oControl &c)
{
c.Name = row["Name"];
c.setNumbers(string(row["Numbers"]));
c.Name = fromUTF((string)row["Name"]);
c.setNumbers(fromUTF((string)row["Numbers"]));
oControl::ControlStatus oldStat = c.Status;
c.Status = oControl::ControlStatus(int(row["Status"]));
@ -1430,7 +1493,7 @@ void MeosSQL::storePunch(const Row &row, oFreePunch &p, bool rehash)
if (rehash) {
p.setCardNo(row["CardNo"], true);
p.setTimeInt(row["Time"], true);
p.setType(string(row["Type"]), true);
p.setType(fromUTF(string(row["Type"])), true);
}
else {
p.CardNo = row["CardNo"];
@ -1452,7 +1515,7 @@ OpFailStatus MeosSQL::storeClass(const Row &row, oClass &c,
{
OpFailStatus success = opStatusOK;
c.Name=row["Name"];
c.Name=fromUTF(string(row["Name"]));
string multi = row["MultiCourse"];
string lm(row["LegMethod"]);
@ -1499,7 +1562,7 @@ OpFailStatus MeosSQL::storeCourse(const Row &row, oCourse &c,
{
OpFailStatus success = opStatusOK;
c.Name = row["Name"];
c.Name = fromUTF((string)row["Name"]);
c.importControls(string(row["Controls"]), false);
c.Length = row["Length"];
c.importLegLengths(string(row["Legs"]), false);
@ -1544,9 +1607,9 @@ OpFailStatus MeosSQL::storeRunner(const Row &row, oRunner &r,
r.markClassChanged(-1);
int oldSno = r.StartNo;
const string &oldBib = r.getBib();
const wstring &oldBib = r.getBib();
r.sName = row["Name"];
r.sName = fromUTF((string)row["Name"]);
oRunner::getRealName(r.sName, r.tRealName);
r.setCardNo(row["CardNo"], false, true);
r.StartNo = row["StartNo"];
@ -1678,9 +1741,9 @@ OpFailStatus MeosSQL::storeTeam(const Row &row, oTeam &t,
t.Class->markSQLChanged(-1,-1);
int oldSno = t.StartNo;
const string &oldBib = t.getBib();
const wstring &oldBib = t.getBib();
t.sName=row["Name"];
t.sName=fromUTF((string)row["Name"]);
t.StartNo=row["StartNo"];
t.tStartTime = t.startTime = row["StartTime"];
t.FinishTime=row["FinishTime"];
@ -1740,7 +1803,7 @@ OpFailStatus MeosSQL::storeTeam(const Row &row, oTeam &t,
success = min(success, syncRead(true, &or, readRecursive, readRecursive));
if (or.sName.empty()) {
or.sName = "@AutoCorrection";
or.sName = L"@AutoCorrection";
oRunner::getRealName(or.sName, or.tRealName);
}
pRns[k] = oe->addRunner(or, false);
@ -1837,7 +1900,7 @@ OpFailStatus MeosSQL::syncUpdate(oRunner *r, bool forceWriteAll)
return opStatusFail;
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << r->sName << ", "
queryset << " Name=" << quote << toString(r->sName) << ", "
<< " CardNo=" << r->CardNo << ", "
<< " StartNo=" << r->StartNo << ", "
<< " StartTime=" << r->startTime << ", "
@ -1854,10 +1917,10 @@ OpFailStatus MeosSQL::syncUpdate(oRunner *r, bool forceWriteAll)
<< " MultiR=" << quote << r->codeMultiR()
<< r->getDI().generateSQLSet(forceWriteAll);
string str = "write runner " + r->sName + ", st = " + itos(r->startTime) + "\n";
/*
wstring str = L"write runner " + r->sName + L", st = " + itow(r->startTime) + L"\n";
OutputDebugString(str.c_str());
*/
return syncUpdate(queryset, "oRunner", r);
}
@ -2034,7 +2097,7 @@ OpFailStatus MeosSQL::syncUpdate(oTeam *t, bool forceWriteAll) {
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << t->sName << ", "
queryset << " Name=" << quote << toString(t->sName) << ", "
<< " Runners=" << quote << t->getRunners() << ", "
<< " StartTime=" << t->startTime << ", "
<< " FinishTime=" << t->FinishTime << ", "
@ -2044,8 +2107,8 @@ OpFailStatus MeosSQL::syncUpdate(oTeam *t, bool forceWriteAll) {
<< " Status=" << t->status
<< t->getDI().generateSQLSet(forceWriteAll);
string str = "write team " + t->sName + "\n";
OutputDebugString(str.c_str());
//wstring str = L"write team " + t->sName + L"\n";
//OutputDebugString(str.c_str());
return syncUpdate(queryset, "oTeam", t);
}
@ -2130,7 +2193,7 @@ OpFailStatus MeosSQL::syncUpdate(oClass *c, bool forceWriteAll)
return opStatusFail;
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->Name << ","
queryset << " Name=" << quote << toString(c->Name) << ","
<< " Course=" << c->getCourseId() << ","
<< " MultiCourse=" << quote << c->codeMultiCourse() << ","
<< " LegMethod=" << quote << c->codeLegMethod()
@ -2327,7 +2390,7 @@ OpFailStatus MeosSQL::syncUpdate(oClub *c, bool forceWriteAll)
if (!c || !con.connected())
return opStatusFail;
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->name
queryset << " Name=" << quote << toString(c->name)
<< c->getDI().generateSQLSet(forceWriteAll);
return syncUpdate(queryset, "oClub", c);
@ -2394,8 +2457,8 @@ OpFailStatus MeosSQL::syncUpdate(oControl *c, bool forceWriteAll) {
return opStatusFail;
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->Name << ", "
<< " Numbers=" << quote << c->codeNumbers() << ","
queryset << " Name=" << quote << toString(c->Name) << ", "
<< " Numbers=" << quote << toString(c->codeNumbers()) << ","
<< " Status=" << c->Status
<< c->getDI().generateSQLSet(forceWriteAll);
@ -2462,7 +2525,7 @@ OpFailStatus MeosSQL::syncUpdate(oCourse *c, bool forceWriteAll)
if (!c || !con.connected())
return opStatusFail;
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->Name << ", "
queryset << " Name=" << quote << toString(c->Name) << ", "
<< " Length=" << unsigned(c->Length) << ", "
<< " Controls=" << quote << c->getControls() << ", "
<< " Legs=" << quote << c->getLegLengths()
@ -2681,7 +2744,7 @@ OpFailStatus MeosSQL::syncUpdate(mysqlpp::Query &updateqry,
{
nUpdate++;
if (nUpdate % 100 == 99)
OutputDebugString((itos(nUpdate) +" updates\n").c_str());
OutputDebugStringA((itos(nUpdate) +" updates\n").c_str());
assert(ob->getEvent());
if (!ob->getEvent())
@ -2810,9 +2873,9 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
oldVersion=true;
*/
if (isOld(counter, Modified, oe)) {
oe->Name=row["Name"];
oe->Annotation = row["Annotation"];
oe->Date=row["Date"];
oe->Name=fromUTF(string(row["Name"]));
oe->Annotation = fromUTF(string(row["Annotation"]));
oe->Date=fromUTF(string(row["Date"]));
oe->ZeroTime=row["ZeroTime"];
oe->sqlUpdated=Modified;
const string &lRaw = row.raw_string(res.field_num("Lists"));
@ -2825,7 +2888,7 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
oe->counter = counter;
oDataInterface odi=oe->getDI();
storeData(odi, row, oe->dataRevision);
oe->setCurrency(-1, "", "", false);//Init temp data from stored data
oe->setCurrency(-1, L"", L"", false);//Init temp data from stored data
oe->getMeOSFeatures().deserialize(oe->getDCI().getString("Features"), *oe);
oe->changed=false;
oe->changedObject();
@ -2844,8 +2907,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", "
<< " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime) << ", "
<< " BuildVersion=if (BuildVersion<" <<
buildVersion << "," << buildVersion << ",BuildVersion), "
@ -2859,8 +2922,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
queryset.reset();
queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", "
<< " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime)
<< " WHERE Id=" << oe->Id;
@ -2876,8 +2939,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ","
<< " NameId=" << quote << oe->CurrentNameId << ","
<< " Date=" << quote << toString(oe->Date) << ","
<< " NameId=" << quote << toString(oe->currentNameId) << ","
<< " ZeroTime=" << unsigned(oe->ZeroTime) << ","
<< " BuildVersion=if (BuildVersion<" <<
buildVersion << "," << buildVersion << ",BuildVersion),"
@ -2891,8 +2954,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
queryset.reset();
queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", "
<< " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime)
<< " WHERE Id=" << oe->Id;
@ -3424,7 +3487,7 @@ bool MeosSQL::checkConnection(oEvent *oe)
if (monitorId==0) {
try {
Query query = con.query();
query << "INSERT INTO oMonitor SET Count=1, Client=" << quote << oe->clientName;
query << "INSERT INTO oMonitor SET Count=1, Client=" << quote << toString(oe->clientName);
ResNSel res=query.execute();
if (res)
monitorId=static_cast<int>(res.insert_id);
@ -3437,7 +3500,7 @@ bool MeosSQL::checkConnection(oEvent *oe)
else {
try {
Query query = con.query();
query << "Update oMonitor SET Count=Count+1, Client=" << quote << oe->clientName
query << "Update oMonitor SET Count=Count+1, Client=" << quote << toString(oe->clientName)
<< " WHERE Id = " << monitorId;
query.execute();
}
@ -3543,14 +3606,14 @@ bool MeosSQL::dropDatabase(oEvent *oe)
}
void MeosSQL::importLists(oEvent *oe, const char *bf) {
xmlparser xml(0);
xmlparser xml;
xml.readMemory(bf, 0);
oe->listContainer->clearExternal();
oe->listContainer->load(MetaListContainer::ExternalList, xml.getObject("Lists"), false);
}
void MeosSQL::encodeLists(const oEvent *oe, string &listEnc) const {
xmlparser parser(0);
xmlparser parser;
parser.openMemoryOutput(true);
parser.startTag("Lists");
oe->listContainer->save(MetaListContainer::ExternalList, parser, oe);
@ -3600,7 +3663,7 @@ void MeosSQL::synchronized(const oBase &entity) {
readTimes[make_pair(id, entity.getId())] = GetTickCount();
readent++;
if (readent % 100 == 99)
OutputDebugString("Read 100 entities\n");
OutputDebugStringA("Read 100 entities\n");
}
bool MeosSQL::skipSynchronize(const oBase &entity) const {

View File

@ -20,6 +20,7 @@
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#pragma warning( disable : 4251)
#include <mysql++.h>

View File

@ -32,8 +32,6 @@
#define MEOSDB_API
#endif
#include <mysql++.h>
#include <iostream>
#include <iomanip>
@ -76,7 +74,7 @@ bool MEOSDB_API msSynchronizeList(oEvent *oe, int lid)
{
nSynchList++;
if (nSynchList % 100 == 99)
OutputDebugString("Synchronized 100 lists\n");
OutputDebugString(L"Synchronized 100 lists\n");
if (lid==oLRunnerId)
return msql.syncListRunner(oe);
@ -135,7 +133,7 @@ int MEOSDB_API msSynchronizeRead(oBase *obj)
{
nSynchEnt++;
if (nSynchEnt % 100 == 99)
OutputDebugString("Synchronized 100 entities\n");
OutputDebugString(L"Synchronized 100 entities\n");
if (typeid(*obj)==typeid(oRunner)){
return msql.syncRead(false, (oRunner *) obj );

View File

@ -38,7 +38,7 @@ namespace mysqlpp {
/// \brief Base class for all MySQL++ custom exceptions
class MYSQLPP_EXPORT Exception : public std::exception
class Exception : public std::exception
{
public:
/// \brief Create exception object as copy of another
@ -84,7 +84,7 @@ protected:
/// \brief Exception thrown when a bad type conversion is attempted.
class MYSQLPP_EXPORT BadConversion : public Exception
class BadConversion : public Exception
{
public:
const char* type_name; ///< name of type we tried to convert to
@ -154,7 +154,7 @@ public:
/// Thrown by Row::lookup_by_name() when you pass a field name that
/// isn't in the result set.
class MYSQLPP_EXPORT BadFieldName : public Exception
class BadFieldName : public Exception
{
public:
/// \brief Create exception object
@ -173,7 +173,7 @@ public:
/// \brief Exception thrown when you attempt to convert a SQL null
/// to an incompatible type.
class MYSQLPP_EXPORT BadNullConversion : public Exception
class BadNullConversion : public Exception
{
public:
/// \brief Create exception object
@ -187,7 +187,7 @@ public:
/// \brief Exception thrown when you pass an unrecognized option to
/// Connection::set_option().
class MYSQLPP_EXPORT BadOption : public Exception
class BadOption : public Exception
{
public:
/// \brief Create exception object, taking C string
@ -219,7 +219,7 @@ private:
///
/// This is used in handling template queries.
class MYSQLPP_EXPORT BadParamCount : public Exception
class BadParamCount : public Exception
{
public:
/// \brief Create exception object
@ -240,7 +240,7 @@ public:
/// SQL query. In v1.7, it was used as a more generic exception type,
/// for no particularly good reason.
class MYSQLPP_EXPORT BadQuery : public Exception
class BadQuery : public Exception
{
public:
/// \brief Create exception object, taking C string
@ -261,7 +261,7 @@ public:
/// database server connection. It's also thrown if
/// Connection::shutdown() fails.
class MYSQLPP_EXPORT ConnectionFailed : public Exception
class ConnectionFailed : public Exception
{
public:
/// \brief Create exception object
@ -275,7 +275,7 @@ public:
/// \brief Exception thrown when the program tries to select a new
/// database and the server refuses for some reason.
class MYSQLPP_EXPORT DBSelectionFailed : public Exception
class DBSelectionFailed : public Exception
{
public:
/// \brief Create exception object
@ -289,7 +289,7 @@ public:
/// \brief Exception thrown when ResUse::fetch_row() walks off the end
/// of a use-query's result set.
class MYSQLPP_EXPORT EndOfResults : public Exception
class EndOfResults : public Exception
{
public:
/// \brief Create exception object
@ -303,7 +303,7 @@ public:
/// \brief Exception thrown when Query::store_next() walks off the end
/// of a use-query's multi result sets.
class MYSQLPP_EXPORT EndOfResultSets : public Exception
class EndOfResultSets : public Exception
{
public:
/// \brief Create exception object
@ -322,7 +322,7 @@ public:
/// thread library could assert other errors that would keep this
/// exception relevant.
class MYSQLPP_EXPORT LockFailed : public Exception
class LockFailed : public Exception
{
public:
/// \brief Create exception object
@ -336,7 +336,7 @@ public:
/// \brief Exception thrown when you try to use an object that isn't
/// completely initialized.
class MYSQLPP_EXPORT ObjectNotInitialized : public Exception
class ObjectNotInitialized : public Exception
{
public:
/// \brief Create exception object

View File

@ -21,11 +21,28 @@
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "meos_util.h"
class meosException : public std::exception {
wstring wideMessage;
static const char *narrow(const wstring &msg) {
static string nmsg(msg.begin(), msg.end());
return nmsg.c_str();
}
public:
meosException(const string &msg) : std::exception(msg.c_str()) {}
meosException(const char *msg) : std::exception(msg) {}
meosException(const wstring &wmsg) : std::exception(narrow(wmsg)), wideMessage(wmsg) {
}
meosException(const string &msg) : std::exception(msg.c_str()) {
string2Wide(msg, wideMessage);
}
meosException(const char *msg) : std::exception(msg) {
string2Wide(string(msg), wideMessage);
}
meosException() : std::exception() {}
wstring wwhat() const{
return wideMessage;
}
};

View File

@ -17,7 +17,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{B854EF2A-2BB7-4D62-B08B-96BD64B347E8}</ProjectGuid>
<RootNamespace>meos</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>5.01</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test|Win32'" Label="Configuration">
@ -29,15 +29,15 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -79,6 +79,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>meos</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>meos</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -106,13 +109,14 @@
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DisableSpecificWarnings>4091</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x041d</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>Msimg32.lib;comctl32.lib;odbc32.lib;odbccp32.lib;winmm.lib;ws2_32.lib;wininet.lib;zlibstat.lib;mysqlpp.lib;libhpdf.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Msimg32.lib;comctl32.lib;odbc32.lib;odbccp32.lib;winmm.lib;ws2_32.lib;wininet.lib;zlibstat_vc15.lib;mysqlpp_vc15.lib;libhpdf.lib;RestBed.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\Release/meos.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>./lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -123,6 +127,7 @@
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<MinimumRequiredVersion>5.01</MinimumRequiredVersion>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@ -147,17 +152,17 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\Debug/meos.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
<ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
<BrowseInformation>true</BrowseInformation>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<BrowseInformation>false</BrowseInformation>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4996;4100;4244;4245;4702;4389;4127;4201;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>4996;4091;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
@ -165,7 +170,7 @@
<Culture>0x041d</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>Msimg32.lib;comctl32.lib;odbc32.lib;odbccp32.lib;winmm.lib;ws2_32.lib;wininet.lib;zlibstat.lib;mysqlpp_vc15.lib;libhpdf.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Msimg32.lib;comctl32.lib;odbc32.lib;odbccp32.lib;winmm.lib;ws2_32.lib;wininet.lib;zlibstat_vc15.lib;mysqlpp_vc15.lib;libhpdf.lib;RestBed.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\Debug/meos.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>./lib_db;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -176,6 +181,8 @@
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
<AdditionalOptions>/FORCE:MULTIPLE %(AdditionalOptions)</AdditionalOptions>
</Link>
<Bscmake>
@ -343,7 +350,7 @@
</ClCompile>
<ClCompile Include="StdAfx.cpp">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='test|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -412,6 +419,7 @@
<ClInclude Include="recorder.h" />
<ClInclude Include="socket.h" />
<ClInclude Include="speakermonitor.h" />
<ClInclude Include="subcommand.h" />
<ClInclude Include="testmeos.h" />
<ClInclude Include="toolbar.h" />
<ClInclude Include="csvparser.h" />

View File

@ -27,8 +27,9 @@
//V2: ABCDEFGHIHJKMN
//V31: a
//V33: abcde
//V35: abc
int getMeosBuild() {
string revision("$Rev: 608 $");
string revision("$Rev: 611 $");
return 174 + atoi(revision.substr(5, string::npos).c_str());
}
@ -38,35 +39,35 @@ int getMeosBuild() {
//V31: abcde
//V32: abcdefgh
//V33: abcdefghij
//V34: abcdfgh
string getMeosDate() {
string date("$Date: 2017-08-27 21:13:26 +0200 (sö, 27 aug 2017) $");
//V34: abcdfg
wstring getMeosDate() {
wstring date(L"$Date: 2017-08-28 20:32:01 +0200 (må, 28 aug 2017) $");
return date.substr(7,10);
}
string getBuildType() {
return "U2"; // No parantheses (...)
wstring getBuildType() {
return L"Snapshot"; // No parantheses (...)
}
string getMajorVersion() {
return "3.4";
wstring getMajorVersion() {
return L"3.5";
}
string getMeosFullVersion() {
char bf[256];
string maj = getMajorVersion();
wstring getMeosFullVersion() {
wchar_t bf[256];
wstring maj = getMajorVersion();
if (getBuildType().empty())
sprintf_s(bf, "Version X#%s.%d, %s", maj.c_str(), getMeosBuild(), getMeosDate().c_str());
swprintf_s(bf, L"Version X#%s.%d, %s", maj.c_str(), getMeosBuild(), getMeosDate().c_str());
else
sprintf_s(bf, "Version X#%s.%d, %s %s", maj.c_str(), getMeosBuild(), getBuildType().c_str(), getMeosDate().c_str());
swprintf_s(bf, L"Version X#%s.%d, %s %s", maj.c_str(), getMeosBuild(), getBuildType().c_str(), getMeosDate().c_str());
return bf;
}
string getMeosCompectVersion() {
wstring getMeosCompectVersion() {
if (getBuildType().empty())
return getMajorVersion() + "." + itos(getMeosBuild());
return getMajorVersion() + L"." + itow(getMeosBuild());
else
return getMajorVersion() + "." + itos(getMeosBuild()) + " (" + getBuildType() + ")";
return getMajorVersion() + L"." + itow(getMeosBuild()) + L" (" + getBuildType() + L")";
}
void getSupporters(vector<string> &supp)

View File

@ -123,13 +123,13 @@ void oListParam::deserialize(const xmlobject &xml, const MetaListContainer &cont
saved = true;
}
void oListParam::getCustomTitle(char *t) const
void oListParam::getCustomTitle(wchar_t *t) const
{
if (!title.empty())
strcpy_s(t, 256, MakeDash(title).c_str());
wcscpy_s(t, 256, makeDash(title).c_str());
}
const string &oListParam::getCustomTitle(const string &t) const
const wstring &oListParam::getCustomTitle(const wstring &t) const
{
if (!title.empty())
return title;
@ -161,6 +161,14 @@ int checksum(const string &str) {
return ret;
}
int checksum(const wstring &str) {
int ret = 0;
for (size_t k = 0; k<str.length(); k++)
ret = ret * 19 + str[k];
return ret;
}
void MetaList::initUniqueIndex() const {
__int64 ix = 0;
@ -217,9 +225,9 @@ bool MetaList::isBreak(int x) const {
|| x == ')' || x=='/' || (x>30 && x < 127 && !isalnum(x));
}
string MetaList::encode(const string &input_) const {
string out;
string input = lang.tl(input_);
wstring MetaList::encode(const wstring &input_) const {
wstring out;
wstring input = lang.tl(input_);
out.reserve(input.length() + 5);
for (size_t k = 0; k<input.length(); k++) {
@ -279,9 +287,9 @@ void MetaList::interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par
for (size_t k = 0; k < fontFaces.size(); k++) {
for (map<gdiFonts, string>::const_iterator it = fontToSymbol.begin();
it != fontToSymbol.end(); ++it) {
string face = fontFaces[k].font;
wstring face = fontFaces[k].font;
if (fontFaces[k].scale > 0 && fontFaces[k].scale != 100) {
face += ";" + itos(fontFaces[k].scale/100) + "." + itos(fontFaces[k].scale%100);
face += L";" + itow(fontFaces[k].scale/100) + L"." + itow(fontFaces[k].scale%100);
}
fontHeight[make_pair(it->first, int(k))] = gdi.getLineHeight(it->first, face.c_str());
}
@ -304,7 +312,7 @@ void MetaList::interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par
}
map<EPostType, string> labelMap;
map<string, string> stringLabelMap;
map<wstring, string> stringLabelMap;
set<EPostType> skip;
li.calcResults = false;
@ -388,7 +396,7 @@ void MetaList::interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par
if (mp.font != formatIgnore)
font = mp.font;
vector< pair<EPostType, string> > typeFormats;
vector< pair<EPostType, wstring> > typeFormats;
typeFormats.push_back(make_pair(mp.type, encode(mp.text)));
size_t kk = k+1;
//Add merged entities
@ -397,7 +405,7 @@ void MetaList::interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par
kk++;
}
width = li.getMaxCharWidth(oe, par.selection, typeFormats, font,
width = li.getMaxCharWidth(oe, gdi, par.selection, typeFormats, font,
oPrintPost::encodeFont(fontFaces[i].font,
fontFaces[i].scale).c_str(),
large, max(mp.blockWidth, extraMinWidth));
@ -414,13 +422,13 @@ void MetaList::interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par
pos.alignNext(label, width, mp.alignBlock);
else if (mp.alignType == lString) {
if (stringLabelMap.count(mp.alignWithText) == 0) {
throw meosException("Don't know how to align with 'X'#" + mp.alignWithText);
throw meosException(L"Don't know how to align with 'X'#" + mp.alignWithText);
}
pos.update(stringLabelMap[mp.alignWithText], label, width, mp.alignBlock, true);
}
else {
if (labelMap.count(mp.alignType) == 0) {
throw meosException("Don't know how to align with 'X'#" + typeToSymbol[mp.alignType]);
throw meosException(L"Don't know how to align with 'X'#" + typeToSymbol[mp.alignType]);
}
pos.update(labelMap[mp.alignType], label, width, mp.alignBlock, true);
@ -482,13 +490,13 @@ void MetaList::interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par
continue;
string label = "P" + itos(0*1000 + j*100 + k);
string text = MakeDash(encode(cline[k].text));
wstring text = makeDash(encode(cline[k].text));
gdiFonts font = normalText;
if (j == 0)
font = boldLarge;
if (mp.type == lCmpName) {
text = MakeDash(par.getCustomTitle(text));
text = makeDash(par.getCustomTitle(text));
}
if (mp.font != formatIgnore)
@ -940,8 +948,8 @@ bool Position::postAdjust() {
return false;
}
void MetaList::save(const string &file, const oEvent *oe) const {
xmlparser xml(0);
void MetaList::save(const wstring &file, const oEvent *oe) const {
xmlparser xml;
xml.openOutput(file.c_str(), true);
save(xml, oe);
xml.closeOut();
@ -953,7 +961,7 @@ void MetaList::save(xmlparser &xml, const oEvent *oe) const {
// xml.write("Title", defaultTitle);
xml.write("ListName", listName);
if (listOrigin.empty())
listOrigin = gEvent->getName() + " (" + getLocalDate() + ")";
listOrigin = gEvent->getName() + L" (" + getLocalDateW() + L")";
xml.write("ListOrigin", listOrigin);
xml.write("Tag", tag);
xml.write("UID", getUniqueId());
@ -964,7 +972,7 @@ void MetaList::save(xmlparser &xml, const oEvent *oe) const {
string ttw = DynamicResult::undecorateTag(resultModule);
xml.write("ResultModule", ttw);
try {
string srcFile;
wstring srcFile;
GeneralResult &gr = oe->getGeneralResult(resultModule, srcFile);
DynamicResult &dr = dynamic_cast<DynamicResult &>(gr);
if (!dr.isBuiltIn()) {
@ -997,7 +1005,7 @@ void MetaList::save(xmlparser &xml, const oEvent *oe) const {
for (set<ESubFilterList>::const_iterator it = subFilter.begin(); it != subFilter.end(); ++it)
xml.write("SubFilter", "name", subFilterToSymbol[*it]);
vector< pair<string, string> > props(2);
vector< pair<string, wstring> > props(2);
xml.write("HeadFont", fontFaces[MLHead].serialize(props), fontFaces[MLHead].font);
xml.write("SubHeadFont", fontFaces[MLSubHead].serialize(props), fontFaces[MLSubHead].font);
xml.write("ListFont", fontFaces[MLList].serialize(props), fontFaces[MLList].font);
@ -1011,9 +1019,9 @@ void MetaList::save(xmlparser &xml, const oEvent *oe) const {
xml.endTag();
}
void MetaList::load(const string &file) {
xmlparser xml(0);
xml.read(file.c_str());
void MetaList::load(const wstring &file) {
xmlparser xml;
xml.read(file);
filter.clear();
xmlobject xDef = xml.getObject("MeOSListDefinition");
load(xDef);
@ -1040,7 +1048,7 @@ void MetaList::load(const xmlobject &xDef) {
dr.load(rs[k]);
// string db = "Loaded res mod: " + dr.getTag() + ", h=" + itos(dr.getHashCode())+ "\n";
// OutputDebugString(db.c_str());
string file = "*";
wstring file = L"*";
dynamicResults[k] = GeneralResultCtr(file, new DynamicResult(dr));
}
supportFromControl = xDef.getObjectBool("SupportFrom");
@ -1076,29 +1084,29 @@ void MetaList::load(const xmlobject &xDef) {
xmlobject xSubListFont = xDef.getObject("SubListFont");
if (xHeadFont) {
const char *f = xHeadFont.get();
fontFaces[MLHead].font = f != 0 ? f : "arial";
const wchar_t *f = xHeadFont.getw();
fontFaces[MLHead].font = f != 0 ? f : L"arial";
fontFaces[MLHead].scale = xHeadFont.getObjectInt("scale");
fontFaces[MLHead].extraSpaceAbove = xHeadFont.getObjectInt("above");
}
if (xSubHeadFont) {
const char *f = xSubHeadFont.get();
fontFaces[MLSubHead].font = f != 0 ? f : "arial";
const wchar_t *f = xSubHeadFont.getw();
fontFaces[MLSubHead].font = f != 0 ? f : L"arial";
fontFaces[MLSubHead].scale = xSubHeadFont.getObjectInt("scale");
fontFaces[MLSubHead].extraSpaceAbove = xSubHeadFont.getObjectInt("above");
}
if (xListFont) {
const char *f = xListFont.get();
fontFaces[MLList].font = f != 0 ? f : "arial";
const wchar_t *f = xListFont.getw();
fontFaces[MLList].font = f != 0 ? f : L"arial";
fontFaces[MLList].scale = xListFont.getObjectInt("scale");
fontFaces[MLList].extraSpaceAbove = xListFont.getObjectInt("above");
}
if (xSubListFont) {
const char *f = xSubListFont.get();
fontFaces[MLSubList].font = f != 0 ? f : "arial";
const wchar_t *f = xSubListFont.getw();
fontFaces[MLSubList].font = f != 0 ? f : L"arial";
fontFaces[MLSubList].scale = xSubListFont.getObjectInt("scale");
fontFaces[MLSubList].extraSpaceAbove = xSubListFont.getObjectInt("above");
}
@ -1188,8 +1196,9 @@ void MetaList::getDynamicResults(vector<DynamicResultRef> &resultModules) const
resultModules[k].ctr = const_cast<MetaList *>(this);
}
}
extern gdioutput *gdi_main;
const string &MetaList::getListInfo(const oEvent &oe) const {
const wstring &MetaList::getListInfo(const oEvent &oe) const {
vector<DynamicResultRef> resultModules;
getDynamicResults(resultModules);
@ -1199,7 +1208,7 @@ const string &MetaList::getListInfo(const oEvent &oe) const {
}
}
if (!resultModule.empty()) {
string f;
wstring f;
try {
GeneralResult &res = oe.getGeneralResult(resultModule, f);
DynamicResult &dres = dynamic_cast<DynamicResult &>(res);
@ -1209,7 +1218,7 @@ const string &MetaList::getListInfo(const oEvent &oe) const {
}
}
return _EmptyString;
return _EmptyWString;
}
@ -1308,7 +1317,7 @@ void MetaList::deserialize(const xmlobject &xml, vector< vector<MetaListPost> >
}
}
const string &MetaListPost::getType() const {
const wstring &MetaListPost::getType() const {
return MetaList::typeToSymbol[type];
}
@ -1337,11 +1346,11 @@ void MetaListPost::setColor(GDICOLOR c) {
color = c;
}
void MetaListPost::getTypes(vector< pair<string, size_t> > &types, int &currentType) const {
void MetaListPost::getTypes(vector< pair<wstring, size_t> > &types, int &currentType) const {
currentType = type;
types.clear();
types.reserve(MetaList::typeToSymbol.size());
for (map<EPostType, string>::const_iterator it =
for (map<EPostType, wstring>::const_iterator it =
MetaList::typeToSymbol.begin(); it != MetaList::typeToSymbol.end(); ++it) {
if (it->first == lNone)
continue;
@ -1356,7 +1365,7 @@ const string &MetaListPost::getFont() const {
return MetaList::fontToSymbol[font];
}
void MetaListPost::getFonts(vector< pair<string, size_t> > &fonts, int &currentFont) const {
void MetaListPost::getFonts(vector< pair<wstring, size_t> > &fonts, int &currentFont) const {
currentFont = font;
fonts.clear();
fonts.reserve(MetaList::fontToSymbol.size());
@ -1366,7 +1375,7 @@ void MetaListPost::getFonts(vector< pair<string, size_t> > &fonts, int &currentF
}
}
void MetaListPost::getAllFonts(vector< pair<string, size_t> > &fonts) {
void MetaListPost::getAllFonts(vector< pair<wstring, size_t> > &fonts) {
fonts.clear();
fonts.reserve(MetaList::fontToSymbol.size());
for (map<gdiFonts, string>::const_iterator it =
@ -1375,12 +1384,12 @@ void MetaListPost::getAllFonts(vector< pair<string, size_t> > &fonts) {
}
}
void MetaList::getAlignTypes(const MetaListPost &mlp, vector< pair<string, size_t> > &types, int &currentType) const {
void MetaList::getAlignTypes(const MetaListPost &mlp, vector< pair<wstring, size_t> > &types, int &currentType) const {
currentType = mlp.alignType;
types.clear();
int gix, lix, ix;
getIndex(mlp, gix, lix, ix);
set< pair<EPostType, string> > atypes;
set< pair<EPostType, wstring> > atypes;
bool q = false;
for (size_t k = 0; k < data.size(); k++) {
for (size_t j = 0; j < data[k].size(); j++) {
@ -1390,7 +1399,7 @@ void MetaList::getAlignTypes(const MetaListPost &mlp, vector< pair<string, size_
}
for (size_t i = 0; i < data[k][j].size(); i++) {
if (data[k][j][i].type != lString)
atypes.insert(make_pair(data[k][j][i].type, ""));
atypes.insert(make_pair(data[k][j][i].type, L""));
else
atypes.insert(make_pair(data[k][j][i].type, data[k][j][i].text));
}
@ -1400,13 +1409,13 @@ void MetaList::getAlignTypes(const MetaListPost &mlp, vector< pair<string, size_
break;
}
if (currentType != lString)
atypes.insert(make_pair(EPostType(currentType), ""));
atypes.insert(make_pair(lNone, ""));
atypes.insert(make_pair(EPostType(currentType), L""));
atypes.insert(make_pair(lNone, L""));
for (set< pair<EPostType, string> >::iterator it = atypes.begin(); it != atypes.end(); ++it) {
string type = lang.tl(typeToSymbol[it->first]);
for (set< pair<EPostType, wstring> >::iterator it = atypes.begin(); it != atypes.end(); ++it) {
wstring type = lang.tl(typeToSymbol[it->first]);
if (it->first == lString)
type += ":" + it->second;
type += L":" + it->second;
types.push_back(make_pair(type, it->first));
}
}
@ -1432,9 +1441,9 @@ void MetaListPost::serialize(xmlparser &xml) const {
if (leg != -1)
xml.write("Leg", itos(leg));
if (alignType == lString)
xml.write("Align", "BlockAlign", alignBlock, alignWithText);
xml.writeBool("Align", "BlockAlign", alignBlock, alignWithText);
else
xml.write("Align", "BlockAlign", alignBlock, MetaList::typeToSymbol[alignType]);
xml.writeBool("Align", "BlockAlign", alignBlock, MetaList::typeToSymbol[alignType]);
xml.write("BlockWidth", blockWidth);
xml.write("IndentMin", minimalIndent);
if (font != formatIgnore)
@ -1455,10 +1464,10 @@ void MetaListPost::deserialize(const xmlobject &xml) {
if (!xml)
throw meosException("Ogiltigt filformat");
string tp = xml.getAttrib("Type").get();
wstring tp = xml.getAttrib("Type").wget();
if (MetaList::symbolToType.count(tp) == 0) {
string err = "Invalid type X#" + tp;
throw std::exception(err.c_str());
wstring err = L"Invalid type X#" + tp;
throw meosException(err);
}
type = MetaList::symbolToType[tp];
@ -1472,7 +1481,7 @@ void MetaListPost::deserialize(const xmlobject &xml) {
alignBlock = xAlignBlock && xAlignBlock.getObjectBool("BlockAlign");
blockWidth = xml.getObjectInt("BlockWidth");
minimalIndent = xml.getObjectInt("IndentMin");
string at;
wstring at;
xml.getObjectString("Align", at);
if (!at.empty()) {
@ -1486,14 +1495,14 @@ void MetaListPost::deserialize(const xmlobject &xml) {
mergeWithPrevious = xml.getObjectInt("MergePrevious") != 0;
xml.getObjectString("TextAdjust", at);
if (at == "Right")
if (at == L"Right")
textAdjust = textRight;
else if (at == "Center")
else if (at == L"Center")
textAdjust = textCenter;
xml.getObjectString("Color", at);
if (!at.empty()) {
color = (GDICOLOR)(strtol(at.c_str(), 0, 16)&0xFFFFFF);
color = (GDICOLOR)(wcstol(at.c_str(), 0, 16)&0xFFFFFF);
//color = GDICOLOR(atoi(at.c_str()));
}
@ -1508,8 +1517,8 @@ void MetaListPost::deserialize(const xmlobject &xml) {
}
}
map<EPostType, string> MetaList::typeToSymbol;
map<string, EPostType> MetaList::symbolToType;
map<EPostType, wstring> MetaList::typeToSymbol;
map<wstring, EPostType> MetaList::symbolToType;
map<oListInfo::EBaseType, string> MetaList::baseTypeToSymbol;
map<string, oListInfo::EBaseType> MetaList::symbolToBaseType;
map<SortOrder, string> MetaList::orderToSymbol;
@ -1523,151 +1532,151 @@ map<string, ESubFilterList> MetaList::symbolToSubFilter;
void MetaList::initSymbols() {
if (typeToSymbol.empty()) {
typeToSymbol[lAlignNext] = "AlignNext";
typeToSymbol[lNone] = "None";
typeToSymbol[lString] = "String";
typeToSymbol[lResultDescription] = "ResultDescription";
typeToSymbol[lTimingFromName] = "TimingFrom";
typeToSymbol[lTimingToName] = "TimingTo";
typeToSymbol[lCmpName] = "CmpName";
typeToSymbol[lCmpDate] = "CmpDate";
typeToSymbol[lCurrentTime] = "CurrentTime";
typeToSymbol[lClubName] = "ClubName";
typeToSymbol[lClassName] = "ClassName";
typeToSymbol[lClassStartName] = "ClassStartName";
typeToSymbol[lClassStartTime] = "StartTimeForClass";
typeToSymbol[lClassStartTimeRange] = "StartTimeForClassRange";
typeToSymbol[lClassLength] = "ClassLength";
typeToSymbol[lClassResultFraction] = "ClassResultFraction";
typeToSymbol[lCourseLength] = "CourseLength";
typeToSymbol[lCourseName] = "CourseName";
typeToSymbol[lCourseClimb] = "CourseClimb";
typeToSymbol[lCourseUsage] = "CourseUsage";
typeToSymbol[lCourseUsageNoVacant] = "CourseUsageNoVacant";
typeToSymbol[lCourseClasses] = "CourseClasses";
typeToSymbol[lCourseShortening] = "CourseShortening";
typeToSymbol[lRunnerName] = "RunnerName";
typeToSymbol[lRunnerGivenName] = "RunnerGivenName";
typeToSymbol[lRunnerFamilyName] = "RunnerFamilyName";
typeToSymbol[lRunnerCompleteName] = "RunnerCompleteName";
typeToSymbol[lPatrolNameNames] = "PatrolNameNames";
typeToSymbol[lPatrolClubNameNames] = "PatrolClubNameNames";
typeToSymbol[lRunnerFinish] = "RunnerFinish";
typeToSymbol[lRunnerTime] = "RunnerTime";
typeToSymbol[lRunnerTimeStatus] = "RunnerTimeStatus";
typeToSymbol[lRunnerTempTimeStatus] = "RunnerTempTimeStatus";
typeToSymbol[lRunnerTempTimeAfter] = "RunnerTempTimeAfter";
typeToSymbol[lRunnerTimeAfter] = "RunnerTimeAfter";
typeToSymbol[lRunnerClassCourseTimeAfter] = "RunnerClassCourseTimeAfter";
typeToSymbol[lRunnerMissedTime] = "RunnerTimeLost";
typeToSymbol[lRunnerPlace] = "RunnerPlace";
typeToSymbol[lRunnerClassCoursePlace] = "RunnerClassCoursePlace";
typeToSymbol[lRunnerStart] = "RunnerStart";
typeToSymbol[lRunnerStartCond] = "RunnerStartCond";
typeToSymbol[lRunnerStartZero] = "RunnerStartZero";
typeToSymbol[lRunnerClub] = "RunnerClub";
typeToSymbol[lRunnerCard] = "RunnerCard";
typeToSymbol[lRunnerBib] = "RunnerBib";
typeToSymbol[lRunnerStartNo] = "RunnerStartNo";
typeToSymbol[lRunnerRank] = "RunnerRank";
typeToSymbol[lRunnerCourse] = "RunnerCourse";
typeToSymbol[lRunnerRogainingPoint] = "RunnerRogainingPoint";
typeToSymbol[lRunnerRogainingPointTotal] = "RunnerRogainingPointTotal";
typeToSymbol[lRunnerRogainingPointReduction] = "RunnerRogainingReduction";
typeToSymbol[lRunnerRogainingPointOvertime] = "RunnerRogainingOvertime";
typeToSymbol[lRunnerTimeAdjustment] = "RunnerTimeAdjustment";
typeToSymbol[lRunnerPointAdjustment] = "RunnerPointAdjustment";
typeToSymbol[lRunnerRogainingPointGross] = "RunnerRogainingPointGross";
typeToSymbol[lAlignNext] = L"AlignNext";
typeToSymbol[lNone] = L"None";
typeToSymbol[lString] = L"String";
typeToSymbol[lResultDescription] = L"ResultDescription";
typeToSymbol[lTimingFromName] = L"TimingFrom";
typeToSymbol[lTimingToName] = L"TimingTo";
typeToSymbol[lCmpName] = L"CmpName";
typeToSymbol[lCmpDate] = L"CmpDate";
typeToSymbol[lCurrentTime] = L"CurrentTime";
typeToSymbol[lClubName] = L"ClubName";
typeToSymbol[lClassName] = L"ClassName";
typeToSymbol[lClassStartName] = L"ClassStartName";
typeToSymbol[lClassStartTime] = L"StartTimeForClass";
typeToSymbol[lClassStartTimeRange] = L"StartTimeForClassRange";
typeToSymbol[lClassLength] = L"ClassLength";
typeToSymbol[lClassResultFraction] = L"ClassResultFraction";
typeToSymbol[lCourseLength] = L"CourseLength";
typeToSymbol[lCourseName] = L"CourseName";
typeToSymbol[lCourseClimb] = L"CourseClimb";
typeToSymbol[lCourseUsage] = L"CourseUsage";
typeToSymbol[lCourseUsageNoVacant] = L"CourseUsageNoVacant";
typeToSymbol[lCourseClasses] = L"CourseClasses";
typeToSymbol[lCourseShortening] = L"CourseShortening";
typeToSymbol[lRunnerName] = L"RunnerName";
typeToSymbol[lRunnerGivenName] = L"RunnerGivenName";
typeToSymbol[lRunnerFamilyName] = L"RunnerFamilyName";
typeToSymbol[lRunnerCompleteName] = L"RunnerCompleteName";
typeToSymbol[lPatrolNameNames] = L"PatrolNameNames";
typeToSymbol[lPatrolClubNameNames] = L"PatrolClubNameNames";
typeToSymbol[lRunnerFinish] = L"RunnerFinish";
typeToSymbol[lRunnerTime] = L"RunnerTime";
typeToSymbol[lRunnerTimeStatus] = L"RunnerTimeStatus";
typeToSymbol[lRunnerTempTimeStatus] = L"RunnerTempTimeStatus";
typeToSymbol[lRunnerTempTimeAfter] = L"RunnerTempTimeAfter";
typeToSymbol[lRunnerTimeAfter] = L"RunnerTimeAfter";
typeToSymbol[lRunnerClassCourseTimeAfter] = L"RunnerClassCourseTimeAfter";
typeToSymbol[lRunnerMissedTime] = L"RunnerTimeLost";
typeToSymbol[lRunnerPlace] = L"RunnerPlace";
typeToSymbol[lRunnerClassCoursePlace] = L"RunnerClassCoursePlace";
typeToSymbol[lRunnerStart] = L"RunnerStart";
typeToSymbol[lRunnerStartCond] = L"RunnerStartCond";
typeToSymbol[lRunnerStartZero] = L"RunnerStartZero";
typeToSymbol[lRunnerClub] = L"RunnerClub";
typeToSymbol[lRunnerCard] = L"RunnerCard";
typeToSymbol[lRunnerBib] = L"RunnerBib";
typeToSymbol[lRunnerStartNo] = L"RunnerStartNo";
typeToSymbol[lRunnerRank] = L"RunnerRank";
typeToSymbol[lRunnerCourse] = L"RunnerCourse";
typeToSymbol[lRunnerRogainingPoint] = L"RunnerRogainingPoint";
typeToSymbol[lRunnerRogainingPointTotal] = L"RunnerRogainingPointTotal";
typeToSymbol[lRunnerRogainingPointReduction] = L"RunnerRogainingReduction";
typeToSymbol[lRunnerRogainingPointOvertime] = L"RunnerRogainingOvertime";
typeToSymbol[lRunnerTimeAdjustment] = L"RunnerTimeAdjustment";
typeToSymbol[lRunnerPointAdjustment] = L"RunnerPointAdjustment";
typeToSymbol[lRunnerRogainingPointGross] = L"RunnerRogainingPointGross";
typeToSymbol[lRunnerUMMasterPoint] = "RunnerUMMasterPoint";
typeToSymbol[lRunnerTimePlaceFixed] = "RunnerTimePlaceFixed";
typeToSymbol[lRunnerLegNumberAlpha] = "RunnerLegNumberAlpha";
typeToSymbol[lRunnerLegNumber] = "RunnerLegNumber";
typeToSymbol[lRunnerUMMasterPoint] = L"RunnerUMMasterPoint";
typeToSymbol[lRunnerTimePlaceFixed] = L"RunnerTimePlaceFixed";
typeToSymbol[lRunnerLegNumberAlpha] = L"RunnerLegNumberAlpha";
typeToSymbol[lRunnerLegNumber] = L"RunnerLegNumber";
typeToSymbol[lResultModuleTime] = "ResultModuleTime";
typeToSymbol[lResultModuleNumber] = "ResultModuleNumber";
typeToSymbol[lResultModuleTimeTeam] = "ResultModuleTimeTeam";
typeToSymbol[lResultModuleNumberTeam] = "ResultModuleNumberTeam";
typeToSymbol[lResultModuleTime] = L"ResultModuleTime";
typeToSymbol[lResultModuleNumber] = L"ResultModuleNumber";
typeToSymbol[lResultModuleTimeTeam] = L"ResultModuleTimeTeam";
typeToSymbol[lResultModuleNumberTeam] = L"ResultModuleNumberTeam";
typeToSymbol[lRunnerBirthYear] = "RunnerBirthYear";
typeToSymbol[lRunnerAge] = "RunnerAge";
typeToSymbol[lRunnerSex] = "RunnerSex";
typeToSymbol[lRunnerNationality] = "RunnerNationality";
typeToSymbol[lRunnerPhone] = "RunnerPhone";
typeToSymbol[lRunnerFee] = "RunnerFee";
typeToSymbol[lRunnerBirthYear] = L"RunnerBirthYear";
typeToSymbol[lRunnerAge] = L"RunnerAge";
typeToSymbol[lRunnerSex] = L"RunnerSex";
typeToSymbol[lRunnerNationality] = L"RunnerNationality";
typeToSymbol[lRunnerPhone] = L"RunnerPhone";
typeToSymbol[lRunnerFee] = L"RunnerFee";
typeToSymbol[lTeamName] = "TeamName";
typeToSymbol[lTeamStart] = "TeamStart";
typeToSymbol[lTeamStartCond] = "TeamStartCond";
typeToSymbol[lTeamStartZero] = "TeamStartZero";
typeToSymbol[lTeamName] = L"TeamName";
typeToSymbol[lTeamStart] = L"TeamStart";
typeToSymbol[lTeamStartCond] = L"TeamStartCond";
typeToSymbol[lTeamStartZero] = L"TeamStartZero";
typeToSymbol[lTeamTimeStatus] = "TeamTimeStatus";
typeToSymbol[lTeamTimeAfter] = "TeamTimeAfter";
typeToSymbol[lTeamPlace] = "TeamPlace";
typeToSymbol[lTeamLegTimeStatus] = "TeamLegTimeStatus";
typeToSymbol[lTeamLegTimeAfter] = "TeamLegTimeAfter";
typeToSymbol[lTeamRogainingPoint] = "TeamRogainingPoint";
typeToSymbol[lTeamRogainingPointTotal] = "TeamRogainingPointTotal";
typeToSymbol[lTeamRogainingPointReduction] = "TeamRogainingReduction";
typeToSymbol[lTeamRogainingPointOvertime] = "TeamRogainingOvertime";
typeToSymbol[lTeamTimeAdjustment] = "TeamTimeAdjustment";
typeToSymbol[lTeamPointAdjustment] = "TeamPointAdjustment";
typeToSymbol[lTeamTimeStatus] = L"TeamTimeStatus";
typeToSymbol[lTeamTimeAfter] = L"TeamTimeAfter";
typeToSymbol[lTeamPlace] = L"TeamPlace";
typeToSymbol[lTeamLegTimeStatus] = L"TeamLegTimeStatus";
typeToSymbol[lTeamLegTimeAfter] = L"TeamLegTimeAfter";
typeToSymbol[lTeamRogainingPoint] = L"TeamRogainingPoint";
typeToSymbol[lTeamRogainingPointTotal] = L"TeamRogainingPointTotal";
typeToSymbol[lTeamRogainingPointReduction] = L"TeamRogainingReduction";
typeToSymbol[lTeamRogainingPointOvertime] = L"TeamRogainingOvertime";
typeToSymbol[lTeamTimeAdjustment] = L"TeamTimeAdjustment";
typeToSymbol[lTeamPointAdjustment] = L"TeamPointAdjustment";
typeToSymbol[lTeamTime] = "TeamTime";
typeToSymbol[lTeamStatus] = "TeamStatus";
typeToSymbol[lTeamClub] = "TeamClub";
typeToSymbol[lTeamRunner] = "TeamRunner";
typeToSymbol[lTeamRunnerCard] = "TeamRunnerCard";
typeToSymbol[lTeamBib] = "TeamBib";
typeToSymbol[lTeamStartNo] = "TeamStartNo";
typeToSymbol[lPunchNamedTime] = "PunchNamedTime";
typeToSymbol[lPunchTime] = "PunchTime";
typeToSymbol[lPunchControlNumber] = "PunchControlNumber";
typeToSymbol[lPunchControlCode] = "PunchControlCode";
typeToSymbol[lPunchLostTime] = "PunchLostTime";
typeToSymbol[lPunchControlPlace] = "PunchControlPlace";
typeToSymbol[lPunchControlPlaceAcc] = "PunchControlPlaceAcc";
typeToSymbol[lTeamTime] = L"TeamTime";
typeToSymbol[lTeamStatus] = L"TeamStatus";
typeToSymbol[lTeamClub] = L"TeamClub";
typeToSymbol[lTeamRunner] = L"TeamRunner";
typeToSymbol[lTeamRunnerCard] = L"TeamRunnerCard";
typeToSymbol[lTeamBib] = L"TeamBib";
typeToSymbol[lTeamStartNo] = L"TeamStartNo";
typeToSymbol[lPunchNamedTime] = L"PunchNamedTime";
typeToSymbol[lPunchTime] = L"PunchTime";
typeToSymbol[lPunchControlNumber] = L"PunchControlNumber";
typeToSymbol[lPunchControlCode] = L"PunchControlCode";
typeToSymbol[lPunchLostTime] = L"PunchLostTime";
typeToSymbol[lPunchControlPlace] = L"PunchControlPlace";
typeToSymbol[lPunchControlPlaceAcc] = L"PunchControlPlaceAcc";
typeToSymbol[lRogainingPunch] = "RogainingPunch";
typeToSymbol[lTotalCounter] = "TotalCounter";
typeToSymbol[lSubCounter] = "SubCounter";
typeToSymbol[lSubSubCounter] = "SubSubCounter";
typeToSymbol[lTeamFee] = "TeamFee";
typeToSymbol[lRogainingPunch] = L"RogainingPunch";
typeToSymbol[lTotalCounter] = L"TotalCounter";
typeToSymbol[lSubCounter] = L"SubCounter";
typeToSymbol[lSubSubCounter] = L"SubSubCounter";
typeToSymbol[lTeamFee] = L"TeamFee";
typeToSymbol[lRunnerTotalTime] = "RunnerTotalTime";
typeToSymbol[lRunnerTimePerKM] = "RunnerTimePerKM";
typeToSymbol[lRunnerTotalTimeStatus] = "RunnerTotalTimeStatus";
typeToSymbol[lRunnerTotalPlace] = "RunnerTotalPlace";
typeToSymbol[lRunnerTotalTimeAfter] = "RunnerTotalTimeAfter";
typeToSymbol[lRunnerTimeAfterDiff] = "RunnerTimeAfterDiff";
typeToSymbol[lRunnerPlaceDiff] = "RunnerPlaceDiff";
typeToSymbol[lRunnerTotalTime] = L"RunnerTotalTime";
typeToSymbol[lRunnerTimePerKM] = L"RunnerTimePerKM";
typeToSymbol[lRunnerTotalTimeStatus] = L"RunnerTotalTimeStatus";
typeToSymbol[lRunnerTotalPlace] = L"RunnerTotalPlace";
typeToSymbol[lRunnerTotalTimeAfter] = L"RunnerTotalTimeAfter";
typeToSymbol[lRunnerTimeAfterDiff] = L"RunnerTimeAfterDiff";
typeToSymbol[lRunnerPlaceDiff] = L"RunnerPlaceDiff";
typeToSymbol[lRunnerGeneralTimeStatus] = "RunnerGeneralTimeStatus";
typeToSymbol[lRunnerGeneralPlace] = "RunnerGeneralPlace";
typeToSymbol[lRunnerGeneralTimeAfter] = "RunnerGeneralTimeAfter";
typeToSymbol[lRunnerGeneralTimeStatus] = L"RunnerGeneralTimeStatus";
typeToSymbol[lRunnerGeneralPlace] = L"RunnerGeneralPlace";
typeToSymbol[lRunnerGeneralTimeAfter] = L"RunnerGeneralTimeAfter";
typeToSymbol[lTeamTotalTime] = "TeamTotalTime";
typeToSymbol[lTeamTotalTimeStatus] = "TeamTotalTimeStatus";
typeToSymbol[lTeamTotalPlace] = "TeamTotalPlace";
typeToSymbol[lTeamTotalTimeAfter] = "TeamTotalTimeAfter";
typeToSymbol[lTeamTotalTimeDiff] = "TeamTotalTimeDiff";
typeToSymbol[lTeamPlaceDiff] = "TeamPlaceDiff";
typeToSymbol[lTeamTotalTime] = L"TeamTotalTime";
typeToSymbol[lTeamTotalTimeStatus] = L"TeamTotalTimeStatus";
typeToSymbol[lTeamTotalPlace] = L"TeamTotalPlace";
typeToSymbol[lTeamTotalTimeAfter] = L"TeamTotalTimeAfter";
typeToSymbol[lTeamTotalTimeDiff] = L"TeamTotalTimeDiff";
typeToSymbol[lTeamPlaceDiff] = L"TeamPlaceDiff";
typeToSymbol[lCountry] = "Country";
typeToSymbol[lNationality] = "Nationality";
typeToSymbol[lCountry] = L"Country";
typeToSymbol[lNationality] = L"Nationality";
typeToSymbol[lControlName] = "ControlName";
typeToSymbol[lControlCourses] = "ControlCourses";
typeToSymbol[lControlClasses] = "ControlClasses";
typeToSymbol[lControlVisitors] = "ControlVisitors";
typeToSymbol[lControlPunches] = "ControlPunches";
typeToSymbol[lControlMedianLostTime] = "ControlMedianLostTime";
typeToSymbol[lControlMaxLostTime] = "ControlMaxLostTime";
typeToSymbol[lControlMistakeQuotient] = "ControlMistakeQuotient";
typeToSymbol[lControlRunnersLeft] = "ControlRunnersLeft";
typeToSymbol[lControlCodes] = "ControlCodes";
typeToSymbol[lControlName] = L"ControlName";
typeToSymbol[lControlCourses] = L"ControlCourses";
typeToSymbol[lControlClasses] = L"ControlClasses";
typeToSymbol[lControlVisitors] = L"ControlVisitors";
typeToSymbol[lControlPunches] = L"ControlPunches";
typeToSymbol[lControlMedianLostTime] = L"ControlMedianLostTime";
typeToSymbol[lControlMaxLostTime] = L"ControlMaxLostTime";
typeToSymbol[lControlMistakeQuotient] = L"ControlMistakeQuotient";
typeToSymbol[lControlRunnersLeft] = L"ControlRunnersLeft";
typeToSymbol[lControlCodes] = L"ControlCodes";
for (map<EPostType, string>::iterator it = typeToSymbol.begin();
for (map<EPostType, wstring>::iterator it = typeToSymbol.begin();
it != typeToSymbol.end(); ++it) {
symbolToType[it->second] = it->first;
}
@ -1849,17 +1858,17 @@ bool MetaListContainer::load(MetaListType type, const xmlobject &xDef, bool igno
return true;
xmlList xList;
xDef.getObjects("MeOSListDefinition", xList);
string majVer = getMajorVersion();
wstring majVer = getMajorVersion();
bool hasSkipped = false;
if (xList.empty() && strcmp(xDef.getName(), "MeOSListDefinition") == 0)
xList.push_back(xDef);
string err;
wstring err;
for (size_t k = 0; k<xList.size(); k++) {
xmlattrib ver = xList[k].getAttrib("version");
bool newVersion = false;
if (ver) {
string vers = ver.get();
wstring vers = ver.wget();
if (vers > majVer) {
newVersion = true;
}
@ -1869,14 +1878,23 @@ bool MetaListContainer::load(MetaListType type, const xmlobject &xDef, bool igno
try {
data.back().second.load(xList[k]);
}
catch (const std::exception &ex) {
catch (const meosException &ex) {
if (newVersion && ignoreOld)
hasSkipped = true;
else if (err.empty())
err = ex.what();
err = ex.wwhat();
data.pop_back();
}
catch (const std::exception &ex) {
if (newVersion && ignoreOld)
hasSkipped = true;
else if (err.empty()) {
string nw = ex.what();
err.insert(err.begin(), nw.begin(), nw.end());
}
data.pop_back();
}
}
setupIndex(EFirstLoadedList);
@ -1888,9 +1906,16 @@ bool MetaListContainer::load(MetaListType type, const xmlobject &xDef, bool igno
try {
listParam[k].deserialize(xParam[k], *this);
}
catch (const std::exception &ex) {
catch (const meosException &ex) {
if (err.empty())
err = ex.what();
err = ex.wwhat();
listParam.erase(k);
}
catch (const std::exception &ex) {
if (err.empty()) {
string ne = ex.what();
err.insert(err.begin(), ne.begin(), ne.end());
}
listParam.erase(k);
}
}
@ -2055,7 +2080,7 @@ void MetaListContainer::setupListInfo(int firstIndex,
}
}
string MetaListContainer::makeUniqueParamName(const string &nameIn) const {
wstring MetaListContainer::makeUniqueParamName(const wstring &nameIn) const {
int maxValue = -1;
size_t len = nameIn.length();
for (map<int, oListParam>::const_iterator it = listParam.begin(); it != listParam.end(); ++it) {
@ -2064,7 +2089,7 @@ string MetaListContainer::makeUniqueParamName(const string &nameIn) const {
maxValue = max(1, maxValue);
else {
if (it->second.name.substr(0, len) == nameIn) {
int v = atoi(it->second.name.substr(len + 1).c_str());
int v = _wtoi(it->second.name.substr(len + 1).c_str());
if (v > 0)
maxValue = max(v, maxValue);
}
@ -2074,7 +2099,7 @@ string MetaListContainer::makeUniqueParamName(const string &nameIn) const {
if (maxValue == -1)
return nameIn;
else
return nameIn + " " + itos(maxValue + 1);
return nameIn + L" " + itow(maxValue + 1);
}
@ -2102,7 +2127,7 @@ EStdListType MetaListContainer::getType(const int index) const {
return EStdListType(index + EFirstLoadedList);
}
void MetaListContainer::getLists(vector<pair<string, size_t> > &lists, bool markBuiltIn,
void MetaListContainer::getLists(vector<pair<wstring, size_t> > &lists, bool markBuiltIn,
bool resultListOnly, bool noTeamList) const {
lists.clear();
for (size_t k = 0; k<data.size(); k++) {
@ -2116,7 +2141,7 @@ void MetaListContainer::getLists(vector<pair<string, size_t> > &lists, bool mark
if (data[k].first == InternalList) {
if (markBuiltIn)
lists.push_back( make_pair("[" + lang.tl(data[k].second.getListName()) + "]", k) );
lists.push_back( make_pair(L"[" + lang.tl(data[k].second.getListName()) + L"]", k) );
else
lists.push_back( make_pair(lang.tl(data[k].second.getListName()), k) );
}
@ -2149,24 +2174,24 @@ void MetaListContainer::mergeParam(int toInsertAfter, int toMerge, bool showTitl
owner->updateChanged();
}
void MetaListContainer::getMergeCandidates(int toMerge, vector< pair<string, size_t> > &param) const {
void MetaListContainer::getMergeCandidates(int toMerge, vector< pair<wstring, size_t> > &param) const {
param.clear();
for (map<int, oListParam>::const_iterator it = listParam.begin(); it != listParam.end(); ++it) {
if (it->first == toMerge)
continue;
if (it->second.previousList == 0) {
string desc = "Före X#" + it->second.getName();
wstring desc = L"Före X#" + it->second.getName();
param.push_back(make_pair(lang.tl(desc), MAXLISTPARAMID + it->first));
}
if (it->second.nextList == 0) {
string desc = "Efter X#" + it->second.getName();
wstring desc = L"Efter X#" + it->second.getName();
param.push_back(make_pair(lang.tl(desc), it->first));
}
else {
const oListParam &next = getParam(it->second.nextList - 1);
string desc = "Mellan X och Y#" + it->second.getName() + "#" + next.getName();
wstring desc = L"Mellan X och Y#" + it->second.getName() + L"#" + next.getName();
param.push_back(make_pair(lang.tl(desc), it->first));
}
}
@ -2224,12 +2249,12 @@ void MetaListContainer::saveList(int index, const MetaList &ml) {
owner->updateChanged();
}
void MetaList::getFilters(vector< pair<string, bool> > &filters) const {
void MetaList::getFilters(vector< pair<wstring, bool> > &filters) const {
filters.clear();
for (map<EFilterList, string>::const_iterator it = filterToSymbol.begin();
it != filterToSymbol.end(); ++it) {
bool has = this->filter.count(it->first) == 1;
filters.push_back(make_pair(it->second, has));
filters.push_back(make_pair(gdi_main->widen(it->second), has));
}
}
@ -2245,12 +2270,12 @@ void MetaList::setFilters(const vector<bool> &filters) {
}
}
void MetaList::getSubFilters(vector< pair<string, bool> > &filters) const {
void MetaList::getSubFilters(vector< pair<wstring, bool> > &filters) const {
filters.clear();
for (map<ESubFilterList, string>::const_iterator it = subFilterToSymbol.begin();
it != subFilterToSymbol.end(); ++it) {
bool has = this->subFilter.count(it->first) == 1;
filters.push_back(make_pair(it->second, has));
filters.push_back(make_pair(gdi_main->widen(it->second), has));
}
}
@ -2266,9 +2291,9 @@ void MetaList::setSubFilters(const vector<bool> &filters) {
}
}
void MetaList::getResultModule(const oEvent &oe, vector< pair<string, size_t> > &modules, int &currentModule) const {
void MetaList::getResultModule(const oEvent &oe, vector< pair<wstring, size_t> > &modules, int &currentModule) const {
modules.clear();
vector< pair<int, pair<string, string> > > mol;
vector< pair<int, pair<string, wstring> > > mol;
oe.getGeneralResults(false, mol, true);
modules.push_back(make_pair(lang.tl("Standard"), 0));
currentModule = 0;
@ -2281,7 +2306,7 @@ void MetaList::getResultModule(const oEvent &oe, vector< pair<string, size_t> >
}
MetaList &MetaList::setResultModule(const oEvent &oe, int moduleIx) {
vector< pair<int, pair<string, string> > > mol;
vector< pair<int, pair<string, wstring> > > mol;
oe.getGeneralResults(false, mol, false);
if (moduleIx == 0) {
//resultModule = "";
@ -2305,7 +2330,7 @@ MetaList &MetaList::setSupportFromTo(bool from, bool to) {
return *this;
}
void MetaList::getSortOrder(bool forceIncludeCustom, vector< pair<string, size_t> > &orders, int &currentOrder) const {
void MetaList::getSortOrder(bool forceIncludeCustom, vector< pair<wstring, size_t> > &orders, int &currentOrder) const {
orders.clear();
for(map<SortOrder, string>::const_iterator it = orderToSymbol.begin();
it != orderToSymbol.end(); ++it) {
@ -2315,7 +2340,7 @@ void MetaList::getSortOrder(bool forceIncludeCustom, vector< pair<string, size_t
currentOrder = sortOrder;
}
void MetaList::getBaseType(vector< pair<string, size_t> > &types, int &currentType) const {
void MetaList::getBaseType(vector< pair<wstring, size_t> > &types, int &currentType) const {
types.clear();
for(map<oListInfo::EBaseType, string>::const_iterator it = baseTypeToSymbol.begin();
it != baseTypeToSymbol.end(); ++it) {
@ -2327,7 +2352,7 @@ void MetaList::getBaseType(vector< pair<string, size_t> > &types, int &currentTy
currentType = listType;
}
void MetaList::getSubType(vector< pair<string, size_t> > &types, int &currentType) const {
void MetaList::getSubType(vector< pair<wstring, size_t> > &types, int &currentType) const {
types.clear();
oListInfo::EBaseType t;
@ -2362,7 +2387,7 @@ int MetaListContainer::getNumLists(MetaListType t) const {
return num;
}
void MetaListContainer::getListParam( vector< pair<string, size_t> > &param) const {
void MetaListContainer::getListParam( vector< pair<wstring, size_t> > &param) const {
for (map<int, oListParam>::const_iterator it = listParam.begin(); it != listParam.end(); ++it) {
if (it->second.previousList > 0)
continue;
@ -2410,30 +2435,32 @@ oListParam &MetaListContainer::getParam(int index) {
return listParam.find(index)->second;
}
void MetaListContainer::enumerateLists(vector< pair<string, pair<string, string> > > &out) const {
extern gdioutput *gdi_main;
void MetaListContainer::enumerateLists(vector< pair<wstring, pair<string, wstring> > > &out) const {
out.clear();
char bf[260];
getUserFile(bf, "");
vector<string> res;
expandDirectory(bf, "*.meoslist", res);
wchar_t bf[260];
getUserFile(bf, L"");
vector<wstring> res;
expandDirectory(bf, L"*.meoslist", res);
for (size_t k = 0; k < res.size(); k++) {
xmlparser xml(0);
xmlparser xml;
try {
xml.read(res[k].c_str(), 6);
xml.read(res[k], 6);
xmlobject xDef = xml.getObject("MeOSListDefinition");
string name;
wstring name;
xDef.getObjectString("ListName", name);
string origin;
wstring origin;
xDef.getObjectString("ListOrigin", origin);
string uid;
xDef.getObjectString("UID", uid);
if (!origin.empty())
name += MakeDash(" - ") + origin;
name += makeDash(L" - ") + origin;
out.push_back(make_pair(name, make_pair(uid, res[k])));
}
catch (std::exception &) { // Ignore log?!
out.push_back(make_pair("Error? " + res[k], make_pair("?", res[k])));
out.push_back(make_pair(L"Error? " + res[k], make_pair("?", res[k])));
}
}
sort(out.begin(), out.end());
@ -2442,7 +2469,7 @@ void MetaListContainer::enumerateLists(vector< pair<string, pair<string, string>
int MetaList::getResultModuleIndex(oEvent *oe, oListInfo &li, const MetaListPost &lp) const {
if (resultToIndex.empty()) {
vector< pair<int, pair<string, string> > > tagNameList;
vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(false, tagNameList, false);
resultToIndex[""] = -1;
for (size_t k = 0; k < tagNameList.size(); k++) {

View File

@ -33,6 +33,7 @@ enum gdiFonts;
class oEvent;
const string &itos(int);
const wstring &itow(int i);
class Position
{
@ -79,8 +80,8 @@ private:
void deserialize(const xmlobject &xml);
EPostType type;
string text;
string alignWithText;
wstring text;
wstring alignWithText;
string resultModule;
EPostType alignType;
int leg;
@ -96,24 +97,24 @@ public:
MetaListPost(EPostType type_, EPostType align_ = lNone, int leg_ = -1);
MetaListPost &setBlock(int width) {blockWidth = width; return *this;}
MetaListPost &setText(const string &text_) {text = text_; return *this;}
MetaListPost &setText(const wstring &text_) {text = text_; return *this;}
MetaListPost &setResultModule(const string &resMod) {resultModule = resMod; return *this;}
MetaListPost &align(EPostType align_, bool alignBlock_ = true) {alignType = align_; alignBlock = alignBlock_; return *this;}
MetaListPost &align(bool alignBlock_ = true) {return align(lAlignNext, alignBlock_);}
MetaListPost &alignText(const string &t) {alignWithText = t; return *this;}
MetaListPost &alignText(const wstring &t) {alignWithText = t; return *this;}
MetaListPost &mergePrevious(bool m_=true) {mergeWithPrevious = m_; return *this;}
MetaListPost &indent(int ind) {minimalIndent = ind; return *this;}
void getTypes(vector< pair<string, size_t> > &types, int &currentType) const;
void getTypes(vector< pair<wstring, size_t> > &types, int &currentType) const;
const string &getType() const;
const wstring &getType() const;
MetaListPost &setType(EPostType type_) {type = type_; return *this;}
const string &getText() const {return text;}
const wstring &getText() const {return text;}
const string &getResultModule() const {return resultModule;}
const string &getAlignText() const {return alignWithText;}
const wstring &getAlignText() const {return alignWithText;}
int getLeg() const {return leg;}
void setLeg(int leg_) {leg = leg_;}
@ -127,7 +128,7 @@ public:
const string &getFont() const;
void setFont(gdiFonts font_) {font = font_;}
void getFonts(vector< pair<string, size_t> > &fonts, int &currentFont) const;
void getFonts(vector< pair<wstring, size_t> > &fonts, int &currentFont) const;
const string &getTextAdjust() const;
int getTextAdjustNum() const {return textAdjust;}
@ -136,7 +137,7 @@ public:
void setColor(GDICOLOR color);
GDICOLOR getColorValue() const {return color;}
static void getAllFonts(vector< pair<string, size_t> > &fonts);
static void getAllFonts(vector< pair<wstring, size_t> > &fonts);
friend class MetaList;
};
@ -152,17 +153,17 @@ class MetaList {
private:
struct FontInfo {
string font;
wstring font;
int scale;
int extraSpaceAbove;
FontInfo() : scale(0), extraSpaceAbove(0) {}
const vector< pair<string, string> > &serialize(vector< pair<string, string> > &props) const {
const vector< pair<string, wstring> > &serialize(vector< pair<string, wstring> > &props) const {
props[0].first = "scale";
props[0].second = itos(scale);
props[0].second = itow(scale);
props[1].first = "above";
props[1].second = itos(extraSpaceAbove);
props[1].second = itow(extraSpaceAbove);
return props;
}
};
@ -170,8 +171,8 @@ private:
vector< vector< vector<MetaListPost> > > data;
vector<FontInfo> fontFaces;
string listName;
mutable string listOrigin;
wstring listName;
mutable wstring listOrigin;
string tag;
mutable string uniqueIndex;
@ -192,11 +193,11 @@ private:
enum ListIndex {MLHead = 0, MLSubHead = 1, MLList = 2, MLSubList=3};
MetaListPost &add(ListIndex ix, const MetaListPost &post);
void addRow(int ix);
string encode(const string &input) const;
wstring encode(const wstring &input) const;
bool isBreak(int x) const;
static map<EPostType, string> typeToSymbol;
static map<string, EPostType> symbolToType;
static map<EPostType, wstring> typeToSymbol;
static map<wstring, EPostType> symbolToType;
static map<oListInfo::EBaseType, string> baseTypeToSymbol;
static map<string, oListInfo::EBaseType> symbolToBaseType;
@ -228,7 +229,7 @@ public:
bool supportClasses() const;
const string &getListInfo(const oEvent &oe) const;
const wstring &getListInfo(const oEvent &oe) const;
void clearTag() {tag.clear();}
void initUniqueIndex() const;
@ -242,26 +243,26 @@ public:
bool updateResultModule(const DynamicResult &dr, bool updateSimilar);
void getDynamicResults(vector<DynamicResultRef> &resultModules) const;
void getFilters(vector< pair<string, bool> > &filters) const;
void getFilters(vector< pair<wstring, bool> > &filters) const;
void setFilters(const vector<bool> &filters);
void getSubFilters(vector< pair<string, bool> > &filters) const;
void getSubFilters(vector< pair<wstring, bool> > &filters) const;
void setSubFilters(const vector<bool> &filters);
void getResultModule(const oEvent &oe, vector< pair<string, size_t> > &modules, int &currentModule) const;
void getResultModule(const oEvent &oe, vector< pair<wstring, size_t> > &modules, int &currentModule) const;
const string &getResultModule() const {return resultModule;}
MetaList &setSupportFromTo(bool from, bool to);
bool supportFrom() const {return supportFromControl;}
bool supportTo() const {return supportToControl;}
void getSortOrder(bool forceIncludeCustom, vector< pair<string, size_t> > &orders, int &currentOrder) const;
void getBaseType(vector< pair<string, size_t> > &types, int &currentType) const;
void getSubType(vector< pair<string, size_t> > &types, int &currentType) const;
void getSortOrder(bool forceIncludeCustom, vector< pair<wstring, size_t> > &orders, int &currentOrder) const;
void getBaseType(vector< pair<wstring, size_t> > &types, int &currentType) const;
void getSubType(vector< pair<wstring, size_t> > &types, int &currentType) const;
const string &getFontFace(int type) const {return fontFaces[type].font;}
const wstring &getFontFace(int type) const {return fontFaces[type].font;}
int getFontFaceFactor(int type) const {return fontFaces[type].scale;}
int getExtraSpace(int type) const {return fontFaces[type].extraSpaceAbove;}
MetaList &setFontFace(int type, const string &face, int factor) {
MetaList &setFontFace(int type, const wstring &face, int factor) {
fontFaces[type].font = face;
fontFaces[type].scale = factor;
return *this;
@ -274,7 +275,7 @@ public:
void getExistingTypes(vector< pair<string, size_t> > &types) const;
const string &getListName() const {return listName;}
const wstring &getListName() const {return listName;}
oListInfo::EBaseType getListType() const;
oListInfo::ResultType getResultType() const; // Classwise or global
@ -282,7 +283,7 @@ public:
bool hasResults() const {return hasResults_;}
const string &getTag() const {return tag;}
void getAlignTypes(const MetaListPost &mlp, vector< pair<string, size_t> > &types, int &currentType) const;
void getAlignTypes(const MetaListPost &mlp, vector< pair<wstring, size_t> > &types, int &currentType) const;
void getIndex(const MetaListPost &mlp, int &gix, int &lix, int &ix) const;
MetaList &setResultModule(const oEvent &oe, int moduleIx);
@ -294,8 +295,8 @@ public:
MetaList &addFilter(EFilterList f) {filter.insert(f); return *this;}
MetaList &addSubFilter(ESubFilterList f) {subFilter.insert(f); return *this;}
void save(const string &file, const oEvent *oe) const;
void load(const string &file);
void save(const wstring &file, const oEvent *oe) const;
void load(const wstring &file);
bool isValidIx(size_t gIx, size_t lIx, size_t ix) const;
@ -305,7 +306,7 @@ public:
void interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par,
int lineHeight, oListInfo &li) const;
MetaList &setListName(const string &title) {listName = title; return *this;}
MetaList &setListName(const wstring &title) {listName = title; return *this;}
MetaListPost &addNew(int groupIx, int lineIx, int &ix);
MetaListPost &getMLP(int groupIx, int lineIx, int ix);
@ -353,7 +354,7 @@ public:
string getUniqueId(EStdListType code) const;
EStdListType getCodeFromUnqiueId(const string &id) const;
string makeUniqueParamName(const string &nameIn) const;
wstring makeUniqueParamName(const wstring &nameIn) const;
bool updateResultModule(const DynamicResult &res, bool updateSimilar);
@ -375,7 +376,7 @@ public:
MetaList &addExternal(const MetaList &ml);
void clearExternal();
void getLists(vector< pair<string, size_t> > &lists,
void getLists(vector< pair<wstring, size_t> > &lists,
bool markBuiltIn,
bool resultListOnly,
bool noTeamList) const;
@ -395,17 +396,17 @@ public:
void setupListInfo(int firstIndex, map<EStdListType, oListInfo> &listMap, bool resultsOnly) const;
void setupIndex(int firstIndex) const;
void getListParam( vector< pair<string, size_t> > &param) const;
void getListParam( vector< pair<wstring, size_t> > &param) const;
void removeParam(int index);
void addListParam(oListParam &listParam);
void mergeParam(int toInsertAfter, int toMerge, bool showTitleBetween);
void getMergeCandidates(int toMerge, vector< pair<string, size_t> > &param) const;
void getMergeCandidates(int toMerge, vector< pair<wstring, size_t> > &param) const;
bool canSplit(int index) const;
void split(int index);
bool interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par,
int lineHeight, oListInfo &li) const;
void enumerateLists(vector< pair<string, pair<string, string> > > &out) const;
void enumerateLists(vector< pair<wstring, pair<string, wstring> > > &out) const;
};

View File

@ -47,10 +47,10 @@ MethodEditor::MethodEditor(oEvent *oe_) {
}
MethodEditor::~MethodEditor() {
setCurrentResult(0, "");
setCurrentResult(0, L"");
}
void MethodEditor::setCurrentResult(DynamicResult *lst, const string &fileSrc) {
void MethodEditor::setCurrentResult(DynamicResult *lst, const wstring &fileSrc) {
delete currentResult;
currentResult = lst;
fileNameSource = fileSrc;
@ -74,7 +74,7 @@ void MethodEditor::show(gdioutput &gdi) {
gdi.pushX();
gdi.setCX(gdi.getCX() + gdi.scaleLength(6));
if (currentResult)
gdi.addString("", boldLarge, MakeDash("Result Module - X#") + currentResult->getName(true));
gdi.addString("", boldLarge, makeDash(L"Result Module - X#") + currentResult->getName(true));
else
gdi.addString("", boldLarge, "Edit Result Modules");
@ -109,32 +109,32 @@ void MethodEditor::show(gdioutput &gdi) {
if (currentResult->getTag().empty())
currentResult->setTag(uniqueTag("result"));
gdi.addInput("Name", currentResult->getName(false), 20, methodCB, "Name of result module:");
gdi.addInput("Name", currentResult->getName(false), 20, methodCB, L"Name of result module:");
string tag = currentResult->getTag();
vector<int> listIx;
oe->getListContainer().getListsByResultModule(tag, listIx);
string udtag = DynamicResult::undecorateTag(tag);
gdi.addInput("Tag", udtag, 20, methodCB, "Result module identifier:");
gdi.addInput("Tag", gdi.widen(udtag), 20, methodCB, L"Result module identifier:");
if (!listIx.empty()) {
gdi.disableInput("Tag");
gdi.getBaseInfo("Tag").setExtra(1);
string lists = oe->getListContainer().getList(listIx.front()).getListName();
wstring lists = oe->getListContainer().getList(listIx.front()).getListName();
if (listIx.size() > 1)
lists += ", ...";
gdi.addString("", 0, "Resultatmodulen används i X.#" + lists);
lists += L", ...";
gdi.addString("", 0, L"Resultatmodulen används i X.#" + lists);
}
string desc = currentResult->getDescription();
wstring desc = currentResult->getDescription();
if (wasLoadedBuiltIn)
desc = lang.tl(desc);
gdi.addInputBox("Desc", 300, 70, desc, methodCB, "Description:");
gdi.addInputBox("Desc", 300, 70, desc, methodCB, L"Description:");
gdi.dropLine();
gdi.fillRight();
gdi.addSelection("Method", 200, 200, methodCB, "Edit rule for:");
gdi.addSelection("Method", 200, 200, methodCB, L"Edit rule for:");
vector< pair<DynamicResult::DynamicMethods, string> > mt;
currentResult->getMethodTypes(mt);
@ -158,7 +158,7 @@ void MethodEditor::show(gdioutput &gdi) {
}
bool MethodEditor::checkTag(const string &tag, bool throwError) const {
vector< pair<int, pair<string, string> > > tagNameList;
vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(false, tagNameList, false);
for (size_t k = 0; k < tag.length(); k++) {
char c = tag[k];
@ -189,7 +189,7 @@ bool MethodEditor::checkTag(const string &tag, bool throwError) const {
}
string MethodEditor::uniqueTag(const string &tag) const {
vector< pair<int, pair<string, string> > > tagNameList;
vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(false, tagNameList, false);
set<string> tags;
for (size_t k = 0; k < tagNameList.size(); k++)
@ -220,22 +220,22 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
ofstream fout("methoddoc.txt");
DynamicResult dr;
dr.declareSymbols(DynamicResult::MRScore, true);
vector< pair<string, size_t> > symbs;
vector< pair<wstring, size_t> > symbs;
dr.getSymbols(symbs);
fout << "#head{" << lang.tl("Deltagare") << "}\n#table{2}" << endl;
fout << "#head{" << gdi.toUTF8(lang.tl("Deltagare")) << "}\n#table{2}" << endl;
for (size_t k = 0; k < symbs.size(); k++) {
string name, desc;
wstring name, desc;
dr.getSymbolInfo(symbs[k].second, name, desc);
fout << "{#mono{" << name << "}}{" << lang.tl(desc) << "}" << endl;
fout << "{#mono{" << gdi.toUTF8(name) << "}}{" << gdi.toUTF8(lang.tl(desc)) << "}" << endl;
}
dr.declareSymbols(DynamicResult::MTScore, true);
dr.getSymbols(symbs);
fout << "#head{" << lang.tl("Lag") << "}\n#table{2}" << endl;
fout << "#head{" << gdi.toUTF8(lang.tl("Lag")) << "}\n#table{2}" << endl;
for (size_t k = 0; k < symbs.size(); k++) {
string name, desc;
wstring name, desc;
dr.getSymbolInfo(symbs[k].second, name, desc);
fout << "{#mono{" << name << "}}{" << lang.tl(desc) << "}" << endl;
fout << "{#mono{" << gdi.toUTF8(name) << "}}{" << gdi.toUTF8(lang.tl(desc)) << "}" << endl;
}
}
else if (bi.id == "NewRules") {
@ -245,7 +245,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.setData("MethodEditorClz", this);
gdi.addString("", boldLarge, "New Set of Result Rules");
setCurrentResult(new DynamicResult(), "");
setCurrentResult(new DynamicResult(), L"");
wasLoadedBuiltIn = false;
currentResult->setName(lang.tl("Result Calculation"));
currentIndex = -1;
@ -258,17 +258,17 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
return 0;
checkChangedSave(gdi);
string fileName;
wstring fileName;
int ix = 0;
vector< pair<string, string> > ext;
ext.push_back(make_pair("xml-data", "*.rules"));
fileName = gdi.browseForSave(ext, "rules", ix);
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"xml-data", L"*.rules"));
fileName = gdi.browseForSave(ext, L"rules", ix);
if (fileName.empty())
return 0;
saveSettings(gdi);
string path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
wstring path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
currentResult->save(path);
fileNameSource = path;
oe->loadGeneralResults(true);
@ -284,7 +284,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
saveSettings(gdi);
checkChangedSave(gdi);
string path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
wstring path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
currentResult->save(path);
fileNameSource = path;
@ -300,7 +300,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
continue;
if (utag == DynamicResult::undecorateTag(mtag)) {
doUpdate = gdi.ask("Vill du uppdatera resultatlistorna i den öppande tävlingen?");
doUpdate = gdi.ask(L"Vill du uppdatera resultatlistorna i den öppande tävlingen?");
break;
}
}
@ -319,14 +319,14 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
else if (bi.id == "Remove") {
if (!currentResult)
return 0;
if (gdi.ask("Vill du ta bort 'X'?#" + currentResult->getName(true))) {
string path = fileNameSource;//getInternalPath(currentResult->getTag());
string rm = path + ".removed";
if (gdi.ask(L"Vill du ta bort 'X'?#" + currentResult->getName(true))) {
wstring path = fileNameSource;//getInternalPath(currentResult->getTag());
wstring rm = path + L".removed";
DeleteFile(rm.c_str());
rename(path.c_str(), rm.c_str());
_wrename(path.c_str(), rm.c_str());
oe->loadGeneralResults(true);
makeDirty(gdi, ClearDirty);
setCurrentResult(0, "");
setCurrentResult(0, L"");
gdi.clearPage(false);
show(gdi);
}
@ -336,9 +336,9 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
if (!checkSave(gdi))
return 0;
vector< pair<string, string> > ext;
ext.push_back(make_pair("xml-data", "*.rules"));
string fileName = gdi.browseForOpen(ext, "rules");
vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair(L"xml-data", L"*.rules"));
wstring fileName = gdi.browseForOpen(ext, L"rules");
if (fileName.empty())
return 0;
@ -352,7 +352,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
wasLoadedBuiltIn = false;
setCurrentResult(tmp, "");
setCurrentResult(tmp, L"");
currentIndex = -1;
gdi.clearPage(false);
@ -369,26 +369,26 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.setData("MethodEditorClz", this);
gdi.pushX();
vector< pair<string, size_t> > lists;
vector< pair<wstring, size_t> > lists;
//oe->getListContainer().getLists(lists);
vector< pair<int, pair<string, string> > > tagNameList;
vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(true, tagNameList, true);
for (size_t k = 0; k < tagNameList.size(); k++) {
string tag = tagNameList[k].second.first;
string utag = DynamicResult::undecorateTag(tag);
vector<int> listIx;
oe->getListContainer().getListsByResultModule(tag, listIx);
string n = tagNameList[k].second.second + " (" + utag + ")";
wstring n = tagNameList[k].second.second + L" (" + gdi.widen(utag) + L")";
if (listIx.size() > 0) {
n += " *";
n += L" *";
}
lists.push_back(make_pair(n, tagNameList[k].first));
}
sort(lists.begin(), lists.end());
gdi.fillRight();
gdi.addSelection("OpenList", 350, 400, methodCB, "Choose result module:", "Rader markerade med (*) kommer från en lista i tävlingen.");
gdi.addSelection("OpenList", 350, 400, methodCB, L"Choose result module:", L"Rader markerade med (*) kommer från en lista i tävlingen.");
gdi.addItem("OpenList", lists);
gdi.autoGrow("OpenList");
gdi.selectFirstItem("OpenList");
@ -398,7 +398,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.addButton("DoOpenCopy", "Open a Copy", methodCB);
if (!lists.empty()) {
string srcFile;
wstring srcFile;
bool ro = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList.front().second.first, srcFile)).isReadOnly();
gdi.setInputStatus("DoOpen", !ro);
@ -416,7 +416,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
ListBoxInfo lbi;
DynamicResult *dr = 0;
if (gdi.getSelectedItem("OpenList", lbi)) {
vector< pair<int, pair<string, string> > > tagNameList;
vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(true, tagNameList, false);
size_t ix = -1;
for (size_t k = 0; k < tagNameList.size(); k++) {
@ -427,14 +427,14 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
if (ix < tagNameList.size()) {
string srcFile;
wstring srcFile;
DynamicResult &drIn = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList[ix].second.first, srcFile));
wasLoadedBuiltIn = drIn.isReadOnly();
dr = new DynamicResult(drIn);
if (bi.id == "DoOpenCopy") {
dr->setTag(uniqueTag("result"));
dr->setName(lang.tl("Copy of ") + dr->getName(false));
setCurrentResult(dr, "");
setCurrentResult(dr, L"");
}
else
setCurrentResult(dr, srcFile);
@ -458,7 +458,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
if (!checkSave(gdi))
return 0;
setCurrentResult(0, "");
setCurrentResult(0, L"");
makeDirty(gdi, ClearDirty);
currentIndex = -1;
gdi.getTabs().get(TListTab)->loadPage(gdi);
@ -466,9 +466,9 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
else if (bi.id == "SaveSource") {
DynamicResult::DynamicMethods dm = DynamicResult::DynamicMethods(bi.getExtraInt());
string src = gdi.getText("Source");
string src = gdi.narrow(gdi.getText("Source"));
currentResult->setMethodSource(dm, src);
gdi.setText("Source", src);
gdi.setText("Source", gdi.widen(src));
}
else if (bi.id == "CancelSource") {
checkChangedSave(gdi);
@ -520,7 +520,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
int yp = gdi.getCY();
int diff = gdi.scaleLength(3);
const int w[5] = {200, 70, 70, 70, 85};
set<string> errors;
set<wstring> errors;
currentResult->prepareCalculations(*oe, tr.size()>0, inputNumber);
for (size_t k = 0; k < rr.size(); k++) {
@ -532,16 +532,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
int rt = 0, pt = 0;
RunnerStatus st = StatusUnknown;
{
string err;
string str;
wstring err;
wstring str;
try {
st = currentResult->deduceStatus(*rr[k]);
str = oe->formatStatus(st);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -552,16 +552,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
txp += w[wi++];
}
{
string err;
string str;
wstring err;
wstring str;
try {
rt = currentResult->deduceTime(*rr[k], rr[k]->getStartTime());
str = formatTime(rt);
str = formatTimeW(rt);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -572,16 +572,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
{
string err;
string str;
wstring err;
wstring str;
try {
pt = currentResult->deducePoints(*rr[k]);
str = itos(pt);
str = itow(pt);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -592,16 +592,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
{
string err;
string str;
wstring err;
wstring str;
try {
int score = currentResult->score(*rr[k], st, rt, pt, false);
str = itos(score);
str = itow(score);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -634,16 +634,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
int rt = 0, pt = 0;
RunnerStatus st = StatusUnknown;
{
string err;
string str;
wstring err;
wstring str;
try {
st = currentResult->deduceStatus(*tr[k]);
str = oe->formatStatus(st);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -653,16 +653,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
txp += w[wi++];
}
{
string err;
string str;
wstring err;
wstring str;
try {
rt = currentResult->deduceTime(*tr[k]);
str = formatTime(rt);
str = formatTimeW(rt);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -673,16 +673,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
{
string err;
string str;
wstring err;
wstring str;
try {
pt = currentResult->deducePoints(*tr[k]);
str = itos(pt);
str = itow(pt);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -693,16 +693,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
{
string err;
string str;
wstring err;
wstring str;
try {
int score = currentResult->score(*tr[k], st, rt, pt);
str = itos(score);
str = itow(score);
}
catch (meosException &ex) {
err = ex.what();
errors.insert(ex.what());
str = "Error";
err = ex.wwhat();
errors.insert(ex.wwhat());
str = L"Error";
}
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) {
@ -738,11 +738,11 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.pushX();
gdi.setRestorePoint("NoSourceEdit");
gdi.addInputBox("Source", 450, 300,
src,
methodCB, "Source code:").setFont(gdi, monoText);
gdi.widen(src),
methodCB, L"Source code:").setFont(gdi, monoText);
gdi.fillDown();
gdi.setCX(gdi.getCX() + gdi.getLineHeight());
gdi.addListBox("Symbols", 450, 300-20, methodCB, "Available symbols:");
gdi.addListBox("Symbols", 450, 300-20, methodCB, L"Available symbols:");
gdi.setTabStops("Symbols", 180);
gdi.addString("SymbInfo", gdi.getCY(), gdi.getCX(), 0, "", 350, 0);
gdi.popX();
@ -751,21 +751,21 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.scrollToBottom();
}
else {
gdi.setText("Source", src);
gdi.setText("Source", gdi.widen(src));
}
currentResult->declareSymbols(m, true);
vector< pair<string, size_t> > symb;
vector< pair<wstring, size_t> > symb;
currentResult->getSymbols(symb);
gdi.addItem("Symbols", symb);
}
else if (lbi.id == "Symbols") {
string name, desc;
wstring name, desc;
currentResult->getSymbolInfo(lbi.data, name, desc);
gdi.setText("SymbInfo", name + ":" + lang.tl(desc) +".", true);
gdi.setText("SymbInfo", name + L":" + lang.tl(desc) + L".", true);
}
else if (lbi.id == "OpenList") {
vector< pair<int, pair<string, string> > > tagNameList;
vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(true, tagNameList, false);
size_t ix = -1;
for (size_t k = 0; k < tagNameList.size(); k++) {
@ -774,7 +774,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
break;
}
}
string srcFile;
wstring srcFile;
if (ix < tagNameList.size()) {
bool ro = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList[ix].second.first, srcFile)).isReadOnly();
gdi.setInputStatus("DoOpen", !ro);
@ -786,7 +786,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
else if (type == GUI_LISTBOXSELECT) {
ListBoxInfo &lbi = dynamic_cast<ListBoxInfo &>(data);
if (lbi.id == "Symbols") {
string name, desc;
wstring name, desc;
currentResult->getSymbolInfo(lbi.data, name, desc);
gdi.replaceSelection("Source", name);
}
@ -818,21 +818,21 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
}
void MethodEditor::saveSettings(gdioutput &gdi) {
string name = gdi.getText("Name");
wstring name = gdi.getText("Name");
string tag;
const bool updateTag = gdi.getBaseInfo("Tag").getExtraInt() == 0;
if (updateTag)
tag = gdi.getText("Tag");
tag = gdi.narrow(gdi.getText("Tag"));
else
tag = currentResult->getTag();
string desc = gdi.getText("Desc");
wstring desc = gdi.getText("Desc");
if (_strcmpi(currentResult->getTag().c_str(), tag.c_str()) != 0) {
checkTag(tag, true);
string oldPath = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
string path = getInternalPath(tag);
rename(oldPath.c_str(), path.c_str());
wstring oldPath = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
wstring path = getInternalPath(tag);
_wrename(oldPath.c_str(), path.c_str());
fileNameSource = path;
}
@ -840,7 +840,7 @@ void MethodEditor::saveSettings(gdioutput &gdi) {
currentResult->setName(name);
currentResult->setDescription(desc);
gdi.setText("Name", name);
gdi.setText("Tag", tag);
gdi.setText("Tag", gdi.widen(tag));
gdi.setText("Desc", desc);
}
@ -874,7 +874,7 @@ void MethodEditor::makeDirty(gdioutput &gdi, DirtyFlag inside) {
bool MethodEditor::checkSave(gdioutput &gdi) {
if (dirtyInt) {
gdioutput::AskAnswer answer = gdi.askCancel("Vill du spara ändringar?");
gdioutput::AskAnswer answer = gdi.askCancel(L"Vill du spara ändringar?");
if (answer == gdioutput::AnswerCancel)
return false;
@ -891,24 +891,25 @@ void MethodEditor::checkChangedSave(gdioutput &gdi) {
if (gdi.hasField("Source")) {
gdi.getText("Source");
if (dynamic_cast<InputInfo &>(gdi.getBaseInfo("Source")).changed() &&
gdi.ask("Save changes in rule code?")) {
gdi.ask(L"Save changes in rule code?")) {
DynamicResult::DynamicMethods dm = DynamicResult::DynamicMethods(gdi.getExtraInt("SaveSource"));
string src = gdi.getText("Source");
string src = gdi.narrow(gdi.getText("Source"));
currentResult->setMethodSource(dm, src);
gdi.setText("Source", src);
gdi.setText("Source", gdi.widen(src));
}
}
}
extern gdioutput *gdi_main;
string MethodEditor::getInternalPath(const string &tag) {
wstring MethodEditor::getInternalPath(const string &tag) {
string udTag = DynamicResult::undecorateTag(tag);
string resFile;
wstring resFile;
if (udTag == tag)
resFile = tag + ".rules";
resFile = gdi_main->widen(tag) + L".rules";
else
resFile = "imp_" + udTag + ".rules";
resFile = L"imp_" + gdi_main->widen(udTag) + L".rules";
char path[260];
wchar_t path[260];
getUserFile(path, resFile.c_str());
return path;
}
@ -940,7 +941,7 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
throw meosException("Internal error");
gdioutput *gdi_new = getExtraWindow("debug", true);
string title = lang.tl("Debug X for Y#" + currentResult->getName(false) + "#" + art->getName());
wstring title = lang.tl(L"Debug X for Y#" + currentResult->getName(false) + L"#" + art->getName());
if (!gdi_new)
gdi_new = createExtraWindow("debug", title,
@ -963,23 +964,23 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
st = currentResult->deduceStatus(r);
currentResult->debugDumpVariables(gdi, true);
gdi.addStringUT(1, "ComputedStatus: " + oe->formatStatus(st)).setColor(colorGreen);
gdi.addStringUT(1, L"ComputedStatus: " + oe->formatStatus(st)).setColor(colorGreen);
}
catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what());
gdi.addString("", 0, "Status Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Status Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MDeduceRStatus))
currentResult->debugDumpVariables(gdi, false);
try {
rt = currentResult->deduceTime(r, r.getStartTime());
gdi.addStringUT(1, "ComputedTime: " + formatTime(rt)).setColor(colorGreen);
gdi.addStringUT(1, L"ComputedTime: " + formatTimeW(rt)).setColor(colorGreen);
}
catch (meosException &ex) {
string err = lang.tl(ex.what());
gdi.addString("", 0, "Time Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Time Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MDeduceRTime))
currentResult->debugDumpVariables(gdi, false);
@ -989,8 +990,8 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
gdi.addStringUT(1, "ComputedPoints: " + itos(pt)).setColor(colorGreen);
}
catch (meosException &ex) {
string err = lang.tl(ex.what());
gdi.addString("", 0, "Points Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Points Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MDeduceRPoints))
currentResult->debugDumpVariables(gdi, true);
@ -1001,8 +1002,8 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
}
catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what());
gdi.addString("", 0, "Score Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Score Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MRScore))
currentResult->debugDumpVariables(gdi, false);
@ -1017,23 +1018,23 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
st = currentResult->deduceStatus(t);
currentResult->debugDumpVariables(gdi, true);
gdi.addStringUT(1, "ComputedStatus: " + oe->formatStatus(st)).setColor(colorGreen);
gdi.addStringUT(1, L"ComputedStatus: " + oe->formatStatus(st)).setColor(colorGreen);
}
catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what());
gdi.addString("", 0, "Status Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Status Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MDeduceTStatus))
currentResult->debugDumpVariables(gdi, false);
try {
rt = currentResult->deduceTime(t);
gdi.addStringUT(1, "ComputedTime: " + formatTime(rt)).setColor(colorGreen);
gdi.addStringUT(1, L"ComputedTime: " + formatTimeW(rt)).setColor(colorGreen);
}
catch (meosException &ex) {
string err = lang.tl(ex.what());
gdi.addString("", 0, "Time Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Time Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MDeduceRTime))
currentResult->debugDumpVariables(gdi, false);
@ -1043,8 +1044,8 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
gdi.addStringUT(1, "ComputedPoints: " + itos(pt)).setColor(colorGreen);
}
catch (meosException &ex) {
string err = lang.tl(ex.what());
gdi.addString("", 0, "Points Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Points Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MDeduceTPoints))
currentResult->debugDumpVariables(gdi, true);
@ -1055,8 +1056,8 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
}
catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what());
gdi.addString("", 0, "Status Calculation Failed: X#" + err).setColor(colorRed);
wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, L"Status Calculation Failed: X#" + err).setColor(colorRed);
}
if (currentResult->hasMethod(DynamicResult::MTScore))
currentResult->debugDumpVariables(gdi, false);

View File

@ -35,8 +35,8 @@ private:
enum SaveType {NotSaved, SavedInside, SavedFile};
oEvent *oe;
DynamicResult *currentResult;
string fileNameSource;
void setCurrentResult(DynamicResult *lst, const string &src);
wstring fileNameSource;
void setCurrentResult(DynamicResult *lst, const wstring &src);
int currentIndex;
bool dirtyInt;
bool wasLoadedBuiltIn;
@ -57,7 +57,7 @@ private:
bool checkTag(const string &tag, bool throwError) const;
string uniqueTag(const string &tag) const;
static string getInternalPath(const string &tag);
static wstring getInternalPath(const string &tag);
void saveSettings(gdioutput &gdi);

View File

@ -50,7 +50,7 @@
#define fseeko64 fseek
#else
#ifdef _MSC_VER
#define fopen64 fopen
#define fopen64 _wfopen
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
#define ftello64 _ftelli64
#define fseeko64 _fseeki64

View File

@ -29,9 +29,9 @@
#include "meosdb/sqltypes.h"
#include <process.h>
MySQLReconnect::MySQLReconnect(const string &errorIn) : AutoMachine("MySQL-daemon"), error(errorIn)
MySQLReconnect::MySQLReconnect(const wstring &errorIn) : AutoMachine("MySQL-daemon"), error(errorIn)
{
timeError = getLocalTime();
timeError = getLocalTimeW();
hThread=0;
}
@ -46,8 +46,8 @@ bool MySQLReconnect::stop()
if (interval==0)
return true;
return MessageBox(0, "If this daemon is stopped, then MeOS will not reconnect to the network. Continue?",
"Warning", MB_YESNO|MB_ICONWARNING)==IDYES;
return MessageBox(0, L"If this daemon is stopped, then MeOS will not reconnect to the network. Continue?",
L"Warning", MB_YESNO|MB_ICONWARNING)==IDYES;
}
static CRITICAL_SECTION CS_MySQL;
@ -105,12 +105,12 @@ void MySQLReconnect::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast)
mysqlStatus=0;
char bf[256];
if (!oe->reConnect(bf)) {
gdi.addInfoBox("", "warning:dbproblem#" + string(bf), 9000);
gdi.addInfoBox("", L"warning:dbproblem#" + gdi.widen(bf), 9000);
interval = 10;
}
else {
gdi.addInfoBox("", "Återansluten mot databasen, tävlingen synkroniserad.", 10000);
timeReconnect = getLocalTime();
gdi.addInfoBox("", L"Återansluten mot databasen, tävlingen synkroniserad.", 10000);
timeReconnect = getLocalTimeW();
gdi.setDBErrorState(false);
gdi.setWindowTitle(oe->getTitleName());
interval=0;
@ -145,15 +145,15 @@ void MySQLReconnect::status(gdioutput &gdi) {
gdi.addString("", 1, name);
gdi.pushX();
if (interval>0){
gdi.addStringUT(1, timeError + ": " + lang.tl("DATABASE ERROR")).setColor(colorDarkRed);
gdi.addStringUT(1, timeError + L": " + lang.tl("DATABASE ERROR")).setColor(colorDarkRed);
gdi.fillRight();
gdi.addString("", 0, "Nästa försök:");
gdi.addTimer(gdi.getCY(), gdi.getCX()+10, timerCanBeNegative, (GetTickCount()-timeout)/1000);
}
else {
gdi.addStringUT(0, timeError + ": " + lang.tl("DATABASE ERROR")).setColor(colorDarkGrey);
gdi.addStringUT(0, timeError + L": " + lang.tl("DATABASE ERROR")).setColor(colorDarkGrey);
gdi.fillRight();
gdi.addStringUT(0, timeReconnect + ":");
gdi.addStringUT(0, timeReconnect + L":");
gdi.addString("", 1, "Återansluten mot databasen, tävlingen synkroniserad.").setColor(colorDarkGreen);
gdi.dropLine();
gdi.fillDown();

View File

@ -70,8 +70,13 @@ int TabCompetition::newGuideCB(gdioutput &gdi, int type, void *data)
else if (bi.id == "DoImportEntries") {
createCompetition(gdi);
try {
gdi.autoRefresh(true);
saveEntries(gdi, false, true);
gdi.autoRefresh(true);
FlowOperation res = saveEntries(gdi, false, true);
if (res != FlowContinue) {
if (res == FlowCancel)
newCompetitionGuide(gdi, 1);
return 0;
}
}
catch (std::exception &) {
newCompetitionGuide(gdi, 1);
@ -216,7 +221,7 @@ int TabCompetition::newGuideCB(gdioutput &gdi, int type, void *data)
}
if (t <= 0 || d <= 0) {
gdi.setTextTranslate("AllowedInterval", "Felaktigt datum/tid", true);
gdi.setTextTranslate("AllowedInterval", L"Felaktigt datum/tid", true);
}
else {
long long absT = SystemTimeToInt64Second(st);
@ -224,7 +229,7 @@ int TabCompetition::newGuideCB(gdioutput &gdi, int type, void *data)
long long stopT = absT + 23 * 3600;
SYSTEMTIME start = Int64SecondToSystemTime(absT);
SYSTEMTIME end = Int64SecondToSystemTime(stopT);
string s = "Tävlingen måste avgöras mellan X och Y.#" + convertSystemTime(start) + "#" + convertSystemTime(end);
wstring s = L"Tävlingen måste avgöras mellan X och Y.#" + convertSystemTimeW(start) + L"#" + convertSystemTimeW(end);
gdi.setTextTranslate("AllowedInterval", s, true);
}
}
@ -252,13 +257,13 @@ void TabCompetition::newCompetitionGuide(gdioutput &gdi, int step) {
gdi.addString("", fontMediumPlus, "Namn och tidpunkt");
gdi.dropLine(0.5);
gdi.addInput("Name", lang.tl("Ny tävling"), 34, 0, "Tävlingens namn:");
gdi.addInput("Name", lang.tl("Ny tävling"), 34, 0, L"Tävlingens namn:");
gdi.pushX();
gdi.fillRight();
InputInfo &date = gdi.addInput("Date", getLocalDate(), 16, NewGuideCB, "Datum (för första start):");
InputInfo &date = gdi.addInput("Date", getLocalDateW(), 16, NewGuideCB, L"Datum (för första start):");
gdi.addInput("FirstStart", "07:00:00", 12, NewGuideCB, "Första tillåtna starttid:");
gdi.addInput("FirstStart", L"07:00:00", 12, NewGuideCB, L"Första tillåtna starttid:");
gdi.popX();
gdi.fillDown();
@ -375,18 +380,18 @@ void TabCompetition::entryChoice(gdioutput &gdi) {
}
void TabCompetition::createCompetition(gdioutput &gdi) {
string name = gdi.getText("Name");
string date = gdi.getText("Date");
string start = gdi.getText("FirstStart");
wstring name = gdi.getText("Name");
wstring date = gdi.getText("Date");
wstring start = gdi.getText("FirstStart");
oe->newCompetition("tmp");
oe->newCompetition(L"tmp");
oe->setName(name);
oe->setDate(date);
int t = convertAbsoluteTimeHMS(start, -1);
if (t > 0 && t < 3600*24) {
t = max(0, t-3600);
oe->setZeroTime(formatTimeHMS(t));
oe->setZeroTime(formatTimeHMSW(t));
}
else
throw meosException("Ogiltig tid");

View File

@ -100,11 +100,11 @@ __int64 oBase::getExtIdentifier() const
return getDCI().getInt64("ExtId");
}
string oBase::getExtIdentifierString() const {
wstring oBase::getExtIdentifierString() const {
__int64 raw = getExtIdentifier();
char res[16];
wchar_t res[16];
if (raw == 0)
return "";
return L"";
if (raw & BaseGenStringFlag)
convertDynamicBase(raw & ExtStringMask, 256-32, res);
else if (raw & Base36StringFlag)
@ -114,7 +114,7 @@ string oBase::getExtIdentifierString() const {
return res;
}
void oBase::converExtIdentifierString(__int64 raw, char bf[16]) {
void oBase::converExtIdentifierString(__int64 raw, wchar_t bf[16]) {
if (raw & BaseGenStringFlag)
convertDynamicBase(raw & ExtStringMask, 256-32, bf);
else if (raw & Base36StringFlag)
@ -123,7 +123,7 @@ void oBase::converExtIdentifierString(__int64 raw, char bf[16]) {
convertDynamicBase(raw, 10, bf);
}
__int64 oBase::converExtIdentifierString(const string &str) {
__int64 oBase::converExtIdentifierString(const wstring &str) {
__int64 val;
int base = convertDynamicBase(str, val);
if (base == 36)
@ -133,7 +133,7 @@ __int64 oBase::converExtIdentifierString(const string &str) {
return val;
}
void oBase::setExtIdentifier(const string &str) {
void oBase::setExtIdentifier(const wstring &str) {
__int64 val = converExtIdentifierString(str);
setExtIdentifier(val);
}
@ -157,9 +157,11 @@ bool oBase::isStringIdentifier() const {
return (raw & (BaseGenStringFlag|Base36StringFlag)) != 0;
}
string oBase::getTimeStamp() const {
if (oe && oe->isClient() && !sqlUpdated.empty())
return sqlUpdated;
wstring oBase::getTimeStamp() const {
if (oe && oe->isClient() && !sqlUpdated.empty()) {
wstring sqlW(sqlUpdated.begin(), sqlUpdated.end());
return sqlW;
}
else return Modified.getStampString();
}

View File

@ -41,7 +41,7 @@ class oDataInterface;
class oDataConstInterface;
class oDataContainer;
typedef void * pvoid;
typedef vector< vector<string> > * pvectorstr;
typedef vector< vector<wstring> > * pvectorstr;
enum RunnerStatus {StatusOK=1, StatusDNS=20, StatusMP=3,
StatusDNF=4, StatusDQ=5, StatusMAX=6,
@ -115,14 +115,14 @@ protected:
public:
/// Returns textual information on the object
virtual string getInfo() const = 0;
virtual wstring getInfo() const = 0;
//Called (by a table) when user enters data in a cell
virtual bool inputData(int id, const string &input, int inputId,
string &output, bool noUpdate) {output=""; return false;}
virtual bool inputData(int id, const wstring &input, int inputId,
wstring &output, bool noUpdate) {output=L""; return false;}
//Called (by a table) to fill a list box with contents in a table
virtual void fillInput(int id, vector< pair<string, size_t> > &elements, size_t &selected)
virtual void fillInput(int id, vector< pair<wstring, size_t> > &elements, size_t &selected)
{throw std::exception("Not implemented");}
oEvent *getEvent() const {return oe;}
@ -133,7 +133,7 @@ public:
unsigned int getModificationTime() const {return Modified.getModificationTime();}
bool synchronize(bool writeOnly=false);
string getTimeStamp() const;
wstring getTimeStamp() const;
bool existInDB() const { return !sqlUpdated.empty(); }
@ -153,15 +153,15 @@ public:
/// Get an external identifier (or 0) if none
__int64 getExtIdentifier() const;
string getExtIdentifierString() const;
void setExtIdentifier(const string &str);
wstring getExtIdentifierString() const;
void setExtIdentifier(const wstring &str);
bool isStringIdentifier() const;
// Convert an external to a int id. The result
// need not be unique, of course.
static int idFromExtId(__int64 extId);
static void converExtIdentifierString(__int64 raw, char bf[16]);
static __int64 converExtIdentifierString(const string &str);
static void converExtIdentifierString(__int64 raw, wchar_t bf[16]);
static __int64 converExtIdentifierString(const wstring &str);
oBase(oEvent *poe);
virtual ~oBase();

View File

@ -88,7 +88,7 @@ void oCard::Set(const xmlobject &xo)
cardNo = it->getInt();
}
else if (it->is("Punches")){
importPunches(it->get());
importPunches(it->getRaw());
}
else if (it->is("ReadId")){
readId = it->getInt();
@ -97,7 +97,7 @@ void oCard::Set(const xmlobject &xo)
Id = it->getInt();
}
else if (it->is("Updated")){
Modified.setStamp(it->get());
Modified.setStamp(it->getRaw());
}
}
}
@ -110,9 +110,8 @@ void oCard::setCardNo(int c)
cardNo=c;
}
const string &oCard::getCardNoString() const
{
return itos(cardNo);
const wstring &oCard::getCardNoString() const {
return itow(cardNo);
}
void oCard::addPunch(int type, int time, int matchControlId)
@ -213,7 +212,7 @@ bool oCard::fillPunches(gdioutput &gdi, const string &name, pCourse crs) {
if (!hasStart && !it->isStart()){
if (it->isUsed){
if (showStart)
gdi.addItem(name, lang.tl("Start")+"\t-", -1);
gdi.addItem(name, lang.tl("Start")+L"\t-", -1);
hasStart=true;
}
}
@ -231,11 +230,11 @@ bool oCard::fillPunches(gdioutput &gdi, const string &name, pCourse crs) {
gdi.addItem(name, rogainingIndex[matchPunch].second->getString(),
rogainingIndex[matchPunch].first);
else
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
}
else {
while(0<punchRemain--) {
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
}
}
// Next control
@ -255,13 +254,13 @@ bool oCard::fillPunches(gdioutput &gdi, const string &name, pCourse crs) {
gdi.addItem(name, rogainingIndex[matchPunch].second->getString(),
rogainingIndex[matchPunch].first);
else
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
ctrl = crs->getControl(++matchPunch);
}
punchRemain = ctrl ? ctrl->getNumMulti() : 1;
}
else {
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
ctrl = crs->getControl(++matchPunch);
}
}
@ -269,7 +268,7 @@ bool oCard::fillPunches(gdioutput &gdi, const string &name, pCourse crs) {
if (it->isFinish() && crs) { //Add missing punches before the finish
while(ctrl) {
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
ctrl = crs->getControl(++matchPunch);
}
}
@ -288,7 +287,7 @@ bool oCard::fillPunches(gdioutput &gdi, const string &name, pCourse crs) {
gdi.addItem(name, rogainingIndex[matchPunch].second->getString(),
rogainingIndex[matchPunch].first);
else
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
ctrl = crs->getControl(++matchPunch);
}
punchRemain = ctrl ? ctrl->getNumMulti() : 1;
@ -306,7 +305,7 @@ bool oCard::fillPunches(gdioutput &gdi, const string &name, pCourse crs) {
}
if (!hasStart && showStart)
gdi.addItem(name, lang.tl("Start")+"\t-", -1);
gdi.addItem(name, lang.tl("Start")+L"\t-", -1);
if (!hasFinish && showFinish) {
@ -318,24 +317,24 @@ bool oCard::fillPunches(gdioutput &gdi, const string &name, pCourse crs) {
gdi.addItem(name, rogainingIndex[matchPunch].second->getString(),
rogainingIndex[matchPunch].first);
else
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
ctrl = crs->getControl(++matchPunch);
}
punchRemain = ctrl ? ctrl->getNumMulti() : 1;
}
else {
gdi.addItem(name, "-\t-", -1);
gdi.addItem(name, L"-\t-", -1);
ctrl = crs->getControl(++matchPunch);
}
}
gdi.addItem(name, lang.tl("Mål")+"\t-", -1);
gdi.addItem(name, lang.tl("Mål")+L"\t-", -1);
}
if (extra) {
//Show punches that are not used.
k=0;
gdi.addItem(name, "", -1);
gdi.addItem(name, L"", -1);
gdi.addItem(name, lang.tl("Extra stämplingar"), -1);
for (it=punches.begin(); it != punches.end(); ++it) {
if (!it->isUsed && !(it->isFinish() && showFinish) && !(it->isStart() && showStart))
@ -389,10 +388,10 @@ void oCard::deletePunch(pPunch pp)
}
}
string oCard::getInfo() const
wstring oCard::getInfo() const
{
char bf[128];
sprintf_s(bf, lang.tl("Löparbricka %d").c_str(), cardNo);
wchar_t bf[128];
swprintf_s(bf, lang.tl("Löparbricka %d").c_str(), cardNo);
return bf;
}
@ -476,7 +475,7 @@ pRunner oCard::getOwner() const {
return tOwner && !tOwner->isRemoved() ? tOwner : 0;
}
bool oCard::setPunchTime(const pPunch punch, const string &time)
bool oCard::setPunchTime(const pPunch punch, const wstring &time)
{
oPunch *op=getPunch(punch);
if (!op) return false;
@ -566,7 +565,7 @@ Table *oEvent::getCardsTB() //Table mode
{
oCardList::iterator it;
Table *table=new Table(this, 20, "Brickor", "cards");
Table *table=new Table(this, 20, L"Brickor", "cards");
table->addColumn("Id", 70, true, true);
table->addColumn("Ändrad", 70, false);
@ -604,7 +603,7 @@ void oEvent::generateCardTableData(Table &table, oCard *addCard)
void oCard::addTableRow(Table &table) const {
string runner(lang.tl("Oparad"));
wstring runner(lang.tl("Oparad"));
if (getOwner())
runner = tOwner->getNameAndRace(true);
@ -612,7 +611,7 @@ void oCard::addTableRow(Table &table) const {
table.addRow(getId(), &it);
int row = 0;
table.set(row++, it, TID_ID, itos(getId()), false);
table.set(row++, it, TID_ID, itow(getId()), false);
table.set(row++, it, TID_MODIFIED, getTimeStamp(), false);
table.set(row++, it, TID_CARD, getCardNoString(), true, cellAction);
@ -620,20 +619,22 @@ void oCard::addTableRow(Table &table) const {
table.set(row++, it, TID_RUNNER, runner, true, cellAction);
oPunch *p=getPunchByType(oPunch::PunchStart);
string time = "-";
wstring time;
if (p)
time = p->getTime();
else
time = makeDash(L"-");
table.set(row++, it, TID_START, time, false, cellEdit);
p = getPunchByType(oPunch::PunchFinish);
time = "-";
if (p)
time = p->getTime();
else
time = makeDash(L"-");
table.set(row++, it, TID_FINISH, time, false, cellEdit);
char npunch[16];
sprintf_s(npunch, "%d", getNumPunches());
table.set(row++, it, TID_COURSE, npunch, false, cellEdit);
table.set(row++, it, TID_COURSE, itow(getNumPunches()), false, cellEdit);
}
oDataContainer &oCard::getDataBuffers(pvoid &data, pvoid &olddata, pvectorstr &strData) const {
@ -660,19 +661,19 @@ int oCard::getSplitTime(int startTime, const pPunch punch) const {
}
string oCard::getRogainingSplit(int ix, int startTime) const
wstring oCard::getRogainingSplit(int ix, int startTime) const
{
oPunchList::const_iterator it;
for (it = punches.begin(); it != punches.end(); ++it) {
int t = it->getAdjustedTime();
if (0 == ix--) {
if (t > 0 && t > startTime)
return formatTime(t - startTime);
return formatTimeW(t - startTime);
}
if (it->isUsed)
startTime = t;
}
return "-";
return makeDash(L"-");
}
void oCard::remove()

Some files were not shown because too many files have changed in this diff Show More