Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
vedi commit precedente


git-svn-id: svn://10.65.10.50/trunk@9772 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2001-06-25 13:34:05 +00:00
parent 7af612c636
commit 45ba42fb12
2 changed files with 105 additions and 22 deletions

View File

@ -1468,27 +1468,66 @@ bool TForm_currency::update()
TCurrency curr = get_currency(); TCurrency curr = get_currency();
if (!_driver) if (!_driver)
{ {
const TExchange& oe = form().output_exchange(); const TExchange* oe = form().output_exchange();
if (!curr.get_exchange().same_value_as(oe)) if (oe != NULL && !curr.get_exchange().same_value_as(*oe))
curr.change_value(oe); curr.change_value(*oe);
} }
// Niente apply_format(), la picture viene ignorata per i TForm_currency // Niente apply_format(), la picture viene ignorata per i TForm_currency
TString80 v;
const TString& pic = picture(); const TString& pic = picture();
const bool dotted = pic.empty() || pic.find('.') > 0; if (pic.find("LETTERE") >= 0)
TString80 v = curr.string(dotted);
if (pic.right(3) == "^^^") // 770 only: to be improved
{ {
const int dec = curr.decimals(); v = get();
if (dec == 0) apply_format(v);
v.rtrim(3+dotted); const int slash = v.rfind('/');
TString16 tail;
for (int i = v.len()-1; i > 0 && !isalnum(v[i]); i--)
{
tail << v[i];
v.cut(i);
}
const TCurrency cur = get_currency();
const int zeroes_needed = cur.decimals();
if (zeroes_needed > 0)
{
int zeroes_missing = 0;
if (slash >= 0)
{
const int decimals_already_there = v.len() - slash - 1;
zeroes_missing = zeroes_needed - decimals_already_there;
}
else
{
v << '/';
zeroes_missing = zeroes_needed;
}
for ( ; zeroes_missing > 0; zeroes_missing--)
v << '0';
}
else else
v.rtrim(dec+1); {
if (slash >= 0)
v.cut(slash);
}
v << tail;
}
else
{
const bool dotted = pic.empty() || pic.find('.') > 0;
v = curr.string(dotted);
if (pic.right(3) == "^^^") // 770 only: to be improved
{
const int dec = curr.decimals();
if (dec == 0)
v.rtrim(3+dotted);
else
v.rtrim(dec+1);
}
const int w = width() - (_section->columnwise() ? _prompt.len() : 0);
if (w > v.len())
v.right_just(w);
} }
const int w = width() - (_section->columnwise() ? _prompt.len() : 0);
if (w > v.len())
v.right_just(w);
put_paragraph(v); put_paragraph(v);
} }
else else
@ -1506,8 +1545,14 @@ bool TForm_currency::update()
} }
else else
{ {
const TCurrency z(ZERO, form().output_exchange(), _flag.price != 0); const TExchange* oe = form().output_exchange();
d = z.decimals(); if (oe != NULL)
{
const TCurrency z(ZERO, *oe, _flag.price != 0);
d = z.decimals();
}
else
d = TCurrency::get_firm_dec(_flag.price != 0);
} }
if (d > 0) if (d > 0)
@ -1528,9 +1573,6 @@ bool TForm_currency::update()
return TRUE; return TRUE;
} }
return TRUE;
}
void TForm_currency::send_message(const TString& cmd, TForm_item& dest) const void TForm_currency::send_message(const TString& cmd, TForm_item& dest) const
{ {
if (cmd == "ADD") if (cmd == "ADD")

View File

@ -1284,7 +1284,7 @@ bool real::is_natural (const char *s)
} }
// Certified 75% // Certified 75%
char *real ::literals () const char* real::literals() const
{ {
const char *primi20[] = const char *primi20[] =
{"", "uno", "due", "tre", "quattro", {"", "uno", "due", "tre", "quattro",
@ -1303,7 +1303,7 @@ char *real ::literals () const
{"", "mila", "milioni", "miliardi"}; {"", "mila", "milioni", "miliardi"};
real tmp_real = *this; real tmp_real = *this;
tmp_real.round(); tmp_real.trunc();
TString r (tmp_real.string (0, 0)); TString r (tmp_real.string (0, 0));
const bool negativo = r[0] == '-'; const bool negativo = r[0] == '-';
@ -1367,11 +1367,52 @@ char *real ::literals () const
risultato.insert(centinaia, 0); risultato.insert(centinaia, 0);
} }
if (tmp_real != *this) // Ci sono dei decimali!
{
TString80 res = risultato;
const real tmp_dec = abs(*this - tmp_real);
TString80 str = tmp_dec.string();
str.ltrim(2); str.cut(3);
res << '/' << str;
risultato = res;
}
if (negativo) if (negativo)
risultato.insert ("meno", 0); risultato.insert ("meno", 0);
return __string; return __string;
} }
// Certified 75%
char* real::points (int dec) const
{
const char *str = stringa (0, dec);
const int neg = (*str == '-') ? 1 : 0;
TFixed_string n ((char *)str, 64);
int i;
int dot = n.find (',');
if (dot < 0)
dot = n.len ();
if (dec > 0)
{
if (n[dot] == '\0')
n << ',';
const int d = strlen (str + dot + 1); // Decimals already there
if (d <= dec)
for (i = d; i < dec; i++)
n << '0';
else
n.cut (dot + dec + 1);
}
for (i = dot - 3; i > neg; i -= 3)
n.insert (".", i);
return __string;
}
HIDDEN int get_picture_decimals (const TString& picture, char& decsep) HIDDEN int get_picture_decimals (const TString& picture, char& decsep)
{ {
int decimali = 0; int decimali = 0;