Patch level : 12.0 no-patch

Files correlati     :

Aggiunte funzioni

    // @cmember Aggiunge un intero al campo
    void add(short fld_id, long num, byte hit = 0x0);
    // @cmember Aggiunge un reale al campo
    void add(short fld_id, const real& num, byte hit = 0x0);
    // @cmember Aggiunge un currency al campo
    void add(short fld_id, const TCurrency& num, byte hit = 0x0);
    // @cmember Sottrae un intero al campo
    void sub(short fld_id, const long num, byte hit = 0x0);
    // @cmember Sottrae un reale al campo
    void sub(short fld_id, const real& num, byte hit = 0x0);
    // @cmember Sottrae un currency al campo
    void sub(short fld_id, const TCurrency& num, byte hit = 0x0);
    // @cmember Moltiplica per un intero al campo
    void mul(short fld_id, long num, byte hit = 0x0);
    // @cmember Moltiplica per un reale al campo
    void mul(short fld_id, const real& num, byte hit = 0x0);
    // @cmember Moltiplica per un currency al campo
    void mul(short fld_id, const TCurrency& num, byte hit = 0x0);
    // @cmember Divide per un intero al campo
    void div(short fld_id, const long num, byte hit = 0x0);
    // @cmember Divide per un reale al campo
    void div(short fld_id, const real& num, byte hit = 0x0);
    // @cmember Divide per un currency al campo
    void div(short fld_id, const TCurrency& num, byte hit = 0x0);
    bool active(short fld_id);
This commit is contained in:
Alessandro Bonazzi 2020-04-26 14:47:48 +02:00
parent 0861409fb7
commit 44b05030c4
2 changed files with 110 additions and 3 deletions

View File

@ -982,7 +982,7 @@ long TMask::handler(WINDOW w, EVENT* ep)
for (int y = ROWY; y < rct.bottom; y += ROWY)
{
PNT pt0 = { y, rct.left }, pt1 = { y, rct.right};
PNT pt0 = { (short) y, rct.left }, pt1 = { (short) y, rct.right};
xvt_dwin_draw_set_pos(w, pt0);
xvt_dwin_draw_line(w, pt1);
char text[8]; sprintf(text, "%d", y/ROWY);
@ -1700,6 +1700,86 @@ void TMask::set(short fld_id, const TCurrency& n, byte hit)
set(fld_id, n.get_num().string(), hit);
}
// @cmember Aggiunge un intero al campo
void TMask::add(short fld_id, long num, byte hit)
{
int val = atol(get(fld_id));
val += num;
set(fld_id, val, hit);
}
// @cmember Aggiunge un reale al campo
void TMask::add(short fld_id, const real& num, byte hit)
{
real val(get(fld_id));
val += num;
set(fld_id, val, hit);
}
// @cmember Aggiunge un currency al campo
void TMask::add(short fld_id, const TCurrency& num, byte hit)
{
TCurrency val;
get_currency(fld_id, val);
val += num;
set(fld_id, val, hit);
}
// @cmember Sottrae un currency al campo
void TMask::sub(short fld_id, const TCurrency& num, byte hit)
{
TCurrency val;
get_currency(fld_id, val);
val -= num;
set(fld_id, val, hit);
}
// @cmember Moltiplica per un intero al campo
void TMask::mul(short fld_id, long num, byte hit)
{
int val = atol(get(fld_id));
val *= num;
set(fld_id, val, hit);
}
// @cmember Moltiplica per un reale al campo
void TMask::mul(short fld_id, const real& num, byte hit)
{
real val(get(fld_id));
val *= num;
set(fld_id, val, hit);
}
// @cmember Moltiplica per un currency al campo
void TMask::mul(short fld_id, const TCurrency& num, byte hit)
{
TCurrency f1;
TCurrency f2(num);
get_currency(fld_id, f1);
f2.change_value(f1.get_exchange());
f1 *= f2.get_num();
set(fld_id, f1, hit);
}
void TMask::div(short fld_id, const TCurrency& num, byte hit)
{
TCurrency f1;
TCurrency f2(num);
get_currency(fld_id, f1);
f2.change_value(f1.get_exchange());
f1 /= f2.get_num();
set(fld_id, f2, hit);
}
// @doc EXTERNAL
// @mfunc Permette di attivare/disattivare tutta la maschera

View File

@ -315,9 +315,34 @@ public:
void set(short fld_id, const TCurrency& num, byte hit=0x0);
// @cmember Setta una tutti i campi che hanno come FIELD <p fld_id>
void set(const char* fld_id, const char* str, byte hit=0x0);
// @cmember Aggiunge un intero al campo
void add(short fld_id, long num, byte hit = 0x0);
// @cmember Aggiunge un reale al campo
void add(short fld_id, const real& num, byte hit = 0x0);
// @cmember Aggiunge un currency al campo
void add(short fld_id, const TCurrency& num, byte hit = 0x0);
// @cmember Sottrae un intero al campo
void sub(short fld_id, const long num, byte hit = 0x0) { add(fld_id, -num, hit); }
// @cmember Sottrae un reale al campo
void sub(short fld_id, const real& num, byte hit = 0x0) { add(fld_id, -num, hit); }
// @cmember Sottrae un currency al campo
void sub(short fld_id, const TCurrency& num, byte hit = 0x0);
// @cmember Moltiplica per un intero al campo
void mul(short fld_id, long num, byte hit = 0x0);
// @cmember Moltiplica per un reale al campo
void mul(short fld_id, const real& num, byte hit = 0x0);
// @cmember Moltiplica per un currency al campo
void mul(short fld_id, const TCurrency& num, byte hit = 0x0);
// @cmember Divide per un intero al campo
void div(short fld_id, const long num, byte hit = 0x0) { div(fld_id, 1/num, hit); }
// @cmember Divide per un reale al campo
void div(short fld_id, const real& num, byte hit = 0x0) { div(fld_id, UNO/num, hit); }
// @cmember Divide per un currency al campo
void div(short fld_id, const TCurrency& num, byte hit = 0x0);
// @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di stringa
virtual const TString& get(short fld_id) const;
virtual const TString& get(short fld_id) const;
// @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di long
long get_long(short fld_id) const;
// @cmember Ritorna il contenuto del campo <p fld_id> sotto forma di int
@ -401,6 +426,8 @@ public:
bool empty(short fld_id) { return field(fld_id).empty(); }
// @cmember il campo non è vuoto ?
bool full(short fld_id) { return field(fld_id).full(); }
// @cmember il campo è attivo ?
bool active(short fld_id) { return field(fld_id).active(); }
// @cmember Azzera il campo
void reset(const char* fld_id) { set(fld_id, ""); }