Corretta _msg_key

git-svn-id: svn://10.65.10.50/trunk@2998 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1996-06-17 08:52:00 +00:00
parent 57c332a0d4
commit 3ea25e2ce3
2 changed files with 174 additions and 174 deletions

View File

@ -19,7 +19,7 @@
#define NULL_PAGE 256 #define NULL_PAGE 256
HIDDEN const char* const MASK_EXT = "msk"; HIDDEN const char* const MASK_EXT = "msk";
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TMask methods // TMask methods
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -40,8 +40,10 @@ void TMask::init_mask()
_handler = NULL; // Nessun handler utente _handler = NULL; // Nessun handler utente
_mode = NO_MODE; // Inizializza modo _mode = NO_MODE; // Inizializza modo
_exchange = 1.0; // Il cambio per la valuta e' la lira _exchange = 1.0; // Il cambio per la valuta e' la lira
_error_severity = 0; _error_severity = 0;
_msg_field = 0;
_msg_key = 0;
_test_fld = -1; _test_fld = -1;
_last_test = -1; _last_test = -1;
@ -49,12 +51,12 @@ void TMask::init_mask()
} }
TMask::TMask(const char* title, int pages, int cols, int rows, TMask::TMask(const char* title, int pages, int cols, int rows,
int xpos, int ypos) int xpos, int ypos)
{ {
init_mask(); init_mask();
for (_pages = 0; _pages < pages; _pages++) for (_pages = 0; _pages < pages; _pages++)
_pagewin[_pages] = create_interface(NULL_WIN, xpos, ypos, _pagewin[_pages] = create_interface(NULL_WIN, xpos, ypos,
cols, rows, title, this, pages > 1); cols, rows, title, this, pages > 1);
} }
@ -79,15 +81,15 @@ void TMask::read_mask(
if (num == 0) if (num == 0)
_total_time = _build_time = _init_time = 0; _total_time = _build_time = _init_time = 0;
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
while (scanner.ok()) while (scanner.ok())
if (scanner.line() == "ENDMASK") break; if (scanner.line() == "ENDMASK") break;
} }
init_mask(); init_mask();
TToken_string captions(80); TToken_string captions(80);
main_app().begin_wait(); main_app().begin_wait();
@ -97,11 +99,11 @@ void TMask::read_mask(
{ {
CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages); CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages);
WINDOW w = read_page(scanner, FALSE); WINDOW w = read_page(scanner, FALSE);
TString title(80); TString title(80);
xvt_vobj_get_title(w, (char*)(const char*)title, title.size()); xvt_vobj_get_title(w, (char*)(const char*)title, title.size());
captions.add(title); captions.add(title);
_pagewin[_pages++] = w; _pagewin[_pages++] = w;
if (_pages >= max) if (_pages >= max)
break; break;
@ -117,7 +119,7 @@ void TMask::read_mask(
fatal_box("Impossibile leggere la maschera %s", name); fatal_box("Impossibile leggere la maschera %s", name);
if (_pages > 1 || toolwin()) if (_pages > 1 || toolwin())
add_tag_buttons(captions); add_tag_buttons(captions);
if (num == 0) if (num == 0)
_total_time = clock()-start_t; _total_time = clock()-start_t;
@ -126,25 +128,25 @@ void TMask::read_mask(
} }
void TMask::add_tag_button(byte pag, TToken_string& tags, byte sel) void TMask::add_tag_button(byte pag, TToken_string& tags, byte sel)
{ {
TTagbutton_control* tb = new TTagbutton_control(_pagewin[pag], 32000, 0, 0, 80, 1, "", tags, sel); TTagbutton_control* tb = new TTagbutton_control(_pagewin[pag], 32000, 0, 0, 80, 1, "", tags, sel);
_pagetag.add(tb, pag); _pagetag.add(tb, pag);
} }
void TMask::add_tag_buttons(TToken_string& tags) void TMask::add_tag_buttons(TToken_string& tags)
{ {
for (byte p = 0; p < _pages; p++) for (byte p = 0; p < _pages; p++)
add_tag_button(p, tags, p); add_tag_button(p, tags, p);
} }
void TMask::add_default_tag_buttons() void TMask::add_default_tag_buttons()
{ {
TToken_string tags(_pages * 6); TToken_string tags(_pages * 6);
for (int p = 1; p <= _pages; p++) for (int p = 1; p <= _pages; p++)
{ {
tags.add("Pag."); tags.add("Pag.");
tags << p; tags << p;
} }
add_tag_buttons(tags); add_tag_buttons(tags);
} }
@ -170,13 +172,13 @@ word TMask::class_id() const
bool TMask::is_kind_of(word c) const bool TMask::is_kind_of(word c) const
{ {
if (c == CLASS_MASK) if (c == CLASS_MASK)
return TRUE; return TRUE;
return TWindow::is_kind_of(c); return TWindow::is_kind_of(c);
} }
void TMask::open() void TMask::open()
{ {
if (!_open || _page != 0) if (!_open || _page != 0)
{ {
_open = TRUE; _open = TRUE;
@ -188,8 +190,8 @@ void TMask::open()
} }
int TMask::find_first_active(WINDOW p) const int TMask::find_first_active(WINDOW p) const
{ {
const int max = fields(); const int max = fields();
for (int f = 0; f < max; f++) for (int f = 0; f < max; f++)
{ {
TMask_field& c = fld(f); TMask_field& c = fld(f);
@ -205,7 +207,7 @@ int TMask::first_focus(short id)
int f = _first_focus; int f = _first_focus;
if (id == 0) if (id == 0)
{ {
if (tempfirstfocus >= 0) if (tempfirstfocus >= 0)
{ {
f = tempfirstfocus; f = tempfirstfocus;
@ -214,15 +216,15 @@ int TMask::first_focus(short id)
tempfirstfocus = -1; tempfirstfocus = -1;
} }
else else
{ {
if (f < 0 || !fld(f).active()) if (f < 0 || !fld(f).active())
{ {
f = find_first_active(_pagewin[0]); f = find_first_active(_pagewin[0]);
if (f < 0 && toolwin()) if (f < 0 && toolwin())
f = find_first_active(toolwin()); f = find_first_active(toolwin());
_first_focus = f; _first_focus = f;
} }
} }
} }
else else
{ {
@ -234,7 +236,7 @@ int TMask::first_focus(short id)
else else
f = tempfirstfocus = id2pos(-id); f = tempfirstfocus = id2pos(-id);
} }
CHECKD(f >= 0 && f < fields() && fld(f).active(), "Invalid focus field ", f); CHECKD(f >= 0 && f < fields() && fld(f).active(), "Invalid focus field ", f);
return f; return f;
} }
@ -242,28 +244,28 @@ int TMask::first_focus(short id)
TOperable_field& TMask::focus_field() const TOperable_field& TMask::focus_field() const
{ {
const short focus = get_focus_id(win()); const short focus = get_focus_id(win());
if (focus > 0 ) if (focus > 0 )
((TMask *)this)->_focus = id2pos(focus); ((TMask *)this)->_focus = id2pos(focus);
TMask_field & f = fld(_focus); TMask_field & f = fld(_focus);
CHECK(f.is_kind_of(CLASS_OPERABLE_FIELD), "Can't set focus to non operable_field"); CHECK(f.is_kind_of(CLASS_OPERABLE_FIELD), "Can't set focus to non operable_field");
return (TOperable_field&)f; return (TOperable_field&)f;
} }
void TMask::set_focus_field(short id) void TMask::set_focus_field(short id)
{ {
const int pos = id2pos(id); const int pos = id2pos(id);
CHECKD(pos >= 0, "Can't set focus to field ", id); CHECKD(pos >= 0, "Can't set focus to field ", id);
_focus = pos; _focus = pos;
if (is_open()) if (is_open())
{ {
const TMask_field& f = fld(pos); const TMask_field& f = fld(pos);
int p = find_parent_page(f); int p = find_parent_page(f);
if (p < 0 || p >= _pages || !page_enabled(p)) if (p < 0 || p >= _pages || !page_enabled(p))
p = 0; p = 0;
show_page(p); show_page(p);
} }
} }
void TMask::notify_focus_field(short id) void TMask::notify_focus_field(short id)
@ -289,7 +291,7 @@ void TMask::close()
} }
short TMask::dirty() const short TMask::dirty() const
{ {
const int max = fields(); const int max = fields();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
@ -332,7 +334,7 @@ void TMask::enable_page(
{ {
TTagbutton_control& tag = (TTagbutton_control&)_pagetag[b]; TTagbutton_control& tag = (TTagbutton_control&)_pagetag[b];
tag.show_button(i, on); tag.show_button(i, on);
} }
} }
} }
} }
@ -340,7 +342,7 @@ void TMask::enable_page(
// Controlla lo stato di abilitazione di una pagina // Controlla lo stato di abilitazione di una pagina
// Certified 100% // Certified 100%
bool TMask::page_enabled(byte p) const bool TMask::page_enabled(byte p) const
{ {
CHECKD(p <= MAX_PAGES, "Page too high ", (int)p); CHECKD(p <= MAX_PAGES, "Page too high ", (int)p);
const bool on = _pagewin[p] != NULL_WIN && _enabled[p]; const bool on = _pagewin[p] != NULL_WIN && _enabled[p];
return on; return on;
@ -351,25 +353,25 @@ void TMask::start_run()
{ {
const long start = clock(); const long start = clock();
const int max = fields(); const int max = fields();
if (_should_check) if (_should_check)
{ {
load_checks(); load_checks();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (f.dirty() <= TRUE) if (f.dirty() <= TRUE)
{ {
f.set_dirty(FALSE); f.set_dirty(FALSE);
const bool op = f.is_operable() && !f.is_kind_of(CLASS_BUTTON_FIELD); const bool op = f.is_operable() && !f.is_kind_of(CLASS_BUTTON_FIELD);
if (op && (f.active() || f.ghost())) if (op && (f.active() || f.ghost()))
f.on_hit(); // Lancia messaggio di inizializzazione f.on_hit(); // Lancia messaggio di inizializzazione
} }
} }
} }
_should_check = TRUE; _should_check = TRUE;
// Make sure that "nearly" all fields are clean! // Make sure that "nearly" all fields are clean!
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
@ -410,25 +412,25 @@ bool TMask::check_fields()
break; // Page disabled: end of test break; // Page disabled: end of test
curpage = f.parent(); // Update current page curpage = f.parent(); // Update current page
} }
if (sheet) f.set_dirty(); // Force check in sheet masks if (sheet) f.set_dirty(); // Force check in sheet masks
if (f.on_key(K_ENTER) == FALSE) if (f.on_key(K_ENTER) == FALSE)
{ {
if (is_open()) if (is_open())
set_focus_field(f.dlg()); set_focus_field(f.dlg());
return FALSE; return FALSE;
} }
} }
} }
return TRUE; return TRUE;
} }
void TMask::check_field( short fld_id ) void TMask::check_field( short fld_id )
{ {
field( fld_id ).on_hit(); field( fld_id ).on_hit();
field( fld_id ).check(); field( fld_id ).check();
} }
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Converte un identificatore di campo nella sua posizione // @mfunc Converte un identificatore di campo nella sua posizione
@ -436,7 +438,7 @@ void TMask::check_field( short fld_id )
// @rdesc Ritorna la posizione del campo nella maschera (-1 se non lo trova) // @rdesc Ritorna la posizione del campo nella maschera (-1 se non lo trova)
int TMask::id2pos( int TMask::id2pos(
short id) const // @parm Identificatore del campo del quale trovare la posizione short id) const // @parm Identificatore del campo del quale trovare la posizione
// @comm Cerca nella maschera il campo con identificatore <p id> e ne ritorna il numero ordinale // @comm Cerca nella maschera il campo con identificatore <p id> e ne ritorna il numero ordinale
// (es. il campo 120 e' il quarto della maschera) // (es. il campo 120 e' il quarto della maschera)
{ {
@ -514,7 +516,7 @@ int TMask::find_parent_page(const TMask_field& f) const
// @flag FALSE | Non e' riuscita a chiudere la maschera // @flag FALSE | Non e' riuscita a chiudere la maschera
bool TMask::stop_run( bool TMask::stop_run(
KEY key) // @parm Tasto che deve provocare la chiusura KEY key) // @parm Tasto che deve provocare la chiusura
// @comm Permette di chiudere la maschera come se l'utente avesse premuto il tasto <p key>. // @comm Permette di chiudere la maschera come se l'utente avesse premuto il tasto <p key>.
// Nel caso la maschera non si chiuda (es. un check fallito), ritorna FALSE. // Nel caso la maschera non si chiuda (es. un check fallito), ritorna FALSE.
{ {
@ -529,7 +531,7 @@ bool TMask::stop_run(
const TButton_field& b = (const TButton_field&)f; const TButton_field& b = (const TButton_field&)f;
if (b.exit_key() == key) if (b.exit_key() == key)
break; break;
} }
} }
if (i >= last) if (i >= last)
return FALSE; return FALSE;
@ -539,9 +541,9 @@ bool TMask::stop_run(
if (key == K_FORCE_CLOSE) key = K_QUIT; if (key == K_FORCE_CLOSE) key = K_QUIT;
if (key != K_ESC && key != K_QUIT && key != K_DEL && key != K_F9) if (key != K_ESC && key != K_QUIT && key != K_DEL && key != K_F9)
{ {
bool ok = check_current_field(); bool ok = check_current_field();
if (ok) if (ok)
ok = check_fields(); ok = check_fields();
if (!ok) return FALSE; if (!ok) return FALSE;
} }
@ -564,9 +566,9 @@ void TMask::on_button(short)
// @flag FALSE | Non era prevista nessuna azione collegata al tasto // @flag FALSE | Non era prevista nessuna azione collegata al tasto
bool TMask::on_key( bool TMask::on_key(
KEY key) // @parm Tasto premuto sulla maschera KEY key) // @parm Tasto premuto sulla maschera
// @comm Controlla se il tasto e' tra quelli standard previsti dalla maschera corrente, in caso // @comm Controlla se il tasto e' tra quelli standard previsti dalla maschera corrente, in caso
// contrario ne assegna una azione // contrario ne assegna una azione
{ {
if (_handler) if (_handler)
{ {
@ -600,27 +602,27 @@ bool TMask::on_key(
BYTE mkKeylist; BYTE mkKeylist;
char mkKeyphrase[16]; char mkKeyphrase[16];
} mk; } mk;
TFilename topic(source_file()); topic.ext(""); TFilename topic(source_file()); topic.ext("");
mk.mkSize = sizeof(MULTIGUY); mk.mkSize = sizeof(MULTIGUY);
mk.mkKeylist = 'M'; mk.mkKeylist = 'M';
strcpy(mk.mkKeyphrase, topic); strcpy(mk.mkKeyphrase, topic);
TFilename hlp("prassi.hlp"); TFilename hlp("prassi.hlp");
const TString16 mod(topic.left(2)); const TString16 mod(topic.left(2));
if (mod != "ba") hlp.insert(mod, 0); if (mod != "ba") hlp.insert(mod, 0);
HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW); HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, hlp, HELP_MULTIKEY, (DWORD)&mk); WinHelp(hwnd, hlp, HELP_MULTIKEY, (DWORD)&mk);
next_page(0); next_page(0);
} }
#endif #endif
break; break;
case K_F12: case K_F12:
post_error_message(format("Lettura = %ld\n" post_error_message(format("Lettura = %ld\n"
"Creazione = %ld\n" "Creazione = %ld\n"
"Inizializzazione = %ld\n", "Inizializzazione = %ld\n",
_total_time-_build_time, _build_time, _init_time), _total_time-_build_time, _build_time, _init_time),
1); 1);
break; break;
default: default:
@ -646,7 +648,7 @@ bool TMask::on_key(
f.on_key(K_SPACE); f.on_key(K_SPACE);
break; break;
} }
} }
} }
} }
} }
@ -662,7 +664,7 @@ bool TMask::on_dirty(TMask_field&)
TMask_field* TMask::parse_field(TScanner& scanner) TMask_field* TMask::parse_field(TScanner& scanner)
{ {
const TString& k = scanner.key(); const TString& k = scanner.key();
if (k == "ST") return new TEdit_field(this); if (k == "ST") return new TEdit_field(this);
if (k == "NU") return new TReal_field(this); if (k == "NU") return new TReal_field(this);
@ -684,7 +686,7 @@ TMask_field* TMask::parse_field(TScanner& scanner)
return NULL; return NULL;
} }
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Legge la pagina dal file // @mfunc Legge la pagina dal file
@ -693,7 +695,7 @@ TMask_field* TMask::parse_field(TScanner& scanner)
WINDOW TMask::read_page( WINDOW TMask::read_page(
TScanner& scanner, // @parm File dal quale leggere la pagina TScanner& scanner, // @parm File dal quale leggere la pagina
bool toolbar) // @parm Indica se e' la toolbar bool toolbar) // @parm Indica se e' la toolbar
// @comm Il parametro <p toolbar> e' utilizzato per indicare se la pagina deve essere visualizzata // @comm Il parametro <p toolbar> e' utilizzato per indicare se la pagina deve essere visualizzata
// a tutto schermo (TRUE) oppure no // a tutto schermo (TRUE) oppure no
{ {
@ -721,30 +723,30 @@ WINDOW TMask::read_page(
else r = rect; else r = rect;
} }
} }
bool orecchie = _pagewin[0] != NULL_WIN || toolwin(); bool orecchie = _pagewin[0] != NULL_WIN || toolwin();
if (!orecchie && !toolbar) // Controlla se la maschera ha piu' di una pagina if (!orecchie && !toolbar) // Controlla se la maschera ha piu' di una pagina
{ {
const streampos pos = scanner.tellg(); // Memorizza posizione dello scanner const streampos pos = scanner.tellg(); // Memorizza posizione dello scanner
TString l(scanner.line().left(2)); TString l(scanner.line().left(2));
while (l != "EN" && l.not_empty()) while (l != "EN" && l.not_empty())
{ {
if (l == "PA") // Ho trovato un'altra pagina! if (l == "PA") // Ho trovato un'altra pagina!
{ {
orecchie = TRUE; // Quindi devo metterci le orecchie orecchie = TRUE; // Quindi devo metterci le orecchie
break; break;
} }
l = scanner.line().left(2); l = scanner.line().left(2);
} }
scanner.seekg(pos); // Ripristin aposizione dello scanner scanner.seekg(pos); // Ripristin aposizione dello scanner
} }
WINDOW w; WINDOW w;
if (toolbar || toolwin()) if (toolbar || toolwin())
{ {
w = create_interface(NULL_WIN, 0, r.top, 0, toolbar ? 0 : tooly, title, this, orecchie); w = create_interface(NULL_WIN, 0, r.top, 0, toolbar ? 0 : tooly, title, this, orecchie);
} }
else else
{ {
w = create_interface(NULL_WIN, r.left, r.top, r.right, r.bottom, title, this, orecchie); w = create_interface(NULL_WIN, r.left, r.top, r.right, r.bottom, title, this, orecchie);
} }
@ -754,7 +756,7 @@ WINDOW TMask::read_page(
TMask_field* f = parse_field(scanner); TMask_field* f = parse_field(scanner);
#ifdef DBG #ifdef DBG
if (f == NULL) if (f == NULL)
{ {
const int f = fields(); const int f = fields();
TString e("Unknown control at position "); e << f; TString e("Unknown control at position "); e << f;
if (f > 0) e << ".\nLast good one was " << fld(f-1).dlg() << ": " << fld(f-1).prompt(); if (f > 0) e << ".\nLast good one was " << fld(f-1).dlg() << ": " << fld(f-1).prompt();
@ -762,16 +764,16 @@ WINDOW TMask::read_page(
while (scanner.popkey() != "EN"); while (scanner.popkey() != "EN");
} }
#endif #endif
if (f != NULL) if (f != NULL)
{ {
const long start = clock(); const long start = clock();
f->construct(scanner, w); f->construct(scanner, w);
_field.add(f); _field.add(f);
_build_time += clock()-start; _build_time += clock()-start;
} }
} }
return w; return w;
@ -783,18 +785,18 @@ bool TMask::check_current_field() const
if (_focus >= 0) if (_focus >= 0)
{ {
TMask_field& ff = fld(_focus); TMask_field& ff = fld(_focus);
if (ff.focusdirty()) if (ff.focusdirty())
ok = ff.on_key(K_TAB); ok = ff.on_key(K_TAB);
} }
return ok; return ok;
} }
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Mostra la prossima/precedente pagina // @mfunc Mostra la prossima/precedente pagina
void TMask::next_page( void TMask::next_page(
int p) // @parm Pagina alla quale saltare int p) // @parm Pagina alla quale saltare
// @comm Il valore <p p> puo' assumere i seguenti valori: // @comm Il valore <p p> puo' assumere i seguenti valori:
// //
// @flag -1 | Mostra la pagina precedente // @flag -1 | Mostra la pagina precedente
@ -821,23 +823,23 @@ void TMask::next_page(
if (prev >= 0) if (prev >= 0)
xvt_vobj_set_visible(_pagewin[prev], FALSE); xvt_vobj_set_visible(_pagewin[prev], FALSE);
} }
TMask_field& ff = fld(_focus); TMask_field& ff = fld(_focus);
if (ff.parent() != win() || !ff.active()) if (ff.parent() != win() || !ff.active())
{ {
_focus = find_first_active(win()); _focus = find_first_active(win());
if (_focus < 0 && toolwin() != NULL_WIN) if (_focus < 0 && toolwin() != NULL_WIN)
_focus = find_first_active(toolwin()); _focus = find_first_active(toolwin());
} }
if (_focus >= 0) if (_focus >= 0)
{ {
TMask_field& ff = fld(_focus); TMask_field& ff = fld(_focus);
if (ff.active()) if (ff.active())
ff.highlight(); ff.highlight();
} }
TWindow::set_focus(); TWindow::set_focus();
} }
void TMask::show_page(int p) void TMask::show_page(int p)
@ -858,7 +860,7 @@ void TMask::reset(short fld_id)
{ {
c._flags.dirty = c._flags.focusdirty = FALSE; c._flags.dirty = c._flags.focusdirty = FALSE;
c.reset(); c.reset();
} }
} }
} }
else field(fld_id).reset(); else field(fld_id).reset();
@ -877,7 +879,7 @@ long TMask::get_long(short fld_id) const
} }
bool TMask::get_bool(short fld_id) const bool TMask::get_bool(short fld_id) const
{ {
const TString& s = field(fld_id).get(); const TString& s = field(fld_id).get();
return s.not_empty(); return s.not_empty();
} }
@ -903,17 +905,17 @@ void TMask::set(
bool hit) // @parm Indica se occorre rifare i controlli una volta settato il campo bool hit) // @parm Indica se occorre rifare i controlli una volta settato il campo
// con il nuovo valore (default FALSE) // con il nuovo valore (default FALSE)
// @parm long | n | Numero da asegnare al campo // @parm long | n | Numero da asegnare al campo
// @syntax set(short fld_id, const char *s, bool hit); // @syntax set(short fld_id, const char *s, bool hit);
// @syntax set(short fld_id, long n, bool hit); // @syntax set(short fld_id, long n, bool hit);
{ {
TMask_field& f = field(fld_id); TMask_field& f = field(fld_id);
f.set(s); f.set(s);
if (hit && (f.active() || f.ghost())) if (hit && (f.active() || f.ghost()))
{ {
f.set_dirty(); f.set_dirty();
f.on_hit(); f.on_hit();
} }
} }
void TMask::set(short fld_id, long n, bool hit) void TMask::set(short fld_id, long n, bool hit)
@ -969,7 +971,7 @@ void TMask::enable(
f.enable(on); f.enable(on);
} }
} }
else else
field(fld_id).enable(on); field(fld_id).enable(on);
} }
@ -984,9 +986,9 @@ void TMask::enable_default(short fld_id)
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (gr == 0 || f.in_group(gr)) if (gr == 0 || f.in_group(gr))
f.enable_default(); f.enable_default();
} }
} }
else else
field(fld_id).enable_default(); field(fld_id).enable_default();
} }
@ -995,13 +997,13 @@ byte TMask::num_keys() const
{ {
word max = 0; word max = 0;
for (int i = fields()-1; i >= 0; i--) for (int i = fields()-1; i >= 0; i--)
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (f.is_editable()) if (f.is_editable())
{ {
word k = ((TEditable_field&)f).last_key(); word k = ((TEditable_field&)f).last_key();
if (k > max) max = k; if (k > max) max = k;
} }
} }
return max; return max;
} }
@ -1028,10 +1030,10 @@ void TMask::enable_key(
if (!f.shown()) if (!f.shown())
f.show_default(); f.show_default();
} }
else else
f.disable(); f.disable();
} }
} }
} }
// @doc EXTERNAL // @doc EXTERNAL
@ -1049,10 +1051,10 @@ TEditable_field* TMask::get_key_field(
static int last = 0; static int last = 0;
if (first) last = 0; if (first) last = 0;
const int max = fields(); const int max = fields();
for (int i = last; i < max; i++) for (int i = last; i < max; i++)
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (f.in_key(key)) if (f.in_key(key))
{ {
@ -1077,7 +1079,7 @@ bool TMask::key_valid(int key) const
{ {
if (e.empty()) if (e.empty())
return FALSE; return FALSE;
} }
} }
} }
return TRUE; return TRUE;
@ -1114,8 +1116,8 @@ void TMask::show(
// @mfunc Rimette lo stato di default del campo // @mfunc Rimette lo stato di default del campo
void TMask::show_default( void TMask::show_default(
short fld_id) // @parm Identificatore del campo da risettare (default -1) short fld_id) // @parm Identificatore del campo da risettare (default -1)
// @comm Se <p parm> Assume il valore -1 vuole dire che vengono risettati tutti i campi della amschera // @comm Se <p parm> Assume il valore -1 vuole dire che vengono risettati tutti i campi della amschera
{ {
if (fld_id <= 0) if (fld_id <= 0)
{ {
@ -1133,12 +1135,12 @@ void TMask::autoload(const TRelation& r)
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (f.is_editable()) if (f.is_editable())
((TEditable_field&)f).autoload(r); ((TEditable_field&)f).autoload(r);
} }
} }
void TMask::autosave(TRelation& r) const void TMask::autosave(TRelation& r) const
{ {
const int max = fields(); const int max = fields();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
@ -1152,12 +1154,12 @@ void TMask::autosave(TRelation& r) const
if (!save) if (!save)
{ {
e.autoload(r); e.autoload(r);
save = f.empty(); save = f.empty();
} }
if (save) if (save)
e.autosave(r); e.autosave(r);
} }
} }
} }
} }
@ -1185,41 +1187,41 @@ void TMask::on_idle()
{ {
TOperable_field& s = (TOperable_field&)fld(_focus); TOperable_field& s = (TOperable_field&)fld(_focus);
s.on_idle(); s.on_idle();
if (_msg_field > 0) if (_msg_field > 0)
{ {
TMask_field& f = field(_msg_field); TMask_field& f = field(_msg_field);
_msg_field = 0; _msg_field = 0;
if (_msg_key > 0) if (_msg_key > 0)
f.on_key(_msg_key); f.on_key(_msg_key);
} }
} }
if (_error_severity > 0) if (_error_severity > 0)
{ {
switch(_error_severity) switch(_error_severity)
{ {
case 2: case 2:
warning_box("%s", (const char*)_error_message); break; warning_box("%s", (const char*)_error_message); break;
case 3: case 3:
error_box("%s", (const char*)_error_message); break; error_box("%s", (const char*)_error_message); break;
default: default:
message_box("%s", (const char*)_error_message); break; message_box("%s", (const char*)_error_message); break;
} }
_error_severity = 0; _error_severity = 0;
set_focus(); set_focus();
} }
if (_test_fld >= 0) if (_test_fld >= 0)
{ {
const TOperable_field & f = focus_field(); const TOperable_field & f = focus_field();
if (_last_test != f.dlg()) if (_last_test != f.dlg())
{ {
TEditable_field & e = (TEditable_field &) field(_test_fld); TEditable_field & e = (TEditable_field &) field(_test_fld);
if (!f.in_key(0) || !e.has_a_common_key(f)) if (!f.in_key(0) || !e.has_a_common_key(f))
{ {
e.test_key_complete(FALSE); e.test_key_complete(FALSE);
_test_fld = -1; _test_fld = -1;
} }
_last_test = f.dlg(); _last_test = f.dlg();
} }
} }
@ -1254,13 +1256,13 @@ void TMask::send_key(
else else
{ {
const int pos = id2pos(to); const int pos = id2pos(to);
if (pos >= 0) if (pos >= 0)
{ {
if (_msg_field > 0) if (_msg_field > 0)
on_idle(); on_idle();
_msg_field = to; _msg_field = to;
_msg_key = key; _msg_key = key;
} }
#ifdef DBG #ifdef DBG
else else
yesnofatal_box("Can't send key %u to field %d", key, to); yesnofatal_box("Can't send key %u to field %d", key, to);
@ -1294,7 +1296,7 @@ void TMask::set_handler(
// da <p fld_id>, mentre nel secondo viene mandato un <t MASK_HANDLER> // da <p fld_id>, mentre nel secondo viene mandato un <t MASK_HANDLER>
// alla maschera corrente // alla maschera corrente
{ {
TMask_field& f = field(fld_id); TMask_field& f = field(fld_id);
CHECKD(f.is_operable(), "Can't set an handler to non-operable field ", fld_id); CHECKD(f.is_operable(), "Can't set an handler to non-operable field ", fld_id);
((TOperable_field&)f).set_handler(handler); ((TOperable_field&)f).set_handler(handler);
@ -1345,7 +1347,7 @@ TEdit_field& TMask::add_string (
// @xref <mf TMask::add_static> <mf TMask::add_number> <mf TMask::add_date> // @xref <mf TMask::add_static> <mf TMask::add_number> <mf TMask::add_date>
// <mf TMask::add_button> <mf TMask::add_radio> <mf TMask::add_memo> // <mf TMask::add_button> <mf TMask::add_radio> <mf TMask::add_memo>
{ {
TEdit_field* f = new TEdit_field(this); TEdit_field* f = new TEdit_field(this);
f->construct(id, prompt, x, y, dim, _pagewin[page], flags, width); f->construct(id, prompt, x, y, dim, _pagewin[page], flags, width);
_field.add(f); _field.add(f);
return *f; return *f;
@ -1370,7 +1372,7 @@ TButton_field& TMask::add_button (
// @xref <mf TMask::add_static> <mf TMask::add_string> <mf TMask::add_number> // @xref <mf TMask::add_static> <mf TMask::add_string> <mf TMask::add_number>
// <mf TMask::add_date> <mf TMask::add_radio> <mf TMask::add_memo> // <mf TMask::add_date> <mf TMask::add_radio> <mf TMask::add_memo>
{ {
TButton_field* f = new TButton_field(this); TButton_field* f = new TButton_field(this);
f->construct(id, prompt, x, y, dy, _pagewin[page], flags, dx); f->construct(id, prompt, x, y, dy, _pagewin[page], flags, dx);
if (bmpup > 0) if (bmpup > 0)
@ -1468,7 +1470,7 @@ TList_field& TMask::add_list (
{ {
TList_field* f = new TList_field(this); TList_field* f = new TList_field(this);
f->construct(id, prompt, x, y, dim, _pagewin[page], flags); f->construct(id, prompt, x, y, dim, _pagewin[page], flags);
f->replace_items(codes,items); f->replace_items(codes,items);
_field.add(f); _field.add(f);
return *f; return *f;
} }
@ -1565,10 +1567,10 @@ bool TMask::save(
if (f == NULL) if (f == NULL)
return yesnofatal_box("Non posso aprire %s ", (const char*) _workfile); return yesnofatal_box("Non posso aprire %s ", (const char*) _workfile);
const int max = fields(); const int max = fields();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
TMask_field& c = fld(i); TMask_field& c = fld(i);
if (c.is_editable()) if (c.is_editable())
fprintf(f, "%d|%s\n", c.dlg(), (const char*)c.get()); fprintf(f, "%d|%s\n", c.dlg(), (const char*)c.get());
@ -1602,12 +1604,12 @@ bool TMask::load(
TToken_string t(256); TToken_string t(256);
while (fgets((char*)(const char*)t, t.size(), f) != NULL && t != "[EOM]") while (fgets((char*)(const char*)t, t.size(), f) != NULL && t != "[EOM]")
{ {
if (t.not_empty()) if (t.not_empty())
{ {
t.cut(t.len() - 1); t.cut(t.len() - 1);
const int pos = id2pos(t.get_int(0)); const int pos = id2pos(t.get_int(0));
if (pos >= 0) fld(pos).set(t.get()); if (pos >= 0) fld(pos).set(t.get());
} }
} }
_lastpos = ftell(f); _lastpos = ftell(f);
fclose(f); fclose(f);
@ -1617,25 +1619,25 @@ bool TMask::load(
// @doc EXTERNAL // @doc EXTERNAL
// @mfunc Copia i valori dei campi dalla maschera <p m> // @mfunc Copia i valori dei campi dalla maschera <p m>
// //
void TMask::copy_values( void TMask::copy_values(
const TMask& m) // @parm Maschera sorgente const TMask& m) // @parm Maschera sorgente
{ {
reset(); reset();
const int nfields = fields(); const int nfields = fields();
for (int i = 0; i < nfields; i++) for (int i = 0; i < nfields; i++)
{ {
TMask_field& dest_field = fld( i ); TMask_field& dest_field = fld( i );
if (dest_field.is_editable() ) if (dest_field.is_editable() )
{ {
const int pos = m.id2pos(dest_field.dlg()); const int pos = m.id2pos(dest_field.dlg());
if (pos >= 0) if (pos >= 0)
{ {
const TMask_field& source_field = m.fld(pos); const TMask_field& source_field = m.fld(pos);
dest_field.set( source_field.get( ) ); dest_field.set( source_field.get( ) );
} }
} }
} }
@ -1649,20 +1651,20 @@ const char* TMask::get_caption() const
} }
void TMask::set_caption(const char* c) void TMask::set_caption(const char* c)
{ {
TToken_string captions(c); TToken_string captions(c);
for (int p = 0; p < _pages; p++) for (int p = 0; p < _pages; p++)
{ {
const char* cap = captions.get(); const char* cap = captions.get();
if (cap == NULL) cap = captions.get(0); if (cap == NULL) cap = captions.get(0);
xvt_vobj_set_title(_pagewin[p], (char*)cap); xvt_vobj_set_title(_pagewin[p], (char*)cap);
TTagbutton_control* tag = (TTagbutton_control*)_pagetag.objptr(p); TTagbutton_control* tag = (TTagbutton_control*)_pagetag.objptr(p);
if (tag) tag->set_caption(c); if (tag) tag->set_caption(c);
} }
} }
void TMask::post_error_message(const char* msg, int sev) void TMask::post_error_message(const char* msg, int sev)
{ {
CHECK(sev > 0 && msg, "Bad error message posted"); CHECK(sev > 0 && msg, "Bad error message posted");
if (_error_severity > 0) // C'e' gia' un messaggio d'errore in coda if (_error_severity > 0) // C'e' gia' un messaggio d'errore in coda
on_idle(); on_idle();
@ -1684,11 +1686,11 @@ void TMask::set_exchange(
{ {
TMask_field& f = fld(i); TMask_field& f = fld(i);
if (f.is_operable()) if (f.is_operable())
{ {
TOperable_field& o = (TOperable_field&)f; TOperable_field& o = (TOperable_field&)f;
if (o.exchangeable() || o.is_kind_of(CLASS_SHEET_FIELD)) if (o.exchangeable() || o.is_kind_of(CLASS_SHEET_FIELD))
o.exchange(show_value, nuo); o.exchange(show_value, nuo);
} }
} }
_exchange = nuo; // Update current exchange _exchange = nuo; // Update current exchange

View File

@ -9,11 +9,7 @@
#include <maskfld.h> #include <maskfld.h>
#endif #endif
HIDDEN short _msg_field; class TSheet_field;
HIDDEN KEY _msg_key;
class TSheet_field;
// @doc EXTERNAL // @doc EXTERNAL
@ -40,7 +36,7 @@ enum TMaskmode {
class TMask : public TWindow class TMask : public TWindow
{ {
// @author:(INTERNAL) Guido // @author:(INTERNAL) Guido
// @access Protected Member // @access Protected Member
protected: protected:
@ -52,7 +48,7 @@ class TMask : public TWindow
// @cmember:(INTERNAL) Windows delle pagine // @cmember:(INTERNAL) Windows delle pagine
WINDOW _pagewin[MAX_PAGES+1]; WINDOW _pagewin[MAX_PAGES+1];
// @cmember:(INTERNAL) Numero di pagine della maschera // @cmember:(INTERNAL) Numero di pagine della maschera
int _pages; int _pages;
// @cmember:(INTERNAL) Pagina corrente // @cmember:(INTERNAL) Pagina corrente
@ -69,7 +65,7 @@ class TMask : public TWindow
int _first_focus; int _first_focus;
int _focus; int _focus;
// @cmember:(INTERNAL) Puntatore allo sheet che contiene la maschera (puo' essere NULL) // @cmember:(INTERNAL) Puntatore allo sheet che contiene la maschera (puo' essere NULL)
TSheet_field* _sheet; TSheet_field* _sheet;
@ -87,9 +83,11 @@ class TMask : public TWindow
real _exchange; real _exchange;
// @cmember:(INTERNAL) Controlla se la maschera deve fare i controlli iniziali di validita' dei campi // @cmember:(INTERNAL) Controlla se la maschera deve fare i controlli iniziali di validita' dei campi
bool _should_check; bool _should_check;
int _error_severity; int _error_severity;
TString _error_message; TString _error_message;
short _msg_field;
KEY _msg_key;
// @cmember:(INTERNAL) Tempo totale di caricamento della maschera // @cmember:(INTERNAL) Tempo totale di caricamento della maschera
long _total_time; long _total_time;
@ -109,7 +107,7 @@ class TMask : public TWindow
// @access Protected Member // @access Protected Member
protected: protected:
TArray& fields_array() { return _field; } TArray& fields_array() { return _field; }
// @cmember:(INTERNAL) Numero di sheet contenuti nella maschera // @cmember:(INTERNAL) Numero di sheet contenuti nella maschera
int _sheets; int _sheets;
@ -126,7 +124,7 @@ protected:
WINDOW read_page(TScanner& scanner, bool toolbar = FALSE); WINDOW read_page(TScanner& scanner, bool toolbar = FALSE);
// @cmember Legge la maschera da file // @cmember Legge la maschera da file
void read_mask(const char* name, int num, int max); void read_mask(const char* name, int num, int max);
// @cmember Aggiunge i tags ad una pagina // @cmember Aggiunge i tags ad una pagina
void add_tag_button(byte pag, TToken_string& tags, byte sel); void add_tag_button(byte pag, TToken_string& tags, byte sel);
@ -139,7 +137,7 @@ protected:
int find_parent_page(const TMask_field& f) const; int find_parent_page(const TMask_field& f) const;
// @cmember Esegue i check del campo corrente // @cmember Esegue i check del campo corrente
bool check_current_field() const; bool check_current_field() const;
// @cmember Mostra la prossima/precedente pagina // @cmember Mostra la prossima/precedente pagina
void next_page(int p); void next_page(int p);
// @cmember Ritorna il numero della pagina corrente // @cmember Ritorna il numero della pagina corrente
int curr_page() const int curr_page() const
@ -156,13 +154,13 @@ public:
// @cmember Distruttore // @cmember Distruttore
virtual ~TMask(); virtual ~TMask();
// @cmember Ritorna l'identificatore della classe maschera // @cmember Ritorna l'identificatore della classe maschera
virtual word class_id() const; virtual word class_id() const;
// @cmember Ritorna TRUE se la maschera deriva dalla classe <p c> // @cmember Ritorna TRUE se la maschera deriva dalla classe <p c>
virtual bool is_kind_of(word c) const; virtual bool is_kind_of(word c) const;
// @cmember Ritorna la finestra della pagina corrente (Usare con attenzione) // @cmember Ritorna la finestra della pagina corrente (Usare con attenzione)
WINDOW win() const WINDOW win() const
{ return _page < 0 ? _pagewin[0] : _pagewin[_page]; } { return _page < 0 ? _pagewin[0] : _pagewin[_page]; }
@ -170,7 +168,7 @@ public:
// @cmember Ritorna il nome del file contentente la maschera // @cmember Ritorna il nome del file contentente la maschera
const TFilename& source_file() const const TFilename& source_file() const
{ return _source_file; } { return _source_file; }
// @cmember Aggiunge alla maschera tutti i bottoni Pag. n // @cmember Aggiunge alla maschera tutti i bottoni Pag. n
void add_default_tag_buttons(); void add_default_tag_buttons();
@ -209,11 +207,11 @@ public:
// @cmember Ritorna la modalita' corrente di utilizzo della maschera // @cmember Ritorna la modalita' corrente di utilizzo della maschera
int mode() const int mode() const
{ return _mode; } { return _mode; }
// @cmember Setta la chiave da testare per l'autopremimento // @cmember Setta la chiave da testare per l'autopremimento
void set_test_field(int id) void set_test_field(int id)
{ if (_test_fld < 0) _test_fld = id; } { if (_test_fld < 0) _test_fld = id; }
void set_focus_field(short id); void set_focus_field(short id);
void notify_focus_field(short id); void notify_focus_field(short id);
@ -281,10 +279,10 @@ public:
// @cmember Disabilita la lettura dei check della maschera // @cmember Disabilita la lettura dei check della maschera
void disable_starting_check() void disable_starting_check()
{ _should_check = FALSE;} { _should_check = FALSE;}
// @cmember Evita che venga chiamata la TWindow // @cmember Evita che venga chiamata la TWindow
virtual void TMask::on_button(short); virtual void TMask::on_button(short);
// @cmember Assegna una azione al tasto non standard // @cmember Assegna una azione al tasto non standard
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
// @cmember Aggiorna i campi con i valori salvati una volta che non ci sono processi attivi // @cmember Aggiorna i campi con i valori salvati una volta che non ci sono processi attivi
@ -313,14 +311,14 @@ public:
// @cmember Ritorna il numero di chiavi utilizzate nei campi della maschera // @cmember Ritorna il numero di chiavi utilizzate nei campi della maschera
byte num_keys() const; byte num_keys() const;
// @cmember Abilita/disabilita i campi di una chiave sulla maschera // @cmember Abilita/disabilita i campi di una chiave sulla maschera
void enable_key(byte key, bool on = TRUE); void enable_key(byte key, bool on = TRUE);
// @cmember Disabilita i campi di una chiave sulla maschera (chiama <mf TMask::enable_key>) // @cmember Disabilita i campi di una chiave sulla maschera (chiama <mf TMask::enable_key>)
void disable_key(byte key) void disable_key(byte key)
{ enable_key(key, FALSE); } { enable_key(key, FALSE); }
// @cmember Ritorna il l'identificatore di un campo della chiave <p key> // @cmember Ritorna il l'identificatore di un campo della chiave <p key>
TEditable_field* get_key_field(byte key, bool first) const; TEditable_field* get_key_field(byte key, bool first) const;
// @cmember Controlla se la chiave <p key> ha un valore significativo // @cmember Controlla se la chiave <p key> ha un valore significativo
// (TRUE se il valore e' valido) // (TRUE se il valore e' valido)
bool key_valid(int key) const; bool key_valid(int key) const;
@ -358,11 +356,11 @@ public:
// @cmember Ritorna il primo campo dirty // @cmember Ritorna il primo campo dirty
short dirty() const; short dirty() const;
// @cmember Setta lo sheet di cui la maschera gestisce le righe // @cmember Setta lo sheet di cui la maschera gestisce le righe
void set_sheet(TSheet_field* s) void set_sheet(TSheet_field* s)
{ _sheet = s; } { _sheet = s; }
// @cmember Ritorna lo sheet che gestisce la maschera // @cmember Ritorna lo sheet che gestisce la maschera
TSheet_field* get_sheet() TSheet_field* get_sheet()
{ return _sheet; } { return _sheet; }
@ -388,13 +386,13 @@ public:
virtual const char* get_caption() const; virtual const char* get_caption() const;
// @cmember Setta il titolo della maschera // @cmember Setta il titolo della maschera
virtual void set_caption(const char* c); virtual void set_caption(const char* c);
// @cmember Mostra un messaggio d'errore appena possibile // @cmember Mostra un messaggio d'errore appena possibile
void post_error_message(const char* msg, int severity); void post_error_message(const char* msg, int severity);
// @cmember Viene eseguita se il campo viene modificato // @cmember Viene eseguita se il campo viene modificato
virtual bool on_dirty(TMask_field& c); virtual bool on_dirty(TMask_field& c);
// @cmember Ritorna la finestra della toolbar // @cmember Ritorna la finestra della toolbar
WINDOW toolwin() const WINDOW toolwin() const
{ return _pagewin[MAX_PAGES]; } { return _pagewin[MAX_PAGES]; }