Modificata gestione focus negli sheet.

git-svn-id: svn://10.65.10.50/trunk@40 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-08-19 10:43:57 +00:00
parent 617fd7e074
commit 5479720988
6 changed files with 2322 additions and 2320 deletions

View File

@ -390,8 +390,6 @@ void TMask::start_run()
else else
{ {
f.set_dirty(FALSE); f.set_dirty(FALSE);
if (sheets() && f.class_id() == CLASS_SHEET_FIELD)
((TSheet_field&)f).force_update();
} }
} }

View File

@ -375,8 +375,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
case XIE_GET_PREV: case XIE_GET_PREV:
case XIE_GET_NEXT: case XIE_GET_NEXT:
{ {
const long n = xiev->v.rec_request.spec_rec + const long n = xiev->v.rec_request.spec_rec + (xiev->type == XIE_GET_NEXT ? +1 : -1) ;
(xiev->type == XIE_GET_NEXT ? +1 : -1) ;
if (n < 0 || n >= items()) if (n < 0 || n >= items())
xiev->refused = TRUE; xiev->refused = TRUE;
else else
@ -481,7 +480,6 @@ break;
if (row_dirty && check_enabled) if (row_dirty && check_enabled)
{ {
check_enabled = FALSE; // Avoid recursion! check_enabled = FALSE; // Avoid recursion!
set_dirty();
str2mask(cur_row); // It shouldn't have to be necessary str2mask(cur_row); // It shouldn't have to be necessary
bool ok = _mask.check_fields(); bool ok = _mask.check_fields();
if (ok) if (ok)
@ -489,11 +487,15 @@ break;
mask2str(cur_row); mask2str(cur_row);
ok = notify(cur_row, K_ENTER); // Notify edit ok = notify(cur_row, K_ENTER); // Notify edit
} }
else if (!ok)
{ {
xiev->refused = TRUE; xiev->refused = TRUE;
set_dirty(2); // Set error status set_dirty(2); // Set error status
set_focus_cell(cur_row, cur_col); }
else
{
xvt_statbar_set("");
set_dirty();
} }
check_enabled = TRUE; check_enabled = TRUE;
} }
@ -511,16 +513,17 @@ break;
else else
{ {
xiev->refused = TRUE; // Refuse focus on disabled cells xiev->refused = TRUE; // Refuse focus on disabled cells
/*
const int r = xiev->v.xi_obj->v.cell.row; const int r = xiev->v.xi_obj->v.cell.row;
int c = xiev->v.xi_obj->v.cell.column; int c = xiev->v.xi_obj->v.cell.column;
c += cur_col > col ? -1 : +1; c += cur_col > col ? -1 : +1;
if (c < 0) c = _columns-1; else if (c < 1) c = _columns-1; else
if (c >= _columns) c = 0; if (c >= _columns) c = 1;
XI_OBJ cell; XI_OBJ cell;
XI_MAKE_CELL(&cell, _list, r, c); XI_MAKE_CELL(&cell, _list, r, c);
xi_set_focus(&cell); xi_move_focus(&cell);
*/
} }
} }
break; break;
@ -543,18 +546,17 @@ break;
if (c->on_key(K_TAB) == FALSE) // Test it if (c->on_key(K_TAB) == FALSE) // Test it
{ {
c->set(old); c->set(old);
XI_OBJ* itf = xi_get_itf(win()); xiev->refused = TRUE;
// xi_set_focus(xiev->v.xi_obj);
} }
else else
{ {
xiev->refused = TRUE;
mask2str(cur_row); // Update sheet row mask2str(cur_row); // Update sheet row
edit_field = NULL; // Reset current field edit_field = NULL; // Reset current field
xi_set_color(xiev->v.xi_obj, XIC_BACK, NORMAL_BACK_COLOR);
} }
check_enabled = TRUE; check_enabled = TRUE;
} }
if (!xiev->refused)
xi_set_color(xiev->v.xi_obj, XIC_BACK, NORMAL_BACK_COLOR);
} }
break; break;
case XIE_GET_PERCENT: case XIE_GET_PERCENT:
@ -843,9 +845,11 @@ void TSpreadsheet::str2mask(int riga)
TMask_field& f = _mask.fld(pos); TMask_field& f = _mask.fld(pos);
f.set(val); f.set(val);
f.enable(!cell_disabled(riga, id-FIRST_FIELD)); f.enable(!cell_disabled(riga, id-FIRST_FIELD));
if (f.active() || f.ghost()) if (f.active() || f.ghost())
{ {
if (f.has_check()) f.check(STARTING_CHECK); if (f.has_check()) f.check(STARTING_CHECK);
f.set_dirty(FALSE);
f.on_hit(); f.on_hit();
} }
f.set_dirty(FALSE); f.set_dirty(FALSE);
@ -989,18 +993,6 @@ void TSheet_field::force_update(int r)
} }
void TSheet_field::set_window_data(const char*)
{
_sheet->set_dirty(FALSE);
set_dirty(FALSE);
}
void TSheet_field::set_field_data(const char*)
{
set_dirty(_sheet->dirty());
}
int TSheet_field::items() const int TSheet_field::items() const
{ {
return (int)_sheet->items(); return (int)_sheet->items();
@ -1030,6 +1022,15 @@ TMask& TSheet_field::sheet_mask() const
return _sheet->mask(); return _sheet->mask();
} }
bool TSheet_field::on_hit()
{
if (!mask().is_running())
{
force_update();
_sheet->set_dirty(FALSE);
}
return TRUE;
}
bool TSheet_field::on_key(KEY k) bool TSheet_field::on_key(KEY k)
{ {
@ -1037,8 +1038,9 @@ bool TSheet_field::on_key(KEY k)
{ {
const bool spork = _sheet->dirty(); const bool spork = _sheet->dirty();
if (spork < FALSE || spork > TRUE) if (spork < FALSE || spork > TRUE)
return error_box("Tabella inconsistente: correggere i valori errati prima di uscirne"); return error_box("Tabella inconsistente: correggere le celle errate");
set_dirty(spork); set_dirty(spork);
} }
return TMask_field::on_key(k); return TMask_field::on_key(k);
} }

View File

@ -17,13 +17,12 @@ class TSheet_field : public TMask_field
protected: protected:
virtual word class_id() const; virtual word class_id() const;
virtual bool on_hit();
virtual bool on_key(KEY k); virtual bool on_key(KEY k);
virtual void parse_head(TScanner& scanner); virtual void parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
virtual void create(WINDOW parent); virtual void create(WINDOW parent);
virtual void set_window_data(const char*);
virtual void set_field_data(const char*);
public: public:
TToken_string& row(int n); // Get/Create a new row TToken_string& row(int n); // Get/Create a new row

View File

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

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.1.1.1 1994-08-12 10:52:01 alex Exp $ // $Id: relation.cpp,v 1.2 1994-08-19 10:43:55 guy Exp $
// relation.cpp // relation.cpp
// fv 12/8/93 // fv 12/8/93
// relation class for isam files // relation class for isam files
@ -29,7 +29,7 @@
class TRelationdef : public TObject class TRelationdef : public TObject
{ {
// @DPRIV // @DPRIV
friend class TRelation; friend class TRelation;
const TRelation* _rel; // Relazione padre const TRelation* _rel; // Relazione padre
int _num; // Posizione file int _num; // Posizione file
@ -153,14 +153,14 @@ void TRelationdef::print_on(ostream& out) const
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TRelation::TRelation(int logicnum, bool linkrecinst) TRelation::TRelation(int logicnum, bool linkrecinst)
: _files(4) , _reldefs(4), _errors(NOERR) : _files(4) , _reldefs(4), _errors(NOERR)
{ {
TLocalisamfile* f = new TLocalisamfile(logicnum, linkrecinst); TLocalisamfile* f = new TLocalisamfile(logicnum, linkrecinst);
_files.add(f); _files.add(f);
} }
TRelation::TRelation(const char* tabname, bool linkrecinst) TRelation::TRelation(const char* tabname, bool linkrecinst)
: _files(4) , _reldefs(4), _errors(NOERR) : _files(4) , _reldefs(4), _errors(NOERR)
{ {
TTable* t = new TTable(tabname, linkrecinst); TTable* t = new TTable(tabname, linkrecinst);
_files.add(t); _files.add(t);
@ -345,7 +345,7 @@ TRectype& TRelationdef::load_rec(TRectype& r, const TBaseisamfile* from) const
// r.put(s, from->get(s)); // r.put(s, from->get(s));
TFieldref& s = (TFieldref&) _fields[j]; TFieldref& s = (TFieldref&) _fields[j];
s.write(s.read(from->curr()),r); s.write(s.read(from->curr()),r);
// r.put(s.name(), s.read(from->curr())); // r.put(s.name(), s.read(from->curr()));
} }
return r; return r;
@ -473,9 +473,9 @@ bool TRelation::next_match(int logicnum, const char* fieldlist, int nkey)
{ {
if (reldef(j)->_forced[kk]) if (reldef(j)->_forced[kk])
{ {
// TString& fl = (TString&)reldef(j)->_fields[kk]; // TString& fl = (TString&)reldef(j)->_fields[kk];
// const TFixed_string f_fr(from->curr().get(fl)); // const TFixed_string f_fr(from->curr().get(fl));
// const TFixed_string f_to(to->curr().get(fl)); // const TFixed_string f_to(to->curr().get(fl));
TFieldref& fl = (TFieldref&)reldef(j)->_fields[kk]; TFieldref& fl = (TFieldref&)reldef(j)->_fields[kk];
const TFixed_string f_fr(fl.read(from->curr())); const TFixed_string f_fr(fl.read(from->curr()));
const TFixed_string f_to(fl.read(to->curr())); const TFixed_string f_to(fl.read(to->curr()));
@ -522,8 +522,8 @@ bool TRelation::next_match(int logicnum, const char* fieldlist, int nkey)
} }
bool TRelation::is_first_match(int logicnum) bool TRelation::is_first_match(int logicnum)
// TRUE se c'e' un record ed e' il primo match (non si e' mai fatta // TRUE se c'e' un record ed e' il primo match (non si e' mai fatta
// position_rels) // position_rels)
{ {
const int i = log2ind(logicnum); const int i = log2ind(logicnum);
CHECKD(i != NOTFOUND,"Nonexistent file referenced in relation ",logicnum); CHECKD(i != NOTFOUND,"Nonexistent file referenced in relation ",logicnum);
@ -648,12 +648,12 @@ HIDDEN bool __evalcondition(const TRectype& r,TExpression* cond)
for (int i = 0; i < cond->numvar(); i++) for (int i = 0; i < cond->numvar(); i++)
{ {
const char* s = cond->varname(i); const char* s = cond->varname(i);
// if (cond->type() == _numexpr) // if (cond->type() == _numexpr)
// { // {
// real n(r.get(s)); // real n(r.get(s));
// cond->setvar(i, n); // cond->setvar(i, n);
// } // }
// else // else
cond->setvar(i, r.get(s)); cond->setvar(i, r.get(s));
} }
return (bool) *cond; return (bool) *cond;
@ -662,11 +662,11 @@ HIDDEN bool __evalcondition(const TRectype& r,TExpression* cond)
FILE* TCursor::open_index(bool create) const FILE* TCursor::open_index(bool create) const
{ {
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
const char* r = "r"; const char* const ";
const char* w = "w"; const char* const w = "w";
#else #else
const char* r = "rb"; const char* const r = "rb";
const char* w = "wb"; const char* const w = "wb";
#endif #endif
FILE* f = fopen(_indexname, create ? w : r); FILE* f = fopen(_indexname, create ? w : r);
@ -760,11 +760,11 @@ int TCursor::filtercursor(int pagecnt, TRecnotype* page)
TRectype& rec = file()->curr(); TRectype& rec = file()->curr();
const bool tab = file()->tab(); const bool tab = file()->tab();
if (tab) file()->filehnd()->r->Fd[0].RecOff += 3; if (tab) file()->filehnd()->r->Fd[0].RecOff += 3;
// TRecfield* codtab = tab ? new TRecfield(rec, "CODTAB") : NULL; // TRecfield* codtab = tab ? new TRecfield(rec, "CODTAB") : NULL;
for (int i = 0; i < pagecnt; i++) for (int i = 0; i < pagecnt; i++)
{ {
CRead(&file()->filehnd()->f, rec.string(), page[i], _nolock); CRead(&file()->filehnd()->f, rec.string(), page[i], _nolock);
// if (tab) *codtab = (const char*)(*codtab) + 3; // if (tab) *codtab = (const char*)(*codtab) + 3;
if ((_filterfunction ? _filterfunction(_if) : TRUE ) && if ((_filterfunction ? _filterfunction(_if) : TRUE ) &&
(_fexpr ? __evalcondition(rec, _fexpr) : TRUE)) (_fexpr ? __evalcondition(rec, _fexpr) : TRUE))
{ {
@ -773,7 +773,7 @@ int TCursor::filtercursor(int pagecnt, TRecnotype* page)
} }
} }
if (tab) file()->filehnd()->r->Fd[0].RecOff -= 3; if (tab) file()->filehnd()->r->Fd[0].RecOff -= 3;
// if (tab) delete codtab; // if (tab) delete codtab;
return np; return np;
} }
@ -806,13 +806,13 @@ bool TCursor::changed()
if (_frozen && _lastrec != 0L) return _filename != fh->f.name; if (_frozen && _lastrec != 0L) return _filename != fh->f.name;
#if XVT_OS==XVT_OS_SCOUNIX #if XVT_OS==XVT_OS_SCOUNIX
const TRecnotype eod = file()->eod(); const TRecnotype eod = file()->eod();
#else #else
int junk = 0; int junk = 0;
const TRecnotype eod = cisgeteod(fh, &junk); const TRecnotype eod = cisgeteod(fh, &junk);
// GetHead(&fh->i, _nolock, &junk); // GetHead(&fh->i, _nolock, &junk);
#endif #endif
if (_lastrec != eod || if (_lastrec != eod ||
(_lastkrec != fh->i.Base[_nkey -1].PEOD) || (_lastkrec != fh->i.Base[_nkey -1].PEOD) ||
@ -966,16 +966,16 @@ TCursor::TCursor(TRelation* r, const char* filter, int nkey, TRectype *from, TRe
CHECKD(_nkey > 0 && _nkey <= file()->filehnd()->r->NKeys, "Bad key number : ", _nkey); CHECKD(_nkey > 0 && _nkey <= file()->filehnd()->r->NKeys, "Bad key number : ", _nkey);
_indexname.temp("ci"); _indexname.temp("ci");
/* /*
#if XVT_OS==XVT_OS_SCOUNIX #if XVT_OS==XVT_OS_SCOUNIX
_f = fopen(_indexname, "w+"); _f = fopen(_indexname, "w+");
#else #else
_f = fopen(_indexname, "wb+"); _f = fopen(_indexname, "wb+");
#endif #endif
if (_f == NULL) if (_f == NULL)
fatal_box("Can't create cursor index on file %d: %s", fatal_box("Can't create cursor index on file %d: %s",
file()->num(), strerror(errno)); file()->num(), strerror(errno));
*/ */
FILE* _f = open_index(TRUE); FILE* _f = open_index(TRUE);
fclose(_f); fclose(_f);
@ -1021,7 +1021,7 @@ TCursor::TCursor(TRelation* r, const char* filter, int nkey, TRectype *from, TRe
TCursor::~TCursor() TCursor::~TCursor()
{ {
// fclose(_f); // fclose(_f);
::remove(_indexname); ::remove(_indexname);
if (_fexpr) delete _fexpr; if (_fexpr) delete _fexpr;
} }
@ -1186,9 +1186,9 @@ TFieldref& TFieldref::operator =(const TString& s)
if (par > 0) if (par > 0)
{ {
pos = par+1; pos = par+1;
par = s.find(',', pos);
_from = atoi(&s[pos]); _from = atoi(&s[pos]);
if (_from > 0) _from--; else _from = 0; if (_from > 0) _from--; else _from = 0;
par = s.find(',', pos);
if (par > 0) _to = atoi(&s[par+1]); else _to = -1; if (par > 0) _to = atoi(&s[par+1]); else _to = -1;
} }
else else
@ -1280,7 +1280,8 @@ void TFieldref::write(const char* val, TRectype& rec) const
campo.overwrite(val, _from); campo.overwrite(val, _from);
rec.put(_name, campo); rec.put(_name, campo);
} }
else rec.put(_name, val); else
rec.put(_name, val);
} }
int TFieldref::len(TRectype &rec) const int TFieldref::len(TRectype &rec) const

View File

@ -5,7 +5,7 @@
#include <utility.h> #include <utility.h>
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
extern "C" {long nap(long period);} extern "C" {long nap(long period);}
#endif #endif
@ -57,7 +57,7 @@ HIDDEN COLOR RGB2COLOR(COLORREF c)
extern "C" { extern "C" {
WINDOW xvtwi_hwnd_to_window(HWND); WINDOW xvtwi_hwnd_to_window(HWND);
#include <statbar.h> #include <statbar.h>
} }
#include <controls.h> #include <controls.h>
@ -78,7 +78,7 @@ HIDDEN LOGFONT NormalLogFont =
PROOF_QUALITY, PROOF_QUALITY,
VARIABLE_PITCH | FF_SWISS, VARIABLE_PITCH | FF_SWISS,
NULL NULL
}; };
HIDDEN HFONT NormalFont = CreateFontIndirect(&NormalLogFont); HIDDEN HFONT NormalFont = CreateFontIndirect(&NormalLogFont);
COLOR MASK_BACK_COLOR = MAKE_COLOR(0,128,128); COLOR MASK_BACK_COLOR = MAKE_COLOR(0,128,128);
@ -156,7 +156,6 @@ HIDDEN BOOLEAN event_hook(HWND hwnd,
GetClassName(hwnd, name, 15); GetClassName(hwnd, name, 15);
if (stricmp(name, "Edit") == 0) if (stricmp(name, "Edit") == 0)
{ {
WINDOW w = xvtwi_hwnd_to_window(GetParent(hwnd));
switch(wparam) switch(wparam)
{ {
case VK_PRIOR:wparam = K_PREV; break; case VK_PRIOR:wparam = K_PREV; break;
@ -166,10 +165,13 @@ HIDDEN BOOLEAN event_hook(HWND hwnd,
default:wparam = 0; break; default:wparam = 0; break;
} }
if (wparam) if (wparam)
{
WINDOW w = xvtwi_hwnd_to_window(GetParent(hwnd));
dispatch_e_char(w, wparam); dispatch_e_char(w, wparam);
} }
} }
} }
}
return FALSE; return FALSE;
@ -357,7 +359,7 @@ void dispatch_e_char(WINDOW win, KEY key)
e.v.chr.ch = short(key); e.v.chr.ch = short(key);
// dispatch_event(win, &e); // dispatch_event(win, &e);
EM.push(win, e); EM.push(win, e);
} }
@ -700,7 +702,7 @@ WINDOW xvt_create_statbar()
void xvt_statbar_set(const char* text) void xvt_statbar_set(const char* text)
{ {
TString80 t(text); TString t(text); t.cut(60);
const TDate oggi(TODAY); const TDate oggi(TODAY);
t << '\t' << oggi.string() << " - " << MainApp()->title(); t << '\t' << oggi.string() << " - " << MainApp()->title();
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN