Corretti errori neele stampe w

git-svn-id: svn://10.65.10.50/trunk@64 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-08-26 13:07:24 +00:00
parent 86bd8244c4
commit b108a12dba
18 changed files with 1728 additions and 1697 deletions

View File

@ -11,23 +11,23 @@
class CG0100_application : public TRelation_application
{
TMask* _msk;
TRelation *_rel;
TLocalisamfile* _saldi;
TLocalisamfile* _tabcom;
TMask* _msk;
TRelation *_rel;
TLocalisamfile* _saldi;
TLocalisamfile* _tabcom;
bool user_create();
bool user_destroy();
virtual TMask* get_mask(int mode) {return _msk;}
virtual bool changing_mask(int mode) {return FALSE;}
virtual bool protected_record(TRectype &rec);
virtual void init_query_mode(TMask& m);
virtual void init_insert_mode(TMask& m);
virtual void init_modify_mode(TMask& m) {init_insert_mode(m);}
bool user_create();
bool user_destroy();
virtual TMask* get_mask(int mode) {return _msk;}
virtual bool changing_mask(int mode) {return FALSE;}
virtual bool protected_record(TRectype &rec);
virtual void init_query_mode(TMask& m);
virtual void init_insert_mode(TMask& m);
virtual void init_modify_mode(TMask& m) {init_insert_mode(m);}
public:
virtual TRelation* get_relation() const {return _rel;}
CG0100_application() {}
virtual TRelation* get_relation() const {return _rel;}
CG0100_application() {}
};
@ -41,7 +41,7 @@ bool CG0100_application::protected_record(TRectype &rec)
const int conto = atoi(m->get(FLD_CM1_CONTO));
const long sottoc = atol(m->get(FLD_CM1_SOTTOCONTO));
// Se e' un sottoconto posso cancellarlo se non esistono saldi
// Se e' un sottoconto posso cancellarlo se non esistono saldi
if ((gruppo != 0) && (conto != 0) && (sottoc != 0))
{
_saldi->zero();
@ -51,12 +51,12 @@ bool CG0100_application::protected_record(TRectype &rec)
_saldi->read(_isgteq);
return _saldi->good() && gruppo ==_saldi->get_int(PCN_GRUPPO) &&
conto ==_saldi->get_int(PCN_CONTO) &&
sottoc ==_saldi->get_long(PCN_SOTTOCONTO);
conto ==_saldi->get_int(PCN_CONTO) &&
sottoc ==_saldi->get_long(PCN_SOTTOCONTO);
}
pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo);
// Se e' un conto controllo se ha dei sottoconti
// Se e' un conto controllo se ha dei sottoconti
if (conto != 0)
pconti.put(PCN_CONTO, conto);
TRectype rec1(pconti.curr());
@ -64,47 +64,47 @@ bool CG0100_application::protected_record(TRectype &rec)
pconti.setkey(1) ;
pconti.read();
pconti.next();
return pconti.good() && (pconti.curr() == rec1);
//
// if (pconti.bad()) return FALSE;
//
// if (pconti.bad()) return FALSE;
// const int ngruppo = pconti.get_int(PCN_GRUPPO);
// const int nconto = pconti.get_int(PCN_CONTO);
// Cercavo di cancellare un gruppo e ho trovato un conto dello stesso gruppo
// if (conto == 0 && gruppo == ngruppo)
// return TRUE;
// Cercavo di cancellare un conto e ho trovato un sottoconto
// dello stesso gruppo e conto
// const int ngruppo = pconti.get_int(PCN_GRUPPO);
// const int nconto = pconti.get_int(PCN_CONTO);
// Cercavo di cancellare un gruppo e ho trovato un conto dello stesso gruppo
// if (conto == 0 && gruppo == ngruppo)
// return TRUE;
// Cercavo di cancellare un conto e ho trovato un sottoconto
// dello stesso gruppo e conto
// if (gruppo == ngruppo && conto == nconto)
// return TRUE;
// return FALSE;
// if (gruppo == ngruppo && conto == nconto)
// return TRUE;
// return FALSE;
}
void CG0100_application::init_query_mode(TMask& m)
{
m.send_key(K_SHIFT + K_CTRL + 's', -1);
m.send_key(K_SHIFT + K_CTRL + 's', -2);
m.send_key(K_SHIFT + K_CTRL + 's', -3);
m.send_key(K_SHIFT + K_CTRL + 's', -1);
m.send_key(K_SHIFT + K_CTRL + 's', -2);
m.send_key(K_SHIFT + K_CTRL + 's', -3);
}
HIDDEN bool tmcf_handler(TMask_field& f, KEY key)
{
if (f.active() && key == K_SPACE)
{
{
TMask& m = f.mask();
const int conto = atoi(m.get(FLD_CM1_CONTO));
const long sottoc = atol(m.get(FLD_CM1_SOTTOCONTO));
const bool enable_sezsaldi = (sottoc != 0) || (sottoc == 0 && conto != 0 && m.get(FLD_CM1_TMCF).not_empty());
const int conto = atoi(m.get(FLD_CM1_CONTO));
const long sottoc = atol(m.get(FLD_CM1_SOTTOCONTO));
const bool enable_sezsaldi = (sottoc != 0) || (sottoc == 0 && conto != 0 && m.get(FLD_CM1_TMCF).not_empty());
m.show(FLD_CM2_SEZSALDI, enable_sezsaldi);
}
return TRUE;
m.show(FLD_CM2_SEZSALDI, enable_sezsaldi);
}
return TRUE;
}
HIDDEN bool ivd_enable = TRUE;
@ -116,7 +116,7 @@ HIDDEN bool indbil_handler(TMask_field& f, KEY key)
{
TMask& m = f.mask();
const int indbil = atoi(f.get());
if (indbil == ORDINE)
{
m.send_key(K_SHIFT + K_CTRL + 'h', -4);
@ -206,17 +206,17 @@ void CG0100_application::init_insert_mode(TMask& m)
m.show(FLD_CM1_NUMIVDH, !ivd_enable);
if (!ivd_enable)
{
m.set(FLD_CM1_SEZIVD, s1);
m.set(FLD_CM1_LETTIVDH, s2);
m.set(FLD_CM1_NUMRIVDH, s3);
m.set(FLD_CM1_NUMIVDH, s4);
m.set(FLD_CM1_SEZIVD, s1);
m.set(FLD_CM1_LETTIVDH, s2);
m.set(FLD_CM1_NUMRIVDH, s3);
m.set(FLD_CM1_NUMIVDH, s4);
}
}
pconti.zero();
pconti.put(PCN_GRUPPO, gruppo);
pconti.read();
if (pconti.good())
if (s.empty()) s = pconti.get(PCN_CODCBL);
if (s.empty()) s = pconti.get(PCN_CODCBL);
}
if (s.not_empty())
{
@ -236,90 +236,90 @@ void CG0100_application::init_insert_mode(TMask& m)
HIDDEN bool gruppo_handler(TMask_field& f, KEY key)
{
if (key == K_ENTER)
{
const TMask& m = f.mask();
const int gruppo = atoi(m.get(FLD_CM1_GRUPPO));
const int conto = atoi(m.get(FLD_CM1_CONTO));
const long sottoc = atol(m.get(FLD_CM1_SOTTOCONTO));
const TFixed_string descrizione(m.get(FLD_CM1_DESC));
CG0100_application* app = (CG0100_application*) MainApp();
TLocalisamfile& pconti = *app->get_relation()->lfile();
if (key == K_ENTER)
{
const TMask& m = f.mask();
const int gruppo = atoi(m.get(FLD_CM1_GRUPPO));
const int conto = atoi(m.get(FLD_CM1_CONTO));
const long sottoc = atol(m.get(FLD_CM1_SOTTOCONTO));
const TFixed_string descrizione(m.get(FLD_CM1_DESC));
CG0100_application* app = (CG0100_application*) MainApp();
TLocalisamfile& pconti = *app->get_relation()->lfile();
if (gruppo == 0 && conto == 0 && sottoc == 0 && descrizione.not_empty())
return TRUE;
if (gruppo == 0)
{
if (conto != 0 || sottoc != 0)
return f.warning_box("Codice conto impossibile!");
else
return f.error_box("E' obbligatorio l'inserimento del gruppo");
}
if (conto > 0 && sottoc == 0) // conto => ricerca gruppo
{
pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo) ;
pconti.setkey(1) ;
pconti.read(_isequal, _nolock );
if (pconti.bad())
return f.warning_box ("Non esiste il gruppo relativo a questo conto");
}
if (sottoc > 0) // sottoconto => ricerca conto
{
pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo) ;
pconti.put(PCN_CONTO, conto) ;
pconti.setkey(1) ;
pconti.read(_isequal, _nolock );
if (pconti.bad())
return f.warning_box ("Non esiste il conto relativo a questo sottoconto");
if (gruppo == 0 && conto == 0 && sottoc == 0 && descrizione.not_empty())
return TRUE;
if (gruppo == 0)
{
if (conto != 0 || sottoc != 0)
return f.warning_box("Codice conto impossibile!");
else
return f.error_box("E' obbligatorio l'inserimento del gruppo");
}
if (conto > 0 && sottoc == 0) // conto => ricerca gruppo
{
pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo) ;
pconti.setkey(1) ;
pconti.read(_isequal, _nolock );
if (pconti.bad())
return f.warning_box ("Non esiste il gruppo relativo a questo conto");
}
if (sottoc > 0) // sottoconto => ricerca conto
{
pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo) ;
pconti.put(PCN_CONTO, conto) ;
pconti.setkey(1) ;
pconti.read(_isequal, _nolock );
if (pconti.bad())
return f.warning_box ("Non esiste il conto relativo a questo sottoconto");
else
{
TString tmcf = pconti.get(PCN_TMCF);
TString tmcf = pconti.get(PCN_TMCF);
if (tmcf.not_empty())
return f.warning_box ("Non puoi inserire un sottoconto di un conto relativo ad un cliente/fornitore");
return f.warning_box ("Non puoi inserire un sottoconto di un conto relativo ad un cliente/fornitore");
}
}
}
return TRUE;
}
}
return TRUE;
}
HIDDEN bool sottoc_handler(TMask_field& f, KEY key)
{
if (key == K_TAB)
{
TString gruppo(f.mask().get(FLD_CM1_GRUPPO));
if (gruppo.empty()) return TRUE;
TString conto(f.mask().get(FLD_CM1_CONTO));
TString sottoconto(f.mask().get(FLD_CM1_SOTTOCONTO));
if (sottoconto.not_empty() && conto.empty()) return f.error_box("Manca il CONTO");
dispatch_e_char(f.parent(), K_SHIFT_ENTER);
}
if (key == K_TAB)
{
TString gruppo(f.mask().get(FLD_CM1_GRUPPO));
if (gruppo.empty()) return TRUE;
TString conto(f.mask().get(FLD_CM1_CONTO));
TString sottoconto(f.mask().get(FLD_CM1_SOTTOCONTO));
if (sottoconto.not_empty() && conto.empty()) return f.error_box("Manca il CONTO");
dispatch_e_char(f.parent(), K_AUTO_ENTER);
}
return TRUE;
return TRUE;
}
bool CG0100_application::user_create()
{
_msk = new TMask("cg0100a") ;
_msk->set_handler(FLD_CM1_GRUPPO, gruppo_handler);
_msk->set_handler(FLD_CM1_SOTTOCONTO, sottoc_handler);
_msk->set_handler(FLD_CM1_INDBIL, indbil_handler);
_msk->set_handler(FLD_CM1_TMCF, tmcf_handler);
_msk = new TMask("cg0100a") ;
_msk->set_handler(FLD_CM1_GRUPPO, gruppo_handler);
_msk->set_handler(FLD_CM1_SOTTOCONTO, sottoc_handler);
_msk->set_handler(FLD_CM1_INDBIL, indbil_handler);
_msk->set_handler(FLD_CM1_TMCF, tmcf_handler);
_rel = new TRelation(LF_PCON);
_saldi = new TLocalisamfile(LF_SALDI);
_saldi->setkey(2);
set_search_field(FLD_CM1_GRUPPO);
return TRUE;
_rel = new TRelation(LF_PCON);
_saldi = new TLocalisamfile(LF_SALDI);
_saldi->setkey(2);
set_search_field(FLD_CM1_GRUPPO);
return TRUE;
}
bool CG0100_application::user_destroy()
{
delete _msk;
delete _rel;
delete _saldi;
delete _rel;
delete _saldi;
return TRUE;
}

View File

@ -7,18 +7,18 @@
class CG0300_application : public TRelation_application
{
TMask* _msk;
TRelation *_rel;
TLocalisamfile* _ditte;
TLocalisamfile* _attiv;
TLocalisamfile* _clifo;
TRelation *_rel;
TLocalisamfile* _ditte;
TLocalisamfile* _attiv;
TLocalisamfile* _clifo;
bool user_create();
bool user_destroy();
virtual TMask* get_mask(int mode) {return _msk;}
virtual bool changing_mask(int mode) {return FALSE;}
virtual TRelation* get_relation() const {return _rel;}
virtual void init_query_mode(TMask& m);
virtual void init_query_insert_mode(TMask& m);
bool user_create();
bool user_destroy();
virtual TMask* get_mask(int mode) {return _msk;}
virtual bool changing_mask(int mode) {return FALSE;}
virtual TRelation* get_relation() const {return _rel;}
virtual void init_query_mode(TMask& m);
virtual void init_query_insert_mode(TMask& m);
public:
CG0300_application() {}
@ -27,51 +27,51 @@ public:
void CG0300_application::init_query_mode(TMask& m)
{
disable_menu_item(M_FILE_NEW);
m.send_key(K_SHIFT + K_CTRL + 's', -1);
m.send_key(K_SHIFT + K_CTRL + 'h', -2);
disable_menu_item(M_FILE_NEW);
m.send_key(K_SHIFT + K_CTRL + 's', -1);
m.send_key(K_SHIFT + K_CTRL + 'h', -2);
}
void CG0300_application::init_query_insert_mode(TMask& m)
{
disable_menu_item(M_FILE_NEW);
m.send_key(K_SHIFT + K_CTRL + 'h', -1);
m.send_key(K_SHIFT + K_CTRL + 's', -2);
disable_menu_item(M_FILE_NEW);
m.send_key(K_SHIFT + K_CTRL + 'h', -1);
m.send_key(K_SHIFT + K_CTRL + 's', -2);
}
HIDDEN bool key_handler (TMask_field& f, KEY k)
{
if (k == K_TAB)
{
TMask& m = f.mask();
if (k == K_TAB)
{
TMask& m = f.mask();
if (m.get(F_ANNO).not_empty() && m.get(F_CODATT).not_empty() &&
m.get(F_CODCF).not_empty())
m.send_key(K_SHIFT_ENTER, 0);
}
return TRUE;
if (m.get(F_ANNO).not_empty() && m.get(F_CODATT).not_empty() &&
m.get(F_CODCF).not_empty())
m.send_key(K_AUTO_ENTER, 0);
}
return TRUE;
}
bool CG0300_application::user_create()
{
_msk = new TMask("cg0300a") ;
_msk->set_handler (F_IMMESSO, key_handler);
_rel = new TRelation(LF_ALLEG);
_rel = new TRelation(LF_ALLEG);
_ditte = new TLocalisamfile(LF_NDITTE);
_attiv = new TLocalisamfile(LF_ATTIV);
_clifo = new TLocalisamfile(LF_CLIFO);
const long ditta = get_firm();
_msk->set(F_CODDITTA, format("%ld", ditta));
_ditte->zero();
_ditte->put(N_CODDITTA, ditta);
_ditte->read();
if (_ditte->good())
_msk->set(F_CODATT,_ditte->get(N_CODATTPREV));
_attiv = new TLocalisamfile(LF_ATTIV);
_clifo = new TLocalisamfile(LF_CLIFO);
const long ditta = get_firm();
_msk->set(F_CODDITTA, format("%ld", ditta));
_ditte->zero();
_ditte->put(N_CODDITTA, ditta);
_ditte->read();
if (_ditte->good())
_msk->set(F_CODATT,_ditte->get(N_CODATTPREV));
return TRUE;
}
bool CG0300_application::user_destroy()

View File

@ -396,12 +396,12 @@ void CG1600_application::set_bil_key(bil_ivd* b, char lettera, char sezione,
}
}
void CG1600_application::set_bil_val(bil_ivd* b, const real& saldo = ZERO,
const real& saldorafr = ZERO,
const real& sld_prg_dare = ZERO,
const real& sld_prg_avere = ZERO,
const real& mov_dare = ZERO,
const real& mov_avere = ZERO)
void CG1600_application::set_bil_val(bil_ivd* b, const real& saldo,
const real& saldorafr,
const real& sld_prg_dare,
const real& sld_prg_avere,
const real& mov_dare,
const real& mov_avere)
{
b->saldo = saldo;
b->saldorafr = saldorafr;

View File

@ -627,7 +627,7 @@ void TPrimanota_application::mask2rel(const TMask& m)
int TPrimanota_application::write(const TMask& m)
{
const long numreg = m.get_long(F_NUMREG);
if (numreg > _lastreg) _lastreg = numreg;
if (numreg > _lastreg) _lastreg = numreg; // Aggiorna ultima registrazione
mask2rel(m);
const int err = _rel->write(TRUE);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,7 @@
#include <tabutil.h>
#include <printapp.h>
#include <mask.h>
#include <date.h>
#include <scanner.h>
#include <utility.h>
#include <prefix.h>
#include <config.h>
#include <urldefid.h>
@ -18,7 +15,6 @@
#include <causali.h>
#include <nditte.h>
#include "cg4.h"
#include "cg4500a.h"
#include "cg4500b.h"
@ -576,3 +572,15 @@ int cg4500 (int argc, char* argv[])
main_app.run(argc, argv, "");
return TRUE;
}
<<<<<<< cg4500.cpp
=======
>>>>>>> 1.4

View File

@ -546,7 +546,8 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
caption = format("#%d#%d", BMP_DELREC, BMP_DELRECDN);
break;
case DLG_NEWREC:
caption = format("#%d#%d", BMP_NEWREC, BMP_NEWRECDN);
if (height > ROWY && strcmp("~Nuovo", caption) == 0) // Puo' essere Gestione
caption = format("#%d#%d", BMP_NEWREC, BMP_NEWRECDN);
break;
case DLG_FIRSTREC:
caption = format("#%d", BMP_FIRSTREC);

View File

@ -16,6 +16,7 @@
#define K_CTRL_ENTER K_CTRL+K_ENTER
#define K_AUTO_ENTER K_SHIFT+K_ENTER
#define K_QUIT 10334
#define K_FORCE_CLOSE 11334
#define K_SAVE 10082
#define K_SHIFT_TAB K_SHIFT+K_TAB
#define K_SHIFT_F2 K_SHIFT+K_F2

View File

@ -98,10 +98,12 @@ void TMask::handler(WINDOW win, EVENT* ep)
switch(ep->v.ctl.id)
{
case DLG_OK :
on_key(K_AUTO_ENTER); break;
stop_run(K_AUTO_ENTER); break;
case DLG_BAR :
case DLG_CANCEL :
on_key(K_ESC); break;
stop_run(K_ESC); break;
case DLG_QUIT :
stop_run(K_FORCE_CLOSE); break;
/*
case DLG_PGDN :
on_key(K_NEXT); break;
@ -123,8 +125,6 @@ void TMask::handler(WINDOW win, EVENT* ep)
stop_run(K_DEL); break;
case DLG_SAVEREC :
stop_run(K_SAVE); break;
case DLG_QUIT :
stop_run(K_QUIT); break;
*/
case DLG_F9:
{
@ -557,18 +557,18 @@ int TMask::find_active_field(int first, int dir) const
void TMask::set_focus()
{
_focus = find_active_field(_focus, +1);
const int page = find_parent_page(fld(_focus));
const TMask_field& f = fld(_focus);
const int page = find_parent_page(f);
if (page != _page && page != MAX_PAGES)
{
const WINDOW pw = win(); // previous window
_page = page;
show_window(win(), TRUE); // show new page
const WINDOW pw = win(); // previous window
_page = page; // update page number
show_window(win(), TRUE); // show new page
if (pw) show_window(pw, FALSE); // hide old page
}
const WINDOW fw = fld(_focus).win();
set_front_window(fw);
set_front_window(f.win());
}
@ -577,9 +577,9 @@ void TMask::move_focus_field(int d)
{
TMask_field& f = fld(_focus);
if (f.on_key(K_TAB) == FALSE) // New style
if (f.on_key(K_TAB) == FALSE) // Don't you agree to lose focus? ...
{
set_focus();
set_focus(); // ... Keep it
return;
}
@ -601,9 +601,7 @@ void TMask::move_focus_field(int d)
bool TMask::stop_run(KEY key)
{
if (key == K_CTRL_ENTER) key = K_ENTER;
if (key != K_AUTO_ENTER)
if (key != K_AUTO_ENTER && key != K_FORCE_CLOSE)
{
const int last = fields();
bool found = FALSE;
@ -626,11 +624,13 @@ bool TMask::stop_run(KEY key)
#ifdef DBG
return error_box("Non e' attivo il bottone associato a %d", key);
#else
beep();
return FALSE;
#endif
}
} else key = K_ENTER;
}
if (key == K_CTRL_ENTER) key = K_ENTER; else
if (key == K_FORCE_CLOSE) key = K_QUIT;
if (key != K_ESC && key != K_QUIT && key != K_DEL)
{
@ -694,7 +694,7 @@ bool TMask::on_key(KEY key)
if (key > K_CTRL)
{
key -= K_CTRL;
if (key >= K_F1 && key <= K_F10)
if (key >= K_F1 && key <= K_F12)
next_page(1000 + key - K_F1);
else
{

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.3 1994-08-23 13:52:21 guy Exp $
// $Id: maskfld.cpp,v 1.4 1994-08-26 13:07:14 guy Exp $
#include <xvt.h>
#include <applicat.h>
@ -1721,13 +1721,13 @@ const char* TEdit_field::format(const char* d)
if (fpark.not_empty())
{
#ifdef DBG
if (fpark.len() > _size)
{
#ifdef DBG
error_box("Campo %d troppo lungo: %d > %d", dlg(), fpark.len(), _size);
#endif
fpark.cut(_size);
}
#endif
}
if (_flags.uppercase)
fpark.upper();

View File

@ -31,6 +31,11 @@ class TSpreadsheet : public TWindow
XI_OBJ *_list;
SPREADSHEET_NOTIFY _notify;
TMask_field* _edit_field; // Current edit field
int _cur_row, _cur_col; // Current cell
bool _row_dirty; // Current row changed
bool _check_enabled; // Perform OFF_ROW checks
static void xiev_handler(XI_OBJ *itf, XI_EVENT *xiev);
void init();
@ -45,7 +50,7 @@ protected:
void mask2str(int n);
void str2mask(int n);
KEY edit(int n);
TMask_field* field(short id) const;
int rec2row(int rec);
@ -97,13 +102,14 @@ void TSpreadsheet::init()
// xi_set_pref(XI_PREF_COLOR_DARK, COLOR_GRAY);
first = FALSE;
}
}
TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
const char* maskname, int maskno,
const char* head, WINDOW parent)
: _mask(maskname, NO_MODE, maskno), _notify(NULL)
: _mask(maskname, NO_MODE, maskno), _notify(NULL), _edit_field(NULL), _cur_row(0), _cur_col(0),
_row_dirty(FALSE), _check_enabled(TRUE)
{
const int NUMBER_WIDTH = 3;
const int MAX_COL = 32;
@ -181,8 +187,8 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
for (h = new_header.get(0), i = 0; h; h = new_header.get(), i++)
{
const int cid = FIRST_FIELD+i; // Column & Field ID
const TMask_field* f = field(cid); // Field on mask
const int cid = FIRST_FIELD+i; // Column & Field ID
const TMask_field* f = field(cid); // Field on mask
const int w = width[i] + (f->has_query() ? 2 : 0); // Column width
long flags = XI_ATR_EDITMENU | XI_ATR_AUTOSCROLL;
@ -259,8 +265,8 @@ TMask_field* TSpreadsheet::cell2field(const XI_OBJ* cell) const
{
TMask_field* f = field(id);
if (f == NULL) break;
good = f;
if (f->active()) break;
good = f; // We've found a field with the proper ID ...
if (f->active()) break; // ... and it's active: end of search
}
return good;
@ -280,7 +286,7 @@ void TSpreadsheet::update_rec(int rec)
void TSpreadsheet::set_focus_cell(int riga, int colonna)
{
set_front_window(win());
// set_front_window(win());
XI_OBJ cell;
XI_MAKE_CELL(&cell, _list, rec2row(riga), colonna);
xi_set_focus(&cell);
@ -328,10 +334,12 @@ bool TSpreadsheet::destroy(int rec)
void TSpreadsheet::update(int row)
{
if (row < 0)
{
{
xi_cell_request(_list);
xi_scroll(_list, XI_SCROLL_FIRST);
set_front_window(win());
XI_OBJ* itf = xi_get_itf(win());
xi_set_focus(itf);
// set_front_window(win());
}
else
update_rec(row);
@ -349,11 +357,6 @@ void TSpreadsheet::xiev_handler(XI_OBJ *itf, XI_EVENT *xiev)
// Certified 75%
void TSpreadsheet::list_handler(XI_EVENT *xiev)
{
static TMask_field* edit_field = NULL; // Current edit field
static int cur_row = 0, cur_col = 0; // Current cell
static bool row_dirty = FALSE; // Current row changed
static bool check_enabled = TRUE; // Perform OFF_ROW checks
switch (xiev->type)
{
case XIE_GET_FIRST:
@ -430,18 +433,18 @@ break;
case XIE_BUTTON:
if (xiev->v.xi_obj->type == XIT_CELL)
{
if (edit_field)
if (_edit_field)
{
const char* val = xi_get_text(xiev->v.xi_obj, NULL, -1);
edit_field->set(val); // Update current cell
check_enabled = FALSE; // Disable checks
if (!row_dirty) notify(cur_row, K_SPACE);
if (edit_field->on_key(K_F9)) // Show search sheet
_edit_field->set(val); // Update current cell
_check_enabled = FALSE; // Disable checks
if (!_row_dirty) notify(_cur_row, K_SPACE);
if (_edit_field->on_key(K_F9)) // Show search sheet
{
mask2str(cur_row); // Update row
row_dirty = TRUE;
mask2str(_cur_row); // Update row
_row_dirty = TRUE;
}
check_enabled = TRUE; // Enable checks
_check_enabled = TRUE; // Enable checks
xi_set_focus(xiev->v.xi_obj); // Restore focus to cell
}
} else
@ -450,17 +453,17 @@ if (xiev->v.xi_obj->type == XIT_LIST)
break;
case XIE_DBL_CELL:
{
check_enabled = FALSE;
cur_row = row2rec(xiev->v.xi_obj->v.cell.row);
cur_col = xiev->v.xi_obj->v.cell.column;
const KEY k = edit(cur_row);
_check_enabled = FALSE;
_cur_row = row2rec(xiev->v.xi_obj->v.cell.row);
_cur_col = xiev->v.xi_obj->v.cell.column;
const KEY k = edit(_cur_row);
if (k == K_ENTER)
{
update_rec(cur_row);
row_dirty = TRUE;
update_rec(_cur_row);
_row_dirty = TRUE;
}
xi_set_focus(xiev->v.xi_obj);
check_enabled = TRUE;
_check_enabled = TRUE;
}
break;
case XIE_ON_ROW:
@ -468,24 +471,24 @@ break;
const int rec = row2rec(xiev->v.xi_obj->v.row);
if (rec < items())
{
cur_row = rec;
_cur_row = rec;
str2mask(rec);
row_dirty = FALSE;
_row_dirty = FALSE;
}
else
xiev->refused = TRUE;
}
break;
case XIE_OFF_ROW:
if (row_dirty && check_enabled)
if (_row_dirty && _check_enabled)
{
check_enabled = FALSE; // Avoid recursion!
str2mask(cur_row); // It shouldn't have to be necessary
_check_enabled = FALSE; // Avoid recursion!
str2mask(_cur_row); // It shouldn't have to be necessary
bool ok = _mask.check_fields();
if (ok)
{
mask2str(cur_row);
ok = notify(cur_row, K_ENTER); // Notify edit
mask2str(_cur_row);
ok = notify(_cur_row, K_ENTER); // Notify edit
}
if (!ok)
{
@ -497,17 +500,17 @@ break;
xvt_statbar_set("");
set_dirty();
}
check_enabled = TRUE;
_check_enabled = TRUE;
}
break;
case XIE_ON_CELL:
{
TMask_field* f = cell2field(xiev->v.xi_obj);
const int col = (f->dlg() - FIRST_FIELD) % 100;
if (!cell_disabled(cur_row, col))
if (!cell_disabled(_cur_row, col))
{
edit_field = f;
cur_col = xiev->v.xi_obj->v.cell.column;
_edit_field = f;
_cur_col = xiev->v.xi_obj->v.cell.column;
xi_set_color(xiev->v.xi_obj, XIC_BACK, FOCUS_BACK_COLOR);
}
else
@ -528,18 +531,18 @@ break;
}
break;
case XIE_OFF_CELL:
if (edit_field && check_enabled)
if (_edit_field && _check_enabled)
{
TMask_field* c = edit_field; // Save field, it could turn out to be NULL on error
TMask_field* c = _edit_field; // Save field, it could turn out to be NULL on error
const TString80 old(c->get()); // Save old value on mask
const TString80 nuo(c->picture_data(xi_get_text(xiev->v.xi_obj, NULL, -1), TRUE));
if (old != nuo)
{
check_enabled = FALSE;
if (!row_dirty)
_check_enabled = FALSE;
if (!_row_dirty)
{
notify(cur_row, K_SPACE);
row_dirty = TRUE;
notify(_cur_row, K_SPACE);
_row_dirty = TRUE;
}
c->set(nuo); // Set new mask value
c->set_dirty(); // Get it dirty!
@ -550,10 +553,10 @@ break;
}
else
{
mask2str(cur_row); // Update sheet row
edit_field = NULL; // Reset current field
mask2str(_cur_row); // Update sheet row
_edit_field = NULL; // Reset current field
}
check_enabled = TRUE;
_check_enabled = TRUE;
}
if (!xiev->refused)
xi_set_color(xiev->v.xi_obj, XIC_BACK, NORMAL_BACK_COLOR);
@ -580,35 +583,38 @@ break;
XI_OBJ* itf = xi_get_itf(win());
const bool ok = (bool)xi_move_focus(itf);
if (!ok)
{
set_dirty(2);
xiev->refused = TRUE;
}
}
break;
case E_CHAR:
if (edit_field)
if (_edit_field)
{
const KEY k = e_char_to_key(ep);
switch(k)
{
case K_F1:
check_enabled = FALSE; // Disable checks
edit_field->on_key(K_F1);
set_focus_cell(cur_row, cur_col);
check_enabled = TRUE; // Enable checks
_check_enabled = FALSE; // Disable checks
_edit_field->on_key(K_F1);
set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks
break;
case K_F2:
case K_F3:
case K_F8:
case K_F9:
{
check_enabled = FALSE; // Disable checks
if (!row_dirty) notify(cur_row, K_SPACE);
if (edit_field->on_key(k))
_check_enabled = FALSE; // Disable checks
if (!_row_dirty) notify(_cur_row, K_SPACE);
if (_edit_field->on_key(k))
{
mask2str(cur_row);
row_dirty = TRUE;
mask2str(_cur_row);
_row_dirty = TRUE;
}
set_focus_cell(cur_row, cur_col);
check_enabled = TRUE; // Enable checks
set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks
}
break;
case K_PREV:

View File

@ -1 +1 @@
#define VERSION 1.8
#define VERSION 1.9

View File

@ -76,13 +76,12 @@ TSheet::TSheet(short x, short y, short dx, short dy,
void TSheet::add_button(short id, const char* caption, KEY key)
{
const int BUT_HEIGHT =
#if XVT_OS == XVT_OS_WIN
2
const int BUT_HEIGHT = 2;
#else
1
const int BUT_HEIGHT = 1;
#endif
;
WINDOW b = xvt_create_control(WC_PUSHBUTTON, 0, 0, 11, BUT_HEIGHT, caption, win(), 0, 0, id);
for (int i = 0; i < MAX_BUT; i++)
if (_button[i] == NULL_WIN)
@ -611,21 +610,25 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
{
xvt_create_control(WC_EDIT, 1, -3, f->size()+1, 1, f->get(), win(),
CTL_FLAG_DISABLED, 0L, 100);
if (s)
if (s && s->items() > 2)
{
WINDOW listbox = xvt_create_control(WC_LISTBUTTON, f->size()+3, -3, 18, 3,
"", win(), 0, 0L, 99);
int maxlen = 0;
SLIST lst = slist_new();
for (const char* item = s->get(0); item; item = s->get())
{
item = s->get();
const int len = strlen(item);
if (len > maxlen) maxlen = len;
slist_add(lst, (SLIST_ELT)NULL, (char*)item, 0L);
}
WINDOW listbox = xvt_create_control(WC_LISTBUTTON, f->size()+3, -3, maxlen+3, 3,
"", win(), 0, 0L, 99);
win_list_add(listbox, -1, (char*)lst);
slist_dispose(lst);
TString id(3); id << f->dlg();
TString16 id; id << f->dlg();
const int sel = s->get_pos(id) >> 1;
win_list_set_sel(listbox, sel, TRUE);
}
@ -649,7 +652,7 @@ void TBrowse_sheet::repos_buttons() const
if (w != NULL_WIN)
{
RCT r; get_client_rect(w, &r);
r.left = CHARX*(id == 99 ? 1 : 21);
r.left = CHARX*(id == 99 ? _field->size()+3 : 1);
r.top = wr.bottom - 4*CHARY + 4;
r.right += r.left;
r.bottom += r.top;
@ -673,7 +676,12 @@ bool TBrowse_sheet::on_key(KEY k)
const TString old(_field->get());
TString val(old.size()+1); val = old;
if (alnum) val << char(k);
if (alnum)
{
if (val.len() > field().size())
val.cut(0);
val << char(k);
}
else val.rtrim(1);
field().set(val);

View File

@ -18,7 +18,7 @@ END
BUTTON DLG_FINDREC 8 2
BEGIN
PROMPT -46 -1 "Ricerca"
PROMPT -46 -1 "Ri~cerca"
MESSAGE EXIT,K_F9
END

View File

@ -28,7 +28,7 @@ HIDDEN bool _expr_val(TEdit_field& f, KEY)
const char* s = e.varname(i);
if (s[0] != '#')
{
TString err(64); err << "Cannot load variable " << s << " in " << e;
TString80 err; err << "Cannot load variable " << s << " in " << e;
return f.error_box((const char*)err);
}
s++;
@ -100,7 +100,7 @@ bool pi_check(const char * st, const char * paiva)
// Controlla la partita iva se e' non vuota ed italiana
HIDDEN bool _pi_val(TEdit_field& f, KEY)
{
TString stato(f.mask().get(atoi(get_val_param(0)))), pi(f.get());
TString16 stato(f.mask().get(atoi(get_val_param(0)))), pi(f.get());
if (stato.not_empty() && stato != "IT") return TRUE;
if (pi.empty()) return TRUE;
@ -220,10 +220,10 @@ HIDDEN bool _xt_pi_val(TEdit_field& f, KEY key)
TMask& m = f.mask();
if (m.query_mode()) return TRUE;
TString value(f.get());
TString16 value(f.get());
if (value.empty()) return f.error_box("Partita IVA obbligatoria");
const TString stato(m.get(atoi(get_val_param(0))));
const TString16 stato(m.get(atoi(get_val_param(0))));
if (stato.not_empty() && stato != "IT") return TRUE;
if (!_pi_val(f, key)) return FALSE;
@ -237,7 +237,7 @@ HIDDEN bool _xt_pi_val(TEdit_field& f, KEY key)
const int comune = atoi(get_val_param(i));
if (comune)
{
const TString com(m.get(comune)); // Comune residenza fiscale e residenza
const TString16 com(m.get(comune)); // Comune residenza fiscale e residenza
if (com.not_empty())
{
c.zero();
@ -269,7 +269,7 @@ HIDDEN bool _xtz_pi_val(TEdit_field& f, KEY key)
{
if (f.mask().query_mode()) return TRUE;
TString pi(f.get());
TString16 pi(f.get());
if (pi.empty()) return TRUE;
return _xt_pi_val(f, key);
}
@ -280,7 +280,7 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
{
if (f.mask().query_mode()) return TRUE;
const TString cf(f.get());
const TString16 cf(f.get());
if (cf.empty()) return f.error_box("Codice fiscale obbligatorio");
if (!_cf_val(f, key)) return FALSE;
@ -288,7 +288,7 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
if (cf.len() == 11)
{
if (!_xt_pi_val(f, key)) return FALSE;
TString stato(f.mask().get(atoi(get_val_param(0))));
TString16 stato(f.mask().get(atoi(get_val_param(0))));
if ((stato.not_empty()) && (stato != "IT")) return TRUE;
}
@ -302,10 +302,10 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
TMask_field& fld_com = m.field(atoi(get_val_param(3)));
char sesso = fld_sex.get()[0];
TString data(fld_dat.get());
TString com(fld_com.get());
TString16 data(fld_dat.get());
TString16 com(fld_com.get());
TString wm("LMNPQRSTUV");
TString16 wm("LMNPQRSTUV");
int p;
if ((p = wm.find(cf[6])) != -1) cf[6] = '0' + p;
if ((p = wm.find(cf[7])) != -1) cf[7] = '0' + p;
@ -494,7 +494,7 @@ HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
const char* s = e.varname(i);
if (s[0] != '#')
{
TString err(64); err << "Cannot load variable " << s << " in " << e;
TString80 err; err << "Cannot load variable " << s << " in " << e;
return f.error_box((const char*)err);
}
s++;
@ -517,7 +517,7 @@ HIDDEN bool _strcalc_val(TEdit_field& f, KEY k)
const char* s = e.varname(i);
if (s[0] != '#')
{
TString err(64); err << "Cannot load variable " << s << " in " << e;
TString80 err; err << "Cannot load variable " << s << " in " << e;
return f.error_box((const char*)err);
}
s++;

View File

@ -53,7 +53,7 @@ void TWindow_manager::destroy()
while (_current >= 0)
{
TWindow* w = cur_win();
w->stop_run(K_QUIT);
w->stop_run(K_FORCE_CLOSE);
w->close_modal();
}
}

View File

@ -750,8 +750,17 @@ void xvt_statbar_refresh()
HIDDEN bool test_menu_tag(MENU_ITEM* mi, MENU_TAG tag)
{
CHECK(mi, "Can't test NULL MENU_ITEM");
if (mi->tag == tag) return TRUE;
if (mi->child != NULL) return test_menu_tag(mi->child, tag);
while (mi->tag)
{
if (mi->tag == tag) return TRUE;
if (mi->child != NULL)
{
const bool ok = test_menu_tag(mi->child, tag);
if (ok) return TRUE;
}
mi++;
}
return FALSE;
}