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:
parent
5f3e554116
commit
5fc07b4f63
@ -247,7 +247,12 @@ long TApplication::handler(WINDOW win, EVENT* ep)
|
||||
TBanner banner;
|
||||
_create_ok = create();
|
||||
}
|
||||
if (!_create_ok)
|
||||
if (_create_ok)
|
||||
{
|
||||
on_firm_change();
|
||||
on_config_change();
|
||||
}
|
||||
else
|
||||
stop_run();
|
||||
#if XVT_OS == XVT_OS_SCOUNIX
|
||||
else
|
||||
@ -272,6 +277,7 @@ else
|
||||
break;
|
||||
case M_FILE_REVERT:
|
||||
config();
|
||||
on_config_change();
|
||||
break;
|
||||
case (M_FILE+11):
|
||||
about();
|
||||
@ -614,6 +620,19 @@ bool TApplication::set_firm(long newfirm)
|
||||
{
|
||||
prefhndl->set_codditta(newfirm);
|
||||
_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;
|
||||
@ -652,12 +671,10 @@ bool TApplication::config()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// run mask
|
||||
disable_menu_item(M_FILE_NEW);
|
||||
disable_menu_item(M_FILE_REVERT);
|
||||
|
||||
if (m.run() == K_ENTER)
|
||||
if (m.run() == K_ENTER && m.dirty())
|
||||
{
|
||||
// aggiusta campi
|
||||
for (i = 0; i < m.fields(); i++)
|
||||
@ -667,26 +684,20 @@ bool TApplication::config()
|
||||
{
|
||||
const TFieldref* fref = f.field();
|
||||
if (fref != NULL)
|
||||
{
|
||||
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);
|
||||
}
|
||||
cnf.set(fref->name(), f.get(), NULL, TRUE);
|
||||
}
|
||||
}
|
||||
ok = TRUE;
|
||||
}
|
||||
else ok = FALSE;
|
||||
enable_menu_item(M_FILE_NEW);
|
||||
|
||||
enable_menu_item(M_FILE_REVERT);
|
||||
return ok;
|
||||
}
|
||||
return warning_box("Nessun parametro da configurare");
|
||||
}
|
||||
|
||||
bool TApplication::change_config(const char* var, const char* oldv,
|
||||
const char* newv)
|
||||
void TApplication::on_firm_change()
|
||||
{}
|
||||
|
||||
{ return TRUE; }
|
||||
void TApplication::on_config_change()
|
||||
{}
|
||||
|
@ -16,9 +16,9 @@
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message (printapp -> relapp)
|
||||
#define CHK_ALL -1 // all authorization checks
|
||||
#define CHK_DONGLE 0 // dongle authorization checks
|
||||
#define CHK_USER 1 // user authorization checks
|
||||
#define CHK_ALL -1 // all authorization checks
|
||||
#define CHK_DONGLE 0 // dongle authorization checks
|
||||
#define CHK_USER 1 // user authorization checks
|
||||
|
||||
class TApplication
|
||||
{
|
||||
@ -49,7 +49,9 @@ protected:
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
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 terminate();
|
||||
|
@ -2,9 +2,7 @@
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
#include <mask.h>
|
||||
#include <maskfld.h>
|
||||
#include <relation.h>
|
||||
#include <xvtility.h>
|
||||
|
||||
bool TConfig_application::create()
|
||||
{
|
||||
|
@ -94,9 +94,8 @@ void TConfig::_write_file()
|
||||
|
||||
out.close(); in.close();
|
||||
TFilename bak(_file); bak.ext("bak");
|
||||
rename(_file,bak);
|
||||
fcopy(temp,_file);
|
||||
remove(temp);
|
||||
rename(_file, bak);
|
||||
rename(temp, _file);
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,9 +47,14 @@ bool TExternal_app::can_run() const
|
||||
int TExternal_app::run(bool async, bool iconized)
|
||||
{
|
||||
TString256 path(_path);
|
||||
if (iconized)
|
||||
path << " -icon";
|
||||
path << " -u" << main_app().user();
|
||||
|
||||
if (!async)
|
||||
{
|
||||
if (iconized)
|
||||
path << " -icon";
|
||||
path << " -u" << main_app().user();
|
||||
}
|
||||
|
||||
_error = 0;
|
||||
_exitcode = 0;
|
||||
|
||||
|
@ -1329,17 +1329,19 @@ void TBaseisamfile::recover()
|
||||
|
||||
fn = fn.name();
|
||||
#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;
|
||||
TString mess(80);
|
||||
|
||||
mess.format("Ricostruzione archivio %s : I Fase", (const char*) fn);
|
||||
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.eox() = fh->d->EOX = nitems;
|
||||
d.put(num(), _nordir, _sysdirop);
|
||||
d.put(num(), dir, _sysdirop);
|
||||
for (TRecnotype r = 1; r <= nitems; r++)
|
||||
{
|
||||
p.addstatus(1);
|
||||
|
@ -131,6 +131,10 @@ void TMask::handler(WINDOW win, EVENT* ep)
|
||||
#endif
|
||||
update();
|
||||
return;
|
||||
case E_COMMAND:
|
||||
if (ep->v.cmd.tag == M_FILE_NEW)
|
||||
on_firm_change();
|
||||
break;
|
||||
case E_CONTROL:
|
||||
switch(ep->v.ctl.id)
|
||||
{
|
||||
@ -201,6 +205,7 @@ void TMask::read_mask(const char* name, int num, int max)
|
||||
TScanner scanner(_source_file);
|
||||
|
||||
_sheetmask = num > 0;
|
||||
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
while (scanner.ok())
|
||||
@ -1040,7 +1045,6 @@ byte TMask::num_keys() const
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
void TMask::enable_key(byte key, bool on)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (fld_id < 1)
|
||||
{
|
||||
for (int i = 0; i < fields(); i++)
|
||||
if (fld_id <= 0)
|
||||
{
|
||||
const int gr = -fld_id;
|
||||
for (int i = 0; i < fields(); i++) if (fld(i).in_group(gr))
|
||||
fld(i).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)
|
||||
{
|
||||
if (fld_id < 1)
|
||||
if (fld_id <= 0)
|
||||
{
|
||||
for (int i = 0; i < fields(); i++)
|
||||
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)
|
||||
{
|
||||
if (to == 0)
|
||||
@ -1178,11 +1200,11 @@ void TMask::send_key(KEY key, short to, TMask_field* from)
|
||||
else
|
||||
{
|
||||
const int max = fields();
|
||||
to = -to;
|
||||
const int gr = -to;
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
TMask_field& campo = fld(i);
|
||||
if (campo.in_group((int)to))
|
||||
if (campo.in_group(gr))
|
||||
campo.on_key(key);
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +147,7 @@ public:
|
||||
int focus_field() const { return _focus;}
|
||||
|
||||
virtual bool on_key(KEY key);
|
||||
void on_firm_change();
|
||||
|
||||
void enable(short fld_id, bool on = TRUE); // Abilita un campo
|
||||
void disable(short fld_id) { enable(fld_id, FALSE); }
|
||||
|
@ -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 <applicat.h>
|
||||
@ -1515,10 +1515,6 @@ bool TBrowse::check(CheckTime t)
|
||||
if (_secondary == TRUE && t != RUNNING_CHECK)
|
||||
return TRUE;
|
||||
|
||||
// if (_checked && t == FINAL_CHECK)
|
||||
// return TRUE;
|
||||
// _checked = TRUE;
|
||||
|
||||
if (_fld->check_type() != CHECK_NONE)
|
||||
{
|
||||
const TMaskmode mode = (TMaskmode)field().mask().mode();
|
||||
@ -2400,13 +2396,19 @@ bool TDate_field::on_key(KEY key)
|
||||
changed = TRUE;
|
||||
}
|
||||
else
|
||||
if (data == "ULTIMO")
|
||||
if (data == "NATALE")
|
||||
{
|
||||
gstring.overwrite("31-12", 0);
|
||||
gstring.overwrite("25-12", 0);
|
||||
changed = TRUE;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ const short FIRST_FIELD = 101;
|
||||
|
||||
class TSpreadsheet : public TWindow
|
||||
{
|
||||
friend class TSheet_field;
|
||||
|
||||
enum { ITF_CID = 0, LIST_CID = 1 };
|
||||
|
||||
TArray _str; // Array di TToken_strings
|
||||
@ -70,7 +72,7 @@ public:
|
||||
bool cell_disabled(int row, int column) const;
|
||||
|
||||
TMask& sheet_mask() { return _mask; }
|
||||
TMask& mask();
|
||||
TMask& mask() const;
|
||||
|
||||
void mask2str(int n);
|
||||
void str2mask(int n);
|
||||
@ -251,7 +253,7 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
|
||||
}
|
||||
|
||||
TSpreadsheet::~TSpreadsheet()
|
||||
{
|
||||
{
|
||||
set_win(NULL_WIN);
|
||||
}
|
||||
|
||||
@ -322,7 +324,6 @@ void TSpreadsheet::update_rec(int rec)
|
||||
|
||||
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
|
||||
const int r = rec2row(riga);
|
||||
XI_OBJ cell;
|
||||
@ -551,7 +552,7 @@ break;
|
||||
{
|
||||
_check_enabled = FALSE; // Avoid recursion!
|
||||
str2mask(_cur_row); // It shouldn't have to be necessary
|
||||
bool ok = _mask.check_fields();
|
||||
bool ok = sheet_mask().check_fields();
|
||||
if (ok)
|
||||
{
|
||||
mask2str(_cur_row);
|
||||
@ -710,23 +711,23 @@ break;
|
||||
void TSpreadsheet::enable(bool on)
|
||||
{
|
||||
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)
|
||||
{
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_list, &num);
|
||||
|
||||
xi_move_focus(_itf); // Set focus to interface
|
||||
att = on ? (att | XI_ATR_TABWRAP) : (att & ~XI_ATR_TABWRAP);
|
||||
xi_set_attrib(_list, att);
|
||||
|
||||
att = on ? (att | XI_ATR_TABWRAP) : (att & ~XI_ATR_TABWRAP);
|
||||
for (int col = 1; col < num; col++)
|
||||
{
|
||||
XI_OBJ* column = columns[col];
|
||||
dword attr = xi_get_attrib(column);
|
||||
if (on) attr &= ~XI_ATR_READONLY;
|
||||
else attr |= XI_ATR_READONLY;
|
||||
xi_set_attrib(column, attr); // Set new attributes
|
||||
att = xi_get_attrib(column);
|
||||
if (on) att &= ~XI_ATR_READONLY;
|
||||
else att |= XI_ATR_READONLY;
|
||||
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
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TMask& TSpreadsheet::mask()
|
||||
TMask& TSpreadsheet::mask() const
|
||||
{
|
||||
TMask* m = (TMask*)get_app_data(parent());
|
||||
return *m;
|
||||
@ -873,12 +874,12 @@ void TSpreadsheet::mask2str(int riga)
|
||||
r.cut(0);
|
||||
for (short id = FIRST_FIELD; ; id++)
|
||||
{
|
||||
int pos = _mask.id2pos(id);
|
||||
int pos = sheet_mask().id2pos(id);
|
||||
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())
|
||||
{
|
||||
r.add(f.get());
|
||||
@ -968,7 +969,7 @@ void TSpreadsheet::str2mask(int riga)
|
||||
{
|
||||
if (riga == items())
|
||||
{
|
||||
_mask.reset();
|
||||
sheet_mask().reset();
|
||||
mask2str(riga);
|
||||
return;
|
||||
}
|
||||
@ -978,7 +979,7 @@ void TSpreadsheet::str2mask(int riga)
|
||||
TString80 val;
|
||||
for (short id = FIRST_FIELD; ; id++)
|
||||
{
|
||||
int pos = _mask.id2pos(id);
|
||||
int pos = sheet_mask().id2pos(id);
|
||||
if (pos < 0) break;
|
||||
|
||||
val = r.get(); // Value to set
|
||||
@ -986,7 +987,7 @@ void TSpreadsheet::str2mask(int riga)
|
||||
int rid = id;
|
||||
while (pos >= 0)
|
||||
{
|
||||
TMask_field& f = _mask.fld(pos);
|
||||
TMask_field& f = sheet_mask().fld(pos);
|
||||
f.set(val);
|
||||
f.enable(!cell_disabled(riga, id-FIRST_FIELD));
|
||||
|
||||
@ -1001,14 +1002,14 @@ void TSpreadsheet::str2mask(int riga)
|
||||
f.set_dirty(FALSE);
|
||||
}
|
||||
else
|
||||
_mask.first_focus(-rid);
|
||||
sheet_mask().first_focus(-rid);
|
||||
|
||||
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();
|
||||
str2mask(n);
|
||||
|
||||
const KEY k = _mask.run();
|
||||
const KEY k = sheet_mask().run();
|
||||
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
@ -1185,8 +1186,11 @@ void TSheet_field::set_notify(SPREADSHEET_NOTIFY n)
|
||||
void TSheet_field::highlight() const
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
if (items())
|
||||
if (_sheet->_firstfocus && items())
|
||||
{
|
||||
_sheet->_firstfocus = FALSE;
|
||||
_sheet->set_focus_cell(0, 1);
|
||||
}
|
||||
#else
|
||||
TMask_field::highlight();
|
||||
#endif
|
||||
|
@ -1 +1 @@
|
||||
#define VERSION 1.16
|
||||
#define VERSION 1.17
|
||||
|
@ -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 <sheet.h>
|
||||
#include <urldefid.h>
|
||||
@ -7,11 +7,35 @@
|
||||
#include <xvtility.h>
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
extern "C" {
|
||||
#include <statbar.h>
|
||||
}
|
||||
#include <windows.h>
|
||||
#include <toolhelp.h>
|
||||
#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
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -709,11 +733,11 @@ bool TRelation_application::main_loop()
|
||||
// Seleziona il cursore a freccia
|
||||
set_cursor(TASK_WIN, CURSOR_ARROW);
|
||||
|
||||
const bool change = _mask->query_mode() && can_change_firm();
|
||||
// Dis/abilita cambio ditta
|
||||
enable_menu_item(M_FILE_NEW, _mask->query_mode());
|
||||
|
||||
enable_menu_item(M_FILE_NEW, change);
|
||||
// Dis/abilita cambio parametri
|
||||
enable_menu_item(M_FILE_REVERT, _mask->query_mode());
|
||||
enable_menu_item(M_FILE_REVERT, change);
|
||||
|
||||
k = _mask->run();
|
||||
|
||||
@ -820,7 +844,6 @@ bool TRelation_application::main_loop()
|
||||
return k != K_QUIT;
|
||||
}
|
||||
|
||||
|
||||
bool TRelation_application::filter()
|
||||
{
|
||||
TMailbox mail;
|
||||
|
@ -154,7 +154,6 @@ void TWindow_manager::unreg(const TWindow* m)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void close_all_dialogs()
|
||||
{
|
||||
WinManager.destroy();
|
||||
|
Loading…
x
Reference in New Issue
Block a user