Aggiunte di pred e suuc agli array ed ai record_array

git-svn-id: svn://10.65.10.50/trunk@1714 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-08-21 07:47:18 +00:00
parent b5da2ff050
commit 82d26224e0
12 changed files with 138 additions and 56 deletions

View File

@ -286,11 +286,38 @@ void TArray::swap(int i1, int i2)
if (o2) add(o2, i1);
}
int TArray::last() const
// @mfunc Cerca il prossimo oggetto dell'array
int TArray::succ(int i) const
// @rdesc Ritorna l'indice del prossimo elemento trovato o size() se non esiste
{
CHECKD(i >= -1, "Bad array index ", i);
for (i++; i < size(); i++)
if (_data[i]) break;
return i;
}
// @mfunc Cerca il precedente oggetto dell'array
int TArray::pred(int i) const
// @rdesc Ritorna l'indice dell'elemento precedente o -1 se non esiste
{
for (int last = size(); --last >= 0; )
if (_data[last]) break;
return last;
CHECKD(i <= size(), "Bad array index ", i);
for (i--; i >= 0; i--)
if (_data[i]) break;
return i;
}
// @mfunc Cerca il primo oggetto dell'array
int TArray::first() const
// @rdesc Ritorna l'indice del primo elemento trovato o size() se l'array e' vuoto
{
return succ(-1);
}
// @mfunc Cerca l'ultimo oggetto dell'array
int TArray::last() const
// @rdesc Ritorna l'indice dell'ultimo elemento trovato o -1 se l'array e' vuoto
{
return pred(size());
}
// @mfunc Rende contigui tutti gli elementi non nulli

View File

@ -66,9 +66,16 @@ public:
// @cmember Ritorna numero di oggetti nell'array
int items() const
{ return _items; }
// @cmember Ritorna l'indice del primo oggetto
int first() const;
// @cmember Ritorna l'indice dell'ultimo oggetto
int last() const;
// @cmember Ritorna l'indice del primo oggetto dopo i
int succ(int i) const;
// @cmember Ritorna l'indice del primo oggetto che precede i
int pred(int i) const;
// @cmember Ritorna l'oggetto puntato da index
TObject& operator[] (int index) const ;
// @cmember Ritorna l'oggetto di posto index

View File

@ -197,6 +197,7 @@ void TMask::handler(WINDOW win, EVENT* ep)
void TMask::init_mask()
{
_sheets = _pages = 0; // Azzera numero pagine e sheets
_sheet = NULL; // Non appartiene a nessuno sheet
_enabled.set(MAX_PAGES);
_enabled.set(); // Abilita tutte le pagine
@ -240,13 +241,11 @@ void TMask::read_mask(
_source_file.lower();
TScanner scanner(_source_file);
_sheetmask = num > 0;
long start_t = clock();
while (clock() == start_t) continue; // Attende scatto timer
start_t = clock();
if (!_sheetmask)
if (num == 0)
_total_time = _build_time = _init_time = 0;
for (int i = 0; i < num; i++)
@ -279,7 +278,7 @@ void TMask::read_mask(
add_buttons();
if (!_sheetmask)
if (num == 0)
_total_time = clock()-start_t;
main_app().end_wait();

View File

@ -9,9 +9,7 @@
#include <maskfld.h>
#endif
#ifndef __REAL_H
#include <real.h>
#endif
class TSheet_field;
// @doc EXTERNAL
@ -63,8 +61,11 @@ class TMask : public TWindow
int _focus;
// @cmember Controllo che deve ricevere il focus
int _next_fld;
// @cmember Numero di sheet
// @cmember Numero di sheet contenuti nella maschera
int _sheets;
// @cmember Puntatore allo sheet che contiene la maschera (puo' essere NULL)
TSheet_field* _sheet;
// @cmember Handler per gestire i tasti speciali nelle maschere
MASK_HANDLER _handler;
@ -79,8 +80,6 @@ class TMask : public TWindow
// @cmember Cambio attuale per i cambi in valuta
real _exchange;
// @cmember Controlla se e' una maschera contenuto in un sheet
bool _sheetmask;
// @cmember Controlla se la maschera deve fare i controlli iniziali di validita' dei campi
bool _should_check;
@ -324,9 +323,18 @@ public:
// @cmember Ritorna il primo campo dirty
short dirty() const;
// @cmember Setta lo sheet che gestisce la maschera
void set_sheet(TSheet_field* s)
{ _sheet = s; }
// @cmember Ritorna lo sheet che gestisce la maschera
TSheet_field* get_sheet()
{ return _sheet; }
// @cmember Ritorna se la maschera e' contenuta in uno sheet (TRUE se contenuta)
bool is_sheetmask() const
{ return _sheetmask; }
{ return _sheet != NULL; }
// @cmember Ritorna TRUE se la maschera non ha modalita' di utilizzo (vedi <t TMaskmode>)
bool no_mode() const

View File

@ -131,7 +131,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
const char* maskname, int maskno,
const char* head, WINDOW parent,
TSheet_field* o)
: _mask(maskname, maskno), _notify(NULL), _edit_field(NULL), /* Matteo */ _getmask( NULL ),
: _mask(maskname, maskno), _notify(NULL), _edit_field(NULL), _getmask( NULL ),
_owner(o), _cur_row(0), _cur_col(0), _active(TRUE),
_row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE),
_needs_update(-1)
@ -142,7 +142,9 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
int fixed_columns = 1; // Number of fixed columns
init();
_mask.set_sheet(o);
// Calcolo larghezza massima tabella
TToken_string header(head);
@ -608,12 +610,10 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
const int oldrec = _cur_rec;
set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column);
if (oldrec != _cur_rec)
{
str2mask(_cur_rec);
_row_dirty = FALSE;
}
update(_cur_rec);
str2mask(_cur_rec);
update(_cur_rec); // Forces update delayed by str2mask
if (_mask.id2pos(FIRST_FIELD-1) != -1)
{
@ -966,7 +966,9 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
TSheet_field* o)
: TArray_sheet(x, y, dx, dy, maskname, head, 0, parent), _owner(o),
_mask(maskname, maskno), _notify(NULL), /* Matteo */ _getmask( NULL )
{}
{
_mask.set_sheet(o);
}
bool TSpreadsheet::on_key(KEY k)
{

15
include/pagsca.h Executable file
View File

@ -0,0 +1,15 @@
#define PAGSCA_NRIGA "NRIGA"
#define PAGSCA_NRATA "NRATA"
#define PAGSCA_NRIGP "NRIGP"
#define PAGSCA_IMPORTO "IMPORTO"
#define PAGSCA_IMPORTOVAL "IMPORTOVAL"
#define PAGSCA_RITENUTE "RITENUTE"
#define PAGSCA_ABBUONI "ABBUONI"
#define PAGSCA_DIFFCAM "DIFFCAM"
#define PAGSCA_CODABI "CODABI"
#define PAGSCA_CODCAB "CODCAB"
#define PAGSCA_CODAG "CODAG"
#define PAGSCA_CODABIPR "CODABIPR"
#define PAGSCA_CODCABPR "CODCABPR"

View File

@ -1,9 +1,14 @@
#ifndef __PARTITE_H
#define __PARTITE_H
#define PART_TIPOCF "TIPOC"
#define PART_GRUPPO "GRUPPO"
#define PART_CONTO "CONTO"
#define PART_SOTTOCONTO "SOTTOCONTO"
#define PART_ANNO "ANNO"
#define PART_NUMPART "NUMPART"
#define PART_NRIGA "NRIGA"
#define PART_TIPOMOV "TIPOMOV"
#define PART_NREG "NREG"
#define PART_NUMRIG "NUMRIG"
@ -14,6 +19,7 @@
#define PART_REG "REG"
#define PART_PROTIVA "PROTIVA"
#define PART_CODCAUS "CODCAUS"
#define PART_SEZ "SEZ"
#define PART_IMPORTO "IMPORTO"
#define PART_IMPOSTA "IMPOSTA"
@ -21,26 +27,16 @@
#define PART_CODPAG "CODPAG"
#define PART_CODVAL "CODVAL"
#define PART_CAMBIO "CAMBIO"
#define PART_IMPORTOVAL "IMPORTOVAL"
#define PART_DATACAM "DATACAM"
#define PART_TIPOCF "TIPOC"
#define PART_GRUPPO "GRUPPO"
#define PART_CONTO "CONTO"
#define PART_SOTTOCONTO "SOTTOCONTO"
#define PART_CODABI "CODABI"
#define PART_CODCAB "CODCAB"
#define PART_CODAG "CODAG"
#define PART_IMPORTOVAL "IMPORTOVAL"
#define PART_IMPTOTPAG "IMPTOTPAG"
#define PART_RITENUTE "RITENUTE"
#define PART_SALACC "SALACC"
#define PART_TIPOPAG "TIPOPAG"
#define PART_ABBUONI "ABBUONI"
#define PART_DIFFCAM "DIFFCAM"
#define PART_SEZABB "SEZABB"
#define PART_SEZDIFCAM "SEZDIFCAM"
#define PART_CHIUSA "CHIUSA"
#define PART_DATARIFPAG "DATARIFPAG"
#define PART_NUMRIFPAG "NUMRIFPAG"
#define PART_NRATA "NRATA"
#define PART_CHIUSA "CHIUSA"
#define PART_CODABIPR "CODABIPR"
#define PART_CODCABPR "CODCABPR"
#define PART_GRUPPOCL "GRUPPOCL"
#define PART_CONTOCL "CONTOCL"
#endif

View File

@ -1056,9 +1056,29 @@ const TImporto& TImporto::swap_section()
}
const TImporto& TImporto::normalize()
{
if (_valore.sign() < 0)
// Normalizza l'importo al parametro s
// Valore Azione
// A Forza la sezione Avere
// D Forza la sezione Dare
// < 0 Forza il segno negativo
// >=0 Forza il segno positivo
const TImporto& TImporto::normalize(char s)
{
bool ex = FALSE;
switch (s)
{
case 'A':
case 'D':
ex = s != _sezione;
break;
default:
if (s < 0)
ex = _valore.sign() > 0;
else
ex = _valore.sign() < 0;
break;
}
if (ex)
{
_valore = -_valore;
swap_section();

View File

@ -248,6 +248,9 @@ public:
// @cmember Ritorna il valore dell'importo
const real& valore() const
{ return _valore; }
// @cmember Ritorna il valore dell'importo
real& valore()
{ return _valore; }
// @cmember Controlla se l'importo e' 0 (in qualsiasi sezione, TRUE se 0)
bool is_zero() const
@ -263,8 +266,8 @@ public:
const TImporto& operator+=(const TImporto& i);
// @cmember Sottrae all'importo l'oggetto passato
const TImporto& operator-=(const TImporto& i);
// @cmember Inverte la sezione se il valore e' minore di 0
const TImporto& normalize();
// @cmember Normalizza il segno o la sezione in base al parametro s
const TImporto& normalize(char s = '\0');
// @cmember Inverte la sezione dell'importo
const TImporto& swap_section();

View File

@ -54,7 +54,6 @@ protected:
TLocalisamfile& file() const { return get_relation()->lfile(); } // File principale della relazione
TRecnotype first() const { return _first;}
TRecnotype last() const { return _first;}
TMask& curr_mask() const { return *_mask; }
const TString& autoins_caller() const { return _autoins_caller;}
virtual bool menu(MENU_TAG m);
@ -106,12 +105,14 @@ protected:
void set_search_field(short id) { _search_id = id;} // Impone il campo da utilizzare col bottone Ricerca
public:
TMask& curr_mask() const { return *_mask; }
TRelation_application();
virtual ~TRelation_application();
bool filtered() const { return _fixed.not_empty(); }
bool find(byte key = 0);
void set_link(TMask & m, const char * keyexpr);
TRelation_application();
virtual ~TRelation_application();
};
#endif

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.56 1995-08-09 09:54:30 guy Exp $
// $Id: relation.cpp,v 1.57 1995-08-21 07:47:12 guy Exp $
// relation.cpp
// fv 12/8/93
// relation class for isam files
@ -1623,14 +1623,14 @@ bool TRecord_array::exist(int n) const
TRectype& TRecord_array::row(int n, bool create)
{
const int i = n > 0 ? n - _offset : -1;
const int i = n >= 0 ? n - _offset : -1;
TRectype* r = (TRectype*)objptr(i);
if (r == NULL && create)
{
r = (TRectype*)key().dup(); // Crea nuovo record copiando la chiave
n = add(r, i) + _offset; // Riassegna n se era negativo!
r->put(_num, n); // Aggiorna campo numero riga
}
}
CHECKD(r && n > 0, "Bad record number ", n);
return *r;
}
@ -1646,8 +1646,9 @@ bool TRecord_array::renum_key(const char* field, const TString& num)
for (int i = last(); i >= 0; i--)
{
TRectype* r = (TRectype*)objptr(i);
if (r != NULL) r->put(field, num);
}
if (r == NULL)
r->put(field, num);
}
return TRUE;
}
@ -1662,7 +1663,7 @@ bool TRecord_array::renum_key(const char* field, long num)
int TRecord_array::rec2row(const TRectype& r) const
{
CHECK(r == key(), "Incompatible record");
CHECK(r.num() == key().num(), "Incompatible record");
const int n = atoi(r.get(_num)) - _offset; // Non e' detto che sia un int!
CHECKD(n >= 0 && n < 30000, "Bad line number in record ", n + _offset);
return n;

View File

@ -1,4 +1,4 @@
/* $Id: relation.h,v 1.24 1995-08-09 09:54:34 guy Exp $ */
/* $Id: relation.h,v 1.25 1995-08-21 07:47:18 guy Exp $ */
// join.h
// fv 12/8/93
// join class for isam files
@ -142,8 +142,11 @@ protected:
public:
const TRectype& key() const;
int rows() const { return items()-1; } // Numero di righe presenti
int succ_row(int r) const { return succ(r - _offset) + _offset; }
int pred_row(int r) const { return pred(r - _offset) + _offset; };
int last_row() const { return last() + _offset; } // Ultima riga
int first_row() const { return 1 + _offset ; } // Prima riga
int first_row() const { return succ_row(0); } // Prima riga
const TRectype& row(int r) const // Riga r costante
{ CHECKD(r > _offset, "Bad record number ", r); return (const TRectype&)operator[](r - _offset); }