Aggiunto oggetto TCursor_sheet_recno; innestato nella TSelection_mask al

posto dei normali TCursor_sheet. L'oggetto in questione ha in piu' un
TBit_array utilizzato nei filtri delle stampe scadenzario/scaduto. Ogni
elemento di questo TBit_array e' posto a uno in corrispondenza del
numero di record del CLI/FO o CONTO selezionato.
Sono state apportate le dovute modifiche ai metodi di TSelection_mask
che ritornano i TCursor_sheet ed in piu' sono stati resi virtuali 2
metodi (reset_sheet e cur_sheet) per una classe derivata da usare sempre
in stampa scadenzario/scaduto.
In scselmsk.h sono stati aggiunti alcuni identificatori (Relativi a PCON).


git-svn-id: svn://10.65.10.50/trunk@2224 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1995-12-01 16:35:31 +00:00
parent e057d0b9f7
commit 2b33f854d2
3 changed files with 172 additions and 89 deletions

View File

@ -1,5 +1,58 @@
#include "scselect.h" #include "scselect.h"
///////////////////////////////////////////////////////////////////////////////
// TCursor_sheet_recno //
///////////////////////////////////////////////////////////////////////////////
TCursor_sheet_recno::TCursor_sheet_recno(TCursor * cursor, const char* fields,
const char * title, const char * head, byte buttons)
: TCursor_sheet(cursor, fields, title, head, buttons)
{
_recnos.reset();
}
bool TCursor_sheet_recno::on_key(KEY k)
{
switch(k)
{
case K_SPACE:
{
*cursor() = selected(); // Posiziona il cursore
rec_check(cursor()->file().recno(), !checked(selected()));
break;
}
case K_F2:
rec_uncheck(-1);
break;
case K_F3:
rec_check(-1);
break;
default:
break;
}
return TCursor_sheet::on_key(k);
}
void TCursor_sheet_recno::rec_check(long n, bool on)
{
if (n < 0)
{
if (on)
{
_recnos.set(cursor()->size()); // Force the size of Bit_array
_recnos.set();
}
else
_recnos.reset();
}
else
_recnos.set(n, on);
}
///////////////////////////////////////////////////////////////////////////////
// TSelection_mask //
///////////////////////////////////////////////////////////////////////////////
TSelection_mask::TSelection_mask(const char* name) TSelection_mask::TSelection_mask(const char* name)
: TMask(name), _who('C'), _key(1), _clifo_rel(NULL), : TMask(name), _who('C'), _key(1), _clifo_rel(NULL),
_cli_cur_k1(NULL), _cli_cur_k2(NULL), _for_cur_k1(NULL), _for_cur_k2(NULL) _cli_cur_k1(NULL), _cli_cur_k2(NULL), _for_cur_k1(NULL), _for_cur_k2(NULL)
@ -7,24 +60,22 @@ TSelection_mask::TSelection_mask(const char* name)
// crea relazioni, cursori e cursor_sheets // crea relazioni, cursori e cursor_sheets
_clifo_rel = new TRelation(LF_CLIFO); _clifo_rel = new TRelation(LF_CLIFO);
TRectype filter(LF_CLIFO); _cli_cur_k1 = new TCursor(_clifo_rel, "TIPOCF=\"C\"", 1);
filter.put("TIPOCF", "C"); _cli_cur_k2 = new TCursor(_clifo_rel, "TIPOCF=\"C\"", 2);
_cli_cur_k1 = new TCursor(_clifo_rel, "", 1, &filter, &filter);
_cli_cur_k2 = new TCursor(_clifo_rel, "", 2, &filter, &filter);
_cli_sh_k1 = new TCursor_sheet(_cli_cur_k1, " |CODCF|RAGSOC", "Selezione clienti per codice",
_cli_sh_k1 = new TCursor_sheet_recno(_cli_cur_k1, " |CODCF|RAGSOC", "Selezione clienti per codice",
"@1|Codice|Ragione Sociale@50"); "@1|Codice|Ragione Sociale@50");
_cli_sh_k2 = new TCursor_sheet(_cli_cur_k2, " |RAGSOC|CODCF", "Selezione clienti per ragione sociale", _cli_sh_k2 = new TCursor_sheet_recno(_cli_cur_k2, " |RAGSOC|CODCF", "Selezione clienti per ragione sociale",
"@1|Ragione Sociale@50|Codice"); "@1|Ragione Sociale@50|Codice");
if (id2pos(SC_CLIFO) >= 0) if (id2pos(SC_CLIFO) >= 0)
{ {
filter.put("TIPOCF", "F"); _for_cur_k1 = new TCursor(_clifo_rel, "TIPOCF=\"F\"", 1);
_for_cur_k1 = new TCursor(_clifo_rel, "", 1, &filter, &filter); _for_cur_k2 = new TCursor(_clifo_rel, "TIPOCF=\"F\"", 2);
_for_cur_k2 = new TCursor(_clifo_rel, "", 2, &filter, &filter); _for_sh_k1 = new TCursor_sheet_recno(_for_cur_k1, " |CODCF|RAGSOC", "Selezione fornitori per codice",
_for_sh_k1 = new TCursor_sheet(_for_cur_k1, " |CODCF|RAGSOC", "Selezione fornitori per codice",
"@1|Codice|Ragione Sociale@50"); "@1|Codice|Ragione Sociale@50");
_for_sh_k2 = new TCursor_sheet(_for_cur_k2, " |RAGSOC|CODCF", "Selezione fornitori per ragione sociale", _for_sh_k2 = new TCursor_sheet_recno(_for_cur_k2, " |RAGSOC|CODCF", "Selezione fornitori per ragione sociale",
"@1|Ragione Sociale@50|Codice"); "@1|Ragione Sociale@50|Codice");
} }
@ -60,24 +111,28 @@ void TSelection_mask::set_handler(short fld_id, CONTROL_HANDLER handler)
fld(pos).set_handler(handler); fld(pos).set_handler(handler);
} }
TCursor_sheet& TSelection_mask::cur_sheet() TCursor_sheet_recno& TSelection_mask::cur_sheet()
{ {
TCursor_sheet* cs; TCursor_sheet_recno* cs;
if (get_key() == 1) cs = get_who() == 'C' ? _cli_sh_k1 : _for_sh_k1; if (get_key() == 1) cs = get_who() == 'C' ? _cli_sh_k1 : _for_sh_k1;
else cs = get_who() == 'C' ? _cli_sh_k2 : _for_sh_k2; else cs = get_who() == 'C' ? _cli_sh_k2 : _for_sh_k2;
CHECK(cs, "Can't use a NULL TCursor_sheet"); CHECK(cs, "Can't use a NULL TCursor_sheet_recno");
return *cs; return *cs;
} }
void TSelection_mask::reset_sheets() void TSelection_mask::reset_sheets()
{ {
_cli_sh_k1->uncheck(-1); _cli_sh_k1->uncheck(-1);
_cli_sh_k1->rec_uncheck(-1);
_cli_sh_k2->uncheck(-1); _cli_sh_k2->uncheck(-1);
_cli_sh_k2->rec_uncheck(-1);
if (_for_sh_k1) if (_for_sh_k1)
{ {
_for_sh_k1->uncheck(-1); _for_sh_k1->uncheck(-1);
_for_sh_k1->rec_uncheck(-1);
_for_sh_k2->uncheck(-1); _for_sh_k2->uncheck(-1);
_for_sh_k2->rec_uncheck(-1);
} }
reset(SC_CFCODFR); reset(SC_CFCODFR);
reset(SC_CFCODTO); reset(SC_CFCODTO);
@ -88,7 +143,7 @@ void TSelection_mask::reset_sheets()
// Seleziona tutti i clienti con codice compreso tra due estremi // Seleziona tutti i clienti con codice compreso tra due estremi
void TSelection_mask::select_clifo_range(long from, long to) void TSelection_mask::select_clifo_range(long from, long to)
{ {
TCursor_sheet& c = cur_sheet(); TCursor_sheet_recno& c = cur_sheet();
const long items = c.items(); const long items = c.items();
const int key = get_key(); const int key = get_key();
@ -118,12 +173,16 @@ void TSelection_mask::select_clifo_range(long from, long to)
if (cod >= from && cod <= to) if (cod >= from && cod <= to)
{ {
c.check(i); c.check(i);
c.rec_check(i);
nsel ++; nsel ++;
if (firs == 0l) firs = cod; if (firs == 0l) firs = cod;
last = cod; last = cod;
} }
else c.uncheck(i); else
{
c.uncheck(i);
c.rec_uncheck(i);
}
if (cod == from) cod1ok = TRUE; if (cod == from) cod1ok = TRUE;
if (cod == to) cod2ok = TRUE; if (cod == to) cod2ok = TRUE;
} }
@ -141,7 +200,7 @@ void TSelection_mask::set_clifo_limits()
{ {
long first = 0, last = 0, nsel = 0; long first = 0, last = 0, nsel = 0;
TCursor_sheet& c = cur_sheet(); TCursor_sheet_recno& c = cur_sheet();
const long items = c.items(); const long items = c.items();
const int key = get_key(); const int key = get_key();
@ -172,7 +231,7 @@ bool TSelection_mask::bfrom_handler(TMask_field& f, KEY k)
if (k == K_SPACE) if (k == K_SPACE)
{ {
TSelection_mask& m = (TSelection_mask&)f.mask(); TSelection_mask& m = (TSelection_mask&)f.mask();
TCursor_sheet& c = m.cur_sheet(); TCursor_sheet_recno& c = m.cur_sheet();
c.disable_check(); c.disable_check();
if (c.run() == K_ENTER) if (c.run() == K_ENTER)
@ -192,7 +251,7 @@ bool TSelection_mask::bto_handler(TMask_field& f, KEY k)
if (k == K_SPACE) if (k == K_SPACE)
{ {
TSelection_mask& m = (TSelection_mask&)f.mask(); TSelection_mask& m = (TSelection_mask&)f.mask();
TCursor_sheet& c = m.cur_sheet(); TCursor_sheet_recno& c = m.cur_sheet();
c.disable_check(); c.disable_check();
if (c.run() == K_ENTER) if (c.run() == K_ENTER)
{ {
@ -260,7 +319,7 @@ bool TSelection_mask::bselect_handler(TMask_field& f, KEY k)
if (k == K_SPACE) if (k == K_SPACE)
{ {
TSelection_mask& m = (TSelection_mask&)f.mask(); TSelection_mask& m = (TSelection_mask&)f.mask();
TCursor_sheet& c = m.cur_sheet(); TCursor_sheet_recno& c = m.cur_sheet();
c.enable_check(); c.enable_check();
c.run(); c.run();
m.set_clifo_limits(); m.set_clifo_limits();

View File

@ -1,68 +1,83 @@
#ifndef __SCSELECT_H #ifndef __SCSELECT_H
#define __SCSELECT_H #define __SCSELECT_H
#ifndef __MASK_H #ifndef __MASK_H
#include <mask.h> #include <mask.h>
#endif #endif
#ifndef __RELATION_H #ifndef __RELATION_H
#include <relation.h> #include <relation.h>
#endif #endif
#ifndef __SHEET_H #ifndef __SHEET_H
#include <sheet.h> #include <sheet.h>
#endif #endif
#ifndef __SCSELMSK_H #ifndef __SCSELMSK_H
#include "scselmsk.h" #include "scselmsk.h"
#endif #endif
class TSelection_mask : public TMask class TCursor_sheet_recno : public TCursor_sheet
{ {
TRelation* _clifo_rel; TBit_array _recnos;
TCursor* _cli_cur_k1;
TCursor* _cli_cur_k2; protected:
TCursor* _for_cur_k1; virtual bool on_key(KEY k);
TCursor* _for_cur_k2; public:
TCursor_sheet_recno(TCursor * cursor, const char* fields,
TCursor_sheet* _cli_sh_k1; const char * title, const char * head, byte buttons = 0);
TCursor_sheet* _cli_sh_k2; virtual ~TCursor_sheet_recno() {}
TCursor_sheet* _for_sh_k1; bool rec_checked(TRecnotype n) { return _recnos[n]; }
TCursor_sheet* _for_sh_k2; void rec_check(TRecnotype n, bool on = TRUE) ;
void rec_uncheck(TRecnotype n) { rec_check(n,FALSE); }
char _who; };
int _key;
class TSelection_mask : public TMask
protected: // TMask {
virtual void set_handler(short fld_id, CONTROL_HANDLER handler); TRelation* _clifo_rel;
TCursor* _cli_cur_k1;
protected: TCursor* _cli_cur_k2;
void select_clifo_range(long from, long to); TCursor* _for_cur_k1;
void set_clifo_limits(); TCursor* _for_cur_k2;
void set_who(char w) { _who = w; } TCursor_sheet_recno* _cli_sh_k1;
void set_key (int k) { _key = k; } TCursor_sheet_recno* _cli_sh_k2;
TCursor_sheet_recno* _for_sh_k1;
void reset_sheets(); TCursor_sheet_recno* _for_sh_k2;
// handlers char _who;
static bool bfrom_handler(TMask_field& f, KEY k); int _key;
static bool bto_handler(TMask_field& f, KEY k);
static bool ffrom_handler(TMask_field& f, KEY k); protected: // TMask
static bool fto_handler(TMask_field& f, KEY k); virtual void set_handler(short fld_id, CONTROL_HANDLER handler);
static bool breset_handler(TMask_field& f, KEY k);
static bool bselect_handler(TMask_field& f, KEY k); protected:
static bool rclifo_handler(TMask_field& f, KEY k); void select_clifo_range(long from, long to);
static bool rsortcf_handler(TMask_field& f, KEY k); void set_clifo_limits();
public: void set_who(char w) { _who = w; }
TCursor_sheet& cur_sheet(); void set_key (int k) { _key = k; }
char get_who() const { return _who; } virtual void reset_sheets();
int get_key() const { return _key; }
// handlers
TSelection_mask(const char* name); static bool bfrom_handler(TMask_field& f, KEY k);
virtual ~TSelection_mask(); static bool bto_handler(TMask_field& f, KEY k);
}; static bool ffrom_handler(TMask_field& f, KEY k);
static bool fto_handler(TMask_field& f, KEY k);
#endif static bool breset_handler(TMask_field& f, KEY k);
static bool bselect_handler(TMask_field& f, KEY k);
static bool rclifo_handler(TMask_field& f, KEY k);
static bool rsortcf_handler(TMask_field& f, KEY k);
public:
virtual TCursor_sheet_recno& cur_sheet();
char get_who() const { return _who; }
int get_key() const { return _key; }
TSelection_mask(const char* name);
virtual ~TSelection_mask();
};
#endif

View File

@ -12,6 +12,15 @@
#define SC_CLIFO 309 #define SC_CLIFO 309
#define SC_SORTCF 310 #define SC_SORTCF 310
#define SC_NSEL 311 #define SC_NSEL 311
#define SC_SORTCFPCON 312
#define SC_PCONCODFR1 313
#define SC_PCONCODFR2 314
#define SC_PCONCODFR3 315
#define SC_PCONCODTO1 316
#define SC_PCONCODTO2 317
#define SC_PCONCODTO3 318
#define SC_PCONBUTFR 319
#define SC_PCONBUTTO 320
#define BASE_EC_PROFILE "PEC" #define BASE_EC_PROFILE "PEC"