Corretta gestione messaggi
git-svn-id: svn://10.65.10.50/trunk@769 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
12bd1870ca
commit
fb30854f4c
27
include/b3.h
27
include/b3.h
@ -1,18 +1,17 @@
|
||||
#define F_GROUP 101
|
||||
#define F_CLASS 101
|
||||
#define F_KEY 102
|
||||
#define F_CLASS 103
|
||||
#define F_Y 103
|
||||
#define F_X 104
|
||||
#define F_Y 105
|
||||
#define F_WIDTH 106
|
||||
#define F_HEIGTH 107
|
||||
|
||||
#define F_PROMPT 108
|
||||
#define F_PICTURE 121
|
||||
#define F_FIELD 131
|
||||
#define F_FIELD2 132
|
||||
|
||||
#define F_AUTOMAGIC 151
|
||||
#define F_HIDDEN 152
|
||||
#define F_DISABLED 153
|
||||
#define F_WIDTH 105
|
||||
#define F_HEIGHT 106
|
||||
#define F_PROMPT 107
|
||||
#define F_HIDDEN 108
|
||||
#define F_DISABLED 109
|
||||
#define F_AUTOMAGIC 110
|
||||
#define F_PICTURE 111
|
||||
#define F_GROUP 112
|
||||
#define F_FIELD 113
|
||||
#define F_FIELD2 114
|
||||
#define F_DECIMALS 206
|
||||
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include <bagn003.h>
|
||||
|
||||
PAGE "CAMPO DI STAMPA" -1 -1 60 12
|
||||
PAGE "CAMPO DI STAMPA" -1 -1 60 14
|
||||
|
||||
LIST F_CLASS 10
|
||||
BEGIN
|
||||
PROMPT 1 1 "Tipo "
|
||||
FLAGS "D"
|
||||
ITEM "STRING|Testo" MESSAGE HIDE,2@
|
||||
ITEM "NUMBER|Numero" MESSAGE SHOW,2@
|
||||
ITEM "DATE|Data" MESSAGE HIDE,2@
|
||||
ITEM "LIST|Selettore" MESSAGE HIDE,2@
|
||||
ITEM "STRINGA|Testo" MESSAGE HIDE,2@,SHOW F_HEIGHT
|
||||
ITEM "NUMERO|Numero" MESSAGE SHOW,2@,HIDE F_HEIGHT
|
||||
ITEM "DATA|Data" MESSAGE HIDE,2@,SHOW F_HEIGHT
|
||||
ITEM "LISTA|Lista" MESSAGE HIDE,2@,SHOW F_HEIGHT
|
||||
END
|
||||
|
||||
STRING F_KEY 44
|
||||
@ -21,65 +21,82 @@ END
|
||||
NUMBER F_Y 3
|
||||
BEGIN
|
||||
PROMPT 1 4 "Riga "
|
||||
HELP "Riga in cui stampare il campo"
|
||||
HELP "Riga in cui stampare"
|
||||
END
|
||||
|
||||
NUMBER F_X 3
|
||||
BEGIN
|
||||
PROMPT 21 4 "Colonna "
|
||||
HELP "Colonna in cui stampare il campo"
|
||||
PROMPT 16 4 "Colonna "
|
||||
HELP "Colonna in cui stampare"
|
||||
END
|
||||
|
||||
NUMBER F_WIDTH 3
|
||||
BEGIN
|
||||
PROMPT 41 4 "Dimensione "
|
||||
HELP "Lunghezza di stampa del campo"
|
||||
PROMPT 32 4 "Larghezza "
|
||||
HELP "Lunghezza massima da stampare"
|
||||
END
|
||||
|
||||
NUMBER F_HEIGHT 2
|
||||
BEGIN
|
||||
PROMPT 48 4 "Altezza "
|
||||
HELP "Righe massime su cui stampare"
|
||||
END
|
||||
|
||||
NUMBER F_DECIMALS 2
|
||||
BEGIN
|
||||
PROMPT 48 4 "Decimali "
|
||||
HELP "Numero di decimali"
|
||||
MESSAGE COPY,F_HEIGHT
|
||||
GROUP 2
|
||||
END
|
||||
|
||||
STRING F_PROMPT 40
|
||||
BEGIN
|
||||
PROMPT 1 5 "Testo "
|
||||
HELP "Eventuale commento al valore del campo"
|
||||
HELP "Eventuale testo fisso da stampare"
|
||||
END
|
||||
|
||||
BOOLEAN F_HIDDEN
|
||||
BEGIN
|
||||
PROMPT 1 6 "Nascosto"
|
||||
HELP "Inidcare se il campo va calcolato ma non visualizzato"
|
||||
HELP "Il campo va elaborato ma non stampato"
|
||||
END
|
||||
|
||||
BOOLEAN F_DISABLED
|
||||
BEGIN
|
||||
PROMPT 21 6 "Disabilitato"
|
||||
HELP "Indicare se il campo viene ignorato"
|
||||
HELP "Il campo viene completamente ignorato e quindi nemmeno stampato"
|
||||
END
|
||||
|
||||
BOOLEAN F_AUTOMAGIC
|
||||
BEGIN
|
||||
PROMPT 41 6 "Automatico"
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
STRING F_FIELD 24
|
||||
BEGIN
|
||||
PROMPT 1 7 "Campo su file "
|
||||
FLAGS "H"
|
||||
HELP "Il campo viene calcolato automaticamente"
|
||||
END
|
||||
|
||||
STRING F_PICTURE 16
|
||||
BEGIN
|
||||
PROMPT 1 8 "Formato di stampa "
|
||||
HELP "Indicare il formato in cui stampare il campo (vedi codici sul manuale)"
|
||||
GROUP 2
|
||||
PROMPT 1 7 "Formato di stampa "
|
||||
HELP "Formato di stampa (vedere codici sul manuale)"
|
||||
END
|
||||
|
||||
|
||||
STRING F_GROUP 16
|
||||
BEGIN
|
||||
PROMPT 1 9 "Gruppo di stampa "
|
||||
HELP "Indicare il numero del gruppo nel quale rientra il campo"
|
||||
PROMPT 1 8 "Gruppo di stampa "
|
||||
HELP "Numeri dei gruppi di appartenenza"
|
||||
END
|
||||
|
||||
STRING F_FIELD 24
|
||||
BEGIN
|
||||
PROMPT 1 9 "Campo su file "
|
||||
HELP "Nome del campo su file"
|
||||
END
|
||||
|
||||
STRING F_FIELD2 24
|
||||
BEGIN
|
||||
PROMPT 1 10 "II campo su file "
|
||||
HELP "Nome del campo su file da utilizzare se il primo e' vuoto"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 9 2
|
||||
BEGIN
|
||||
|
268
include/form.cpp
268
include/form.cpp
@ -17,8 +17,8 @@
|
||||
struct TForm_flags : public TObject
|
||||
{
|
||||
bool automagic : 1;
|
||||
bool disabled : 1;
|
||||
bool hidden : 1;
|
||||
bool enabled : 1;
|
||||
bool shown : 1;
|
||||
|
||||
protected:
|
||||
void print_on(ostream& out) const;
|
||||
@ -34,17 +34,22 @@ public:
|
||||
|
||||
TForm_flags::TForm_flags()
|
||||
{
|
||||
hidden = automagic = disabled = FALSE;
|
||||
automagic = FALSE;
|
||||
shown = enabled = TRUE;
|
||||
}
|
||||
|
||||
bool TForm_flags::update(const char* s)
|
||||
{
|
||||
for (; *s; s++) switch(toupper(*s))
|
||||
{
|
||||
case 'A': automagic = TRUE; break;
|
||||
case 'D': disabled = TRUE; break;
|
||||
case 'H': hidden = TRUE; break;
|
||||
default : error_box("Unknown form item flag '%c'", *s); break;
|
||||
case 'A':
|
||||
automagic = TRUE; break;
|
||||
case 'D':
|
||||
enabled = FALSE; break;
|
||||
case 'H':
|
||||
shown = FALSE; break;
|
||||
default :
|
||||
error_box("Unknown form item flag '%c'", *s); break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -54,23 +59,23 @@ void TForm_flags::print_on(ostream& out) const
|
||||
TString16 s;
|
||||
|
||||
if (automagic) s << "A";
|
||||
if (disabled) s << "D";
|
||||
if (hidden) s << "H";
|
||||
if (!enabled) s << "D";
|
||||
if (!shown) s << "H";
|
||||
|
||||
if (s.not_empty()) out << " FLAGS \"" << s << '"' << endl;
|
||||
}
|
||||
|
||||
void TForm_flags::to_mask(TMask& m) const
|
||||
{
|
||||
m.set(F_DISABLED, disabled ? "X" : " ");
|
||||
m.set(F_HIDDEN, hidden ? "X" : " ");
|
||||
m.set(F_DISABLED, enabled ? " " : "X");
|
||||
m.set(F_HIDDEN, shown ? " " : "X");
|
||||
m.set(F_AUTOMAGIC, automagic ? "X" : " ");
|
||||
}
|
||||
|
||||
void TForm_flags::from_mask(const TMask& m)
|
||||
{
|
||||
hidden = m.get_bool(F_HIDDEN);
|
||||
disabled = m.get_bool(F_DISABLED);
|
||||
shown = !m.get_bool(F_HIDDEN);
|
||||
enabled = !m.get_bool(F_DISABLED);
|
||||
automagic = m.get_bool(F_AUTOMAGIC);
|
||||
}
|
||||
|
||||
@ -88,7 +93,7 @@ class TForm_item : public TObject
|
||||
TArray _message;
|
||||
|
||||
protected:
|
||||
int _x, _y, _width, _heigth;
|
||||
int _x, _y, _width, _height;
|
||||
TString _prompt;
|
||||
|
||||
virtual void print_on(ostream& out) const;
|
||||
@ -98,10 +103,12 @@ protected:
|
||||
virtual void from_mask(const TMask& m);
|
||||
|
||||
int width() const { return _width; }
|
||||
int heigth() const { return _heigth; }
|
||||
int height() const { return _height; }
|
||||
|
||||
bool hidden() const { return _flag.hidden; }
|
||||
bool disabled() const { return _flag.disabled; }
|
||||
bool shown() const { return _flag.shown; }
|
||||
bool hidden() const { return !_flag.shown; }
|
||||
bool enabled() const { return _flag.enabled; }
|
||||
bool disabled() const { return !_flag.enabled; }
|
||||
bool automagic() const { return !_flag.automagic; }
|
||||
|
||||
virtual bool parse_head(TScanner&);
|
||||
@ -111,7 +118,7 @@ protected:
|
||||
virtual bool set(const char* s) { _prompt = s; return TRUE; }
|
||||
|
||||
TToken_string& message(int m = 0);
|
||||
void send_message(const TString& cmd, TForm_item* dest) const;
|
||||
void send_message(const TString& cmd, TForm_item& dest) const;
|
||||
bool do_message(int m = 0);
|
||||
|
||||
void string_at(int x, int y, const char* s);
|
||||
@ -128,7 +135,7 @@ public:
|
||||
const TString& key() const { return _desc; }
|
||||
void to_row(TToken_string& row) const;
|
||||
|
||||
void show(bool on = TRUE) { _flag.hidden = !on; }
|
||||
void show(bool on = TRUE) { _flag.shown = on; }
|
||||
void hide() { show(FALSE); }
|
||||
void enable(bool on = TRUE);
|
||||
void disable() { enable(FALSE); }
|
||||
@ -138,13 +145,13 @@ public:
|
||||
|
||||
|
||||
TForm_item::TForm_item(TPrint_section* section)
|
||||
: _section(section), _x(-1), _y(-1), _width(0), _heigth(0)
|
||||
: _section(section), _x(-1), _y(-1), _width(0), _height(0)
|
||||
{}
|
||||
|
||||
bool TForm_item::parse_head(TScanner& scanner)
|
||||
{
|
||||
_width = scanner.integer();
|
||||
if (_width) _heigth = scanner.integer();
|
||||
if (_width) _height = scanner.integer();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -154,8 +161,8 @@ void TForm_item::print_on(ostream& out) const
|
||||
if (_width > 0)
|
||||
{
|
||||
out << ' ' << _width;
|
||||
if (_heigth > 0)
|
||||
out << ' ' << _heigth;
|
||||
if (_height > 0)
|
||||
out << ' ' << _height;
|
||||
}
|
||||
out << "\nBEGIN\n";
|
||||
|
||||
@ -217,7 +224,7 @@ bool TForm_item::parse_item(TScanner& scanner)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
error_box("Unknown symbol in item '%s': '%s'",
|
||||
yesnofatal_box("Unknown symbol in item '%s': '%s'",
|
||||
(const char*)key(), (const char*)scanner.token());
|
||||
|
||||
return FALSE;
|
||||
@ -228,7 +235,7 @@ bool TForm_item::parse(TScanner& scanner)
|
||||
bool ok = parse_head(scanner);
|
||||
|
||||
if (ok && scanner.popkey() != "BE")
|
||||
ok = error_box("Missing BEGIN in form item %s", (const char*)key());
|
||||
ok = yesnofatal_box("Missing BEGIN in form item %s", (const char*)key());
|
||||
|
||||
while (ok && scanner.popkey() != "EN")
|
||||
ok = parse_item(scanner);
|
||||
@ -238,9 +245,8 @@ bool TForm_item::parse(TScanner& scanner)
|
||||
|
||||
void TForm_item::enable(bool on)
|
||||
{
|
||||
_flag.disabled = !on;
|
||||
if (on) show();
|
||||
else hide();
|
||||
_flag.enabled = on;
|
||||
show(on);
|
||||
}
|
||||
|
||||
|
||||
@ -272,53 +278,52 @@ TToken_string& TForm_item::message(int m)
|
||||
}
|
||||
|
||||
|
||||
void TForm_item::send_message(const TString& cmd, TForm_item* des) const
|
||||
void TForm_item::send_message(const TString& cmd, TForm_item& des) const
|
||||
{
|
||||
if (cmd == "ADD" || cmd == "SUM" || cmd == "INC")
|
||||
{
|
||||
const real n((cmd[0] != 'I') ? get() : "1.0");
|
||||
real r(des->get());
|
||||
real r(des.get());
|
||||
r += n;
|
||||
des->set(r.string());
|
||||
des.set(r.string());
|
||||
} else
|
||||
if (cmd == "COPY")
|
||||
{
|
||||
des->set(get());
|
||||
des.set(get());
|
||||
} else
|
||||
if (cmd == "APPEND")
|
||||
{
|
||||
TString80 val;
|
||||
val = des->get();
|
||||
TString80 val = des.get();
|
||||
if (val.not_empty()) val << ' ';
|
||||
val << get();
|
||||
des->set(val);
|
||||
des.set(val);
|
||||
} else
|
||||
|
||||
if (cmd == "DISABLE")
|
||||
{
|
||||
des->disable();
|
||||
des.disable();
|
||||
} else
|
||||
if (cmd == "ENABLE")
|
||||
{
|
||||
des->enable();
|
||||
des.enable();
|
||||
} else
|
||||
if (cmd == "HIDE")
|
||||
{
|
||||
des->hide();
|
||||
des.hide();
|
||||
} else
|
||||
if (cmd == "SHOW")
|
||||
{
|
||||
des->show();
|
||||
des.show();
|
||||
} else
|
||||
if (cmd == "RESET")
|
||||
{
|
||||
des->set("");
|
||||
des.set("");
|
||||
} else
|
||||
if (cmd[0] == '"')
|
||||
{
|
||||
TString80 val(cmd);
|
||||
val.strip("\"");
|
||||
des->set(val);
|
||||
des.set(val);
|
||||
} else
|
||||
error_box("Unknown message in item '%s': '%s'",
|
||||
(const char*)key(), (const char*)cmd);
|
||||
@ -327,26 +332,21 @@ void TForm_item::send_message(const TString& cmd, TForm_item* des) const
|
||||
|
||||
bool TForm_item::do_message(int num)
|
||||
{
|
||||
if (message(num).empty()) return FALSE;
|
||||
TToken_string& messaggio = message(num);
|
||||
if (messaggio.empty()) return FALSE;
|
||||
|
||||
TToken_string msg(16, ',');
|
||||
TString16 cmd;
|
||||
const char* m;
|
||||
|
||||
message(num).restart();
|
||||
while ((m = message(num).get()) != NULL)
|
||||
for (const char* m = messaggio.get(0); m; m = messaggio.get())
|
||||
{
|
||||
msg = m;
|
||||
cmd = msg.get(); // Get command
|
||||
|
||||
TFixed_string str(msg.get());
|
||||
const word id = atoi(str); // Get destination id
|
||||
const TString16 cmd = msg.get(); // Get command
|
||||
const word id = msg.get_int(); // Get destination group
|
||||
|
||||
// Send the message to all fields with the given group
|
||||
for (int i = 0; i < section()->items(); i++)
|
||||
{
|
||||
TForm_item* des = section()->item(i);
|
||||
if (des->in_group(id))
|
||||
TForm_item& des = section()->item(i);
|
||||
if (des.in_group(id))
|
||||
send_message(cmd, des);
|
||||
}
|
||||
}
|
||||
@ -376,6 +376,7 @@ void TForm_item::to_mask(TMask& m) const
|
||||
m.set(F_Y, _y);
|
||||
m.set(F_PROMPT, _prompt);
|
||||
m.set(F_WIDTH, _width);
|
||||
m.set(F_HEIGHT, _height);
|
||||
_flag.to_mask(m);
|
||||
|
||||
TString16 g;
|
||||
@ -390,27 +391,19 @@ void TForm_item::from_mask(const TMask& m)
|
||||
_y = atoi(m.get(F_Y));
|
||||
_prompt = m.get(F_PROMPT);
|
||||
_width = atoi(m.get(F_WIDTH));
|
||||
|
||||
TString16 flag;
|
||||
if (m.get(F_AUTOMAGIC) == "X") flag << "A";
|
||||
if (m.get(F_HIDDEN) == "X") flag << "H";
|
||||
_flag.update(flag);
|
||||
_height = atoi(m.get(F_HEIGHT));
|
||||
_flag.from_mask(m);
|
||||
_group.reset();
|
||||
_group.set(m.get(F_GROUP));
|
||||
}
|
||||
|
||||
|
||||
bool TForm_item::edit(TMaskmode mode)
|
||||
{
|
||||
TMask m("bagn003");
|
||||
if (mode == MODE_INS)
|
||||
{
|
||||
m.disable(0);
|
||||
m.show();
|
||||
}
|
||||
|
||||
to_mask(m);
|
||||
const bool dirty = (m.run() == K_ENTER) && m.dirty();
|
||||
if (dirty) from_mask(m);
|
||||
|
||||
return dirty;
|
||||
}
|
||||
|
||||
@ -425,7 +418,7 @@ class TForm_string : public TForm_item
|
||||
TArray _field;
|
||||
|
||||
protected:
|
||||
virtual const char* class_name() const { return "STRING"; }
|
||||
virtual const char* class_name() const { return "STRINGA"; }
|
||||
virtual void print_body(ostream& out) const;
|
||||
|
||||
virtual void to_mask(TMask& m) const;
|
||||
@ -439,7 +432,7 @@ protected:
|
||||
|
||||
const TString& picture() const { return _picture; }
|
||||
|
||||
TFieldref* field(int i) const { return (TFieldref*)_field.objptr(i); }
|
||||
TFieldref& field(int i) const { return (TFieldref&)_field[i]; }
|
||||
void put_paragraph(const char* s);
|
||||
|
||||
bool read();
|
||||
@ -472,14 +465,19 @@ void TForm_string::print_body(ostream& out) const
|
||||
if (_picture.not_empty())
|
||||
out << " PICTURE \"" << _picture << "\"" << endl;
|
||||
for (int i = 0; i < _field.items(); i++)
|
||||
out << " FIELD " << *field(i) << endl;
|
||||
out << " FIELD " << field(i) << endl;
|
||||
}
|
||||
|
||||
void TForm_string::to_mask(TMask& m) const
|
||||
{
|
||||
TForm_item::to_mask(m);
|
||||
TString f(24); f << *field(0);
|
||||
m.set(F_FIELD, f);
|
||||
for (int i = 0; i < 2; i++) if (i < _field.items())
|
||||
{
|
||||
TString80 f;
|
||||
f << field(i);
|
||||
m.set(i == 0 ? F_FIELD : F_FIELD2, f);
|
||||
}
|
||||
|
||||
m.set(F_PICTURE, _picture);
|
||||
}
|
||||
|
||||
@ -487,7 +485,15 @@ void TForm_string::from_mask(const TMask& m)
|
||||
{
|
||||
TForm_item::from_mask(m);
|
||||
_picture = m.get(F_PICTURE);
|
||||
*field(0) = m.get(F_FIELD);
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
const TString& f = m.get(i == 0 ? F_FIELD : F_FIELD2);
|
||||
if (f.not_empty())
|
||||
_field.add(new TFieldref(f, 0), i);
|
||||
else
|
||||
_field.destroy(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool TForm_string::set(const char* s)
|
||||
@ -502,12 +508,12 @@ const char* TForm_string::get() const
|
||||
|
||||
bool TForm_string::read()
|
||||
{
|
||||
if (_field.items() && !disabled())
|
||||
if (enabled() && _field.items())
|
||||
{
|
||||
const char* s = "";
|
||||
for (int i = 0; i < _field.items(); i++)
|
||||
{
|
||||
s = field(i)->read(section()->form()->relation());
|
||||
s = field(i).read(section()->form()->relation());
|
||||
if (*s) break;
|
||||
}
|
||||
set(s);
|
||||
@ -521,11 +527,11 @@ void TForm_string::put_paragraph(const char* s)
|
||||
{
|
||||
if (hidden()) return;
|
||||
|
||||
if (heigth() > 1)
|
||||
if (height() > 1)
|
||||
{
|
||||
TParagraph_string p(s, width());
|
||||
int i = _prompt.not_empty() ? 1 : 0;
|
||||
for (; (s = p.get()) != NULL && i < heigth(); i++)
|
||||
for (; (s = p.get()) != NULL && i < height(); i++)
|
||||
string_at(_x, _y+i, s);
|
||||
}
|
||||
else string_at(-1, _y, s);
|
||||
@ -539,10 +545,12 @@ bool TForm_string::update()
|
||||
{
|
||||
if (_picture.not_empty())
|
||||
{
|
||||
TString p;
|
||||
TString80 p;
|
||||
p.picture(_picture, get());
|
||||
put_paragraph(p);
|
||||
} else put_paragraph(get());
|
||||
}
|
||||
else
|
||||
put_paragraph(get());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -554,10 +562,12 @@ bool TForm_string::update()
|
||||
class TForm_number : public TForm_string
|
||||
{
|
||||
protected:
|
||||
virtual const char* class_name() const { return "NUMBER"; }
|
||||
virtual const char* class_name() const { return "NUMERO"; }
|
||||
virtual bool parse_head(TScanner& scanner);
|
||||
virtual bool update();
|
||||
|
||||
int decimals() const { return height(); }
|
||||
|
||||
public:
|
||||
TForm_number(TPrint_section* section) : TForm_string(section) {}
|
||||
};
|
||||
@ -566,7 +576,7 @@ public:
|
||||
bool TForm_number::parse_head(TScanner& scanner)
|
||||
{
|
||||
_width = 0;
|
||||
_heigth = scanner.integer();
|
||||
_height = scanner.integer();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -576,9 +586,10 @@ bool TForm_number::update()
|
||||
TForm_item::update();
|
||||
if (read())
|
||||
{
|
||||
real n(get());
|
||||
n.round(heigth());
|
||||
const char* s = n.string(picture());
|
||||
const char* s = get();
|
||||
real n(s);
|
||||
n.round(decimals());
|
||||
s = n.string(picture());
|
||||
put_paragraph(s);
|
||||
}
|
||||
return TRUE;
|
||||
@ -591,7 +602,7 @@ bool TForm_number::update()
|
||||
class TForm_date : public TForm_string
|
||||
{
|
||||
protected:
|
||||
virtual const char* class_name() const { return "DATE"; }
|
||||
virtual const char* class_name() const { return "DATA"; }
|
||||
virtual bool set(const char*);
|
||||
|
||||
public:
|
||||
@ -612,11 +623,13 @@ TForm_date::TForm_date(TPrint_section* section)
|
||||
|
||||
bool TForm_date::set(const char* s)
|
||||
{
|
||||
TDate d(s);
|
||||
bool ok = d.ok();
|
||||
if (ok)
|
||||
ok = TForm_string::set(d.string((width() == 8) ? 2 : 4));
|
||||
return ok;
|
||||
const TDate d(s);
|
||||
TForm_string::set(d.string((width() == 8) ? 2 : 4));
|
||||
#ifdef DBG
|
||||
return d.ok();
|
||||
#else
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -629,7 +642,7 @@ class TForm_list : public TForm_string
|
||||
TToken_string _values;
|
||||
|
||||
protected:
|
||||
virtual const char* class_name() const { return "LIST"; }
|
||||
virtual const char* class_name() const { return "LISTA"; }
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
virtual void print_body(ostream& out) const;
|
||||
virtual bool update();
|
||||
@ -649,9 +662,11 @@ bool TForm_list::parse_item(TScanner& scanner)
|
||||
TToken_string s(scanner.string());
|
||||
_codes.add(s.get());
|
||||
_values.add(s.get());
|
||||
|
||||
TString m(80);
|
||||
while (scanner.popkey() == "ME")
|
||||
{
|
||||
TString m(scanner.line());
|
||||
m = scanner.line();
|
||||
m.strip_spaces();
|
||||
message(_values.items()-1).add(m);
|
||||
}
|
||||
@ -694,39 +709,22 @@ bool TForm_list::update()
|
||||
|
||||
if (!read()) return ok;
|
||||
|
||||
int pos = _codes.get_pos(get());
|
||||
const TString& val =get();
|
||||
const int pos = _codes.get_pos(val);
|
||||
if (pos < 0)
|
||||
{
|
||||
TString k(_codes.get(0));
|
||||
ok = error_box("Il campo '%s' non puo' valere '%s': assumo '%s'",
|
||||
(const char*)key(), get(), (const char*)k);
|
||||
set(k);
|
||||
pos = 0;
|
||||
ok = yesnofatal_box("Il campo '%s' non puo' valere '%s'",
|
||||
(const char*)key(), (const char*)val);
|
||||
}
|
||||
|
||||
do_message(pos);
|
||||
|
||||
if (!hidden())
|
||||
{
|
||||
if (_prompt.not_empty())
|
||||
{
|
||||
int found = -1;
|
||||
for (int i = 0; found < pos && _prompt[i]; i++)
|
||||
if (_prompt[i] != ' ') found++;
|
||||
if (found == pos)
|
||||
{
|
||||
char c[2] = { _prompt[i], '\0' };
|
||||
string_at(_x+i, _y, c);
|
||||
}
|
||||
else error_box("Non trovo l'elemento %d in '%s'", (const char*)_prompt);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* c = _values.get(pos);
|
||||
if (c == NULL) c = get();
|
||||
if (c == NULL) c = val;
|
||||
if (c) string_at(_x, _y, c);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -743,7 +741,7 @@ void TPrint_section::init(const char* name, TForm* f)
|
||||
}
|
||||
|
||||
TPrint_section::TPrint_section(const char* name, TForm* f)
|
||||
: _heigth(0)
|
||||
: _height(0)
|
||||
{
|
||||
init(name, f);
|
||||
}
|
||||
@ -770,14 +768,17 @@ TForm_item* TPrint_section::parse_item(TScanner& scanner)
|
||||
if (scanner.key() == "LI")
|
||||
return new TForm_list(this);
|
||||
|
||||
error_box("Elemento sconosciuto nella sezione %s: %s",
|
||||
#ifdef DBG
|
||||
yesnofatal_box("Elemento sconosciuto nella sezione '%s': '%s'",
|
||||
(const char*)_name, (const char*)scanner.token());
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool TPrint_section::parse(TScanner& scanner)
|
||||
{
|
||||
_heigth = scanner.integer();
|
||||
_height = scanner.integer();
|
||||
|
||||
set_cursor(TASK_WIN, CURSOR_WAIT);
|
||||
|
||||
@ -808,24 +809,24 @@ bool TPrint_section::update()
|
||||
if (!esito) ok = FALSE;
|
||||
}
|
||||
i = items();
|
||||
if (i < _heigth) row(_heigth-1);
|
||||
else if (i > _heigth)
|
||||
if (i < _height) row(_height-1);
|
||||
else if (i > _height)
|
||||
ok = warning_box("Sezione %s troppo lunga: %d > %d",
|
||||
(const char*)_name, i, _heigth);
|
||||
(const char*)_name, i, _height);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TPrint_section::edit(int mode)
|
||||
{
|
||||
TString title(40);
|
||||
TString80 title;
|
||||
title = "Campi della sezione "; title << _name;
|
||||
|
||||
TArray_sheet a(-1, -1, 0, 0, title, "Tipo@6|Descrizione@40", 0x8);
|
||||
TArray_sheet a(-1, -1, 0, 0, title, "Tipo@8|Descrizione@40", 0x8);
|
||||
|
||||
for (int i = 0; i < items(); i++)
|
||||
{
|
||||
TToken_string s(64);
|
||||
item(i)->to_row(s);
|
||||
item(i).to_row(s);
|
||||
a.add(s);
|
||||
}
|
||||
|
||||
@ -833,11 +834,11 @@ bool TPrint_section::edit(int mode)
|
||||
while (a.run() == K_ENTER)
|
||||
{
|
||||
i = (int)a.selected();
|
||||
const bool spork = item(i)->edit((TMaskmode)mode);
|
||||
const bool spork = item(i).edit((TMaskmode)mode);
|
||||
if (spork)
|
||||
{
|
||||
dirty = TRUE;
|
||||
item(i)->to_row(a.row(i));
|
||||
item(i).to_row(a.row(i));
|
||||
}
|
||||
}
|
||||
return dirty;
|
||||
@ -845,9 +846,9 @@ bool TPrint_section::edit(int mode)
|
||||
|
||||
void TPrint_section::print_on(ostream& out) const
|
||||
{
|
||||
out << "\nPAGE " << _name << ' ' << _heigth << '\n' << endl;
|
||||
out << "\nPAGE " << _name << ' ' << _height << '\n' << endl;
|
||||
for(int i = 0; i < items(); i++)
|
||||
out << *item(i);
|
||||
out << item(i);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -918,9 +919,9 @@ bool TForm::parse_join(TScanner& scanner)
|
||||
exp.add(r);
|
||||
r = scanner.pop();
|
||||
}
|
||||
if (exp.empty())
|
||||
error_box("JOIN senza espressioni INTO");
|
||||
}
|
||||
if (exp.empty())
|
||||
yesnofatal_box("JOIN senza espressioni INTO");
|
||||
scanner.push();
|
||||
|
||||
if (isdigit(j[0]))
|
||||
@ -939,7 +940,7 @@ bool TForm::set_header()
|
||||
|
||||
const bool ok = _head.update();
|
||||
|
||||
int last = _head.last();
|
||||
const int last = _head.last();
|
||||
for (int j = 0; j <= last; j++)
|
||||
printer.setheaderline(j, _head.row(j));
|
||||
|
||||
@ -954,7 +955,7 @@ bool TForm::set_footer()
|
||||
|
||||
const bool ok = _foot.update();
|
||||
|
||||
int last = _foot.last();
|
||||
const int last = _foot.last();
|
||||
for (int j = 0; j <= last; j++)
|
||||
printer.setfooterline(j, _foot.row(j));
|
||||
|
||||
@ -1015,9 +1016,12 @@ bool TForm::edit(int mode, int section)
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case 0: dirty = _head.edit(mode); break;
|
||||
case 2: dirty = _foot.edit(mode); break;
|
||||
default: dirty = _body.edit(mode); break;
|
||||
case 0:
|
||||
dirty = _head.edit(mode); break;
|
||||
case 2:
|
||||
dirty = _foot.edit(mode); break;
|
||||
default:
|
||||
dirty = _body.edit(mode); break;
|
||||
}
|
||||
|
||||
if (dirty && yesno_box("Salvare le modifiche?"))
|
||||
|
@ -19,11 +19,11 @@ class TForm_item;
|
||||
|
||||
class TPrint_section : public TArray
|
||||
{
|
||||
TString16 _name;
|
||||
int _heigth;
|
||||
TString16 _name; // Nome della sezione di stampa
|
||||
int _height; // Altezza della sezione
|
||||
|
||||
TForm* _form;
|
||||
TArray _item;
|
||||
TForm* _form; // Form cui appartiene alla sezione
|
||||
TArray _item; // Lista dei campi da stampare
|
||||
|
||||
protected:
|
||||
virtual void print_on(ostream& out) const;
|
||||
@ -33,7 +33,7 @@ public:
|
||||
TPrintrow& row(int num);
|
||||
TForm* form() const { return _form; }
|
||||
|
||||
TForm_item* item(int n) const { return (TForm_item*)_item.objptr(n); }
|
||||
TForm_item& item(int n) const { return (TForm_item&)_item[n]; }
|
||||
int items() const { return _item.items(); }
|
||||
|
||||
bool update();
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: mailbox.cpp,v 1.9 1994-12-07 12:20:58 guy Exp $
|
||||
// $Id: mailbox.cpp,v 1.10 1994-12-15 18:06:18 guy Exp $
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fstream.h>
|
||||
@ -20,7 +20,7 @@ TMessage::TMessage(const char* to, const char* sub,
|
||||
const char* text, const char* from)
|
||||
{
|
||||
_to = to;
|
||||
if (_to.len() != 6 || _to.strip(" -") != to)
|
||||
if (to && *to && (_to.len() != 6 || _to.strip(" -") != to))
|
||||
_to = cmd2name(to);
|
||||
_subject = sub;
|
||||
_text = text;
|
||||
|
@ -1058,7 +1058,7 @@ void TMask::enable_key(byte key, bool on)
|
||||
if (on)
|
||||
{
|
||||
fld(i).enable_default();
|
||||
if (!fld(i).showed())
|
||||
if (!fld(i).shown())
|
||||
fld(i).show_default();
|
||||
}
|
||||
else fld(i).disable();
|
||||
@ -1108,15 +1108,22 @@ bool TMask::key_valid(int key) const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void TMask::show(short fld_id, bool on)
|
||||
{
|
||||
if (fld_id <= 0)
|
||||
{
|
||||
const int gr = -fld_id;
|
||||
for (int i = 0; i < fields(); i++) if (gr == 0 || fld(i).in_group(gr))
|
||||
fld(i).show(on);
|
||||
} else field(fld_id).show(on);
|
||||
for (int i = 0; i < fields(); i++)
|
||||
{
|
||||
TMask_field& f = fld(i);
|
||||
if (gr == 0 || f.in_group(gr))
|
||||
f.show(on);
|
||||
}
|
||||
}
|
||||
else field(fld_id).show(on);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TMask::show_default(short fld_id)
|
||||
@ -1150,7 +1157,7 @@ void TMask::autosave(TRelation* r) const
|
||||
const TFieldref* fr =f.field();
|
||||
if (fr != NULL)
|
||||
{
|
||||
if (f.showed() || *fr->read(r) == '\0')
|
||||
if (f.shown() || *fr->read(r) == '\0')
|
||||
f.autosave(r);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: maskfld.cpp,v 1.60 1994-12-07 18:03:37 guy Exp $
|
||||
// $Id: maskfld.cpp,v 1.61 1994-12-15 18:06:23 guy Exp $
|
||||
#include <xvt.h>
|
||||
|
||||
#include <applicat.h>
|
||||
@ -31,7 +31,7 @@ TMask_field::TField_Flags::TField_Flags()
|
||||
{
|
||||
automagic = persistent = FALSE;
|
||||
enabled = enable_default = TRUE;
|
||||
showed = show_default = TRUE;
|
||||
shown = show_default = TRUE;
|
||||
uppercase = rightjust = FALSE;
|
||||
zerofilled = FALSE;
|
||||
dirty = focusdirty = FALSE;
|
||||
@ -58,7 +58,7 @@ char TMask_field::TField_Flags::update(const char* s)
|
||||
case 'G':
|
||||
ghost = TRUE; break;
|
||||
case 'H':
|
||||
show_default = showed = FALSE; break;
|
||||
show_default = shown = FALSE; break;
|
||||
case 'M':
|
||||
roman = TRUE; break;
|
||||
case 'P':
|
||||
@ -348,7 +348,7 @@ void TMask_field::show(bool on)
|
||||
show_window(_win, on);
|
||||
if (_promptwin != NULL_WIN)
|
||||
show_window(_promptwin, on);
|
||||
_flags.showed = on;
|
||||
_flags.shown = on;
|
||||
}
|
||||
|
||||
|
||||
@ -363,7 +363,7 @@ void TMask_field::show_default()
|
||||
// Certified 100%
|
||||
bool TMask_field::active() const
|
||||
{
|
||||
return enabled() && showed() && class_id() != CLASS_FIELD;
|
||||
return enabled() && shown() && class_id() != CLASS_FIELD;
|
||||
};
|
||||
|
||||
|
||||
@ -661,7 +661,7 @@ bool TMask_field::do_message(int num)
|
||||
if (value != prev)
|
||||
{
|
||||
f.set(value);
|
||||
if (f.showed() || f.ghost())
|
||||
if (f.shown() || f.ghost())
|
||||
f.on_hit();
|
||||
}
|
||||
}
|
||||
@ -674,7 +674,7 @@ bool TMask_field::do_message(int num)
|
||||
if (value != prev)
|
||||
{
|
||||
f.set(value);
|
||||
if (f.showed() || f.ghost())
|
||||
if (f.shown() || f.ghost())
|
||||
f.on_hit();
|
||||
}
|
||||
}
|
||||
@ -1383,7 +1383,7 @@ TToken_string& TBrowse::create_siblings(TToken_string& siblings)
|
||||
{
|
||||
const short id = _fld->atodlg(i);
|
||||
const TMask_field& f = mask.field(id);
|
||||
if (!f.showed() || !f.is_edit()) // Scarta i campi non editabili
|
||||
if (!f.shown() || !f.is_edit()) // Scarta i campi non editabili
|
||||
continue;
|
||||
const TEdit_field& e = (const TEdit_field&)f;
|
||||
const TBrowse* b = e.browse();
|
||||
@ -1582,7 +1582,7 @@ void TEdit_field::enable(bool on)
|
||||
{
|
||||
TMask_field::enable(on);
|
||||
if (_buttonwin != NULL_WIN)
|
||||
show_window(_buttonwin, on && check_enabled() && showed());
|
||||
show_window(_buttonwin, on && check_enabled() && shown());
|
||||
}
|
||||
|
||||
void TEdit_field::show(bool on)
|
||||
@ -2096,7 +2096,7 @@ bool TEdit_field::has_check() const
|
||||
|
||||
bool TEdit_field::check(CheckTime t)
|
||||
{
|
||||
if (check_enabled() || (t == STARTING_CHECK && showed()))
|
||||
if (check_enabled() || (t == STARTING_CHECK && shown()))
|
||||
{
|
||||
if (_browse) return _browse->check(t); else
|
||||
if (_sheet) return _sheet->check(t);
|
||||
@ -2703,7 +2703,7 @@ void TList_field::delete_item(const char* s)
|
||||
if (mask().is_running())
|
||||
{
|
||||
win_list_set_sel(win(), 0, TRUE);
|
||||
if (showed()) on_hit();
|
||||
if (shown()) on_hit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3029,7 +3029,7 @@ void TRadio_field::show(bool on)
|
||||
|
||||
for(int i = 0; i < _nitems; i++)
|
||||
show_window(_radio_ctl_win[i], on);
|
||||
_flags.showed = on;
|
||||
_flags.shown = on;
|
||||
}
|
||||
|
||||
// Return TRUE if focus has left the radio
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: maskfld.h,v 1.14 1994-11-29 17:34:31 alex Exp $ */
|
||||
/* $Id: maskfld.h,v 1.15 1994-12-15 18:06:30 guy Exp $ */
|
||||
#ifndef __MASKFLD_H
|
||||
#define __MASKFLD_H
|
||||
|
||||
@ -74,7 +74,7 @@ protected:
|
||||
bool persistent : 1;
|
||||
bool rightjust : 1;
|
||||
bool roman : 1; // Is a Roman number ?
|
||||
bool showed : 1; // Is visible
|
||||
bool shown : 1; // Is visible
|
||||
bool show_default : 1;
|
||||
bool uppercase : 1;
|
||||
bool exchange : 1; // Value exchange
|
||||
@ -153,7 +153,7 @@ public:
|
||||
|
||||
virtual void show(bool on = TRUE);
|
||||
void hide() { show(FALSE); }
|
||||
bool showed() const { return _flags.showed; }
|
||||
bool shown() const { return _flags.shown; }
|
||||
void show_default();
|
||||
|
||||
bool active() const; // Is visible and enabled?
|
||||
|
@ -950,7 +950,7 @@ void TSpreadsheet::mask2str(int riga)
|
||||
for(int dlg = id; pos >= 0; pos = sheet_mask().id2pos(dlg += 100))
|
||||
{
|
||||
const TMask_field& f = sheet_mask().fld(pos);
|
||||
if (f.showed())
|
||||
if (f.shown())
|
||||
{
|
||||
r.add(f.get());
|
||||
break;
|
||||
@ -1204,7 +1204,7 @@ void TSheet_field::create(WINDOW parent)
|
||||
|
||||
_win = _sheet->win();
|
||||
enable_window(_win, enabled());
|
||||
show_window(_win, showed());
|
||||
show_window(_win, shown());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
#define VERSION 1.1
|
||||
#define VERSION 1.2
|
||||
|
@ -74,19 +74,19 @@ char* format(const char* fmt, ...)
|
||||
|
||||
const char* cmd2name(const char* argv0, const char* argv1)
|
||||
{
|
||||
TFilename app(argv0); app.ext(""); app = app.name();
|
||||
if (argv1 != NULL && *argv1 != '\0') app << ' ' << argv1;
|
||||
TFilename app(argv0);
|
||||
app = app.name();
|
||||
if (argv1 && *argv1) app << ' ' << argv1;
|
||||
else app << " -0";
|
||||
app.lower();
|
||||
|
||||
const int par = app.find(" -");
|
||||
if (par > 0)
|
||||
{
|
||||
CHECKS(par > 0, "Bad command line: ", (const char*)app);
|
||||
|
||||
const int num = atoi(app.mid(par+2)) + 1;
|
||||
const char c = (num > 9) ? ('a'+num-10) : ('0'+num);
|
||||
app.cut(par);
|
||||
app.cut(3);
|
||||
app << c << "00";
|
||||
}
|
||||
|
||||
return strcpy(__tmp_string, app);
|
||||
}
|
||||
|
@ -1795,9 +1795,11 @@ bool TViswin::call_editor ()
|
||||
strcpy (fs.name, "");
|
||||
|
||||
save_dir ();
|
||||
if (save_file_dlg (&fs, "Salva il file con il nome:") == FL_OK)
|
||||
{
|
||||
ok = save_file_dlg (&fs, "Salva il file con il nome:") == FL_OK;
|
||||
restore_dir ();
|
||||
|
||||
if (ok)
|
||||
{
|
||||
char path[256];
|
||||
dir_to_str (&fs.dir, path, sizeof (path));
|
||||
newfilename = path;
|
||||
@ -1819,7 +1821,6 @@ bool TViswin::call_editor ()
|
||||
ok = TRUE;
|
||||
}
|
||||
}
|
||||
restore_dir ();
|
||||
}
|
||||
else
|
||||
warning_box ("Nessun editor specificato nei parametri studio");
|
||||
@ -1831,7 +1832,6 @@ void TViswin::add_line (const char *l)
|
||||
if (_isopen && !_frozen)
|
||||
{
|
||||
if (_txt.frozen ()) // error writing files
|
||||
|
||||
{
|
||||
close_print ();
|
||||
return;
|
||||
@ -2025,7 +2025,7 @@ void TBrowsefile_field::create(WINDOW parent)
|
||||
_size, _width, _flags.rightjust ? TRUE : FALSE, parent, this);
|
||||
_win = _viswin->win();
|
||||
enable_window(_win, enabled());
|
||||
show_window(_win, showed());
|
||||
show_window(_win, shown());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user