Nuovo modo di notificare i cambiamenti dei parametri

git-svn-id: svn://10.65.10.50/trunk@705 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-11-30 09:04:03 +00:00
parent 5f3e554116
commit 5fc07b4f63
13 changed files with 146 additions and 78 deletions

View File

@ -247,7 +247,12 @@ long TApplication::handler(WINDOW win, EVENT* ep)
TBanner banner; TBanner banner;
_create_ok = create(); _create_ok = create();
} }
if (!_create_ok) if (_create_ok)
{
on_firm_change();
on_config_change();
}
else
stop_run(); stop_run();
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
else else
@ -272,6 +277,7 @@ else
break; break;
case M_FILE_REVERT: case M_FILE_REVERT:
config(); config();
on_config_change();
break; break;
case (M_FILE+11): case (M_FILE+11):
about(); about();
@ -614,6 +620,19 @@ bool TApplication::set_firm(long newfirm)
{ {
prefhndl->set_codditta(newfirm); prefhndl->set_codditta(newfirm);
_savefirm = 0; _savefirm = 0;
WINDOW w = cur_win();
if (w != NULL_WIN)
{
EVENT e;
e.type = E_COMMAND;
e.v.cmd.tag = M_FILE_NEW;
e.v.cmd.shift = e.v.cmd.control = 0;
dispatch_event(w, &e);
}
on_firm_change();
on_config_change();
} }
return TRUE; return TRUE;
@ -652,12 +671,10 @@ bool TApplication::config()
} }
} }
// run mask // run mask
disable_menu_item(M_FILE_NEW);
disable_menu_item(M_FILE_REVERT); disable_menu_item(M_FILE_REVERT);
if (m.run() == K_ENTER) if (m.run() == K_ENTER && m.dirty())
{ {
// aggiusta campi // aggiusta campi
for (i = 0; i < m.fields(); i++) for (i = 0; i < m.fields(); i++)
@ -667,26 +684,20 @@ bool TApplication::config()
{ {
const TFieldref* fref = f.field(); const TFieldref* fref = f.field();
if (fref != NULL) if (fref != NULL)
{ cnf.set(fref->name(), f.get(), NULL, TRUE);
const char* fname = fref->name();
const char* value = f.get();
const char* oldvl = cnf.get(fname);
if (change_config(fname,oldvl,value))
cnf.set(fname, value, NULL, TRUE);
}
} }
} }
ok = TRUE; ok = TRUE;
} }
else ok = FALSE;
enable_menu_item(M_FILE_NEW);
enable_menu_item(M_FILE_REVERT); enable_menu_item(M_FILE_REVERT);
return ok; return ok;
} }
return warning_box("Nessun parametro da configurare"); return warning_box("Nessun parametro da configurare");
} }
bool TApplication::change_config(const char* var, const char* oldv, void TApplication::on_firm_change()
const char* newv) {}
{ return TRUE; } void TApplication::on_config_change()
{}

View File

@ -16,9 +16,9 @@
#define MSG_AI "AI" // message auto_insert (relapp) #define MSG_AI "AI" // message auto_insert (relapp)
#define MSG_FS "FS" // message filtered start (relapp) #define MSG_FS "FS" // message filtered start (relapp)
#define MSG_LN "LN" // message (printapp -> relapp) #define MSG_LN "LN" // message (printapp -> relapp)
#define CHK_ALL -1 // all authorization checks #define CHK_ALL -1 // all authorization checks
#define CHK_DONGLE 0 // dongle authorization checks #define CHK_DONGLE 0 // dongle authorization checks
#define CHK_USER 1 // user authorization checks #define CHK_USER 1 // user authorization checks
class TApplication class TApplication
{ {
@ -49,7 +49,9 @@ protected:
virtual bool destroy(); // Rimuove l'applicazione virtual bool destroy(); // Rimuove l'applicazione
virtual void print(); virtual void print();
virtual bool change_config(const char* var, const char* oldv, const char* newv); virtual void on_config_change();
virtual void on_firm_change();
void set_user(const char * user) { _user = user; } void set_user(const char * user) { _user = user; }
void terminate(); void terminate();

View File

@ -2,9 +2,7 @@
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
#include <mask.h> #include <mask.h>
#include <maskfld.h>
#include <relation.h> #include <relation.h>
#include <xvtility.h>
bool TConfig_application::create() bool TConfig_application::create()
{ {

View File

@ -94,9 +94,8 @@ void TConfig::_write_file()
out.close(); in.close(); out.close(); in.close();
TFilename bak(_file); bak.ext("bak"); TFilename bak(_file); bak.ext("bak");
rename(_file,bak); rename(_file, bak);
fcopy(temp,_file); rename(temp, _file);
remove(temp);
} }

View File

@ -47,9 +47,14 @@ bool TExternal_app::can_run() const
int TExternal_app::run(bool async, bool iconized) int TExternal_app::run(bool async, bool iconized)
{ {
TString256 path(_path); TString256 path(_path);
if (iconized)
path << " -icon"; if (!async)
path << " -u" << main_app().user(); {
if (iconized)
path << " -icon";
path << " -u" << main_app().user();
}
_error = 0; _error = 0;
_exitcode = 0; _exitcode = 0;

View File

@ -1329,17 +1329,19 @@ void TBaseisamfile::recover()
fn = fn.name(); fn = fn.name();
#ifndef FOXPRO #ifndef FOXPRO
if (yesno_box("La dimensione dell' archivio %s e' errata. Cerco di recuperarlo?", (const char *) fn)) if (yesno_box("La dimensione dell'archivio %s e' errata. Cerco di recuperarlo?", (const char *)fn))
{ {
TDir d; TDir d;
TString mess(80); TString mess(80);
mess.format("Ricostruzione archivio %s : I Fase", (const char*) fn); mess.format("Ricostruzione archivio %s : I Fase", (const char*) fn);
TProgind p(nitems ? nitems : 1, mess, TRUE, TRUE, 70); TProgind p(nitems ? nitems : 1, mess, TRUE, TRUE, 70);
d.get(num(), _lock, _nordir, _sysdirop);
const TDirtype dir = (fh->ft == 0) ? _nordir : _comdir;
d.get(num(), _lock, dir, _sysdirop);
d.eod() = fh->d->EOD = nitems; d.eod() = fh->d->EOD = nitems;
d.eox() = fh->d->EOX = nitems; d.eox() = fh->d->EOX = nitems;
d.put(num(), _nordir, _sysdirop); d.put(num(), dir, _sysdirop);
for (TRecnotype r = 1; r <= nitems; r++) for (TRecnotype r = 1; r <= nitems; r++)
{ {
p.addstatus(1); p.addstatus(1);

View File

@ -131,6 +131,10 @@ void TMask::handler(WINDOW win, EVENT* ep)
#endif #endif
update(); update();
return; return;
case E_COMMAND:
if (ep->v.cmd.tag == M_FILE_NEW)
on_firm_change();
break;
case E_CONTROL: case E_CONTROL:
switch(ep->v.ctl.id) switch(ep->v.ctl.id)
{ {
@ -201,6 +205,7 @@ void TMask::read_mask(const char* name, int num, int max)
TScanner scanner(_source_file); TScanner scanner(_source_file);
_sheetmask = num > 0; _sheetmask = num > 0;
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
while (scanner.ok()) while (scanner.ok())
@ -1040,7 +1045,6 @@ byte TMask::num_keys() const
return max; return max;
} }
void TMask::enable_key(byte key, bool on) void TMask::enable_key(byte key, bool on)
{ {
for (int i = 0; i < fields(); i++) for (int i = 0; i < fields(); i++)
@ -1101,9 +1105,10 @@ bool TMask::key_valid(int key) const
void TMask::show(short fld_id, bool on) void TMask::show(short fld_id, bool on)
{ {
if (fld_id < 1) if (fld_id <= 0)
{ {
for (int i = 0; i < fields(); i++) const int gr = -fld_id;
for (int i = 0; i < fields(); i++) if (fld(i).in_group(gr))
fld(i).show(on); fld(i).show(on);
} else field(fld_id).show(on); } else field(fld_id).show(on);
} }
@ -1111,7 +1116,7 @@ void TMask::show(short fld_id, bool on)
void TMask::show_default(short fld_id) void TMask::show_default(short fld_id)
{ {
if (fld_id < 1) if (fld_id <= 0)
{ {
for (int i = 0; i < fields(); i++) for (int i = 0; i < fields(); i++)
fld(i).show_default(); fld(i).show_default();
@ -1146,6 +1151,23 @@ void TMask::autosave(TRelation* r) const
} }
} }
void TMask::on_firm_change()
{
TString16 firm; firm << main_app().get_firm();
for (int i = 0; i < fields(); i++)
{
TMask_field& f = fld(i);
if (f._flags.firm)
{
f.set(firm);
f.check(STARTING_CHECK);
f.on_hit();
}
}
}
void TMask::send_key(KEY key, short to, TMask_field* from) void TMask::send_key(KEY key, short to, TMask_field* from)
{ {
if (to == 0) if (to == 0)
@ -1178,11 +1200,11 @@ void TMask::send_key(KEY key, short to, TMask_field* from)
else else
{ {
const int max = fields(); const int max = fields();
to = -to; const int gr = -to;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
TMask_field& campo = fld(i); TMask_field& campo = fld(i);
if (campo.in_group((int)to)) if (campo.in_group(gr))
campo.on_key(key); campo.on_key(key);
} }
} }

View File

@ -147,6 +147,7 @@ public:
int focus_field() const { return _focus;} int focus_field() const { return _focus;}
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
void on_firm_change();
void enable(short fld_id, bool on = TRUE); // Abilita un campo void enable(short fld_id, bool on = TRUE); // Abilita un campo
void disable(short fld_id) { enable(fld_id, FALSE); } void disable(short fld_id) { enable(fld_id, FALSE); }

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.54 1994-11-29 17:34:25 alex Exp $ // $Id: maskfld.cpp,v 1.55 1994-11-30 09:03:49 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1515,10 +1515,6 @@ bool TBrowse::check(CheckTime t)
if (_secondary == TRUE && t != RUNNING_CHECK) if (_secondary == TRUE && t != RUNNING_CHECK)
return TRUE; return TRUE;
// if (_checked && t == FINAL_CHECK)
// return TRUE;
// _checked = TRUE;
if (_fld->check_type() != CHECK_NONE) if (_fld->check_type() != CHECK_NONE)
{ {
const TMaskmode mode = (TMaskmode)field().mask().mode(); const TMaskmode mode = (TMaskmode)field().mask().mode();
@ -2400,13 +2396,19 @@ bool TDate_field::on_key(KEY key)
changed = TRUE; changed = TRUE;
} }
else else
if (data == "ULTIMO") if (data == "NATALE")
{ {
gstring.overwrite("31-12", 0); gstring.overwrite("25-12", 0);
changed = TRUE; changed = TRUE;
} }
else else
if (data == "OGGI") changed = TRUE; if (data == "ULTIMO")
{
gstring.overwrite("31-12", 0);
changed = TRUE;
}
else
if (data == "OGGI") changed = TRUE;
if (changed) data = gstring; if (changed) data = gstring;
} }

View File

@ -18,6 +18,8 @@ const short FIRST_FIELD = 101;
class TSpreadsheet : public TWindow class TSpreadsheet : public TWindow
{ {
friend class TSheet_field;
enum { ITF_CID = 0, LIST_CID = 1 }; enum { ITF_CID = 0, LIST_CID = 1 };
TArray _str; // Array di TToken_strings TArray _str; // Array di TToken_strings
@ -70,7 +72,7 @@ public:
bool cell_disabled(int row, int column) const; bool cell_disabled(int row, int column) const;
TMask& sheet_mask() { return _mask; } TMask& sheet_mask() { return _mask; }
TMask& mask(); TMask& mask() const;
void mask2str(int n); void mask2str(int n);
void str2mask(int n); void str2mask(int n);
@ -251,7 +253,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
} }
TSpreadsheet::~TSpreadsheet() TSpreadsheet::~TSpreadsheet()
{ {
set_win(NULL_WIN); set_win(NULL_WIN);
} }
@ -322,7 +324,6 @@ void TSpreadsheet::update_rec(int rec)
void TSpreadsheet::set_focus_cell(int riga, int colonna) void TSpreadsheet::set_focus_cell(int riga, int colonna)
{ {
_firstfocus = FALSE;
set_front_window(win()); // It seems necessary to make xi_set_focus work properly set_front_window(win()); // It seems necessary to make xi_set_focus work properly
const int r = rec2row(riga); const int r = rec2row(riga);
XI_OBJ cell; XI_OBJ cell;
@ -551,7 +552,7 @@ break;
{ {
_check_enabled = FALSE; // Avoid recursion! _check_enabled = FALSE; // Avoid recursion!
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 = sheet_mask().check_fields();
if (ok) if (ok)
{ {
mask2str(_cur_row); mask2str(_cur_row);
@ -710,23 +711,23 @@ break;
void TSpreadsheet::enable(bool on) void TSpreadsheet::enable(bool on)
{ {
const dword old = xi_get_attrib(_list); const dword old = xi_get_attrib(_list);
const dword att = on ? (old & ~XI_ATR_NAVIGATE) : (old | XI_ATR_NAVIGATE); dword att = on ? (old & ~XI_ATR_NAVIGATE) : (old | XI_ATR_NAVIGATE);
if (old != att) if (old != att)
{ {
int num; int num;
XI_OBJ** columns = xi_get_member_list(_list, &num); XI_OBJ** columns = xi_get_member_list(_list, &num);
xi_move_focus(_itf); // Set focus to interface xi_move_focus(_itf); // Set focus to interface
att = on ? (att | XI_ATR_TABWRAP) : (att & ~XI_ATR_TABWRAP);
xi_set_attrib(_list, att); xi_set_attrib(_list, att);
att = on ? (att | XI_ATR_TABWRAP) : (att & ~XI_ATR_TABWRAP);
for (int col = 1; col < num; col++) for (int col = 1; col < num; col++)
{ {
XI_OBJ* column = columns[col]; XI_OBJ* column = columns[col];
dword attr = xi_get_attrib(column); att = xi_get_attrib(column);
if (on) attr &= ~XI_ATR_READONLY; if (on) att &= ~XI_ATR_READONLY;
else attr |= XI_ATR_READONLY; else att |= XI_ATR_READONLY;
xi_set_attrib(column, attr); // Set new attributes xi_set_attrib(column, att); // Set new attributes
} }
} }
} }
@ -852,7 +853,7 @@ bool TSpreadsheet::on_key(KEY k)
// Metodi di TSpreadsheet comuni a tutte le piattaforme // Metodi di TSpreadsheet comuni a tutte le piattaforme
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TMask& TSpreadsheet::mask() TMask& TSpreadsheet::mask() const
{ {
TMask* m = (TMask*)get_app_data(parent()); TMask* m = (TMask*)get_app_data(parent());
return *m; return *m;
@ -873,12 +874,12 @@ void TSpreadsheet::mask2str(int riga)
r.cut(0); r.cut(0);
for (short id = FIRST_FIELD; ; id++) for (short id = FIRST_FIELD; ; id++)
{ {
int pos = _mask.id2pos(id); int pos = sheet_mask().id2pos(id);
if (pos < 0) break; if (pos < 0) break;
for(int dlg = id; pos >= 0; pos = _mask.id2pos(dlg += 100)) for(int dlg = id; pos >= 0; pos = sheet_mask().id2pos(dlg += 100))
{ {
const TMask_field& f = _mask.fld(pos); const TMask_field& f = sheet_mask().fld(pos);
if (f.showed()) if (f.showed())
{ {
r.add(f.get()); r.add(f.get());
@ -968,7 +969,7 @@ void TSpreadsheet::str2mask(int riga)
{ {
if (riga == items()) if (riga == items())
{ {
_mask.reset(); sheet_mask().reset();
mask2str(riga); mask2str(riga);
return; return;
} }
@ -978,7 +979,7 @@ void TSpreadsheet::str2mask(int riga)
TString80 val; TString80 val;
for (short id = FIRST_FIELD; ; id++) for (short id = FIRST_FIELD; ; id++)
{ {
int pos = _mask.id2pos(id); int pos = sheet_mask().id2pos(id);
if (pos < 0) break; if (pos < 0) break;
val = r.get(); // Value to set val = r.get(); // Value to set
@ -986,7 +987,7 @@ void TSpreadsheet::str2mask(int riga)
int rid = id; int rid = id;
while (pos >= 0) while (pos >= 0)
{ {
TMask_field& f = _mask.fld(pos); TMask_field& f = sheet_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));
@ -1001,14 +1002,14 @@ void TSpreadsheet::str2mask(int riga)
f.set_dirty(FALSE); f.set_dirty(FALSE);
} }
else else
_mask.first_focus(-rid); sheet_mask().first_focus(-rid);
rid += 100; rid += 100;
pos = _mask.id2pos(rid); pos = sheet_mask().id2pos(rid);
} }
} }
_mask.set_caption(format("Riga %d", riga+1)); sheet_mask().set_caption(format("Riga %d", riga+1));
} }
@ -1032,7 +1033,7 @@ KEY TSpreadsheet::edit(int n, KEY tasto)
const int olditems = items(); const int olditems = items();
str2mask(n); str2mask(n);
const KEY k = _mask.run(); const KEY k = sheet_mask().run();
if (k == K_ENTER) if (k == K_ENTER)
{ {
@ -1185,8 +1186,11 @@ void TSheet_field::set_notify(SPREADSHEET_NOTIFY n)
void TSheet_field::highlight() const void TSheet_field::highlight() const
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (items()) if (_sheet->_firstfocus && items())
{
_sheet->_firstfocus = FALSE;
_sheet->set_focus_cell(0, 1); _sheet->set_focus_cell(0, 1);
}
#else #else
TMask_field::highlight(); TMask_field::highlight();
#endif #endif

View File

@ -1 +1 @@
#define VERSION 1.16 #define VERSION 1.17

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.34 1994-11-24 14:01:16 guy Exp $ // $Id: relapp.cpp,v 1.35 1994-11-30 09:04:01 guy Exp $
#include <mailbox.h> #include <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -7,11 +7,35 @@
#include <xvtility.h> #include <xvtility.h>
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
extern "C" { #include <windows.h>
#include <statbar.h> #include <toolhelp.h>
}
#endif #endif
HIDDEN bool can_change_firm()
{
#ifndef DBG
static bool can = 2;
if (can == 2)
{
#if XVT_OS == XVT_OS_WIN
HTASK ct = GetCurrentTask();
TASKENTRY te;
te.dwSize = sizeof(TASKENTRY);
TaskFindHandle(&te, ct);
TaskFindHandle(&te, te.hTaskParent);
can = strcmp(te.szModule, "BA0") == 0;
#else
can = TRUE;
#endif
}
return can;
#else /* DBG */
return TRUE;
#endif
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Array delle chiavi della maschera di ricerca // Array delle chiavi della maschera di ricerca
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -709,11 +733,11 @@ bool TRelation_application::main_loop()
// Seleziona il cursore a freccia // Seleziona il cursore a freccia
set_cursor(TASK_WIN, CURSOR_ARROW); set_cursor(TASK_WIN, CURSOR_ARROW);
const bool change = _mask->query_mode() && can_change_firm();
// Dis/abilita cambio ditta // Dis/abilita cambio ditta
enable_menu_item(M_FILE_NEW, _mask->query_mode()); enable_menu_item(M_FILE_NEW, change);
// Dis/abilita cambio parametri // Dis/abilita cambio parametri
enable_menu_item(M_FILE_REVERT, _mask->query_mode()); enable_menu_item(M_FILE_REVERT, change);
k = _mask->run(); k = _mask->run();
@ -820,7 +844,6 @@ bool TRelation_application::main_loop()
return k != K_QUIT; return k != K_QUIT;
} }
bool TRelation_application::filter() bool TRelation_application::filter()
{ {
TMailbox mail; TMailbox mail;

View File

@ -154,7 +154,6 @@ void TWindow_manager::unreg(const TWindow* m)
} }
} }
void close_all_dialogs() void close_all_dialogs()
{ {
WinManager.destroy(); WinManager.destroy();