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 GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
@ -7,17 +7,15 @@
Preamble Preamble
The GNU General Public License is a free, copyleft license for The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works. 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 The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast, 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 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 software for all its users.
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.
When we speak of free software, we are referring to freedom, not When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you 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 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. free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you Developers that use our General Public Licenses protect your rights
these rights or asking you to surrender the rights. Therefore, you have with two steps: (1) assert copyright on the software, and (2) offer
certain responsibilities if you distribute copies of the software, or if you this License which gives you legal permission to copy, distribute
you modify it: responsibilities to respect the freedom of others. and/or modify the software.
For example, if you distribute copies of such a program, whether A secondary benefit of defending all users' freedom is that
gratis or for a fee, you must pass on to the recipients the same improvements made in alternate versions of the program, if they
freedoms that you received. You must make sure that they, too, receive receive widespread use, become available for other developers to
or can get the source code. And you must show them these terms so they incorporate. Many developers of free software are heartened and
know their rights. 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: The GNU Affero General Public License is designed specifically to
(1) assert copyright on the software, and (2) offer you this License ensure that, in such cases, the modified source code becomes available
giving you legal permission to copy, distribute and/or modify it. 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 An older license, called the Affero General Public License and
that there is no warranty for this free software. For both users' and published by Affero, was designed to accomplish similar goals. This is
authors' sake, the GPL requires that modified versions be marked as a different license, not a version of the Affero GPL, but Affero has
changed, so that their problems will not be attributed erroneously to released a new version of the Affero GPL which permits relicensing under
authors of previous versions. this license.
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.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
@ -72,7 +60,7 @@ modification follow.
0. Definitions. 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 "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks. 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 the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program. 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 Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed 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 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, License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License, but the work with which it is combined will remain governed by version
section 13, concerning interaction through a network will apply to the 3 of the GNU General Public License.
combination as such.
14. Revised Versions of this License. 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of 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 the GNU Affero General Public License from time to time. Such new versions
be similar in spirit to the present version, but may differ in detail to will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns.
Each version is given a distinguishing version number. If the 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 Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the 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. by the Free Software Foundation.
If the Program specifies that a proxy can decide which future 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 public statement of acceptance of a version permanently authorizes you
to choose that version for the Program. 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 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. 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.} <one line to give the program's name and a brief idea of what it does.>
Copyright (C) {year} {name of author} Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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/>. 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. Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short If your software can interact with users remotely through a computer
notice like this when it starts in an interactive mode: 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
{project} Copyright (C) {year} {fullname} interface could display a "Source" link that leads users to an archive
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. of the code. There are many ways you could offer source, and different
This is free software, and you are welcome to redistribute it solutions will be better for different programs; see section 13 for the
under certain conditions; type `show c' for details. specific requirements.
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".
You should also get your employer (if you work as a programmer) or school, 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. 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/>. <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 "Localizer.h"
#include "gdiconstants.h" #include "gdiconstants.h"
double getLocalScale(const string &fontName, string &faceName); double getLocalScale(const wstring &fontName, wstring &faceName);
string getMeosCompectVersion(); 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) { map< pair<gdiFonts, string>, pair<string, string> > &styles) {
fout << "<style type=\"text/css\">\n"; fout << "<style type=\"text/css\">\n";
fout << "body {background-color: rgb(250,250,255)}\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) if (!it->font.empty() || (font == italicMediumPlus)
|| (font == fontMediumPlus)) { || (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; ++it;
continue; continue;
} }
@ -92,20 +92,20 @@ static void generateStyles(ostream &fout, bool withTbl, const list<TextInfo> &TL
break; break;
} }
string faceName; wstring faceName;
double scale = 1.0; double scale = 1.0;
if (it->font.empty()) { if (it->font.empty()) {
faceName = "arial,sans-serif"; faceName = L"arial,sans-serif";
} }
else else
scale = getLocalScale(it->font, faceName); scale = getLocalScale(it->font, faceName);
fout << element << "." << style fout << element << "." << style
<< "{font-family:" << faceName << ";font-size:" << "{font-family:" << gdi.narrow(faceName) << ";font-size:"
<< itos(int(floor(scale * baseSize + 0.5))) << itos(int(floor(scale * baseSize + 0.5)))
<< "px;font-weight:normal;white-space:nowrap}\n"; << "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; ++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()); 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"; fout << "<title>" << toUTF8(title) << "</title>\n";
map< pair<gdiFonts, string>, pair<string, string> > styles; map< pair<gdiFonts, string>, pair<string, string> > styles;
generateStyles(fout, false, TL, styles); generateStyles(*this, fout, false, TL, styles);
fout << "</head>\n"; fout << "</head>\n";
@ -246,7 +246,7 @@ bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshT
xp + "px;top:" + yp + "px\""; xp + "px;top:" + yp + "px\"";
} }
string starttag, endtag; 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()) if (!it->text.empty())
fout << starttag << toUTF8(encodeXML(it->text)) << endtag << endl; 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 bf1[256];
char bf2[256]; char bf2[256];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256); GetTimeFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256); GetDateFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
//fout << "Skapad av <i>MeOS</i>: " << bf1 << " "<< bf2 << "\n"; //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 << toUTF8(lang.tl("Skapad av ")) + "<a href=\"http://www.melin.nu/meos\" target=\"_blank\"><i>MeOS</i></a>: " << bf1 << " "<< bf2 << "\n";
fout << "</p>\n"; fout << "</p>\n";
@ -276,10 +276,10 @@ bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshT
return false; return false;
} }
string html_table_code(const string &in) wstring html_table_code(const wstring &in)
{ {
if (in.size()==0) if (in.size()==0)
return "&nbsp;"; return L"&nbsp;";
else { else {
return encodeXML(in); return encodeXML(in);
} }
@ -292,7 +292,7 @@ bool sortTL_X(const TextInfo *a, const TextInfo *b)
bool gdioutput::writeTableHTML(const wstring &file, bool gdioutput::writeTableHTML(const wstring &file,
const string &title, int refreshTimeOut) const const wstring &title, int refreshTimeOut) const
{ {
ofstream fout(file.c_str()); ofstream fout(file.c_str());
@ -303,7 +303,7 @@ bool gdioutput::writeTableHTML(const wstring &file,
} }
bool gdioutput::writeTableHTML(ostream &fout, bool gdioutput::writeTableHTML(ostream &fout,
const string &title, const wstring &title,
bool simpleFormat, bool simpleFormat,
int refreshTimeOut) const { int refreshTimeOut) const {
@ -317,7 +317,7 @@ bool gdioutput::writeTableHTML(ostream &fout,
fout << "<title>" << toUTF8(title) << "</title>\n"; fout << "<title>" << toUTF8(title) << "</title>\n";
map< pair<gdiFonts, string>, pair<string, string> > styles; map< pair<gdiFonts, string>, pair<string, string> > styles;
generateStyles(fout, true, TL, styles); generateStyles(*this, fout, true, TL, styles);
fout << "</head>\n"; fout << "</head>\n";
@ -332,16 +332,15 @@ bool gdioutput::writeTableHTML(ostream &fout,
++it; ++it;
} }
map<int, int>::iterator mit=tableCoordinates.begin(); int kr = 0;
int k=0; map<int, int>::iterator mit = tableCoordinates.begin();
while (mit != tableCoordinates.end()) {
while (mit!=tableCoordinates.end()) { mit->second = kr++;
mit->second=k++;
++mit; ++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"; fout << "<table cellspacing=\"0\" border=\"0\">\n";
@ -492,7 +491,7 @@ bool gdioutput::writeTableHTML(ostream &fout,
gdiFonts font = row[k]->getGdiFont(); gdiFonts font = row[k]->getGdiFont();
string starttag, endtag; 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; fout << starttag << toUTF8(html_table_code(row[k]->text)) << endtag << "</td>" << endl;
@ -508,11 +507,11 @@ bool gdioutput::writeTableHTML(ostream &fout,
fout << "<br><p>"; fout << "<br><p>";
char bf1[256]; char bf1[256];
char bf2[256]; char bf2[256];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256); GetTimeFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256); GetDateFormatA(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
string meos = getMeosCompectVersion(); wstring meos = getMeosCompectVersion();
fout << toUTF8(lang.tl("Skapad av ")) + "<a href=\"http://www.melin.nu/meos\" target=\"_blank\"><i>MeOS " 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 << "</p><br>\n";
} }
fout << "</body>\n"; fout << "</body>\n";

View File

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

View File

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

View File

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

View File

@ -39,6 +39,9 @@
#include "oEvent.h" #include "oEvent.h"
extern gdioutput *gdi_main;
RunnerDB::RunnerDB(oEvent *oe_): oe(oe_) RunnerDB::RunnerDB(oEvent *oe_): oe(oe_)
{ {
loadedFromServer = false; loadedFromServer = false;
@ -58,21 +61,86 @@ RunnerDBEntry::RunnerDBEntry()
memset(this, 0, sizeof(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() RunnerDBEntryV1::RunnerDBEntryV1()
{ {
memset(this, 0, sizeof(RunnerDBEntryV1)); memset(this, 0, sizeof(RunnerDBEntryV1));
} }
RunnerDBEntryV2::RunnerDBEntryV2()
void RunnerDBEntry::getName(string &n) const
{ {
memset(this, 0, sizeof(RunnerDBEntryV2));
}
void RunnerWDBEntry::getName(wstring &n) const
{
initName();
n=name; 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; 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 string RunnerDBEntry::getNationality() const
@ -95,46 +163,99 @@ string RunnerDBEntry::getSex() const
n[0] = sex; n[0] = sex;
return n; 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); return ::getGivenName(name);
} }
string RunnerDBEntry::getFamilyName() const wstring RunnerWDBEntry::getFamilyName() const
{ {
initName();
return ::getFamilyName(name); 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)); memcpy(this, &dbe, sizeof(RunnerDBEntryV1));
extId = 0; extId = 0;
} }
void RunnerDBEntry::init(const RunnerDBEntryV2 &dbe)
RunnerDBEntry *RunnerDB::addRunner(const char *name,
__int64 extId,
int club, int card)
{ {
rdb.push_back(RunnerDBEntry()); memcpy(name, dbe.name, 32);
RunnerDBEntry &e=rdb.back();
e.cardNo = card;
e.clubNo = club;
e.setName(name);
e.extId = extId;
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(); rdb.pop_back();
rwdb.pop_back();
return 0; return 0;
} else { } else {
if (card>0) if (card>0)
@ -142,20 +263,55 @@ RunnerDBEntry *RunnerDB::addRunner(const char *name,
if (!idhash.empty()) if (!idhash.empty())
idhash[extId] = rdb.size()-1; idhash[extId] = rdb.size()-1;
if (!nhash.empty()) 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; return &e;
} }
int RunnerDB::addClub(oClub &c, bool createNewId) { int RunnerDB::addClub(oClub &c, bool createNewId) {
//map<int,int>::iterator it = chash.find(c.getId());
//if (it == chash.end()) {
if (createNewId) { if (createNewId) {
oDBClubEntry ce(c, cdb.size(), this); oDBClubEntry ce(c, cdb.size(), this);
cdb.push_back(ce); cdb.push_back(ce);
int b = 0; int b = 0;
while(++b<0xFFFF) { while(++b<0xFFFF) {
int newId = 10000 + rand() & 0xFFFF; int off = (rand() & 0xFFFF);
int newId = 10000 + off;
int dummy; int dummy;
if (!chash.lookup(newId, dummy)) { if (!chash.lookup(newId, dummy)) {
cdb.back().Id = newId; cdb.back().Id = newId;
@ -240,7 +396,7 @@ void RunnerDB::compactifyClubs()
oDBClubEntry &ref = cdb[k]; oDBClubEntry &ref = cdb[k];
vector<int> compacted; vector<int> compacted;
for (size_t j=k+1;j<cdb.size(); j++) { 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) cdb[j].getName().c_str())==0)
compacted.push_back(j); 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) if (card == 0)
return 0; return 0;
int value; int value;
if (rhash.lookup(card, value)) if (rhash.lookup(card, value))
return (RunnerDBEntry *)&rdb[value]; return (RunnerWDBEntry *)&rwdb[value];
return 0; return 0;
} }
RunnerDBEntry *RunnerDB::getRunnerByIndex(size_t index) const { RunnerWDBEntry *RunnerDB::getRunnerByIndex(size_t index) const {
if (index >= rdb.size()) if (index >= rdb.size())
throw meosException("Index out of bounds"); 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) if (extId == 0)
return 0; return 0;
@ -295,21 +451,21 @@ RunnerDBEntry *RunnerDB::getRunnerById(__int64 extId) const
int value; int value;
if (idhash.lookup(extId, value)) if (idhash.lookup(extId, value))
return (RunnerDBEntry *)&rdb[value]; return (RunnerWDBEntry *)&rwdb[value];
return 0; return 0;
} }
RunnerDBEntry *RunnerDB::getRunnerByName(const string &name, int clubId, RunnerWDBEntry *RunnerDB::getRunnerByName(const wstring &name, int clubId,
int expectedBirthYear) const int expectedBirthYear) const
{ {
if (expectedBirthYear>0 && expectedBirthYear<100) if (expectedBirthYear>0 && expectedBirthYear<100)
expectedBirthYear = extendYear(expectedBirthYear); expectedBirthYear = extendYear(expectedBirthYear);
setupNameHash(); setupNameHash();
vector<int> ix; vector<int> ix;
string cname(canonizeName(name.c_str())); wstring cname(canonizeName(name.c_str()));
multimap<string, int>::const_iterator it = nhash.find(cname); multimap<wstring, int>::const_iterator it = nhash.find(cname);
while (it != nhash.end() && cname == it->first) { while (it != nhash.end() && cname == it->first) {
ix.push_back(it->second); ix.push_back(it->second);
@ -321,7 +477,7 @@ RunnerDBEntry *RunnerDB::getRunnerByName(const string &name, int clubId,
if (clubId == 0) { if (clubId == 0) {
if (ix.size() == 1) if (ix.size() == 1)
return (RunnerDBEntry *)&rdb[ix[0]]; return (RunnerWDBEntry *)&rwdb[ix[0]];
else else
return 0; // Not uniquely defined. return 0; // Not uniquely defined.
} }
@ -335,19 +491,19 @@ RunnerDBEntry *RunnerDB::getRunnerByName(const string &name, int clubId,
if (ix2.empty()) if (ix2.empty())
return 0; return 0;
else if (ix2.size() == 1) else if (ix2.size() == 1)
return (RunnerDBEntry *)&rdb[ix2[0]]; return (RunnerWDBEntry *)&rwdb[ix2[0]];
else if (expectedBirthYear > 0) { else if (expectedBirthYear > 0) {
int bestMatch = 0; int bestMatch = 0;
int bestYear = 0; int bestYear = 0;
for (size_t k = 0;k<ix2.size(); k++) { for (size_t k = 0;k<ix2.size(); k++) {
const RunnerDBEntry &re = rdb[ix2[k]]; const RunnerWDBEntry &re = rwdb[ix2[k]];
if (abs(re.birthYear-expectedBirthYear) < abs(bestYear-expectedBirthYear)) { if (abs(re.dbe().birthYear-expectedBirthYear) < abs(bestYear-expectedBirthYear)) {
bestMatch = ix2[k]; bestMatch = ix2[k];
bestYear = re.birthYear; bestYear = re.dbe().birthYear;
} }
} }
if (bestYear>0) if (bestYear>0)
return (RunnerDBEntry *)&rdb[bestMatch]; return (RunnerWDBEntry *)&rwdb[bestMatch];
} }
return 0; return 0;
@ -370,8 +526,10 @@ void RunnerDB::setupNameHash() const
return; return;
for (size_t k=0; k<rdb.size(); k++) { for (size_t k=0; k<rdb.size(); k++) {
if (!rdb[k].isRemoved()) if (!rdb[k].isRemoved()) {
nhash.insert(pair<string, int>(canonizeName(rdb[k].name), k)); rwdb[k].initName();
nhash.insert(pair<wstring, int>(canonizeName(rwdb[k].name), k));
}
} }
} }
@ -380,13 +538,13 @@ void RunnerDB::setupCNHash() const
if (!cnhash.empty()) if (!cnhash.empty())
return; return;
vector<string> split; vector<wstring> split;
for (size_t k=0; k<cdb.size(); k++) { for (size_t k=0; k<cdb.size(); k++) {
if (cdb[k].isRemoved()) if (cdb[k].isRemoved())
continue; continue;
canonizeSplitName(cdb[k].getName(), split); canonizeSplitName(cdb[k].getName(), split);
for (size_t j = 0; j<split.size(); j++) 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=='ö'; c=='å' || c=='ä' || c=='ö';
} }
void RunnerDB::canonizeSplitName(const string &name, vector<string> &split) void RunnerDB::canonizeSplitName(const wstring &name, vector<wstring> &split)
{ {
split.clear(); split.clear();
const char *cname = name.c_str(); const wchar_t *cname = name.c_str();
int k = 0; int k = 0;
for (k=0; cname[k]; k++) for (k=0; cname[k]; k++)
if (cname[k] != ' ') if (cname[k] != ' ')
break; break;
char out[128]; wchar_t out[128];
int outp; int outp;
while (cname[k]) { while (cname[k]) {
outp = 0; 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); //map<int,int>::const_iterator it = chash.find(clubId);
@ -465,16 +623,16 @@ oClub *RunnerDB::getClub(int clubId) const
return 0; return 0;
} }
oClub *RunnerDB::getClub(const string &name) const oClub *RunnerDB::getClub(const wstring &name) const
{ {
setupCNHash(); setupCNHash();
vector<string> names; vector<wstring> names;
canonizeSplitName(name, names); canonizeSplitName(name, names);
vector< vector<int> > ix(names.size()); vector< vector<int> > ix(names.size());
set<int> iset; set<int> iset;
for (size_t k = 0; k<names.size(); k++) { 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) { while (it != cnhash.end() && names[k] == it->first) {
ix[k].push_back(it->second); ix[k].push_back(it->second);
@ -504,15 +662,15 @@ oClub *RunnerDB::getClub(const string &name) const
// Exact compare // Exact compare
for (set<int>::iterator it = iset.begin(); it != iset.end(); ++it) { for (set<int>::iterator it = iset.begin(); it != iset.end(); ++it) {
pClub pc = pClub(&cdb[*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; return pc;
} }
string cname = canonizeName(name.c_str()); wstring cname = canonizeName(name.c_str());
// Looser compare // Looser compare
for (set<int>::iterator it = iset.begin(); it != iset.end(); ++it) { for (set<int>::iterator it = iset.begin(); it != iset.end(); ++it) {
pClub pc = pClub(&cdb[*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; return pc;
} }
@ -542,11 +700,11 @@ oClub *RunnerDB::getClub(const string &name) const
return 0; 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; vector<oDBClubEntry>::iterator it;
@ -595,14 +753,14 @@ void RunnerDB::setDataDate(const string &date)
dataTime = 0; dataTime = 0;
} }
void RunnerDB::saveRunners(const char *file) void RunnerDB::saveRunners(const wstring &file)
{ {
int f=-1; 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); _SH_DENYWR, _S_IREAD|_S_IWRITE);
if (f!=-1) { if (f!=-1) {
int version = 5460002; int version = 5460003;
_write(f, &version, 4); _write(f, &version, 4);
_write(f, &dataDate, 4); _write(f, &dataDate, 4);
_write(f, &dataTime, 4); _write(f, &dataTime, 4);
@ -613,9 +771,9 @@ void RunnerDB::saveRunners(const char *file)
else throw std::exception("Could not save runner database."); 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); xml.read(file);
@ -640,10 +798,13 @@ void RunnerDB::loadClubs(const char *file)
oDBClubEntry c(oe, cdb.size(), this); oDBClubEntry c(oe, cdb.size(), this);
c.set(*it); c.set(*it);
int value; int value;
if (c.getId() == 0)
continue;
//if (chash.find(c.getId()) == chash.end()) { //if (chash.find(c.getId()) == chash.end()) {
if (!chash.lookup(c.getId(), value)) { if (!chash.lookup(c.getId(), value)) {
chash[c.getId()]=cdb.size(); chash[c.getId()]=cdb.size();
cdb.push_back(c); cdb.push_back(c);
freeCIx = max(c.getId()+1, freeCIx);;
} }
} }
} }
@ -652,7 +813,7 @@ void RunnerDB::loadClubs(const char *file)
bool checkClubs = false; bool checkClubs = false;
if (checkClubs) { if (checkClubs) {
vector<string> problems; vector<wstring> problems;
for (size_t k=0; k<cdb.size(); k++) { for (size_t k=0; k<cdb.size(); k++) {
pClub pc = &cdb[k]; pClub pc = &cdb[k];
@ -660,17 +821,17 @@ void RunnerDB::loadClubs(const char *file)
if (!pc2) if (!pc2)
problems.push_back(pc->getName()); problems.push_back(pc->getName());
else if (pc != pc2) else if (pc != pc2)
problems.push_back(pc->getName() + "-" + pc2->getName()); problems.push_back(pc->getName() + L"-" + pc2->getName());
} }
problems.begin(); 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; 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); _SH_DENYWR, _S_IREAD|_S_IWRITE);
if (f!=-1) { if (f!=-1) {
@ -684,23 +845,52 @@ void RunnerDB::loadRunners(const char *file)
} }
int nentry = 0; int nentry = 0;
if (len % sizeof(RunnerDBEntry) == 12) { if (len % sizeof(RunnerDBEntryV2) == 12 || len % sizeof(RunnerDBEntry) == 12) {
nentry = (len-12) / sizeof(RunnerDBEntry);
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); rdb.resize(nentry);
if (rdb.empty()) { if (rdb.empty()) {
_close(f); _close(f);
return; return;
} }
int version; rwdb.resize(rdb.size());
_read(f, &version, 4);
_read(f, &dataDate, 4); if (!migrateV2) {
_read(f, &dataTime, 4); _read(f, &rdb[0], len-12);
_read(f, &rdb[0], len-12); _close(f);
_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++) { for (int k=0;k<nentry;k++) {
rwdb[k].init(this, k);
if (!check(rdb[k])) if (!check(rdb[k]))
throw std::exception(ex.c_str()); throw meosException(ex);
} }
} }
else { else {
@ -718,10 +908,14 @@ void RunnerDB::loadRunners(const char *file)
_read(f, &rdbV1[0], len); _read(f, &rdbV1[0], len);
_close(f); _close(f);
rwdb.resize(rdb.size());
RunnerDBEntryV2 tmp;
for (int k=0;k<nentry;k++) { 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])) 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 bool RunnerDB::check(const RunnerDBEntry &rde) const
{ {
if (rde.cardNo<0 || rde.cardNo>99999999 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 false;
return true; return true;
} }
@ -752,9 +946,9 @@ bool RunnerDB::check(const RunnerDBEntry &rde) const
void RunnerDB::updateAdd(const oRunner &r, map<int, int> &clubIdMap) void RunnerDB::updateAdd(const oRunner &r, map<int, int> &clubIdMap)
{ {
if (r.getExtIdentifier() > 0) { if (r.getExtIdentifier() > 0) {
RunnerDBEntry *dbe = getRunnerById(int(r.getExtIdentifier())); RunnerWDBEntry *dbe = getRunnerById(int(r.getExtIdentifier()));
if (dbe) { if (dbe) {
dbe->cardNo = r.CardNo; dbe->dbe().cardNo = r.CardNo;
return; // Do not change too much in runner from national database 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) { if (dbe == 0) {
dbe = addRunner(r.getName().c_str(), 0, localClubId, r.getCardNo()); dbe = addRunner(r.getName().c_str(), 0, localClubId, r.getCardNo());
if (dbe) if (dbe)
dbe->birthYear = r.getDCI().getInt("BirthYear"); dbe->dbe().birthYear = r.getDCI().getInt("BirthYear");
} }
else { else {
if (dbe->getExtId() == 0) { // Only update entries not in national db. if (dbe->getExtId() == 0) { // Only update entries not in national db.
dbe->setName(r.getName().c_str()); dbe->setName(r.getName().c_str());
dbe->clubNo = localClubId; dbe->dbe().clubNo = localClubId;
dbe->birthYear = r.getDCI().getInt("BirthYear"); 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()); givenName.reserve(rdb.size());
familyName.reserve(rdb.size()); familyName.reserve(rdb.size());
for (size_t k=0;k<rdb.size(); k++) { for (size_t k=0;k<rwdb.size(); k++) {
string gname(rdb[k].getGivenName()); wstring gname(rwdb[k].getGivenName());
string fname(rdb[k].getFamilyName()); wstring fname(rwdb[k].getFamilyName());
if (!gname.empty()) if (!gname.empty())
givenName.push_back(gname); givenName.push_back(gname);
if (!fname.empty()) if (!fname.empty())
@ -839,15 +1033,32 @@ void RunnerDB::clearRunners()
idhash.clear(); idhash.clear();
rhash.clear(); rhash.clear();
rdb.clear(); rdb.clear();
rwdb.clear();
if (runnerTable) if (runnerTable)
runnerTable->clear(); 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; return cdb;
} }
const vector<RunnerDBEntry> &RunnerDB::getRunnerDB() const { const vector<RunnerWDBEntry> &RunnerDB::getRunnerDB() const {
return rwdb;
}
const vector<RunnerDBEntry> &RunnerDB::getRunnerDBN() const {
return rdb; return rdb;
} }
@ -858,7 +1069,7 @@ void RunnerDB::prepareLoadFromServer(int nrunner, int nclub) {
rdb.reserve(nrunner); 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()); out.reserve(cdb.size());
for (size_t k = 0; k<cdb.size(); k++) { for (size_t k = 0; k<cdb.size(); k++) {
if (!cdb[k].isRemoved()) { if (!cdb[k].isRemoved()) {
@ -929,7 +1140,7 @@ void RunnerDB::releaseTables() {
Table *RunnerDB::getRunnerTB()//Table mode Table *RunnerDB::getRunnerTB()//Table mode
{ {
if (runnerTable == 0) { 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("Index", 70, true, true);
table->addColumn("Id", 70, true, true); table->addColumn("Id", 70, true, true);
@ -996,7 +1207,7 @@ Table *RunnerDB::getClubTB()//Table mode
bool canEdit = !oe->isClient(); bool canEdit = !oe->isClient();
if (clubTable == 0) { 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("Id", 70, true, true);
table->addColumn("Ändrad", 70, false); table->addColumn("Ändrad", 70, false);
@ -1034,34 +1245,37 @@ void oDBRunnerEntry::addTableRow(Table &table) const {
if (!db) if (!db)
throw meosException("Not initialized"); throw meosException("Not initialized");
RunnerDBEntry &r = db->rdb[index]; RunnerWDBEntry &r = db->rwdb[index];
RunnerDBEntry &rn = r.dbe();
int row = 0; int row = 0;
table.set(row++, it, TID_INDEX, itos(index+1), false, cellEdit); table.set(row++, it, TID_INDEX, itow(index+1), false, cellEdit);
char bf[16]; wchar_t bf[16];
oBase::converExtIdentifierString(r.extId, bf); oBase::converExtIdentifierString(rn.extId, bf);
table.set(row++, it, TID_ID, bf, false, cellEdit); table.set(row++, it, TID_ID, bf, false, cellEdit);
r.initName();
table.set(row++, it, TID_NAME, r.name, canEdit, cellEdit); 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) if (pc)
table.set(row++, it, TID_CLUB, pc->getName(), canEdit, cellSelection); table.set(row++, it, TID_CLUB, pc->getName(), canEdit, cellSelection);
else 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); table.set(row++, it, TID_CARD, rn.cardNo > 0 ? itow(rn.cardNo) : L"", canEdit, cellEdit);
char nat[4] = {r.national[0],r.national[1],r.national[2], 0}; 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); 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_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; oClass *val = 0;
bool found = false; bool found = false;
if (r.extId != 0) if (rn.extId != 0)
found = db->runnerInEvent.lookup(r.extId, val); found = db->runnerInEvent.lookup(rn.extId, val);
if (canEdit) if (canEdit)
table.setTableProp(Table::CAN_DELETE|Table::CAN_INSERT|Table::CAN_PASTE); table.setTableProp(Table::CAN_DELETE|Table::CAN_INSERT|Table::CAN_PASTE);
@ -1069,9 +1283,9 @@ void oDBRunnerEntry::addTableRow(Table &table) const {
table.setTableProp(0); table.setTableProp(0);
if (!found) if (!found)
table.set(row++, it, TID_ENTER, "@+", false, cellAction); table.set(row++, it, TID_ENTER, L"@+", false, cellAction);
else 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 { const RunnerDBEntry &oDBRunnerEntry::getRunner() const {
@ -1080,12 +1294,13 @@ const RunnerDBEntry &oDBRunnerEntry::getRunner() const {
return db->rdb[index]; return db->rdb[index];
} }
bool oDBRunnerEntry::inputData(int id, const string &input, bool oDBRunnerEntry::inputData(int id, const wstring &input,
int inputId, string &output, bool noUpdate) int inputId, wstring &output, bool noUpdate)
{ {
if (!db) if (!db)
throw meosException("Not initialized"); throw meosException("Not initialized");
RunnerDBEntry &r = db->rdb[index]; RunnerWDBEntry &r = db->rwdb[index];
RunnerDBEntry &rd = db->rdb[index];
switch(id) { switch(id) {
case TID_NAME: case TID_NAME:
@ -1094,58 +1309,60 @@ bool oDBRunnerEntry::inputData(int id, const string &input,
db->nhash.clear(); db->nhash.clear();
return true; return true;
case TID_CARD: case TID_CARD:
db->rhash.remove(r.cardNo); db->rhash.remove(rd.cardNo);
r.cardNo = atoi(input.c_str()); rd.cardNo = _wtoi(input.c_str());
db->rhash.insert(r.cardNo, index); db->rhash.insert(rd.cardNo, index);
if (r.cardNo) if (rd.cardNo)
output = itos(r.cardNo); output = itow(rd.cardNo);
else else
output = ""; output = L"";
return true; return true;
case TID_NATIONAL: case TID_NATIONAL:
if (input.empty()) { if (input.empty()) {
r.national[0] = 0; rd.national[0] = 0;
r.national[1] = 0; rd.national[1] = 0;
r.national[2] = 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(); output = r.getNationality();
break; break;
case TID_SEX: case TID_SEX:
r.sex = input[0]; rd.sex = char(input[0]);
output = r.getSex(); output = r.getSex();
break; break;
case TID_YEAR: case TID_YEAR:
r.birthYear = short(atoi(input.c_str())); rd.birthYear = short(_wtoi(input.c_str()));
output = itos(r.getBirthYear()); output = itow(r.getBirthYear());
break; break;
case TID_CLUB: case TID_CLUB:
r.clubNo = inputId; rd.clubNo = inputId;
output = input; output = input;
break; break;
} }
return false; 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]; RunnerDBEntry &r = db->rdb[index];
if (id==TID_CLUB) { if (id==TID_CLUB) {
db->fillClubs(out); db->fillClubs(out);
out.push_back(make_pair("-", 0)); out.push_back(make_pair(L"-", 0));
selected = r.clubNo; selected = r.clubNo;
} }
} }
void oDBRunnerEntry::remove() { void oDBRunnerEntry::remove() {
RunnerDBEntry &r = db->rdb[index]; RunnerWDBEntry &r = db->rwdb[index];
r.remove(); r.remove();
db->idhash.remove(r.extId); db->idhash.remove(r.dbe().extId);
string cname(canonizeName(r.name)); wstring cname(canonizeName(r.name));
multimap<string, int>::const_iterator it = db->nhash.find(cname); multimap<wstring, int>::const_iterator it = db->nhash.find(cname);
while (it != db->nhash.end() && cname == it->first) { while (it != db->nhash.end() && cname == it->first) {
if (it->second == index) { if (it->second == index) {
@ -1155,10 +1372,10 @@ void oDBRunnerEntry::remove() {
++it; ++it;
} }
if (r.cardNo > 0) { if (r.dbe().cardNo > 0) {
int ix = -1; int ix = -1;
if (db->rhash.lookup(r.cardNo, ix) && ix == index) { if (db->rhash.lookup(r.dbe().cardNo, ix) && ix == index) {
db->rhash.remove(r.cardNo); db->rhash.remove(r.dbe().cardNo);
} }
} }
} }
@ -1169,6 +1386,9 @@ bool oDBRunnerEntry::canRemove() const {
oDBRunnerEntry *RunnerDB::addRunner() { oDBRunnerEntry *RunnerDB::addRunner() {
rdb.push_back(RunnerDBEntry()); rdb.push_back(RunnerDBEntry());
rwdb.push_back(RunnerWDBEntry());
rwdb.back().init(this, rdb.size() -1);
oRDB.push_back(oDBRunnerEntry(oe)); oRDB.push_back(oDBRunnerEntry(oe));
oRDB.back().init(this, rdb.size() - 1); oRDB.back().init(this, rdb.size() - 1);
@ -1208,10 +1428,10 @@ void oDBClubEntry::remove() {
Removed = true; Removed = true;
db->chash.remove(getId()); db->chash.remove(getId());
vector<string> split; vector<wstring> split;
db->canonizeSplitName(getName(), split); db->canonizeSplitName(getName(), split);
for (size_t j = 0; j<split.size(); j++) { 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) { while (it != db->cnhash.end() && split[j] == it->first) {
if (it->second == index) { if (it->second == index) {
db->cnhash.erase(it); db->cnhash.erase(it);
@ -1229,4 +1449,13 @@ bool oDBClubEntry::canRemove() const {
int oDBClubEntry::getTableId() const { int oDBClubEntry::getTableId() const {
return index + 1; 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 <map>
#include "inthashmap.h" #include "inthashmap.h"
#include "oclub.h" #include "oclub.h"
#ifdef OLD
#include <hash_set> #include <hash_set>
#else
#include <unordered_set>
#endif
/************************************************************************ /************************************************************************
MeOS - Orienteering Software MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB 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 //Has 0-clearing constructor. Must not contain any
//dynamic data etc. //dynamic data etc.
struct RunnerDBEntryV1 { struct RunnerDBEntryV1 {
RunnerDBEntryV1(); RunnerDBEntryV1();
char name[baseNameLength]; char name[32];
int cardNo; int cardNo;
int clubNo; int clubNo;
char national[3]; char national[3];
@ -43,13 +50,13 @@ struct RunnerDBEntryV1 {
short int reserved; short int reserved;
}; };
struct RunnerDBEntry { struct RunnerDBEntryV2 {
// Init from old struct // Init from old struct
void init(const RunnerDBEntryV1 &dbe); void init(const RunnerDBEntryV1 &dbe);
RunnerDBEntry(); RunnerDBEntryV2();
/** Binary compatible with V1*/ /** Binary compatible with V1*/
char name[baseNameLength]; char name[32];
int cardNo; int cardNo;
int clubNo; int clubNo;
char national[3]; char national[3];
@ -57,24 +64,79 @@ struct RunnerDBEntry {
short int birthYear; short int birthYear;
short int reserved; short int reserved;
/** End of V1*/ /** End of V1*/
__int64 extId; __int64 extId;
void getName(string &name) const; bool isRemoved() const {return (reserved & 1) == 1;}
void setName(const char *name); void remove() {reserved |= 1;}
string getGivenName() const; bool isUTF() const {return (reserved & 2) == 2;}
string getFamilyName() const; void setUTF() {reserved |= 2;}
};
struct RunnerDBEntry {
// Init from old struct
void init(const RunnerDBEntryV2 &dbe);
RunnerDBEntry();
// 8 it versions
string getNationality() const; string getNationality() const;
int getBirthYear() const {return birthYear;}
string getSex() const; 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; __int64 getExtId() const;
void setExtId(__int64 id); void setExtId(__int64 id);
bool isRemoved() const {return (reserved & 1) == 1;} bool isRemoved() const {return (dbe().reserved & 1) == 1;}
void remove() {reserved |= 1;} void remove() {dbe().reserved |= 1;}
}; };
typedef vector<RunnerDBEntry> RunnerDBVector; typedef vector<RunnerDBEntry> RunnerDBVector;
@ -100,6 +162,8 @@ private:
void setupCNHash() const; void setupCNHash() const;
vector<RunnerDBEntry> rdb; vector<RunnerDBEntry> rdb;
vector<RunnerWDBEntry> rwdb;
vector<oDBClubEntry> cdb; vector<oDBClubEntry> cdb;
vector<oDBRunnerEntry> oRDB; vector<oDBRunnerEntry> oRDB;
@ -116,12 +180,12 @@ private:
int freeCIx; int freeCIx;
// Name hash // Name hash
mutable multimap<string, int> nhash; mutable multimap<wstring, int> nhash;
// Club name hash // 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; bool loadedFromServer;
@ -131,7 +195,7 @@ private:
/** Time when database was updated. The format is HH:MM:SS */ /** Time when database was updated. The format is HH:MM:SS */
int dataTime; int dataTime;
void fillClubs(vector< pair<string, size_t> > &out) const; void fillClubs(vector< pair<wstring, size_t> > &out) const;
public: public:
@ -161,46 +225,50 @@ public:
/** Prepare for loading runner from server*/ /** Prepare for loading runner from server*/
void prepareLoadFromServer(int nrunner, int nclub); void prepareLoadFromServer(int nrunner, int nclub);
const vector<RunnerDBEntry>& getRunnerDB() const; const vector<RunnerWDBEntry>& getRunnerDB() const;
const vector<oDBClubEntry>& getClubDB() const; const vector<RunnerDBEntry>& getRunnerDBN() const;
const vector<oDBClubEntry>& getClubDB(bool checkProblems) const;
void clearRunners(); void clearRunners();
void clearClubs(); void clearClubs();
/** Add a club. Create a new Id if necessary*/ /** Add a club. Create a new Id if necessary*/
int addClub(oClub &c, bool createNewId); int addClub(oClub &c, bool createNewId);
RunnerDBEntry *addRunner(const char *name, __int64 extId, RunnerWDBEntry *addRunner(const wchar_t *name, __int64 extId,
int club, int card); int club, int card);
RunnerWDBEntry *addRunner(const char *nameUTF, __int64 extId,
int club, int card);
oDBRunnerEntry *addRunner(); oDBRunnerEntry *addRunner();
oClub *addClub(); oClub *addClub();
RunnerDBEntry *getRunnerByIndex(size_t index) const; RunnerWDBEntry *getRunnerByIndex(size_t index) const;
RunnerDBEntry *getRunnerById(__int64 extId) const; RunnerWDBEntry *getRunnerById(__int64 extId) const;
RunnerDBEntry *getRunnerByCard(int card) const; RunnerWDBEntry *getRunnerByCard(int card) const;
RunnerDBEntry *getRunnerByName(const string &name, int clubId, RunnerWDBEntry *getRunnerByName(const wstring &name, int clubId,
int expectedBirthYear) const; int expectedBirthYear) const;
bool getClub(int clubId, string &club) const; bool getClub(int clubId, wstring &club) const;
oClub *getClub(int clubId) const; oClub *getClub(int clubId) const;
oClub *getClub(const string &name) const; oClub *getClub(const wstring &name) const;
void saveClubs(const char *file); void saveClubs(const wstring &file);
void saveRunners(const char *file); void saveRunners(const wstring &file);
void loadRunners(const char *file); void loadRunners(const wstring &file);
void loadClubs(const char *file); void loadClubs(const wstring &file);
void updateAdd(const oRunner &r, map<int, int> &clubIdMap); void updateAdd(const oRunner &r, map<int, int> &clubIdMap);
void importClub(oClub &club, bool matchName); void importClub(oClub &club, bool matchName);
void compactifyClubs(); void compactifyClubs();
void getAllNames(vector<string> &givenName, vector<string> &familyName); void getAllNames(vector<wstring> &givenName, vector<wstring> &familyName);
RunnerDB(oEvent *); RunnerDB(oEvent *);
~RunnerDB(void); ~RunnerDB(void);
friend class oDBRunnerEntry; friend class oDBRunnerEntry;
friend class oDBClubEntry; friend class oDBClubEntry;
friend struct RunnerWDBEntry;
}; };
class oDBRunnerEntry : public oBase { class oDBRunnerEntry : public oBase {
@ -220,9 +288,9 @@ public:
const RunnerDBEntry &getRunner() const; const RunnerDBEntry &getRunner() const;
void addTableRow(Table &table) const; void addTableRow(Table &table) const;
bool inputData(int id, const string &input, bool inputData(int id, const wstring &input,
int inputId, string &output, bool noUpdate); int inputId, wstring &output, bool noUpdate);
void fillInput(int id, vector< pair<string, size_t> > &out, size_t &selected); void fillInput(int id, vector< pair<wstring, size_t> > &out, size_t &selected);
oDBRunnerEntry(oEvent *oe); oDBRunnerEntry(oEvent *oe);
virtual ~oDBRunnerEntry(); virtual ~oDBRunnerEntry();
@ -230,7 +298,7 @@ public:
void remove(); void remove();
bool canRemove() const; 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; SIPunch CheckPunch;
DWORD nPunch; DWORD nPunch;
SIPunch Punch[192]; SIPunch Punch[192];
char FirstName[21]; wchar_t FirstName[21];
char LastName[21]; wchar_t LastName[21];
char Club[41]; wchar_t Club[41];
char readOutTime[32]; char readOutTime[32];
bool PunchOnly; bool PunchOnly;
bool convertedTime; bool convertedTime;
@ -110,7 +110,7 @@ struct SI_StationInfo
{ {
SI_StationInfo(); SI_StationInfo();
HANDLE ThreadHandle; HANDLE ThreadHandle;
string ComPort; wstring ComPort;
HANDLE hComm; HANDLE hComm;
COMMTIMEOUTS TimeOuts; COMMTIMEOUTS TimeOuts;
@ -142,19 +142,19 @@ struct SI_StationInfo
class SportIdent class SportIdent
{ {
protected: protected:
bool ReadSI6Block(HANDLE hComm, BYTE *data); bool readSI6Block(HANDLE hComm, BYTE *data);
bool ReadSystemData(SI_StationInfo *si, int retry=2); bool readSystemData(SI_StationInfo *si, int retry=2);
bool ReadSystemDataV2(SI_StationInfo &si); bool readSystemDataV2(SI_StationInfo &si);
CRITICAL_SECTION SyncObj; CRITICAL_SECTION SyncObj;
DWORD ZeroTime; //Used to analyse times. Seconds 0-24h (0-24*3600) DWORD ZeroTime; //Used to analyse times. Seconds 0-24h (0-24*3600)
int ReadByte_delay(BYTE &byte, HANDLE hComm); int readByte_delay(BYTE &byte, HANDLE hComm);
int ReadBytes_delay(BYTE *byte, DWORD buffSize, DWORD len, 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 readBytesDLE_delay(BYTE *byte, DWORD buffSize, DWORD len, HANDLE hComm);
int ReadByte(BYTE &byte, HANDLE hComm); int readByte(BYTE &byte, HANDLE hComm);
int ReadBytes(BYTE *byte, DWORD len, HANDLE hComm); int readBytes(BYTE *byte, DWORD len, HANDLE hComm);
int ReadBytesDLE(BYTE *byte, DWORD len, HANDLE hComm); int readBytesDLE(BYTE *byte, DWORD len, HANDLE hComm);
// Returns zero on failure, number of bytes used on success. // Returns zero on failure, number of bytes used on success.
int analyzeStation(BYTE *db, SI_StationData &si); int analyzeStation(BYTE *db, SI_StationData &si);
@ -163,26 +163,26 @@ protected:
int n_SI_Info; //Number of structures.. int n_SI_Info; //Number of structures..
SI_StationInfo *Current_SI_Info; //Current SI_Info in use (for thread startup); SI_StationInfo *Current_SI_Info; //Current SI_Info in use (for thread startup);
WORD CalcCRC(BYTE *data, DWORD length); WORD calcCRC(BYTE *data, DWORD length);
bool CheckCRC(BYTE *bf); bool checkCRC(BYTE *bf);
void SetCRC(BYTE *bf); void setCRC(BYTE *bf);
bool GetCard5Data(BYTE *data, SICard &card); bool getCard5Data(BYTE *data, SICard &card);
bool GetCard6Data(BYTE *data, SICard &card); bool getCard6Data(BYTE *data, SICard &card);
bool GetCard9Data(BYTE *data, SICard &card); bool getCard9Data(BYTE *data, SICard &card);
DWORD GetExtCardNumber(BYTE *data) const; DWORD GetExtCardNumber(BYTE *data) const;
void GetSI5Data(HANDLE hComm); void getSI5Data(HANDLE hComm);
void GetSI5DataExt(HANDLE hComm); void getSI5DataExt(HANDLE hComm);
void GetSI6Data(HANDLE hComm); void getSI6Data(HANDLE hComm);
void GetSI6DataExt(HANDLE hComm); void getSI6DataExt(HANDLE hComm);
void GetSI9DataExt(HANDLE hComm); void getSI9DataExt(HANDLE hComm);
void AnalyseSI5Time(BYTE *data, DWORD &time, DWORD &control); void analyseSI5Time(BYTE *data, DWORD &time, DWORD &control);
bool AnalysePunch(BYTE *data, DWORD &time, DWORD &control); bool analysePunch(BYTE *data, DWORD &time, DWORD &control);
void AnalyseTPunch(BYTE *data, DWORD &time, DWORD &control); void analyseTPunch(BYTE *data, DWORD &time, DWORD &control);
//Card read waiting to be processed. //Card read waiting to be processed.
list<SICard> ReadCards; list<SICard> ReadCards;
@ -196,27 +196,27 @@ protected:
int MonitorTCPSI(WORD port, int localZeroTime); int MonitorTCPSI(WORD port, int localZeroTime);
public: public:
SI_StationInfo *findStation(const string &com); SI_StationInfo *findStation(const wstring &com);
void getInfoString(const string &com, vector<string> &info); void getInfoString(const wstring &com, vector<wstring> &info);
bool IsPortOpen(const string &com); bool isPortOpen(const wstring &com);
void SetZeroTime(DWORD zt); void setZeroTime(DWORD zt);
bool AutoDetect(list<int> &ComPorts); bool autoDetect(list<int> &ComPorts);
void StopMonitorThread(); void stopMonitorThread();
void StartMonitorThread(const char *com); void startMonitorThread(const wchar_t *com);
bool GetCard(SICard &sic); bool getCard(SICard &sic);
void addCard(const 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 EnumrateSerialPorts(list<int> &ports);
void CloseCom(const char *com); void closeCom(const wchar_t *com);
bool OpenCom(const char *com); bool openCom(const wchar_t *com);
bool tcpAddPort(int port, DWORD zeroTime); 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); SportIdent(HWND hWnd, DWORD Id);
virtual ~SportIdent(); virtual ~SportIdent();

View File

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

View File

@ -32,24 +32,24 @@
#include <crtdbg.h> #include <crtdbg.h>
using namespace std; using namespace std;
bool getUserFile(char *fileNamePath, const char *fileName); bool getUserFile(wchar_t *fileNamePath, const wchar_t *fileName);
bool getDesktopFile(char *fileNamePath, const char *fileName, const char *subFolder = 0); bool getDesktopFile(wchar_t *fileNamePath, const wchar_t *fileName, const wchar_t *subFolder = 0);
bool getMeOSFile(char *FileNamePath, const char *FileName); bool getMeOSFile(wchar_t *FileNamePath, const wchar_t *FileName);
class gdioutput; 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); gdioutput *getExtraWindow(const string &tag, bool toForeGround);
string uniqueTag(const char *base); string uniqueTag(const char *base);
void LoadPage(const string &name); void LoadPage(const string &name);
string getTempFile(); wstring getTempFile();
string getTempPath(); wstring getTempPath();
void removeTempFile(const string &file); // Delete a temporyary void removeTempFile(const wstring &file); // Delete a temporyary
void registerTempFile(const string &tempFile); //Register a file/folder as temporary => autmatic removal on exit. void registerTempFile(const wstring &tempFile); //Register a file/folder as temporary => autmatic removal on exit.
const extern string _EmptyString; const extern string _EmptyString;
const extern string _VacantName; const extern string _VacantName;
const extern string _UnkownName; const extern wstring _EmptyWString;
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) #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) void TabAuto::syncCallback(gdioutput &gdi)
{ {
string msg; wstring msg;
try { try {
list<AutoMachine *>::iterator it; list<AutoMachine *>::iterator it;
for (it=machines.begin(); it!=machines.end(); ++it) { for (it=machines.begin(); it!=machines.end(); ++it) {
@ -159,11 +159,14 @@ void TabAuto::syncCallback(gdioutput &gdi)
am->process(gdi, oe, SyncDataUp); am->process(gdi, oe, SyncDataUp);
} }
} }
catch (meosException &ex) {
msg = ex.wwhat();
}
catch(std::exception &ex) { catch(std::exception &ex) {
msg=ex.what(); msg = gdi.widen(ex.what());
} }
catch(...) { catch(...) {
msg="Ett okänt fel inträffade."; msg = L"Ett okänt fel inträffade.";
} }
if (!msg.empty()) { if (!msg.empty()) {
gdi.alert(msg); gdi.alert(msg);
@ -234,7 +237,7 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
int nRunner=gdi.getTextNo("nRunner"); int nRunner=gdi.getTextNo("nRunner");
if (nRunner>0 && 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")); oe->generateTestCompetition(nClass, nRunner, gdi.isChecked("UseRelay"));
gdi.getTabs().get(TCmpTab)->loadPage(gdi); gdi.getTabs().get(TCmpTab)->loadPage(gdi);
return 0; return 0;
@ -242,9 +245,9 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
#endif #endif
} }
else if (bu.id == "BrowseFolder") { else if (bu.id == "BrowseFolder") {
const char *edit = bu.getExtra(); const wchar_t *edit = bu.getExtra();
string currentPath = gdi.getText(edit); wstring currentPath = gdi.getText(gdi.narrow(edit));
string newPath = gdi.browseForFolder(currentPath, 0); wstring newPath = gdi.browseForFolder(currentPath, 0);
if (!newPath.empty()) if (!newPath.empty())
gdi.setText(edit, newPath); gdi.setText(edit, newPath);
} }
@ -261,18 +264,18 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
} }
else if (bu.id == "BrowseFile") { else if (bu.id == "BrowseFile") {
static int index = 0; static int index = 0;
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("Webbdokument", "*.html;*.htm")); 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()) if (!file.empty())
gdi.setText("ExportFile", file); gdi.setText("ExportFile", file);
} }
else if (bu.id == "BrowseScript") { else if (bu.id == "BrowseScript") {
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("Skript", "*.bat;*.exe;*.js")); 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()) if (!file.empty())
gdi.setText("ExportScript", file); gdi.setText("ExportScript", file);
} }
@ -315,7 +318,7 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
} }
else if (bu.id=="StartResult") { else if (bu.id=="StartResult") {
#ifndef MEOSDB #ifndef MEOSDB
string minute=gdi.getText("Interval"); wstring minute=gdi.getText("Interval");
int t=convertAbsoluteTimeMS(minute); int t=convertAbsoluteTimeMS(minute);
if (t<2 || t>7200) { if (t<2 || t>7200) {
@ -366,13 +369,13 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
} }
else if (bu.id=="StartSplits") { else if (bu.id=="StartSplits") {
string ivt = gdi.getText("Interval"); wstring ivt = gdi.getText("Interval");
int iv = gdi.getTextNo("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)) { 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()) { if (file.empty()) {
@ -427,11 +430,11 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
} }
else if (bu.id=="StartPunch") { else if (bu.id=="StartPunch") {
string minute=gdi.getText("Interval"); wstring minute=gdi.getText("Interval");
int t=atoi(minute.c_str()); int t=_wtoi(minute.c_str());
if (t<1 || t>7200) { if (t<1 || t>7200) {
throw meosException("Ogiltigt antal sekunder: X#" + minute); throw meosException(L"Ogiltigt antal sekunder: X#" + minute);
} }
else { else {
PunchMachine *pm=dynamic_cast<PunchMachine*>(getMachine(bu.getExtraInt())); 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") { else if (bu.id == "SelectAll") {
const char *ctrl = bu.getExtra(); const wchar_t *ctrl = bu.getExtra();
set<int> lst; set<int> lst;
lst.insert(-1); lst.insert(-1);
gdi.setSelection(ctrl, lst); gdi.setSelection(ctrl, lst);
} }
else if (bu.id == "SelectNone") { else if (bu.id == "SelectNone") {
const char *ctrl= bu.getExtra(); const wchar_t *ctrl= bu.getExtra();
set<int> lst; set<int> lst;
gdi.setSelection(ctrl, lst); gdi.setSelection(ctrl, lst);
} }
@ -491,17 +494,17 @@ int TabAuto::processButton(gdioutput &gdi, const ButtonInfo &bu)
oe->tryPrewarningSounds(pwm->waveFolder, rand()%400+1); oe->tryPrewarningSounds(pwm->waveFolder, rand()%400+1);
} }
else if ( bu.id == "WaveBrowse") { 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) if (wf.length()>0)
gdi.setText("WaveFolder", wf); gdi.setText("WaveFolder", wf);
} }
else if ( bu.id == "BrowseSplits") { else if ( bu.id == "BrowseSplits") {
int index=0; int index=0;
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("Sträcktider", "*.xml")); 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()) if (!wf.empty())
gdi.setText("FileName", wf); gdi.setText("FileName", wf);
@ -652,13 +655,13 @@ void AutoMachine::settingsTitle(gdioutput &gdi, char *title) {
gdi.dropLine(0.5); 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.pushX();
gdi.fillRight(); gdi.fillRight();
if (type == IntervalMinute) 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) 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.dropLine(1);
gdi.addButton(startCommand, "Starta automaten", AutomaticCB).setExtra(getId()); gdi.addButton(startCommand, "Starta automaten", AutomaticCB).setExtra(getId());
gdi.addButton(created ? "Stop":"Cancel", "Avbryt", 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) { void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Resultatutskrift / export"); 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); startCancelInterval(gdi, "StartResult", created, IntervalMinute, time);
if (created) { if (created) {
@ -697,7 +700,7 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addCheckbox("DoExport", "Exportera", AutomaticCB, doExport); gdi.addCheckbox("DoExport", "Exportera", AutomaticCB, doExport);
gdi.dropLine(-1); gdi.dropLine(-1);
int cx = gdi.getCX(); 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.dropLine(0.7);
gdi.addButton("BrowseFile", "Bläddra...", AutomaticCB); gdi.addButton("BrowseFile", "Bläddra...", AutomaticCB);
gdi.setCX(cx); 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.addCheckbox("HTMLRefresh", "HTML med AutoRefresh", 0, htmlRefresh != 0);
gdi.dropLine(1.2); gdi.dropLine(1.2);
gdi.setCX(cx); 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.dropLine(0.7);
gdi.addButton("BrowseScript", "Bläddra...", AutomaticCB); gdi.addButton("BrowseScript", "Bläddra...", AutomaticCB);
gdi.dropLine(3); gdi.dropLine(3);
@ -725,14 +728,14 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addString("", 1, "Listval"); gdi.addString("", 1, "Listval");
gdi.dropLine(); gdi.dropLine();
gdi.fillRight(); gdi.fillRight();
gdi.addListBox("Classes", 150,300,0,"","", true); gdi.addListBox("Classes", 150,300,0, L"", L"", true);
gdi.pushX(); gdi.pushX();
gdi.fillDown(); 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.addItem("Classes", oe.fillClasses(d, oEvent::extraNone, oEvent::filterNone));
gdi.setSelection("Classes", classesToPrint); gdi.setSelection("Classes", classesToPrint);
gdi.addSelection("ListType", 200, 100, 0, "Lista"); gdi.addSelection("ListType", 200, 100, 0, L"Lista");
oe.fillListTypes(gdi, "ListType", 1); oe.fillListTypes(gdi, "ListType", 1);
if (notShown) { if (notShown) {
notShown = false; notShown = false;
@ -749,9 +752,9 @@ void PrintResultMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
else else
gdi.selectItemByData("ListType", listInfo.getListCode()); 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; set<int> clsUnused;
vector< pair<string, size_t> > out; vector< pair<wstring, size_t> > out;
oe.fillLegNumbers(clsUnused, listInfo.isTeamList(), true, out); oe.fillLegNumbers(clsUnused, listInfo.isTeamList(), true, out);
gdi.addItem("LegNumber", out); gdi.addItem("LegNumber", out);
gdi.selectItemByData("LegNumber", listInfo.getLegNumberCoded()); 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.addCheckbox("OnlyChanged", "Skriv endast ut ändade sidor", 0, po.onlyChanged);
gdi.popX(); gdi.popX();
gdi.addButton("SelectAll", "Välj allt", AutomaticCB, "").setExtra("Classes"); gdi.addButton("SelectAll", "Välj allt", AutomaticCB, "").setExtra(L"Classes");
gdi.popX(); gdi.popX();
gdi.addButton("SelectNone", "Välj inget", AutomaticCB, "").setExtra("Classes"); gdi.addButton("SelectNone", "Välj inget", AutomaticCB, "").setExtra(L"Classes");
} }
else { else {
gdi.fillDown(); 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); 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; return;
if (ast!=SyncDataUp) { if (ast!=SyncDataUp) {
string printError; wstring printError;
lock = true; lock = true;
try { try {
gdioutput gdiPrint("print", gdi.getScale(), gdi.getEncoding()); gdioutput gdiPrint("print", gdi.getScale(), gdi.getCP());
gdiPrint.clearPage(false); gdiPrint.clearPage(false);
oe->generateList(gdiPrint, true, listInfo, false); oe->generateList(gdiPrint, true, listInfo, false);
if (doPrint) { if (doPrint) {
@ -793,17 +796,17 @@ void PrintResultMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast)
gdiPrint.print(po, oe); gdiPrint.print(po, oe);
} }
catch (const meosException &ex) { catch (const meosException &ex) {
printError = ex.what(); printError = ex.wwhat();
if (printError.empty()) 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 (doExport) {
if (!exportFile.empty()) { if (!exportFile.empty()) {
if (structuredExport) if (structuredExport)
gdiPrint.writeTableHTML(gdi.toWide(exportFile), oe->getName(), htmlRefresh); gdiPrint.writeTableHTML(exportFile, oe->getName(), htmlRefresh);
else else
gdiPrint.writeHTML(gdi.toWide(exportFile), oe->getName(), htmlRefresh); gdiPrint.writeHTML(exportFile, oe->getName(), htmlRefresh);
if (!exportScript.empty()) { if (!exportScript.empty()) {
ShellExecute(NULL, NULL, exportScript.c_str(), exportFile.c_str(), NULL, SW_HIDE); 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) { void PrewarningMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Förvarningsröst"); settingsTitle(gdi, "Förvarningsröst");
startCancelInterval(gdi, "StartPrewarning", created, IntervalNone, ""); startCancelInterval(gdi, "StartPrewarning", created, IntervalNone, L"");
gdi.addString("", 10, "help:computer_voice"); gdi.addString("", 10, "help:computer_voice");
gdi.pushX(); gdi.pushX();
gdi.fillRight(); gdi.fillRight();
gdi.addInput("WaveFolder", waveFolder, 32, 0, "Ljudfiler, baskatalog."); gdi.addInput("WaveFolder", waveFolder, 32, 0, L"Ljudfiler, baskatalog.");
gdi.fillDown(); gdi.fillDown();
gdi.dropLine(); gdi.dropLine();
gdi.addButton("WaveBrowse", "Bläddra...", AutomaticCB); gdi.addButton("WaveBrowse", "Bläddra...", AutomaticCB);
gdi.popX(); gdi.popX();
gdi.addListBox("Controls", 100, 200, 0, "", "", true); gdi.addListBox("Controls", 100, 200, 0, L"", L"", true);
gdi.pushX(); gdi.pushX();
gdi.fillDown(); gdi.fillDown();
vector< pair<string, size_t> > d; vector< pair<wstring, size_t> > d;
oe.fillControls(d, oEvent::CTCourseControl); oe.fillControls(d, oEvent::CTCourseControl);
gdi.addItem("Controls", d); gdi.addItem("Controls", d);
gdi.setSelection("Controls", controls); gdi.setSelection("Controls", controls);
gdi.popX(); gdi.popX();
gdi.addButton("SelectAll", "Välj alla", AutomaticCB, "").setExtra("Controls"); gdi.addButton("SelectAll", "Välj alla", AutomaticCB, "").setExtra(L"Controls");
gdi.popX(); gdi.popX();
} }
@ -923,7 +926,7 @@ void PrewarningMachine::status(gdioutput &gdi)
void PunchMachine::settings(gdioutput &gdi, oEvent &oe, bool created) { void PunchMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Test av stämplingsinläsningar"); 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); startCancelInterval(gdi, "StartPunch", created, IntervalSecond, time);
gdi.addString("", 10, "help:simulate"); gdi.addString("", 10, "help:simulate");
@ -934,15 +937,15 @@ void PunchMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.addString("", 0, "Radiotider, kontroll:"); gdi.addString("", 0, "Radiotider, kontroll:");
gdi.dropLine(-0.2); gdi.dropLine(-0.2);
gdi.addInput("Radio", "", 6, 0); gdi.addInput("Radio", L"", 6, 0);
gdi.fillDown(); gdi.fillDown();
gdi.popX(); gdi.popX();
gdi.dropLine(5); gdi.dropLine(5);
gdi.addString("", 1, "Generera testtävling"); gdi.addString("", 1, "Generera testtävling");
gdi.fillRight(); gdi.fillRight();
gdi.addInput("nRunner", "100", 10, 0, "Antal löpare"); gdi.addInput("nRunner", L"100", 10, 0, L"Antal löpare");
gdi.addInput("nClass", "10", 10, 0, "Antal klasser"); gdi.addInput("nClass", L"10", 10, 0, L"Antal klasser");
gdi.dropLine(); gdi.dropLine();
gdi.addCheckbox("UseRelay", "Med stafettklasser"); gdi.addCheckbox("UseRelay", "Med stafettklasser");
gdi.addButton("GenerateCMP", "Generera testtävling", AutomaticCB); gdi.addButton("GenerateCMP", "Generera testtävling", AutomaticCB);
@ -978,7 +981,7 @@ void PunchMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast)
if (!sic.empty()) { if (!sic.empty()) {
if (!radio) si.addCard(sic); 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()) { if (radio && !sic.empty()) {
pRunner r=oe->getRunnerByCardNo(sic.CardNumber, 0, false); 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) { void SplitsMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
string time = ""; wstring time;
if (interval>0) if (interval>0)
time = itos(interval); time = itow(interval);
else if (created) else if (created)
time = "30"; time = L"30";
settingsTitle(gdi, "Sträcktider / WinSplits"); settingsTitle(gdi, "Sträcktider / WinSplits");
startCancelInterval(gdi, "StartSplits", created, IntervalSecond, time); startCancelInterval(gdi, "StartSplits", created, IntervalSecond, time);
@ -1012,7 +1015,7 @@ void SplitsMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
gdi.dropLine(); gdi.dropLine();
gdi.fillRight(); gdi.fillRight();
gdi.addInput("FileName", file, 30, 0, "Filnamn:"); gdi.addInput("FileName", file, 30, 0, L"Filnamn:");
gdi.dropLine(0.9); gdi.dropLine(0.9);
gdi.addButton("BrowseSplits", "Bläddra...", AutomaticCB); gdi.addButton("BrowseSplits", "Bläddra...", AutomaticCB);
@ -1027,7 +1030,7 @@ void SplitsMachine::status(gdioutput &gdi)
if (!file.empty()) { if (!file.empty()) {
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); gdi.pushX();
gdi.addString("", 0, "Fil: X#" + file); gdi.addString("", 0, L"Fil: X#" + file);
if (interval>0){ if (interval>0){
gdi.popX(); gdi.popX();
@ -1064,7 +1067,7 @@ void SaveMachine::status(gdioutput &gdi) {
if (!baseFile.empty()) { if (!baseFile.empty()) {
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); gdi.pushX();
gdi.addString("", 0, "Destination: X#" + baseFile); gdi.addString("", 0, L"Destination: X#" + baseFile);
if (interval>0){ if (interval>0){
gdi.popX(); gdi.popX();
@ -1085,7 +1088,7 @@ void SaveMachine::status(gdioutput &gdi) {
void SaveMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast) { void SaveMachine::process(gdioutput &gdi, oEvent *oe, AutoSyncType ast) {
if (interval>0 && ast==SyncTimer) { if (interval>0 && ast==SyncTimer) {
if (!baseFile.empty()) { 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->autoSynchronizeLists(true);
oe->save(file); 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) { void SaveMachine::settings(gdioutput &gdi, oEvent &oe, bool created) {
settingsTitle(gdi, "Säkerhetskopiering"); 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); startCancelInterval(gdi, "StartBackup", created, IntervalMinute, time);
int cx = gdi.getCX(); int cx = gdi.getCX();
gdi.addInput("BaseFile", baseFile, 32, 0, "Mapp:"); gdi.addInput("BaseFile", baseFile, 32, 0, L"Mapp:");
gdi.dropLine(0.7); gdi.dropLine(0.7);
gdi.addButton("BrowseFolder", "Bläddra...", AutomaticCB).setExtra("BaseFile"); gdi.addButton("BrowseFolder", "Bläddra...", AutomaticCB).setExtra(L"BaseFile");
gdi.setCX(cx); gdi.setCX(cx);
} }
void SaveMachine::saveSettings(gdioutput &gdi) { void SaveMachine::saveSettings(gdioutput &gdi) {
string minute=gdi.getText("Interval"); wstring minute=gdi.getText("Interval");
int t=convertAbsoluteTimeMS(minute); int t=convertAbsoluteTimeMS(minute);
if (t<2 || t>7200) { if (t<2 || t>7200) {
throw meosException("Intervallet måste anges på formen MM:SS."); throw meosException("Intervallet måste anges på formen MM:SS.");
} }
string f = gdi.getText("BaseFile"); wstring f = gdi.getText("BaseFile");
if (f.empty()) { if (f.empty()) {
throw meosException("Filnamnet får inte vara tomt"); throw meosException("Filnamnet får inte vara tomt");
} }
if (*f.rbegin() != '\\' && *f.rbegin() != '/') 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); ofstream fout(sample.c_str(), ios_base::trunc|ios_base::out);
bool bad = false; bool bad = false;
if (fout.bad()) if (fout.bad())
@ -1129,10 +1132,10 @@ void SaveMachine::saveSettings(gdioutput &gdi) {
fout << "foo" << endl; fout << "foo" << endl;
fout.close(); fout.close();
bad = fout.bad(); bad = fout.bad();
remove(sample.c_str()); _wremove(sample.c_str());
} }
if (bad) if (bad)
throw meosException("Ogiltig destination X#" + f); throw meosException(L"Ogiltig destination X#" + f);
baseFile = f; baseFile = f;
interval = t; interval = t;

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -28,15 +28,15 @@ class TabClub :
{ {
int clubCB(gdioutput &gdi, int type, void *data); int clubCB(gdioutput &gdi, int type, void *data);
string firstDate; wstring firstDate;
string lastDate; wstring lastDate;
bool filterAge; bool filterAge;
bool onlyNoFee; bool onlyNoFee;
bool useManualFee; bool useManualFee;
int highAge; int highAge;
int lowAge; int lowAge;
int baseFee; int baseFee;
string typeS; wstring typeS;
int firstInvoice; int firstInvoice;
@ -50,7 +50,7 @@ protected:
public: public:
void selectClub(gdioutput &gdi, pClub pc); 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";} const char * getTypeStr() const {return "TClubTab";}
TabType getType() 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 : class TabCompetition :
public TabBase public TabBase
{ {
string eventorBase; enum FlowOperation {
string iofExportVersion; FlowContinue,
FlowCancel,
FlowAborted
};
wstring eventorBase;
wstring iofExportVersion;
void textSizeControl(gdioutput &gdi) const; void textSizeControl(gdioutput &gdi) const;
bool showConnectionPage; bool showConnectionPage;
@ -48,14 +54,14 @@ class TabCompetition :
list<PrefsEditor> prefsEditor; list<PrefsEditor> prefsEditor;
oFreeImport fi; oFreeImport fi;
string entryText; wstring entryText;
vector<oEntryBlock> entries; vector<oEntryBlock> entries;
void loadConnectionPage(gdioutput &gdi); void loadConnectionPage(gdioutput &gdi);
string defaultServer; wstring defaultServer;
string defaultName; wstring defaultName;
string defaultPwd; wstring defaultPwd;
string defaultPort; wstring defaultPort;
void copyrightLine(gdioutput &gdi) const; void copyrightLine(gdioutput &gdi) const;
void loadAboutPage(gdioutput &gdi) const; void loadAboutPage(gdioutput &gdi) const;
@ -65,30 +71,30 @@ class TabCompetition :
int lastChangeClassType; int lastChangeClassType;
struct { struct {
string name; wstring name;
string careOf; wstring careOf;
string street; wstring street;
string city; wstring city;
string zipCode; wstring zipCode;
string account; wstring account;
string email; wstring email;
} eventor; } eventor;
int getOrganizer(bool updateEvent); int getOrganizer(bool updateEvent);
void getAPIKey(vector< pair<string, string> > &key) const; void getAPIKey(vector< pair<wstring, wstring> > &key) const;
void getEventorCompetitions(gdioutput &gdi, void getEventorCompetitions(gdioutput &gdi,
const string &fromDate, const wstring &fromDate,
vector<CompetitionInfo> &events) const; vector<CompetitionInfo> &events) const;
void saveSettings(gdioutput &gdi); void saveSettings(gdioutput &gdi);
void loadSettings(gdioutput &gdi); void loadSettings(gdioutput &gdi);
void getEventorCmpData(gdioutput &gdi, int id, void getEventorCmpData(gdioutput &gdi, int id,
const string &eventFile, const wstring &eventFile,
const string &clubFile, const wstring &clubFile,
const string &classFile, const wstring &classFile,
const string &entryFile, const wstring &entryFile,
const string &dbFile) const; const wstring &dbFile) const;
void loadMultiEvent(gdioutput &gdi); void loadMultiEvent(gdioutput &gdi);
void saveMultiEvent(gdioutput &gdi); void saveMultiEvent(gdioutput &gdi);
@ -117,7 +123,9 @@ class TabCompetition :
void newCompetitionGuide(gdioutput &gdi, int step); void newCompetitionGuide(gdioutput &gdi, int step);
void entryForm(gdioutput &gdi, bool isGuide); 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 setExportOptionsStatus(gdioutput &gdi, int format) const;
void selectStartlistOptions(gdioutput &gdi); void selectStartlistOptions(gdioutput &gdi);
@ -137,7 +145,7 @@ public:
void saveMeosFeatures(gdioutput &gdi, bool write); void saveMeosFeatures(gdioutput &gdi, bool write);
void updateFeatureStatus(gdioutput &gdi); void updateFeatureStatus(gdioutput &gdi);
void setEventorServer(const string &server); void setEventorServer(const wstring &server);
void setEventorUTC(bool useUTC); void setEventorUTC(bool useUTC);
int competitionCB(gdioutput &gdi, int type, void *data); 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) { pc->getStatus() == oControl::StatusFinish) {
gdi.selectItemByData("Controls", pc->getId()); gdi.selectItemByData("Controls", pc->getId());
gdi.selectItemByData("Status", oControl::StatusOK); 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("Name", pc->getName());
gdi.setText("TimeAdjust", "00:00"); gdi.setText("TimeAdjust", L"00:00");
gdi.setText("MinTime", "-"); gdi.setText("MinTime", makeDash(L"-"));
gdi.setText("Point", ""); gdi.setText("Point", L"");
controlId = pc->getId(); controlId = pc->getId();
gdi.enableInput("Remove"); gdi.enableInput("Remove");
@ -88,7 +88,7 @@ void TabControl::selectControl(gdioutput &gdi, pControl pc)
else if (numVisitExp > 0) { else if (numVisitExp > 0) {
info = "Förväntat antal besökare: X#" + itos(numVisitExp); 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("Info", lang.tl(info), true);
gdi.setText("Code", pc->codeNumbers()); gdi.setText("Code", pc->codeNumbers());
@ -120,14 +120,14 @@ void TabControl::selectControl(gdioutput &gdi, pControl pc)
else { else {
gdi.selectItemByData("Controls", -1); gdi.selectItemByData("Controls", -1);
gdi.selectItemByData("Status", oControl::StatusOK); gdi.selectItemByData("Status", oControl::StatusOK);
gdi.setText("Code", ""); gdi.setText("Code", L"");
gdi.setText("Name", ""); gdi.setText("Name", L"");
controlId = 0; controlId = 0;
gdi.setText("ControlID", "-", true); gdi.setText("ControlID", makeDash(L"-"), true);
gdi.setText("TimeAdjust", "00:00"); gdi.setText("TimeAdjust", L"00:00");
if (gdi.hasField("Point")) if (gdi.hasField("Point"))
gdi.setText("Point", ""); gdi.setText("Point", L"");
gdi.disableInput("Remove"); gdi.disableInput("Remove");
gdi.disableInput("Save"); gdi.disableInput("Save");
@ -178,7 +178,7 @@ void TabControl::save(gdioutput &gdi)
pc->setName(gdi.getText("Name")); pc->setName(gdi.getText("Name"));
pc->synchronize(); pc->synchronize();
vector< pair<string, size_t> > d; vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll); oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d); gdi.addItem("Controls", d);
@ -226,12 +226,12 @@ void TabControl::courseTable(Table &table) const {
table.addRow(ix++, &it); table.addRow(ix++, &it);
int row = 0; 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_MODIFIED, it.getTimeStamp(), false);
table.set(row++, it, TID_COURSE, crs[k]->getName(), 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_INDEX, itow(used), false);
table.set(row++, it, TID_RUNNER, itos(runnersPerCourse[crs[k]->getId()]), 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); table.addRow(ix++, &it);
int row = 0; 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_MODIFIED, it.getTimeStamp(), false);
pRunner r = it.getOwner(); pRunner r = it.getOwner();
@ -289,8 +289,8 @@ void TabControl::visitorTable(Table &table) const {
table.set(row++, it, TID_COURSE, r->getCourseName(), false); table.set(row++, it, TID_COURSE, r->getCourseName(), false);
} }
else { else {
table.set(row++, it, TID_RUNNER, "-", false); table.set(row++, it, TID_RUNNER, L"-", false);
table.set(row++, it, TID_COURSE, "-", false); table.set(row++, it, TID_COURSE, L"-", false);
} }
table.set(row++, it, TID_FEE, punch->isUsedInCourse() ? table.set(row++, it, TID_FEE, punch->isUsedInCourse() ?
lang.tl("Ja") : lang.tl("Nej"), false); 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_STATUS, punch->getTime(), false);
table.set(row++, it, TID_CONTROL, punch->getType(), 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); pControl pc = oe->getControl(controlId, false);
rogaining = pc && pc->getStatus() == oControl::StatusRogaining; rogaining = pc && pc->getStatus() == oControl::StatusRogaining;
} }
pControl pc = oe->addControl(0,oe->getNextControlNumber(), ""); pControl pc = oe->addControl(0,oe->getNextControlNumber(), L"");
if (rogaining) if (rogaining)
pc->setStatus(oControl::StatusRogaining); pc->setStatus(oControl::StatusRogaining);
vector< pair<string, size_t> > d; vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll); oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d); gdi.addItem("Controls", d);
selectControl(gdi, pc); selectControl(gdi, pc);
@ -340,7 +340,7 @@ int TabControl::controlCB(gdioutput &gdi, int type, void *data)
else else
oe->removeControl(cid); oe->removeControl(cid);
vector< pair<string, size_t> > d; vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll); oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d); gdi.addItem("Controls", d);
selectControl(gdi, 0); selectControl(gdi, 0);
@ -354,7 +354,7 @@ int TabControl::controlCB(gdioutput &gdi, int type, void *data)
else if (bi.id=="Visitors") { else if (bi.id=="Visitors") {
save(gdi); 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("Id", 70, true, true);
table->addColumn("Ändrad", 70, false); table->addColumn("Ändrad", 70, false);
@ -378,7 +378,7 @@ int TabControl::controlCB(gdioutput &gdi, int type, void *data)
gdi.refresh(); gdi.refresh();
} }
else if (bi.id=="Courses") { 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("Id", 70, true, true);
table->addColumn("Ändrad", 70, false); 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.addListBox("Controls", 250, 530, ControlsCB).isEdit(false).ignore(true);
gdi.setTabStops("Controls", 40, 160); gdi.setTabStops("Controls", 40, 160);
vector< pair<string, size_t> > d; vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTAll); oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d); gdi.addItem("Controls", d);
@ -472,14 +472,14 @@ bool TabControl::loadPage(gdioutput &gdi)
gdi.popX(); gdi.popX();
gdi.fillRight(); 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"); oe->fillControlStatus(gdi, "Status");
gdi.addInput("TimeAdjust", "", 6, 0, "Tidsjustering:"); gdi.addInput("TimeAdjust", L"", 6, 0, L"Tidsjustering:");
gdi.fillDown(); gdi.fillDown();
gdi.addInput("MinTime", "", 6, 0, "Minsta sträcktid:"); gdi.addInput("MinTime", L"", 6, 0, L"Minsta sträcktid:");
gdi.popX(); gdi.popX();
gdi.dropLine(0.5); gdi.dropLine(0.5);
@ -488,10 +488,10 @@ bool TabControl::loadPage(gdioutput &gdi)
gdi.fillRight(); gdi.fillRight();
gdi.dropLine(0.5); 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)) { 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.popX();
gdi.dropLine(3.5); gdi.dropLine(3.5);

View File

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

View File

@ -35,11 +35,11 @@ class TabCourse :
int courseCB(gdioutput &gdi, int type, void *data); int courseCB(gdioutput &gdi, int type, void *data);
bool addedCourse; bool addedCourse;
string time_limit; wstring time_limit;
string point_limit; wstring point_limit;
string point_reduction; wstring point_reduction;
void fillCourseControls(gdioutput &gdi, const string &ctrl); void fillCourseControls(gdioutput &gdi, const wstring &ctrl);
void fillOtherCourses(gdioutput &gdi, oCourse &crs); void fillOtherCourses(gdioutput &gdi, oCourse &crs);
void saveLegLengths(gdioutput &gdi); void saveLegLengths(gdioutput &gdi);
@ -48,10 +48,10 @@ class TabCourse :
DrawMethod getDefaultMethod() const; DrawMethod getDefaultMethod() const;
string encodeCourse(const string &in, bool firstStart, bool lastFinish); wstring encodeCourse(const wstring &in, bool firstStart, bool lastFinish);
void refreshCourse(const string &text, gdioutput &gdi); void refreshCourse(const wstring &text, gdioutput &gdi);
const string &formatControl(int id, string &bf) const; const wstring &formatControl(int id, wstring &bf) const;
protected: protected:
void clearCompetitionData(); void clearCompetitionData();
@ -68,7 +68,7 @@ public:
TabCourse(oEvent *oe); TabCourse(oEvent *oe);
~TabCourse(void); ~TabCourse(void);
static void runCourseImport(gdioutput& gdi, const string &filename, static void runCourseImport(gdioutput& gdi, const wstring &filename,
oEvent *oe, bool addClasses); oEvent *oe, bool addClasses);
static void setupCourseImport(gdioutput& gdi, GUICALLBACK cb); 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->highlight=false;
ti->active=false; ti->active=false;
ti->color=RGB(255,0,0); ti->color=RGB(255,0,0);
gdi->setText(ti->id, "Ej start", true); gdi->setText(ti->id, L"Ej start", true);
} }
} }
return 0; return 0;
@ -213,8 +213,8 @@ void TabList::generateList(gdioutput &gdi)
oe->generateList(gdi, !noReEvaluate, currentList, false); oe->generateList(gdi, !noReEvaluate, currentList, false);
} }
catch (const meosException &ex) { catch (const meosException &ex) {
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 1, "List Error: X#" + err).setColor(colorRed); gdi.addString("", 1, L"List Error: X#" + err).setColor(colorRed);
} }
gdi.setOffset(oX, oY, false); gdi.setOffset(oX, oY, false);
@ -300,37 +300,38 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
gdi.print(oe); gdi.print(oe);
} }
else if (bi.id=="HTML") { else if (bi.id=="HTML") {
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("Strukturerat webbdokument (html)", "*.html;*.htm")); ext.push_back(make_pair(L"Strukturerat webbdokument (html)", L"*.html;*.htm"));
ext.push_back(make_pair("Formaterat webbdokument (html)", "*.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 (!file.empty()) {
if (index == 1) if (index == 1)
gdi.writeTableHTML(gdi.toWide(file), oe->getName(), 0); gdi.writeTableHTML(file, oe->getName(), 0);
else { else {
assert(index == 2); assert(index == 2);
gdi.writeHTML(gdi.toWide(file), oe->getName(), 0); gdi.writeHTML(file, oe->getName(), 0);
} }
gdi.openDoc(file.c_str()); gdi.openDoc(file.c_str());
} }
} }
else if (bi.id=="Copy") { else if (bi.id=="Copy") {
ostringstream fout; ostringstream fout;
gdi.writeTableHTML(fout, "MeOS", true, 0); gdi.writeTableHTML(fout, L"MeOS", true, 0);
string res = fout.str(); string res = fout.str();
gdi.copyToClipboard(res, false, ""); gdi.copyToClipboard(res, L"");
} }
else if (bi.id=="PDF") { else if (bi.id=="PDF") {
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("Portable Document Format (PDF)", "*.pdf")); 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()) { if (!file.empty()) {
pdfwriter pdf; 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()); gdi.openDoc(file.c_str());
} }
} }
@ -339,7 +340,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
gdioutput *gdi_new; gdioutput *gdi_new;
TabList *tl_new = this; TabList *tl_new = this;
if (!ownWindow) { 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) { if (gdi_new) {
TabList &tl = dynamic_cast<TabList &>(*gdi_new->getTabs().get(TListTab)); TabList &tl = dynamic_cast<TabList &>(*gdi_new->getTabs().get(TListTab));
tl.currentList = currentList; tl.currentList = currentList;
@ -377,7 +378,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
} }
else if (bi.id == "Remember") { else if (bi.id == "Remember") {
oListParam &par = currentList.getParam(); oListParam &par = currentList.getParam();
string baseName = par.getDefaultName(); wstring baseName = par.getDefaultName();
baseName = oe->getListContainer().makeUniqueParamName(baseName); baseName = oe->getListContainer().makeUniqueParamName(baseName);
par.setName(baseName); par.setName(baseName);
oe->synchronize(false); oe->synchronize(false);
@ -399,7 +400,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
if (gdi.getSelectedItem("SavedInstance", lbi)) { if (gdi.getSelectedItem("SavedInstance", lbi)) {
const oListParam &par = oe->getListContainer().getParam(lbi.data); const oListParam &par = oe->getListContainer().getParam(lbi.data);
gdi.clearPage(true); 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.setData("ParamIx", lbi.data);
gdi.dropLine(); gdi.dropLine();
gdi.fillRight(); gdi.fillRight();
@ -413,7 +414,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
else if (bi.id == "DoRenameSaved") { else if (bi.id == "DoRenameSaved") {
int ix = int(gdi.getData("ParamIx")); int ix = int(gdi.getData("ParamIx"));
oListParam &par = oe->getListContainer().getParam(ix); oListParam &par = oe->getListContainer().getParam(ix);
string name = gdi.getText("Name"); wstring name = gdi.getText("Name");
par.setName(name); par.setName(name);
loadPage(gdi); loadPage(gdi);
} }
@ -423,11 +424,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
//oe->getListContainer().mergeParam(0, lbi.data); //oe->getListContainer().mergeParam(0, lbi.data);
const oListParam &par = oe->getListContainer().getParam(lbi.data); const oListParam &par = oe->getListContainer().getParam(lbi.data);
gdi.clearPage(true); 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.setData("ParamIx", lbi.data);
gdi.dropLine(); gdi.dropLine();
gdi.addListBox("Merge", 350, 250, 0, "Slå ihop med:"); gdi.addListBox("Merge", 350, 250, 0, L"Slå ihop med:");
vector < pair<string, size_t> > cand; vector < pair<wstring, size_t> > cand;
oe->getListContainer().getMergeCandidates(lbi.data, cand); oe->getListContainer().getMergeCandidates(lbi.data, cand);
gdi.addItem("Merge", cand); gdi.addItem("Merge", cand);
gdi.addCheckbox("ShowTitle", "Visa rubrik mellan listorna", 0, false); 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; lastResultClassSelection = par.selection;
par.filterMaxPer = gdi.getTextNo("ClassLimit"); par.filterMaxPer = gdi.getTextNo("ClassLimit");
par.inputNumber = gdi.getTextNo("InputNumber"); par.inputNumber = gdi.getTextNo("InputNumber");
lastInputNumber = itos(par.inputNumber); lastInputNumber = itow(par.inputNumber);
par.pageBreak = gdi.isChecked("PageBreak"); par.pageBreak = gdi.isChecked("PageBreak");
par.listCode = (EStdListType)currentListType; par.listCode = (EStdListType)currentListType;
@ -981,7 +982,7 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
else if (bi.id == "ImportCustom") { else if (bi.id == "ImportCustom") {
MetaListContainer &lc = oe->getListContainer(); MetaListContainer &lc = oe->getListContainer();
vector< pair<string, int> > installedLists; vector< pair<wstring, int> > installedLists;
set<string> installedId; set<string> installedId;
for (int k = 0; k < lc.getNumLists(); k++) { for (int k = 0; k < lc.getNumLists(); k++) {
if (lc.isExternal(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); lc.enumerateLists(lists);
if (lists.empty() && installedLists.empty()) { if (lists.empty() && installedLists.empty()) {
bi.id = "BrowseList"; bi.id = "BrowseList";
@ -1061,11 +1062,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
gdi.refresh(); gdi.refresh();
} }
else if (bi.id == "BrowseList") { else if (bi.id == "BrowseList") {
vector< pair<string, string> > filter; vector< pair<wstring, wstring> > filter;
filter.push_back(make_pair("xml-data", "*.xml;*.meoslist")); filter.push_back(make_pair(L"xml-data", L"*.xml;*.meoslist"));
string file = gdi.browseForOpen(filter, "xml"); wstring file = gdi.browseForOpen(filter, L"xml");
if (!file.empty()) { if (!file.empty()) {
xmlparser xml(0); xmlparser xml;
xml.read(file); xml.read(file);
xmlobject xlist = xml.getObject(0); xmlobject xlist = xml.getObject(0);
oe->synchronize(); oe->synchronize();
@ -1075,13 +1076,6 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
loadPage(gdi); 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") { else if (bi.id == "EditInForest") {
TabRunner &rt = dynamic_cast<TabRunner &>(*gdi.getTabs().get(TRunnerTab)); TabRunner &rt = dynamic_cast<TabRunner &>(*gdi.getTabs().get(TRunnerTab));
rt.showInForestList(gdi); rt.showInForestList(gdi);
@ -1140,11 +1134,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
else if (type == GUI_LINK) { else if (type == GUI_LINK) {
TextInfo ti = *(TextInfo *)data; TextInfo ti = *(TextInfo *)data;
if (ti.id == "CustomList") { if (ti.id == "CustomList") {
vector< pair<string, pair<string, string> > > lists; vector< pair<wstring, pair<string, wstring> > > lists;
oe->getListContainer().enumerateLists(lists); oe->getListContainer().enumerateLists(lists);
size_t ix = ti.getExtraSize(); size_t ix = ti.getExtraSize();
if (ix < lists.size()) { if (ix < lists.size()) {
xmlparser xml(0); xmlparser xml;
xml.read(lists[ix].second.second); xml.read(lists[ix].second.second);
xmlobject xlist = xml.getObject(0); xmlobject xlist = xml.getObject(0);
@ -1159,11 +1153,11 @@ int TabList::listCB(gdioutput &gdi, int type, void *data)
} }
else if (ti.id == "RemoveList") { else if (ti.id == "RemoveList") {
vector< pair<string, pair<string, string> > > lists; vector< pair<wstring, pair<string, wstring> > > lists;
oe->getListContainer().enumerateLists(lists); oe->getListContainer().enumerateLists(lists);
size_t ix = ti.getExtraSize(); size_t ix = ti.getExtraSize();
if (ix < lists.size()) { 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()); 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") { else if (ti.id == "RemoveInstalled") {
int ix = ti.getExtraInt(); 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->synchronize(false);
oe->getListContainer().removeList(ix); 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) { 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); oe.fillControls(d, oEvent::CTCourseControl);
if (from) { if (from) {
gdi.enableInput("ResultSpecialFrom"); 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.push_back(make_pair(lang.tl("Start"), 0));
ds.insert(ds.end(), d.begin(), d.end()); ds.insert(ds.end(), d.begin(), d.end());
gdi.addItem("ResultSpecialFrom", ds); gdi.addItem("ResultSpecialFrom", ds);
@ -1261,7 +1255,7 @@ void TabList::selectGeneralList(gdioutput &gdi, EStdListType type)
//gdi.enableInput("LegNumber"); //gdi.enableInput("LegNumber");
//oe->fillLegNumbers(gdi, "LegNumber", li.isTeamList(), true); //oe->fillLegNumbers(gdi, "LegNumber", li.isTeamList(), true);
set<int> clsUnused; set<int> clsUnused;
vector< pair<string, size_t> > out; vector< pair<wstring, size_t> > out;
oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out); oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out);
gdi.addItem("LegNumber", out); gdi.addItem("LegNumber", out);
gdi.setInputStatus("LegNumber", !out.empty()); gdi.setInputStatus("LegNumber", !out.empty());
@ -1276,7 +1270,7 @@ void TabList::selectGeneralList(gdioutput &gdi, EStdListType type)
void TabList::makeClassSelection(gdioutput &gdi) { void TabList::makeClassSelection(gdioutput &gdi) {
gdi.fillDown(); gdi.fillDown();
gdi.addListBox("ListSelection", 250, 300, ListsCB, "Urval:", "", true); gdi.addListBox("ListSelection", 250, 300, ListsCB, L"Urval:", L"", true);
gdi.pushX(); gdi.pushX();
gdi.fillRight(); gdi.fillRight();
@ -1295,7 +1289,7 @@ void TabList::loadGeneralList(gdioutput &gdi)
gdi.addString("", boldLarge, "Skapa generell lista"); gdi.addString("", boldLarge, "Skapa generell lista");
gdi.dropLine(0.8); gdi.dropLine(0.8);
gdi.pushY(); gdi.pushY();
gdi.addSelection("ListType", 250, 300, ListsCB, "Lista:"); gdi.addSelection("ListType", 250, 300, ListsCB, L"Lista:");
oe->fillListTypes(gdi, "ListType", 0); oe->fillListTypes(gdi, "ListType", 0);
makeClassSelection(gdi); makeClassSelection(gdi);
@ -1313,11 +1307,11 @@ void TabList::loadGeneralList(gdioutput &gdi)
if (lastLimitPer == -1) { if (lastLimitPer == -1) {
lastLimitPer = oe->getPropertyInt("classlimit", 0); lastLimitPer = oe->getPropertyInt("classlimit", 0);
} }
string lastClassLimit; wstring lastClassLimit;
if (lastLimitPer > 0) 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(); gdi.dropLine();
makeFromTo(gdi); makeFromTo(gdi);
@ -1333,10 +1327,10 @@ void TabList::loadGeneralList(gdioutput &gdi)
gdi.popX(); gdi.popX();
gdi.dropLine(3); gdi.dropLine(3);
*/ */
gdi.addSelection("LegNumber", 140, 300, ListsCB, "Sträcka:"); gdi.addSelection("LegNumber", 140, 300, ListsCB, L"Sträcka:");
gdi.disableInput("LegNumber"); 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.disableInput("InputNumber");
gdi.popX(); gdi.popX();
@ -1347,7 +1341,7 @@ void TabList::loadGeneralList(gdioutput &gdi)
gdi.dropLine(3); gdi.dropLine(3);
gdi.addInput("Title", "", 32, ListsCB, "Egen listrubrik:"); gdi.addInput("Title", L"", 32, ListsCB, L"Egen listrubrik:");
gdi.dropLine(); gdi.dropLine();
gdi.fillRight(); gdi.fillRight();
@ -1372,10 +1366,10 @@ void TabList::makeFromTo(gdioutput &gdi) {
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); 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.disableInput("ResultSpecialFrom");
gdi.addSelection("ResultSpecialTo", 140, 300, ListsCB, "Till kontroll:"); gdi.addSelection("ResultSpecialTo", 140, 300, ListsCB, L"Till kontroll:");
gdi.disableInput("ResultSpecialTo"); gdi.disableInput("ResultSpecialTo");
gdi.popX(); gdi.popX();
@ -1388,14 +1382,14 @@ void TabList::settingsResultList(gdioutput &gdi)
oe->sanityCheck(gdi, true); oe->sanityCheck(gdi, true);
gdi.fillDown(); gdi.fillDown();
gdi.clearPage(false); 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"); //gdi.addSelection("ListType", 200, 300, ListsCB, "Lista");
//oe->fillListTypes(gdi, "ListType", 0); //oe->fillListTypes(gdi, "ListType", 0);
const int boxHeight = 380; const int boxHeight = 380;
gdi.pushY(); gdi.pushY();
gdi.fillDown(); 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.dropLine(0.5);
gdi.fillRight(); gdi.fillRight();
@ -1414,8 +1408,8 @@ void TabList::settingsResultList(gdioutput &gdi)
gdi.addListBox("ResultType", 180, boxHeight, ListsCB); gdi.addListBox("ResultType", 180, boxHeight, ListsCB);
vector< pair<string, size_t> > lists; vector< pair<wstring, size_t> > lists;
vector< pair<string, size_t> > dlists; vector< pair<wstring, size_t> > dlists;
const MetaListContainer &lc = oe->getListContainer(); const MetaListContainer &lc = oe->getListContainer();
lc.getLists(dlists, false, true, !oe->hasTeam()); lc.getLists(dlists, false, true, !oe->hasTeam());
set<int> usedListIx; set<int> usedListIx;
@ -1427,20 +1421,20 @@ void TabList::settingsResultList(gdioutput &gdi)
} }
lists.reserve(dlists.size() + 10); 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)) 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)) { if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Relay)) {
lists.push_back(make_pair(lang.tl("Stafett - total"), 3)); lists.push_back(make_pair(lang.tl(L"Stafett - total"), 3));
lists.push_back(make_pair(lang.tl("Stafett - sammanställning"), 4)); 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))); 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(); size_t startIx = lists.size();
for (size_t k = 0; k < dlists.size(); k++) { for (size_t k = 0; k < dlists.size(); k++) {
@ -1479,28 +1473,28 @@ void TabList::settingsResultList(gdioutput &gdi)
if (lastLimitPer == -1) { if (lastLimitPer == -1) {
lastLimitPer = oe->getPropertyInt("classlimit", 0); lastLimitPer = oe->getPropertyInt("classlimit", 0);
} }
string lastClassLimit; wstring lastClassLimit;
if (lastLimitPer > 0) if (lastLimitPer > 0)
lastClassLimit = itos(lastLimitPer); lastClassLimit = itow(lastLimitPer);
gdi.addInput("ClassLimit", lastClassLimit, 5, 0); gdi.addInput("ClassLimit", lastClassLimit, 5, 0);
gdi.popX(); gdi.popX();
gdi.dropLine(2); gdi.dropLine(2);
gdi.addString("", 0, "Listparameter:"); gdi.addString("", 0, "Listparameter:");
gdi.dropLine(-0.2); 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.disableInput("InputNumber");
gdi.popX(); gdi.popX();
gdi.dropLine(2); gdi.dropLine(2);
makeFromTo(gdi); makeFromTo(gdi);
gdi.addSelection("LegNumber", 140, 300, ListsCB, "Sträcka:"); gdi.addSelection("LegNumber", 140, 300, ListsCB, L"Sträcka:");
gdi.disableInput("LegNumber"); gdi.disableInput("LegNumber");
gdi.popX(); gdi.popX();
gdi.dropLine(3); gdi.dropLine(3);
gdi.addInput("Title", "", 32, ListsCB, "Egen listrubrik:"); gdi.addInput("Title", L"", 32, ListsCB, L"Egen listrubrik:");
gdi.popX(); gdi.popX();
gdi.dropLine(3.5); gdi.dropLine(3.5);
@ -1694,7 +1688,7 @@ bool TabList::loadPage(gdioutput &gdi)
gdi.dropLine(3); gdi.dropLine(3);
gdi.fillDown(); gdi.fillDown();
vector< pair<string, size_t> > savedParams; vector< pair<wstring, size_t> > savedParams;
lc.getListParam(savedParams); lc.getListParam(savedParams);
if (savedParams.size() > 0) { if (savedParams.size() > 0) {
gdi.addString("", 1, "Sparade listval"); gdi.addString("", 1, "Sparade listval");
@ -1788,7 +1782,7 @@ bool TabList::loadPage(gdioutput &gdi)
int v = k; int v = k;
if (v>12) if (v>12)
v=(v-11)*10; v=(v-11)*10;
gdi.addItem("ClassLimit", itos(v), v); gdi.addItem("ClassLimit", itow(v), v);
} }
gdi.selectItemByData("ClassLimit", oe->getPropertyInt("classlimit", 0)); gdi.selectItemByData("ClassLimit", oe->getPropertyInt("classlimit", 0));
@ -1867,15 +1861,15 @@ void TabList::splitPrintSettings(oEvent &oe, gdioutput &gdi, bool setupPrinter,
if (returnMode == TSITab) { if (returnMode == TSITab) {
int printLen = oe.getPropertyInt("NumSplitsOnePage", 3); 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++) for (size_t j = 1; j < 8; j++)
nsp.push_back(make_pair(itos(j), j)); nsp.push_back(make_pair(itow(j), j));
gdi.addSelection("NumPerPage", 90, 200, ListsCB, "Max antal brickor per sida"); gdi.addSelection("NumPerPage", 90, 200, ListsCB, L"Max antal brickor per sida");
gdi.addItem("NumPerPage", nsp); gdi.addItem("NumPerPage", nsp);
gdi.selectItemByData("NumPerPage", printLen); gdi.selectItemByData("NumPerPage", printLen);
int maxWait = oe.getPropertyInt("SplitPrintMaxWait", 60); 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); 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) { 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++) { for (int k = 0; k < 5; k++) {
string row = "row"+itos(k); string row = "row"+itos(k);
string key = "font"+itos(k); string key = "font"+itos(k);
ListBoxInfo lbi; ListBoxInfo lbi;
gdi.getSelectedItem(key, lbi); gdi.getSelectedItem(key, lbi);
string r = gdi.getText(row); wstring r = gdi.getText(row);
lines.push_back(make_pair(r, lbi.data)); lines.push_back(make_pair(r, lbi.data));
} }
oe.setExtraLines(dataField, lines); oe.setExtraLines(dataField, lines);
@ -1907,8 +1901,8 @@ void TabList::customTextLines(oEvent &oe, const char *dataField, gdioutput &gdi)
gdi.dropLine(2.5); gdi.dropLine(2.5);
gdi.addString("", boldText, "Egna textrader"); gdi.addString("", boldText, "Egna textrader");
vector< pair<string, size_t> > fonts; vector< pair<wstring, size_t> > fonts;
vector< pair<string, int> > lines; vector< pair<wstring, int> > lines;
MetaListPost::getAllFonts(fonts); MetaListPost::getAllFonts(fonts);
oe.getExtraLines(dataField, lines); oe.getExtraLines(dataField, lines);
@ -1917,7 +1911,7 @@ void TabList::customTextLines(oEvent &oe, const char *dataField, gdioutput &gdi)
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); gdi.pushX();
string row = "row"+itos(k); string row = "row"+itos(k);
gdi.addInput(row, "", 24); gdi.addInput(row, L"", 24);
string key = "font"+itos(k); string key = "font"+itos(k);
gdi.addSelection(key, 100, 100); gdi.addSelection(key, 100, 100);
gdi.addItem(key, fonts); gdi.addItem(key, fonts);
@ -1968,7 +1962,7 @@ EStdListType TabList::getTypeFromResultIndex(int ix) const {
void TabList::setResultOptionsFromType(gdioutput &gdi, int data) { void TabList::setResultOptionsFromType(gdioutput &gdi, int data) {
bool builtIn = data < CUSTOM_OFFSET; bool builtIn = data < CUSTOM_OFFSET;
string info, title; wstring info, title;
bool hasResMod = false; bool hasResMod = false;
oListInfo li; oListInfo li;
EStdListType type = getTypeFromResultIndex(data); EStdListType type = getTypeFromResultIndex(data);
@ -1993,7 +1987,7 @@ void TabList::setResultOptionsFromType(gdioutput &gdi, int data) {
set<int> clsUnused; set<int> clsUnused;
vector< pair<string, size_t> > out; vector< pair<wstring, size_t> > out;
oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out); oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out);
gdi.addItem("LegNumber", out); gdi.addItem("LegNumber", out);
@ -2019,7 +2013,7 @@ void TabList::setResultOptionsFromType(gdioutput &gdi, int data) {
gdi.enableInput("LegNumber"); gdi.enableInput("LegNumber");
//oe->fillLegNumbers(gdi, "LegNumber", li.isTeamList(), true); //oe->fillLegNumbers(gdi, "LegNumber", li.isTeamList(), true);
set<int> clsUnused; set<int> clsUnused;
vector< pair<string, size_t> > out; vector< pair<wstring, size_t> > out;
oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out); oe->fillLegNumbers(clsUnused, li.isTeamList(), true, out);
gdi.addItem("LegNumber", out); gdi.addItem("LegNumber", out);
if (!out.empty() && lastLeg >= 0) if (!out.empty() && lastLeg >= 0)

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -40,11 +40,13 @@
#include "TabSpeaker.h" #include "TabSpeaker.h"
#include "TabList.h" #include "TabList.h"
#include "speakermonitor.h" #include "speakermonitor.h"
#include "meosexception.h"
#include <cassert> #include <cassert>
//Base position for speaker buttons //Base position for speaker buttons
#define SPEAKER_BASE_X 40 #define SPEAKER_BASE_X 40
vector<string> getExtraWindows();
TabSpeaker::TabSpeaker(oEvent *poe):TabBase(poe) TabSpeaker::TabSpeaker(oEvent *poe):TabBase(poe)
{ {
@ -124,16 +126,27 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
gdi.pushX(); gdi.pushX();
gdi.fillRight(); 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); oe->fillClasses(gdi, "Classes", oEvent::extraNone, oEvent::filterNone);
gdi.setSelection("Classes", classesToWatch); 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.pushX();
gdi.fillDown(); gdi.fillDown();
vector< pair<string, size_t> > d; vector< pair<wstring, size_t> > d;
oe->fillControls(d, oEvent::CTCourseControl); oe->fillControls(d, oEvent::CTCourseControl);
gdi.addItem("Controls", d); gdi.addItem("Controls", d);
@ -145,6 +158,15 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
gdi.refresh(); 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") { else if (bu.id=="ZoomIn") {
gdi.scaleSize(1.05); gdi.scaleSize(1.05);
} }
@ -174,7 +196,7 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); gdi.pushX();
gdi.addString("", 0, "Klass:"); 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); oe->fillClasses(gdi, "Class", oEvent::extraNone, oEvent::filterNone);
gdi.addButton("ClosePri", "Stäng", tabSpeakerCB); gdi.addButton("ClosePri", "Stäng", tabSpeakerCB);
gdi.dropLine(2); gdi.dropLine(2);
@ -186,7 +208,7 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
loadPage(gdi); loadPage(gdi);
} }
else if (bu.id == "LiveResult") { 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->clearPage(false);
gdi_new->addString("", boldLarge, "Liveresultat"); gdi_new->addString("", boldLarge, "Liveresultat");
@ -228,22 +250,61 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
} }
else if (bu.id == "Events") { else if (bu.id == "Events") {
gdi.restore("classes"); gdi.restore("classes");
/* classId = -1;
shownEvents.clear();
events.clear();
*/
drawTimeLine(gdi); drawTimeLine(gdi);
} }
else if (bu.id == "Window") { else if (bu.id == "Window") {
oe->setupTimeLineEvents(0); 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) { if (gdi_new) {
TabSpeaker &tl = dynamic_cast<TabSpeaker &>(*gdi_new->getTabs().get(TSpeakerTab)); TabSpeaker &tl = dynamic_cast<TabSpeaker &>(*gdi_new->getTabs().get(TSpeakerTab));
tl.ownWindow = true; tl.ownWindow = true;
tl.loadPage(*gdi_new); tl.loadPage(*gdi_new);
//oe->renderTimeLineEvents(*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") { else if (bu.id=="StoreTime") {
storeManualTime(gdi); storeManualTime(gdi);
@ -260,13 +321,11 @@ int TabSpeaker::processButton(gdioutput &gdi, const ButtonInfo &bu)
if (controlsToWatch.empty()) if (controlsToWatch.empty())
controlsToWatch.insert(-2); // Non empty but no control controlsToWatch.insert(-2); // Non empty but no control
controlsToWatchSI.clear();
for (set<int>::iterator it=controlsToWatch.begin();it!=controlsToWatch.end();++it) { for (set<int>::iterator it=controlsToWatch.begin();it!=controlsToWatch.end();++it) {
pControl pc=oe->getControl(*it, false); pControl pc=oe->getControl(*it, false);
if (pc) { if (pc) {
pc->setRadio(true); pc->setRadio(true);
pc->synchronize(true); pc->synchronize(true);
controlsToWatchSI.insert(pc->Numbers, pc->Numbers+pc->nNumbers);
} }
} }
oe->setProperty("SpeakerShortNames", (int)gdi.isChecked("ShortNames")); 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") { else if (bu.id.substr(0, 4)=="ctrl") {
bool shortNames = oe->getPropertyInt("SpeakerShortNames", false) != 0; 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(); int ctrlPrev = bu.getExtraInt();
selectedControl[classId].setControl(ctrl, ctrlPrev); selectedControl[classId].setControl(ctrl, ctrlPrev);
gdi.restore("speaker"); gdi.restore("speaker");
@ -305,10 +365,29 @@ void TabSpeaker::drawTimeLine(gdioutput &gdi) {
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); 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.addString("", 0, "Filtrering:");
gdi.dropLine(-0.2); gdi.dropLine(-0.2);
gdi.addSelection("DetailLevel", 160, 100, tabSpeakerCB); 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("Alla händelser"), oTimeLine::PLow);
gdi.addItem("DetailLevel", lang.tl("Viktiga händelser"), oTimeLine::PMedium); gdi.addItem("DetailLevel", lang.tl("Viktiga händelser"), oTimeLine::PMedium);
gdi.addItem("DetailLevel", lang.tl("Avgörande händelser"), oTimeLine::PHigh); 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#10"), 10);
gdi.addItem("WatchNumber", lang.tl("X senaste#20"), 20); gdi.addItem("WatchNumber", lang.tl("X senaste#20"), 20);
gdi.addItem("WatchNumber", lang.tl("X senaste#50"), 50); 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.selectItemByData("WatchNumber", watchNumber);
gdi.dropLine(2); gdi.dropLine(2);
gdi.popX(); gdi.popX();
string cls; wstring cls;
for (set<int>::iterator it = classesToWatch.begin(); it != classesToWatch.end(); ++it) { for (set<int>::iterator it = classesToWatch.begin(); it != classesToWatch.end(); ++it) {
pClass pc = oe->getClass(*it); pClass pc = oe->getClass(*it);
if (pc) { if (pc) {
if (!cls.empty()) if (!cls.empty())
cls += ", "; cls += L", ";
cls += oe->getClass(*it)->getName(); cls += oe->getClass(*it)->getName();
} }
} }
gdi.fillDown(); gdi.fillDown();
gdi.addString("", 1, "Bevakar händelser i X#" + cls); gdi.addString("", 1, L"Bevakar händelser i X#" + cls);
gdi.dropLine(); gdi.dropLine();
gdi.setRestorePoint("TimeLine"); gdi.setRestorePoint("TimeLine");
@ -566,7 +645,7 @@ void TabSpeaker::splitAnalysis(gdioutput &gdi, int xp, int yp, pRunner r)
vector<int> delta; vector<int> delta;
r->getSplitAnalysis(delta); r->getSplitAnalysis(delta);
string timeloss = lang.tl("Bommade kontroller: "); wstring timeloss = lang.tl("Bommade kontroller: ");
pCourse pc = 0; pCourse pc = 0;
bool first = true; bool first = true;
const int charlimit = 90; const int charlimit = 90;
@ -579,16 +658,16 @@ void TabSpeaker::splitAnalysis(gdioutput &gdi, int xp, int yp, pRunner r)
} }
if (!first) if (!first)
timeloss += " | "; timeloss += L" | ";
else else
first = false; 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())) { if (timeloss.length() > charlimit || (!timeloss.empty() && !first && j+1 == delta.size())) {
gdi.addStringUT(yp, xp, 0, timeloss).setColor(colorDarkRed); gdi.addStringUT(yp, xp, 0, timeloss).setColor(colorDarkRed);
yp += gdi.getLineHeight(); yp += gdi.getLineHeight();
timeloss = ""; timeloss = L"";
} }
} }
if (first) { if (first) {
@ -645,9 +724,10 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
if (!keepLegs) { if (!keepLegs) {
gdi.setData("CurrentY", cy); gdi.setData("CurrentY", cy);
gdi.addSelection(cx, cy+2, "Leg", int(bw/gdi.getScale())-5, 100, tabSpeakerCB); 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) { if (leg == 0 && stages[0].first != 0) {
leg = stages[0].first; leg = stages[0].first;
selectedControl[pc->getId()].setLeg(selectedControl[pc->getId()].isTotal(), leg); selectedControl[pc->getId()].setLeg(total, leg);
} }
if (stages.size() > 1) { 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.addItem("Leg", lang.tl("Totalresultat"), 1000 + stages[0].first);
} }
gdi.selectItemByData("Leg", leg); gdi.selectItemByData("Leg", leg + (total ? 1000 : 0));
gdi.setRestorePoint("LegSelection"); gdi.setRestorePoint("LegSelection");
} }
else { else {
@ -712,7 +792,7 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
char bf[16]; char bf[16];
sprintf_s(bf, "ctrl%d", cid); sprintf_s(bf, "ctrl%d", cid);
string name = course->getRadioName(cid); wstring name = course->getRadioName(cid);
/*if (controls[k]->hasName()) { /*if (controls[k]->hasName()) {
name = "#" + controls[k]->getName(); name = "#" + controls[k]->getName();
if (controls[k]->getNumberDuplicates() > 1) if (controls[k]->getNumberDuplicates() > 1)
@ -724,9 +804,9 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
name = "#" + name; 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); 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); bi.setExtra(previousControl);
previousControl = cid; previousControl = cid;
cx+=bw; cx+=bw;
@ -752,6 +832,32 @@ void TabSpeaker::generateControlList(gdioutput &gdi, int classId)
gdi.popX(); 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) int TabSpeaker::processListBox(gdioutput &gdi, const ListBoxInfo &bu)
{ {
if (bu.id=="Leg") { if (bu.id=="Leg") {
@ -769,6 +875,10 @@ int TabSpeaker::processListBox(gdioutput &gdi, const ListBoxInfo &bu)
shortNames); shortNames);
} }
} }
else if (bu.id == "MultiStage") {
getSpeakerMonitor()->useTotalResults(gdi.isChecked(bu.id));
updateTimeLine(gdi);
}
else if (bu.id == "DetailLevel") { else if (bu.id == "DetailLevel") {
watchLevel = oTimeLine::Priority(bu.data); watchLevel = oTimeLine::Priority(bu.data);
shownEvents.clear(); shownEvents.clear();
@ -817,7 +927,7 @@ bool TabSpeaker::loadPage(gdioutput &gdi)
pClass pc=oe->getClass(*it); pClass pc=oe->getClass(*it);
if (pc) { 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; cx+=bw;
cb++; cb++;
@ -844,7 +954,7 @@ bool TabSpeaker::loadPage(gdioutput &gdi)
} else db += bw; } else db += bw;
gdi.addButton(cx+db, cy, bw/5, "ZoomIn", "+", tabSpeakerCB, "Zooma in (Ctrl + '+')", false, false); gdi.addButton(cx+db, cy, bw/5, "ZoomIn", "+", tabSpeakerCB, "Zooma in (Ctrl + '+')", false, false);
db += bw/5+2; 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; 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); 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; cb = 1, cx = basex, db = 0;
cy += gdi.getButtonHeight()+4; cy += gdi.getButtonHeight()+4;
} else db += bw; } 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.setRestorePoint("classes");
gdi.refresh(); gdi.refresh();
return true; return true;
@ -894,7 +1038,6 @@ void TabSpeaker::clearCompetitionData()
{ {
controlsToWatch.clear(); controlsToWatch.clear();
classesToWatch.clear(); classesToWatch.clear();
controlsToWatchSI.clear();
selectedControl.clear(); selectedControl.clear();
classId=0; classId=0;
lastControl.clear(); lastControl.clear();
@ -915,9 +1058,9 @@ void TabSpeaker::manualTimePage(gdioutput &gdi) const
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); gdi.pushX();
gdi.addInput("Control", lastControl, 5, 0, "Kontroll"); gdi.addInput("Control", lastControl, 5, 0, L"Kontroll");
gdi.addInput("Runner", "", 6, 0, "Löpare"); gdi.addInput("Runner", L"", 6, 0, L"Löpare");
gdi.addInput("Time", "", 8, 0, "Tid"); gdi.addInput("Time", L"", 8, 0, L"Tid");
gdi.dropLine(); gdi.dropLine();
gdi.addButton("StoreTime", "Spara", tabSpeakerCB).setDefault(); gdi.addButton("StoreTime", "Spara", tabSpeakerCB).setDefault();
gdi.addButton("Cancel", "Avbryt", tabSpeakerCB).setCancel(); gdi.addButton("Cancel", "Avbryt", tabSpeakerCB).setCancel();
@ -940,11 +1083,11 @@ void TabSpeaker::storeManualTime(gdioutput &gdi)
throw std::exception("Kontrollnummer måste anges."); throw std::exception("Kontrollnummer måste anges.");
lastControl=gdi.getText("Control"); lastControl=gdi.getText("Control");
const string &r_str=gdi.getText("Runner"); const wstring &r_str=gdi.getText("Runner");
string time=gdi.getText("Time"); wstring time=gdi.getText("Time");
if (time.empty()) if (time.empty())
time=getLocalTimeOnly(); time=getLocalTimeOnlyW();
int itime=oe->getRelativeTime(time); int itime=oe->getRelativeTime(time);
@ -952,15 +1095,15 @@ void TabSpeaker::storeManualTime(gdioutput &gdi)
throw std::exception("Ogiltig tid."); throw std::exception("Ogiltig tid.");
pRunner r=oe->getRunnerByBibOrStartNo(r_str, false); 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) if (!r)
r=oe->getRunnerByCardNo(r_no, itime); r=oe->getRunnerByCardNo(r_no, itime);
string Name; wstring Name;
int sino=r_no; int sino=r_no;
if (r) { if (r) {
Name=r->getName(); Name = r->getName();
sino=r->getCardNo(); sino = r->getCardNo();
} }
else else
Name = lang.tl("Okänd"); Name = lang.tl("Okänd");
@ -973,7 +1116,7 @@ void TabSpeaker::storeManualTime(gdioutput &gdi)
oe->addFreePunch(itime, punch, sino, true); oe->addFreePunch(itime, punch, sino, true);
gdi.restore("manual", false); 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); manualTimePage(gdi);
} }
@ -1046,3 +1189,150 @@ SpeakerMonitor *TabSpeaker::getSpeakerMonitor() {
return speakerMonitor; 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,8 +57,7 @@ class TabSpeaker :
private: private:
set<int> controlsToWatch; set<int> controlsToWatch;
set<int> classesToWatch; set<int> classesToWatch;
set<int> controlsToWatchSI;
int lastControlToWatch; int lastControlToWatch;
int lastClassToWatch; int lastClassToWatch;
@ -70,7 +69,7 @@ private:
void generateControlList(gdioutput &gdi, int classId); void generateControlList(gdioutput &gdi, int classId);
void generateControlListForLeg(gdioutput &gdi, int classId, int leg); void generateControlListForLeg(gdioutput &gdi, int classId, int leg);
string lastControl; wstring lastControl;
void manualTimePage(gdioutput &gdi) const; void manualTimePage(gdioutput &gdi) const;
void storeManualTime(gdioutput &gdi); void storeManualTime(gdioutput &gdi);
@ -80,6 +79,7 @@ private:
//Map CourseNo -> selected Control. //Map CourseNo -> selected Control.
//map<int, int> selectedControl; //map<int, int> selectedControl;
map<int, spkClassSelection> selectedControl; map<int, spkClassSelection> selectedControl;
int deducePreviousControl(int classId, int leg, int control);
bool ownWindow; bool ownWindow;
@ -93,6 +93,11 @@ private:
SpeakerMonitor *getSpeakerMonitor(); 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: public:
bool onClear(gdioutput &gdi); bool onClear(gdioutput &gdi);
@ -103,7 +108,6 @@ public:
//Clear selection data //Clear selection data
void clearCompetitionData(); void clearCompetitionData();
int processButton(gdioutput &gdi, const ButtonInfo &bu); int processButton(gdioutput &gdi, const ButtonInfo &bu);
int processListBox(gdioutput &gdi, const ListBoxInfo &bu); int processListBox(gdioutput &gdi, const ListBoxInfo &bu);
int handleEvent(gdioutput &gdi, const EventInfo &ei); 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) { int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
static DWORD editTick = 0; static DWORD editTick = 0;
string expr; wstring expr;
bool showNow = false; bool showNow = false;
bool filterMore = 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)) if (timeToFill < 50 || (filterMore && (timeToFill * lastFilter.size())/nr < 50))
showNow = true; showNow = true;
else {// Delay filter 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); TimerInfo &ti = *(TimerInfo *)(data);
if (inputId != int(ti.getExtra())) if (inputId != ti.getData())
return 0; return 0;
expr = ti.id.substr(8); expr = ti.getDataString();
filterMore = expr.length() > lastSearchExpr.length() && filterMore = expr.length() > lastSearchExpr.length() &&
expr.substr(0, lastSearchExpr.length()) == lastSearchExpr; expr.substr(0, lastSearchExpr.length()) == lastSearchExpr;
showNow = true; showNow = true;
@ -115,12 +115,12 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
InputInfo &ii = *(InputInfo *)(data); InputInfo &ii = *(InputInfo *)(data);
if (ii.text == getSearchString()) { if (ii.text == getSearchString()) {
((InputInfo *)gdi.setText("SearchText", ""))->setFgColor(colorDefault); ((InputInfo *)gdi.setText("SearchText", L""))->setFgColor(colorDefault);
} }
} }
if (showNow) { if (showNow) {
stdext::hash_set<int> filter; unordered_set<int> filter;
if (type == GUI_TIMER) if (type == GUI_TIMER)
gdi.setWaitCursor(true); gdi.setWaitCursor(true);
@ -131,8 +131,8 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
lastSearchExpr = expr; lastSearchExpr = expr;
// Filter more // Filter more
if (filter.empty()) { if (filter.empty()) {
vector< pair<string, size_t> > runners; vector< pair<wstring, size_t> > runners;
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));
gdi.addItem("Teams", runners); gdi.addItem("Teams", runners);
} }
else else
@ -142,21 +142,21 @@ int TabTeam::searchCB(gdioutput &gdi, int type, void *data) {
oe->findTeam(expr, 0, filter); oe->findTeam(expr, 0, filter);
lastSearchExpr = expr; lastSearchExpr = expr;
vector< pair<string, size_t> > runners; vector< pair<wstring, size_t> > runners;
oe->fillTeams(runners); oe->fillTeams(runners);
if (filter.size() == runners.size()){ if (filter.size() == runners.size()){
} }
else if (filter.empty()) { else if (filter.empty()) {
runners.clear(); 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 { else {
vector< pair<string, size_t> > runners2; vector< pair<wstring, size_t> > runners2;
for (size_t k = 0; k<runners.size(); k++) { for (size_t k = 0; k<runners.size(); k++) {
if (filter.count(runners[k].second) == 1) { 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); runners2.back().first.swap(runners[k].first);
} }
} }
@ -197,7 +197,7 @@ void TabTeam::selectTeam(gdioutput &gdi, pTeam t)
if (ip > 0) if (ip > 0)
gdi.setText("PlaceIn", ip); gdi.setText("PlaceIn", ip);
else else
gdi.setText("PlaceIn", MakeDash("-")); gdi.setText("PlaceIn", makeDash(L"-"));
gdi.setText("TimeIn", t->getInputTimeS()); gdi.setText("TimeIn", t->getInputTimeS());
if (gdi.hasField("PointIn")) if (gdi.hasField("PointIn"))
@ -221,10 +221,10 @@ void TabTeam::selectTeam(gdioutput &gdi, pTeam t)
if (gdi.hasField("StatusIn")) { if (gdi.hasField("StatusIn")) {
gdi.selectFirstItem("StatusIn"); gdi.selectFirstItem("StatusIn");
gdi.setText("PlaceIn", ""); gdi.setText("PlaceIn", L"");
gdi.setText("TimeIn", "-"); gdi.setText("TimeIn", makeDash(L"-"));
if (gdi.hasField("PointIn")) if (gdi.hasField("PointIn"))
gdi.setText("PointIn", ""); gdi.setText("PointIn", L"");
} }
loadTeamMembers(gdi, lbi.data, 0, 0); loadTeamMembers(gdi, lbi.data, 0, 0);
@ -237,21 +237,21 @@ void TabTeam::selectTeam(gdioutput &gdi, pTeam t)
void TabTeam::updateTeamStatus(gdioutput &gdi, pTeam t) void TabTeam::updateTeamStatus(gdioutput &gdi, pTeam t)
{ {
if (!t) { if (!t) {
gdi.setText("Name", ""); gdi.setText("Name", L"");
if (gdi.hasField("StartNo")) if (gdi.hasField("StartNo"))
gdi.setText("StartNo", ""); gdi.setText("StartNo", L"");
if (gdi.hasField("Club")) if (gdi.hasField("Club"))
gdi.setText("Club", ""); gdi.setText("Club", L"");
bool hasFee = gdi.hasField("Fee"); bool hasFee = gdi.hasField("Fee");
if (hasFee) { if (hasFee) {
gdi.setText("Fee", ""); gdi.setText("Fee", L"");
} }
gdi.setText("Start", "-"); gdi.setText("Start", makeDash(L"-"));
gdi.setText("Finish", "-"); gdi.setText("Finish", makeDash(L"-"));
gdi.setText("Time", "-"); gdi.setText("Time", makeDash(L"-"));
gdi.selectItemByData("Status", 0); gdi.selectItemByData("Status", 0);
gdi.setText("TimeAdjust", "-"); gdi.setText("TimeAdjust", makeDash(L"-"));
gdi.setText("PointAdjust", "-"); gdi.setText("PointAdjust", makeDash(L"-"));
return; return;
} }
@ -270,7 +270,7 @@ void TabTeam::updateTeamStatus(gdioutput &gdi, pTeam t)
gdi.setText("Start", t->getStartTimeS()); gdi.setText("Start", t->getStartTimeS());
gdi.setText("Finish",t->getFinishTimeS()); gdi.setText("Finish",t->getFinishTimeS());
gdi.setText("Time", t->getRunningTimeS()); gdi.setText("Time", t->getRunningTimeS());
gdi.setText("TimeAdjust", getTimeMS(t->getTimeAdjustment())); gdi.setText("TimeAdjust", getTimeMSW(t->getTimeAdjustment()));
gdi.setText("PointAdjust", -t->getPointAdjustment()); gdi.setText("PointAdjust", -t->getPointAdjustment());
gdi.selectItemByData("Status", t->getStatus()); gdi.selectItemByData("Status", t->getStatus());
} }
@ -280,7 +280,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
return 0; return 0;
DWORD tid=teamId; DWORD tid=teamId;
string name=gdi.getText("Name"); wstring name=gdi.getText("Name");
if (name.empty()) { if (name.empty()) {
gdi.alert("Alla lag måste ha ett namn."); gdi.alert("Alla lag måste ha ett namn.");
@ -301,15 +301,15 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
if (t) { if (t) {
t->setName(name, true); t->setName(name, true);
if (gdi.hasField("StartNo")) { if (gdi.hasField("StartNo")) {
const string &bib = gdi.getText("StartNo"); const wstring &bib = gdi.getText("StartNo");
if (bib != t->getBib()) { if (bib != t->getBib()) {
bibModified = true; bibModified = true;
char pat[32]; wchar_t pat[32];
int no = oClass::extractBibPattern(bib, pat); int no = oClass::extractBibPattern(bib, pat);
t->setBib(bib, no, no > 0, false); t->setBib(bib, no, no > 0, false);
} }
} }
string start = gdi.getText("Start"); wstring start = gdi.getText("Start");
t->setStartTimeS(start); t->setStartTimeS(start);
if (t->getRunner(0)) if (t->getRunner(0))
t->getRunner(0)->setStartTimeS(start); t->getRunner(0)->setStartTimeS(start);
@ -364,7 +364,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
bool readStatusIn = true; bool readStatusIn = true;
if (newClass && t->getInputStatus() != StatusNotCompetiting && t->hasInputData()) { 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(); t->resetInputData();
readStatusIn = false; readStatusIn = false;
} }
@ -373,7 +373,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
if (newClass && !bibModified) { if (newClass && !bibModified) {
pClass pc = oe->getClass(classId); pClass pc = oe->getClass(classId);
if (pc) { if (pc) {
pair<int, string> snoBib = pc->getNextBib(); pair<int, wstring> snoBib = pc->getNextBib();
if (snoBib.first > 0) { if (snoBib.first > 0) {
t->setBib(snoBib.second, snoBib.first, true, false); t->setBib(snoBib.second, snoBib.first, true, false);
} }
@ -412,7 +412,7 @@ bool TabTeam::save(gdioutput &gdi, bool dontReloadTeams) {
if (pc->getLegRunner(i)==i) { if (pc->getLegRunner(i)==i) {
const string name=gdi.getText(bf); const wstring name=gdi.getText(bf);
if (name.empty()) { //Remove if (name.empty()) { //Remove
t->removeRunner(gdi, true, i); t->removeRunner(gdi, true, i);
} }
@ -532,7 +532,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
ListBoxInfo lbi; ListBoxInfo lbi;
gdi.getSelectedItem("Teams", lbi); gdi.getSelectedItem("Teams", lbi);
oe->fillTeams(gdi, "Teams"); oe->fillTeams(gdi, "Teams");
stdext::hash_set<int> foo; unordered_set<int> foo;
pTeam t=oe->findTeam(gdi.getText("SearchText"), lbi.data, foo); pTeam t=oe->findTeam(gdi.getText("SearchText"), lbi.data, foo);
if (t) { if (t) {
@ -574,8 +574,8 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
int leg = bi.getExtraInt(); int leg = bi.getExtraInt();
gdi.fillRight(); gdi.fillRight();
gdi.addInput("DirName", "", 16, TeamCB, "Namn:"); gdi.addInput("DirName", L"", 16, TeamCB, L"Namn:");
gdi.addInput("DirCard", "", 8, TeamCB, "Bricka:"); gdi.addInput("DirCard", L"", 8, TeamCB, L"Bricka:");
TabSI &tsi = dynamic_cast<TabSI &>(*gdi.getTabs().get(TSITab)); TabSI &tsi = dynamic_cast<TabSI &>(*gdi.getTabs().get(TSITab));
tsi.setCardNumberField("DirCard"); tsi.setCardNumberField("DirCard");
@ -598,7 +598,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
return 0; return 0;
int leg = bi.getExtraInt(); int leg = bi.getExtraInt();
string name = gdi.getText("DirName"); wstring name = gdi.getText("DirName");
int storedId = gdi.getBaseInfo("DirName").getExtraInt(); int storedId = gdi.getBaseInfo("DirName").getExtraInt();
int card = gdi.getTextNo("DirCard"); 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); pRunner old = oe->getRunnerByCardNo(card, 0, true, true);
if (old && r != old) { 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") { else if (bi.id == "Browse") {
const char *target = (const char *)bi.getExtra(); const char *target = (const char *)bi.getExtra();
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("Laguppställning", "*.csv;*.txt")); ext.push_back(make_pair(L"Laguppställning", L"*.csv;*.txt"));
string fileName = gdi.browseForOpen(ext, "csv"); wstring fileName = gdi.browseForOpen(ext, L"csv");
if (!fileName.empty()) if (!fileName.empty())
gdi.setText(target, fileName); gdi.setText(target, fileName);
} }
@ -679,11 +679,11 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); gdi.pushX();
gdi.dropLine(); gdi.dropLine();
gdi.addSelection("ForkKey", 100, 400, 0, "Gafflingsnyckel:"); gdi.addSelection("ForkKey", 100, 400, 0, L"Gafflingsnyckel:");
int nf = pc->getNumForks(); int nf = pc->getNumForks();
vector< pair<string, size_t> > keys; vector< pair<wstring, size_t> > keys;
for (int f = 0; f < nf; f++) { 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; int currentKey = max(t->getStartNo()-1, 0) % nf;
gdi.addItem("ForkKey", keys); gdi.addItem("ForkKey", keys);
@ -761,7 +761,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
gdi.dropLine(); gdi.dropLine();
gdi.fillDown(); 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.setData("Leg", leg);
gdi.setRestorePoint("DirectEntry"); gdi.setRestorePoint("DirectEntry");
@ -776,9 +776,9 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
gdi.getTargetDimension(w, h); gdi.getTargetDimension(w, h);
w = max(w, gdi.getWidth()); w = max(w, gdi.getWidth());
int limit = max(w - gdi.scaleLength(150), gdi.getCX() + gdi.scaleLength(200)); 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; set<int> usedR;
string anon = lang.tl("N.N."); wstring anon = lang.tl("N.N.");
set<int> clubs; set<int> clubs;
for (int i = 0; i < t->getNumRunners(); i++) { 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++) { for (size_t i = 0; i < clsR.size(); i++) {
if (clsR[i]->getRaceNo() > 0) if (clsR[i]->getRaceNo() > 0)
@ -838,10 +838,10 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
continue; continue;
if (usedR.count(clsR[i]->getId())) if (usedR.count(clsR[i]->getId()))
continue; continue;
const string &club = clsR[i]->getClub(); const wstring &club = clsR[i]->getClub();
string id = clsR[i]->getName() + ", " + clsR[i]->getClass(); wstring id = clsR[i]->getName() + L", " + clsR[i]->getClass();
if (!club.empty()) if (!club.empty())
id += " (" + club + ")"; id += L" (" + club + L")";
otherR.push_back(make_pair(id, clsR[i]->getId())); 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") { else if (bi.id=="Add") {
if (teamId>0) { if (teamId>0) {
string name = gdi.getText("Name"); wstring name = gdi.getText("Name");
pTeam t = oe->getTeam(teamId); pTeam t = oe->getTeam(teamId);
if (!name.empty() && t && t->getName() != name) { 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); t = oe->addTeam(name);
teamId = t->getId(); teamId = t->getId();
} }
@ -903,7 +903,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
pClass pc = oe->getClass(clsId); pClass pc = oe->getClass(clsId);
if (pc) { if (pc) {
pair<int, string> snoBib = pc->getNextBib(); pair<int, wstring> snoBib = pc->getNextBib();
if (snoBib.first > 0) { if (snoBib.first > 0) {
t->setBib(snoBib.second, snoBib.first, true, false); 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()) { if (!t || t->isRemoved()) {
selectTeam(gdi, 0); 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> runners;
vector<int> noRemove; vector<int> noRemove;
for (int k = 0; k < t->getNumRunners(); k++) { for (int k = 0; k < t->getNumRunners(); k++) {
@ -1025,7 +1025,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
if (r) { if (r) {
sprintf_s(bf, "SI%d", i); sprintf_s(bf, "SI%d", i);
int cno = r->getCardNo(); 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); warnDuplicateCard(gdi, bf, cno, r, rCache);
} }
} }
@ -1084,9 +1084,9 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
matched = true; matched = true;
} }
else if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::RunnerDb)) { else if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::RunnerDb)) {
const RunnerDBEntry *rdb = oe->getRunnerDatabase().getRunnerByCard(cno); const RunnerWDBEntry *rdb = oe->getRunnerDatabase().getRunnerByCard(cno);
if (rdb) { if (rdb) {
string name; wstring name;
rdb->getName(name); rdb->getName(name);
gdi.setText("DirName", name)->setExtra(0); gdi.setText("DirName", name)->setExtra(0);
matched = true; matched = true;
@ -1103,7 +1103,7 @@ int TabTeam::teamCB(gdioutput &gdi, int type, void *data)
if (pc) { if (pc) {
for(unsigned i=0;i<pc->getNumStages();i++){ for(unsigned i=0;i<pc->getNumStages();i++){
if (ii.id == "SI" + itos(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); pTeam t = oe->getTeam(teamId);
if (t) { if (t) {
vector<pRunner> rc; vector<pRunner> rc;
@ -1172,26 +1172,26 @@ void TabTeam::loadTeamMembers(gdioutput &gdi, int ClassId, int ClubId, pTeam t)
sprintf_s(bf, "R%d", i); sprintf_s(bf, "R%d", i);
gdi.pushX(); gdi.pushX();
bool hasSI = false; 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) { 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 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); sprintf_s(bf_si, "SI%d", i);
hasSI = true; 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 gdi.addCheckbox(xp + dx[3], yp + gdi.scaleLength(10), "RENT"+itos(i), "", 0, false); //Rentcard
} }
else { else {
//gdi.addInput(bf, "", 24); //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.disableInput(bf);
} }
gdi.addButton(xp + dx[4], yp-2, gdi.scaleLength(38), "MR" + itos(i), "...", TeamCB, "Redigera deltagaren.", false, false); // Change 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.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.dropLine(0.5);
gdi.popX(); gdi.popX();
@ -1203,18 +1203,18 @@ void TabTeam::loadTeamMembers(gdioutput &gdi, int ClassId, int ClubId, pTeam t)
if (hasSI) { if (hasSI) {
int cno = r->getCardNo(); 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); warnDuplicateCard(gdi, bf_si, cno, r, rCache);
gdi.check("RENT" + itos(i), r->getDCI().getInt("CardFee") != 0); gdi.check("RENT" + itos(i), r->getDCI().getInt("CardFee") != 0);
} }
string sid = "STATUS"+itos(i); string sid = "STATUS"+itos(i);
if (r->statusOK()) { 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) if (ti)
ti->setColor(colorGreen); ti->setColor(colorGreen);
} }
else if (r->getStatus() != StatusUnknown) { 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) if (ti)
ti->setColor(colorRed); ti->setColor(colorRed);
} }
@ -1229,20 +1229,20 @@ void TabTeam::loadTeamMembers(gdioutput &gdi, int ClassId, int ClubId, pTeam t)
if (numF>1 && t) { if (numF>1 && t) {
gdi.addString ("", 1, "Gafflingsnyckel X#" + itos(1+(max(t->getStartNo()-1, 0) % numF))).setColor(colorGreen); gdi.addString ("", 1, "Gafflingsnyckel X#" + itos(1+(max(t->getStartNo()-1, 0) % numF))).setColor(colorGreen);
string crsList; wstring crsList;
bool hasCrs = false; bool hasCrs = false;
for (size_t k = 0; k < pc->getNumStages(); k++) { for (size_t k = 0; k < pc->getNumStages(); k++) {
pCourse crs = pc->getCourse(k, t->getStartNo()); pCourse crs = pc->getCourse(k, t->getStartNo());
string cS; wstring cS;
if (crs != 0) { if (crs != 0) {
cS = crs->getName(); cS = crs->getName();
hasCrs = true; hasCrs = true;
} }
else else
cS = MakeDash("-"); cS = makeDash(L"-");
if (!crsList.empty()) if (!crsList.empty())
crsList += ", "; crsList += L", ";
crsList += cS; crsList += cS;
if (hasCrs && crsList.length() > 50) { if (hasCrs && crsList.length() > 50) {
@ -1295,14 +1295,14 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.registerEvent("SearchRunner", teamSearchCB).setKeyCommand(KC_FIND); gdi.registerEvent("SearchRunner", teamSearchCB).setKeyCommand(KC_FIND);
gdi.registerEvent("SearchRunnerBack", teamSearchCB).setKeyCommand(KC_FINDBACK); 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.dropLine(-0.2);
gdi.addButton("ShowAll", "Visa alla", TeamCB).isEdit(false); gdi.addButton("ShowAll", "Visa alla", TeamCB).isEdit(false);
gdi.dropLine(2); gdi.dropLine(2);
gdi.popX(); gdi.popX();
gdi.fillDown(); 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"); gdi.setInputFocus("Teams");
fillTeamList(gdi); fillTeamList(gdi);
@ -1312,17 +1312,17 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.newColumn(); gdi.newColumn();
gdi.fillDown(); gdi.fillDown();
gdi.pushX(); gdi.pushX();
gdi.addInput("Name", "", 24, 0, "Lagnamn:"); gdi.addInput("Name", L"", 24, 0, L"Lagnamn:");
gdi.fillRight(); gdi.fillRight();
bool drop = false; bool drop = false;
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Bib)) { 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); drop = oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy);
} }
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Clubs)) { 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"); oe->fillClubs(gdi, "Club");
drop = true; drop = true;
} }
@ -1332,12 +1332,12 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.popX(); 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); oe->fillClasses(gdi, "RClass", oEvent::extraNone, oEvent::filterNone);
gdi.addItem("RClass", lang.tl("Ny klass"), 0); gdi.addItem("RClass", lang.tl("Ny klass"), 0);
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy)) if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy))
gdi.addInput("Fee", "", 5, 0, "Avgift:"); gdi.addInput("Fee", L"", 5, 0, L"Avgift:");
gdi.popX(); gdi.popX();
gdi.fillDown(); gdi.fillDown();
@ -1346,8 +1346,8 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.pushX(); gdi.pushX();
gdi.fillRight(); gdi.fillRight();
gdi.addInput("Start", "", 8, 0, "Starttid:"); gdi.addInput("Start", L"", 8, 0, L"Starttid:");
gdi.addInput("Finish", "", 8, 0, "Måltid:"); gdi.addInput("Finish", L"", 8, 0, L"Måltid:");
const bool timeAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::TimeAdjust); const bool timeAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::TimeAdjust);
const bool pointAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::PointAdjust); const bool pointAdjust = oe->getMeOSFeatures().hasFeature(MeOSFeatures::PointAdjust);
@ -1356,10 +1356,10 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.dropLine(3); gdi.dropLine(3);
gdi.popX(); gdi.popX();
if (timeAdjust) { if (timeAdjust) {
gdi.addInput("TimeAdjust", "", 8, 0, "Tidstillägg:"); gdi.addInput("TimeAdjust", L"", 8, 0, L"Tidstillägg:");
} }
if (pointAdjust) { 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.pushX();
gdi.fillRight(); 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.disableInput("Time");
gdi.fillDown(); 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"); oe->fillStatus(gdi, "Status");
gdi.popX(); gdi.popX();
@ -1403,16 +1403,16 @@ bool TabTeam::loadPage(gdioutput &gdi)
gdi.dropLine(0.3); gdi.dropLine(0.3);
gdi.fillRight(); 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"); oe->fillStatus(gdi, "StatusIn");
gdi.selectItemByData("Status", 0); gdi.selectItemByData("Status", 0);
gdi.addInput("PlaceIn", "", 5, 0, "Placering:"); gdi.addInput("PlaceIn", L"", 5, 0, L"Placering:");
int xmax = gdi.getCX() + dx; int xmax = gdi.getCX() + dx;
gdi.setCX(ccx); gdi.setCX(ccx);
gdi.dropLine(3); gdi.dropLine(3);
gdi.addInput("TimeIn", "", 5, 0, "Tid:"); gdi.addInput("TimeIn", L"", 5, 0, L"Tid:");
if (oe->hasRogaining()) { if (oe->hasRogaining()) {
gdi.addInput("PointIn", "", 5, 0, "Poäng:"); gdi.addInput("PointIn", L"", 5, 0, L"Poäng:");
} }
gdi.dropLine(3); gdi.dropLine(3);
RECT rc; RECT rc;
@ -1471,14 +1471,14 @@ void TabTeam::fillTeamList(gdioutput &gdi) {
timeToFill = GetTickCount(); timeToFill = GetTickCount();
oe->fillTeams(gdi, "Teams"); oe->fillTeams(gdi, "Teams");
timeToFill = GetTickCount() - timeToFill; timeToFill = GetTickCount() - timeToFill;
lastSearchExpr = ""; lastSearchExpr = L"";
((InputInfo *)gdi.setText("SearchText", getSearchString()))->setFgColor(colorGreyBlue); ((InputInfo *)gdi.setText("SearchText", getSearchString()))->setFgColor(colorGreyBlue);
lastFilter.clear(); lastFilter.clear();
} }
const string &TabTeam::getSearchString() const { const wstring &TabTeam::getSearchString() const {
return lang.tl("Sök (X)#Ctrl+F"); return lang.tl(L"Sök (X)#Ctrl+F");
} }
void TabTeam::addToolbar(gdioutput &gdi) const { void TabTeam::addToolbar(gdioutput &gdi) const {
@ -1505,9 +1505,9 @@ void TabTeam::showTeamImport(gdioutput &gdi) {
gdi.pushX(); gdi.pushX();
gdi.fillRight(); gdi.fillRight();
gdi.addInput("FileName", "", 40, 0, "Filnamn:"); gdi.addInput("FileName", L"", 40, 0, L"Filnamn:");
gdi.dropLine(0.9); 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.dropLine(3);
gdi.popX(); gdi.popX();
gdi.fillDown(); gdi.fillDown();
@ -1521,12 +1521,12 @@ void TabTeam::showTeamImport(gdioutput &gdi) {
} }
void TabTeam::doTeamImport(gdioutput &gdi) { void TabTeam::doTeamImport(gdioutput &gdi) {
string file = gdi.getText("FileName"); wstring file = gdi.getText("FileName");
bool useExisting = gdi.isChecked("OnlyExisting"); bool useExisting = gdi.isChecked("OnlyExisting");
csvparser csv; csvparser csv;
map<string, int> classNameToNumber; map<wstring, int> classNameToNumber;
vector<pClass> cls; vector<pClass> cls;
oe->getClasses(cls, true); oe->getClasses(cls, true);
for (size_t k = 0; k < cls.size();k++) { for (size_t k = 0; k < cls.size();k++) {
@ -1539,16 +1539,16 @@ void TabTeam::doTeamImport(gdioutput &gdi) {
gdi.dropLine(); gdi.dropLine();
for (size_t k = 0; k < teamLineup.size(); k++) { 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()) if (!teamLineup[k].teamClub.empty())
tdesc += ", " + teamLineup[k].teamClub; tdesc += L", " + teamLineup[k].teamClub;
gdi.addStringUT(1, tdesc); gdi.addStringUT(1, tdesc);
for (size_t j = 0; j < teamLineup[k].members.size(); j++) { for (size_t j = 0; j < teamLineup[k].members.size(); j++) {
TeamLineup::TeamMember &member = teamLineup[k].members[j]; TeamLineup::TeamMember &member = teamLineup[k].members[j];
if (member.name.empty()) if (member.name.empty())
continue; continue;
string mdesc = " " + itos(j+1) + ". "; wstring mdesc = L" " + itow(j+1) + L". ";
bool warn = false; bool warn = false;
if (useExisting) { if (useExisting) {
@ -1556,28 +1556,28 @@ void TabTeam::doTeamImport(gdioutput &gdi) {
if (r != 0) if (r != 0)
mdesc += r->getCompleteIdentification(); mdesc += r->getCompleteIdentification();
else { else {
mdesc += member.name + lang.tl(" (ej funnen)"); mdesc += member.name + lang.tl(L" (ej funnen)");
warn = true; warn = true;
} }
} }
else { else {
mdesc += member.name + " (" + itos(member.cardNo) + ") " + member.club; mdesc += member.name + L" (" + itow(member.cardNo) + L") " + member.club;
} }
if (!member.course.empty()) { if (!member.course.empty()) {
if (oe->getCourse(member.course)) if (oe->getCourse(member.course))
mdesc += " : " + member.course; mdesc += L" : " + member.course;
else { else {
mdesc += " : " + lang.tl("Banan saknas"); mdesc += L" : " + lang.tl(L"Banan saknas");
warn = true; warn = true;
} }
} }
if (!member.cls.empty()) { if (!member.cls.empty()) {
if (oe->getClass(member.cls)) if (oe->getClass(member.cls))
mdesc += " [" + member.cls + "]"; mdesc += L" [" + member.cls + L"]";
else { else {
mdesc += " " + lang.tl("Klassen saknas"); mdesc += L" " + lang.tl(L"Klassen saknas");
warn = true; warn = true;
} }
} }
@ -1642,14 +1642,14 @@ void TabTeam::saveTeamImport(gdioutput &gdi, bool useExisting) {
loadPage(gdi); loadPage(gdi);
} }
pRunner TabTeam::findRunner(const string &name, int cardNo) const { pRunner TabTeam::findRunner(const wstring &name, int cardNo) const {
string n = canonizeName(name.c_str()); wstring n = canonizeName(name.c_str());
if (cardNo != 0) { if (cardNo != 0) {
vector<pRunner> pr; vector<pRunner> pr;
oe->getRunnersByCard(cardNo, pr); oe->getRunnersByCard(cardNo, pr);
for (size_t k = 0; k < pr.size(); k++) { 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) if (a == n)
return pr[k]; return pr[k];
} }
@ -1658,7 +1658,7 @@ pRunner TabTeam::findRunner(const string &name, int cardNo) const {
vector<pRunner> pr; vector<pRunner> pr;
oe->getRunners(0, 0, pr, false); oe->getRunners(0, 0, pr, false);
for (size_t k = 0; k < pr.size(); k++) { 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) if (a == n)
return pr[k]; return pr[k];
} }
@ -1675,7 +1675,7 @@ void TabTeam::showAddTeamMembers(gdioutput &gdi) {
gdi.pushX(); gdi.pushX();
gdi.fillDown(); 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.fillDown();
gdi.addCheckbox("OnlyRequired", "Endast på obligatoriska sträckor", 0, true); gdi.addCheckbox("OnlyRequired", "Endast på obligatoriska sträckor", 0, true);
gdi.addCheckbox("WithFee", "Med anmälningsavgift (lagets klubb)", 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); oe->getTeams(0, t, true);
bool onlyReq = gdi.isChecked("OnlyRequired"); bool onlyReq = gdi.isChecked("OnlyRequired");
bool withFee = gdi.isChecked("WithFee"); bool withFee = gdi.isChecked("WithFee");
string nn = gdi.getText("Name"); wstring nn = gdi.getText("Name");
for (size_t k = 0; k < t.size(); k++) { for (size_t k = 0; k < t.size(); k++) {
pTeam mt = t[k]; pTeam mt = t[k];
@ -1737,14 +1737,14 @@ void TabTeam::doAddTeamMembers(gdioutput &gdi) {
} }
void TabTeam::showRunners(gdioutput &gdi, const char *title, 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) { int limitX, set<int> &usedR) {
if (rToList.empty()) if (rToList.empty())
return; return;
bool any = false; 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)) if (usedR.count(it->second))
continue; continue;
usedR.insert(it->second); usedR.insert(it->second);
@ -1761,7 +1761,7 @@ void TabTeam::showRunners(gdioutput &gdi, const char *title,
gdi.popX(); 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) { if (any) {
@ -1780,16 +1780,16 @@ void TabTeam::processChangeRunner(gdioutput &gdi, pTeam t, int leg, pRunner r) {
} }
else if (oldR) { else if (oldR) {
if (r->getTeam()) { if (r->getTeam()) {
ans = gdi.askCancel("Vill du att X och Y byter sträcka?#" + ans = gdi.askCancel(L"Vill du att X och Y byter sträcka?#" +
r->getName() + "#" + oldR->getName()); r->getName() + L"#" + oldR->getName());
} }
else { else {
ans = gdi.askCancel("Vill du att X tar sträckan istället för Y?#" + ans = gdi.askCancel(L"Vill du att X tar sträckan istället för Y?#" +
r->getName() + "#" + oldR->getName()); r->getName() + L"#" + oldR->getName());
} }
} }
else { 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) 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())); InputInfo &cardNo = dynamic_cast<InputInfo &>(gdi.getBaseInfo(id.c_str()));
if (warnCardDupl) { if (warnCardDupl) {
cardNo.setBgColor(colorLightRed); 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(); cardNo.refresh();
return warnCardDupl->getTeam() == r->getTeam(); return warnCardDupl->getTeam() == r->getTeam();
} }
else { else {
if (cardNo.getBgColor() != colorDefault) { if (cardNo.getBgColor() != colorDefault) {
cardNo.setBgColor(colorDefault); cardNo.setBgColor(colorDefault);
gdi.updateToolTip(id, ""); gdi.updateToolTip(id, L"");
cardNo.refresh(); cardNo.refresh();
} }
return false; return false;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -48,16 +48,16 @@ struct PunchInfo {
struct TeamLineup { struct TeamLineup {
struct TeamMember { struct TeamMember {
string name; wstring name;
string club; wstring club;
int cardNo; int cardNo;
string course; wstring course;
string cls; wstring cls;
}; };
string teamName; wstring teamName;
string teamClass; wstring teamClass;
string teamClub; wstring teamClub;
vector<TeamMember> members; vector<TeamMember> members;
}; };
@ -71,13 +71,13 @@ protected:
string ErrorMessage; string ErrorMessage;
// Returns true if a SI-manager line is identified // 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 // 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 // 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 { enum SIConfigFields {
sicSIID, sicSIID,
@ -97,40 +97,42 @@ protected:
}; };
map<SIConfigFields, int> siconfigmap; 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 // 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, int &cardIndex, int &timeIndex, int &dateIndex,
string &processedTime, string &date); wstring &processedTime, wstring &date);
public: 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, void importTeamLineup(const wstring &file,
const map<string, int> &classNameToNumber, const map<wstring, int> &classNameToNumber,
vector<TeamLineup> &teams); vector<TeamLineup> &teams);
bool openOutput(const char *file); bool openOutput(const wstring &file);
bool closeOutput(); bool closeOutput();
bool OutputRow(vector<string> &out); bool OutputRow(vector<string> &out);
bool OutputRow(const string &row); bool OutputRow(const string &row);
int nimport; int nimport;
bool ImportOCAD_CSV(oEvent &event, const char *file, bool addClasses); bool importOCAD_CSV(oEvent &oe, const wstring &file, bool addClasses);
bool ImportOS_CSV(oEvent &event, const char *file); bool importOS_CSV(oEvent &oe, const wstring &file);
bool ImportRAID(oEvent &event, const char *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); vector<PunchInfo> &punches);
bool importCards(const oEvent &oe, const char *file, bool importCards(const oEvent &oe, const wstring &file,
vector<SICard> &punches); vector<SICard> &punches);
int split(char *line, vector<char *> &split); 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 wstring &file);
int iscsv(const char *file);
csvparser(); csvparser();
virtual ~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 "Localizer.h"
#include "meos_util.h" #include "meos_util.h"
#include "progress.h" #include "progress.h"
#include "meosexception.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <io.h> #include <io.h>
@ -93,7 +94,7 @@ void Download::shutDown()
} }
//If unsuccessful ending thread, do it violently //If unsuccessful ending thread, do it violently
if (hThread) { if (hThread) {
OutputDebugString("Terminate thread...\n"); OutputDebugString(L"Terminate thread...\n");
TerminateThread(HANDLE(hThread), 0); TerminateThread(HANDLE(hThread), 0);
CloseHandle(HANDLE(hThread)); CloseHandle(HANDLE(hThread));
} }
@ -112,64 +113,65 @@ void Download::initThread()
} }
void Download::initInternet() { 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) { if (hInternet==NULL) {
DWORD ec = GetLastError(); DWORD ec = GetLastError();
string error = lang.tl("Error: X#" + getErrorMessage(ec)); wstring error = lang.tl(L"Error: X#" + getErrorMessage(ec));
throw std::exception(error.c_str()); throw meosException(error);
} }
DWORD dwTimeOut = 120 * 1000; DWORD dwTimeOut = 180 * 1000;
InternetSetOption(hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD)); InternetSetOption(hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD));
InternetSetOption(hInternet, INTERNET_OPTION_SEND_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) if (hURL || !hInternet)
throw std::exception("Not inititialized"); throw std::exception("Not inititialized");
success = false; success = false;
string hdr; wstring hdr;
for (size_t k = 0; k<headers.size(); k++) wstring row;
hdr += headers[k].first + ": " + headers[k].second + "\r\n"; for (size_t k = 0; k<headers.size(); k++) {
hdr += headers[k].first + L": " + headers[k].second + L"\r\n";
string url2 = url; }
wstring url2 = url;
hURL = InternetOpenUrl(hInternet, url2.c_str(), hdr.empty() ? 0 : hdr.c_str(), hdr.length(), INTERNET_FLAG_DONT_CACHE, 0); hURL = InternetOpenUrl(hInternet, url2.c_str(), hdr.empty() ? 0 : hdr.c_str(), hdr.length(), INTERNET_FLAG_DONT_CACHE, 0);
if (!hURL) { if (!hURL) {
int err = GetLastError(); int err = GetLastError();
string msg2 = getErrorMessage(err); wstring msg2 = getErrorMessage(err);
DWORD em = 0, blen = 256; DWORD em = 0, blen = 256;
char bf2[256]; wchar_t bf2[256];
InternetGetLastResponseInfo(&em, bf2, &blen); InternetGetLastResponseInfo(&em, bf2, &blen);
string msg = "Failed to connect to: " + url; wstring msg = L"Failed to connect to: " + url2;
msg += " " + msg2; msg += L" " + msg2;
if (bf2[0] != 0) if (bf2[0] != 0)
msg += " (" + string(bf2) + ")"; msg += L" (" + wstring(bf2) + L")";
throw std::exception(msg.c_str()); throw meosException(msg.c_str());
} }
DWORD dwContentLen = 0; DWORD dwContentLen = 0;
DWORD dwBufLen = sizeof(dwContentLen); DWORD dwBufLen = sizeof(dwContentLen);
BOOL success = HttpQueryInfo(hURL, BOOL vsuccess = HttpQueryInfo(hURL,
HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwContentLen, &dwBufLen, 0); (LPVOID)&dwContentLen, &dwBufLen, 0);
if (success) if (vsuccess)
setBytesToDownload(dwContentLen); setBytesToDownload(dwContentLen);
else else
setBytesToDownload(0); setBytesToDownload(0);
DWORD dwStatus = 0; DWORD dwStatus = 0;
dwBufLen = sizeof(dwStatus); 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); (LPVOID)&dwStatus, &dwBufLen, 0);
if (success) { if (vsuccess) {
if (dwStatus >= 400) { if (dwStatus >= 400) {
char bf[256]; char bf[256];
switch (dwStatus) { 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) { if (fileno==-1) {
fileno=0; fileno=0;
endDownload(); endDownload();
char bf[256]; wchar_t bf[256];
sprintf_s(bf, "Error opening '%s' for writing", file.c_str()); swprintf_s(bf, L"Error opening '%s' for writing", file.c_str());
throw std::exception(bf); throw meosException(bf);
} }
bytesLoaded = 0; bytesLoaded = 0;
@ -266,16 +268,16 @@ bool Download::successful()
return success; return success;
} }
void Download::postFile(const string &url, const string &file, const string &fileOut, void Download::postFile(const wstring &url, const wstring &file, const wstring &fileOut,
const vector< pair<string, string> > &headers, ProgressWindow &pw) { const vector< pair<wstring, wstring> > &headers, ProgressWindow &pw) {
SetLastError(0); SetLastError(0);
DWORD_PTR dw = 0; DWORD_PTR dw = 0;
URL_COMPONENTS uc; URL_COMPONENTS uc;
memset(&uc, 0, sizeof(uc)); memset(&uc, 0, sizeof(uc));
uc.dwStructSize = sizeof(uc); uc.dwStructSize = sizeof(uc);
char host[128]; wchar_t host[128];
char path[128]; wchar_t path[128];
char extra[256]; wchar_t extra[256];
uc.lpszExtraInfo = extra; uc.lpszExtraInfo = extra;
uc.dwExtraInfoLength = sizeof(extra); uc.dwExtraInfoLength = sizeof(extra);
uc.lpszHostName = host; uc.lpszHostName = host;
@ -291,10 +293,10 @@ void Download::postFile(const string &url, const string &file, const string &fil
port = uc.nPort; port = uc.nPort;
HINTERNET hConnect = InternetConnect(hInternet, host, port, HINTERNET hConnect = InternetConnect(hInternet, host, port,
NULL, NULL, INTERNET_SERVICE_HTTP, 0, dw); NULL, NULL, INTERNET_SERVICE_HTTP, 0, dw);
bool success = false; bool vsuccess = false;
int errorCode = 0; int errorCode = 0;
try { try {
success = httpSendReqEx(hConnect, path, headers, file, fileOut, pw, errorCode); vsuccess = httpSendReqEx(hConnect, path, headers, file, fileOut, pw, errorCode);
} }
catch (std::exception &) { catch (std::exception &) {
InternetCloseHandle(hConnect); InternetCloseHandle(hConnect);
@ -302,20 +304,20 @@ void Download::postFile(const string &url, const string &file, const string &fil
} }
InternetCloseHandle(hConnect); InternetCloseHandle(hConnect);
if (!success) { if (!vsuccess) {
if (errorCode != 0) if (errorCode != 0)
errorCode = GetLastError(); errorCode = GetLastError();
string error = errorCode != 0 ? getErrorMessage(errorCode) : ""; wstring error = errorCode != 0 ? getErrorMessage(errorCode) : L"";
if (error.empty()) if (error.empty())
error = "Ett okänt fel inträffade."; error = L"Ett okänt fel inträffade.";
throw std::exception(error.c_str()); throw meosException(error);
} }
} }
bool Download::httpSendReqEx(HINTERNET hConnect, const string &dest, bool Download::httpSendReqEx(HINTERNET hConnect, const wstring &dest,
const vector< pair<string, string> > &headers, const vector< pair<wstring, wstring> > &headers,
const string &upFile, const string &outFile, const wstring &upFile, const wstring &outFile,
ProgressWindow &pw, ProgressWindow &pw,
int &errorCode) const { int &errorCode) const {
errorCode = 0; errorCode = 0;
@ -323,16 +325,16 @@ bool Download::httpSendReqEx(HINTERNET hConnect, const string &dest,
memset(&BufferIn, 0, sizeof(BufferIn)); memset(&BufferIn, 0, sizeof(BufferIn));
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS ); 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 dwBytesRead = 0;
DWORD dwBytesWritten = 0; DWORD dwBytesWritten = 0;
BYTE pBuffer[4*1024]; // Read from file in 4K chunks BYTE pBuffer[4*1024]; // Read from file in 4K chunks
string hdr; wstring hdr;
for (size_t k = 0; k<headers.size(); k++) { for (size_t k = 0; k<headers.size(); k++) {
if (!trim(headers[k].second).empty()) { 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 dwStatus = 0;
DWORD dwBufLen = sizeof(dwStatus); 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); (LPVOID)&dwStatus, &dwBufLen, 0);
if (success) { if (vsuccess) {
if (dwStatus >= 400) { if (dwStatus >= 400) {
char bf[256]; char bf[256];
switch (dwStatus) { 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 { do {
dwBytesRead=0; dwBytesRead=0;
if (InternetReadFile(hRequest, pBuffer, sizeof(pBuffer)-1, &dwBytesRead)) { if (InternetReadFile(hRequest, pBuffer, sizeof(pBuffer)-1, &dwBytesRead)) {
_write(fileno, pBuffer, dwBytesRead); _write(rfileno, pBuffer, dwBytesRead);
} }
} while(dwBytesRead>0); } while(dwBytesRead>0);
_close(fileno); _close(rfileno);
InternetCloseHandle(hRequest); InternetCloseHandle(hRequest);
return true; return true;

View File

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

View File

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

View File

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

View File

@ -132,11 +132,11 @@ private:
vector<MethodInfo> methods; vector<MethodInfo> methods;
mutable bool isCompiled; mutable bool isCompiled;
mutable Parser parser; mutable Parser parser;
string name; wstring name;
string tag; string tag;
string description; wstring description;
string annotation; wstring annotation;
mutable string origin; mutable wstring origin;
string timeStamp; string timeStamp;
bool builtIn; bool builtIn;
mutable bool readOnly; mutable bool readOnly;
@ -161,8 +161,8 @@ public:
long long getHashCode() const; long long getHashCode() const;
void getSymbols(vector< pair<string, size_t> > &symb) const; void getSymbols(vector< pair<wstring, size_t> > &symb) const;
void getSymbolInfo(int ix, string &name, string &desc) const; void getSymbolInfo(int ix, wstring &name, wstring &desc) const;
void declareSymbols(DynamicMethods m, bool clear) const; void declareSymbols(DynamicMethods m, bool clear) const;
@ -200,16 +200,16 @@ public:
void setTag(const string &t) {tag = t;} void setTag(const string &t) {tag = t;}
void setBuiltIn() {builtIn = true;} void setBuiltIn() {builtIn = true;}
bool isBuiltIn() const {return builtIn;} bool isBuiltIn() const {return builtIn;}
string getName(bool withAnnotation) const; wstring getName(bool withAnnotation) const;
void setName(const string &n) {name = n;} void setName(const wstring &n) {name = n;}
void setAnnotation(const string &a) {annotation = a;} void setAnnotation(const wstring &a) {annotation = a;}
const string &getDescription() const {return description;} const wstring &getDescription() const {return description;}
void setDescription(const string &n) {description = n;} 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 save(xmlparser &xml) const;
void load(const string &file); void load(const wstring &file);
void load(const xmlobject &xDef); void load(const xmlobject &xDef);
void compile(bool forceRecompile) const; 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; 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(); types.clear();
string v; 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)); types.push_back(make_pair(lang.tl("Webbdokument (html)"), HTML));
} }
void ImportFormats::getExportFilters(bool exportFilters, vector< pair<string, string> > &ext) { void ImportFormats::getExportFilters(bool exportFilters, vector< pair<wstring, wstring> > &ext) {
string v; wstring v;
if (exportFilters) if (exportFilters)
v = "Resultat"; v = L"Resultat";
else else
v = "Startlista"; v = L"Startlista";
ext.push_back(make_pair("IOF " + v + ", version 3.0 (xml)", "*.xml")); ext.push_back(make_pair(L"IOF " + v + L", version 3.0 (xml)", L"*.xml"));
ext.push_back(make_pair("IOF " + v + ", version 2.0.3 (xml)", "*.xml")); ext.push_back(make_pair(L"IOF " + v + L", version 2.0.3 (xml)", L"*.xml"));
ext.push_back(make_pair("OE Semikolonseparerad (csv)", "*.csv")); ext.push_back(make_pair(L"OE Semikolonseparerad (csv)", L"*.csv"));
ext.push_back(make_pair("OE/French Federation of Orienteering (csv)", "*.csv")); ext.push_back(make_pair(L"OE/French Federation of Orienteering (csv)", L"*.csv"));
ext.push_back(make_pair("Webbdokument (html)", "*.html")); ext.push_back(make_pair(L"Webbdokument (html)", L"*.html"));
} }
ImportFormats::ExportFormats ImportFormats::getDefaultExportFormat(oEvent &oe) { ImportFormats::ExportFormats ImportFormats::getDefaultExportFormat(oEvent &oe) {
@ -80,13 +80,13 @@ ImportFormats::ExportFormats ImportFormats::setExportFormat(oEvent &oe, int raw)
return (ExportFormats)raw; return (ExportFormats)raw;
} }
void ImportFormats::getOECSVLanguage(vector< pair<string, size_t> > &typeLanguages) { void ImportFormats::getOECSVLanguage(vector< pair<wstring, size_t> > &typeLanguages) {
typeLanguages.push_back(make_pair("English", 1)); typeLanguages.push_back(make_pair(L"English", 1));
typeLanguages.push_back(make_pair("Svenska", 2)); typeLanguages.push_back(make_pair(L"Svenska", 2));
typeLanguages.push_back(make_pair("Deutsch", 3)); typeLanguages.push_back(make_pair(L"Deutsch", 3));
typeLanguages.push_back(make_pair("Dansk", 4)); typeLanguages.push_back(make_pair(L"Dansk", 4));
typeLanguages.push_back(make_pair("Français", 5)); typeLanguages.push_back(make_pair(L"Français", 5));
typeLanguages.push_back(make_pair("Russian", 6)); typeLanguages.push_back(make_pair(L"Russian", 6));
} }
int ImportFormats::getDefaultCSVLanguage(oEvent &oe) { int ImportFormats::getDefaultCSVLanguage(oEvent &oe) {

View File

@ -41,9 +41,9 @@ public:
HTML = 5 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); static ExportFormats getDefaultExportFormat(oEvent &oe);
@ -55,7 +55,7 @@ public:
return option; 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); static int getDefaultCSVLanguage(oEvent &oe);

View File

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

View File

@ -42,8 +42,8 @@ class xmlbuffer {
private: private:
struct block { struct block {
string tag; string tag;
vector<pair<string, string>> prop; vector< pair<string, wstring> > prop;
string value; wstring value;
vector<xmlbuffer> subValues; vector<xmlbuffer> subValues;
}; };
@ -51,16 +51,21 @@ private:
bool complete; bool complete;
public: public:
void setComplete(bool c) {complete = c;} 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 endTag();
void write(const char *tag, void write(const char *tag,
const vector< pair<string, string> > &prop, const vector< pair<string, string> > &prop,
const string &value); const string &value);
void write(const char *tag,
const vector< pair<string, wstring> > &prop,
const wstring &value);
size_t size() const {return blocks.size();} size_t size() const {return blocks.size();}
bool commit(xmlparser &xml, int count); bool commit(xmlparser &xml, int count);
void startXML(xmlparser &xml, const string &dest); void startXML(xmlparser &xml, const wstring &dest);
}; };
class InfoBase class InfoBase
@ -93,7 +98,7 @@ typedef InfoBase * pInfoBase;
class InfoRadioControl : public InfoBase { class InfoRadioControl : public InfoBase {
protected: protected:
string name; wstring name;
bool synchronize(oControl &c, int number); bool synchronize(oControl &c, int number);
void serialize(xmlbuffer &xml, bool diffOnly) const; void serialize(xmlbuffer &xml, bool diffOnly) const;
public: public:
@ -105,11 +110,11 @@ class InfoRadioControl : public InfoBase {
class InfoClass : public InfoBase { class InfoClass : public InfoBase {
protected: protected:
string name; wstring name;
int sortOrder; int sortOrder;
vector< vector<int> > radioControls; vector< vector<int> > radioControls;
vector<int> linearLegNumberToActual; vector<int> linearLegNumberToActual;
bool synchronize(oClass &c); bool synchronize(oClass &c, const set<int> &ctrls);
void serialize(xmlbuffer &xml, bool diffOnly) const; void serialize(xmlbuffer &xml, bool diffOnly) const;
public: public:
InfoClass(int id); InfoClass(int id);
@ -120,7 +125,7 @@ class InfoClass : public InfoBase {
class InfoOrganization : public InfoBase { class InfoOrganization : public InfoBase {
protected: protected:
string name; wstring name;
bool synchronize(oClub &c); bool synchronize(oClub &c);
void serialize(xmlbuffer &xml, bool diffOnly) const; void serialize(xmlbuffer &xml, bool diffOnly) const;
public: public:
@ -141,7 +146,7 @@ struct RadioTime {
class InfoBaseCompetitor : public InfoBase { class InfoBaseCompetitor : public InfoBase {
protected: protected:
string name; wstring name;
int organizationId; int organizationId;
int classId; int classId;
@ -185,10 +190,10 @@ class InfoTeam : public InfoBaseCompetitor {
class InfoCompetition : public InfoBase { class InfoCompetition : public InfoBase {
private: private:
string name; wstring name;
string date; wstring date;
string organizer; wstring organizer;
string homepage; wstring homepage;
protected: protected:
bool forceComplete; bool forceComplete;
@ -206,7 +211,7 @@ protected:
public: public:
const vector<int> &getControls(int classId, int legNumber) const; 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 getCompleteXML(xmlbuffer &xml);
void getDiffXML(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 oDataInterface;
class oDataConstInterface; class oDataConstInterface;
class oAbstractRunner; class oAbstractRunner;
struct RunnerDBEntry; struct RunnerWDBEntry;
class RunnerDB; class RunnerDB;
typedef oRunner * pRunner; typedef oRunner * pRunner;
@ -78,13 +78,13 @@ class IOF30Interface {
double taxable; double taxable;
double percentage; // Eventor / OLA stupidity double percentage; // Eventor / OLA stupidity
string currency; wstring currency;
string fromTime; wstring fromTime;
string toTime; wstring toTime;
string fromBirthDate; wstring fromBirthDate;
string toBirthDate; wstring toBirthDate;
bool includes(const FeeInfo &fo) const { bool includes(const FeeInfo &fo) const {
if (toBirthDate != fo.toBirthDate || fromBirthDate != fo.fromBirthDate) if (toBirthDate != fo.toBirthDate || fromBirthDate != fo.fromBirthDate)
@ -102,20 +102,20 @@ class IOF30Interface {
void add(FeeInfo &fi); void add(FeeInfo &fi);
string getDateKey() const {return fromTime + " - " + toTime;} wstring getDateKey() const {return fromTime + L" - " + toTime;}
FeeInfo() : fee(0), taxable(0), percentage(0) {} FeeInfo() : fee(0), taxable(0), percentage(0) {}
const bool operator<(const FeeInfo &fi) const { const bool operator<(const FeeInfo &fi) const {
return fee < fi.fee || (fee == fi.fee && taxable < fi.taxable); return fee < fi.fee || (fee == fi.fee && taxable < fi.taxable);
} }
private: 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()) ) if ( a > b || (b.empty() && !a.empty()) )
return false; return false;
return true; 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()) ) if ( (!a.empty() && a < b) || (b.empty() && !a.empty()) )
return false; return false;
return true; return true;
@ -130,12 +130,15 @@ class IOF30Interface {
vector<FeeStatistics> feeStatistics; vector<FeeStatistics> feeStatistics;
static void getAgeLevels(const vector<FeeInfo> &fees, const vector<int> &ix, 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, void readEvent(gdioutput &gdi, const xmlobject &xo,
map<int, vector<LegInfo> > &teamClassConfig); map<int, vector<LegInfo> > &teamClassConfig);
pRunner readPersonEntry(gdioutput &gdi, xmlobject &xo, pTeam team, pRunner readPersonEntry(gdioutput &gdi, xmlobject &xo, pTeam team,
const map<int, vector<LegInfo> > &teamClassConfig, const map<int, vector<LegInfo> > &teamClassConfig,
const set<int> &stageFilter,
map<int, vector< pair<int, int> > > &personId2TeamLeg); map<int, vector< pair<int, int> > > &personId2TeamLeg);
pRunner readPerson(gdioutput &gdi, const xmlobject &xo); pRunner readPerson(gdioutput &gdi, const xmlobject &xo);
pClub readOrganization(gdioutput &gdi, const xmlobject &xo, bool saveToDB); pClub readOrganization(gdioutput &gdi, const xmlobject &xo, bool saveToDB);
@ -143,7 +146,8 @@ class IOF30Interface {
map<int, vector<LegInfo> > &teamClassConfig); map<int, vector<LegInfo> > &teamClassConfig);
pTeam readTeamEntry(gdioutput &gdi, xmlobject &xTeam, 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, const map<int, vector<LegInfo> > &teamClassConfig,
map<int, vector< pair<int, int> > > &personId2TeamLeg); map<int, vector< pair<int, int> > > &personId2TeamLeg);
@ -151,26 +155,28 @@ class IOF30Interface {
const map<int, vector<LegInfo> > &teamClassConfig); const map<int, vector<LegInfo> > &teamClassConfig);
pTeam readTeamStart(gdioutput &gdi, pClass pc, xmlobject &xTeam, 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); const map<int, vector<LegInfo> > &teamClassConfig);
pTeam getCreateTeam(gdioutput &gdi, const xmlobject &xTeam, bool &newTeam); pTeam getCreateTeam(gdioutput &gdi, const xmlobject &xTeam, bool &newTeam);
static int getIndexFromLegPos(int leg, int legorder, const vector<LegInfo> &setup); 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 setupClassConfig(int classId, const xmlobject &xTeam, map<int, vector<LegInfo> > &teamClassConfig);
void setupRelayClasses(const map<int, vector<LegInfo> > &teamClassConfig); void setupRelayClasses(const map<int, vector<LegInfo> > &teamClassConfig);
void setupRelayClass(pClass pc, const vector<LegInfo> &teamClassConfig); void setupRelayClass(pClass pc, const vector<LegInfo> &teamClassConfig);
int parseISO8601Time(const xmlobject &xo); int parseISO8601Time(const xmlobject &xo);
string getCurrentTime() const; wstring getCurrentTime() const;
static void getNationality(const xmlobject &xCountry, oDataInterface &di); static void getNationality(const xmlobject &xCountry, oDataInterface &di);
static void getAmount(const xmlobject &xAmount, double &amount, 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, string &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 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; 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 writeAssignedFee(xmlparser &xml, const oAbstractRunner &tr, int paidForCard) const;
void writeRentalCardService(xmlparser &xml, int cardFee, bool paid) 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, void writeClassResult(xmlparser &xml, const oClass &c, const vector<pRunner> &r,
const vector<pTeam> &t); const vector<pTeam> &t);
@ -219,9 +225,9 @@ class IOF30Interface {
int getStageNumber(); int getStageNumber();
bool readXMLCompetitorDB(const xmlobject &xCompetitor); 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); bool readControl(const xmlobject &xControl);
pCourse readCourse(const xmlobject &xcrs); pCourse readCourse(const xmlobject &xcrs);
@ -229,31 +235,31 @@ class IOF30Interface {
void readCourseGroups(xmlobject xClassCourse, vector< vector<pCourse> > &crs); void readCourseGroups(xmlobject xClassCourse, vector< vector<pCourse> > &crs);
void bindClassCourse(oClass &pc, const vector< vector<pCourse> > &crs); void bindClassCourse(oClass &pc, const vector< vector<pCourse> > &crs);
static string constructCourseName(const xmlobject &xcrs); static wstring constructCourseName(const xmlobject &xcrs);
static string constructCourseName(const string &family, const string &name); static wstring constructCourseName(const wstring &family, const wstring &name);
void classAssignmentObsolete(gdioutput &gdi, xmlList &xAssignment, const map<string, pCourse> &courses, void classAssignmentObsolete(gdioutput &gdi, xmlList &xAssignment, const map<wstring, pCourse> &courses,
const map<string, vector<pCourse> > &coursesFamilies); const map<wstring, vector<pCourse> > &coursesFamilies);
void classCourseAssignment(gdioutput &gdi, xmlList &xAssignment, void classCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses, const map<wstring, pCourse> &courses,
const map<string, vector<pCourse> > &coursesFamilies); const map<wstring, vector<pCourse> > &coursesFamilies);
void personCourseAssignment(gdioutput &gdi, xmlList &xAssignment, void personCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses); const map<wstring, pCourse> &courses);
void teamCourseAssignment(gdioutput &gdi, xmlList &xAssignment, void teamCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses); const map<wstring, pCourse> &courses);
void assignTeamCourse(gdioutput &gdi, oTeam &t, xmlList &xAssignment, 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); 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 writeCourseInfo(xmlparser &xml, const oCourse &c);
void writeFullCourse(xmlparser &xml, const oCourse &c, void writeFullCourse(xmlparser &xml, const oCourse &c,
const map<int, string> &ctrlId2ExportId); const map<int, wstring> &ctrlId2ExportId);
public: public:
IOF30Interface(oEvent *oe, bool forceSplitFee); IOF30Interface(oEvent *oe, bool forceSplitFee);
@ -261,7 +267,11 @@ public:
void readEventList(gdioutput &gdi, xmlobject &xo); 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); 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.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +1,53 @@
/* /*
* << Haru Free PDF Library >> -- hpdf_u3d.h * << Haru Free PDF Library >> -- hpdf_u3d.h
* *
* URL: http://libharu.org * URL: http://libharu.org
* *
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org> * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
* *
* Permission to use, copy, modify, distribute and sell this software * Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee, * and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and * provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear * that both that copyright notice and this permission notice appear
* in supporting documentation. * in supporting documentation.
* It is provided "as is" without express or implied warranty. * It is provided "as is" without express or implied warranty.
* *
*/ */
#ifndef _HPDF_U3D_H #ifndef _HPDF_U3D_H
#define _HPDF_U3D_H #define _HPDF_U3D_H
#include "hpdf_objects.h" #include "hpdf_objects.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
HPDF_EXPORT(HPDF_JavaScript) HPDF_CreateJavaScript(HPDF_Doc pdf, const char *code); HPDF_EXPORT(HPDF_JavaScript) HPDF_CreateJavaScript(HPDF_Doc pdf, const char *code);
HPDF_EXPORT(HPDF_U3D) HPDF_LoadU3DFromFile (HPDF_Doc pdf, const char *filename); HPDF_EXPORT(HPDF_U3D) HPDF_LoadU3DFromFile (HPDF_Doc pdf, const char *filename);
HPDF_EXPORT(HPDF_Dict) HPDF_Create3DView (HPDF_MMgr mmgr, const char *name); HPDF_EXPORT(HPDF_Image) HPDF_LoadU3DFromMem (HPDF_Doc pdf, const HPDF_BYTE *buffer, HPDF_UINT size);
HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_Add3DView(HPDF_U3D u3d, HPDF_Dict view); HPDF_EXPORT(HPDF_Dict) HPDF_Create3DView (HPDF_MMgr mmgr, const char *name);
HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_SetDefault3DView(HPDF_U3D u3d, const char *name); HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_Add3DView(HPDF_U3D u3d, HPDF_Dict view);
HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_AddOnInstanciate(HPDF_U3D u3d, HPDF_JavaScript javaScript); HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_SetDefault3DView(HPDF_U3D u3d, const char *name);
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_AddNode(HPDF_Dict view, const char *name, HPDF_REAL opacity, HPDF_BOOL visible); HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_AddOnInstanciate(HPDF_U3D u3d, HPDF_JavaScript javaScript);
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetLighting(HPDF_Dict view, const char *scheme); HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_AddNode(HPDF_Dict view, const char *name, HPDF_REAL opacity, HPDF_BOOL visible);
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetBackgroundColor(HPDF_Dict view, HPDF_REAL r, HPDF_REAL g, HPDF_REAL b); HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetLighting(HPDF_Dict view, const char *scheme);
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetPerspectiveProjection(HPDF_Dict view, HPDF_REAL fov); HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetBackgroundColor(HPDF_Dict view, HPDF_REAL r, HPDF_REAL g, HPDF_REAL b);
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetOrthogonalProjection(HPDF_Dict view, HPDF_REAL mag); HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetPerspectiveProjection(HPDF_Dict view, HPDF_REAL fov);
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetCamera(HPDF_Dict view, HPDF_REAL coox, HPDF_REAL cooy, HPDF_REAL cooz, HPDF_REAL c2cx, HPDF_REAL c2cy, HPDF_REAL c2cz, HPDF_REAL roo, HPDF_REAL roll); HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetOrthogonalProjection(HPDF_Dict view, HPDF_REAL mag);
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetCamera(HPDF_Dict view, HPDF_REAL coox, HPDF_REAL cooy, HPDF_REAL cooz, HPDF_REAL c2cx, HPDF_REAL c2cy, HPDF_REAL c2cz, HPDF_REAL roo, HPDF_REAL roll);
HPDF_Dict
HPDF_3DView_New ( HPDF_MMgr mmgr, HPDF_Dict
HPDF_Xref xref, HPDF_3DView_New ( HPDF_MMgr mmgr,
HPDF_U3D u3d, HPDF_Xref xref,
const char *name); HPDF_U3D u3d,
#ifdef __cplusplus const char *name);
} #ifdef __cplusplus
#endif /* __cplusplus */ }
#endif /* __cplusplus */
#endif /* _HPDF_U3D_H */
#endif /* _HPDF_U3D_H */

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. 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. 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 AFFERO GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE Version 3, 19 November 2007
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
@ -21,17 +20,15 @@ Copyright 2007-2013 Melin Software HB.
Preamble Preamble
The GNU General Public License is a free, copyleft license for The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works. 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 The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast, 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 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 software for all its users.
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.
When we speak of free software, we are referring to freedom, not When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you 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 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. free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you Developers that use our General Public Licenses protect your rights
these rights or asking you to surrender the rights. Therefore, you have with two steps: (1) assert copyright on the software, and (2) offer
certain responsibilities if you distribute copies of the software, or if you this License which gives you legal permission to copy, distribute
you modify it: responsibilities to respect the freedom of others. and/or modify the software.
For example, if you distribute copies of such a program, whether A secondary benefit of defending all users' freedom is that
gratis or for a fee, you must pass on to the recipients the same improvements made in alternate versions of the program, if they
freedoms that you received. You must make sure that they, too, receive receive widespread use, become available for other developers to
or can get the source code. And you must show them these terms so they incorporate. Many developers of free software are heartened and
know their rights. 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: The GNU Affero General Public License is designed specifically to
(1) assert copyright on the software, and (2) offer you this License ensure that, in such cases, the modified source code becomes available
giving you legal permission to copy, distribute and/or modify it. 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 An older license, called the Affero General Public License and
that there is no warranty for this free software. For both users' and published by Affero, was designed to accomplish similar goals. This is
authors' sake, the GPL requires that modified versions be marked as a different license, not a version of the Affero GPL, but Affero has
changed, so that their problems will not be attributed erroneously to released a new version of the Affero GPL which permits relicensing under
authors of previous versions. this license.
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.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
@ -86,7 +73,7 @@ modification follow.
0. Definitions. 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 "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks. 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 the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program. 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 Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed 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 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, License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License, but the work with which it is combined will remain governed by version
section 13, concerning interaction through a network will apply to the 3 of the GNU General Public License.
combination as such.
14. Revised Versions of this License. 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of 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 the GNU Affero General Public License from time to time. Such new versions
be similar in spirit to the present version, but may differ in detail to will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns.
Each version is given a distinguishing version number. If the 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 Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the 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. by the Free Software Foundation.
If the Program specifies that a proxy can decide which future 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 public statement of acceptance of a version permanently authorizes you
to choose that version for the Program. 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> Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify 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 the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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/>. 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. Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short If your software can interact with users remotely through a computer
notice like this when it starts in an interactive mode: 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
<program> Copyright (C) <year> <name of author> interface could display a "Source" link that leads users to an archive
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. of the code. There are many ways you could offer source, and different
This is free software, and you are welcome to redistribute it solutions will be better for different programs; see section 13 for the
under certain conditions; type `show c' for details. specific requirements.
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".
You should also get your employer (if you work as a programmer) or school, 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. 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/>. <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(); int by = gdi.getCY();
if (currentList) if (currentList)
gdi.addString("", boldLarge, MakeDash("Listredigerare - X#") + currentList->getListName()); gdi.addString("", boldLarge, makeDash(L"Listredigerare - X#") + currentList->getListName());
else else
gdi.addString("", boldLarge, "Listredigerare"); gdi.addString("", boldLarge, "Listredigerare");
@ -106,7 +106,7 @@ void ListEditor::show(gdioutput &gdi) {
if (savedFileName.empty()) if (savedFileName.empty())
gdi.addButton("SaveFile", "Spara som fil", editListCB); gdi.addButton("SaveFile", "Spara som fil", editListCB);
else { else {
gdi.addButton("SaveFile", "Spara fil", editListCB, "#" + savedFileName); gdi.addButton("SaveFile", L"Spara fil", editListCB, L"#" + savedFileName);
gdi.addButton("SaveFileCopy", "Spara som...", editListCB); gdi.addButton("SaveFileCopy", "Spara som...", editListCB);
} }
@ -228,6 +228,10 @@ void ListEditor::show(gdioutput &gdi) {
oe->generateList(gdi, false, li, true); 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) { catch (std::exception &ex) {
gdi.addString("", 1, "Listan kan inte visas").setColor(colorRed); gdi.addString("", 1, "Listan kan inte visas").setColor(colorRed);
gdi.addString("", 0, ex.what()); 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 { ButtonInfo &ListEditor::addButton(gdioutput &gdi, const MetaListPost &mlp, int x, int y, int lineIx, int ix) const {
string cap; wstring cap;
if (mlp.getType() == "String") { if (mlp.getType() == L"String") {
cap = "Text: X#" + mlp.getText(); cap = L"Text: X#" + mlp.getText();
} }
else { else {
const string &text = mlp.getText(); const wstring &text = mlp.getText();
if (text.length() > 0) { if (text.length() > 0) {
if (text[0] == '@') { if (text[0] == '@') {
vector<string> part; vector<wstring> part;
split(text.substr(1), ";", part); split(text.substr(1), L";", part);
unsplit(part, "|", cap); unsplit(part, L"|", cap);
} }
else else
cap = text + "#" + lang.tl(mlp.getType()); cap = text + L"#" + lang.tl(mlp.getType());
} }
else { else {
cap = mlp.getType(); cap = mlp.getType();
@ -319,10 +323,10 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
if (ChooseColor(&cc)) { if (ChooseColor(&cc)) {
data.setExtra((int)cc.rgbResult); data.setExtra((int)cc.rgbResult);
string co; wstring co;
for (ix = 0; ix < 16; ix++) { for (ix = 0; ix < 16; ix++) {
char bf[16]; wchar_t bf[16];
sprintf_s(bf, "%x ", staticColor[ix]); swprintf_s(bf, L"%x ", staticColor[ix]);
co += bf; co += bf;
} }
oe->setProperty("Colors", co); oe->setProperty("Colors", co);
@ -403,14 +407,14 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
EPostType ptype = EPostType(lbi.data); EPostType ptype = EPostType(lbi.data);
string str = gdi.getText("Text"); wstring str = gdi.getText("Text");
if (ptype != lString) { if (ptype != lString) {
if (!str.empty() && str.find_first_of('X') == string::npos && str[0]!='@') { 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"); 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); EPostType newType = EPostType(lbi.data);
mlp.setType(newType); mlp.setType(newType);
if (t1 != mlp.getType()) if (t1 != mlp.getType())
@ -461,7 +465,7 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
} }
} }
else if (bi.id == "ApplyListProp") { else if (bi.id == "ApplyListProp") {
string name = gdi.getText("Name"); wstring name = gdi.getText("Name");
if (name.empty()) if (name.empty())
throw meosException("Namnet kan inte vara tomt"); 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)) if (gdi.getSelectedItem("SubType", lbi))
list.setSubListType(oListInfo::EBaseType(lbi.data)); list.setSubListType(oListInfo::EBaseType(lbi.data));
vector< pair<string, bool> > filtersIn; vector< pair<wstring, bool> > filtersIn;
vector< bool > filtersOut; vector< bool > filtersOut;
list.getFilters(filtersIn); list.getFilters(filtersIn);
for (size_t k = 0; k < filtersIn.size(); k++) 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); list.setFilters(filtersOut);
vector< pair<string, bool> > subFiltersIn; vector< pair<wstring, bool> > subFiltersIn;
vector< bool > subFiltersOut; vector< bool > subFiltersOut;
list.getSubFilters(subFiltersIn); list.getSubFilters(subFiltersIn);
for (size_t k = 0; k < subFiltersIn.size(); k++) 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"; bool copy = bi.id == "SaveFileCopy";
string fileName = copy ? "" : savedFileName; wstring fileName = copy ? L"" : savedFileName;
if (fileName.empty()) { if (fileName.empty()) {
int ix = 0; int ix = 0;
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("xml-data", "*.xml")); ext.push_back(make_pair(L"xml-data", L"*.xml"));
fileName = gdi.browseForSave(ext, "xml", ix); fileName = gdi.browseForSave(ext, L"xml", ix);
if (fileName.empty()) if (fileName.empty())
return 0; return 0;
} }
@ -572,15 +576,15 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
if (!checkSave(gdi)) if (!checkSave(gdi))
return 0; return 0;
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("xml-data", "*.xml")); ext.push_back(make_pair(L"xml-data", L"*.xml"));
string fileName = gdi.browseForOpen(ext, "xml"); wstring fileName = gdi.browseForOpen(ext, L"xml");
if (fileName.empty()) if (fileName.empty())
return 0; return 0;
MetaList *tmp = new MetaList(); MetaList *tmp = new MetaList();
try { try {
tmp->setListName(lang.tl("Ny lista")); tmp->setListName(lang.tl(L"Ny lista"));
tmp->load(fileName); tmp->load(fileName);
} }
catch(...) { catch(...) {
@ -608,12 +612,12 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
gdi.setData("ListEditorClz", this); gdi.setData("ListEditorClz", this);
gdi.pushX(); gdi.pushX();
vector< pair<string, size_t> > lists; vector< pair<wstring, size_t> > lists;
oe->getListContainer().getLists(lists, true, false, false); oe->getListContainer().getLists(lists, true, false, false);
reverse(lists.begin(), lists.end()); reverse(lists.begin(), lists.end());
gdi.fillRight(); 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.addItem("OpenList", lists);
gdi.selectFirstItem("OpenList"); gdi.selectFirstItem("OpenList");
@ -709,12 +713,12 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
if (lbi.id == "AlignType") { if (lbi.id == "AlignType") {
gdi.setInputStatus("AlignText", lbi.data == lString); gdi.setInputStatus("AlignText", lbi.data == lString);
if (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) if (ix != lbi.text.npos)
gdi.setText("AlignText", lbi.text.substr(ix+1)); gdi.setText("AlignText", lbi.text.substr(ix+1));
} }
else else
gdi.setText("AlignText", ""); gdi.setText("AlignText", L"");
} }
else if (lbi.id == "Type") { else if (lbi.id == "Type") {
EPostType type = EPostType(lbi.data); EPostType type = EPostType(lbi.data);
@ -727,12 +731,12 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
gdi.disableInput("UseLeg"); gdi.disableInput("UseLeg");
gdi.enableInput("Leg"); gdi.enableInput("Leg");
if (gdi.getText("Leg").empty()) if (gdi.getText("Leg").empty())
gdi.setText("Leg", "0"); gdi.setText("Leg", L"0");
} }
else { else {
gdi.enableInput("UseLeg"); gdi.enableInput("UseLeg");
if (gdi.getTextNo("Leg") == 0) { if (gdi.getTextNo("Leg") == 0) {
gdi.setText("Leg", ""); gdi.setText("Leg", L"");
gdi.enableInput("UseLeg"); gdi.enableInput("UseLeg");
gdi.enableInput("UseResultModule", true); gdi.enableInput("UseResultModule", true);
gdi.check("UseLeg", false); gdi.check("UseLeg", false);
@ -742,14 +746,14 @@ int ListEditor::editList(gdioutput &gdi, int type, BaseInfo &data) {
} }
else if (lbi.id == "SubType") { else if (lbi.id == "SubType") {
oListInfo::EBaseType subType = oListInfo::EBaseType(lbi.data); oListInfo::EBaseType subType = oListInfo::EBaseType(lbi.data);
vector< pair<string, bool> > subfilters; vector< pair<wstring, bool> > subfilters;
currentList->getSubFilters(subfilters); currentList->getSubFilters(subfilters);
for (size_t k = 0; k < subfilters.size(); k++) { for (size_t k = 0; k < subfilters.size(); k++) {
gdi.setInputStatus("subfilter" + itos(k), subType != oListInfo::EBaseTypeNone); gdi.setInputStatus("subfilter" + itos(k), subType != oListInfo::EBaseTypeNone);
} }
} }
else if (lbi.id == "ResultType") { else if (lbi.id == "ResultType") {
vector< pair<string, size_t> > types; vector< pair<wstring, size_t> > types;
int currentType = 0; int currentType = 0;
currentList->getSortOrder(lbi.data != 0, types, currentType); currentList->getSortOrder(lbi.data != 0, types, currentType);
if (lbi.data == 0) { if (lbi.data == 0) {
@ -811,7 +815,7 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.dropLine(3); gdi.dropLine(3);
gdi.popX(); gdi.popX();
vector< pair<string, size_t> > types; vector< pair<wstring, size_t> > types;
int currentType; int currentType;
mlp.getTypes(types, currentType); mlp.getTypes(types, currentType);
EPostType storedType = EPostType(currentType); EPostType storedType = EPostType(currentType);
@ -833,21 +837,21 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.pushX(); gdi.pushX();
gdi.fillRight(); gdi.fillRight();
int boxY = gdi.getCY(); int boxY = gdi.getCY();
gdi.addSelection("Type", 290, 500, editListCB, "Typ:"); gdi.addSelection("Type", 290, 500, editListCB, L"Typ:");
gdi.addItem("Type", types); gdi.addItem("Type", types);
gdi.selectItemByData("Type", currentType); 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(); int boxX = gdi.getCX();
gdi.popX(); gdi.popX();
gdi.fillRight(); gdi.fillRight();
gdi.dropLine(3); gdi.dropLine(3);
currentList->getAlignTypes(mlp, types, currentType); currentList->getAlignTypes(mlp, types, currentType);
sort(types.begin(), types.end()); 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.addItem("AlignType", types);
gdi.selectItemByData("AlignType", currentType); gdi.selectItemByData("AlignType", currentType);
gdi.addInput("AlignText", mlp.getAlignText(), 16, 0, "Text:"); gdi.addInput("AlignText", mlp.getAlignText(), 16, 0, L"Text:");
if (currentType != lString) if (currentType != lString)
gdi.disableInput("AlignText"); gdi.disableInput("AlignText");
gdi.popX(); gdi.popX();
@ -855,7 +859,7 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.fillRight(); gdi.fillRight();
gdi.addCheckbox("BlockAlign", "Justera blockvis:", 0, mlp.getAlignBlock()); gdi.addCheckbox("BlockAlign", "Justera blockvis:", 0, mlp.getAlignBlock());
gdi.dropLine(-0.2); 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.dropLine(2.1);
gdi.popX(); gdi.popX();
gdi.fillRight(); gdi.fillRight();
@ -871,9 +875,9 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.dropLine(-0.2); gdi.dropLine(-0.2);
gdi.setCX(gdi.getCX() + gdi.getLineHeight() * 5); gdi.setCX(gdi.getCX() + gdi.getLineHeight() * 5);
if (storedType == lResultModuleNumber || storedType == lResultModuleTime || storedType == lResultModuleTimeTeam || storedType == lResultModuleNumberTeam) 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 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) { if (storedType == lResultModuleNumber || storedType == lResultModuleTime || storedType == lResultModuleTimeTeam || storedType == lResultModuleNumberTeam) {
gdi.check("UseLeg", true); gdi.check("UseLeg", true);
@ -897,13 +901,13 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.addString("", 1, "Formateringsregler"); gdi.addString("", 1, "Formateringsregler");
gdi.dropLine(0.5); gdi.dropLine(0.5);
gdi.fillRight(); 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; int currentFont;
mlp.getFonts(fonts, 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.addItem("Fonts", fonts);
gdi.selectItemByData("Fonts", currentFont); gdi.selectItemByData("Fonts", currentFont);
int maxX = gdi.getCX(); int maxX = gdi.getCX();
@ -911,7 +915,7 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.popX(); gdi.popX();
gdi.dropLine(3); 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("Vänster"), 0);
gdi.addItem("TextAdjust", lang.tl("Höger"), textRight); gdi.addItem("TextAdjust", lang.tl("Höger"), textRight);
gdi.addItem("TextAdjust", lang.tl("Centrera"), textCenter); gdi.addItem("TextAdjust", lang.tl("Centrera"), textCenter);
@ -954,13 +958,13 @@ void ListEditor::editListPost(gdioutput &gdi, const MetaListPost &mlp, int id) {
gdi.refresh(); gdi.refresh();
} }
const char *ListEditor::getIndexDescription(EPostType type) { const wchar_t *ListEditor::getIndexDescription(EPostType type) {
if (type == lResultModuleTime || type == lResultModuleTimeTeam) if (type == lResultModuleTime || type == lResultModuleTimeTeam)
return "Index in X[index]#OutputTimes"; return L"Index in X[index]#OutputTimes";
else if (type == lResultModuleNumber || type == lResultModuleNumberTeam) else if (type == lResultModuleNumber || type == lResultModuleNumberTeam)
return "Index in X[index]#OutputNumbers"; return L"Index in X[index]#OutputNumbers";
else else
return "Applicera för specifik sträcka:"; return L"Applicera för specifik sträcka:";
} }
void ListEditor::editListProp(gdioutput &gdi, bool newList) { void ListEditor::editListProp(gdioutput &gdi, bool newList) {
@ -993,39 +997,39 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.fillRight(); gdi.fillRight();
gdi.pushX(); gdi.pushX();
gdi.addInput("Name", list.getListName(), 20, 0, "Listnamn:"); gdi.addInput("Name", list.getListName(), 20, 0, L"Listnamn:");
if (newList) { if (newList) {
gdi.dropLine(3.5); gdi.dropLine(3.5);
gdi.popX(); gdi.popX();
} }
vector< pair<string, size_t> > types; vector< pair<wstring, size_t> > types;
int currentType = 0; int currentType = 0;
int maxX = gdi.getCX(); int maxX = gdi.getCX();
list.getBaseType(types, currentType); list.getBaseType(types, currentType);
gdi.addSelection("BaseType", 150, 400, 0, "Listtyp:"); gdi.addSelection("BaseType", 150, 400, 0, L"Listtyp:");
gdi.addItem("BaseType", types); gdi.addItem("BaseType", types);
gdi.selectItemByData("BaseType", currentType); gdi.selectItemByData("BaseType", currentType);
gdi.autoGrow("BaseType"); gdi.autoGrow("BaseType");
list.getResultModule(*oe, types, currentType); 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.addItem("ResultType", types);
gdi.autoGrow("ResultType"); gdi.autoGrow("ResultType");
gdi.selectItemByData("ResultType", currentType); gdi.selectItemByData("ResultType", currentType);
list.getSortOrder(false, types, 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.addItem("SortOrder", types);
gdi.autoGrow("SortOrder"); gdi.autoGrow("SortOrder");
gdi.selectItemByData("SortOrder", currentType); gdi.selectItemByData("SortOrder", currentType);
list.getSubType(types, 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.addItem("SubType", types);
gdi.selectItemByData("SubType", currentType); gdi.selectItemByData("SubType", currentType);
oListInfo::EBaseType subType = oListInfo::EBaseType(currentType); oListInfo::EBaseType subType = oListInfo::EBaseType(currentType);
@ -1043,7 +1047,7 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.fillDown(); gdi.fillDown();
gdi.addString("", 1, "Filter"); gdi.addString("", 1, "Filter");
gdi.dropLine(0.5); gdi.dropLine(0.5);
vector< pair<string, bool> > filters; vector< pair<wstring, bool> > filters;
list.getFilters(filters); list.getFilters(filters);
gdi.fillRight(); gdi.fillRight();
int xp = gdi.getCX(); int xp = gdi.getCX();
@ -1065,7 +1069,7 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.fillDown(); gdi.fillDown();
gdi.addString("", 1, "Underfilter"); gdi.addString("", 1, "Underfilter");
gdi.dropLine(0.5); gdi.dropLine(0.5);
vector< pair<string, bool> > subfilters; vector< pair<wstring, bool> > subfilters;
list.getSubFilters(subfilters); list.getSubFilters(subfilters);
gdi.fillRight(); gdi.fillRight();
xp = gdi.getCX(); xp = gdi.getCX();
@ -1091,8 +1095,8 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.addString("", 1, "Typsnitt"); gdi.addString("", 1, "Typsnitt");
gdi.dropLine(0.5); gdi.dropLine(0.5);
gdi.fillRight(); gdi.fillRight();
const char *expl[4] = {"Rubrik", "Underrubrik", "Lista", "Underlista"}; const wchar_t *expl[4] = {L"Rubrik", L"Underrubrik", L"Lista", L"Underlista"};
vector< pair<string, size_t> > fonts; vector< pair<wstring, size_t> > fonts;
gdi.getEnumeratedFonts(fonts); gdi.getEnumeratedFonts(fonts);
sort(fonts.begin(), fonts.end()); sort(fonts.begin(), fonts.end());
@ -1104,10 +1108,10 @@ void ListEditor::editListProp(gdioutput &gdi, bool newList) {
gdi.setText(id, list.getFontFace(k)); gdi.setText(id, list.getFontFace(k));
gdi.setCX(gdi.getCX()+20); gdi.setCX(gdi.getCX()+20);
int f = list.getFontFaceFactor(k); int f = list.getFontFaceFactor(k);
string ff = f == 0 ? "100 %" : itos(f) + " %"; wstring ff = f == 0 ? L"100 %" : itow(f) + L" %";
gdi.addInput("FontFactor" + itos(k), ff, 4, 0, "Skalfaktor", "Relativ skalfaktor för typsnittets storlek i procent"); gdi.addInput("FontFactor" + itos(k), ff, 4, 0, L"Skalfaktor", L"Relativ skalfaktor för typsnittets storlek i procent");
f = list.getExtraSpace(k); 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) { if (k == 1) {
gdi.dropLine(3); gdi.dropLine(3);
gdi.popX(); gdi.popX();
@ -1172,7 +1176,7 @@ void ListEditor::makeDirty(gdioutput &gdi, DirtyFlag inside, DirtyFlag outside)
bool ListEditor::checkSave(gdioutput &gdi) { bool ListEditor::checkSave(gdioutput &gdi) {
if (dirtyInt || dirtyExt) { 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) if (answer == gdioutput::AnswerCancel)
return false; return false;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
@ -58,7 +58,7 @@
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir> <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> <OutDir Condition="'$(Configuration)|$(Platform)'=='test|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='test|Win32'">$(Configuration)\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='test|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='test|Win32'">true</LinkIncremental> <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 <vector>
#include <map> #include <map>
@ -58,31 +59,53 @@ string getLocalTime();
string getLocalDate(); string getLocalDate();
string getLocalTimeOnly(); 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... // Get a day number after a fixed day some time ago...
int getRelativeDay(); int getRelativeDay();
/// Get time and date in a format that forms a part of a filename /// 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 &getTimeMS(int m);
const string &formatTime(int rt); const string &formatTimeN(int rt);
const string &formatTimeHMS(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, bool checkValid);
int convertDateYMS(const string &m, SYSTEMTIME &st, 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 // 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 // Format number date 20160421 -> 2016-04-21 (if iso) or according to a custom format otherwise
string formatDate(int m, bool useIsoFormat); string formatDate(int m, bool useIsoFormat);
wstring formatDateW(int m, bool useIsoFormat);
__int64 SystemTimeToInt64Second(const SYSTEMTIME &st); __int64 SystemTimeToInt64Second(const SYSTEMTIME &st);
SYSTEMTIME Int64SecondToSystemTime(__int64 time); SYSTEMTIME Int64SecondToSystemTime(__int64 time);
#define NOTIME 0x7FFFFFFF #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 //Returns a time converted from +/-MM:SS or NOTIME, in seconds
int convertAbsoluteTimeMS(const string &m); int convertAbsoluteTimeMS(const string &m);
// Parses a time on format HH:MM:SS+01:00Z or HHMMSS+0100Z (but ignores time zone) // 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. @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); 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 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 &unsplit(const vector<string> &split_vector, const string &separators, string &line);
const string &MakeDash(const string &t); const vector<wstring> &split(const wstring &line, const wstring &separators, vector<wstring> &split_vector);
const string &MakeDash(const char *t); const wstring &unsplit(const vector<wstring> &split_vector, const wstring &separators, wstring &line);
string FormatRank(int rank);
const wstring &makeDash(const wstring &t);
const wstring &makeDash(const wchar_t *t);
wstring formatRank(int rank);
const string &itos(int i); const string &itos(int i);
string itos(unsigned long i); string itos(unsigned long i);
string itos(unsigned int i); string itos(unsigned int i);
string itos(__int64 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) ///Lower case match (filt_lc must be lc)
bool filterMatchString(const string &c, const char *filt_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(); int getMeosBuild();
string getMeosDate(); wstring getMeosDate();
string getMeosFullVersion(); wstring getMeosFullVersion();
string getMajorVersion(); wstring getMajorVersion();
string getMeosCompectVersion(); wstring getMeosCompectVersion();
void getSupporters(vector<string> &supp); 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); 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 char *decodeXML(const char *in);
const string &decodeXML(const string &in); const string &decodeXML(const string &in);
const string &encodeXML(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 */ /** Extend a year from 03 -> 2003, 97 -> 1997 etc */
int extendYear(int year); int extendYear(int year);
@ -136,27 +179,30 @@ int extendYear(int year);
int getThisYear(); int getThisYear();
/** Translate a char to lower/stripped of accents etc.*/ /** Translate a char to lower/stripped of accents etc.*/
int toLowerStripped(int c); int toLowerStripped(wchar_t c);
/** Canonize a person/club name */ /** 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*/ /** 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*/ /** Get a number suffix, Start 1 -> 1. Zero for none*/
int getNumberSuffix(const string &str); int getNumberSuffix(const string &str);
int getNumberSuffix(const wstring &str);
/// Extract any number from a string and return the number, prefix and suffix /// 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 */ /** 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 */ /** Get WinAPI error from code */
string getErrorMessage(int code); wstring getErrorMessage(int code);
class HLS { class HLS {
private: private:
@ -175,46 +221,52 @@ public:
DWORD HLStoRGB() const; DWORD HLStoRGB() const;
}; };
#ifndef MEOSDB void unzip(const wchar_t *zipfilename, const char *password, vector<wstring> &extractedFiles);
void unzip(const char *zipfilename, const char *password, vector<string> &extractedFiles); int zip(const wchar_t *zipfilename, const char *password, const vector<wstring> &files);
int zip(const char *zipfilename, const char *password, const vector<string> &files);
#endif bool isAscii(const wstring &s);
bool isNumber(const wstring &s);
bool isAscii(const string &s); bool isAscii(const string &s);
bool isNumber(const string &s); bool isNumber(const string &s);
int convertDynamicBase(const string &s, long long &out); int convertDynamicBase(const wstring &s, long long &out);
void convertDynamicBase(long long val, int base, char out[16]); void convertDynamicBase(long long val, int base, wchar_t out[16]);
/// Find all files in dir matching given file pattern /// 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}; 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. */ /** Initial capital letter. */
void capitalize(string &str); void capitalize(wstring &str);
/** Initial capital letter for each word. */ /** 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. */ /** 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)*/ /** 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.*/ /** 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.*/ /** 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. */ /** Simple file locking class to prevent opening in different MeOS session. */
class MeOSFileLock { class MeOSFileLock {
@ -228,9 +280,12 @@ public:
~MeOSFileLock() {unlockFile();} ~MeOSFileLock() {unlockFile();}
void unlockFile(); void unlockFile();
void lockFile(const string &file); void lockFile(const wstring &file);
}; };
namespace MeOSUtil { namespace MeOSUtil {
extern int useHourFormat; 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; 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) MeosSQL::MeosSQL(void)
{ {
monitorId=0; monitorId=0;
@ -120,6 +139,14 @@ string limitLength(const string &in, size_t max) {
return in.substr(0, 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) { bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
errorMessage.clear(); errorMessage.clear();
CmpDataBase=""; CmpDataBase="";
@ -168,6 +195,16 @@ bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
Query query = con.query(); Query query = con.query();
try{
mysqlpp::Query queryset = con.query();
queryset << "SET NAMES UTF8";
queryset.execute();
}
catch (const mysqlpp::Exception& ){
}
query.reset();
try{ try{
query << C_START("oEvent") query << C_START("oEvent")
<< C_STRING("Name", 128) << C_STRING("Name", 128)
@ -212,12 +249,12 @@ bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
if (int(row["Version"]) <= oe->dbVersion) { if (int(row["Version"]) <= oe->dbVersion) {
CompetitionInfo ci; CompetitionInfo ci;
ci.Name = row["Name"]; ci.Name = fromUTF((string)row["Name"]);
ci.Annotation = row["Annotation"]; ci.Annotation = fromUTF((string)row["Annotation"]);
ci.Id = row["Id"]; ci.Id = row["Id"];
ci.Date = row["Date"]; ci.Date = fromUTF((string)row["Date"]);
ci.FullPath = row["NameId"]; ci.FullPath = fromUTF((string)row["NameId"]);
ci.NameId = row["NameId"]; ci.NameId = fromUTF((string)row["NameId"]);
ci.Server = oe->MySQLServer; ci.Server = oe->MySQLServer;
ci.ServerPassword = oe->MySQLPassword; ci.ServerPassword = oe->MySQLPassword;
ci.ServerUser = oe->MySQLUser; ci.ServerUser = oe->MySQLUser;
@ -227,12 +264,12 @@ bool MeosSQL::listCompetitions(oEvent *oe, bool keepConnection) {
} }
else { else {
CompetitionInfo ci; CompetitionInfo ci;
ci.Name = row["Name"]; ci.Name = fromUTF(string(row["Name"]));
ci.Date = row["Date"]; ci.Date = fromUTF(string(row["Date"]));
ci.Annotation = row["Annotation"]; ci.Annotation = fromUTF(string(row["Annotation"]));
ci.Id=0; ci.Id=0;
ci.Server="bad"; ci.Server="bad";
ci.FullPath=row["NameId"]; ci.FullPath=fromUTF(string(row["NameId"]));
oe->cinfo.push_front(ci); oe->cinfo.push_front(ci);
} }
} }
@ -299,7 +336,7 @@ bool MeosSQL::createRunnerDB(oEvent *oe, Query &query)
query.reset(); query.reset();
query << C_START_noid("dbRunner") 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_INT("Club") << C_STRING("Nation", 3)
<< C_STRING("Sex", 1) << C_INT("BirthYear") << C_STRING("Sex", 1) << C_INT("BirthYear")
<< C_INT64("ExtId") << C_END_noindex(); << C_INT64("ExtId") << C_END_noindex();
@ -387,7 +424,7 @@ bool MeosSQL::openDB(oEvent *oe)
return 0; return 0;
} }
monitorId=0; monitorId=0;
string dbname=oe->CurrentNameId; string dbname(oe->currentNameId.begin(), oe->currentNameId.end());//WCS
try { try {
Query query = con.query(); Query query = con.query();
@ -646,6 +683,14 @@ bool MeosSQL::reConnect()
errorMessage=er.what(); errorMessage=er.what();
return false; return false;
} }
try{
mysqlpp::Query queryset = con.query();
queryset << "SET NAMES UTF8";
queryset.execute();
}
catch (const mysqlpp::Exception& ){
}
return true; return true;
} }
@ -663,8 +708,8 @@ OpFailStatus MeosSQL::SyncUpdate(oEvent *oe)
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", " queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", " << " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", " << " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", " << " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime) << " ZeroTime=" << unsigned(oe->ZeroTime)
<< " WHERE Id=" << oe->Id; << " WHERE Id=" << oe->Id;
@ -699,8 +744,8 @@ OpFailStatus MeosSQL::SyncUpdate(oEvent *oe)
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", " queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", " << " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", " << " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", " << " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime) << ", " << " ZeroTime=" << unsigned(oe->ZeroTime) << ", "
<< " BuildVersion=" << buildVersion << ", " << " BuildVersion=" << buildVersion << ", "
<< " Lists=" << quote << listEnc << " Lists=" << quote << listEnc
@ -794,13 +839,14 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
if (CmpDataBase.empty()) if (CmpDataBase.empty())
return opStatusFail; return opStatusFail;
int errorCount = 0; int errorCount = 0;
int totErrorCount = 0;
ProgressWindow pw(oe->hWnd()); ProgressWindow pw(oe->hWnd());
try { try {
const vector<oDBClubEntry> &cdb = oe->runnerDB->getClubDB(); const vector<oDBClubEntry> &cdb = oe->runnerDB->getClubDB(true);
size_t size = cdb.size(); 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) if (cdb.size() + rdb.size() > 2000)
pw.init(); pw.init();
@ -819,14 +865,16 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
mysqlpp::Query query = con.query(); mysqlpp::Query query = con.query();
string setId = "Id=" + itos(cdb[k].Id) + ", "; 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); << cdb[k].getDCI().generateSQLSet(true);
try { try {
query.execute(); query.execute();
errorCount = 0;
} }
catch (const mysqlpp::Exception& ex) { catch (const mysqlpp::Exception& ex) {
errorMessage = ex.what(); errorMessage = ex.what();
totErrorCount++;
if (++errorCount > 5) if (++errorCount > 5)
throw; throw;
} }
@ -839,6 +887,9 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
for (size_t k = 0; k<size; k++) { for (size_t k = 0; k<size; k++) {
if (rdb[k].isRemoved()) if (rdb[k].isRemoved())
continue; continue;
if (!rdb[k].isUTF()) {
rwdb[k].recode(rdb[k]);
}
mysqlpp::Query query = con.query(); mysqlpp::Query query = con.query();
query << "INSERT INTO dbRunner SET " << query << "INSERT INTO dbRunner SET " <<
@ -847,7 +898,17 @@ OpFailStatus MeosSQL::uploadRunnerDB(oEvent *oe)
", CardNo=" << rdb[k].cardNo << ", Sex=" << quote << rdb[k].getSex() << ", CardNo=" << rdb[k].cardNo << ", Sex=" << quote << rdb[k].getSex() <<
", Nation=" << quote << rdb[k].getNationality() << ", BirthYear=" << rdb[k].birthYear; ", 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) if (k%200 == 150)
pw.setProgress(s1 + (k*s2)/size); pw.setProgress(s1 + (k*s2)/size);
} }
@ -903,7 +964,8 @@ bool MeosSQL::storeData(oDataInterface odi, const Row &row, unsigned long &revis
odi.getVariableString(varstring); odi.getVariableString(varstring);
list<oVariableString>::iterator it_string; list<oVariableString>::iterator it_string;
for(it_string=varstring.begin(); it_string!=varstring.end(); 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; updated = true;
} }
} }
@ -949,11 +1011,11 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
Row row; Row row;
if (row=res.at(0)){ if (row=res.at(0)){
oe->Name = row["Name"]; oe->Name = fromUTF(string(row["Name"]));
oe->Annotation = row["Annotation"]; oe->Annotation = fromUTF(string(row["Annotation"]));
oe->Date = row["Date"]; oe->Date = fromUTF(string(row["Date"]));
oe->ZeroTime = row["ZeroTime"]; oe->ZeroTime = row["ZeroTime"];
strcpy_s(oe->CurrentNameId, row["NameId"].c_str()); oe->currentNameId = fromUTF(string(row["NameId"]));
} }
con.select_db(CmpDataBase); con.select_db(CmpDataBase);
@ -988,7 +1050,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
cnt = query.store("SELECT COUNT(*) FROM dbRunner WHERE Modified>'" + time + "'"); cnt = query.store("SELECT COUNT(*) FROM dbRunner WHERE Modified>'" + time + "'");
int modrunner = cnt.at(0).at(0); 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(); nRunnerDB == oe->runnerDB->getRunnerDB().size();
if (skipDB) { if (skipDB) {
@ -1024,11 +1086,11 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
Row row; Row row;
if (row=res.at(0)) { if (row=res.at(0)) {
oe->Name = row["Name"]; oe->Name = fromUTF(string(row["Name"]));
oe->Annotation = row["Annotation"]; oe->Annotation = fromUTF(string(row["Annotation"]));
oe->Date = row["Date"]; oe->Date = fromUTF(string(row["Date"]));
oe->ZeroTime = row["ZeroTime"]; oe->ZeroTime = row["ZeroTime"];
strcpy_s(oe->CurrentNameId, row["NameId"].c_str()); oe->currentNameId = fromUTF(string(row["NameId"]));
oe->sqlUpdated = row["Modified"]; oe->sqlUpdated = row["Modified"];
oe->counter = row["Counter"]; oe->counter = row["Counter"];
@ -1049,7 +1111,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
oDataInterface odi=oe->getDI(); oDataInterface odi=oe->getDI();
storeData(odi, row, oe->dataRevision); storeData(odi, row, oe->dataRevision);
oe->changed = false; 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); oe->getMeOSFeatures().deserialize(oe->getDCI().getString("Features"), *oe);
} }
} }
@ -1302,7 +1364,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
oClub t(oe, row["Id"]); oClub t(oe, row["Id"]);
string n = row["Name"]; string n = row["Name"];
t.internalSetName(n); t.internalSetName(fromUTF(n));
storeData(t.getDI(), row, oe->dataRevision); storeData(t.getDI(), row, oe->dataRevision);
oe->runnerDB->addClub(t, false); oe->runnerDB->addClub(t, false);
@ -1328,24 +1390,25 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
if (res) { if (res) {
Row row; Row row;
while (row = res.fetch_row()) { while (row = res.fetch_row()) {
string name = row["Name"]; string name = (string)row["Name"];
string ext = row["ExtId"]; string ext = row["ExtId"];
string club = row["Club"]; string club = row["Club"];
string card = row["CardNo"]; string card = row["CardNo"];
string sex = row["Sex"]; string sex = row["Sex"];
string nat = row["Nation"]; string nat = row["Nation"];
string birth = row["BirthYear"]; string birth = row["BirthYear"];
RunnerDBEntry *db = oe->runnerDB->addRunner(name.c_str(), _atoi64(ext.c_str()), RunnerWDBEntry *db = oe->runnerDB->addRunner(name.c_str(), _atoi64(ext.c_str()),
atoi(club.c_str()), atoi(card.c_str())); atoi(club.c_str()), atoi(card.c_str()));
if (db) { if (db) {
RunnerDBEntry &dbn = db->dbe();
if (sex.length()==1) if (sex.length()==1)
db->sex = sex[0]; dbn.sex = sex[0];
db->birthYear = short(atoi(birth.c_str())); dbn.birthYear = short(atoi(birth.c_str()));
if (nat.length()==3) { if (nat.length()==3) {
db->national[0] = nat[0]; dbn.national[0] = nat[0];
db->national[1] = nat[1]; dbn.national[1] = nat[1];
db->national[2] = nat[2]; dbn.national[2] = nat[2];
} }
} }
@ -1370,7 +1433,7 @@ OpFailStatus MeosSQL::SyncRead(oEvent *oe) {
void MeosSQL::storeClub(const Row &row, oClub &c) void MeosSQL::storeClub(const Row &row, oClub &c)
{ {
string n = row["Name"]; string n = row["Name"];
c.internalSetName(n); c.internalSetName(fromUTF(n));
c.sqlUpdated = row["Modified"]; c.sqlUpdated = row["Modified"];
c.counter = row["Counter"]; c.counter = row["Counter"];
@ -1385,8 +1448,8 @@ void MeosSQL::storeClub(const Row &row, oClub &c)
void MeosSQL::storeControl(const Row &row, oControl &c) void MeosSQL::storeControl(const Row &row, oControl &c)
{ {
c.Name = row["Name"]; c.Name = fromUTF((string)row["Name"]);
c.setNumbers(string(row["Numbers"])); c.setNumbers(fromUTF((string)row["Numbers"]));
oControl::ControlStatus oldStat = c.Status; oControl::ControlStatus oldStat = c.Status;
c.Status = oControl::ControlStatus(int(row["Status"])); c.Status = oControl::ControlStatus(int(row["Status"]));
@ -1430,7 +1493,7 @@ void MeosSQL::storePunch(const Row &row, oFreePunch &p, bool rehash)
if (rehash) { if (rehash) {
p.setCardNo(row["CardNo"], true); p.setCardNo(row["CardNo"], true);
p.setTimeInt(row["Time"], true); p.setTimeInt(row["Time"], true);
p.setType(string(row["Type"]), true); p.setType(fromUTF(string(row["Type"])), true);
} }
else { else {
p.CardNo = row["CardNo"]; p.CardNo = row["CardNo"];
@ -1452,7 +1515,7 @@ OpFailStatus MeosSQL::storeClass(const Row &row, oClass &c,
{ {
OpFailStatus success = opStatusOK; OpFailStatus success = opStatusOK;
c.Name=row["Name"]; c.Name=fromUTF(string(row["Name"]));
string multi = row["MultiCourse"]; string multi = row["MultiCourse"];
string lm(row["LegMethod"]); string lm(row["LegMethod"]);
@ -1499,7 +1562,7 @@ OpFailStatus MeosSQL::storeCourse(const Row &row, oCourse &c,
{ {
OpFailStatus success = opStatusOK; OpFailStatus success = opStatusOK;
c.Name = row["Name"]; c.Name = fromUTF((string)row["Name"]);
c.importControls(string(row["Controls"]), false); c.importControls(string(row["Controls"]), false);
c.Length = row["Length"]; c.Length = row["Length"];
c.importLegLengths(string(row["Legs"]), false); c.importLegLengths(string(row["Legs"]), false);
@ -1544,9 +1607,9 @@ OpFailStatus MeosSQL::storeRunner(const Row &row, oRunner &r,
r.markClassChanged(-1); r.markClassChanged(-1);
int oldSno = r.StartNo; 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); oRunner::getRealName(r.sName, r.tRealName);
r.setCardNo(row["CardNo"], false, true); r.setCardNo(row["CardNo"], false, true);
r.StartNo = row["StartNo"]; r.StartNo = row["StartNo"];
@ -1678,9 +1741,9 @@ OpFailStatus MeosSQL::storeTeam(const Row &row, oTeam &t,
t.Class->markSQLChanged(-1,-1); t.Class->markSQLChanged(-1,-1);
int oldSno = t.StartNo; 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.StartNo=row["StartNo"];
t.tStartTime = t.startTime = row["StartTime"]; t.tStartTime = t.startTime = row["StartTime"];
t.FinishTime=row["FinishTime"]; t.FinishTime=row["FinishTime"];
@ -1740,7 +1803,7 @@ OpFailStatus MeosSQL::storeTeam(const Row &row, oTeam &t,
success = min(success, syncRead(true, &or, readRecursive, readRecursive)); success = min(success, syncRead(true, &or, readRecursive, readRecursive));
if (or.sName.empty()) { if (or.sName.empty()) {
or.sName = "@AutoCorrection"; or.sName = L"@AutoCorrection";
oRunner::getRealName(or.sName, or.tRealName); oRunner::getRealName(or.sName, or.tRealName);
} }
pRns[k] = oe->addRunner(or, false); pRns[k] = oe->addRunner(or, false);
@ -1837,7 +1900,7 @@ OpFailStatus MeosSQL::syncUpdate(oRunner *r, bool forceWriteAll)
return opStatusFail; return opStatusFail;
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << r->sName << ", " queryset << " Name=" << quote << toString(r->sName) << ", "
<< " CardNo=" << r->CardNo << ", " << " CardNo=" << r->CardNo << ", "
<< " StartNo=" << r->StartNo << ", " << " StartNo=" << r->StartNo << ", "
<< " StartTime=" << r->startTime << ", " << " StartTime=" << r->startTime << ", "
@ -1854,10 +1917,10 @@ OpFailStatus MeosSQL::syncUpdate(oRunner *r, bool forceWriteAll)
<< " MultiR=" << quote << r->codeMultiR() << " MultiR=" << quote << r->codeMultiR()
<< r->getDI().generateSQLSet(forceWriteAll); << 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()); OutputDebugString(str.c_str());
*/
return syncUpdate(queryset, "oRunner", r); return syncUpdate(queryset, "oRunner", r);
} }
@ -2034,7 +2097,7 @@ OpFailStatus MeosSQL::syncUpdate(oTeam *t, bool forceWriteAll) {
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << t->sName << ", " queryset << " Name=" << quote << toString(t->sName) << ", "
<< " Runners=" << quote << t->getRunners() << ", " << " Runners=" << quote << t->getRunners() << ", "
<< " StartTime=" << t->startTime << ", " << " StartTime=" << t->startTime << ", "
<< " FinishTime=" << t->FinishTime << ", " << " FinishTime=" << t->FinishTime << ", "
@ -2044,8 +2107,8 @@ OpFailStatus MeosSQL::syncUpdate(oTeam *t, bool forceWriteAll) {
<< " Status=" << t->status << " Status=" << t->status
<< t->getDI().generateSQLSet(forceWriteAll); << t->getDI().generateSQLSet(forceWriteAll);
string str = "write team " + t->sName + "\n"; //wstring str = L"write team " + t->sName + L"\n";
OutputDebugString(str.c_str()); //OutputDebugString(str.c_str());
return syncUpdate(queryset, "oTeam", t); return syncUpdate(queryset, "oTeam", t);
} }
@ -2130,7 +2193,7 @@ OpFailStatus MeosSQL::syncUpdate(oClass *c, bool forceWriteAll)
return opStatusFail; return opStatusFail;
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->Name << "," queryset << " Name=" << quote << toString(c->Name) << ","
<< " Course=" << c->getCourseId() << "," << " Course=" << c->getCourseId() << ","
<< " MultiCourse=" << quote << c->codeMultiCourse() << "," << " MultiCourse=" << quote << c->codeMultiCourse() << ","
<< " LegMethod=" << quote << c->codeLegMethod() << " LegMethod=" << quote << c->codeLegMethod()
@ -2327,7 +2390,7 @@ OpFailStatus MeosSQL::syncUpdate(oClub *c, bool forceWriteAll)
if (!c || !con.connected()) if (!c || !con.connected())
return opStatusFail; return opStatusFail;
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->name queryset << " Name=" << quote << toString(c->name)
<< c->getDI().generateSQLSet(forceWriteAll); << c->getDI().generateSQLSet(forceWriteAll);
return syncUpdate(queryset, "oClub", c); return syncUpdate(queryset, "oClub", c);
@ -2394,8 +2457,8 @@ OpFailStatus MeosSQL::syncUpdate(oControl *c, bool forceWriteAll) {
return opStatusFail; return opStatusFail;
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->Name << ", " queryset << " Name=" << quote << toString(c->Name) << ", "
<< " Numbers=" << quote << c->codeNumbers() << "," << " Numbers=" << quote << toString(c->codeNumbers()) << ","
<< " Status=" << c->Status << " Status=" << c->Status
<< c->getDI().generateSQLSet(forceWriteAll); << c->getDI().generateSQLSet(forceWriteAll);
@ -2462,7 +2525,7 @@ OpFailStatus MeosSQL::syncUpdate(oCourse *c, bool forceWriteAll)
if (!c || !con.connected()) if (!c || !con.connected())
return opStatusFail; return opStatusFail;
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << c->Name << ", " queryset << " Name=" << quote << toString(c->Name) << ", "
<< " Length=" << unsigned(c->Length) << ", " << " Length=" << unsigned(c->Length) << ", "
<< " Controls=" << quote << c->getControls() << ", " << " Controls=" << quote << c->getControls() << ", "
<< " Legs=" << quote << c->getLegLengths() << " Legs=" << quote << c->getLegLengths()
@ -2681,7 +2744,7 @@ OpFailStatus MeosSQL::syncUpdate(mysqlpp::Query &updateqry,
{ {
nUpdate++; nUpdate++;
if (nUpdate % 100 == 99) if (nUpdate % 100 == 99)
OutputDebugString((itos(nUpdate) +" updates\n").c_str()); OutputDebugStringA((itos(nUpdate) +" updates\n").c_str());
assert(ob->getEvent()); assert(ob->getEvent());
if (!ob->getEvent()) if (!ob->getEvent())
@ -2810,9 +2873,9 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
oldVersion=true; oldVersion=true;
*/ */
if (isOld(counter, Modified, oe)) { if (isOld(counter, Modified, oe)) {
oe->Name=row["Name"]; oe->Name=fromUTF(string(row["Name"]));
oe->Annotation = row["Annotation"]; oe->Annotation = fromUTF(string(row["Annotation"]));
oe->Date=row["Date"]; oe->Date=fromUTF(string(row["Date"]));
oe->ZeroTime=row["ZeroTime"]; oe->ZeroTime=row["ZeroTime"];
oe->sqlUpdated=Modified; oe->sqlUpdated=Modified;
const string &lRaw = row.raw_string(res.field_num("Lists")); const string &lRaw = row.raw_string(res.field_num("Lists"));
@ -2825,7 +2888,7 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
oe->counter = counter; oe->counter = counter;
oDataInterface odi=oe->getDI(); oDataInterface odi=oe->getDI();
storeData(odi, row, oe->dataRevision); 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->getMeOSFeatures().deserialize(oe->getDCI().getString("Features"), *oe);
oe->changed=false; oe->changed=false;
oe->changedObject(); oe->changedObject();
@ -2844,8 +2907,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", " queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", " << " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", " << " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", " << " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime) << ", " << " ZeroTime=" << unsigned(oe->ZeroTime) << ", "
<< " BuildVersion=if (BuildVersion<" << << " BuildVersion=if (BuildVersion<" <<
buildVersion << "," << buildVersion << ",BuildVersion), " buildVersion << "," << buildVersion << ",BuildVersion), "
@ -2859,8 +2922,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
queryset.reset(); queryset.reset();
queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", " queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", " << " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", " << " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", " << " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime) << " ZeroTime=" << unsigned(oe->ZeroTime)
<< " WHERE Id=" << oe->Id; << " WHERE Id=" << oe->Id;
@ -2876,8 +2939,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
mysqlpp::Query queryset = con.query(); mysqlpp::Query queryset = con.query();
queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", " queryset << " Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", " << " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << "," << " Date=" << quote << toString(oe->Date) << ","
<< " NameId=" << quote << oe->CurrentNameId << "," << " NameId=" << quote << toString(oe->currentNameId) << ","
<< " ZeroTime=" << unsigned(oe->ZeroTime) << "," << " ZeroTime=" << unsigned(oe->ZeroTime) << ","
<< " BuildVersion=if (BuildVersion<" << << " BuildVersion=if (BuildVersion<" <<
buildVersion << "," << buildVersion << ",BuildVersion)," buildVersion << "," << buildVersion << ",BuildVersion),"
@ -2891,8 +2954,8 @@ OpFailStatus MeosSQL::SyncEvent(oEvent *oe) {
queryset.reset(); queryset.reset();
queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", " queryset << "UPDATE oEvent SET Name=" << quote << limitLength(oe->Name, 128) << ", "
<< " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", " << " Annotation=" << quote << limitLength(oe->Annotation, 128) << ", "
<< " Date=" << quote << oe->Date << ", " << " Date=" << quote << toString(oe->Date) << ", "
<< " NameId=" << quote << oe->CurrentNameId << ", " << " NameId=" << quote << toString(oe->currentNameId) << ", "
<< " ZeroTime=" << unsigned(oe->ZeroTime) << " ZeroTime=" << unsigned(oe->ZeroTime)
<< " WHERE Id=" << oe->Id; << " WHERE Id=" << oe->Id;
@ -3424,7 +3487,7 @@ bool MeosSQL::checkConnection(oEvent *oe)
if (monitorId==0) { if (monitorId==0) {
try { try {
Query query = con.query(); 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(); ResNSel res=query.execute();
if (res) if (res)
monitorId=static_cast<int>(res.insert_id); monitorId=static_cast<int>(res.insert_id);
@ -3437,7 +3500,7 @@ bool MeosSQL::checkConnection(oEvent *oe)
else { else {
try { try {
Query query = con.query(); 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; << " WHERE Id = " << monitorId;
query.execute(); query.execute();
} }
@ -3543,14 +3606,14 @@ bool MeosSQL::dropDatabase(oEvent *oe)
} }
void MeosSQL::importLists(oEvent *oe, const char *bf) { void MeosSQL::importLists(oEvent *oe, const char *bf) {
xmlparser xml(0); xmlparser xml;
xml.readMemory(bf, 0); xml.readMemory(bf, 0);
oe->listContainer->clearExternal(); oe->listContainer->clearExternal();
oe->listContainer->load(MetaListContainer::ExternalList, xml.getObject("Lists"), false); oe->listContainer->load(MetaListContainer::ExternalList, xml.getObject("Lists"), false);
} }
void MeosSQL::encodeLists(const oEvent *oe, string &listEnc) const { void MeosSQL::encodeLists(const oEvent *oe, string &listEnc) const {
xmlparser parser(0); xmlparser parser;
parser.openMemoryOutput(true); parser.openMemoryOutput(true);
parser.startTag("Lists"); parser.startTag("Lists");
oe->listContainer->save(MetaListContainer::ExternalList, parser, oe); oe->listContainer->save(MetaListContainer::ExternalList, parser, oe);
@ -3600,7 +3663,7 @@ void MeosSQL::synchronized(const oBase &entity) {
readTimes[make_pair(id, entity.getId())] = GetTickCount(); readTimes[make_pair(id, entity.getId())] = GetTickCount();
readent++; readent++;
if (readent % 100 == 99) if (readent % 100 == 99)
OutputDebugString("Read 100 entities\n"); OutputDebugStringA("Read 100 entities\n");
} }
bool MeosSQL::skipSynchronize(const oBase &entity) const { bool MeosSQL::skipSynchronize(const oBase &entity) const {

View File

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

View File

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

View File

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

View File

@ -21,11 +21,28 @@
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/ ************************************************************************/
#include "meos_util.h"
class meosException : public std::exception { 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: public:
meosException(const string &msg) : std::exception(msg.c_str()) {} meosException(const wstring &wmsg) : std::exception(narrow(wmsg)), wideMessage(wmsg) {
meosException(const char *msg) : std::exception(msg) {}
}
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() {} meosException() : std::exception() {}
wstring wwhat() const{
return wideMessage;
}
}; };

View File

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

View File

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

View File

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

View File

@ -33,6 +33,7 @@ enum gdiFonts;
class oEvent; class oEvent;
const string &itos(int); const string &itos(int);
const wstring &itow(int i);
class Position class Position
{ {
@ -79,8 +80,8 @@ private:
void deserialize(const xmlobject &xml); void deserialize(const xmlobject &xml);
EPostType type; EPostType type;
string text; wstring text;
string alignWithText; wstring alignWithText;
string resultModule; string resultModule;
EPostType alignType; EPostType alignType;
int leg; int leg;
@ -96,24 +97,24 @@ public:
MetaListPost(EPostType type_, EPostType align_ = lNone, int leg_ = -1); MetaListPost(EPostType type_, EPostType align_ = lNone, int leg_ = -1);
MetaListPost &setBlock(int width) {blockWidth = width; return *this;} 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 &setResultModule(const string &resMod) {resultModule = resMod; return *this;}
MetaListPost &align(EPostType align_, bool alignBlock_ = true) {alignType = align_; alignBlock = alignBlock_; 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 &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 &mergePrevious(bool m_=true) {mergeWithPrevious = m_; return *this;}
MetaListPost &indent(int ind) {minimalIndent = ind; 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;} 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 &getResultModule() const {return resultModule;}
const string &getAlignText() const {return alignWithText;} const wstring &getAlignText() const {return alignWithText;}
int getLeg() const {return leg;} int getLeg() const {return leg;}
void setLeg(int leg_) {leg = leg_;} void setLeg(int leg_) {leg = leg_;}
@ -127,7 +128,7 @@ public:
const string &getFont() const; const string &getFont() const;
void setFont(gdiFonts font_) {font = font_;} 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; const string &getTextAdjust() const;
int getTextAdjustNum() const {return textAdjust;} int getTextAdjustNum() const {return textAdjust;}
@ -136,7 +137,7 @@ public:
void setColor(GDICOLOR color); void setColor(GDICOLOR color);
GDICOLOR getColorValue() const {return 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; friend class MetaList;
}; };
@ -152,17 +153,17 @@ class MetaList {
private: private:
struct FontInfo { struct FontInfo {
string font; wstring font;
int scale; int scale;
int extraSpaceAbove; int extraSpaceAbove;
FontInfo() : scale(0), extraSpaceAbove(0) {} 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].first = "scale";
props[0].second = itos(scale); props[0].second = itow(scale);
props[1].first = "above"; props[1].first = "above";
props[1].second = itos(extraSpaceAbove); props[1].second = itow(extraSpaceAbove);
return props; return props;
} }
}; };
@ -170,8 +171,8 @@ private:
vector< vector< vector<MetaListPost> > > data; vector< vector< vector<MetaListPost> > > data;
vector<FontInfo> fontFaces; vector<FontInfo> fontFaces;
string listName; wstring listName;
mutable string listOrigin; mutable wstring listOrigin;
string tag; string tag;
mutable string uniqueIndex; mutable string uniqueIndex;
@ -192,11 +193,11 @@ private:
enum ListIndex {MLHead = 0, MLSubHead = 1, MLList = 2, MLSubList=3}; enum ListIndex {MLHead = 0, MLSubHead = 1, MLList = 2, MLSubList=3};
MetaListPost &add(ListIndex ix, const MetaListPost &post); MetaListPost &add(ListIndex ix, const MetaListPost &post);
void addRow(int ix); void addRow(int ix);
string encode(const string &input) const; wstring encode(const wstring &input) const;
bool isBreak(int x) const; bool isBreak(int x) const;
static map<EPostType, string> typeToSymbol; static map<EPostType, wstring> typeToSymbol;
static map<string, EPostType> symbolToType; static map<wstring, EPostType> symbolToType;
static map<oListInfo::EBaseType, string> baseTypeToSymbol; static map<oListInfo::EBaseType, string> baseTypeToSymbol;
static map<string, oListInfo::EBaseType> symbolToBaseType; static map<string, oListInfo::EBaseType> symbolToBaseType;
@ -228,7 +229,7 @@ public:
bool supportClasses() const; bool supportClasses() const;
const string &getListInfo(const oEvent &oe) const; const wstring &getListInfo(const oEvent &oe) const;
void clearTag() {tag.clear();} void clearTag() {tag.clear();}
void initUniqueIndex() const; void initUniqueIndex() const;
@ -242,26 +243,26 @@ public:
bool updateResultModule(const DynamicResult &dr, bool updateSimilar); bool updateResultModule(const DynamicResult &dr, bool updateSimilar);
void getDynamicResults(vector<DynamicResultRef> &resultModules) const; 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 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 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;} const string &getResultModule() const {return resultModule;}
MetaList &setSupportFromTo(bool from, bool to); MetaList &setSupportFromTo(bool from, bool to);
bool supportFrom() const {return supportFromControl;} bool supportFrom() const {return supportFromControl;}
bool supportTo() const {return supportToControl;} bool supportTo() const {return supportToControl;}
void getSortOrder(bool forceIncludeCustom, vector< pair<string, size_t> > &orders, int &currentOrder) const; void getSortOrder(bool forceIncludeCustom, vector< pair<wstring, size_t> > &orders, int &currentOrder) const;
void getBaseType(vector< pair<string, size_t> > &types, int &currentType) const; void getBaseType(vector< pair<wstring, size_t> > &types, int &currentType) const;
void getSubType(vector< pair<string, 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 getFontFaceFactor(int type) const {return fontFaces[type].scale;}
int getExtraSpace(int type) const {return fontFaces[type].extraSpaceAbove;} 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].font = face;
fontFaces[type].scale = factor; fontFaces[type].scale = factor;
return *this; return *this;
@ -274,7 +275,7 @@ public:
void getExistingTypes(vector< pair<string, size_t> > &types) const; 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::EBaseType getListType() const;
oListInfo::ResultType getResultType() const; // Classwise or global oListInfo::ResultType getResultType() const; // Classwise or global
@ -282,7 +283,7 @@ public:
bool hasResults() const {return hasResults_;} bool hasResults() const {return hasResults_;}
const string &getTag() const {return tag;} 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; void getIndex(const MetaListPost &mlp, int &gix, int &lix, int &ix) const;
MetaList &setResultModule(const oEvent &oe, int moduleIx); MetaList &setResultModule(const oEvent &oe, int moduleIx);
@ -294,8 +295,8 @@ public:
MetaList &addFilter(EFilterList f) {filter.insert(f); return *this;} MetaList &addFilter(EFilterList f) {filter.insert(f); return *this;}
MetaList &addSubFilter(ESubFilterList f) {subFilter.insert(f); return *this;} MetaList &addSubFilter(ESubFilterList f) {subFilter.insert(f); return *this;}
void save(const string &file, const oEvent *oe) const; void save(const wstring &file, const oEvent *oe) const;
void load(const string &file); void load(const wstring &file);
bool isValidIx(size_t gIx, size_t lIx, size_t ix) const; 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, void interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par,
int lineHeight, oListInfo &li) const; 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 &addNew(int groupIx, int lineIx, int &ix);
MetaListPost &getMLP(int groupIx, int lineIx, int ix); MetaListPost &getMLP(int groupIx, int lineIx, int ix);
@ -353,7 +354,7 @@ public:
string getUniqueId(EStdListType code) const; string getUniqueId(EStdListType code) const;
EStdListType getCodeFromUnqiueId(const string &id) 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); bool updateResultModule(const DynamicResult &res, bool updateSimilar);
@ -375,7 +376,7 @@ public:
MetaList &addExternal(const MetaList &ml); MetaList &addExternal(const MetaList &ml);
void clearExternal(); void clearExternal();
void getLists(vector< pair<string, size_t> > &lists, void getLists(vector< pair<wstring, size_t> > &lists,
bool markBuiltIn, bool markBuiltIn,
bool resultListOnly, bool resultListOnly,
bool noTeamList) const; bool noTeamList) const;
@ -395,17 +396,17 @@ public:
void setupListInfo(int firstIndex, map<EStdListType, oListInfo> &listMap, bool resultsOnly) const; void setupListInfo(int firstIndex, map<EStdListType, oListInfo> &listMap, bool resultsOnly) const;
void setupIndex(int firstIndex) 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 removeParam(int index);
void addListParam(oListParam &listParam); void addListParam(oListParam &listParam);
void mergeParam(int toInsertAfter, int toMerge, bool showTitleBetween); 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; bool canSplit(int index) const;
void split(int index); void split(int index);
bool interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par, bool interpret(oEvent *oe, const gdioutput &gdi, const oListParam &par,
int lineHeight, oListInfo &li) const; 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() { 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; delete currentResult;
currentResult = lst; currentResult = lst;
fileNameSource = fileSrc; fileNameSource = fileSrc;
@ -74,7 +74,7 @@ void MethodEditor::show(gdioutput &gdi) {
gdi.pushX(); gdi.pushX();
gdi.setCX(gdi.getCX() + gdi.scaleLength(6)); gdi.setCX(gdi.getCX() + gdi.scaleLength(6));
if (currentResult) if (currentResult)
gdi.addString("", boldLarge, MakeDash("Result Module - X#") + currentResult->getName(true)); gdi.addString("", boldLarge, makeDash(L"Result Module - X#") + currentResult->getName(true));
else else
gdi.addString("", boldLarge, "Edit Result Modules"); gdi.addString("", boldLarge, "Edit Result Modules");
@ -109,32 +109,32 @@ void MethodEditor::show(gdioutput &gdi) {
if (currentResult->getTag().empty()) if (currentResult->getTag().empty())
currentResult->setTag(uniqueTag("result")); 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(); string tag = currentResult->getTag();
vector<int> listIx; vector<int> listIx;
oe->getListContainer().getListsByResultModule(tag, listIx); oe->getListContainer().getListsByResultModule(tag, listIx);
string udtag = DynamicResult::undecorateTag(tag); 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()) { if (!listIx.empty()) {
gdi.disableInput("Tag"); gdi.disableInput("Tag");
gdi.getBaseInfo("Tag").setExtra(1); 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) if (listIx.size() > 1)
lists += ", ..."; lists += L", ...";
gdi.addString("", 0, "Resultatmodulen används i X.#" + lists); gdi.addString("", 0, L"Resultatmodulen används i X.#" + lists);
} }
string desc = currentResult->getDescription(); wstring desc = currentResult->getDescription();
if (wasLoadedBuiltIn) if (wasLoadedBuiltIn)
desc = lang.tl(desc); desc = lang.tl(desc);
gdi.addInputBox("Desc", 300, 70, desc, methodCB, "Description:"); gdi.addInputBox("Desc", 300, 70, desc, methodCB, L"Description:");
gdi.dropLine(); gdi.dropLine();
gdi.fillRight(); 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; vector< pair<DynamicResult::DynamicMethods, string> > mt;
currentResult->getMethodTypes(mt); currentResult->getMethodTypes(mt);
@ -158,7 +158,7 @@ void MethodEditor::show(gdioutput &gdi) {
} }
bool MethodEditor::checkTag(const string &tag, bool throwError) const { 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); oe->getGeneralResults(false, tagNameList, false);
for (size_t k = 0; k < tag.length(); k++) { for (size_t k = 0; k < tag.length(); k++) {
char c = tag[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 { 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); oe->getGeneralResults(false, tagNameList, false);
set<string> tags; set<string> tags;
for (size_t k = 0; k < tagNameList.size(); k++) 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"); ofstream fout("methoddoc.txt");
DynamicResult dr; DynamicResult dr;
dr.declareSymbols(DynamicResult::MRScore, true); dr.declareSymbols(DynamicResult::MRScore, true);
vector< pair<string, size_t> > symbs; vector< pair<wstring, size_t> > symbs;
dr.getSymbols(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++) { for (size_t k = 0; k < symbs.size(); k++) {
string name, desc; wstring name, desc;
dr.getSymbolInfo(symbs[k].second, 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.declareSymbols(DynamicResult::MTScore, true);
dr.getSymbols(symbs); 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++) { for (size_t k = 0; k < symbs.size(); k++) {
string name, desc; wstring name, desc;
dr.getSymbolInfo(symbs[k].second, 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") { else if (bi.id == "NewRules") {
@ -245,7 +245,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.setData("MethodEditorClz", this); gdi.setData("MethodEditorClz", this);
gdi.addString("", boldLarge, "New Set of Result Rules"); gdi.addString("", boldLarge, "New Set of Result Rules");
setCurrentResult(new DynamicResult(), ""); setCurrentResult(new DynamicResult(), L"");
wasLoadedBuiltIn = false; wasLoadedBuiltIn = false;
currentResult->setName(lang.tl("Result Calculation")); currentResult->setName(lang.tl("Result Calculation"));
currentIndex = -1; currentIndex = -1;
@ -258,17 +258,17 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
return 0; return 0;
checkChangedSave(gdi); checkChangedSave(gdi);
string fileName; wstring fileName;
int ix = 0; int ix = 0;
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("xml-data", "*.rules")); ext.push_back(make_pair(L"xml-data", L"*.rules"));
fileName = gdi.browseForSave(ext, "rules", ix); fileName = gdi.browseForSave(ext, L"rules", ix);
if (fileName.empty()) if (fileName.empty())
return 0; return 0;
saveSettings(gdi); saveSettings(gdi);
string path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource; wstring path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
currentResult->save(path); currentResult->save(path);
fileNameSource = path; fileNameSource = path;
oe->loadGeneralResults(true); oe->loadGeneralResults(true);
@ -284,7 +284,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
saveSettings(gdi); saveSettings(gdi);
checkChangedSave(gdi); checkChangedSave(gdi);
string path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource; wstring path = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
currentResult->save(path); currentResult->save(path);
fileNameSource = path; fileNameSource = path;
@ -300,7 +300,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
continue; continue;
if (utag == DynamicResult::undecorateTag(mtag)) { 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; break;
} }
} }
@ -319,14 +319,14 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
else if (bi.id == "Remove") { else if (bi.id == "Remove") {
if (!currentResult) if (!currentResult)
return 0; return 0;
if (gdi.ask("Vill du ta bort 'X'?#" + currentResult->getName(true))) { if (gdi.ask(L"Vill du ta bort 'X'?#" + currentResult->getName(true))) {
string path = fileNameSource;//getInternalPath(currentResult->getTag()); wstring path = fileNameSource;//getInternalPath(currentResult->getTag());
string rm = path + ".removed"; wstring rm = path + L".removed";
DeleteFile(rm.c_str()); DeleteFile(rm.c_str());
rename(path.c_str(), rm.c_str()); _wrename(path.c_str(), rm.c_str());
oe->loadGeneralResults(true); oe->loadGeneralResults(true);
makeDirty(gdi, ClearDirty); makeDirty(gdi, ClearDirty);
setCurrentResult(0, ""); setCurrentResult(0, L"");
gdi.clearPage(false); gdi.clearPage(false);
show(gdi); show(gdi);
} }
@ -336,9 +336,9 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
if (!checkSave(gdi)) if (!checkSave(gdi))
return 0; return 0;
vector< pair<string, string> > ext; vector< pair<wstring, wstring> > ext;
ext.push_back(make_pair("xml-data", "*.rules")); ext.push_back(make_pair(L"xml-data", L"*.rules"));
string fileName = gdi.browseForOpen(ext, "rules"); wstring fileName = gdi.browseForOpen(ext, L"rules");
if (fileName.empty()) if (fileName.empty())
return 0; return 0;
@ -352,7 +352,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
} }
wasLoadedBuiltIn = false; wasLoadedBuiltIn = false;
setCurrentResult(tmp, ""); setCurrentResult(tmp, L"");
currentIndex = -1; currentIndex = -1;
gdi.clearPage(false); gdi.clearPage(false);
@ -369,26 +369,26 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.setData("MethodEditorClz", this); gdi.setData("MethodEditorClz", this);
gdi.pushX(); gdi.pushX();
vector< pair<string, size_t> > lists; vector< pair<wstring, size_t> > lists;
//oe->getListContainer().getLists(lists); //oe->getListContainer().getLists(lists);
vector< pair<int, pair<string, string> > > tagNameList; vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(true, tagNameList, true); oe->getGeneralResults(true, tagNameList, true);
for (size_t k = 0; k < tagNameList.size(); k++) { for (size_t k = 0; k < tagNameList.size(); k++) {
string tag = tagNameList[k].second.first; string tag = tagNameList[k].second.first;
string utag = DynamicResult::undecorateTag(tag); string utag = DynamicResult::undecorateTag(tag);
vector<int> listIx; vector<int> listIx;
oe->getListContainer().getListsByResultModule(tag, 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) { if (listIx.size() > 0) {
n += " *"; n += L" *";
} }
lists.push_back(make_pair(n, tagNameList[k].first)); lists.push_back(make_pair(n, tagNameList[k].first));
} }
sort(lists.begin(), lists.end()); sort(lists.begin(), lists.end());
gdi.fillRight(); 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.addItem("OpenList", lists);
gdi.autoGrow("OpenList"); gdi.autoGrow("OpenList");
gdi.selectFirstItem("OpenList"); gdi.selectFirstItem("OpenList");
@ -398,7 +398,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.addButton("DoOpenCopy", "Open a Copy", methodCB); gdi.addButton("DoOpenCopy", "Open a Copy", methodCB);
if (!lists.empty()) { if (!lists.empty()) {
string srcFile; wstring srcFile;
bool ro = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList.front().second.first, srcFile)).isReadOnly(); bool ro = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList.front().second.first, srcFile)).isReadOnly();
gdi.setInputStatus("DoOpen", !ro); gdi.setInputStatus("DoOpen", !ro);
@ -416,7 +416,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
ListBoxInfo lbi; ListBoxInfo lbi;
DynamicResult *dr = 0; DynamicResult *dr = 0;
if (gdi.getSelectedItem("OpenList", lbi)) { if (gdi.getSelectedItem("OpenList", lbi)) {
vector< pair<int, pair<string, string> > > tagNameList; vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(true, tagNameList, false); oe->getGeneralResults(true, tagNameList, false);
size_t ix = -1; size_t ix = -1;
for (size_t k = 0; k < tagNameList.size(); k++) { 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()) { if (ix < tagNameList.size()) {
string srcFile; wstring srcFile;
DynamicResult &drIn = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList[ix].second.first, srcFile)); DynamicResult &drIn = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList[ix].second.first, srcFile));
wasLoadedBuiltIn = drIn.isReadOnly(); wasLoadedBuiltIn = drIn.isReadOnly();
dr = new DynamicResult(drIn); dr = new DynamicResult(drIn);
if (bi.id == "DoOpenCopy") { if (bi.id == "DoOpenCopy") {
dr->setTag(uniqueTag("result")); dr->setTag(uniqueTag("result"));
dr->setName(lang.tl("Copy of ") + dr->getName(false)); dr->setName(lang.tl("Copy of ") + dr->getName(false));
setCurrentResult(dr, ""); setCurrentResult(dr, L"");
} }
else else
setCurrentResult(dr, srcFile); setCurrentResult(dr, srcFile);
@ -458,7 +458,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
if (!checkSave(gdi)) if (!checkSave(gdi))
return 0; return 0;
setCurrentResult(0, ""); setCurrentResult(0, L"");
makeDirty(gdi, ClearDirty); makeDirty(gdi, ClearDirty);
currentIndex = -1; currentIndex = -1;
gdi.getTabs().get(TListTab)->loadPage(gdi); gdi.getTabs().get(TListTab)->loadPage(gdi);
@ -466,9 +466,9 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
} }
else if (bi.id == "SaveSource") { else if (bi.id == "SaveSource") {
DynamicResult::DynamicMethods dm = DynamicResult::DynamicMethods(bi.getExtraInt()); DynamicResult::DynamicMethods dm = DynamicResult::DynamicMethods(bi.getExtraInt());
string src = gdi.getText("Source"); string src = gdi.narrow(gdi.getText("Source"));
currentResult->setMethodSource(dm, src); currentResult->setMethodSource(dm, src);
gdi.setText("Source", src); gdi.setText("Source", gdi.widen(src));
} }
else if (bi.id == "CancelSource") { else if (bi.id == "CancelSource") {
checkChangedSave(gdi); checkChangedSave(gdi);
@ -520,7 +520,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
int yp = gdi.getCY(); int yp = gdi.getCY();
int diff = gdi.scaleLength(3); int diff = gdi.scaleLength(3);
const int w[5] = {200, 70, 70, 70, 85}; const int w[5] = {200, 70, 70, 70, 85};
set<string> errors; set<wstring> errors;
currentResult->prepareCalculations(*oe, tr.size()>0, inputNumber); currentResult->prepareCalculations(*oe, tr.size()>0, inputNumber);
for (size_t k = 0; k < rr.size(); k++) { 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; int rt = 0, pt = 0;
RunnerStatus st = StatusUnknown; RunnerStatus st = StatusUnknown;
{ {
string err; wstring err;
string str; wstring str;
try { try {
st = currentResult->deduceStatus(*rr[k]); st = currentResult->deduceStatus(*rr[k]);
str = oe->formatStatus(st); str = oe->formatStatus(st);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -552,16 +552,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
txp += w[wi++]; txp += w[wi++];
} }
{ {
string err; wstring err;
string str; wstring str;
try { try {
rt = currentResult->deduceTime(*rr[k], rr[k]->getStartTime()); rt = currentResult->deduceTime(*rr[k], rr[k]->getStartTime());
str = formatTime(rt); str = formatTimeW(rt);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -572,16 +572,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
} }
{ {
string err; wstring err;
string str; wstring str;
try { try {
pt = currentResult->deducePoints(*rr[k]); pt = currentResult->deducePoints(*rr[k]);
str = itos(pt); str = itow(pt);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -592,16 +592,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
} }
{ {
string err; wstring err;
string str; wstring str;
try { try {
int score = currentResult->score(*rr[k], st, rt, pt, false); int score = currentResult->score(*rr[k], st, rt, pt, false);
str = itos(score); str = itow(score);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -634,16 +634,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
int rt = 0, pt = 0; int rt = 0, pt = 0;
RunnerStatus st = StatusUnknown; RunnerStatus st = StatusUnknown;
{ {
string err; wstring err;
string str; wstring str;
try { try {
st = currentResult->deduceStatus(*tr[k]); st = currentResult->deduceStatus(*tr[k]);
str = oe->formatStatus(st); str = oe->formatStatus(st);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -653,16 +653,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
txp += w[wi++]; txp += w[wi++];
} }
{ {
string err; wstring err;
string str; wstring str;
try { try {
rt = currentResult->deduceTime(*tr[k]); rt = currentResult->deduceTime(*tr[k]);
str = formatTime(rt); str = formatTimeW(rt);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -673,16 +673,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
} }
{ {
string err; wstring err;
string str; wstring str;
try { try {
pt = currentResult->deducePoints(*tr[k]); pt = currentResult->deducePoints(*tr[k]);
str = itos(pt); str = itow(pt);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -693,16 +693,16 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
} }
{ {
string err; wstring err;
string str; wstring str;
try { try {
int score = currentResult->score(*tr[k], st, rt, pt); int score = currentResult->score(*tr[k], st, rt, pt);
str = itos(score); str = itow(score);
} }
catch (meosException &ex) { catch (meosException &ex) {
err = ex.what(); err = ex.wwhat();
errors.insert(ex.what()); errors.insert(ex.wwhat());
str = "Error"; str = L"Error";
} }
TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff); TextInfo &ti = gdi.addStringUT(yp, txp, 0, str, w[wi]-diff);
if (!err.empty()) { if (!err.empty()) {
@ -738,11 +738,11 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.pushX(); gdi.pushX();
gdi.setRestorePoint("NoSourceEdit"); gdi.setRestorePoint("NoSourceEdit");
gdi.addInputBox("Source", 450, 300, gdi.addInputBox("Source", 450, 300,
src, gdi.widen(src),
methodCB, "Source code:").setFont(gdi, monoText); methodCB, L"Source code:").setFont(gdi, monoText);
gdi.fillDown(); gdi.fillDown();
gdi.setCX(gdi.getCX() + gdi.getLineHeight()); 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.setTabStops("Symbols", 180);
gdi.addString("SymbInfo", gdi.getCY(), gdi.getCX(), 0, "", 350, 0); gdi.addString("SymbInfo", gdi.getCY(), gdi.getCX(), 0, "", 350, 0);
gdi.popX(); gdi.popX();
@ -751,21 +751,21 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
gdi.scrollToBottom(); gdi.scrollToBottom();
} }
else { else {
gdi.setText("Source", src); gdi.setText("Source", gdi.widen(src));
} }
currentResult->declareSymbols(m, true); currentResult->declareSymbols(m, true);
vector< pair<string, size_t> > symb; vector< pair<wstring, size_t> > symb;
currentResult->getSymbols(symb); currentResult->getSymbols(symb);
gdi.addItem("Symbols", symb); gdi.addItem("Symbols", symb);
} }
else if (lbi.id == "Symbols") { else if (lbi.id == "Symbols") {
string name, desc; wstring name, desc;
currentResult->getSymbolInfo(lbi.data, 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") { else if (lbi.id == "OpenList") {
vector< pair<int, pair<string, string> > > tagNameList; vector< pair<int, pair<string, wstring> > > tagNameList;
oe->getGeneralResults(true, tagNameList, false); oe->getGeneralResults(true, tagNameList, false);
size_t ix = -1; size_t ix = -1;
for (size_t k = 0; k < tagNameList.size(); k++) { for (size_t k = 0; k < tagNameList.size(); k++) {
@ -774,7 +774,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
break; break;
} }
} }
string srcFile; wstring srcFile;
if (ix < tagNameList.size()) { if (ix < tagNameList.size()) {
bool ro = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList[ix].second.first, srcFile)).isReadOnly(); bool ro = dynamic_cast<DynamicResult &>(oe->getGeneralResult(tagNameList[ix].second.first, srcFile)).isReadOnly();
gdi.setInputStatus("DoOpen", !ro); gdi.setInputStatus("DoOpen", !ro);
@ -786,7 +786,7 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
else if (type == GUI_LISTBOXSELECT) { else if (type == GUI_LISTBOXSELECT) {
ListBoxInfo &lbi = dynamic_cast<ListBoxInfo &>(data); ListBoxInfo &lbi = dynamic_cast<ListBoxInfo &>(data);
if (lbi.id == "Symbols") { if (lbi.id == "Symbols") {
string name, desc; wstring name, desc;
currentResult->getSymbolInfo(lbi.data, name, desc); currentResult->getSymbolInfo(lbi.data, name, desc);
gdi.replaceSelection("Source", name); gdi.replaceSelection("Source", name);
} }
@ -818,21 +818,21 @@ int MethodEditor::methodCb(gdioutput &gdi, int type, BaseInfo &data) {
} }
void MethodEditor::saveSettings(gdioutput &gdi) { void MethodEditor::saveSettings(gdioutput &gdi) {
string name = gdi.getText("Name"); wstring name = gdi.getText("Name");
string tag; string tag;
const bool updateTag = gdi.getBaseInfo("Tag").getExtraInt() == 0; const bool updateTag = gdi.getBaseInfo("Tag").getExtraInt() == 0;
if (updateTag) if (updateTag)
tag = gdi.getText("Tag"); tag = gdi.narrow(gdi.getText("Tag"));
else else
tag = currentResult->getTag(); tag = currentResult->getTag();
string desc = gdi.getText("Desc"); wstring desc = gdi.getText("Desc");
if (_strcmpi(currentResult->getTag().c_str(), tag.c_str()) != 0) { if (_strcmpi(currentResult->getTag().c_str(), tag.c_str()) != 0) {
checkTag(tag, true); checkTag(tag, true);
string oldPath = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource; wstring oldPath = fileNameSource.empty() ? getInternalPath(currentResult->getTag()) : fileNameSource;
string path = getInternalPath(tag); wstring path = getInternalPath(tag);
rename(oldPath.c_str(), path.c_str()); _wrename(oldPath.c_str(), path.c_str());
fileNameSource = path; fileNameSource = path;
} }
@ -840,7 +840,7 @@ void MethodEditor::saveSettings(gdioutput &gdi) {
currentResult->setName(name); currentResult->setName(name);
currentResult->setDescription(desc); currentResult->setDescription(desc);
gdi.setText("Name", name); gdi.setText("Name", name);
gdi.setText("Tag", tag); gdi.setText("Tag", gdi.widen(tag));
gdi.setText("Desc", desc); gdi.setText("Desc", desc);
} }
@ -874,7 +874,7 @@ void MethodEditor::makeDirty(gdioutput &gdi, DirtyFlag inside) {
bool MethodEditor::checkSave(gdioutput &gdi) { bool MethodEditor::checkSave(gdioutput &gdi) {
if (dirtyInt) { 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) if (answer == gdioutput::AnswerCancel)
return false; return false;
@ -891,24 +891,25 @@ void MethodEditor::checkChangedSave(gdioutput &gdi) {
if (gdi.hasField("Source")) { if (gdi.hasField("Source")) {
gdi.getText("Source"); gdi.getText("Source");
if (dynamic_cast<InputInfo &>(gdi.getBaseInfo("Source")).changed() && 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")); DynamicResult::DynamicMethods dm = DynamicResult::DynamicMethods(gdi.getExtraInt("SaveSource"));
string src = gdi.getText("Source"); string src = gdi.narrow(gdi.getText("Source"));
currentResult->setMethodSource(dm, src); 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 udTag = DynamicResult::undecorateTag(tag);
string resFile; wstring resFile;
if (udTag == tag) if (udTag == tag)
resFile = tag + ".rules"; resFile = gdi_main->widen(tag) + L".rules";
else 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()); getUserFile(path, resFile.c_str());
return path; return path;
} }
@ -940,7 +941,7 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
throw meosException("Internal error"); throw meosException("Internal error");
gdioutput *gdi_new = getExtraWindow("debug", true); 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) if (!gdi_new)
gdi_new = createExtraWindow("debug", title, gdi_new = createExtraWindow("debug", title,
@ -963,23 +964,23 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
st = currentResult->deduceStatus(r); st = currentResult->deduceStatus(r);
currentResult->debugDumpVariables(gdi, true); 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) { catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true); currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Status Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Status Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MDeduceRStatus)) if (currentResult->hasMethod(DynamicResult::MDeduceRStatus))
currentResult->debugDumpVariables(gdi, false); currentResult->debugDumpVariables(gdi, false);
try { try {
rt = currentResult->deduceTime(r, r.getStartTime()); 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) { catch (meosException &ex) {
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Time Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Time Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MDeduceRTime)) if (currentResult->hasMethod(DynamicResult::MDeduceRTime))
currentResult->debugDumpVariables(gdi, false); 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); gdi.addStringUT(1, "ComputedPoints: " + itos(pt)).setColor(colorGreen);
} }
catch (meosException &ex) { catch (meosException &ex) {
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Points Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Points Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MDeduceRPoints)) if (currentResult->hasMethod(DynamicResult::MDeduceRPoints))
currentResult->debugDumpVariables(gdi, true); currentResult->debugDumpVariables(gdi, true);
@ -1001,8 +1002,8 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
} }
catch (meosException &ex) { catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true); currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Score Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Score Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MRScore)) if (currentResult->hasMethod(DynamicResult::MRScore))
currentResult->debugDumpVariables(gdi, false); currentResult->debugDumpVariables(gdi, false);
@ -1017,23 +1018,23 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
st = currentResult->deduceStatus(t); st = currentResult->deduceStatus(t);
currentResult->debugDumpVariables(gdi, true); 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) { catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true); currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Status Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Status Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MDeduceTStatus)) if (currentResult->hasMethod(DynamicResult::MDeduceTStatus))
currentResult->debugDumpVariables(gdi, false); currentResult->debugDumpVariables(gdi, false);
try { try {
rt = currentResult->deduceTime(t); rt = currentResult->deduceTime(t);
gdi.addStringUT(1, "ComputedTime: " + formatTime(rt)).setColor(colorGreen); gdi.addStringUT(1, L"ComputedTime: " + formatTimeW(rt)).setColor(colorGreen);
} }
catch (meosException &ex) { catch (meosException &ex) {
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Time Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Time Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MDeduceRTime)) if (currentResult->hasMethod(DynamicResult::MDeduceRTime))
currentResult->debugDumpVariables(gdi, false); 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); gdi.addStringUT(1, "ComputedPoints: " + itos(pt)).setColor(colorGreen);
} }
catch (meosException &ex) { catch (meosException &ex) {
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Points Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Points Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MDeduceTPoints)) if (currentResult->hasMethod(DynamicResult::MDeduceTPoints))
currentResult->debugDumpVariables(gdi, true); currentResult->debugDumpVariables(gdi, true);
@ -1055,8 +1056,8 @@ void MethodEditor::debug(gdioutput &gdi_in, int id, bool isTeam) {
} }
catch (meosException &ex) { catch (meosException &ex) {
currentResult->debugDumpVariables(gdi, true); currentResult->debugDumpVariables(gdi, true);
string err = lang.tl(ex.what()); wstring err = lang.tl(ex.wwhat());
gdi.addString("", 0, "Status Calculation Failed: X#" + err).setColor(colorRed); gdi.addString("", 0, L"Status Calculation Failed: X#" + err).setColor(colorRed);
} }
if (currentResult->hasMethod(DynamicResult::MTScore)) if (currentResult->hasMethod(DynamicResult::MTScore))
currentResult->debugDumpVariables(gdi, false); currentResult->debugDumpVariables(gdi, false);

View File

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

View File

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

View File

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

View File

@ -70,8 +70,13 @@ int TabCompetition::newGuideCB(gdioutput &gdi, int type, void *data)
else if (bi.id == "DoImportEntries") { else if (bi.id == "DoImportEntries") {
createCompetition(gdi); createCompetition(gdi);
try { try {
gdi.autoRefresh(true); gdi.autoRefresh(true);
saveEntries(gdi, false, true); FlowOperation res = saveEntries(gdi, false, true);
if (res != FlowContinue) {
if (res == FlowCancel)
newCompetitionGuide(gdi, 1);
return 0;
}
} }
catch (std::exception &) { catch (std::exception &) {
newCompetitionGuide(gdi, 1); newCompetitionGuide(gdi, 1);
@ -216,7 +221,7 @@ int TabCompetition::newGuideCB(gdioutput &gdi, int type, void *data)
} }
if (t <= 0 || d <= 0) { if (t <= 0 || d <= 0) {
gdi.setTextTranslate("AllowedInterval", "Felaktigt datum/tid", true); gdi.setTextTranslate("AllowedInterval", L"Felaktigt datum/tid", true);
} }
else { else {
long long absT = SystemTimeToInt64Second(st); long long absT = SystemTimeToInt64Second(st);
@ -224,7 +229,7 @@ int TabCompetition::newGuideCB(gdioutput &gdi, int type, void *data)
long long stopT = absT + 23 * 3600; long long stopT = absT + 23 * 3600;
SYSTEMTIME start = Int64SecondToSystemTime(absT); SYSTEMTIME start = Int64SecondToSystemTime(absT);
SYSTEMTIME end = Int64SecondToSystemTime(stopT); 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); gdi.setTextTranslate("AllowedInterval", s, true);
} }
} }
@ -252,13 +257,13 @@ void TabCompetition::newCompetitionGuide(gdioutput &gdi, int step) {
gdi.addString("", fontMediumPlus, "Namn och tidpunkt"); gdi.addString("", fontMediumPlus, "Namn och tidpunkt");
gdi.dropLine(0.5); 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.pushX();
gdi.fillRight(); 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.popX();
gdi.fillDown(); gdi.fillDown();
@ -375,18 +380,18 @@ void TabCompetition::entryChoice(gdioutput &gdi) {
} }
void TabCompetition::createCompetition(gdioutput &gdi) { void TabCompetition::createCompetition(gdioutput &gdi) {
string name = gdi.getText("Name"); wstring name = gdi.getText("Name");
string date = gdi.getText("Date"); wstring date = gdi.getText("Date");
string start = gdi.getText("FirstStart"); wstring start = gdi.getText("FirstStart");
oe->newCompetition("tmp"); oe->newCompetition(L"tmp");
oe->setName(name); oe->setName(name);
oe->setDate(date); oe->setDate(date);
int t = convertAbsoluteTimeHMS(start, -1); int t = convertAbsoluteTimeHMS(start, -1);
if (t > 0 && t < 3600*24) { if (t > 0 && t < 3600*24) {
t = max(0, t-3600); t = max(0, t-3600);
oe->setZeroTime(formatTimeHMS(t)); oe->setZeroTime(formatTimeHMSW(t));
} }
else else
throw meosException("Ogiltig tid"); throw meosException("Ogiltig tid");

View File

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

View File

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

View File

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

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