Tentata correzione errore di registrazione degli sheet incosistenti

git-svn-id: svn://10.65.10.50/trunk@606 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-11-11 18:04:29 +00:00
parent 782f282a3f
commit 2e4ea1e4a7
11 changed files with 124 additions and 101 deletions

View File

@ -245,9 +245,9 @@ long TApplication::handler(WINDOW win, EVENT* ep)
{ {
TBanner banner; TBanner banner;
_create_ok = create(); _create_ok = create();
if (!_create_ok)
stop_run();
} }
if (!_create_ok)
stop_run();
break; break;
case E_COMMAND: case E_COMMAND:
switch(ep->v.cmd.tag) switch(ep->v.cmd.tag)
@ -432,16 +432,24 @@ void TApplication::set_perms()
void TApplication::check_parameters(int & argc, char* argv[]) void TApplication::check_parameters(int & argc, char* argv[])
{ {
if (strncmp(argv[argc - 1], "-u", 2) == 0) if (strncmp(argv[argc-1], "-u", 2) == 0)
{ _user = &argv[--argc][2];
_user = &argv[argc - 1][2];
argc--;
}
#ifdef DBG #ifdef DBG
else _user = "PRASSI"; else _user = "PRASSI";
#endif #endif
long twin_style = WSF_ICONIZABLE | WSF_SIZE | WSF_CLOSE;
if (stricmp(argv[argc-1], "-icon") == 0)
{
twin_style |= WSF_ICONIZED;
argc--;
}
else
twin_style |= WSF_MAXIMIZED;
set_value(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, twin_style);
} }

View File

@ -1,4 +1,4 @@
// fv 6/10/93 // fv 6/10/93
#include <stdio.h> #include <stdio.h>
@ -19,7 +19,17 @@
#include <holdev.h> #include <holdev.h>
#endif #endif
#include <execp.h> #include <execp.h>
bool TExternal_app::can_run() const
{
const TFixed_string p(_path);
const bool clifo = p.find("cg0") == 0 && p.find("-1") > 0;
const int richieste = clifo ? 45 : 15;
const int libere = GetFreeSystemResources(GFSR_SYSTEMRESOURCES);
return libere >= richieste;
}
// char _path[120]; // app name // char _path[120]; // app name
@ -30,9 +40,11 @@
// int exitcode() { return _exitcode}; // int exitcode() { return _exitcode};
// int count() { return _count; }; // int count() { return _count; };
int TExternal_app::run(bool async) int TExternal_app::run(bool async, bool iconized)
{ {
TString256 path(_path); TString256 path(_path);
if (iconized)
path << " -icon";
path << " -u" << main_app().user(); path << " -u" << main_app().user();
_error = 0; _error = 0;
_exitcode = 0; _exitcode = 0;
@ -41,22 +53,19 @@ int TExternal_app::run(bool async)
save_dir(); save_dir();
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
set_cursor(TASK_WIN, CURSOR_WAIT); if (!can_run())
const int req = 30;
int perc = GetFreeSystemResources(GFSR_SYSTEMRESOURCES);
if (perc < req)
{ {
if (yesno_box("Le risorse di Windows sono quasi esaurite:\n" error_box("Le risorse di Windows sono quasi esaurite:\n"
"eseguire ugualmente l'applicazione %s", (const char*)_path)) "impossibile eseguire %s", (const char*)_path);
perc = req; _exitcode = 8;
else
_exitcode = 8;
} }
if (perc >= req) if (_exitcode == 0)
{ {
_exitcode = WinExec((char*)(const char*)path, SW_SHOW); set_cursor(TASK_WIN, CURSOR_WAIT);
const UINT sh = iconized ? SW_SHOWMINIMIZED : SW_SHOW;
_exitcode = WinExec((char*)(const char*)path, sh);
if (_exitcode >= 32) if (_exitcode >= 32)
{ {
@ -65,8 +74,9 @@ int TExternal_app::run(bool async)
} }
else else
error_box("Impossibile eseguire '%s':\nErrore %d", (const char*)_path, _exitcode); error_box("Impossibile eseguire '%s':\nErrore %d", (const char*)_path, _exitcode);
set_cursor(TASK_WIN, CURSOR_ARROW);
} }
set_cursor(TASK_WIN, CURSOR_ARROW);
#else #else
switch (fork()) switch (fork())
@ -76,7 +86,7 @@ int TExternal_app::run(bool async)
_exitcode = -1; _exitcode = -1;
break; break;
case 0: case 0:
const char* s = strdup( path); const char* s = strdup(path);
char* p = strchr(s, ' '); char* p = strchr(s, ' ');
if (p) *p = '\0'; if (p) *p = '\0';
const char* pathn = strdup(s); const char* pathn = strdup(s);

View File

@ -22,8 +22,8 @@ class TExternal_app : public TObject
int _count; // count of calls int _count; // count of calls
public: public:
bool can_run() const;
int run(bool async = FALSE); int run(bool async = FALSE, bool iconized = FALSE);
int error() { return _error;}; int error() { return _error;};
int exitcode() { return _exitcode;}; int exitcode() { return _exitcode;};
int count() { return _count; }; int count() { return _count; };

View File

@ -1092,7 +1092,7 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
f.equal(); f.equal();
const long level = atol(f.line()); const long level = atol(f.line());
if (level > stdlevel) if (level > stdlevel)
error_box("L' archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\\n Il livello attuale e' %ld/%ld.\\n Convertire gli archivi e ripetere l' operazione.", from, level / 100, level % 100, stdlevel / 100, stdlevel % 100); error_box("L' archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\n Il livello attuale e' %ld/%ld.\n Convertire gli archivi e ripetere l' operazione.", from, level / 100, level % 100, stdlevel / 100, stdlevel % 100);
lcf = getlcf(level); lcf = getlcf(level);
nflds = 0; nflds = 0;
TToken_string s2(f.line()); TToken_string s2(f.line());
@ -1143,14 +1143,14 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
if (fd) sfd << fd; if (fd) sfd << fd;
int last = NOERR; int last = NOERR;
s1.format("Imp. archivio %s\\n%6ld records %6ld errori - %3d", filename(), r, e, last); s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last);
TProgind p(nitems, s1, TRUE, TRUE, 70); TProgind p(nitems, s1, TRUE, TRUE, 70);
s = f.line(); s = f.line();
while (s.not_empty() && !p.iscancelled()) while (s.not_empty() && !p.iscancelled())
{ {
if ((r + e) % 50 == 0) if ((r + e) % 50 == 0)
{ {
s1.format("Imp. archivio %s\\n%6ld records %6ld errori - %3d", filename(), r, e, last); s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last);
p.set_text(s1); p.set_text(s1);
} }
p.setstatus(nread + 1); p.setstatus(nread + 1);
@ -1189,7 +1189,7 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
} }
s = f.line(); s = f.line();
} }
s1.format("Imp. archivio %s\\n%6ld records %6ld errori - %3d", filename(), r, e, last); s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last);
p.set_text(s1); p.set_text(s1);
close(); close();
setstatus(err); setstatus(err);

View File

@ -140,14 +140,6 @@ void TMask::handler(WINDOW win, EVENT* ep)
stop_run(K_ESC); break; stop_run(K_ESC); break;
case DLG_QUIT : case DLG_QUIT :
stop_run(K_FORCE_CLOSE); break; stop_run(K_FORCE_CLOSE); break;
/*
case DLG_NEWREC :
if (test_focus_change()) stop_run(K_INS);
break;
case DLG_DELREC :
if (test_focus_change()) stop_run(K_DEL);
break;
*/
case DLG_F9: case DLG_F9:
{ {
WINDOW w = ep->v.ctl.ci.win; WINDOW w = ep->v.ctl.ci.win;
@ -371,7 +363,7 @@ short TMask::dirty() const
{ {
const TMask_field& f = fld(i); const TMask_field& f = fld(i);
const word id = f.class_id(); const word id = f.class_id();
if (f.dirty() && id != CLASS_FIELD && id != CLASS_BUTTON_FIELD && f.active()) if (f.dirty() && id != CLASS_FIELD && id != CLASS_BUTTON_FIELD && f.active())
return f.dlg(); return f.dlg();
} }
return 0; return 0;
@ -419,10 +411,10 @@ void TMask::start_run()
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if ((f.active() || f.ghost()) && if ((f.active() || f.ghost()) &&
f.class_id() != CLASS_BUTTON_FIELD && f.dirty() != 3) f.class_id() != CLASS_BUTTON_FIELD && f.dirty() <= TRUE)
{ {
f.set_dirty(FALSE); f.set_dirty(FALSE);
f.on_hit(); f.on_hit(); // Lancia messaggio di inizializzazione
} }
} }
@ -431,11 +423,14 @@ void TMask::start_run()
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (mode() == MODE_QUERY && f.is_edit() && f.in_key(1) && if (mode() == MODE_QUERY && f.is_edit() && f.in_key(1) &&
!f.automagic() && !f.get().empty() || f.dirty() == 3) !f.automagic() && !f.get().empty())
f.set_dirty(TRUE);
else
{ {
f.set_dirty(FALSE); f.set_dirty(TRUE);
}
else
{
if (f.dirty() == TRUE)
f.set_dirty(FALSE);
} }
} }

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.43 1994-11-10 13:44:30 guy Exp $ // $Id: maskfld.cpp,v 1.44 1994-11-11 18:04:13 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1430,7 +1430,18 @@ KEY TBrowse::run()
{ {
TToken_string* sib = siblings.empty() ? NULL : &siblings; TToken_string* sib = siblings.empty() ? NULL : &siblings;
const byte buttons = _insert.empty() ? 0 : 1; byte buttons = 0;
if (_insert.not_empty())
{
if (_insert[0] == 'M')
buttons = 1;
else
{
TExternal_app a(_insert.mid(1));
if (a.can_run()) buttons = 1;
}
}
TBrowse_sheet s(_cursor, _items, caption, _head, buttons, _fld, sib); TBrowse_sheet s(_cursor, _items, caption, _head, buttons, _fld, sib);
k = s.run(); k = s.run();
selected = s.selected(); selected = s.selected();

View File

@ -26,13 +26,14 @@ class TSpreadsheet : public TWindow
TMask _mask; TMask _mask;
int _columns; int _columns;
bool _dirty;
bool _firstfocus; bool _firstfocus;
XI_OBJ *_list, *_itf; XI_OBJ *_list, *_itf;
SPREADSHEET_NOTIFY _notify; SPREADSHEET_NOTIFY _notify;
TSheet_field* _owner; // Owner
TMask_field* _edit_field; // Current edit field TMask_field* _edit_field; // Current edit field
int _cur_row, _cur_col; // Current cell int _cur_row, _cur_col; // Current cell
bool _row_dirty; // Current row changed bool _row_dirty; // Current row changed
@ -48,10 +49,6 @@ protected:
void update_rec(int rec); void update_rec(int rec);
void set_focus_cell(int riga, int colonna); void set_focus_cell(int riga, int colonna);
void mask2str(int n);
void str2mask(int n);
KEY edit(int n);
TMask_field* field(short id) const; TMask_field* field(short id) const;
int rec2row(int rec); int rec2row(int rec);
@ -75,16 +72,21 @@ public:
TMask& sheet_mask() { return _mask; } TMask& sheet_mask() { return _mask; }
TMask& mask(); TMask& mask();
void mask2str(int n);
void str2mask(int n);
KEY edit(int n);
int items() const { return _str.items(); } int items() const { return _str.items(); }
int selected() const { return _cur_row; } int selected() const { return _cur_row; }
int columns() const { return _columns; } int columns() const { return _columns; }
bool dirty() const { return _dirty; }
bool dirty() const { return _owner->dirty(); }
void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork); }
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
void set_dirty(bool spork = TRUE) { _dirty = spork; }
TSpreadsheet(short x, short y, short dx, short dy, const char* maskname, int maskno, TSpreadsheet(short x, short y, short dx, short dy, const char* maskname, int maskno,
const char* head, WINDOW parent); const char* head, WINDOW parent, TSheet_field* owner);
virtual ~TSpreadsheet(); virtual ~TSpreadsheet();
}; };
@ -110,8 +112,10 @@ void TSpreadsheet::init()
TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy, TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
const char* maskname, int maskno, const char* maskname, int maskno,
const char* head, WINDOW parent) const char* head, WINDOW parent,
: _mask(maskname, NO_MODE, maskno), _notify(NULL), _edit_field(NULL), _cur_row(0), _cur_col(0), TSheet_field* o)
: _mask(maskname, NO_MODE, maskno), _notify(NULL), _edit_field(NULL),
_owner(o), _cur_row(0), _cur_col(0),
_row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE) _row_dirty(FALSE), _check_enabled(TRUE), _firstfocus(TRUE)
{ {
const int NUMBER_WIDTH = 3; const int NUMBER_WIDTH = 3;
@ -618,7 +622,7 @@ break;
const bool ok = (bool)xi_move_focus(_itf); const bool ok = (bool)xi_move_focus(_itf);
if (!ok) if (!ok)
{ {
set_dirty(2); set_dirty(3);
xiev->refused = TRUE; xiev->refused = TRUE;
} }
} }
@ -715,7 +719,6 @@ class TSpreadsheet : public TArray_sheet
{ {
TMask _mask; TMask _mask;
SPREADSHEET_NOTIFY _notify; SPREADSHEET_NOTIFY _notify;
bool _dirty;
TBit_array _column_disabled; TBit_array _column_disabled;
TArray _disabled; // Array di TBit_array TArray _disabled; // Array di TBit_array
@ -740,8 +743,8 @@ public:
TMask& mask(); TMask& mask();
void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; } void set_notify(SPREADSHEET_NOTIFY n) { _notify = n; }
void set_dirty(bool spork = TRUE) { _dirty = spork;} void set_dirty(bool spork = TRUE) { _owner->set_dirty(spork);}
bool dirty() const { return _dirty;} bool dirty() const { return _owner->dirty(); }
void enable_column(int col, bool on); void enable_column(int col, bool on);
void enable_cell(int row, int column, bool on = TRUE); void enable_cell(int row, int column, bool on = TRUE);
@ -750,8 +753,9 @@ public:
TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy, TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
const char* maskname, int maskno, const char* maskname, int maskno,
const char* head, WINDOW parent) const char* head, WINDOW parent,
: TArray_sheet(x, y, dx, dy, maskname, head, 0, parent), TSheet_field* o)
: TArray_sheet(x, y, dx, dy, maskname, head, 0, parent), _owner(o)
_mask(maskname, NO_MODE, maskno), _notify(NULL) _mask(maskname, NO_MODE, maskno), _notify(NULL)
{} {}
@ -1074,7 +1078,7 @@ void TSheet_field::create(WINDOW parent)
{ {
const TMask& m = mask(); const TMask& m = mask();
_sheet = new TSpreadsheet(_x, _y, _width, _size, m.source_file(), m.sheets(), _sheet = new TSpreadsheet(_x, _y, _width, _size, m.source_file(), m.sheets(),
_head, parent); _head, parent, this);
_win = _sheet->win(); _win = _sheet->win();
enable_window(_win, enabled()); enable_window(_win, enabled());
@ -1167,19 +1171,17 @@ bool TSheet_field::on_hit()
if (!mask().is_running()) if (!mask().is_running())
{ {
force_update(); force_update();
_sheet->set_dirty(FALSE); set_dirty(FALSE);
} }
return TRUE; return TRUE;
} }
bool TSheet_field::on_key(KEY k) bool TSheet_field::on_key(KEY k)
{ {
if (k == K_TAB) if (k == K_TAB || k == K_ENTER)
{ {
const bool spork = _sheet->dirty(); if (dirty() > TRUE)
if (spork != FALSE && spork != TRUE) return FALSE; // Lo sheet e' inconsistente
return FALSE;
set_dirty(spork);
} }
return TMask_field::on_key(k); return TMask_field::on_key(k);

View File

@ -1,4 +1,4 @@
// $Id: progind.cpp,v 1.2 1994-09-13 16:43:46 guy Exp $ // $Id: progind.cpp,v 1.3 1994-11-11 18:04:23 guy Exp $
#include <defmask.h> #include <defmask.h>
#include <progind.h> #include <progind.h>
@ -6,6 +6,18 @@
const char* const CANCEL_TEXT = "Annulla"; const char* const CANCEL_TEXT = "Annulla";
const char* const TITLE_TEXT = "Attesa"; const char* const TITLE_TEXT = "Attesa";
word TIndwin::measure_text(TToken_string& s, word& maxlen) const
{
word lines = 0;
for(const char* t = s.get(0); t; t = s.get())
{
const word l = strlen(t);
if (l > maxlen) maxlen = l;
lines++;
}
return lines;
}
// Certified 70% // Certified 70%
TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div) TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
{ {
@ -16,10 +28,11 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
if (_max <= 0) _max = 1; if (_max <= 0) _max = 1;
_flags = 0x0; _flags = 0x0;
word maxlen = div, lines; TToken_string testo(txt, '\n');
measure_text(txt, maxlen, lines); word maxlen = div;
const word lines = measure_text(testo, maxlen);
int ver = lines+3; int ver = lines+2;
int hor = maxlen+2; if (hor > 78) hor = 78; int hor = maxlen+2; if (hor > 78) hor = 78;
@ -50,19 +63,6 @@ void TIndwin::set_text(const char* t)
TIndwin::~TIndwin() TIndwin::~TIndwin()
{ close_modal(); } { close_modal(); }
void TIndwin::measure_text(const char* txt, word& maxlen, word& lines) const
{
TToken_string s(txt, '\n');
lines = 0;
for(const char* t = s.get(0); t; t = s.get())
{
const word l = strlen(t);
if (l > maxlen) maxlen = l;
lines++;
}
}
bool TIndwin::can_be_closed() const bool TIndwin::can_be_closed() const
{ {
const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED); const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED);

View File

@ -1,4 +1,4 @@
/* $Id: progind.h,v 1.2 1994-09-13 16:43:47 guy Exp $ */ /* $Id: progind.h,v 1.3 1994-11-11 18:04:25 guy Exp $ */
/* @N /* @N
progind.h progind.h
@ -43,7 +43,7 @@ protected:
long _max; // maximum value to reach long _max; // maximum value to reach
long _status; // current status (set by user) long _status; // current status (set by user)
void draw_window(); void draw_window();
void measure_text(const char* t, word& len, word& lin) const; word measure_text(TToken_string& t, word& len) const;
virtual void handler(WINDOW w, EVENT* e); virtual void handler(WINDOW w, EVENT* e);
virtual void update(); virtual void update();

View File

@ -607,7 +607,12 @@ const TFilename& TFilename::tempdir()
if (res == 0) if (res == 0)
{ {
if (not_empty()) *this << "/" ; if (not_empty())
#if XVT_OS==XVT_OS_SCOUNIX
*this << '/' ;
#else
*this << '\\' ;
#endif
*this << main_app().user(); *this << main_app().user();
lower(); lower();
if (!fexist(_str)) if (!fexist(_str))

View File

@ -487,9 +487,6 @@ void customize_controls(bool on)
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (on) if (on)
{ {
const long TWIN_STYLE = WSF_ICONIZABLE | WSF_SIZE | WSF_CLOSE | WSF_MAXIMIZED;
set_value(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, TWIN_STYLE);
set_value(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE); set_value(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE);
set_value(NULL_WIN,ATTR_EVENT_HOOK, (long)event_hook); set_value(NULL_WIN,ATTR_EVENT_HOOK, (long)event_hook);
#ifdef __CTL3D__ #ifdef __CTL3D__
@ -617,11 +614,6 @@ WINDOW xvt_create_window(WIN_TYPE wt,
SetClassWord(hwnd, GCW_STYLE, style); SetClassWord(hwnd, GCW_STYLE, style);
to_set = FALSE; to_set = FALSE;
} }
/*
long style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~WS_CLIPCHILDREN;
SetWindowLong(hwnd, GWL_STYLE, style);
*/
#endif #endif
return win; return win;