Corretta _msg_key
git-svn-id: svn://10.65.10.50/trunk@2998 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
57c332a0d4
commit
3ea25e2ce3
294
include/mask.cpp
294
include/mask.cpp
@ -19,7 +19,7 @@
|
||||
#define NULL_PAGE 256
|
||||
|
||||
HIDDEN const char* const MASK_EXT = "msk";
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMask methods
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -40,8 +40,10 @@ void TMask::init_mask()
|
||||
_handler = NULL; // Nessun handler utente
|
||||
_mode = NO_MODE; // Inizializza modo
|
||||
_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;
|
||||
_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)
|
||||
{
|
||||
init_mask();
|
||||
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);
|
||||
}
|
||||
|
||||
@ -79,15 +81,15 @@ void TMask::read_mask(
|
||||
|
||||
if (num == 0)
|
||||
_total_time = _build_time = _init_time = 0;
|
||||
|
||||
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
while (scanner.ok())
|
||||
if (scanner.line() == "ENDMASK") break;
|
||||
}
|
||||
|
||||
|
||||
init_mask();
|
||||
|
||||
|
||||
TToken_string captions(80);
|
||||
|
||||
main_app().begin_wait();
|
||||
@ -97,11 +99,11 @@ void TMask::read_mask(
|
||||
{
|
||||
CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages);
|
||||
WINDOW w = read_page(scanner, FALSE);
|
||||
|
||||
|
||||
TString title(80);
|
||||
xvt_vobj_get_title(w, (char*)(const char*)title, title.size());
|
||||
captions.add(title);
|
||||
|
||||
|
||||
_pagewin[_pages++] = w;
|
||||
if (_pages >= max)
|
||||
break;
|
||||
@ -117,7 +119,7 @@ void TMask::read_mask(
|
||||
fatal_box("Impossibile leggere la maschera %s", name);
|
||||
|
||||
if (_pages > 1 || toolwin())
|
||||
add_tag_buttons(captions);
|
||||
add_tag_buttons(captions);
|
||||
|
||||
if (num == 0)
|
||||
_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)
|
||||
{
|
||||
{
|
||||
TTagbutton_control* tb = new TTagbutton_control(_pagewin[pag], 32000, 0, 0, 80, 1, "", tags, sel);
|
||||
_pagetag.add(tb, pag);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void TMask::add_default_tag_buttons()
|
||||
{
|
||||
{
|
||||
TToken_string tags(_pages * 6);
|
||||
for (int p = 1; p <= _pages; p++)
|
||||
{
|
||||
tags.add("Pag.");
|
||||
{
|
||||
tags.add("Pag.");
|
||||
tags << p;
|
||||
}
|
||||
}
|
||||
add_tag_buttons(tags);
|
||||
}
|
||||
|
||||
@ -170,13 +172,13 @@ word TMask::class_id() const
|
||||
|
||||
bool TMask::is_kind_of(word c) const
|
||||
{
|
||||
if (c == CLASS_MASK)
|
||||
if (c == CLASS_MASK)
|
||||
return TRUE;
|
||||
return TWindow::is_kind_of(c);
|
||||
}
|
||||
|
||||
void TMask::open()
|
||||
{
|
||||
{
|
||||
if (!_open || _page != 0)
|
||||
{
|
||||
_open = TRUE;
|
||||
@ -188,8 +190,8 @@ void TMask::open()
|
||||
}
|
||||
|
||||
int TMask::find_first_active(WINDOW p) const
|
||||
{
|
||||
const int max = fields();
|
||||
{
|
||||
const int max = fields();
|
||||
for (int f = 0; f < max; f++)
|
||||
{
|
||||
TMask_field& c = fld(f);
|
||||
@ -205,7 +207,7 @@ int TMask::first_focus(short id)
|
||||
|
||||
int f = _first_focus;
|
||||
if (id == 0)
|
||||
{
|
||||
{
|
||||
if (tempfirstfocus >= 0)
|
||||
{
|
||||
f = tempfirstfocus;
|
||||
@ -214,15 +216,15 @@ int TMask::first_focus(short id)
|
||||
tempfirstfocus = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (f < 0 || !fld(f).active())
|
||||
{
|
||||
f = find_first_active(_pagewin[0]);
|
||||
if (f < 0 && toolwin())
|
||||
f = find_first_active(toolwin());
|
||||
_first_focus = f;
|
||||
}
|
||||
}
|
||||
f = find_first_active(toolwin());
|
||||
_first_focus = f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -234,7 +236,7 @@ int TMask::first_focus(short id)
|
||||
else
|
||||
f = tempfirstfocus = id2pos(-id);
|
||||
}
|
||||
|
||||
|
||||
CHECKD(f >= 0 && f < fields() && fld(f).active(), "Invalid focus field ", f);
|
||||
return f;
|
||||
}
|
||||
@ -242,28 +244,28 @@ int TMask::first_focus(short id)
|
||||
TOperable_field& TMask::focus_field() const
|
||||
{
|
||||
const short focus = get_focus_id(win());
|
||||
|
||||
|
||||
if (focus > 0 )
|
||||
((TMask *)this)->_focus = id2pos(focus);
|
||||
((TMask *)this)->_focus = id2pos(focus);
|
||||
TMask_field & f = fld(_focus);
|
||||
|
||||
|
||||
CHECK(f.is_kind_of(CLASS_OPERABLE_FIELD), "Can't set focus to non operable_field");
|
||||
return (TOperable_field&)f;
|
||||
}
|
||||
}
|
||||
|
||||
void TMask::set_focus_field(short id)
|
||||
{
|
||||
const int pos = id2pos(id);
|
||||
CHECKD(pos >= 0, "Can't set focus to field ", id);
|
||||
_focus = pos;
|
||||
if (is_open())
|
||||
if (is_open())
|
||||
{
|
||||
const TMask_field& f = fld(pos);
|
||||
int p = find_parent_page(f);
|
||||
if (p < 0 || p >= _pages || !page_enabled(p))
|
||||
p = 0;
|
||||
p = 0;
|
||||
show_page(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMask::notify_focus_field(short id)
|
||||
@ -289,7 +291,7 @@ void TMask::close()
|
||||
}
|
||||
|
||||
short TMask::dirty() const
|
||||
{
|
||||
{
|
||||
const int max = fields();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
@ -332,7 +334,7 @@ void TMask::enable_page(
|
||||
{
|
||||
TTagbutton_control& tag = (TTagbutton_control&)_pagetag[b];
|
||||
tag.show_button(i, on);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -340,7 +342,7 @@ void TMask::enable_page(
|
||||
// Controlla lo stato di abilitazione di una pagina
|
||||
// Certified 100%
|
||||
bool TMask::page_enabled(byte p) const
|
||||
{
|
||||
{
|
||||
CHECKD(p <= MAX_PAGES, "Page too high ", (int)p);
|
||||
const bool on = _pagewin[p] != NULL_WIN && _enabled[p];
|
||||
return on;
|
||||
@ -351,25 +353,25 @@ void TMask::start_run()
|
||||
{
|
||||
const long start = clock();
|
||||
const int max = fields();
|
||||
|
||||
|
||||
if (_should_check)
|
||||
{
|
||||
load_checks();
|
||||
|
||||
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
TMask_field& f = fld(i);
|
||||
if (f.dirty() <= TRUE)
|
||||
{
|
||||
{
|
||||
f.set_dirty(FALSE);
|
||||
const bool op = f.is_operable() && !f.is_kind_of(CLASS_BUTTON_FIELD);
|
||||
if (op && (f.active() || f.ghost()))
|
||||
f.on_hit(); // Lancia messaggio di inizializzazione
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_should_check = TRUE;
|
||||
|
||||
|
||||
// Make sure that "nearly" all fields are clean!
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
@ -410,25 +412,25 @@ bool TMask::check_fields()
|
||||
break; // Page disabled: end of test
|
||||
curpage = f.parent(); // Update current page
|
||||
}
|
||||
|
||||
|
||||
if (sheet) f.set_dirty(); // Force check in sheet masks
|
||||
if (f.on_key(K_ENTER) == FALSE)
|
||||
{
|
||||
if (is_open())
|
||||
if (is_open())
|
||||
set_focus_field(f.dlg());
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TMask::check_field( short fld_id )
|
||||
{
|
||||
field( fld_id ).on_hit();
|
||||
field( fld_id ).on_hit();
|
||||
field( fld_id ).check();
|
||||
}
|
||||
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @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)
|
||||
int TMask::id2pos(
|
||||
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
|
||||
// (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
|
||||
bool TMask::stop_run(
|
||||
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>.
|
||||
// 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;
|
||||
if (b.exit_key() == key)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i >= last)
|
||||
return FALSE;
|
||||
@ -539,9 +541,9 @@ bool TMask::stop_run(
|
||||
if (key == K_FORCE_CLOSE) key = K_QUIT;
|
||||
|
||||
if (key != K_ESC && key != K_QUIT && key != K_DEL && key != K_F9)
|
||||
{
|
||||
{
|
||||
bool ok = check_current_field();
|
||||
if (ok)
|
||||
if (ok)
|
||||
ok = check_fields();
|
||||
if (!ok) return FALSE;
|
||||
}
|
||||
@ -564,9 +566,9 @@ void TMask::on_button(short)
|
||||
// @flag FALSE | Non era prevista nessuna azione collegata al tasto
|
||||
bool TMask::on_key(
|
||||
KEY key) // @parm Tasto premuto sulla maschera
|
||||
|
||||
|
||||
// @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)
|
||||
{
|
||||
@ -600,27 +602,27 @@ bool TMask::on_key(
|
||||
BYTE mkKeylist;
|
||||
char mkKeyphrase[16];
|
||||
} mk;
|
||||
|
||||
|
||||
TFilename topic(source_file()); topic.ext("");
|
||||
mk.mkSize = sizeof(MULTIGUY);
|
||||
mk.mkKeylist = 'M';
|
||||
strcpy(mk.mkKeyphrase, topic);
|
||||
|
||||
|
||||
TFilename hlp("prassi.hlp");
|
||||
const TString16 mod(topic.left(2));
|
||||
if (mod != "ba") hlp.insert(mod, 0);
|
||||
|
||||
|
||||
HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
|
||||
WinHelp(hwnd, hlp, HELP_MULTIKEY, (DWORD)&mk);
|
||||
next_page(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case K_F12:
|
||||
post_error_message(format("Lettura = %ld\n"
|
||||
"Creazione = %ld\n"
|
||||
"Inizializzazione = %ld\n",
|
||||
_total_time-_build_time, _build_time, _init_time),
|
||||
_total_time-_build_time, _build_time, _init_time),
|
||||
1);
|
||||
break;
|
||||
default:
|
||||
@ -646,7 +648,7 @@ bool TMask::on_key(
|
||||
f.on_key(K_SPACE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -662,7 +664,7 @@ bool TMask::on_dirty(TMask_field&)
|
||||
|
||||
|
||||
TMask_field* TMask::parse_field(TScanner& scanner)
|
||||
{
|
||||
{
|
||||
const TString& k = scanner.key();
|
||||
if (k == "ST") return new TEdit_field(this);
|
||||
if (k == "NU") return new TReal_field(this);
|
||||
@ -684,7 +686,7 @@ TMask_field* TMask::parse_field(TScanner& scanner)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Legge la pagina dal file
|
||||
@ -693,7 +695,7 @@ TMask_field* TMask::parse_field(TScanner& scanner)
|
||||
WINDOW TMask::read_page(
|
||||
TScanner& scanner, // @parm File dal quale leggere la pagina
|
||||
bool toolbar) // @parm Indica se e' la toolbar
|
||||
|
||||
|
||||
// @comm Il parametro <p toolbar> e' utilizzato per indicare se la pagina deve essere visualizzata
|
||||
// a tutto schermo (TRUE) oppure no
|
||||
{
|
||||
@ -721,30 +723,30 @@ WINDOW TMask::read_page(
|
||||
else r = rect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool orecchie = _pagewin[0] != NULL_WIN || toolwin();
|
||||
if (!orecchie && !toolbar) // Controlla se la maschera ha piu' di una pagina
|
||||
{
|
||||
const streampos pos = scanner.tellg(); // Memorizza posizione dello scanner
|
||||
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!
|
||||
{
|
||||
orecchie = TRUE; // Quindi devo metterci le orecchie
|
||||
break;
|
||||
}
|
||||
l = scanner.line().left(2);
|
||||
l = scanner.line().left(2);
|
||||
}
|
||||
scanner.seekg(pos); // Ripristin aposizione dello scanner
|
||||
}
|
||||
|
||||
|
||||
WINDOW w;
|
||||
if (toolbar || toolwin())
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -754,7 +756,7 @@ WINDOW TMask::read_page(
|
||||
TMask_field* f = parse_field(scanner);
|
||||
#ifdef DBG
|
||||
if (f == NULL)
|
||||
{
|
||||
{
|
||||
const int f = fields();
|
||||
TString e("Unknown control at position "); e << f;
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (f != NULL)
|
||||
{
|
||||
const long start = clock();
|
||||
|
||||
|
||||
f->construct(scanner, w);
|
||||
_field.add(f);
|
||||
|
||||
|
||||
_build_time += clock()-start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return w;
|
||||
@ -783,18 +785,18 @@ bool TMask::check_current_field() const
|
||||
if (_focus >= 0)
|
||||
{
|
||||
TMask_field& ff = fld(_focus);
|
||||
if (ff.focusdirty())
|
||||
if (ff.focusdirty())
|
||||
ok = ff.on_key(K_TAB);
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Mostra la prossima/precedente pagina
|
||||
// @mfunc Mostra la prossima/precedente pagina
|
||||
void TMask::next_page(
|
||||
int p) // @parm Pagina alla quale saltare
|
||||
|
||||
|
||||
// @comm Il valore <p p> puo' assumere i seguenti valori:
|
||||
//
|
||||
// @flag -1 | Mostra la pagina precedente
|
||||
@ -821,23 +823,23 @@ void TMask::next_page(
|
||||
if (prev >= 0)
|
||||
xvt_vobj_set_visible(_pagewin[prev], FALSE);
|
||||
}
|
||||
|
||||
|
||||
TMask_field& ff = fld(_focus);
|
||||
if (ff.parent() != win() || !ff.active())
|
||||
{
|
||||
_focus = find_first_active(win());
|
||||
if (_focus < 0 && toolwin() != NULL_WIN)
|
||||
_focus = find_first_active(toolwin());
|
||||
}
|
||||
}
|
||||
|
||||
if (_focus >= 0)
|
||||
{
|
||||
TMask_field& ff = fld(_focus);
|
||||
if (ff.active())
|
||||
if (ff.active())
|
||||
ff.highlight();
|
||||
}
|
||||
|
||||
TWindow::set_focus();
|
||||
}
|
||||
|
||||
TWindow::set_focus();
|
||||
}
|
||||
|
||||
void TMask::show_page(int p)
|
||||
@ -858,7 +860,7 @@ void TMask::reset(short fld_id)
|
||||
{
|
||||
c._flags.dirty = c._flags.focusdirty = FALSE;
|
||||
c.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
|
||||
{
|
||||
{
|
||||
const TString& s = field(fld_id).get();
|
||||
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
|
||||
// con il nuovo valore (default FALSE)
|
||||
// @parm long | n | Numero da asegnare al campo
|
||||
|
||||
|
||||
// @syntax set(short fld_id, const char *s, bool hit);
|
||||
// @syntax set(short fld_id, long n, bool hit);
|
||||
{
|
||||
TMask_field& f = field(fld_id);
|
||||
f.set(s);
|
||||
f.set(s);
|
||||
if (hit && (f.active() || f.ghost()))
|
||||
{
|
||||
f.set_dirty();
|
||||
f.on_hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMask::set(short fld_id, long n, bool hit)
|
||||
@ -969,7 +971,7 @@ void TMask::enable(
|
||||
f.enable(on);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
field(fld_id).enable(on);
|
||||
}
|
||||
|
||||
@ -984,9 +986,9 @@ void TMask::enable_default(short fld_id)
|
||||
TMask_field& f = fld(i);
|
||||
if (gr == 0 || f.in_group(gr))
|
||||
f.enable_default();
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
}
|
||||
else
|
||||
field(fld_id).enable_default();
|
||||
}
|
||||
|
||||
@ -995,13 +997,13 @@ byte TMask::num_keys() const
|
||||
{
|
||||
word max = 0;
|
||||
for (int i = fields()-1; i >= 0; i--)
|
||||
{
|
||||
{
|
||||
TMask_field& f = fld(i);
|
||||
if (f.is_editable())
|
||||
{
|
||||
word k = ((TEditable_field&)f).last_key();
|
||||
if (k > max) max = k;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
@ -1028,10 +1030,10 @@ void TMask::enable_key(
|
||||
if (!f.shown())
|
||||
f.show_default();
|
||||
}
|
||||
else
|
||||
else
|
||||
f.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -1049,10 +1051,10 @@ TEditable_field* TMask::get_key_field(
|
||||
static int last = 0;
|
||||
|
||||
if (first) last = 0;
|
||||
|
||||
|
||||
const int max = fields();
|
||||
for (int i = last; i < max; i++)
|
||||
{
|
||||
{
|
||||
TMask_field& f = fld(i);
|
||||
if (f.in_key(key))
|
||||
{
|
||||
@ -1077,7 +1079,7 @@ bool TMask::key_valid(int key) const
|
||||
{
|
||||
if (e.empty())
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -1114,8 +1116,8 @@ void TMask::show(
|
||||
// @mfunc Rimette lo stato di default del campo
|
||||
void TMask::show_default(
|
||||
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)
|
||||
{
|
||||
@ -1133,12 +1135,12 @@ void TMask::autoload(const TRelation& r)
|
||||
TMask_field& f = fld(i);
|
||||
if (f.is_editable())
|
||||
((TEditable_field&)f).autoload(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TMask::autosave(TRelation& r) const
|
||||
{
|
||||
{
|
||||
const int max = fields();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
@ -1152,12 +1154,12 @@ void TMask::autosave(TRelation& r) const
|
||||
if (!save)
|
||||
{
|
||||
e.autoload(r);
|
||||
save = f.empty();
|
||||
save = f.empty();
|
||||
}
|
||||
if (save)
|
||||
e.autosave(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1185,41 +1187,41 @@ void TMask::on_idle()
|
||||
{
|
||||
TOperable_field& s = (TOperable_field&)fld(_focus);
|
||||
s.on_idle();
|
||||
|
||||
|
||||
if (_msg_field > 0)
|
||||
{
|
||||
{
|
||||
TMask_field& f = field(_msg_field);
|
||||
_msg_field = 0;
|
||||
if (_msg_key > 0)
|
||||
f.on_key(_msg_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_error_severity > 0)
|
||||
{
|
||||
{
|
||||
switch(_error_severity)
|
||||
{
|
||||
{
|
||||
case 2:
|
||||
warning_box("%s", (const char*)_error_message); break;
|
||||
case 3:
|
||||
error_box("%s", (const char*)_error_message); break;
|
||||
default:
|
||||
message_box("%s", (const char*)_error_message); break;
|
||||
}
|
||||
_error_severity = 0;
|
||||
}
|
||||
_error_severity = 0;
|
||||
set_focus();
|
||||
}
|
||||
}
|
||||
if (_test_fld >= 0)
|
||||
{
|
||||
const TOperable_field & f = focus_field();
|
||||
const TOperable_field & f = focus_field();
|
||||
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))
|
||||
{
|
||||
e.test_key_complete(FALSE);
|
||||
_test_fld = -1;
|
||||
}
|
||||
}
|
||||
_last_test = f.dlg();
|
||||
}
|
||||
}
|
||||
@ -1254,13 +1256,13 @@ void TMask::send_key(
|
||||
else
|
||||
{
|
||||
const int pos = id2pos(to);
|
||||
if (pos >= 0)
|
||||
{
|
||||
if (pos >= 0)
|
||||
{
|
||||
if (_msg_field > 0)
|
||||
on_idle();
|
||||
_msg_field = to;
|
||||
_msg_key = key;
|
||||
}
|
||||
}
|
||||
#ifdef DBG
|
||||
else
|
||||
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>
|
||||
// alla maschera corrente
|
||||
|
||||
{
|
||||
{
|
||||
TMask_field& f = field(fld_id);
|
||||
CHECKD(f.is_operable(), "Can't set an handler to non-operable field ", fld_id);
|
||||
((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>
|
||||
// <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);
|
||||
_field.add(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>
|
||||
// <mf TMask::add_date> <mf TMask::add_radio> <mf TMask::add_memo>
|
||||
{
|
||||
{
|
||||
TButton_field* f = new TButton_field(this);
|
||||
f->construct(id, prompt, x, y, dy, _pagewin[page], flags, dx);
|
||||
if (bmpup > 0)
|
||||
@ -1468,7 +1470,7 @@ TList_field& TMask::add_list (
|
||||
{
|
||||
TList_field* f = new TList_field(this);
|
||||
f->construct(id, prompt, x, y, dim, _pagewin[page], flags);
|
||||
f->replace_items(codes,items);
|
||||
f->replace_items(codes,items);
|
||||
_field.add(f);
|
||||
return *f;
|
||||
}
|
||||
@ -1565,10 +1567,10 @@ bool TMask::save(
|
||||
|
||||
if (f == NULL)
|
||||
return yesnofatal_box("Non posso aprire %s ", (const char*) _workfile);
|
||||
|
||||
|
||||
const int max = fields();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
TMask_field& c = fld(i);
|
||||
if (c.is_editable())
|
||||
fprintf(f, "%d|%s\n", c.dlg(), (const char*)c.get());
|
||||
@ -1602,12 +1604,12 @@ bool TMask::load(
|
||||
TToken_string t(256);
|
||||
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);
|
||||
const int pos = id2pos(t.get_int(0));
|
||||
if (pos >= 0) fld(pos).set(t.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
_lastpos = ftell(f);
|
||||
fclose(f);
|
||||
@ -1617,25 +1619,25 @@ bool TMask::load(
|
||||
|
||||
// @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(
|
||||
const TMask& m) // @parm Maschera sorgente
|
||||
|
||||
{
|
||||
reset();
|
||||
{
|
||||
reset();
|
||||
const int nfields = fields();
|
||||
for (int i = 0; i < nfields; i++)
|
||||
{
|
||||
{
|
||||
TMask_field& dest_field = fld( i );
|
||||
|
||||
|
||||
if (dest_field.is_editable() )
|
||||
{
|
||||
const int pos = m.id2pos(dest_field.dlg());
|
||||
if (pos >= 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
{
|
||||
TToken_string captions(c);
|
||||
for (int p = 0; p < _pages; p++)
|
||||
{
|
||||
{
|
||||
const char* cap = captions.get();
|
||||
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);
|
||||
if (tag) tag->set_caption(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMask::post_error_message(const char* msg, int sev)
|
||||
{
|
||||
{
|
||||
CHECK(sev > 0 && msg, "Bad error message posted");
|
||||
if (_error_severity > 0) // C'e' gia' un messaggio d'errore in coda
|
||||
on_idle();
|
||||
@ -1684,11 +1686,11 @@ void TMask::set_exchange(
|
||||
{
|
||||
TMask_field& f = fld(i);
|
||||
if (f.is_operable())
|
||||
{
|
||||
{
|
||||
TOperable_field& o = (TOperable_field&)f;
|
||||
if (o.exchangeable() || o.is_kind_of(CLASS_SHEET_FIELD))
|
||||
o.exchange(show_value, nuo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_exchange = nuo; // Update current exchange
|
||||
|
@ -9,11 +9,7 @@
|
||||
#include <maskfld.h>
|
||||
#endif
|
||||
|
||||
HIDDEN short _msg_field;
|
||||
HIDDEN KEY _msg_key;
|
||||
|
||||
|
||||
class TSheet_field;
|
||||
class TSheet_field;
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
@ -40,7 +36,7 @@ enum TMaskmode {
|
||||
class TMask : public TWindow
|
||||
{
|
||||
// @author:(INTERNAL) Guido
|
||||
|
||||
|
||||
// @access Protected Member
|
||||
protected:
|
||||
|
||||
@ -52,7 +48,7 @@ class TMask : public TWindow
|
||||
|
||||
// @cmember:(INTERNAL) Windows delle pagine
|
||||
WINDOW _pagewin[MAX_PAGES+1];
|
||||
|
||||
|
||||
// @cmember:(INTERNAL) Numero di pagine della maschera
|
||||
int _pages;
|
||||
// @cmember:(INTERNAL) Pagina corrente
|
||||
@ -69,7 +65,7 @@ class TMask : public TWindow
|
||||
int _first_focus;
|
||||
|
||||
int _focus;
|
||||
|
||||
|
||||
// @cmember:(INTERNAL) Puntatore allo sheet che contiene la maschera (puo' essere NULL)
|
||||
TSheet_field* _sheet;
|
||||
|
||||
@ -87,9 +83,11 @@ class TMask : public TWindow
|
||||
real _exchange;
|
||||
// @cmember:(INTERNAL) Controlla se la maschera deve fare i controlli iniziali di validita' dei campi
|
||||
bool _should_check;
|
||||
|
||||
|
||||
int _error_severity;
|
||||
TString _error_message;
|
||||
short _msg_field;
|
||||
KEY _msg_key;
|
||||
|
||||
// @cmember:(INTERNAL) Tempo totale di caricamento della maschera
|
||||
long _total_time;
|
||||
@ -109,7 +107,7 @@ class TMask : public TWindow
|
||||
// @access Protected Member
|
||||
protected:
|
||||
TArray& fields_array() { return _field; }
|
||||
|
||||
|
||||
// @cmember:(INTERNAL) Numero di sheet contenuti nella maschera
|
||||
int _sheets;
|
||||
|
||||
@ -126,7 +124,7 @@ protected:
|
||||
WINDOW read_page(TScanner& scanner, bool toolbar = FALSE);
|
||||
// @cmember Legge la maschera da file
|
||||
void read_mask(const char* name, int num, int max);
|
||||
|
||||
|
||||
// @cmember Aggiunge i tags ad una pagina
|
||||
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;
|
||||
// @cmember Esegue i check del campo corrente
|
||||
bool check_current_field() const;
|
||||
// @cmember Mostra la prossima/precedente pagina
|
||||
// @cmember Mostra la prossima/precedente pagina
|
||||
void next_page(int p);
|
||||
// @cmember Ritorna il numero della pagina corrente
|
||||
int curr_page() const
|
||||
@ -156,13 +154,13 @@ public:
|
||||
|
||||
// @cmember Distruttore
|
||||
virtual ~TMask();
|
||||
|
||||
|
||||
// @cmember Ritorna l'identificatore della classe maschera
|
||||
virtual word class_id() const;
|
||||
|
||||
|
||||
// @cmember Ritorna TRUE se la maschera deriva dalla classe <p c>
|
||||
virtual bool is_kind_of(word c) const;
|
||||
|
||||
|
||||
// @cmember Ritorna la finestra della pagina corrente (Usare con attenzione)
|
||||
WINDOW win() const
|
||||
{ return _page < 0 ? _pagewin[0] : _pagewin[_page]; }
|
||||
@ -170,7 +168,7 @@ public:
|
||||
// @cmember Ritorna il nome del file contentente la maschera
|
||||
const TFilename& source_file() const
|
||||
{ return _source_file; }
|
||||
|
||||
|
||||
// @cmember Aggiunge alla maschera tutti i bottoni Pag. n
|
||||
void add_default_tag_buttons();
|
||||
|
||||
@ -209,11 +207,11 @@ public:
|
||||
// @cmember Ritorna la modalita' corrente di utilizzo della maschera
|
||||
int mode() const
|
||||
{ return _mode; }
|
||||
|
||||
|
||||
// @cmember Setta la chiave da testare per l'autopremimento
|
||||
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 notify_focus_field(short id);
|
||||
|
||||
@ -281,10 +279,10 @@ public:
|
||||
// @cmember Disabilita la lettura dei check della maschera
|
||||
void disable_starting_check()
|
||||
{ _should_check = FALSE;}
|
||||
|
||||
|
||||
// @cmember Evita che venga chiamata la TWindow
|
||||
virtual void TMask::on_button(short);
|
||||
|
||||
|
||||
// @cmember Assegna una azione al tasto non standard
|
||||
virtual bool on_key(KEY key);
|
||||
// @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
|
||||
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);
|
||||
// @cmember Disabilita i campi di una chiave sulla maschera (chiama <mf TMask::enable_key>)
|
||||
void disable_key(byte key)
|
||||
{ enable_key(key, FALSE); }
|
||||
// @cmember Ritorna il l'identificatore di un campo della chiave <p key>
|
||||
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)
|
||||
bool key_valid(int key) const;
|
||||
|
||||
@ -358,11 +356,11 @@ public:
|
||||
|
||||
// @cmember Ritorna il primo campo dirty
|
||||
short dirty() const;
|
||||
|
||||
|
||||
// @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; }
|
||||
|
||||
|
||||
// @cmember Ritorna lo sheet che gestisce la maschera
|
||||
TSheet_field* get_sheet()
|
||||
{ return _sheet; }
|
||||
@ -388,13 +386,13 @@ public:
|
||||
virtual const char* get_caption() const;
|
||||
// @cmember Setta il titolo della maschera
|
||||
virtual void set_caption(const char* c);
|
||||
|
||||
|
||||
// @cmember Mostra un messaggio d'errore appena possibile
|
||||
void post_error_message(const char* msg, int severity);
|
||||
|
||||
// @cmember Viene eseguita se il campo viene modificato
|
||||
virtual bool on_dirty(TMask_field& c);
|
||||
|
||||
|
||||
// @cmember Ritorna la finestra della toolbar
|
||||
WINDOW toolwin() const
|
||||
{ return _pagewin[MAX_PAGES]; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user