fixed: the pad window didn't take into account following options (from display tab):

grouping, input commas and parameter separators
added:   some more info on update dialog (when the update is not available)


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@257 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2009-12-05 18:30:33 +00:00
parent 6f6948087c
commit 48d182a05f
11 changed files with 224 additions and 107 deletions

View File

@ -1,3 +1,30 @@
Version 0.9.1 prerelease (2009.12.05):
* fixed: the pad window didn't take into account following options (from display tab):
grouping, input commas and parameter separators
Changes from TTMath 0.9.1 prerelease relating to TTCalc:
* fixed: the parser didn't use characters for changing the base (# and &)
those characters were skipped
(this bug was introduced in 0.9.0)
* added: to Big::ToString() - additional rounding when conv.base_round is used
if the value is not an integer we calculate how many valid digits there are
after the comma operator (in conv.base radix) and then we skipped the rest
digits, after skipping the base-rounding is made
this helps to print values which have some last clear bits in the mantissa
consider this 32 bit value:
(binary)0.00011100001010001111010111000000000
which has mantissa equal: (binary)11100001010001111010111000000000 (32 bits)
previous the ToString() method gave: (decimal)0.10999999[...]
now we have: (decimal)0.11
* added: Parser::SetSmallToZero(bool zero) (default true)
if true then the parser changes small values into zero
small value means:
- if the mantissa of the value consists only of one, two or three set bits
- and these bits are next to each other
- and the exponent is smaller than about 2 times the number of bits from the mantissa
this helps to correctly calculate expressions such as: "0.80-3*0.34+0.22"
now the parser gives zero (previous there was a value very closed to zero)
Version 0.9.0 (2009.11.25):
* fixed: when 'C' button was pressed, the cursor was not placed in the edit window
* added: Pad window - a multiline edit window

View File

@ -55,8 +55,8 @@
*/
#define TTCALC_MAJOR_VER 0
#define TTCALC_MINOR_VER 9
#define TTCALC_REVISION_VER 0
#define TTCALC_PRERELEASE_VER 0
#define TTCALC_REVISION_VER 1
#define TTCALC_PRERELEASE_VER 1

View File

@ -1,4 +1,3 @@
/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
@ -36,6 +35,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstdio>
#include "compileconfig.h"
#include "download.h"
@ -119,10 +119,17 @@ DWORD read;
bool Download::DownloadUrl(const char * url)
{
bool res = true;
char browser[100];
down_size = 0;
sprintf(browser, "TTCalc updater %d.%d.%d%s",
TTCALC_MAJOR_VER,
TTCALC_MINOR_VER,
TTCALC_REVISION_VER,
(TTCALC_PRERELEASE_VER>0)? " prerelease" : "");
HINTERNET hint = InternetOpen("TTCalcAutoUpdate",INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0);
HINTERNET hint = InternetOpen(browser,INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0);
if( !hint )
return false;

View File

@ -535,7 +535,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(update_check_at_startup, "Always check for the update on startup");
InsertGuiPair(update_check_for_info, "Press Next to check for the update...");
InsertGuiPair(update_is_new_version, "Version %d.%d.%d is available, press Next to download...");
InsertGuiPair(update_no_new_version, "There is not a new version available.");
InsertGuiPair(update_no_new_version1, "There is not a newer version available.");
InsertGuiPair(update_no_new_version2, "You have the newest version.");
InsertGuiPair(update_download_from, "Downloading from...");
#ifndef TTCALC_PORTABLE
InsertGuiPair(update_downloaded_info1, "A new setup program has been downloaded.");
@ -730,7 +731,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(update_check_at_startup, "Zawsze sprawdzaj aktualizacje podczas uruchamiania");
InsertGuiPair(update_check_for_info, "Wciœnij Dalej aby sprawdziæ dostêpnoœæ aktualizacji...");
InsertGuiPair(update_is_new_version, "Wersja %d.%d.%d jest dostêpna, wciœnij Dalej aby j¹ pobraæ...");
InsertGuiPair(update_no_new_version, "Nie ma dostêpnej nowej wersji programu.");
InsertGuiPair(update_no_new_version1, "Nie ma dostêpnej nowszej wersji programu.");
InsertGuiPair(update_no_new_version2, "Obecnie masz najnowsz¹ wersjê.");
InsertGuiPair(update_download_from, "Pobieranie z...");
#ifndef TTCALC_PORTABLE
InsertGuiPair(update_downloaded_info1, "Nowy instalator zosta³ œci¹gniêty.");
@ -930,7 +932,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(update_check_at_startup, "Comprobar siempre al comienzo si hay una nueva versión");
InsertGuiPair(update_check_for_info, "Pulse Siguiente para ver si hay actualizaciones...");
InsertGuiPair(update_is_new_version, "La versión %d.%d.%d está disponible, pulse Siguiente para descargar...");
InsertGuiPair(update_no_new_version, "No hay versiones nuevas disponibles.");
InsertGuiPair(update_no_new_version1, "No hay versiones nuevas disponibles.");
InsertGuiPair(update_no_new_version2, "");
InsertGuiPair(update_download_from, "Descargando desde...");
#ifndef TTCALC_PORTABLE
InsertGuiPair(update_downloaded_info1, "Se ha descargado un nuevo programa de instalación.");
@ -1126,7 +1129,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(update_check_at_startup, "Tjek altid for opdateringer ved opstart");
InsertGuiPair(update_check_for_info, "Tryk på Næste for at tjekke for opdateringen...");
InsertGuiPair(update_is_new_version, "Version %d.%d.%d er tilgængelig, tryk på Næste for at downloade...");
InsertGuiPair(update_no_new_version, "Der er ingen ny version tilgængelig.");
InsertGuiPair(update_no_new_version1, "Der er ingen ny version tilgængelig.");
InsertGuiPair(update_no_new_version2, "");
InsertGuiPair(update_download_from, "Downloader fra...");
#ifndef TTCALC_PORTABLE
InsertGuiPair(update_downloaded_info1, "Et nyt installerings program er blevet downloadet.");
@ -1318,7 +1322,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(update_check_at_startup, "Always check for the update on startup");
InsertGuiPair(update_check_for_info, "Press Next to check for the update...");
InsertGuiPair(update_is_new_version, "Version %d.%d.%d is available, press Next to download...");
InsertGuiPair(update_no_new_version, "There is not a new version available.");
InsertGuiPair(update_no_new_version1, "There is not a newer version available.");
InsertGuiPair(update_no_new_version2, "You have the newest version.");
InsertGuiPair(update_download_from, "Downloading from...");
#ifndef TTCALC_PORTABLE
InsertGuiPair(update_downloaded_info1, "A new setup program has been downloaded.");
@ -1518,7 +1523,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(update_check_at_startup, "Ïðîâåðÿòü íàëè÷èå îáíîâëåíèé ïðè çàãðóçêå ïðîãðàììû");
InsertGuiPair(update_check_for_info, "Íàæìèòå Äàëåå, ÷òîáû ïðîâåðèòü íàëè÷èå îáíîâëåíèé...");
InsertGuiPair(update_is_new_version, "Äîñòóïíà âåðñèÿ %d.%d.%d, íàæìèòå Äàëåå, ÷òîáû ñêà÷àòü å¸...");
InsertGuiPair(update_no_new_version, "Íåò íîâûõ âåðñèé.");
InsertGuiPair(update_no_new_version1, "Íåò íîâûõ âåðñèé.");
InsertGuiPair(update_no_new_version2, "");
InsertGuiPair(update_download_from, "Çàãðóæàåì ñ...");
#ifndef TTCALC_PORTABLE
InsertGuiPair(update_downloaded_info1, "Íîâûé äèñòðèáóòèâ çàãðóæåí.");
@ -1712,7 +1718,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(update_check_at_startup, "Always check for the update on startup");
InsertGuiPair(update_check_for_info, "Press Next to check for the update...");
InsertGuiPair(update_is_new_version, "Version %d.%d.%d is available, press Next to download...");
InsertGuiPair(update_no_new_version, "There is not a new version available.");
InsertGuiPair(update_no_new_version1, "There is not a newer version available.");
InsertGuiPair(update_no_new_version2, "You have the newest version.");
InsertGuiPair(update_download_from, "Downloading from...");
#ifndef TTCALC_PORTABLE
InsertGuiPair(update_downloaded_info1, "A new setup program has been downloaded.");

View File

@ -162,7 +162,8 @@ public:
update_check_at_startup,
update_check_for_info,
update_is_new_version,
update_no_new_version,
update_no_new_version1,
update_no_new_version2,
update_download_from,
update_downloaded_info1,
update_downloaded_info2,

View File

@ -61,10 +61,20 @@ int when_scientific;
int rounding;
bool remove_zeroes;
int angle_deg_rad_grad;
char decimal_point;
char grouping;
char input_comma1;
char input_comma2;
char param_sep;
Languages::Country country;
int last_variables_id;
int last_functions_id;
ttmath::Objects * variables;
ttmath::Objects * functions;
ttmath::ErrorCode code;
bool calculated;
@ -114,7 +124,17 @@ unsigned int i = 0;
{
ValueType result = matparser.stack[i].value;
if( result.ToString(res2, base_output, always_scientific, when_scientific, rounding, remove_zeroes, decimal_point) )
ttmath::Conv conv;
conv.base = base_output;
conv.scient = always_scientific;
conv.scient_from = when_scientific;
conv.round = rounding;
conv.trim_zeroes = remove_zeroes;
conv.comma = decimal_point;
conv.group = grouping;
if( result.ToString(res2, conv) )
res2 = GetPrgRes()->GetLanguages()->GuiMessage(country, Languages::overflow_during_printing);
}
catch(...)
@ -217,8 +237,13 @@ void ParseString(ttmath::Parser<ValueType> & matparser)
{
matparser.SetBase(base_input);
matparser.SetDegRadGrad(angle_deg_rad_grad);
matparser.SetFunctions(functions);
matparser.SetComma(input_comma1, input_comma2);
matparser.SetGroup(grouping);
matparser.SetParamSep(param_sep);
matparser.SetSmallToZero(true);
matparser.SetVariables(variables);
matparser.SetFunctions(functions);
code = matparser.Parse(parse_string.c_str());
@ -237,11 +262,11 @@ void SetParameters()
remove_zeroes = GetPrgRes()->GetRemovingZeroes();
angle_deg_rad_grad = GetPrgRes()->GetDegRadGrad();
country = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
decimal_point = GetPrgRes()->GetDecimalPointChar();
grouping = GetPrgRes()->GetGroupingChar();
param_sep = GetPrgRes()->GetParamSepChar();
if( GetPrgRes()->GetDecimalPoint() == 0 )
decimal_point = '.';
else
decimal_point = ',';
GetPrgRes()->GetInputDecimalPointChar(&input_comma1, &input_comma2);
variables = GetPrgRes()->GetVariables();
functions = GetPrgRes()->GetFunctions();

View File

@ -89,6 +89,8 @@ ttmath::ErrorCode ParserManager::GetLastCode()
}
ttmath::ErrorCode ParserManager::Parse()
{
try
@ -98,41 +100,21 @@ ttmath::ErrorCode ParserManager::Parse()
switch( precision )
{
case 0:
parser1.SetBase(base_input);
parser1.SetDegRadGrad(angle_deg_rad_grad);
parser1.SetComma(input_comma1, input_comma2);
parser1.SetGroup(grouping);
parser1.SetParamSep(param_sep);
code = parser1.Parse(buffer);
Parse(parser1);
break;
case 1:
parser2.SetBase(base_input);
parser2.SetDegRadGrad(angle_deg_rad_grad);
parser2.SetComma(input_comma1, input_comma2);
parser2.SetGroup(grouping);
parser2.SetParamSep(param_sep);
code = parser2.Parse(buffer);
Parse(parser2);
break;
default:
parser3.SetBase(base_input);
parser3.SetDegRadGrad(angle_deg_rad_grad);
parser3.SetComma(input_comma1, input_comma2);
parser3.SetGroup(grouping);
parser3.SetParamSep(param_sep);
code = parser3.Parse(buffer);
Parse(parser3);
break;
}
#else
parser1.SetBase(base_input);
parser1.SetDegRadGrad(angle_deg_rad_grad);
parser1.SetComma(input_comma1, input_comma2);
parser1.SetGroup(grouping);
parser1.SetParamSep(param_sep);
code = parser1.Parse(buffer);
Parse(parser1);
#endif
}
@ -170,10 +152,9 @@ unsigned int i;
last_functions_id = GetPrgRes()->GetFunctionsId();
}
//
base_input = GetPrgRes()->GetBaseInput();
base_output = GetPrgRes()->GetBaseOutput();
always_scientific = GetPrgRes()->GetDisplayAlwaysScientific();
when_scientific = GetPrgRes()->GetDisplayWhenScientific();
rounding = GetPrgRes()->GetDisplayRounding();
@ -181,55 +162,14 @@ unsigned int i;
remove_zeroes = GetPrgRes()->GetRemovingZeroes();
angle_deg_rad_grad = GetPrgRes()->GetDegRadGrad();
country = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
decimal_point = GetPrgRes()->GetDecimalPointChar();
grouping = GetPrgRes()->GetGroupingChar();
param_sep = GetPrgRes()->GetParamSepChar();
GetPrgRes()->GetInputDecimalPointChar(&input_comma1, &input_comma2);
conv_type = GetPrgRes()->GetConvert()->GetCurrentType();
GetPrgRes()->GetConvert()->GetCurrentUnit(conv_type, conv_input_unit, conv_output_unit);
if( GetPrgRes()->GetDecimalPoint() == 0 )
decimal_point = '.';
else
decimal_point = ',';
// grouping
static char group_table[] = "\0 `'.,"; // 5 items
int g = GetPrgRes()->GetGrouping();
if( g>=0 && g<=5 )
grouping = group_table[g];
else
grouping = 0;
// input decimal point
switch( GetPrgRes()->GetInputDecimalPoint() )
{
case 0:
input_comma1 = '.';
input_comma2 = ',';
break;
case 1:
input_comma1 = '.';
input_comma2 = 0;
break;
case 2:
default:
input_comma1 = ',';
input_comma2 = 0;
break;
}
// additional param separator
static char param_table[] = ";.,"; // 3 items
g = GetPrgRes()->GetParamSep();
if( g>=0 && g<=3 )
param_sep = param_table[g];
else
param_sep = ';';
}

View File

@ -134,12 +134,13 @@ private:
int precision;
Languages::Country country;
ttmath::ErrorCode code;
char decimal_point;
int angle_deg_rad_grad;
int grouping;
int input_comma1;
int input_comma2;
int param_sep;
char decimal_point;
char grouping;
char input_comma1;
char input_comma2;
char param_sep;
/*
some buffers which we use in some method in the second thread,
@ -230,6 +231,19 @@ private:
return 0;
}
template<class ValueType>
void Parse(ttmath::Parser<ValueType> & matparser)
{
matparser.SetBase(base_input);
matparser.SetDegRadGrad(angle_deg_rad_grad);
matparser.SetComma(input_comma1, input_comma2);
matparser.SetGroup(grouping);
matparser.SetParamSep(param_sep);
matparser.SetSmallToZero(true);
code = matparser.Parse(buffer);
}
};

View File

@ -381,8 +381,78 @@ int ProgramResources::GetDecimalPoint()
}
char ProgramResources::GetDecimalPointChar()
{
char c;
if( GetDecimalPoint() == 0 )
c = '.';
else
c = ',';
return c;
}
char ProgramResources::GetGroupingChar()
{
char c;
// grouping
static char group_table[] = "\0 `'.,"; // 5 items
int g = GetGrouping();
if( g>=0 && g<=5 )
c = group_table[g];
else
c = 0;
return c;
}
void ProgramResources::GetInputDecimalPointChar(char * comma1, char * comma2)
{
// input decimal point
switch( GetInputDecimalPoint() )
{
case 0:
*comma1 = '.';
*comma2 = ',';
break;
case 1:
*comma1 = '.';
*comma2 = 0;
break;
case 2:
default:
*comma1 = ',';
*comma2 = 0;
break;
}
}
char ProgramResources::GetParamSepChar()
{
char c;
// additional param separator
static char param_table[] = ";.,"; // 3 items
int sep = GetParamSep();
if( sep>=0 && sep<=3 )
c = param_table[sep];
else
c = ';';
return c;
}
//
ttmath::Objects * ProgramResources::GetVariables()
{

View File

@ -366,14 +366,6 @@ public:
*/
int GetBadLine();
/*!
setting and returning the decimal point used during printig values
0 - '.'
1 - ','
*/
void SetDecimalPoint(int decimal);
int GetDecimalPoint();
/*!
setting and returning the state of removing trailing zeroes
@ -418,6 +410,12 @@ public:
int GetGrouping();
/*!
returning the grouping character
*/
char GetGroupingChar();
/*!
setting/getting the input decimal point
0 - dot or comma, 1 - dot, 2 - comma
@ -426,14 +424,41 @@ public:
int GetInputDecimalPoint();
/*!
returning the input decimal point characters
*/
void GetInputDecimalPointChar(char * comma1, char * comma2);
/*!
setting and returning the decimal point used during printig values
0 - '.'
1 - ','
*/
void SetDecimalPoint(int decimal);
int GetDecimalPoint();
/*!
returning the decimal point char (used during printig values)
*/
char GetDecimalPointChar();
/*!
setting/getting the separator of function arguments
0 - semicolon, 1 - dot, 2 - comma
0 - semicolon, 1 - semicolon or dot, 2 - semicolon or comma
*/
void SetParamSep(int s);
int GetParamSep();
/*!
returning the character of param separator
either a semicolon, dot or comma
*/
char GetParamSepChar();
/*!
setting/getting the test which is made when the program starts
(testing for an update)

View File

@ -352,7 +352,8 @@ char buffer[200];
else
{
level = 100;
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, pl->GuiMessage(Languages::update_no_new_version));
SetDlgItemText(hwnd, IDC_UPDATE_INFO1, pl->GuiMessage(Languages::update_no_new_version1));
SetDlgItemText(hwnd, IDC_UPDATE_INFO2, pl->GuiMessage(Languages::update_no_new_version2));
SetDlgItemText(hwnd, IDC_BUTTON_NEXT, pl->GuiMessage(Languages::update_button_finish));
ShowWindow(GetDlgItem(hwnd, IDC_PROGRESS), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDC_BUTTON_CANCEL), false);