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:
parent
7af612c636
commit
45ba42fb12
@ -1468,27 +1468,66 @@ bool TForm_currency::update()
|
||||
TCurrency curr = get_currency();
|
||||
if (!_driver)
|
||||
{
|
||||
const TExchange& oe = form().output_exchange();
|
||||
if (!curr.get_exchange().same_value_as(oe))
|
||||
curr.change_value(oe);
|
||||
const TExchange* oe = form().output_exchange();
|
||||
if (oe != NULL && !curr.get_exchange().same_value_as(*oe))
|
||||
curr.change_value(*oe);
|
||||
}
|
||||
|
||||
// Niente apply_format(), la picture viene ignorata per i TForm_currency
|
||||
TString80 v;
|
||||
const TString& pic = picture();
|
||||
const bool dotted = pic.empty() || pic.find('.') > 0;
|
||||
|
||||
TString80 v = curr.string(dotted);
|
||||
if (pic.right(3) == "^^^") // 770 only: to be improved
|
||||
if (pic.find("LETTERE") >= 0)
|
||||
{
|
||||
const int dec = curr.decimals();
|
||||
if (dec == 0)
|
||||
v.rtrim(3+dotted);
|
||||
v = get();
|
||||
apply_format(v);
|
||||
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
|
||||
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);
|
||||
}
|
||||
else
|
||||
@ -1505,9 +1544,15 @@ bool TForm_currency::update()
|
||||
d = z.decimals();
|
||||
}
|
||||
else
|
||||
{
|
||||
const TCurrency z(ZERO, form().output_exchange(), _flag.price != 0);
|
||||
d = z.decimals();
|
||||
{
|
||||
const TExchange* oe = form().output_exchange();
|
||||
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)
|
||||
@ -1528,9 +1573,6 @@ bool TForm_currency::update()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TForm_currency::send_message(const TString& cmd, TForm_item& dest) const
|
||||
{
|
||||
if (cmd == "ADD")
|
||||
|
@ -1284,7 +1284,7 @@ bool real::is_natural (const char *s)
|
||||
}
|
||||
|
||||
// Certified 75%
|
||||
char *real ::literals () const
|
||||
char* real::literals() const
|
||||
{
|
||||
const char *primi20[] =
|
||||
{"", "uno", "due", "tre", "quattro",
|
||||
@ -1303,7 +1303,7 @@ char *real ::literals () const
|
||||
{"", "mila", "milioni", "miliardi"};
|
||||
|
||||
real tmp_real = *this;
|
||||
tmp_real.round();
|
||||
tmp_real.trunc();
|
||||
|
||||
TString r (tmp_real.string (0, 0));
|
||||
const bool negativo = r[0] == '-';
|
||||
@ -1366,12 +1366,53 @@ char *real ::literals () const
|
||||
|
||||
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)
|
||||
risultato.insert ("meno", 0);
|
||||
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)
|
||||
{
|
||||
int decimali = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user