Ricostruito editor dei forms e corretta dis/abilitazione campi statici

git-svn-id: svn://10.65.10.50/trunk@783 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-12-20 15:11:26 +00:00
parent 1654274d5b
commit 4fae71bdd7
14 changed files with 689 additions and 334 deletions

View File

@ -2,6 +2,10 @@
#include <xvt.h> #include <xvt.h>
#if XVT_OS == XVT_OS_WIN
#include <windows.h>
#endif
#include <extcdecl.h> #include <extcdecl.h>
#include <modaut.h> #include <modaut.h>
@ -306,6 +310,13 @@ void TApplication::terminate()
delete _printer; delete _printer;
_printer = NULL; _printer = NULL;
} }
#if XVT_OS == XVT_OS_WIN
if (fexist("prassi.hlp"))
{
HWND hwnd = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, "prassi.hlp", HELP_QUIT, 0L);
}
#endif
} }
if (use_files()) if (use_files())

View File

@ -9,9 +9,22 @@
#define F_DISABLED 109 #define F_DISABLED 109
#define F_AUTOMAGIC 110 #define F_AUTOMAGIC 110
#define F_PICTURE 111 #define F_PICTURE 111
#define F_GROUP 112
#define F_FIELD 113 #define F_FIELD 113
#define F_FIELD2 114 #define F_FIELD2 114
#define F_GROUP 130
#define F_GROUP1 131
#define F_GROUP2 132
#define F_GROUP3 133
#define F_GROUP4 134
#define F_GROUP5 135
#define F_GROUP6 136
#define F_GROUP7 137
#define F_GROUP8 138
#define F_GROUP9 139
#define F_GROUP10 140
#define F_GROUP11 141
#define F_GROUP12 142
#define F_ITEMS 200
#define F_DECIMALS 206 #define F_DECIMALS 206

View File

@ -1,18 +1,32 @@
#include <bagn003.h> #include <bagn003.h>
TOOLBAR "" 0 20 0 2
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
PAGE "CAMPO DI STAMPA" -1 -1 60 14 PAGE "CAMPO DI STAMPA" -1 -1 60 14
LIST F_CLASS 10 LIST F_CLASS 10
BEGIN BEGIN
PROMPT 1 1 "Tipo " PROMPT 1 1 "Tipo "
FLAGS "D" FLAGS "DG"
ITEM "STRINGA|Testo" MESSAGE HIDE,2@,SHOW F_HEIGHT ITEM "STRINGA|Testo" MESSAGE HIDE,2@|SHOW,F_HEIGHT|HIDE,F_ITEMS
ITEM "NUMERO|Numero" MESSAGE SHOW,2@,HIDE F_HEIGHT ITEM "NUMERO|Numero" MESSAGE SHOW,2@|HIDE,F_HEIGHT|HIDE,F_ITEMS
ITEM "DATA|Data" MESSAGE HIDE,2@,SHOW F_HEIGHT ITEM "DATA|Data" MESSAGE HIDE,2@|HIDE,F_HEIGHT|HIDE,F_ITEMS
ITEM "LISTA|Lista" MESSAGE HIDE,2@,SHOW F_HEIGHT ITEM "LISTA|Lista" MESSAGE HIDE,2@|HIDE,F_HEIGHT|SHOW,F_ITEMS
END END
STRING F_KEY 44 STRING F_KEY 80 60
BEGIN BEGIN
PROMPT 1 2 "Descrizione " PROMPT 1 2 "Descrizione "
HELP "Descrizione del campo da configurare" HELP "Descrizione del campo da configurare"
@ -20,94 +34,180 @@ END
NUMBER F_Y 3 NUMBER F_Y 3
BEGIN BEGIN
PROMPT 1 4 "Riga " PROMPT 1 3 "Riga "
HELP "Riga in cui stampare" HELP "Riga in cui stampare"
END END
NUMBER F_X 3 NUMBER F_X 3
BEGIN BEGIN
PROMPT 16 4 "Colonna " PROMPT 24 3 "Colonna "
HELP "Colonna in cui stampare" HELP "Colonna in cui stampare"
END END
NUMBER F_WIDTH 3 NUMBER F_WIDTH 3
BEGIN BEGIN
PROMPT 32 4 "Larghezza " PROMPT 1 4 "Larghezza "
HELP "Lunghezza massima da stampare" HELP "Lunghezza massima da stampare"
END END
NUMBER F_HEIGHT 2 NUMBER F_HEIGHT 2
BEGIN BEGIN
PROMPT 48 4 "Altezza " PROMPT 24 4 "Altezza "
HELP "Righe massime su cui stampare" HELP "Righe massime su cui stampare"
END END
NUMBER F_DECIMALS 2 NUMBER F_DECIMALS 2
BEGIN BEGIN
PROMPT 48 4 "Decimali " PROMPT 24 4 "Decimali "
HELP "Numero di decimali" HELP "Numero di decimali"
MESSAGE COPY,F_HEIGHT MESSAGE COPY,F_HEIGHT
GROUP 2 GROUP 2
END END
STRING F_PROMPT 40 STRING F_PROMPT 80 60
BEGIN BEGIN
PROMPT 1 5 "Testo " PROMPT 1 5 "Testo "
HELP "Eventuale testo fisso da stampare" HELP "Eventuale testo fisso da stampare"
END END
STRING F_PICTURE 80 40
BEGIN
PROMPT 1 6 "Formato "
HELP "Formato di stampa (vedere codici sul manuale)"
END
STRING F_FIELD 40
BEGIN
PROMPT 1 7 "Campo su file "
HELP "Nome del campo su file"
END
STRING F_FIELD2 40
BEGIN
PROMPT 1 8 "II campo "
HELP "Nome del campo su file da utilizzare se il primo e' vuoto"
END
BOOLEAN F_HIDDEN BOOLEAN F_HIDDEN
BEGIN BEGIN
PROMPT 1 6 "Nascosto" PROMPT 60 6 "Nascosto"
HELP "Il campo va elaborato ma non stampato" HELP "Il campo va elaborato ma non stampato"
END END
BOOLEAN F_DISABLED BOOLEAN F_DISABLED
BEGIN BEGIN
PROMPT 21 6 "Disabilitato" PROMPT 60 7 "Disabilitato"
HELP "Il campo viene completamente ignorato e quindi nemmeno stampato" HELP "Il campo viene completamente ignorato e quindi nemmeno stampato"
END END
BOOLEAN F_AUTOMAGIC BOOLEAN F_AUTOMAGIC
BEGIN BEGIN
PROMPT 41 6 "Automatico" PROMPT 60 8 "Automatico"
HELP "Il campo viene calcolato automaticamente" HELP "Il campo viene calcolato automaticamente"
END END
STRING F_PICTURE 16 GROUPBOX F_GROUP 78 3
BEGIN BEGIN
PROMPT 1 7 "Formato di stampa " PROMPT 1 9 "Gruppi di stampa"
HELP "Formato di stampa (vedere codici sul manuale)"
END END
STRING F_GROUP 16 BOOLEAN F_GROUP1
BEGIN BEGIN
PROMPT 1 8 "Gruppo di stampa " PROMPT 4 10 "1"
HELP "Numeri dei gruppi di appartenenza"
END END
STRING F_FIELD 24 BOOLEAN F_GROUP2
BEGIN BEGIN
PROMPT 1 9 "Campo su file " PROMPT 10 10 "2"
HELP "Nome del campo su file"
END END
STRING F_FIELD2 24 BOOLEAN F_GROUP3
BEGIN BEGIN
PROMPT 1 10 "II campo su file " PROMPT 16 10 "3"
HELP "Nome del campo su file da utilizzare se il primo e' vuoto"
END END
BUTTON DLG_OK 9 2 BOOLEAN F_GROUP4
BEGIN BEGIN
PROMPT -12 -1 "" PROMPT 22 10 "4"
END END
BUTTON DLG_CANCEL 9 2 BOOLEAN F_GROUP5
BEGIN BEGIN
PROMPT -22 -1 "" PROMPT 28 10 "5"
END
BOOLEAN F_GROUP6
BEGIN
PROMPT 34 10 "6"
END
BOOLEAN F_GROUP7
BEGIN
PROMPT 40 10 "7"
END
BOOLEAN F_GROUP8
BEGIN
PROMPT 46 10 "8"
END
BOOLEAN F_GROUP9
BEGIN
PROMPT 52 10 "9"
END
BOOLEAN F_GROUP10
BEGIN
PROMPT 58 10 "10"
END
BOOLEAN F_GROUP11
BEGIN
PROMPT 64 10 "11"
END
BOOLEAN F_GROUP12
BEGIN
PROMPT 70 10 "12"
END
SPREADSHEET F_ITEMS
BEGIN
PROMPT 0 12 "Spreadsheet"
ITEM "Codice@8"
ITEM "Testo@32"
ITEM "Messaggio@80"
END END
ENDPAGE ENDPAGE
ENDMASK ENDMASK
PAGE "Spreadsheet" -1 -1 46 6
STRING 101 8
BEGIN
PROMPT 1 1 "Codice "
END
STRING 102 32
BEGIN
PROMPT 1 2 "Testo "
END
STRING 103 80 32
BEGIN
PROMPT 1 3 "Messaggio "
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE

View File

@ -167,11 +167,7 @@ void TControl::create(
if (bold) title += 2; if (bold) title += 2;
const int prop_count = 1; const int prop_count = 1;
const char* prop_list[prop_count+1] = const char* prop_list[prop_count+1] = { title, NULL };
{
title,
NULL
};
_id = id; _id = id;
_caption = title; _caption.strip("~"); _caption = title; _caption.strip("~");
@ -339,6 +335,7 @@ TText::TText(short left, short top, short right, short bottom,
void TText::update() const void TText::update() const
{ {
TControl::update(); TControl::update();
win_set_fore_color(_hdc, COLOR_BLACK);
win_draw_text(_hdc, _client.left, _client.top+BASEY, (char*)caption(), -1); win_draw_text(_hdc, _client.left, _client.top+BASEY, (char*)caption(), -1);
} }
@ -362,7 +359,7 @@ public:
TGroup::TGroup(short left, short top, short right, short bottom, TGroup::TGroup(short left, short top, short right, short bottom,
const char* caption, WINDOW parent, const char* caption, WINDOW parent,
long flags, long app_data, short id) long flags, long app_data, short id)
: TText(left, top, right, bottom, caption, parent, flags, app_data, : TText(left, top, right, bottom, caption, parent, flags | CTL_FLAG_DISABLED, app_data,
(id < 0) ? -2 : id) (id < 0) ? -2 : id)
{} {}
@ -905,7 +902,7 @@ void TCheckbox::update() const
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
RECT r; RECT r;
r.left = x-2; r.top = _client.top; r.left = x-2; r.top = _client.top;
r.right = _client.right; r.bottom = y+3; r.right = _client.right-CHARX; r.bottom = y+3;
HWND hwnd = (HWND)get_value(_hdc, ATTR_NATIVE_WINDOW); HWND hwnd = (HWND)get_value(_hdc, ATTR_NATIVE_WINDOW);
HDC hdc = GetDC(hwnd); HDC hdc = GetDC(hwnd);

View File

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <applicat.h> #include <applicat.h>
#include <mask.h> #include <msksheet.h>
#include <form.h> #include <form.h>
#include <relation.h> #include <relation.h>
#include <sheet.h> #include <sheet.h>
@ -10,6 +10,14 @@
#include <bagn003.h> #include <bagn003.h>
static TForm* _form = NULL;
static TForm& form()
{
CHECK(_form, "Can't print NULL form");
return *_form;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TForm_flags // TForm_flags
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -26,8 +34,8 @@ protected:
public: public:
TForm_flags(); TForm_flags();
void to_mask(TMask& m) const; void print_on(TMask& m);
void from_mask(const TMask& m); void read_from(const TMask& m);
bool update(const char* s); bool update(const char* s);
}; };
@ -54,6 +62,7 @@ bool TForm_flags::update(const char* s)
return TRUE; return TRUE;
} }
void TForm_flags::print_on(ostream& out) const void TForm_flags::print_on(ostream& out) const
{ {
TString16 s; TString16 s;
@ -65,14 +74,16 @@ void TForm_flags::print_on(ostream& out) const
if (s.not_empty()) out << " FLAGS \"" << s << '"' << endl; if (s.not_empty()) out << " FLAGS \"" << s << '"' << endl;
} }
void TForm_flags::to_mask(TMask& m) const
void TForm_flags::print_on(TMask& m)
{ {
m.set(F_DISABLED, enabled ? " " : "X"); m.set(F_DISABLED, enabled ? " " : "X");
m.set(F_HIDDEN, shown ? " " : "X"); m.set(F_HIDDEN, shown ? " " : "X");
m.set(F_AUTOMAGIC, automagic ? "X" : " "); m.set(F_AUTOMAGIC, automagic ? "X" : " ");
} }
void TForm_flags::from_mask(const TMask& m)
void TForm_flags::read_from(const TMask& m)
{ {
shown = !m.get_bool(F_HIDDEN); shown = !m.get_bool(F_HIDDEN);
enabled = !m.get_bool(F_DISABLED); enabled = !m.get_bool(F_DISABLED);
@ -99,9 +110,6 @@ protected:
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
virtual void print_body(ostream& out) const; virtual void print_body(ostream& out) const;
virtual void to_mask(TMask& m) const;
virtual void from_mask(const TMask& m);
int width() const { return _width; } int width() const { return _width; }
int height() const { return _height; } int height() const { return _height; }
@ -127,7 +135,9 @@ public:
virtual bool parse(TScanner&); virtual bool parse(TScanner&);
virtual bool update(); virtual bool update();
bool edit(TMaskmode mode); virtual void print_on(TMask& m);
virtual void read_from(const TMask& m);
bool edit(TMask& m);
TPrint_section* section() const { return _section; } TPrint_section* section() const { return _section; }
@ -148,6 +158,7 @@ TForm_item::TForm_item(TPrint_section* section)
: _section(section), _x(-1), _y(-1), _width(0), _height(0) : _section(section), _x(-1), _y(-1), _width(0), _height(0)
{} {}
bool TForm_item::parse_head(TScanner& scanner) bool TForm_item::parse_head(TScanner& scanner)
{ {
_width = scanner.integer(); _width = scanner.integer();
@ -155,6 +166,7 @@ bool TForm_item::parse_head(TScanner& scanner)
return TRUE; return TRUE;
} }
void TForm_item::print_on(ostream& out) const void TForm_item::print_on(ostream& out) const
{ {
out << class_name(); out << class_name();
@ -171,6 +183,7 @@ void TForm_item::print_on(ostream& out) const
out << "END\n" << endl; out << "END\n" << endl;
} }
void TForm_item::print_body(ostream& out) const void TForm_item::print_body(ostream& out) const
{ {
if (_y >= 0) if (_y >= 0)
@ -191,6 +204,7 @@ void TForm_item::print_body(ostream& out) const
} }
} }
bool TForm_item::parse_item(TScanner& scanner) bool TForm_item::parse_item(TScanner& scanner)
{ {
if (scanner.key() == "PR") if (scanner.key() == "PR")
@ -298,7 +312,6 @@ void TForm_item::send_message(const TString& cmd, TForm_item& des) const
val << get(); val << get();
des.set(val); des.set(val);
} else } else
if (cmd == "DISABLE") if (cmd == "DISABLE")
{ {
des.disable(); des.disable();
@ -343,9 +356,9 @@ bool TForm_item::do_message(int num)
const word id = msg.get_int(); // Get destination group const word id = msg.get_int(); // Get destination group
// Send the message to all fields with the given group // Send the message to all fields with the given group
for (int i = 0; i < section()->items(); i++) for (word i = 0; i < section()->fields(); i++)
{ {
TForm_item& des = section()->item(i); TForm_item& des = section()->field(i);
if (des.in_group(id)) if (des.in_group(id))
send_message(cmd, des); send_message(cmd, des);
} }
@ -365,10 +378,12 @@ bool TForm_item::update()
void TForm_item::to_row(TToken_string& row) const void TForm_item::to_row(TToken_string& row) const
{ {
row = class_name(); row = class_name();
row.add(_y);
row.add(_x);
row.add(key()); row.add(key());
} }
void TForm_item::to_mask(TMask& m) const void TForm_item::print_on(TMask& m)
{ {
m.set(F_CLASS, class_name()); m.set(F_CLASS, class_name());
m.set(F_KEY, key()); m.set(F_KEY, key());
@ -377,14 +392,13 @@ void TForm_item::to_mask(TMask& m) const
m.set(F_PROMPT, _prompt); m.set(F_PROMPT, _prompt);
m.set(F_WIDTH, _width); m.set(F_WIDTH, _width);
m.set(F_HEIGHT, _height); m.set(F_HEIGHT, _height);
_flag.to_mask(m); _flag.print_on(m);
TString16 g; for (int g = 1; g <= 12; g++)
g << _group; m.set(F_GROUP+g, _group[g] ? "X" : " ");
m.set(F_GROUP, g);
} }
void TForm_item::from_mask(const TMask& m) void TForm_item::read_from(const TMask& m)
{ {
_desc = m.get(F_KEY); _desc = m.get(F_KEY);
_x = atoi(m.get(F_X)); _x = atoi(m.get(F_X));
@ -392,18 +406,26 @@ void TForm_item::from_mask(const TMask& m)
_prompt = m.get(F_PROMPT); _prompt = m.get(F_PROMPT);
_width = atoi(m.get(F_WIDTH)); _width = atoi(m.get(F_WIDTH));
_height = atoi(m.get(F_HEIGHT)); _height = atoi(m.get(F_HEIGHT));
_flag.from_mask(m); _flag.read_from(m);
_group.reset(); _group.reset();
_group.set(m.get(F_GROUP)); for (int g = 1; g <= 12; g++)
_group.set(g, m.get_bool(F_GROUP+g));
} }
bool TForm_item::edit(TMaskmode mode) bool TForm_item::edit(TMask& m)
{ {
TMask m("bagn003"); m.reset();
to_mask(m);
if (m.insert_mode()) m.enable(F_CLASS);
else print_on(m);
const bool dirty = (m.run() == K_ENTER) && m.dirty(); const bool dirty = (m.run() == K_ENTER) && m.dirty();
if (dirty) from_mask(m);
if (m.insert_mode()) m.disable(F_CLASS);
else if (dirty) read_from(m);
return dirty; return dirty;
} }
@ -421,8 +443,8 @@ protected:
virtual const char* class_name() const { return "STRINGA"; } virtual const char* class_name() const { return "STRINGA"; }
virtual void print_body(ostream& out) const; virtual void print_body(ostream& out) const;
virtual void to_mask(TMask& m) const; virtual void print_on(TMask& m);
virtual void from_mask(const TMask& m); virtual void read_from(const TMask& m);
virtual bool parse_item(TScanner&); virtual bool parse_item(TScanner&);
virtual bool update(); virtual bool update();
@ -468,9 +490,9 @@ void TForm_string::print_body(ostream& out) const
out << " FIELD " << field(i) << endl; out << " FIELD " << field(i) << endl;
} }
void TForm_string::to_mask(TMask& m) const void TForm_string::print_on(TMask& m)
{ {
TForm_item::to_mask(m); TForm_item::print_on(m);
for (int i = 0; i < 2; i++) if (i < _field.items()) for (int i = 0; i < 2; i++) if (i < _field.items())
{ {
TString80 f; TString80 f;
@ -481,9 +503,9 @@ void TForm_string::to_mask(TMask& m) const
m.set(F_PICTURE, _picture); m.set(F_PICTURE, _picture);
} }
void TForm_string::from_mask(const TMask& m) void TForm_string::read_from(const TMask& m)
{ {
TForm_item::from_mask(m); TForm_item::read_from(m);
_picture = m.get(F_PICTURE); _picture = m.get(F_PICTURE);
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
@ -644,6 +666,8 @@ class TForm_list : public TForm_string
protected: protected:
virtual const char* class_name() const { return "LISTA"; } virtual const char* class_name() const { return "LISTA"; }
virtual bool parse_item(TScanner& scanner); virtual bool parse_item(TScanner& scanner);
virtual void print_on(TMask& m);
virtual void read_from(const TMask& m);
virtual void print_body(ostream& out) const; virtual void print_body(ostream& out) const;
virtual bool update(); virtual bool update();
@ -677,6 +701,37 @@ bool TForm_list::parse_item(TScanner& scanner)
return TForm_string::parse_item(scanner); return TForm_string::parse_item(scanner);
} }
void TForm_list::print_on(TMask& m)
{
TForm_string::print_on(m);
TSheet_field& s = (TSheet_field&)m.field(F_ITEMS);
_codes.restart(); _values.restart();
for (int i = 0; i < _codes.items(); i++)
{
TToken_string& row = s.row(i);
row = _codes.get();
row.add(_values.get());
row.add(message(i));
}
s.force_update();
}
void TForm_list::read_from(const TMask& m)
{
TForm_string::read_from(m);
TSheet_field& s = (TSheet_field&)m.field(F_ITEMS);
_codes = _values = "";
for (int i = 0; i < s.items(); i++)
{
TToken_string& row = s.row(i);
_codes.add(row.get(0));
_values.add(row.get());
message(i) = row.get();
}
}
void TForm_list::print_body(ostream& out) const void TForm_list::print_body(ostream& out) const
{ {
@ -713,11 +768,10 @@ bool TForm_list::update()
const int pos = _codes.get_pos(val); const int pos = _codes.get_pos(val);
if (pos < 0) if (pos < 0)
{ {
ok = yesnofatal_box("Il campo '%s' non puo' valere '%s'", ok = error_box("Il campo '%s' non puo' valere '%s'",
(const char*)key(), (const char*)val); (const char*)key(), (const char*)val);
} }
else do_message(pos);
do_message(pos);
if (!hidden()) if (!hidden())
{ {
@ -734,17 +788,9 @@ bool TForm_list::update()
// TPrint_section // TPrint_section
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
void TPrint_section::init(const char* name, TForm* f) TPrint_section::TPrint_section(TForm* f)
{ : _height(0), _form(f)
_name = name; {}
_form = f;
}
TPrint_section::TPrint_section(const char* name, TForm* f)
: _height(0)
{
init(name, f);
}
TPrintrow& TPrint_section::row(int num) TPrintrow& TPrint_section::row(int num)
{ {
@ -757,31 +803,33 @@ TPrintrow& TPrint_section::row(int num)
return *pr; return *pr;
} }
TForm_item* TPrint_section::parse_item(TScanner& scanner)
TForm_item* TPrint_section::parse_item(const TString& s)
{ {
if (scanner.key() == "ST") if (s == "ST")
return new TForm_string(this); return new TForm_string(this);
if (scanner.key() == "NU") if (s == "NU")
return new TForm_number(this); return new TForm_number(this);
if (scanner.key() == "DA") if (s == "DA")
return new TForm_date(this); return new TForm_date(this);
if (scanner.key() == "LI") if (s == "LI")
return new TForm_list(this); return new TForm_list(this);
#ifdef DBG CHECKS(NULL, "Elemento di stampa sconosciuto: ", (const char*)s);
yesnofatal_box("Elemento sconosciuto nella sezione '%s': '%s'",
(const char*)_name, (const char*)scanner.token());
#endif
return NULL; return NULL;
} }
TForm_item* TPrint_section::parse_item(TScanner& scanner)
{
return parse_item(scanner.key());
}
bool TPrint_section::parse(TScanner& scanner) bool TPrint_section::parse(TScanner& scanner)
{ {
_height = scanner.integer(); _height = scanner.integer();
set_cursor(TASK_WIN, CURSOR_WAIT);
while (scanner.popkey() != "EN") while (scanner.popkey() != "EN")
{ {
TForm_item *fi = parse_item(scanner); TForm_item *fi = parse_item(scanner);
@ -792,63 +840,102 @@ bool TPrint_section::parse(TScanner& scanner)
else else
return FALSE; return FALSE;
} }
set_cursor(TASK_WIN, CURSOR_ARROW);
return TRUE; return TRUE;
} }
void TPrint_section::reset()
{
for (word i = 0; i < height(); i++)
row(i).reset();
}
bool TPrint_section::update() bool TPrint_section::update()
{ {
destroy();
const int last = _item.items();
bool ok = TRUE; bool ok = TRUE;
for (int i = 0; i < last; i++)
reset();
for (word i = 0; i < fields(); i++)
{ {
bool esito = ((TForm_item&)_item[i]).update(); const bool esito = field(i).update();
if (!esito) ok = FALSE; if (!esito) ok = FALSE;
} }
i = items();
if (i < _height) row(_height-1); const word l = last()-1;
else if (i > _height) if (l >= _height)
ok = warning_box("Sezione %s troppo lunga: %d > %d", ok = warning_box("Sezione troppo lunga: %d > %d", l, _height);
(const char*)_name, i, _height);
return ok; return ok;
} }
bool TPrint_section::edit(int mode)
bool TPrint_section::edit()
{ {
TString80 title; TMask m("bagn003");
title = "Campi della sezione "; title << _name;
TArray_sheet a(-1, -1, 0, 0, title, "Tipo@8|Descrizione@40", 0x8); TString80 title("Campi della sezione");
for (int i = 0; i < items(); i++) TArray_sheet a(-1, -1, 0, 0, title, "Tipo@8|Riga|Col.|Descrizione@80", 0xE);
for (word i = 0; i < fields(); i++)
{ {
TToken_string s(64); TToken_string* s = new TToken_string(128);
item(i).to_row(s); field(i).to_row(*s);
a.add(s); a.add(s);
} }
bool dirty = FALSE; bool dirty = FALSE;
while (a.run() == K_ENTER) KEY k;
do
{ {
i = (int)a.selected(); k = a.run();
const bool spork = item(i).edit((TMaskmode)mode); i = (word)a.selected();
if (spork)
switch(k)
{
case K_ENTER:
m.set_mode(MODE_MOD);
if (field(i).edit(m))
{ {
dirty = TRUE; dirty = TRUE;
item(i).to_row(a.row(i)); field(i).to_row(a.row(i));
}
break;
case K_INS:
{
m.set_mode(MODE_INS);
TForm_string dummy(this);
if (dummy.edit(m))
{
const TString& c = m.get(F_CLASS).left(2);
TForm_item* item = parse_item(c);
item->read_from(m);
_item.insert(item, i);
TToken_string s(128); item->to_row(s);
a.insert(s, i);
} }
} }
break;
case K_DEL:
if (yesno_box("Confermare la cancellazione"))
{
_item.destroy(i, TRUE);
a.destroy(i);
}
break;
default:
break;
}
} while (k != K_ESC);
return dirty; return dirty;
} }
void TPrint_section::print_on(ostream& out) const void TPrint_section::print_on(ostream& out) const
{ {
out << "\nPAGE " << _name << ' ' << _height << '\n' << endl; out << _height << endl;
for(int i = 0; i < items(); i++) for(word i = 0; i < fields(); i++)
out << item(i); out << field(i);
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -933,33 +1020,89 @@ bool TForm::parse_join(TScanner& scanner)
} }
bool TForm::set_header() TPrint_section& TForm::page2pos(const TArray& s, word p) const
{
pagetype pos = odd_page;
if (p == 0 && s.objptr(last_page)) pos = last_page;
if (p == 1 && s.objptr(first_page)) pos = first_page;
if (pos == 0 && (p & 0x1) == 0 && s.objptr(even_page)) pos = even_page;
return (TPrint_section&)s[pos];
}
word TForm::set_header(word p, bool u)
{ {
TPrinter& printer = main_app().printer(); TPrinter& printer = main_app().printer();
printer.resetheader(); printer.resetheader();
const bool ok = _head.update(); TPrint_section& head = page2pos(_head, p);
const int last = _head.last(); if (u) head.update();
for (int j = 0; j <= last; j++) else head.reset();
printer.setheaderline(j, _head.row(j));
return ok; for (word j = 0; j < head.height(); j++)
printer.setheaderline(j, head.row(j));
return head.height();
} }
word TForm::set_body(word p, bool u)
{
TPrint_section& body = page2pos(_body, p);
bool TForm::set_footer() if (u) body.update();
else body.reset();
if (u)
{
TPrinter& printer = main_app().printer();
for (word j = 0; j < body.height(); j++)
printer.print(body.row(j));
}
return body.height();
}
word TForm::set_footer(word p, bool u)
{ {
TPrinter& printer = main_app().printer(); TPrinter& printer = main_app().printer();
printer.resetfooter(); printer.resetfooter();
const bool ok = _foot.update(); TPrint_section& foot = page2pos(_foot, p);
const int last = _foot.last(); if (u) foot.update();
for (int j = 0; j <= last; j++) else foot.reset();
printer.setfooterline(j, _foot.row(j));
return ok; for (word j = 0; j < foot.height(); j++)
printer.setfooterline(j, foot.row(j));
return foot.height();
}
void TForm::header_handler(TPrinter& p)
{
const word page = form().page(p);
form().set_header(page, TRUE);
form().set_footer(page, FALSE);
}
void TForm::footer_handler(TPrinter& p)
{
const word page = form().page(p);
form().set_footer(page, TRUE);
if (page)
form().set_header(page+1, FALSE);
}
word TForm::page(const TPrinter& p) const
{
return _lastpage ? 0 : p.getcurrentpage();
}
long TForm::records() const
{
const long r = _cursor ? _cursor->items() : 0;
return 0;
} }
// Stampa gli items dal from a to // Stampa gli items dal from a to
@ -967,62 +1110,99 @@ bool TForm::set_footer()
bool TForm::print(long from, long to) bool TForm::print(long from, long to)
{ {
CHECK(form == NULL, "Can't print two forms");
_form = this;
_lastpage = FALSE;
TPrinter& printer = main_app().printer(); TPrinter& printer = main_app().printer();
printer.setheaderhandler(header_handler);
printer.setfooterhandler(footer_handler);
const bool was_open = printer.isopen(); const bool was_open = printer.isopen();
if (!was_open && !printer.open()) if (!was_open && !printer.open())
return FALSE; return FALSE;
if (to < 0) to = _cursor->items()-1; if (to < 0) to = records()-1;
bool ok = set_header() && set_footer(); bool ok = TRUE;
for (long i = from; i <= to && ok; i++) for (long i = from; i <= to && ok; i++)
{ {
if (from < 0) to = from; if (from < 0) to = from;
else *_cursor = i; else if (_cursor) *_cursor = i;
ok &= _body.update(); const word h = set_body(page(printer), FALSE);
if (!ok) ok = yesno_box("Stampo ugualmente"); if (h > printer.rows_left())
if (!ok) break; printer.formfeed();
const word last = _body.last()+1; set_body(page(printer), TRUE);
if (last < printer.rows() && last > printer.rows_left()) }
ok = printer.formfeed();
for (word j = 0; j < last && ok; j++) if (i > records())
ok = printer.print(_body.row(j)); {
if (_head.objptr(last_page) || _body.objptr(last_page) || _foot.objptr(last_page))
{
_lastpage = TRUE;
set_header(0, TRUE);
set_body(0, TRUE);
printer.formfeed();
}
} }
if (!was_open) if (!was_open)
printer.close(); printer.close();
_form = NULL;
return ok; return ok;
} }
void TForm::print_section(ostream& out, const TArray& s, const char* name) const
{
for (pagetype t = odd_page; t <= last_page; t = pagetype(t+1)) if (s.objptr(t))
{
out << "SECTION " << name << ' ' << int(t);
out << s[t];
out << "END\n" << endl;
}
}
void TForm::print_on(ostream& out) const void TForm::print_on(ostream& out) const
{ {
out << *_cursor->relation() << endl; if (relation())
if (_head.items()) out << _head; out << *relation() << endl;
if (_body.items()) out << _body;
if (_foot.items()) out << _foot; print_section(out, _head, "HEADER");
out << "ENDPAGE" << endl; print_section(out, _body, "BODY");
print_section(out, _foot, "FOOTER");
out << "END" << endl;
}
TPrint_section& TForm::section(char s, pagetype t)
{
TArray* a = NULL;
switch (s)
{
case 'H':
a = &_head; break;
case 'F':
a = &_foot; break;
default:
a = &_body; break;
}
TPrint_section* sec = (TPrint_section*)a->objptr(t);
if (sec == NULL) a->add(sec = new TPrint_section(this));
return (TPrint_section&)*sec;
} }
bool TForm::edit(int mode, int section) bool TForm::edit(char s, pagetype t)
{ {
bool dirty = FALSE; bool dirty = FALSE;
switch (section) section(s, t).edit();
{
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?")) if (dirty && yesno_box("Salvare le modifiche?"))
{ {
@ -1038,35 +1218,36 @@ bool TForm::edit(int mode, int section)
} }
TForm::TForm(const char* name)
TForm::TForm(const char* name) : _name(name) : _name(name), _relation(NULL), _cursor(NULL)
{ {
const CURSOR oldcur = get_cursor(TASK_WIN);
set_cursor(TASK_WIN, CURSOR_WAIT);
_name.ext("frm"); _name.ext("frm");
TScanner scanner(_name); TScanner scanner(_name);
bool ok = FALSE; bool ok = TRUE;
if (scanner.popkey() == "US") if (scanner.popkey() == "US")
{
ok = parse_use(scanner); ok = parse_use(scanner);
CHECKS(ok, "Missing USE in form: ", name);
while (ok && scanner.popkey() == "JO") while (ok && scanner.popkey() == "JO")
ok = parse_join(scanner); ok = parse_join(scanner);
}
scanner.push(); scanner.push();
_head.init("HEADER", this); while (scanner.popkey() != "" && ok)
_body.init("BODY", this);
_foot.init("FOOTER", this);
while (scanner.popkey() == "PA")
{ {
scanner.pop(); const char sec = scanner.key()[0];
if (scanner.token() == "HEADER") _head.parse(scanner); else const pagetype p = (pagetype)scanner.integer();
if (scanner.token() == "BODY") _body.parse(scanner); else TPrint_section& ps = section(sec, p);
if (scanner.token() == "FOOTER") _foot.parse(scanner); ok = ps.parse(scanner);
} }
set_cursor(TASK_WIN, oldcur);
} }
TForm::~TForm() TForm::~TForm()
{ {
if (_cursor) if (_cursor)

View File

@ -5,73 +5,92 @@
#include <printer.h> #include <printer.h>
#endif #endif
#ifndef __SCANNER_H
#include <scanner.h>
#endif
#ifndef __RELATION_H #ifndef __RELATION_H
class TRelation; class TRelation;
class TCursor; class TCursor;
#endif #endif
#ifndef __SCANNER_H enum pagetype { odd_page, even_page, first_page, last_page };
#include <scanner.h>
#endif
class TForm; class TForm;
class TForm_item; class TForm_item;
class TPrint_section : public TArray class TPrint_section : public TArray
{ {
TString16 _name; // Nome della sezione di stampa word _height; // Altezza della sezione
int _height; // Altezza della sezione
TForm* _form; // Form cui appartiene alla sezione TForm* _form; // Form cui appartiene alla sezione
TArray _item; // Lista dei campi da stampare TArray _item; // Lista dei campi da stampare
protected: protected:
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
TForm_item* parse_item(const TString& key);
TForm_item* parse_item(TScanner& scanner); TForm_item* parse_item(TScanner& scanner);
public: public:
TPrintrow& row(int num); TPrintrow& row(int num);
TForm* form() const { return _form; } TForm* form() const { return _form; }
TForm_item& item(int n) const { return (TForm_item&)_item[n]; } TForm_item& field(int n) const { return (TForm_item&)_item[n]; }
int items() const { return _item.items(); } word fields() const { return _item.items(); }
word height() const { return _height; }
void reset();
bool update(); bool update();
bool parse(TScanner& scanner); bool parse(TScanner& scanner);
bool edit(int mode); bool edit();
TPrint_section(const char* name = "", TForm* form = NULL); TPrint_section(TForm* parent);
void init(const char* name, TForm* form); virtual ~TPrint_section() {}
}; };
class TForm : public TObject class TForm : public TObject
{ {
TFilename _name; TFilename _name; // Profile name
TRelation* _relation; TRelation* _relation; // Can be NULL
TCursor* _cursor; TCursor* _cursor; // Can be NULL
TPrint_section _head; TArray _head; // Headers
TPrint_section _body; TArray _body; // Bodies
TPrint_section _foot; TArray _foot; // Footers
bool _lastpage;
TPrint_section& page2pos(const TArray& a, word p) const;
static void header_handler(TPrinter& p);
static void footer_handler(TPrinter& p);
protected: protected:
TPrint_section& section(char s, pagetype t); // H = Header, B = Body, F = Footer
void print_section(ostream& out, const TArray& s, const char* name) const;
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
bool parse_use(TScanner&); bool parse_use(TScanner&);
bool parse_join(TScanner&); bool parse_join(TScanner&);
bool set_header(); word page(const TPrinter& p) const;
bool set_footer();
virtual long records() const;
virtual word set_header(word p, bool u);
virtual word set_body(word p, bool u);
virtual word set_footer(word p, bool u);
public: public:
bool print(long from = 0L, long to = -1L); bool print(long from = 0L, long to = -1L);
TRelation* relation() const { return _relation; } TRelation* relation() const { return _relation; }
TCursor* cursor() const { return _cursor; } TCursor* cursor() const { return _cursor; }
bool edit(int mode, int section = 1); bool edit(char section, pagetype t);
TForm(const char* form); TForm(const char* form);
~TForm(); ~TForm();

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.62 1994-12-16 15:49:54 guy Exp $ // $Id: maskfld.cpp,v 1.63 1994-12-20 15:11:11 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -282,8 +282,8 @@ int TMask_field::create_prompt(WINDOW parent, int width, int heigth)
if (width) if (width)
{ {
// Static controls shouldn't be grayed const long flags = default_flags() & (~CTL_FLAG_DISABLED); // Static controls shouldn't be grayed
const long flags = default_flags() & (~CTL_FLAG_DISABLED);
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
char* k = strchr(_prompt, '~'); char* k = strchr(_prompt, '~');
if (k != NULL) *k = '&'; if (k != NULL) *k = '&';
@ -745,6 +745,13 @@ bool TMask_field::on_key(KEY key)
send_key(key, 0); send_key(key, 0);
break; break;
case K_F1: case K_F1:
#if XVT_OS == XVT_OS_WIN
if (fexist("prassi.hlp"))
{
HWND hwnd = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, "prassi.hlp", HELP_KEY, (DWORD)(const char*)mask().source_file());
} else
#endif
if (_help.not_empty()) if (_help.not_empty())
message_box(_help); message_box(_help);
else else

View File

@ -1 +1 @@
#define VERSION 1.2 #define VERSION 1.1

View File

@ -5,14 +5,6 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
#ifndef __STRINGS_H
#include <strings.h>
#endif
#ifndef __ARRAY_H
#include <array.h>
#endif
#ifndef __VISWIN_H #ifndef __VISWIN_H
#include <viswin.h> #include <viswin.h>
#endif #endif
@ -269,7 +261,7 @@ public:
TPrtype printtype() { return _printertype; } TPrtype printtype() { return _printertype; }
void set_printtype(TPrtype dest) { _printertype=dest; } void set_printtype(TPrtype dest) { _printertype=dest; }
void set_printerfile(const char * ffile) { _printerfile=ffile; } void set_printerfile(const char * ffile) { _printerfile=ffile; }
word getcurrentpage() { return _currentpage; } word getcurrentpage() const { return _currentpage; }
void setcurrentpage(word n) { _currentpage = n; } void setcurrentpage(word n) { _currentpage = n; }
// dirige la stampa sul file specificato, preservando gli attributi di formato // dirige la stampa sul file specificato, preservando gli attributi di formato
// se header == TRUE si stampano su file anche gli header // se header == TRUE si stampano su file anche gli header

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.26 1994-12-07 11:10:50 guy Exp $ // $Id: relation.cpp,v 1.27 1994-12-20 15:11:20 guy Exp $
// relation.cpp // relation.cpp
// fv 12/8/93 // fv 12/8/93
// relation class for isam files // relation class for isam files
@ -20,6 +20,7 @@
// *** maximum number of elements in a cursor working page // *** maximum number of elements in a cursor working page
#define CMAXELPAGE 8000 #define CMAXELPAGE 8000
#define print_name(out, f) out << (f.num() == LF_TABCOM ? "%" : "") << f.name()
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TRelationdef // TRelationdef
@ -44,6 +45,7 @@ class TRelationdef : public TObject
protected: protected:
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
void print_on(TToken_string& out) const;
public: public:
// @FPUB // @FPUB
@ -62,20 +64,6 @@ public:
// @END // @END
HIDDEN ostream& print_name(ostream& out, const TLocalisamfile& f)
{
const int logicnum = f.num();
if (logicnum == LF_TABCOM || logicnum == LF_TAB)
{
if (logicnum == LF_TABCOM) out << '%';
out << ((TTable&)f).name();
}
else
out << logicnum;
return out;
}
TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key, TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
int idx_to, const char* relexprs, byte alias, int idx_to, const char* relexprs, byte alias,
bool allow_lock, bool write_enable) bool allow_lock, bool write_enable)
@ -126,14 +114,21 @@ TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
void TRelationdef::print_on(ostream& out) const void TRelationdef::print_on(ostream& out) const
{ {
out << "JOIN "; print_name(out, _rel->file(_num)); const TLocalisamfile& f = _rel->file(_num);
out << "JOIN ";
print_name(out, f);
if (_numto > 0) if (_numto > 0)
{ {
out << " TO "; out << " TO ";
const int alias = _rel->reldef(_numto-1).alias(); const int alias = _rel->reldef(_numto-1).alias();
if (alias > 0) out << alias << '@'; if (alias > 0) out << alias << '@';
else print_name(out, _rel->file(_numto)); else
{
const TLocalisamfile& t = _rel->file(_numto);
print_name(out, t);
}
} }
if (_key > 1) out << " KEY " << (int)_key; if (_key > 1) out << " KEY " << (int)_key;
@ -148,6 +143,35 @@ void TRelationdef::print_on(ostream& out) const
} }
void TRelationdef::print_on(TToken_string& out) const
{
const TLocalisamfile& f = _rel->file(_num);
out = "";
print_name(out, f);
out << '|';
if (_numto > 0)
{
const int alias = _rel->reldef(_numto-1).alias();
if (alias > 0)
out << alias << '@';
else
{
const TLocalisamfile& t = _rel->file(_numto);
print_name(out, t);
}
}
out.add(_key);
out.add(_alias);
out << '|';
for (int i = 0; i < _fields.items(); i++)
{
if (i) out << ' ';
out << _fields[i] << '=' << _exprs[i];
}
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TRelation // TRelation
@ -184,6 +208,22 @@ void TRelation::print_on(ostream& out) const
out << _reldefs[r] << endl; out << _reldefs[r] << endl;
} }
void TRelation::print_on(TArray& a) const
{
const TLocalisamfile& f = file();
TToken_string s(128);
print_name(s, f);
s.add(f.getkey());
a.destroy();
a.add(s, 0);
for (int i = 0; i < _reldefs.items(); i++)
{
((TRelationdef&)_reldefs[i]).print_on(s);
a.add(s, i+1);
}
}
void TRelation::restore_status() void TRelation::restore_status()
{ {
_status.restart(); _status.restart();

View File

@ -1,4 +1,4 @@
/* $Id: relation.h,v 1.8 1994-10-20 13:32:24 guy Exp $ */ /* $Id: relation.h,v 1.9 1994-12-20 15:11:23 guy Exp $ */
// join.h // join.h
// fv 12/8/93 // fv 12/8/93
// join class for isam files // join class for isam files
@ -6,10 +6,6 @@
#ifndef __RELATION_H #ifndef __RELATION_H
#define __RELATION_H #define __RELATION_H
#ifndef __ARRAY_H
#include <array.h>
#endif
#ifndef __ISAM_H #ifndef __ISAM_H
#include <isam.h> #include <isam.h>
#endif #endif
@ -133,6 +129,8 @@ public:
TRecnotype operator ++() { return next(); } TRecnotype operator ++() { return next(); }
TRecnotype operator --() { return prev(); } TRecnotype operator --() { return prev(); }
void print_on(TArray& a) const; // Mette la descrizione in un array di TToken_string
TRelation(int logicnum, bool linkrecinst = TRUE); TRelation(int logicnum, bool linkrecinst = TRUE);
TRelation(const char* tabname, bool linkrecinst = FALSE); TRelation(const char* tabname, bool linkrecinst = FALSE);
virtual ~TRelation(); virtual ~TRelation();

View File

@ -7,9 +7,7 @@
int TTable::name2log(const char* n) int TTable::name2log(const char* n)
{ {
return *n == '%' ? LF_TABCOM : return *n == '%' ? LF_TABCOM : (*n == '#' ? LF_TABGEN : LF_TAB);
*n == '#' ? LF_TABGEN :
LF_TAB;
} }

View File

@ -2,6 +2,10 @@
#ifndef __TEXTFILE_H #ifndef __TEXTFILE_H
#define __TEXTFILE_H #define __TEXTFILE_H
#ifndef __STDIO_H
#include <stdio.h>
#endif
#ifndef __ARRAY_H #ifndef __ARRAY_H
#include <array.h> #include <array.h>
#endif #endif
@ -10,10 +14,6 @@
#include <strings.h> #include <strings.h>
#endif #endif
#ifndef __STDIO_H
#include <stdio.h>
#endif
#ifndef __WINDOW_H #ifndef __WINDOW_H
#include <window.h> #include <window.h>
#endif #endif

View File

@ -81,9 +81,8 @@ const char* cmd2name(const char* argv0, const char* argv1)
app.lower(); app.lower();
const int par = app.find(" -"); const int par = app.find(" -");
CHECKS(par > 0, "Bad command line: ", (const char*)app); const int num = par > 0 ? atoi(app.mid(par+2))+1 : 1;
const int num = atoi(app.mid(par+2)) + 1;
const char c = (num > 9) ? ('a'+num-10) : ('0'+num); const char c = (num > 9) ? ('a'+num-10) : ('0'+num);
app.cut(3); app.cut(3);
app << c << "00"; app << c << "00";