added: bigtypes.h convert.h convert.cpp
changed: types used in the ParserManager are defined in bigtypes.h changed: a new class Convert all variables and methods regarding converting are thrown into Convert class changed: Convert uses two values during converting (numerator and denominator) git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@77 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
ec87cd8054
commit
2ff2aebbee
|
@ -1,15 +1,17 @@
|
|||
o = resource.o calculation.o functions.o iniparser.o languages.o mainwindow.o parsermanager.o programresources.o tabs.o variables.o winmain.o
|
||||
o = resource.o calculation.o convert.o functions.o iniparser.o languages.o mainwindow.o parsermanager.o programresources.o tabs.o variables.o winmain.o
|
||||
|
||||
calculation.o: calculation.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h tabs.h messages.h
|
||||
functions.o: functions.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
calculation.o: calculation.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
|
||||
convert.o: convert.cpp convert.h compileconfig.h bigtypes.h
|
||||
functions.o: functions.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
iniparser.o: iniparser.cpp compileconfig.h iniparser.h
|
||||
languages.o: languages.cpp compileconfig.h languages.h
|
||||
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h resource.h messages.h tabs.h
|
||||
parsermanager.o: parsermanager.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
programresources.o: programresources.cpp compileconfig.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
tabs.o: tabs.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
variables.o: variables.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h
|
||||
winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h threadcontroller.h stopcalculating.h resource.h messages.h tabs.h
|
||||
languages.o: languages.cpp compileconfig.h languages.h bigtypes.h
|
||||
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h
|
||||
parsermanager.o: parsermanager.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
|
||||
programresources.o: programresources.cpp compileconfig.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
tabs.o: tabs.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
variables.o: variables.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
|
||||
winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
# we provide a small wrapper for Html Help Workshop because the Html HW returns 1 when
|
||||
# it has compiled the help and the 'make' program then stops
|
||||
|
||||
hhc ../help/help.hhp
|
||||
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
# there was an error
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# there was a success
|
||||
|
||||
exit 0
|
||||
#!/bin/sh
|
||||
|
||||
# we provide a small wrapper for Html Help Workshop because the Html HW returns 1 when
|
||||
# it has compiled the help and the 'make' program then stops
|
||||
|
||||
hhc ../help/help.hhp
|
||||
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
# there was an error
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# there was a success
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* This file is a part of TTCalc - a mathematical calculator
|
||||
* and is distributed under the (new) BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
||||
* project may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef bigtypesheader
|
||||
#define bigtypesheader
|
||||
|
||||
#include "compileconfig.h"
|
||||
#include <ttmath/ttmath.h>
|
||||
|
||||
|
||||
#ifndef TTCALC_PORTABLE
|
||||
|
||||
/*
|
||||
// old ones
|
||||
ttmath::Big<1,3>
|
||||
ttmath::Big<2,6>
|
||||
ttmath::Big<3,9>
|
||||
*/
|
||||
|
||||
typedef ttmath::Big<1,3> TTMathBig1;
|
||||
typedef ttmath::Big<2,9> TTMathBig2;
|
||||
typedef ttmath::Big<4,27> TTMathBig3;
|
||||
typedef TTMathBig3 TTMathBigMax;
|
||||
|
||||
|
||||
#else
|
||||
|
||||
/* portable */
|
||||
|
||||
typedef ttmath::Big<1,3> TTMathBig1;
|
||||
typedef TTMathBig1 TTMathBigMax;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -0,0 +1,444 @@
|
|||
/*
|
||||
* This file is a part of TTCalc - a mathematical calculator
|
||||
* and is distributed under the (new) BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
||||
* project may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "convert.h"
|
||||
|
||||
|
||||
|
||||
Convert::Convert()
|
||||
{
|
||||
Init();
|
||||
current_conv_type = 0;
|
||||
CheckCurrentUnits();
|
||||
}
|
||||
|
||||
|
||||
void Convert::AddType(const char * name)
|
||||
{
|
||||
if( type_tab.empty() )
|
||||
return;
|
||||
|
||||
Type temp;
|
||||
temp.name = name;
|
||||
|
||||
type_tab.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
void Convert::AddUnit(const char * name, const char * abbr, int numerator, int denominator)
|
||||
{
|
||||
if( type_tab.empty() || type_tab.back().empty() || unit_tab.empty() )
|
||||
return;
|
||||
|
||||
Unit temp;
|
||||
temp.name = name;
|
||||
|
||||
if( abbr != 0 )
|
||||
temp.abbr = abbr;
|
||||
|
||||
|
||||
temp.type = int(type_tab.back().size()-1);
|
||||
|
||||
|
||||
temp.value_numerator.FromInt(numerator);
|
||||
|
||||
if( denominator != 1 )
|
||||
{
|
||||
// value_denominator is set into one (default)
|
||||
temp.value_denominator.FromInt(denominator);
|
||||
}
|
||||
|
||||
unit_tab.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Convert::AddUnit(const char * name, const char * abbr, const char * v)
|
||||
{
|
||||
if( type_tab.empty() || type_tab.back().empty() || unit_tab.empty() )
|
||||
return;
|
||||
|
||||
Unit temp;
|
||||
temp.name = name;
|
||||
temp.abbr = abbr;
|
||||
temp.type = int(type_tab.back().size()-1);
|
||||
temp.value_numerator.FromString(v, 16);
|
||||
|
||||
unit_tab.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
void Convert::Init()
|
||||
{
|
||||
// en
|
||||
type_tab.push_back( std::vector<Type>() );
|
||||
unit_tab.push_back( std::vector<Unit>() );
|
||||
|
||||
AddType("none");
|
||||
|
||||
/*
|
||||
yard = 0.9144 metre
|
||||
foot = 1/3 yard = 0.3048 metre
|
||||
inch = 1/36 yard = 1/12 foot = 0.0254 metre
|
||||
|
||||
In 1958 the United States and countries of the Commonwealth of Nations
|
||||
defined the length of the international yard to be precisely 0.9144 metres.
|
||||
|
||||
1 point (Didot's system) = 1 / 2660 m
|
||||
1 point (pica - USA and UK) = 1 / 72 inch
|
||||
*/
|
||||
AddType("length"); // base: 10000 metre
|
||||
AddUnit("inch", "in", 254);
|
||||
AddUnit("foot", "ft", 3048);
|
||||
AddUnit("yard", "yd", 9144);
|
||||
AddUnit("metre", "m", 10000);
|
||||
AddUnit("mile (land)", "mi", 16093440); // 1 land mile = 1609.344 metres
|
||||
AddUnit("mile (nautical)", "nmi", 18520000); // 1 nautical mile = 1852 metres
|
||||
AddUnit("point (Didot)", "p", 10000, 2660);
|
||||
AddUnit("point (pica)", "p", 18288, 5184);
|
||||
AddUnit("light year", "ly", "520F0AA65AAEBAC00"); // 1 ly = 9 460 730 472 580 800 metres
|
||||
// 520F0AA65AAEBAC00 (hex) = 94607304725808000000 (dec)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
yard^2 = 0.83612736 metre^2
|
||||
foot^2 = 1/9 yard^2 = 0.09290304 metre^2
|
||||
inch^2 = 1/1296 yard^2 = 1/144 foot^ = 0.00064516 metre^2
|
||||
|
||||
ar = 100 metre^2
|
||||
hectere = 10000 metre^2
|
||||
*/
|
||||
|
||||
// !!! give a smaller base here
|
||||
AddType("area"); // base: 100 000 000 metre^2
|
||||
AddUnit("inch^2", "in^2", 64516);
|
||||
AddUnit("foot^2", "ft^2", 9290304);
|
||||
AddUnit("yard^2", "yd^2", 83612736);
|
||||
AddUnit("metre^2", "m^2", 100000000);
|
||||
AddUnit("are", "a", "2540BE400"); // 10000000000 (dec)
|
||||
AddUnit("hectare", "ha", "E8D4A51000"); // 1000000000000 (dec)
|
||||
AddUnit("mile (land)^2", "mi^2", "EB8EDC210000" ); // 258998811033600 (dec), 1 land mile^2 = 2589988.110336 metres^2
|
||||
AddUnit("mile (nautical)^2", "nmi^2", "137F2ACF41000"); // 342990400000000 (dec), 1 nautical mile^2 = 3429904 metres^2
|
||||
AddUnit("light year^2", "ly^2", "1A4DA3B4D207FB4C43D08391653B900000"); // 1 ly = 89505421074818927300612528640000 metres^2
|
||||
// 1A4DA3B4D207FB4C43D08391653B900000 (hex) = 8950542107481892730061252864000000000000 (dec)
|
||||
|
||||
|
||||
AddType("time"); // base: second
|
||||
AddUnit("second", "s", 1);
|
||||
AddUnit("minute", "m", 60);
|
||||
AddUnit("hour", "h", 3600);
|
||||
AddUnit("day", "d", 86400);
|
||||
AddUnit("week", "w", 604800);
|
||||
AddUnit("fortnight", "fn", 1209600);
|
||||
AddUnit("month", "m", 2592000);
|
||||
AddUnit("year", "y", 31536000);
|
||||
AddUnit("year (mean)", "my", 31557600);
|
||||
AddUnit("year (leap)", "ly", 31622400);
|
||||
AddUnit("decade", "dc", 315360000);
|
||||
|
||||
|
||||
|
||||
// pl
|
||||
// the 'value' param we're using only from the english
|
||||
type_tab.push_back( std::vector<Type>() );
|
||||
unit_tab.push_back( std::vector<Unit>() );
|
||||
|
||||
AddType("brak");
|
||||
|
||||
AddType("d³ugoœæ");
|
||||
AddUnit("cal");
|
||||
AddUnit("stopa");
|
||||
AddUnit("jard");
|
||||
AddUnit("metr");
|
||||
AddUnit("mila (angielska)");
|
||||
AddUnit("mila (morska)");
|
||||
AddUnit("punkt (Didot)");
|
||||
AddUnit("punkt (pica)");
|
||||
AddUnit("rok œwietlny");
|
||||
|
||||
AddType("powierzchnia");
|
||||
AddUnit("cal^2");
|
||||
AddUnit("stopa^2");
|
||||
AddUnit("jard^2");
|
||||
AddUnit("metr^2");
|
||||
AddUnit("ar", "");
|
||||
AddUnit("hektar");
|
||||
AddUnit("mila (angielska)^2");
|
||||
AddUnit("mila (morska)^2");
|
||||
AddUnit("rok œwietlny^2");
|
||||
|
||||
|
||||
AddType("czas");
|
||||
AddUnit("sekunda");
|
||||
AddUnit("minuta");
|
||||
AddUnit("godzina");
|
||||
AddUnit("dzieñ");
|
||||
AddUnit("tydzieñ");
|
||||
AddUnit("dwa tygodnie");
|
||||
AddUnit("miesi¹c");
|
||||
AddUnit("rok");
|
||||
AddUnit("rok (œredni)");
|
||||
AddUnit("rok (przestêpny)");
|
||||
AddUnit("dekada");
|
||||
|
||||
CheckAfterInit();
|
||||
}
|
||||
|
||||
|
||||
void Convert::ErrorMessage()
|
||||
{
|
||||
MessageBox(0, "Internal error: tables for converting have incorrect values",
|
||||
"Internal error", MB_ICONERROR);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void Convert::CheckAfterInit()
|
||||
{
|
||||
unsigned int i, len;
|
||||
|
||||
if( type_tab.size() != unit_tab.size() )
|
||||
return ErrorMessage();
|
||||
|
||||
if( type_tab.empty() )
|
||||
return;
|
||||
|
||||
len = (unsigned int)type_tab[0].size();
|
||||
for(i=1 ; i<type_tab.size() ; ++i)
|
||||
{
|
||||
if( len != type_tab[i].size() )
|
||||
return ErrorMessage();
|
||||
}
|
||||
|
||||
len = (unsigned int)unit_tab[0].size();
|
||||
for(i=1 ; i<unit_tab.size() ; ++i)
|
||||
{
|
||||
if( len != unit_tab[i].size() )
|
||||
return ErrorMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
cid - country id
|
||||
|
||||
*/
|
||||
const char * Convert::GetTypeName(int cid, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( type_tab.empty() )
|
||||
return unk_err;
|
||||
|
||||
if( cid >= (int)type_tab.size() )
|
||||
cid = 0;
|
||||
|
||||
if( id< 0 || id >= int(type_tab[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
return type_tab[cid][id].name.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char * Convert::GetUnitName(int cid, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( unit_tab.empty() )
|
||||
return unk_err;
|
||||
|
||||
if( cid >= (int)unit_tab.size() )
|
||||
cid = 0;
|
||||
|
||||
if( id < 0 || id >= int(unit_tab[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
return unit_tab[cid][id].name.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char * Convert::GetUnitAbbr(int cid, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( unit_tab.empty() )
|
||||
return unk_err;
|
||||
|
||||
if( cid >= (int)unit_tab.size() )
|
||||
cid = 0;
|
||||
|
||||
if( id < 0 || id >= int(unit_tab[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
if( !unit_tab[cid][id].abbr.empty() )
|
||||
return unit_tab[cid][id].abbr.c_str();
|
||||
|
||||
/*
|
||||
if there is no defined an abbreviation in the specific
|
||||
language, we return the abbreviation from english
|
||||
*/
|
||||
|
||||
return unit_tab[0][id].abbr.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int Convert::GetTypeSize()
|
||||
{
|
||||
if( type_tab.empty() )
|
||||
return 0;
|
||||
|
||||
return int(type_tab[0].size());
|
||||
}
|
||||
|
||||
|
||||
int Convert::GetUnitSize()
|
||||
{
|
||||
if( unit_tab.empty() )
|
||||
return 0;
|
||||
|
||||
return int(unit_tab[0].size());
|
||||
}
|
||||
|
||||
|
||||
int Convert::GetUnitType(int id)
|
||||
{
|
||||
if( unit_tab.empty() )
|
||||
return -1;
|
||||
|
||||
if( id >= int(unit_tab[0].size()) )
|
||||
return -1;
|
||||
|
||||
return unit_tab[0][id].type;
|
||||
}
|
||||
|
||||
|
||||
// value is taken only from english
|
||||
bool Convert::GetUnitValue(int id, TTMathBigMax & numerator, TTMathBigMax & denominator)
|
||||
{
|
||||
if( unit_tab.empty() )
|
||||
return false;
|
||||
|
||||
if( id >= int(unit_tab[0].size()) )
|
||||
return false;
|
||||
|
||||
numerator = unit_tab[0][id].value_numerator;
|
||||
denominator = unit_tab[0][id].value_denominator;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// gui
|
||||
|
||||
void Convert::SetCurrentType(int c)
|
||||
{
|
||||
current_conv_type = c;
|
||||
}
|
||||
|
||||
|
||||
int Convert::GetCurrentType()
|
||||
{
|
||||
return current_conv_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Convert::CheckUnitIndex(int type)
|
||||
{
|
||||
if( current_conv_unit[type].input < -1 || current_conv_unit[type].input >= GetUnitSize() )
|
||||
current_conv_unit[type].input = 0; // maybe better to -1 ?
|
||||
|
||||
if( current_conv_unit[type].output < -1 || current_conv_unit[type].output >= GetUnitSize() )
|
||||
current_conv_unit[type].output = 0; // the same
|
||||
}
|
||||
|
||||
|
||||
void Convert::CheckCurrentUnits()
|
||||
{
|
||||
int len = GetTypeSize();
|
||||
|
||||
if( static_cast<int>( current_conv_unit.size() ) != len )
|
||||
current_conv_unit.resize(len);
|
||||
|
||||
for(int i = 0 ; i<len ; ++i)
|
||||
CheckUnitIndex(i);
|
||||
}
|
||||
|
||||
|
||||
void Convert::SetCurrentUnit(int type, int input, int output)
|
||||
{
|
||||
int len = GetTypeSize();
|
||||
|
||||
if( type >= len )
|
||||
return;
|
||||
|
||||
current_conv_unit[type].input = input;
|
||||
current_conv_unit[type].output = output;
|
||||
CheckUnitIndex(type);
|
||||
}
|
||||
|
||||
|
||||
bool Convert::GetCurrentUnit(int type, int & input, int & output)
|
||||
{
|
||||
int len = GetTypeSize();
|
||||
|
||||
if( type >= len )
|
||||
{
|
||||
input = output = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
input = current_conv_unit[type].input;
|
||||
output = current_conv_unit[type].output;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* This file is a part of TTCalc - a mathematical calculator
|
||||
* and is distributed under the (new) BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
||||
* project may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef convertheader
|
||||
#define convertheader
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include "compileconfig.h"
|
||||
#include "bigtypes.h"
|
||||
|
||||
|
||||
|
||||
class Convert
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Convert();
|
||||
|
||||
|
||||
/*
|
||||
none, length, area, time,
|
||||
*/
|
||||
struct Type
|
||||
{
|
||||
std::string name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct Unit
|
||||
{
|
||||
std::string name, abbr;
|
||||
int type;
|
||||
TTMathBigMax value_numerator, value_denominator;
|
||||
|
||||
Unit()
|
||||
{
|
||||
type = -1;
|
||||
value_numerator.SetZero();
|
||||
value_denominator.SetOne();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
std::vector<std::vector<Type> > type_tab;
|
||||
std::vector<std::vector<Unit> > unit_tab;
|
||||
|
||||
|
||||
|
||||
|
||||
void AddType(const char * name);
|
||||
void AddUnit(const char * name, const char * abbr = 0, int numerator = 0, int denominator = 1);
|
||||
void AddUnit(const char * name, const char * abbr, const char * v);
|
||||
|
||||
void Init();
|
||||
|
||||
|
||||
const char * GetTypeName(int cid, int id);
|
||||
|
||||
const char * GetUnitName(int cid, int id);
|
||||
const char * GetUnitAbbr(int cid, int id);
|
||||
int GetUnitType(int id);
|
||||
|
||||
int GetTypeSize();
|
||||
int GetUnitSize();
|
||||
|
||||
|
||||
/*
|
||||
the return value is the same for all languages
|
||||
(in fact we're taking it from english)
|
||||
*/
|
||||
bool GetUnitValue(int id, TTMathBigMax & numerator, TTMathBigMax & denominator);
|
||||
|
||||
void ErrorMessage();
|
||||
void CheckAfterInit();
|
||||
|
||||
|
||||
template<class ValueType>
|
||||
int Conversion(int conv_input_unit, int conv_output_unit, ValueType & result)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
ValueType v1_n, v1_d; // input
|
||||
ValueType v2_n, v2_d; // output
|
||||
|
||||
TTMathBigMax v1_n_, v1_d_; // input
|
||||
TTMathBigMax v2_n_, v2_d_; // output
|
||||
|
||||
if( !GetUnitValue(conv_input_unit, v1_n_, v1_d_) )
|
||||
return 1;
|
||||
|
||||
if( !GetUnitValue(conv_output_unit, v2_n_, v2_d_) )
|
||||
return 1;
|
||||
|
||||
v1_n.FromBig( v1_n_ );
|
||||
v1_d.FromBig( v1_d_ );
|
||||
v2_n.FromBig( v2_n_ );
|
||||
v2_d.FromBig( v2_d_ );
|
||||
|
||||
// result = result * (v1_n * v2_d) / (v1_d * v2_n)
|
||||
c += result.Mul(v1_n);
|
||||
c += result.Mul(v2_d);
|
||||
c += v1_d.Mul(v2_n);
|
||||
c += result.Div(v1_d);
|
||||
|
||||
return (c==0)? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
for the interface
|
||||
*/
|
||||
|
||||
int current_conv_type; // selected type of converting: none, length, area, ...
|
||||
|
||||
struct CurrentConvUnit
|
||||
{
|
||||
int input, output;
|
||||
CurrentConvUnit() { input = output = -1; }
|
||||
};
|
||||
|
||||
std::vector<CurrentConvUnit> current_conv_unit;
|
||||
|
||||
|
||||
|
||||
void SetCurrentType(int c);
|
||||
int GetCurrentType();
|
||||
void CheckUnitIndex(int type);
|
||||
void CheckCurrentUnits();
|
||||
void SetCurrentUnit(int type, int input, int output);
|
||||
bool GetCurrentUnit(int type, int & input, int & output);
|
||||
|
||||
// end part of gui
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -36,14 +36,11 @@
|
|||
*/
|
||||
|
||||
#include "compileconfig.h"
|
||||
|
||||
#include "languages.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const char * Languages::ErrorMessage(Country country, ttmath::ErrorCode code)
|
||||
{
|
||||
const char * unk_err = "unknown error";
|
||||
|
@ -201,10 +198,15 @@ const char * unk_msg = "unknown";
|
|||
return i->second.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * Languages::GuiMessage(GuiMsg code)
|
||||
{
|
||||
return GuiMessage(current_country, code);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Languages::InsertGuiPair(GuiMsg code, const char * message)
|
||||
{
|
||||
if( gui_messages_tab.empty() )
|
||||
|
@ -214,6 +216,7 @@ void Languages::InsertGuiPair(GuiMsg code, const char * message)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void Languages::InitGuiMessagesTab()
|
||||
{
|
||||
// en
|
||||
|
@ -594,288 +597,4 @@ void Languages::InitGuiMessagesTab()
|
|||
|
||||
|
||||
|
||||
void Languages::ConvertingAddType(const char * name)
|
||||
{
|
||||
if( converting_type.empty() )
|
||||
return;
|
||||
|
||||
ConvType temp;
|
||||
temp.name = name;
|
||||
|
||||
converting_type.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
void Languages::ConvertingAddUnit(const char * name, const char * abbr, double v)
|
||||
{
|
||||
if( converting_type.empty() || converting_type.back().empty() || converting_unit.empty() )
|
||||
return;
|
||||
|
||||
ConvUnit temp;
|
||||
temp.name = name;
|
||||
temp.abbr = abbr;
|
||||
temp.type = static_cast<int>(converting_type.back().size()-1);
|
||||
temp.value.FromDouble(v);
|
||||
|
||||
converting_unit.back().push_back(temp);
|
||||
}
|
||||
|
||||
void Languages::ConvertingAddUnit(const char * name, const char * abbr, const char * v)
|
||||
{
|
||||
if( converting_type.empty() || converting_type.back().empty() || converting_unit.empty() )
|
||||
return;
|
||||
|
||||
ConvUnit temp;
|
||||
temp.name = name;
|
||||
temp.abbr = abbr;
|
||||
temp.type = static_cast<int>(converting_type.back().size()-1);
|
||||
temp.value.FromString(v, 16);
|
||||
|
||||
converting_unit.back().push_back(temp);
|
||||
}
|
||||
|
||||
|
||||
void Languages::InitConverting()
|
||||
{
|
||||
// en
|
||||
converting_type.push_back( std::vector<ConvType>() );
|
||||
converting_unit.push_back( std::vector<ConvUnit>() );
|
||||
|
||||
ConvertingAddType("none");
|
||||
|
||||
/*
|
||||
yard = 0.9144 metre
|
||||
foot = 1/3 yard = 0.3048 metre
|
||||
inch = 1/36 yard = 1/12 foot = 0.0254 metre
|
||||
|
||||
In 1958 the United States and countries of the Commonwealth of Nations
|
||||
defined the length of the international yard to be precisely 0.9144 metres.
|
||||
*/
|
||||
ConvertingAddType("length"); // base: 10000 metre
|
||||
ConvertingAddUnit("inch", "in", 254.0 );
|
||||
ConvertingAddUnit("foot", "ft", 3048.0);
|
||||
ConvertingAddUnit("yard", "yd", 9144.0);
|
||||
ConvertingAddUnit("metre", "m", 10000.0 );
|
||||
ConvertingAddUnit("mile (land)", "mi", 16093440.0); // 1 land mile = 1609.344 metres
|
||||
ConvertingAddUnit("mile (nautical)", "nmi", 18520000.0); // 1 nautical mile = 1852 metres
|
||||
ConvertingAddUnit("light year", "ly", "520F0AA65AAEBAC00"); // 1 ly = 9 460 730 472 580 800 metres
|
||||
// 520F0AA65AAEBAC00 (hex) = 94607304725808000000 (dec)
|
||||
|
||||
/*
|
||||
yard^2 = 0.83612736 metre^2
|
||||
foot^2 = 1/9 yard^2 = 0.09290304 metre^2
|
||||
inch^2 = 1/1296 yard^2 = 1/144 foot^ = 0.00064516 metre^2
|
||||
|
||||
ar = 100 metre^2
|
||||
hectere = 10000 metre^2
|
||||
*/
|
||||
ConvertingAddType("area"); // base: 100 000 000 metre^2
|
||||
ConvertingAddUnit("inch^2", "in^2", 64516.0);
|
||||
ConvertingAddUnit("foot^2", "ft^2", 9290304.0);
|
||||
ConvertingAddUnit("yard^2", "yd^2", 83612736.0);
|
||||
ConvertingAddUnit("metre^2", "m^2", 100000000.0);
|
||||
ConvertingAddUnit("are", "a", 10000000000.0);
|
||||
ConvertingAddUnit("hectare", "ha", 1000000000000.0);
|
||||
ConvertingAddUnit("mile (land)^2", "mi^2", 258998811033600.0 ); // 1 land mile^2 = 2589988.110336 metres^2
|
||||
ConvertingAddUnit("mile (nautical)^2", "nmi^2", 342990400000000.0); // 1 nautical mile^2 = 3429904 metres^2
|
||||
ConvertingAddUnit("light year^2", "ly^2", "1A4DA3B4D207FB4C43D08391653B900000"); // 1 ly = 89505421074818927300612528640000 metres^2
|
||||
// 1A4DA3B4D207FB4C43D08391653B900000 (hex) = 8950542107481892730061252864000000000000 (dec)
|
||||
|
||||
ConvertingAddType("time"); // base: second
|
||||
ConvertingAddUnit("second", "s", 1.0);
|
||||
ConvertingAddUnit("minute", "m", 60.0);
|
||||
ConvertingAddUnit("hour", "h", 3600.0);
|
||||
ConvertingAddUnit("day", "d", 86400.0);
|
||||
ConvertingAddUnit("week", "w", 604800.0);
|
||||
ConvertingAddUnit("fortnight", "fn", 1209600.0);
|
||||
ConvertingAddUnit("month", "m", 2592000.0);
|
||||
ConvertingAddUnit("year", "y", 31536000.0);
|
||||
ConvertingAddUnit("year (mean)", "my", 31557600.0);
|
||||
ConvertingAddUnit("year (leap)", "ly", 31622400.0);
|
||||
ConvertingAddUnit("decade", "dc", 315360000.0);
|
||||
|
||||
|
||||
|
||||
// pl
|
||||
// the 'value' param we're using only from the english
|
||||
converting_type.push_back( std::vector<ConvType>() );
|
||||
converting_unit.push_back( std::vector<ConvUnit>() );
|
||||
|
||||
ConvertingAddType("brak");
|
||||
|
||||
ConvertingAddType("d³ugoœæ");
|
||||
ConvertingAddUnit("cal", "", 0.0 );
|
||||
ConvertingAddUnit("stopa", "", 0.0);
|
||||
ConvertingAddUnit("jard", "", 0.0);
|
||||
ConvertingAddUnit("metr", "", 0.0);
|
||||
ConvertingAddUnit("mila (angielska)", "", 0.0);
|
||||
ConvertingAddUnit("mila (morska)", "", 0.0);
|
||||
ConvertingAddUnit("rok œwietlny", "", 0.0);
|
||||
|
||||
ConvertingAddType("powierzchnia");
|
||||
ConvertingAddUnit("cal^2", "", 0.0);
|
||||
ConvertingAddUnit("stopa^2", "", 0.0);
|
||||
ConvertingAddUnit("jard^2", "", 0.0);
|
||||
ConvertingAddUnit("metr^2", "", 0.0);
|
||||
ConvertingAddUnit("ar", "", 0.0);
|
||||
ConvertingAddUnit("hektar", "", 0.0);
|
||||
ConvertingAddUnit("mila (angielska)^2", "", 0.0);
|
||||
ConvertingAddUnit("mila (morska)^2", "", 0.0);
|
||||
ConvertingAddUnit("rok œwietlny^2", "", 0.0);
|
||||
|
||||
ConvertingAddType("czas");
|
||||
ConvertingAddUnit("sekunda", "", 0.0);
|
||||
ConvertingAddUnit("minuta", "", 0.0);
|
||||
ConvertingAddUnit("godzina", "", 0.0);
|
||||
ConvertingAddUnit("dzieñ", "", 0.0);
|
||||
ConvertingAddUnit("tydzieñ", "", 0.0);
|
||||
ConvertingAddUnit("dwa tygodnie", "", 0.0);
|
||||
ConvertingAddUnit("miesi¹c", "", 0.0);
|
||||
ConvertingAddUnit("rok", "", 0.0);
|
||||
ConvertingAddUnit("rok (œredni)", "", 0.0);
|
||||
ConvertingAddUnit("rok (przestêpny)", "", 0.0);
|
||||
ConvertingAddUnit("dekada", "", 0.0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
const char * Languages::ConvertingType(Country country, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( converting_type.empty() )
|
||||
InitConverting();
|
||||
|
||||
unsigned int cid = static_cast<unsigned int>( country );
|
||||
if( cid >= converting_type.size() )
|
||||
return unk_err;
|
||||
|
||||
if( id< 0 || id >= static_cast<int>(converting_type[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
return converting_type[cid][id].name.c_str();
|
||||
}
|
||||
|
||||
|
||||
const char * Languages::ConvertingUnit(Country country, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( converting_unit.empty() )
|
||||
InitConverting();
|
||||
|
||||
unsigned int cid = static_cast<unsigned int>( country );
|
||||
if( cid >= converting_unit.size() )
|
||||
return unk_err;
|
||||
|
||||
if( id < 0 || id >= static_cast<int>(converting_unit[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
return converting_unit[cid][id].name.c_str();
|
||||
}
|
||||
|
||||
const char * Languages::ConvertingUnitAbbr(Country country, int id)
|
||||
{
|
||||
const char * unk_err = "unknown";
|
||||
|
||||
if( converting_unit.empty() )
|
||||
InitConverting();
|
||||
|
||||
unsigned int cid = static_cast<unsigned int>( country );
|
||||
if( cid >= converting_unit.size() )
|
||||
return unk_err;
|
||||
|
||||
if( id < 0 || id >= static_cast<int>(converting_unit[cid].size()) )
|
||||
return unk_err;
|
||||
|
||||
//return converting_unit[cid][id].abbr.c_str();
|
||||
// at the moment abbreviations we get only from english
|
||||
return converting_unit[0][id].abbr.c_str();
|
||||
}
|
||||
|
||||
|
||||
const char * Languages::ConvertingType(int id)
|
||||
{
|
||||
return ConvertingType(current_country, id);
|
||||
|
||||
}
|
||||
|
||||
const char * Languages::ConvertingUnit(int id)
|
||||
{
|
||||
return ConvertingUnit(current_country, id);
|
||||
}
|
||||
|
||||
const char * Languages::ConvertingUnitAbbr(int id)
|
||||
{
|
||||
return ConvertingUnitAbbr(current_country, id);
|
||||
}
|
||||
|
||||
int Languages::ConvertingTypeSize(Country country)
|
||||
{
|
||||
if( converting_type.empty() )
|
||||
InitConverting();
|
||||
|
||||
unsigned int cid = static_cast<unsigned int>( country );
|
||||
if( cid >= converting_type.size() )
|
||||
return 0;
|
||||
|
||||
return static_cast<int>(converting_type[cid].size());
|
||||
}
|
||||
|
||||
|
||||
int Languages::ConvertingUnitSize(Country country)
|
||||
{
|
||||
if( converting_unit.empty() )
|
||||
InitConverting();
|
||||
|
||||
unsigned int cid = static_cast<unsigned int>( country );
|
||||
if( cid >= converting_unit.size() )
|
||||
return 0;
|
||||
|
||||
return static_cast<int>(converting_unit[cid].size());
|
||||
}
|
||||
|
||||
|
||||
int Languages::ConvertingTypeSize()
|
||||
{
|
||||
return ConvertingTypeSize(current_country);
|
||||
}
|
||||
|
||||
int Languages::ConvertingUnitSize()
|
||||
{
|
||||
return ConvertingUnitSize(current_country);
|
||||
}
|
||||
|
||||
|
||||
int Languages::ConvertingUnitType(Country country, int id)
|
||||
{
|
||||
if( converting_unit.empty() )
|
||||
InitConverting();
|
||||
|
||||
unsigned int cid = static_cast<unsigned int>( country );
|
||||
if( cid >= converting_unit.size() )
|
||||
return -1;
|
||||
|
||||
if( id >= static_cast<int>(converting_unit[cid].size()) )
|
||||
return -1;
|
||||
|
||||
return converting_unit[cid][id].type;
|
||||
}
|
||||
|
||||
int Languages::ConvertingUnitType(int id)
|
||||
{
|
||||
return ConvertingUnitType(current_country, id);
|
||||
}
|
||||
|
||||
// value is taken only from english
|
||||
const Languages::ConvUnit::ValueType & Languages::ConvertingUnitValue(int id)
|
||||
{
|
||||
if( converting_unit.empty() )
|
||||
InitConverting();
|
||||
|
||||
if( id >= static_cast<int>(converting_unit[0].size()) )
|
||||
return foo_return;
|
||||
|
||||
return converting_unit[0][id].value;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -42,7 +42,8 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <ttmath/ttmath.h>
|
||||
#include "bigtypes.h"
|
||||
|
||||
|
||||
class Languages
|
||||
{
|
||||
|
@ -147,25 +148,10 @@ public:
|
|||
en = 0, pl, sp
|
||||
};
|
||||
|
||||
struct ConvType
|
||||
{
|
||||
std::string name;
|
||||
// int id;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct ConvUnit
|
||||
{
|
||||
std::string name, abbr;
|
||||
// int id;
|
||||
int type;
|
||||
|
||||
typedef ttmath::Big<3,27> ValueType;
|
||||
ValueType value;
|
||||
};
|
||||
|
||||
ConvUnit::ValueType foo_return;
|
||||
// TTMathBigMax foo_return;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -181,23 +167,15 @@ private:
|
|||
void InitGuiMessagesTab();
|
||||
|
||||
|
||||
std::vector<std::vector<ConvType> > converting_type;
|
||||
std::vector<std::vector<ConvUnit> > converting_unit;
|
||||
|
||||
|
||||
|
||||
void ConvertingAddType(const char * name);
|
||||
void ConvertingAddUnit(const char * name, const char * abbr, double v);
|
||||
void ConvertingAddUnit(const char * name, const char * abbr, const char * v);
|
||||
|
||||
void InitConverting();
|
||||
|
||||
public:
|
||||
|
||||
Languages()
|
||||
{
|
||||
current_country = en;
|
||||
foo_return = 0;
|
||||
// foo_return = 0;
|
||||
}
|
||||
|
||||
void SetCurrentLanguage(Country c)
|
||||
|
@ -221,7 +199,6 @@ public:
|
|||
{
|
||||
InitErrorMessagesTab();
|
||||
InitGuiMessagesTab();
|
||||
InitConverting();
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,12 +214,7 @@ public:
|
|||
*/
|
||||
const char * ErrorMessage(Country country, ttmath::ErrorCode code);
|
||||
const char * GuiMessage(Country country, GuiMsg code);
|
||||
const char * ConvertingType(Country country, int id);
|
||||
const char * ConvertingUnit(Country country, int id);
|
||||
const char * ConvertingUnitAbbr(Country country, int id);
|
||||
int ConvertingUnitType(Country country, int id);
|
||||
int ConvertingTypeSize(Country country);
|
||||
int ConvertingUnitSize(Country country);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -255,19 +227,8 @@ public:
|
|||
*/
|
||||
const char * ErrorMessage(ttmath::ErrorCode code);
|
||||
const char * GuiMessage(GuiMsg code);
|
||||
const char * ConvertingType(int id);
|
||||
const char * ConvertingUnit(int id);
|
||||
const char * ConvertingUnitAbbr(int id);
|
||||
int ConvertingUnitType(int id);
|
||||
int ConvertingTypeSize();
|
||||
int ConvertingUnitSize();
|
||||
|
||||
|
||||
/*
|
||||
the return value is the same for all languages
|
||||
(in fact we're taking it from english)
|
||||
*/
|
||||
const ConvUnit::ValueType & ConvertingUnitValue(int id);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -152,8 +152,8 @@ unsigned int i;
|
|||
remove_zeroes = GetPrgRes()->GetRemovingZeroes();
|
||||
country = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
|
||||
|
||||
conv_type = GetPrgRes()->GetConvType();
|
||||
GetPrgRes()->GetConvUnit(conv_type, conv_input_unit, conv_output_unit);
|
||||
conv_type = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit(conv_type, conv_input_unit, conv_output_unit);
|
||||
|
||||
if( GetPrgRes()->GetDecimalPoint() == 0 )
|
||||
decimal_point = '.';
|
||||
|
@ -223,52 +223,48 @@ HWND conv_tab = GetPrgRes()->GetTabWindow(TabWindowFunctions::tab_convert);
|
|||
return;
|
||||
}
|
||||
|
||||
Languages * plang = GetPrgRes()->GetLanguages();
|
||||
Convert * pconv = GetPrgRes()->GetConvert();
|
||||
|
||||
// the first unit to the second
|
||||
|
||||
ttmath::Big<1,1> result;
|
||||
result.SetOne();
|
||||
std::string buffer1 = "1 ";
|
||||
|
||||
buffer1 += plang->ConvertingUnitAbbr(country, conv_input_unit);
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_input_unit);
|
||||
buffer1 += " = ";
|
||||
|
||||
ttmath::Big<1,1> value_input, value_output, result;
|
||||
value_input = plang->ConvertingUnitValue(conv_input_unit);
|
||||
value_output = plang->ConvertingUnitValue(conv_output_unit);
|
||||
result = value_input;
|
||||
|
||||
if( result.Div(value_output) )
|
||||
if( pconv->Conversion(conv_input_unit, conv_output_unit, result) )
|
||||
{
|
||||
SetDlgItemText(conv_tab, IDC_EDIT_OUTPUT_INFO, "overflow" );
|
||||
return;
|
||||
}
|
||||
|
||||
result.ToString(buffer2,10,false,3,-1, true);
|
||||
result.ToString(buffer2, 10, false, 3, -1, true);
|
||||
|
||||
buffer1 += buffer2;
|
||||
buffer1 += " ";
|
||||
buffer1 += plang->ConvertingUnitAbbr(country, conv_output_unit);
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_output_unit);
|
||||
|
||||
|
||||
// the second unit to the first
|
||||
|
||||
buffer1 += " 1 ";
|
||||
buffer1 += plang->ConvertingUnitAbbr(country, conv_output_unit);
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_output_unit);
|
||||
buffer1 += " = ";
|
||||
|
||||
result = value_output;
|
||||
if( result.Div(value_input) )
|
||||
result.SetOne();
|
||||
if( pconv->Conversion(conv_output_unit, conv_input_unit, result) )
|
||||
{
|
||||
SetDlgItemText(conv_tab, IDC_EDIT_OUTPUT_INFO, "overflow" );
|
||||
return;
|
||||
}
|
||||
|
||||
result.ToString(buffer2,10,false,3,-1, true);
|
||||
|
||||
result.ToString(buffer2, 10, false, 3, -1, true);
|
||||
|
||||
buffer1 += buffer2;
|
||||
buffer1 += " ";
|
||||
buffer1 += plang->ConvertingUnitAbbr(country, conv_input_unit);
|
||||
|
||||
|
||||
buffer1 += pconv->GetUnitAbbr(country, conv_input_unit);
|
||||
|
||||
SetDlgItemText(conv_tab, IDC_EDIT_OUTPUT_INFO, buffer1.c_str() );
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -113,17 +113,11 @@ private:
|
|||
|
||||
#ifndef TTCALC_PORTABLE
|
||||
|
||||
/*
|
||||
// old ones
|
||||
ttmath::Parser<ttmath::Big<1,3> > parser1;
|
||||
ttmath::Parser<ttmath::Big<2,6> > parser2;
|
||||
ttmath::Parser<ttmath::Big<3,9> > parser3;
|
||||
*/
|
||||
ttmath::Parser<ttmath::Big<1,3> > parser1;
|
||||
ttmath::Parser<ttmath::Big<2,9> > parser2;
|
||||
ttmath::Parser<ttmath::Big<4,27> > parser3;
|
||||
ttmath::Parser<TTMathBig1> parser1;
|
||||
ttmath::Parser<TTMathBig2> parser2;
|
||||
ttmath::Parser<TTMathBig3> parser3;
|
||||
#else
|
||||
ttmath::Parser<ttmath::Big<1,3> > parser1;
|
||||
ttmath::Parser<TTMathBig1> parser1;
|
||||
#endif
|
||||
|
||||
ttmath::Objects variables, functions;
|
||||
|
@ -163,31 +157,14 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
template<class ValueType>
|
||||
int Conversion(ValueType & result)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
if( CanWeConvert() )
|
||||
{
|
||||
ValueType vinput, voutput;
|
||||
|
||||
vinput.FromBig( GetPrgRes()->GetLanguages()->ConvertingUnitValue(conv_input_unit) );
|
||||
voutput.FromBig( GetPrgRes()->GetLanguages()->ConvertingUnitValue(conv_output_unit) );
|
||||
|
||||
c += result.Mul(vinput);
|
||||
c += result.Div(voutput);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void AddOutputSuffix(std::string & result)
|
||||
{
|
||||
if( CanWeConvert() )
|
||||
{
|
||||
result += " ";
|
||||
result += GetPrgRes()->GetLanguages()->ConvertingUnitAbbr(country, conv_output_unit);
|
||||
result += GetPrgRes()->GetConvert()->GetUnitAbbr(country, conv_output_unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,10 +183,14 @@ private:
|
|||
try
|
||||
{
|
||||
ValueType result = matparser.stack[i].value;
|
||||
if( Conversion(result) )
|
||||
|
||||
if( CanWeConvert() )
|
||||
{
|
||||
code = ttmath::err_overflow;
|
||||
return 1;
|
||||
if( GetPrgRes()->GetConvert()->Conversion(conv_input_unit, conv_output_unit, result) )
|
||||
{
|
||||
code = ttmath::err_overflow;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( result.ToString(buffer2,base_output, always_scientific, when_scientific, rounding, remove_zeroes, decimal_point) )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -305,6 +305,13 @@ Languages * ProgramResources::GetLanguages()
|
|||
return &languages;
|
||||
}
|
||||
|
||||
|
||||
Convert * ProgramResources::GetConvert()
|
||||
{
|
||||
return &convert;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::SetInstance(HINSTANCE h)
|
||||
{
|
||||
hInstance = h;
|
||||
|
@ -418,11 +425,14 @@ ProgramResources::ProgramResources()
|
|||
y_size_normal = 0;
|
||||
y_size_compact = 0;
|
||||
x_size_min = 0;
|
||||
|
||||
// !!! wrzucic do kontruktora Convert
|
||||
convert.Init();
|
||||
|
||||
conv_type = 0;
|
||||
ConvUnitCheckAll();
|
||||
|
||||
decimal_point = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -755,66 +765,3 @@ int ProgramResources::GetBadLine()
|
|||
return bad_line;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::SetConvType(int c)
|
||||
{
|
||||
conv_type = c;
|
||||
}
|
||||
|
||||
|
||||
int ProgramResources::GetConvType()
|
||||
{
|
||||
return conv_type;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::ConvUnitCheck(int type)
|
||||
{
|
||||
if( conv_unit[type].input < -1 || conv_unit[type].input >= GetLanguages()->ConvertingUnitSize() )
|
||||
conv_unit[type].input = 0;
|
||||
|
||||
if( conv_unit[type].output < -1 || conv_unit[type].output >= GetLanguages()->ConvertingUnitSize() )
|
||||
conv_unit[type].output = 0;
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::ConvUnitCheckAll()
|
||||
{
|
||||
int len = GetLanguages()->ConvertingTypeSize();
|
||||
|
||||
if( static_cast<int>( conv_unit.size() ) != len )
|
||||
conv_unit.resize(len);
|
||||
|
||||
for(int i = 0 ; i<len ; ++i)
|
||||
ConvUnitCheck(i);
|
||||
}
|
||||
|
||||
|
||||
void ProgramResources::SetConvUnit(int type, int input, int output)
|
||||
{
|
||||
int len = GetLanguages()->ConvertingTypeSize();
|
||||
|
||||
if( type >= len )
|
||||
return;
|
||||
|
||||
conv_unit[type].input = input;
|
||||
conv_unit[type].output = output;
|
||||
ConvUnitCheck(type);
|
||||
}
|
||||
|
||||
|
||||
bool ProgramResources::GetConvUnit(int type, int & input, int & output)
|
||||
{
|
||||
int len = GetLanguages()->ConvertingTypeSize();
|
||||
|
||||
if( type >= len )
|
||||
{
|
||||
input = output = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
input = conv_unit[type].input;
|
||||
output = conv_unit[type].output;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include "iniparser.h"
|
||||
#include "languages.h"
|
||||
#include "threadcontroller.h"
|
||||
#include "convert.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -218,12 +219,13 @@ public:
|
|||
|
||||
|
||||
/*!
|
||||
pointers to variables' table, functions' table, the language's object
|
||||
pointers to variables' table, functions' table, the languages' object, convert object
|
||||
and to the characters' buffer
|
||||
*/
|
||||
ttmath::Objects * GetVariables();
|
||||
ttmath::Objects * GetFunctions();
|
||||
Languages * GetLanguages();
|
||||
Convert * GetConvert();
|
||||
char * GetBuffer();
|
||||
unsigned int GetBufferSize();
|
||||
|
||||
|
@ -291,18 +293,6 @@ public:
|
|||
bool GetRemovingZeroes();
|
||||
|
||||
|
||||
/*!
|
||||
these methods set and return the kind of conversion which should be performed
|
||||
|
||||
0 - none
|
||||
1 - ...
|
||||
2 - ...
|
||||
*/
|
||||
void SetConvType(int c);
|
||||
int GetConvType();
|
||||
|
||||
void SetConvUnit(int c, int input, int output);
|
||||
bool GetConvUnit(int c, int & input, int & output);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -315,6 +305,7 @@ private:
|
|||
ttmath::Objects variables;
|
||||
ttmath::Objects functions;
|
||||
Languages languages;
|
||||
Convert convert;
|
||||
volatile ThreadController thread_controller;
|
||||
|
||||
unsigned int buffer_size;
|
||||
|
@ -352,22 +343,7 @@ private:
|
|||
|
||||
int bad_line;
|
||||
|
||||
int conv_type;
|
||||
|
||||
struct ConvUnit
|
||||
{
|
||||
int input, output;
|
||||
|
||||
ConvUnit()
|
||||
{
|
||||
input = output = -1;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<ConvUnit> conv_unit;
|
||||
|
||||
void ConvUnitCheck(int type);
|
||||
void ConvUnitCheckAll();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -189,8 +189,8 @@ BEGIN
|
|||
LTEXT "Rounding",1164,11,36,43,8
|
||||
LTEXT "Decimal point",1169,178,21,68,8
|
||||
COMBOBOX 1170,143,19,29,62,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
CONTROL "remove trailing zeroes",1171,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,143,35,111,10
|
||||
CONTROL "remove trailing zeroes",1171,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,143,35,111,10
|
||||
COMBOBOX 1159,58,33,69,200,CBS_DROPDOWNLIST | WS_TABSTOP
|
||||
CONTROL "Always",1160,"Button",BS_AUTORADIOBUTTON | BS_LEFT |
|
||||
WS_GROUP | WS_TABSTOP,19,65,44,10
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
37
src/tabs.cpp
37
src/tabs.cpp
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -467,8 +467,8 @@ return ListView_FindItem(list, -1, &info);
|
|||
|
||||
void TabConvertFillUpUnitList(HWND list, int conv_type)
|
||||
{
|
||||
Languages * plang = GetPrgRes()->GetLanguages();
|
||||
unsigned int len = plang->ConvertingUnitSize();
|
||||
Convert * pconv = GetPrgRes()->GetConvert();
|
||||
unsigned int len = pconv->GetUnitSize();
|
||||
unsigned int i, index;
|
||||
|
||||
ListView_DeleteAllItems(list);
|
||||
|
@ -479,11 +479,12 @@ void TabConvertFillUpUnitList(HWND list, int conv_type)
|
|||
|
||||
for( i=index=0 ; i<len ; ++i )
|
||||
{
|
||||
if( plang->ConvertingUnitType(i) == conv_type )
|
||||
if( pconv->GetUnitType(i) == conv_type )
|
||||
{
|
||||
item.lParam = i;
|
||||
item.iItem = index++;
|
||||
item.pszText = const_cast<char*>(plang->ConvertingUnit(i));
|
||||
int country = static_cast<unsigned int>(GetPrgRes()->GetLanguages()->GetCurrentLanguage());
|
||||
item.pszText = const_cast<char*>(pconv->GetUnitName(country, i));
|
||||
|
||||
ListView_InsertItem(list, &item);
|
||||
}
|
||||
|
@ -497,11 +498,11 @@ HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
|||
HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
||||
int input, output;
|
||||
|
||||
int convtype = GetPrgRes()->GetConvType();
|
||||
int convtype = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
|
||||
TabConvertFillUpUnitList(list2b, convtype);
|
||||
TabConvertFillUpUnitList(list3b, convtype);
|
||||
GetPrgRes()->GetConvUnit( convtype, input, output);
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit( convtype, input, output);
|
||||
|
||||
if( input >= 0 )
|
||||
{
|
||||
|
@ -543,7 +544,7 @@ HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
|||
return;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->SetConvType( (int)item.lParam );
|
||||
GetPrgRes()->GetConvert()->SetCurrentType( (int)item.lParam );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
|
||||
TabConvertFillUpUnitLists(hWnd);
|
||||
|
@ -570,12 +571,12 @@ HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
|||
if( !ListView_GetItem(list2b, &item) )
|
||||
return;
|
||||
|
||||
int convtype = GetPrgRes()->GetConvType();
|
||||
int convtype = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
int input, output;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->GetConvUnit(convtype, input, output);
|
||||
GetPrgRes()->SetConvUnit(convtype, (int)item.lParam, output );
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit(convtype, input, output);
|
||||
GetPrgRes()->GetConvert()->SetCurrentUnit(convtype, (int)item.lParam, output );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
}
|
||||
|
||||
|
@ -600,12 +601,12 @@ HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
|||
if( !ListView_GetItem(list3b, &item) )
|
||||
return;
|
||||
|
||||
int convtype = GetPrgRes()->GetConvType();
|
||||
int convtype = GetPrgRes()->GetConvert()->GetCurrentType();
|
||||
int input, output;
|
||||
|
||||
GetPrgRes()->GetThreadController()->StopCalculating();
|
||||
GetPrgRes()->GetConvUnit(convtype, input, output);
|
||||
GetPrgRes()->SetConvUnit(convtype, input, (int)item.lParam );
|
||||
GetPrgRes()->GetConvert()->GetCurrentUnit(convtype, input, output);
|
||||
GetPrgRes()->GetConvert()->SetCurrentUnit(convtype, input, (int)item.lParam );
|
||||
GetPrgRes()->GetThreadController()->StartCalculating();
|
||||
}
|
||||
|
||||
|
@ -616,6 +617,7 @@ HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
|||
void SetLanguageTabConvert(HWND hWnd)
|
||||
{
|
||||
Languages * plang = GetPrgRes()->GetLanguages();
|
||||
Convert * pconv = GetPrgRes()->GetConvert();
|
||||
|
||||
SetDlgItemText(hWnd, IDC_STATIC_UNIT_CONVERSION, plang->GuiMessage(Languages::convert_type) );
|
||||
SetDlgItemText(hWnd, IDC_STATIC_UNIT_INPUT, plang->GuiMessage(Languages::convert_input) );
|
||||
|
@ -630,18 +632,19 @@ Languages * plang = GetPrgRes()->GetLanguages();
|
|||
item.mask = LVIF_PARAM | LVIF_TEXT;
|
||||
item.iSubItem = 0;
|
||||
|
||||
unsigned int conv_type_size = plang->ConvertingTypeSize();
|
||||
unsigned int conv_type_size = pconv->GetTypeSize();
|
||||
|
||||
for(unsigned int i = 0 ; i<conv_type_size ; ++i)
|
||||
{
|
||||
item.lParam = i;
|
||||
item.iItem = i;
|
||||
item.pszText = const_cast<char*>(plang->ConvertingType(i));
|
||||
int country = static_cast<unsigned int>(plang->GetCurrentLanguage());
|
||||
item.pszText = const_cast<char*>(pconv->GetTypeName(country, i));
|
||||
|
||||
ListView_InsertItem(list1, &item);
|
||||
}
|
||||
|
||||
int type = FindItem(list1, GetPrgRes()->GetConvType() );
|
||||
int type = FindItem(list1, GetPrgRes()->GetConvert()->GetCurrentType() );
|
||||
if( type != -1 )
|
||||
ListView_SetItemState(list1, type, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
||||
// there'll be generated wm_notify message and the next lists will be changed then
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -48,7 +48,7 @@
|
|||
|
||||
|
||||
/*!
|
||||
here our application starts
|
||||
the application starts here
|
||||
*/
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||
{
|
||||
|
@ -58,6 +58,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
|||
// that everything is initialized before the second thread is started
|
||||
GetPrgRes()->GetLanguages()->InitAll();
|
||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
||||
//GetPrgRes()->GetConvert()->Init();
|
||||
GetPrgRes()->SetNameOfConfigurationFile();
|
||||
GetPrgRes()->ReadFromFile();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007, Tomasz Sowa
|
||||
* Copyright (c) 2006-2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
Loading…
Reference in New Issue