From 44b05030c410b84400fd0ec7838ff77dffcdc8b1 Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Sun, 26 Apr 2020 14:47:48 +0200 Subject: [PATCH] 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); --- src/include/mask.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++- src/include/mask.h | 31 +++++++++++++++-- 2 files changed, 110 insertions(+), 3 deletions(-) diff --git a/src/include/mask.cpp b/src/include/mask.cpp index dcbf281bf..52ffea161 100755 --- a/src/include/mask.cpp +++ b/src/include/mask.cpp @@ -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 diff --git a/src/include/mask.h b/src/include/mask.h index d18453ad0..3a400e20a 100755 --- a/src/include/mask.h +++ b/src/include/mask.h @@ -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

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

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

sotto forma di long long get_long(short fld_id) const; // @cmember Ritorna il contenuto del campo

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, ""); }