1994-11-10 14:17:03 +00:00
|
|
|
|
#include <ctype.h>
|
1995-08-31 15:16:13 +00:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
|
#define STRICT
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#endif
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <form.h>
|
1994-12-27 14:59:25 +00:00
|
|
|
|
#include <msksheet.h>
|
1995-04-20 14:35:14 +00:00
|
|
|
|
#include <printer.h>
|
1994-11-10 14:17:03 +00:00
|
|
|
|
#include <relation.h>
|
|
|
|
|
#include <sheet.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
#include "../ba/bafrm.h"
|
|
|
|
|
|
|
|
|
|
// per lo sheet di edit campi
|
|
|
|
|
HIDDEN const int idt_id = 101;
|
|
|
|
|
HIDDEN const int dsc_id = 102;
|
|
|
|
|
HIDDEN const int int_id = 103;
|
|
|
|
|
HIDDEN const int prn_id = 104;
|
|
|
|
|
HIDDEN const int yps_id = 105;
|
|
|
|
|
HIDDEN const int len_id = 106;
|
|
|
|
|
HIDDEN const int xps_id = 107;
|
|
|
|
|
HIDDEN const int col_id = 108;
|
|
|
|
|
HIDDEN const int spc_id = 109;
|
|
|
|
|
HIDDEN const int fnl_id = 110;
|
|
|
|
|
HIDDEN const int fnr_id = 111;
|
|
|
|
|
HIDDEN const int typ_id = 112;
|
|
|
|
|
HIDDEN const int frm_id = 113;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Utility functions
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// Current form (edit, print)
|
1995-12-14 10:45:17 +00:00
|
|
|
|
HIDDEN TForm* _cur_form = NULL;
|
|
|
|
|
HIDDEN TPrint_section* _cur_sect = NULL;
|
|
|
|
|
HIDDEN TMask* _special_mask = NULL;
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
HIDDEN TForm& form()
|
1994-12-20 15:11:26 +00:00
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
CHECK(_cur_form, "Can't print NULL form");
|
|
|
|
|
return *_cur_form;
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
HIDDEN TPrint_section& section()
|
|
|
|
|
{
|
|
|
|
|
CHECK(_cur_sect, "Can't print NULL section");
|
|
|
|
|
return *_cur_sect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN TMask& special_mask()
|
|
|
|
|
{
|
|
|
|
|
CHECK(_special_mask, "Can't access NULL mask");
|
|
|
|
|
return *_special_mask;
|
|
|
|
|
}
|
|
|
|
|
|
1995-08-07 08:45:33 +00:00
|
|
|
|
// Translate char to pagetype (visible outside here, no more HIDDEN)
|
|
|
|
|
pagetype char2page(char c)
|
1995-05-18 14:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
pagetype pt;
|
|
|
|
|
switch(c)
|
|
|
|
|
{
|
|
|
|
|
case '1':
|
|
|
|
|
case 'E':
|
|
|
|
|
pt = even_page; break;
|
|
|
|
|
case '2':
|
|
|
|
|
case 'F':
|
|
|
|
|
pt = first_page; break;
|
|
|
|
|
case '3':
|
|
|
|
|
case 'L':
|
|
|
|
|
pt = last_page; break;
|
|
|
|
|
default:
|
|
|
|
|
pt = odd_page; break;
|
|
|
|
|
}
|
|
|
|
|
return pt;
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Gestione TFieldref su maschera
|
|
|
|
|
// ID CAMPO ATTIVO
|
|
|
|
|
// xx0 Stringa completa del TFieldref
|
|
|
|
|
// xx1 Descrizione file
|
|
|
|
|
// xx2 Bottone selezione file X
|
|
|
|
|
// xx3 Descrizione campo
|
|
|
|
|
// xx4 Bottone selezione campo X
|
|
|
|
|
// xx5 Primo carattere campo X
|
|
|
|
|
// xx6 Ultimo carattere campo X
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
HIDDEN void put_fieldref(const TFieldref& fr, TMask_field& f)
|
|
|
|
|
{
|
|
|
|
|
TRelation_description& rd = form().rel_desc();
|
1995-05-30 16:01:38 +00:00
|
|
|
|
rd.set_cur_file(fr.file());
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
|
|
|
|
TString80 desc; desc << fr;
|
|
|
|
|
f.set(desc);
|
|
|
|
|
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
const short id = f.dlg(); // Campo contenente il TFieldref
|
1995-05-30 16:01:38 +00:00
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
m.set(id+1, rd.file_desc());
|
|
|
|
|
m.set(id+3, rd.get_field_description(fr.name()));
|
|
|
|
|
m.set(id+5, (fr.from() > 0 || fr.to() > 0) ? fr.from()+1 : 0);
|
|
|
|
|
m.set(id+6, fr.to() > fr.from() ? fr.to() : 0);
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
|
|
|
|
|
// Handler of F_BUT_FILE field on mask
|
|
|
|
|
HIDDEN bool but_file_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TRelation_description& r = form().rel_desc();
|
|
|
|
|
|
|
|
|
|
TEdit_field& e = f.mask().efield(f.dlg()-2);
|
|
|
|
|
TFieldref ref; ref = e.get();
|
|
|
|
|
if (r.choose_file(ref.file()))
|
|
|
|
|
{
|
|
|
|
|
ref.set_file(r.file_num());
|
|
|
|
|
put_fieldref(ref, e);
|
|
|
|
|
}
|
1995-05-18 14:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-06-07 10:47:05 +00:00
|
|
|
|
HIDDEN bool but_file_handler_sub(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
TRelation_description& r = form().rel_desc();
|
|
|
|
|
|
|
|
|
|
TEdit_field& e = f.mask().efield(f.dlg()-2);
|
|
|
|
|
TFieldref ref; ref = e.get();
|
|
|
|
|
if (r.choose_file(ref.file()))
|
|
|
|
|
{
|
|
|
|
|
ref.set_file(r.file_num());
|
|
|
|
|
f.mask().set(F_FILE1,r.file_desc());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
// Handler of F_BUT_FIELD field on mask
|
|
|
|
|
HIDDEN bool but_field_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TRelation_description& r = form().rel_desc();
|
|
|
|
|
TEdit_field& e = f.mask().efield(f.dlg()-4);
|
|
|
|
|
TFieldref ref; ref = e.get();
|
|
|
|
|
if (r.choose_field(ref.name()))
|
|
|
|
|
{
|
|
|
|
|
ref.set_name(r.field_name());
|
|
|
|
|
put_fieldref(ref, e);
|
|
|
|
|
}
|
1995-05-18 14:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
// Handler of F_FROM field on mask
|
|
|
|
|
HIDDEN bool from_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (f.to_check(k))
|
|
|
|
|
{
|
|
|
|
|
TEdit_field& e = f.mask().efield(f.dlg()-5);
|
|
|
|
|
TFieldref ref; ref = e.get();
|
|
|
|
|
ref.set_from(atoi(f.get()));
|
|
|
|
|
put_fieldref(ref, e);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handler of F_TO field on mask
|
|
|
|
|
HIDDEN bool to_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (f.to_check(k))
|
|
|
|
|
{
|
|
|
|
|
TEdit_field& e = f.mask().efield(f.dlg()-6);
|
|
|
|
|
TFieldref ref; ref = e.get();
|
|
|
|
|
ref.set_to(atoi(f.get()));
|
|
|
|
|
put_fieldref(ref, e);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HIDDEN bool dateformat_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
|
|
|
|
char fmt[8];
|
|
|
|
|
fmt[0] = m.get(F_DFORMAT)[0];
|
|
|
|
|
fmt[1] = m.get(F_DDAY)[0];
|
|
|
|
|
fmt[2] = m.get(F_DMONTH)[0];
|
|
|
|
|
fmt[3] = m.get(F_DYEAR)[0];
|
|
|
|
|
fmt[4] = m.get(F_DSEP)[0];
|
|
|
|
|
fmt[5] = '\0';
|
|
|
|
|
|
|
|
|
|
const TFormatted_date ex(TODAY, 0, 0, fmt);
|
|
|
|
|
m.set(F_DEXAMPLE, ex.string());
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_flags
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
TForm_flags::TForm_flags()
|
|
|
|
|
{
|
1995-12-14 10:45:17 +00:00
|
|
|
|
automagic = dirty = finkr = finkl = FALSE;
|
|
|
|
|
shown = enabled = TRUE;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
// Read from string
|
|
|
|
|
// Certified 100%
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_flags::update(const char* s)
|
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
|
CHECK(s, "NULL flags string");
|
1994-11-10 14:17:03 +00:00
|
|
|
|
for (; *s; s++) switch(toupper(*s))
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
case 'A':
|
|
|
|
|
automagic = TRUE; break;
|
|
|
|
|
case 'D':
|
|
|
|
|
enabled = FALSE; break;
|
|
|
|
|
case 'H':
|
|
|
|
|
shown = FALSE; break;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
case 'F':
|
|
|
|
|
finkl = TRUE; break;
|
|
|
|
|
case 'K':
|
|
|
|
|
finkr = TRUE; break;
|
|
|
|
|
default :
|
1994-12-15 18:06:43 +00:00
|
|
|
|
error_box("Unknown form item flag '%c'", *s); break;
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
// Print on stream
|
|
|
|
|
// Certified 100%
|
1994-11-10 14:17:03 +00:00
|
|
|
|
void TForm_flags::print_on(ostream& out) const
|
|
|
|
|
{
|
1994-12-07 18:03:51 +00:00
|
|
|
|
TString16 s;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
if (automagic) s << "A";
|
1994-12-15 18:06:43 +00:00
|
|
|
|
if (!enabled) s << "D";
|
|
|
|
|
if (!shown) s << "H";
|
1995-12-14 10:45:17 +00:00
|
|
|
|
if (finkl) s << "F";
|
|
|
|
|
if (finkr) s << "K";
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
if (s.not_empty())
|
|
|
|
|
out << " FLAGS \"" << s << '"' << endl;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
// Set mask fields
|
|
|
|
|
// Certified 100%
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm_flags::print_on(TMask& m)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
|
m.set(F_DISABLED, enabled ? " " : "X");
|
|
|
|
|
m.set(F_HIDDEN, shown ? " " : "X");
|
1994-11-10 14:17:03 +00:00
|
|
|
|
m.set(F_AUTOMAGIC, automagic ? "X" : " ");
|
1995-12-14 10:45:17 +00:00
|
|
|
|
m.set(F_FINKL, finkl ? " " : "X");
|
|
|
|
|
m.set(F_FINKR, finkr ? " " : "X");
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
// Get mask fields
|
|
|
|
|
// Certified 100%
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm_flags::read_from(const TMask& m)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
|
shown = !m.get_bool(F_HIDDEN);
|
|
|
|
|
enabled = !m.get_bool(F_DISABLED);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
automagic = m.get_bool(F_AUTOMAGIC);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
finkl = !m.get_bool(F_FINKL);
|
1995-12-15 11:35:47 +00:00
|
|
|
|
finkr = !m.get_bool(F_FINKR);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_item
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TForm_item::TForm_item(TPrint_section* section)
|
1995-12-14 10:45:17 +00:00
|
|
|
|
: _section(section), _x(-1), _y(-1), _width(0), _height(0), _id(0), _ofs(0)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_item::parse_head(TScanner& scanner)
|
1995-05-18 14:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
_id = scanner.integer();
|
|
|
|
|
|
|
|
|
|
if (_id == 0) // Temporary
|
|
|
|
|
_id = _section->fields()+1;
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
_width = scanner.integer();
|
1995-05-18 14:18:01 +00:00
|
|
|
|
if (_width > 0)
|
|
|
|
|
_height = scanner.integer();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
void TForm_item::print_on(ostream& out) const
|
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
out << class_name() << ' ' << id();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (_width > 0)
|
|
|
|
|
{
|
|
|
|
|
out << ' ' << _width;
|
1994-12-15 18:06:43 +00:00
|
|
|
|
if (_height > 0)
|
|
|
|
|
out << ' ' << _height;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
out << "\nBEGIN\n";
|
|
|
|
|
|
|
|
|
|
print_body(out);
|
|
|
|
|
|
|
|
|
|
out << "END\n" << endl;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
void TForm_item::print_body(ostream& out) const
|
|
|
|
|
{
|
1995-01-02 09:33:00 +00:00
|
|
|
|
out << " KEY \"" << _desc << "\"\n";
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (_y >= 0)
|
|
|
|
|
out << " PROMPT " << _x << ' ' << _y << " \"" << _prompt << "\"\n";
|
|
|
|
|
|
|
|
|
|
if (_group.ones())
|
|
|
|
|
out << " GROUP " << _group << "\n";
|
|
|
|
|
|
|
|
|
|
out << _flag;
|
1995-02-09 14:47:31 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (_message.items() == 1)
|
1995-04-26 08:06:43 +00:00
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
const TToken_string& m = _message.row(0);
|
1995-04-26 08:06:43 +00:00
|
|
|
|
if (!m.empty_items())
|
|
|
|
|
out << " MESSAGE " << m << endl;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_special.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
TAssoc_array& aa = specials();
|
|
|
|
|
aa.restart();
|
|
|
|
|
|
|
|
|
|
THash_object* op;
|
|
|
|
|
|
|
|
|
|
while ((op = aa.get_hashobj()) != NULL)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& t = (TToken_string&)op->obj();
|
|
|
|
|
TString typ(t.get(0));
|
|
|
|
|
TString val(t.get(1));
|
|
|
|
|
TString des(t.get(2));
|
|
|
|
|
out << " SPECIAL " << typ << " " << op->key()
|
|
|
|
|
<< " \"" << val << "\" \"" << des << "\"\n";
|
|
|
|
|
}
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_item::parse_item(TScanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
if (scanner.key() == "PR")
|
|
|
|
|
{
|
|
|
|
|
_x = scanner.integer();
|
|
|
|
|
_y = scanner.integer();
|
|
|
|
|
_prompt = scanner.string();
|
|
|
|
|
return TRUE;
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (scanner.key() == "FL")
|
|
|
|
|
return _flag.update(scanner.string());
|
|
|
|
|
|
|
|
|
|
if (scanner.key() == "ME")
|
|
|
|
|
{
|
1994-12-07 18:03:51 +00:00
|
|
|
|
TFixed_string m(scanner.line());
|
1995-11-03 08:23:59 +00:00
|
|
|
|
m.strip_spaces();
|
1995-12-14 10:45:17 +00:00
|
|
|
|
int n = 0;
|
1995-11-03 08:23:59 +00:00
|
|
|
|
if (m.left(5) == "EMPTY")
|
|
|
|
|
{
|
1995-12-14 10:45:17 +00:00
|
|
|
|
n = 1;
|
1995-11-03 08:23:59 +00:00
|
|
|
|
m.ltrim(5);
|
|
|
|
|
}
|
1995-04-26 08:06:43 +00:00
|
|
|
|
if (!m.blank())
|
1995-11-03 08:23:59 +00:00
|
|
|
|
message(n).add(m);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1995-02-09 14:47:31 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (scanner.key() == "KE")
|
1995-05-30 16:01:38 +00:00
|
|
|
|
{
|
1994-11-10 14:17:03 +00:00
|
|
|
|
_desc = scanner.string();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scanner.key() == "GR")
|
|
|
|
|
{
|
|
|
|
|
_group.set(scanner.line());
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1995-12-14 10:45:17 +00:00
|
|
|
|
|
|
|
|
|
if (scanner.key() == "SP")
|
|
|
|
|
{
|
|
|
|
|
TToken_string val(scanner.pop());
|
|
|
|
|
TString16 var = scanner.pop();
|
|
|
|
|
val.add(scanner.string());
|
|
|
|
|
val.add(scanner.string());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
_special.add(var,val);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-15 18:06:43 +00:00
|
|
|
|
yesnofatal_box("Unknown symbol in item '%s': '%s'",
|
|
|
|
|
(const char*)key(), (const char*)scanner.token());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm_item::parse(TScanner& scanner)
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
bool ok = parse_head(scanner);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
if (ok && scanner.popkey() != "BE")
|
1994-12-15 18:06:43 +00:00
|
|
|
|
ok = yesnofatal_box("Missing BEGIN in form item %s", (const char*)key());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
while (ok && scanner.popkey() != "EN")
|
1995-12-14 10:45:17 +00:00
|
|
|
|
ok = parse_item(scanner);
|
|
|
|
|
|
|
|
|
|
if (section().columnwise())
|
|
|
|
|
{
|
|
|
|
|
// look for compulsory SPECIALs and fick them in its cul if absent
|
|
|
|
|
if (!_special.is_key("XHEAD"))
|
|
|
|
|
_special.add("XHEAD",new TToken_string("NUMERO|0|Spostamento orizzontale intestazione in colonna/2/0"));
|
|
|
|
|
if (!_special.is_key("YHEAD"))
|
|
|
|
|
_special.add("YHEAD",new TToken_string("NUMERO|-1|Spostamento verticale intestazione in testata /2/0"));
|
|
|
|
|
if (!_special.is_key("DHEAD"))
|
|
|
|
|
{
|
|
|
|
|
TToken_string* tt = new TToken_string(128);
|
|
|
|
|
TString k(key());
|
|
|
|
|
tt->add("STRINGA");
|
|
|
|
|
tt->add(k);
|
|
|
|
|
tt->add("Intestazione colonna corrispondente/40");
|
1995-12-14 11:55:44 +00:00
|
|
|
|
_special.add("DHEAD",tt);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
bool TForm_item::read_from(const TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM");
|
|
|
|
|
bool changed = FALSE;
|
|
|
|
|
|
|
|
|
|
int i = prof.get_int("X");
|
|
|
|
|
if (_x != i)
|
|
|
|
|
{
|
|
|
|
|
_x = i;
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
i = prof.get_int("Y");
|
|
|
|
|
if (_y != i)
|
|
|
|
|
{
|
|
|
|
|
_y = i;
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
i = prof.get_int("LEN");
|
|
|
|
|
if (_width != i)
|
|
|
|
|
{
|
|
|
|
|
_width = i;
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
i = prof.get_int("HGT");
|
|
|
|
|
if (_height != i)
|
|
|
|
|
{
|
|
|
|
|
_height = i;
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool s = prof.get_bool("ATTIVO");
|
|
|
|
|
if (_flag.shown != s)
|
|
|
|
|
{
|
|
|
|
|
_flag.shown = s;
|
|
|
|
|
changed = TRUE;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TToken_string special(prof.get("SPECIAL"),'\n');
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
for (i = 0; i < special.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string sp(special.get(i), '$');
|
|
|
|
|
TString key(sp.get(0));
|
|
|
|
|
TString val(sp.get(1));
|
|
|
|
|
|
|
|
|
|
if (!_special.is_key(key))
|
|
|
|
|
{
|
|
|
|
|
error_box("Variabile speciale non presente nel profilo: %s",
|
|
|
|
|
(const char*)key);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TToken_string& tt = (TToken_string&)_special[key];
|
|
|
|
|
tt.add(val,1);
|
|
|
|
|
// forza riscrittura su memo
|
|
|
|
|
if (tt.items() == 3) tt.add("X");
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_item::print_on(TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM");
|
|
|
|
|
prof.put("ID", id());
|
|
|
|
|
prof.put("X", _x);
|
|
|
|
|
prof.put("Y", _y);
|
|
|
|
|
prof.put("LEN", width());
|
|
|
|
|
prof.put("HGT", height());
|
1995-12-14 10:45:17 +00:00
|
|
|
|
prof.put("ATTIVO", shown() ? "X" : " ");
|
|
|
|
|
|
|
|
|
|
// specials: se e' stato cambiato, la tokenstring del valore contiene
|
|
|
|
|
// una X alla fine (campo 3)
|
|
|
|
|
if (_special.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
TToken_string special(128,'\n');
|
|
|
|
|
_special.restart();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < _special.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
THash_object* o = _special.get_hashobj();
|
|
|
|
|
|
|
|
|
|
TString key(o->key());
|
|
|
|
|
TToken_string& tt = (TToken_string&)o->obj();
|
|
|
|
|
|
|
|
|
|
if (tt.items() == 4)
|
|
|
|
|
{
|
|
|
|
|
TToken_string sp(key,'$');
|
|
|
|
|
TString val(tt.get(1));
|
|
|
|
|
sp.add(val);
|
|
|
|
|
special.add(sp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
prof.put("SPECIAL", special);
|
|
|
|
|
}
|
1995-05-29 10:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
void TForm_item::enable(bool on)
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
_flag.enabled = on;
|
|
|
|
|
show(on);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_item::string_at(int x, int y, const char* s)
|
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (shown())
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
section().offset(x, y);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
if (section().columnwise()) x += _ofs;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TPrintrow& row = section().row(y-1); // Seleziona riga di stampa
|
|
|
|
|
|
|
|
|
|
if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario
|
|
|
|
|
{
|
|
|
|
|
strncpy(__tmp_string, s, width());
|
|
|
|
|
__tmp_string[_width] = '\0';
|
|
|
|
|
s = __tmp_string;
|
|
|
|
|
}
|
|
|
|
|
row.put(s, x-1); // Stampa testo
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TToken_string& TForm_item::message(int m)
|
|
|
|
|
{
|
|
|
|
|
TToken_string* t = (TToken_string*)_message.objptr(m);
|
|
|
|
|
if (t == NULL)
|
|
|
|
|
{
|
|
|
|
|
t = new TToken_string(16);
|
|
|
|
|
_message.add(t, m);
|
|
|
|
|
}
|
|
|
|
|
return *t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-12-15 18:06:43 +00:00
|
|
|
|
void TForm_item::send_message(const TString& cmd, TForm_item& des) const
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (cmd == "ADD" || cmd == "INC")
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-01-09 16:51:21 +00:00
|
|
|
|
const real n((cmd[0] == 'I') ? "1.0" : get());
|
1994-12-15 18:06:43 +00:00
|
|
|
|
real r(des.get());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
r += n;
|
1994-12-15 18:06:43 +00:00
|
|
|
|
des.set(r.string());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
|
|
|
|
if (cmd == "COPY")
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
des.set(get());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
|
|
|
|
if (cmd == "APPEND")
|
|
|
|
|
{
|
1995-02-09 14:47:31 +00:00
|
|
|
|
TString256 val = des.get();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (val.not_empty()) val << ' ';
|
|
|
|
|
val << get();
|
1994-12-15 18:06:43 +00:00
|
|
|
|
des.set(val);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
|
|
|
|
if (cmd == "DISABLE")
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
des.disable();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
|
|
|
|
if (cmd == "ENABLE")
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
des.enable();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
|
|
|
|
if (cmd == "HIDE")
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
des.hide();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
1995-02-09 14:47:31 +00:00
|
|
|
|
if (cmd == "RESET")
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-02-09 14:47:31 +00:00
|
|
|
|
des.set("");
|
|
|
|
|
} else
|
|
|
|
|
if (cmd == "SHOW")
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-02-09 14:47:31 +00:00
|
|
|
|
des.show();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
|
|
|
|
if (cmd[0] == '"')
|
|
|
|
|
{
|
1995-02-09 14:47:31 +00:00
|
|
|
|
TString256 val(cmd);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
val.strip("\"");
|
1994-12-15 18:06:43 +00:00
|
|
|
|
des.set(val);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
} else
|
|
|
|
|
error_box("Unknown message in item '%s': '%s'",
|
|
|
|
|
(const char*)key(), (const char*)cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-07-19 09:57:25 +00:00
|
|
|
|
TForm_item& TForm_item::find_field(const TString& id) const
|
|
|
|
|
{
|
|
|
|
|
if (isdigit(id[0])) // Field in the same section
|
|
|
|
|
{
|
|
|
|
|
TForm_item& des = section().find_field(atoi(id));
|
|
|
|
|
return des;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const pagetype pt = (id[1] == '-') ? section().page_type() : char2page(id[1]);
|
|
|
|
|
const int freccia = id.find("->");
|
|
|
|
|
CHECKS(freccia > 0, "Non trovo la freccia nel campo ", (const char*)id);
|
|
|
|
|
TForm_item& des = form().find_field(id[0], pt, atoi(id.mid(freccia+2)));
|
|
|
|
|
return des;
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_item::do_message(int num)
|
|
|
|
|
{
|
1994-12-15 18:06:43 +00:00
|
|
|
|
TToken_string& messaggio = message(num);
|
1995-04-26 08:06:43 +00:00
|
|
|
|
if (messaggio.empty_items()) return FALSE;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
TToken_string msg(16, ',');
|
1994-12-15 18:06:43 +00:00
|
|
|
|
for (const char* m = messaggio.get(0); m; m = messaggio.get())
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
msg = m;
|
1995-02-09 14:47:31 +00:00
|
|
|
|
if (*m == '_')
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-07-19 09:57:25 +00:00
|
|
|
|
form().validate(*this, msg);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
1995-02-09 14:47:31 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const TString16 cmd(msg.get()); // Get command
|
1995-05-18 14:18:01 +00:00
|
|
|
|
const TString16 id = msg.get(); // Get destination
|
1995-02-09 14:47:31 +00:00
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
if (id.right(1) == "@")
|
|
|
|
|
{
|
|
|
|
|
const word group = atoi(id);
|
|
|
|
|
// Send the message to all fields with the given group
|
|
|
|
|
for (word i = 0; i < section().fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& des = section().field(i);
|
|
|
|
|
if (des.in_group(group))
|
|
|
|
|
send_message(cmd, des);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
1995-07-19 09:57:25 +00:00
|
|
|
|
{
|
|
|
|
|
TForm_item& des = find_field(id);
|
|
|
|
|
send_message(cmd, des);
|
1995-02-09 14:47:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TForm_item::update()
|
1995-06-02 13:09:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (_prompt.right(1) == "#")
|
|
|
|
|
{
|
|
|
|
|
TString prompt(_prompt);
|
|
|
|
|
for (int i = prompt.len()-2; i >= 0; i--)
|
|
|
|
|
if (prompt[i] != '#') break;
|
|
|
|
|
prompt.cut(i+1);
|
|
|
|
|
string_at(_x, _y, prompt);
|
|
|
|
|
}
|
|
|
|
|
else string_at(_x, _y, _prompt);
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_item::print_on(TToken_string& row) const
|
1995-06-05 08:58:11 +00:00
|
|
|
|
{
|
1995-07-19 09:57:25 +00:00
|
|
|
|
row.cut(0);
|
1995-05-18 14:18:01 +00:00
|
|
|
|
row.add(id());
|
1995-10-16 17:52:24 +00:00
|
|
|
|
row.add(key());
|
1994-12-20 15:11:26 +00:00
|
|
|
|
row.add(_y);
|
|
|
|
|
row.add(_x);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
row.add(shown() ? " " : "X");
|
1994-12-27 14:59:25 +00:00
|
|
|
|
|
1995-07-19 09:57:25 +00:00
|
|
|
|
if (form().edit_level() > 1)
|
|
|
|
|
{
|
|
|
|
|
const long fu = _group.first_one();
|
|
|
|
|
if (fu > 0) row.add(fu);
|
|
|
|
|
else row.add(" ");
|
|
|
|
|
}
|
1995-12-14 10:45:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_item::print_on_sheet_row(TToken_string& tt) const
|
|
|
|
|
{
|
|
|
|
|
TString tmp(80);
|
|
|
|
|
tt.add(_id, idt_id - 101);
|
|
|
|
|
tt.add(_desc, _section->columnwise() ? int_id - 101 : dsc_id - 101);
|
|
|
|
|
tt.add(_x, _section->columnwise() ? col_id - 101 : xps_id - 101);
|
|
|
|
|
tt.add(_y, _section->columnwise() ? len_id - 101 : yps_id - 101);
|
|
|
|
|
tt.add(class_name(), typ_id - 101);
|
|
|
|
|
tt.add(shown() ? "X" : " ", prn_id - 101);
|
|
|
|
|
tmp = example(); tt.add(tmp, frm_id - 101);
|
|
|
|
|
|
|
|
|
|
if (_section->columnwise())
|
|
|
|
|
{
|
|
|
|
|
tt.add(_ofs, spc_id -101);
|
|
|
|
|
tt.add(finkl() ? "" : "X", fnl_id -101);
|
|
|
|
|
tt.add(finkr() ? "" : "X", fnr_id -101);
|
|
|
|
|
}
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm_item::print_on(TMask& m)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
m.set(F_CLASS, class_name());
|
1995-05-18 14:18:01 +00:00
|
|
|
|
m.set(F_ID, id());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
m.set(F_KEY, key());
|
|
|
|
|
m.set(F_X, _x);
|
|
|
|
|
m.set(F_Y, _y);
|
|
|
|
|
m.set(F_PROMPT, _prompt);
|
|
|
|
|
m.set(F_WIDTH, _width);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
m.set(F_HEIGHT, _height);
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
_flag.print_on(m);
|
|
|
|
|
|
1995-02-09 14:47:31 +00:00
|
|
|
|
for (int g = 1; g <= 24; g++)
|
1994-12-20 15:11:26 +00:00
|
|
|
|
m.set(F_GROUP+g, _group[g] ? "X" : " ");
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm_item::read_from(const TMask& m)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
_desc = m.get(F_KEY);
|
|
|
|
|
_x = atoi(m.get(F_X));
|
|
|
|
|
_y = atoi(m.get(F_Y));
|
|
|
|
|
_prompt = m.get(F_PROMPT);
|
|
|
|
|
_width = atoi(m.get(F_WIDTH));
|
1994-12-15 18:06:43 +00:00
|
|
|
|
_height = atoi(m.get(F_HEIGHT));
|
1995-06-05 08:58:11 +00:00
|
|
|
|
_id = atoi(m.get(F_ID));
|
1995-12-14 10:45:17 +00:00
|
|
|
|
_ofs = atoi(m.get(F_SPACES));
|
1995-05-18 14:18:01 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
_flag.read_from(m);
|
|
|
|
|
|
1994-12-15 18:06:43 +00:00
|
|
|
|
_group.reset();
|
1995-02-09 14:47:31 +00:00
|
|
|
|
for (int g = 1; g <= 24; g++)
|
1994-12-20 15:11:26 +00:00
|
|
|
|
_group.set(g, m.get_bool(F_GROUP+g));
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_item::read_from(TToken_string& s)
|
|
|
|
|
{
|
|
|
|
|
_id = s.get_int(idt_id - 101);
|
|
|
|
|
_desc = _section->columnwise() ? s.get(int_id - 101) : s.get(dsc_id - 101);
|
|
|
|
|
_x = _section->columnwise() ? s.get_int(col_id - 101) : s.get_int(xps_id - 101);
|
|
|
|
|
_y = _section->columnwise() ? s.get_int(len_id - 101) : s.get_int(yps_id - 101);
|
|
|
|
|
_ofs = s.get_int(spc_id - 101);
|
|
|
|
|
_flag.set_enabled(s.get(prn_id - 101) != "X");
|
|
|
|
|
|
|
|
|
|
if (_section->columnwise())
|
|
|
|
|
{
|
|
|
|
|
_flag.set_finkl(s.get(fnl_id - 101) != "X");
|
|
|
|
|
_flag.set_finkr(s.get(fnr_id - 101) != "X");
|
|
|
|
|
}
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
bool TForm_item::edit(TMask& m)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
m.enable(F_CLASS, m.insert_mode());
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
m.reset();
|
1995-06-05 08:58:11 +00:00
|
|
|
|
|
|
|
|
|
if (m.insert_mode())
|
|
|
|
|
{
|
|
|
|
|
short id = 0;
|
|
|
|
|
for (word i = 0; i < section().fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
const TForm_item& f = section().field(i);
|
|
|
|
|
if (f.id() > id) id = f.id();
|
|
|
|
|
}
|
|
|
|
|
_id = id+1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print_on(m);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1995-05-30 16:01:38 +00:00
|
|
|
|
const bool godmode = form().edit_level() > 1;
|
|
|
|
|
m.enable_page(1, godmode);
|
|
|
|
|
m.enable(-7, godmode);
|
1995-06-05 08:58:11 +00:00
|
|
|
|
m.enable(F_ID, godmode);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1995-06-22 14:48:00 +00:00
|
|
|
|
const bool dirty = m.run() == K_ENTER;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (dirty)
|
|
|
|
|
{
|
|
|
|
|
read_from(m);
|
|
|
|
|
set_dirty();
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return dirty;
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-11 17:36:57 +00:00
|
|
|
|
const TString& TForm_item::picture() const
|
|
|
|
|
{
|
|
|
|
|
CHECK(0, "Can't get the picture of a generic form item!");
|
|
|
|
|
return _prompt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_item::set_picture(const char*)
|
|
|
|
|
{
|
|
|
|
|
CHECK(0, "Can't set the picture of a generic form item!");
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
short TForm_item::x() const
|
|
|
|
|
{
|
|
|
|
|
if (_section == NULL || !_section->columnwise())
|
|
|
|
|
return _x;
|
|
|
|
|
return _section->tab(_x-1);
|
|
|
|
|
}
|
1995-12-11 17:36:57 +00:00
|
|
|
|
|
1995-05-09 09:12:26 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_subsection
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TForm_subsection : public TForm_item
|
|
|
|
|
{
|
1995-06-07 10:47:05 +00:00
|
|
|
|
TPrint_section _ssec;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TString _name;
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1995-06-07 10:47:05 +00:00
|
|
|
|
int _file_id; // ID del file su cui iterare in stampa se previsto
|
|
|
|
|
|
1995-05-09 09:12:26 +00:00
|
|
|
|
protected:
|
|
|
|
|
virtual void print_on(ostream& out) const;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
1995-06-07 10:47:05 +00:00
|
|
|
|
virtual bool parse(TScanner& s);
|
|
|
|
|
virtual bool update();
|
1995-05-09 09:12:26 +00:00
|
|
|
|
virtual bool edit(TMask& m);
|
|
|
|
|
|
|
|
|
|
virtual const char* class_name() const { return "SEZIONE"; }
|
|
|
|
|
|
|
|
|
|
TPrint_section& subsection() { return _ssec; }
|
|
|
|
|
|
|
|
|
|
virtual void show(bool on = TRUE);
|
|
|
|
|
virtual void enable(bool on = TRUE);
|
|
|
|
|
void hide() { show(FALSE); }
|
|
|
|
|
void disable() { enable(FALSE); }
|
|
|
|
|
|
|
|
|
|
void name(const char* s) { _name = s; _desc << "Sottosezione " << s; }
|
|
|
|
|
const char* name() const { return _name; }
|
|
|
|
|
|
|
|
|
|
TForm_subsection(TPrint_section* section, const char* name = "");
|
|
|
|
|
virtual ~TForm_subsection() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TForm_subsection::TForm_subsection(TPrint_section* s, const char* nm) :
|
1995-07-19 09:57:25 +00:00
|
|
|
|
TForm_item(s), _ssec(&(s->form()), s->section_type(), s->page_type(), TRUE), _file_id(-1), _name(nm)
|
1995-05-09 09:12:26 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
1995-06-07 10:47:05 +00:00
|
|
|
|
bool TForm_subsection::parse(TScanner& s)
|
|
|
|
|
{
|
|
|
|
|
name(s.pop());
|
|
|
|
|
_width = s.integer();
|
|
|
|
|
_height = s.integer();
|
|
|
|
|
_x = s.integer();
|
|
|
|
|
_y = s.integer();
|
|
|
|
|
|
|
|
|
|
if (s.popkey() == "FI") // FILE su cui iterare con next_match
|
|
|
|
|
_file_id = s.integer(); // TBI controllo alias
|
|
|
|
|
else s.push();
|
|
|
|
|
|
|
|
|
|
return _ssec.parse(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TForm_subsection::update()
|
|
|
|
|
{
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
TRelation* rel = form().relation();
|
|
|
|
|
|
|
|
|
|
if (rel == NULL || _file_id == -1)
|
|
|
|
|
ok = _ssec.update();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
if (rel->is_first_match(_file_id))
|
|
|
|
|
do {
|
|
|
|
|
if (!(ok = _ssec.update()))
|
|
|
|
|
break;
|
|
|
|
|
_ssec.set_repeat_count(++i);
|
|
|
|
|
}
|
|
|
|
|
while (rel->next_match(_file_id));
|
|
|
|
|
_ssec.set_repeat_count(0);
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-09 09:12:26 +00:00
|
|
|
|
bool TForm_subsection::edit(TMask& m)
|
|
|
|
|
{
|
|
|
|
|
// mask con nome e bottone edit contents / annulla
|
|
|
|
|
TMask mu("ba2100u");
|
|
|
|
|
mu.set(F_CAPTION, _name);
|
1995-06-07 10:47:05 +00:00
|
|
|
|
mu.set(F_WIDTH, _width);
|
|
|
|
|
mu.set(F_HEIGHT, _height);
|
|
|
|
|
mu.set(F_X, _x);
|
|
|
|
|
mu.set(F_Y, _y);
|
|
|
|
|
|
|
|
|
|
mu.set_handler(F_BUT_FILE1, but_file_handler_sub);
|
|
|
|
|
|
|
|
|
|
if (_file_id != -1)
|
|
|
|
|
{
|
|
|
|
|
// set file description
|
|
|
|
|
form().rel_desc().set_cur_file(_file_id);
|
|
|
|
|
TString80 desc; desc << form().rel_desc().file_desc();
|
|
|
|
|
mu.set(F_FILE1, desc);
|
|
|
|
|
}
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
|
|
|
|
KEY k;
|
|
|
|
|
|
|
|
|
|
// vedere se e' nuova etc.
|
|
|
|
|
// gestire aggiunta / modifica menu
|
|
|
|
|
|
|
|
|
|
while ((k = mu.run()) != K_ESC)
|
|
|
|
|
{
|
|
|
|
|
if (mu.field(F_CAPTION).dirty())
|
|
|
|
|
_name = mu.get(F_CAPTION);
|
|
|
|
|
|
1995-06-07 10:47:05 +00:00
|
|
|
|
if (mu.field(F_WIDTH).dirty())
|
|
|
|
|
_width = mu.get_int(F_WIDTH);
|
|
|
|
|
|
|
|
|
|
if (mu.field(F_HEIGHT).dirty())
|
|
|
|
|
_height = mu.get_int(F_HEIGHT);
|
|
|
|
|
|
|
|
|
|
if (mu.field(F_X).dirty())
|
|
|
|
|
_x = mu.get_int(F_X);
|
|
|
|
|
|
|
|
|
|
if (mu.field(F_Y).dirty())
|
|
|
|
|
_y = mu.get_int(F_Y);
|
|
|
|
|
|
|
|
|
|
if (mu.field(F_FILE1).dirty())
|
|
|
|
|
{
|
|
|
|
|
if (mu.get(F_FILE1).empty())
|
|
|
|
|
_file_id = -1;
|
|
|
|
|
else
|
|
|
|
|
_file_id = form().rel_desc().file_num();
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-09 09:12:26 +00:00
|
|
|
|
if (k == K_INS)
|
1995-06-07 10:47:05 +00:00
|
|
|
|
_ssec.edit(_name);
|
|
|
|
|
else if (k == K_DEL)
|
|
|
|
|
{
|
|
|
|
|
// remove myself
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (k == K_ENTER)
|
|
|
|
|
break;
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return k != K_ESC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_subsection::print_on(ostream& out) const
|
1995-05-09 09:12:26 +00:00
|
|
|
|
{
|
1995-06-07 10:47:05 +00:00
|
|
|
|
out << "SEZIONE " << _name << ' ' << _width << ' ' << _height
|
|
|
|
|
<< ' ' << _x << ' ' << _y;
|
|
|
|
|
|
|
|
|
|
if (_file_id != -1)
|
|
|
|
|
out << " FILE " << _file_id;
|
|
|
|
|
out << "\n";
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
|
|
|
|
for (word i = 0; i < _ssec.fields(); i++)
|
1995-06-07 10:47:05 +00:00
|
|
|
|
out << _ssec.field(i);
|
|
|
|
|
out << "\nEND" << "\n";
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
// ???
|
1995-05-09 09:12:26 +00:00
|
|
|
|
void TForm_subsection::show(bool on)
|
|
|
|
|
{
|
|
|
|
|
for (unsigned int i = 0; i < _ssec.fields(); i++)
|
|
|
|
|
_ssec.field(i).show(on);
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
// ???
|
1995-05-09 09:12:26 +00:00
|
|
|
|
void TForm_subsection::enable(bool on)
|
|
|
|
|
{
|
|
|
|
|
for (unsigned int i = 0; i < _ssec.fields(); i++)
|
|
|
|
|
_ssec.field(i).enable(on);
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_string
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TForm_string : public TForm_item
|
|
|
|
|
{
|
|
|
|
|
TString _str, _picture;
|
|
|
|
|
TArray _field;
|
|
|
|
|
|
|
|
|
|
protected:
|
1994-12-15 18:06:43 +00:00
|
|
|
|
virtual const char* class_name() const { return "STRINGA"; }
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual void print_body(ostream& out);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
virtual void print_on(TMask& m);
|
|
|
|
|
virtual void read_from(const TMask& m);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
|
|
|
|
virtual bool read_from(const TRectype& rform);
|
|
|
|
|
virtual void print_on(TRectype& rform);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual void print_on(TToken_string& row);
|
1995-06-22 14:48:00 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
virtual bool parse_item(TScanner&);
|
1995-01-03 14:19:41 +00:00
|
|
|
|
virtual bool read();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
virtual bool update();
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual const char* example() const;
|
|
|
|
|
virtual void apply_format(TString& s, const TString& p) const;
|
|
|
|
|
|
1995-07-19 09:57:25 +00:00
|
|
|
|
virtual const char* get() const;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool set(const char*);
|
|
|
|
|
|
1994-12-15 18:06:43 +00:00
|
|
|
|
TFieldref& field(int i) const { return (TFieldref&)_field[i]; }
|
1994-11-10 14:17:03 +00:00
|
|
|
|
void put_paragraph(const char* s);
|
|
|
|
|
|
|
|
|
|
public:
|
1995-12-11 17:36:57 +00:00
|
|
|
|
virtual const TString& picture() const { return _picture; }
|
|
|
|
|
virtual void set_picture(const char* p) { _picture = p; }
|
1995-11-24 09:54:06 +00:00
|
|
|
|
|
1995-10-27 08:28:13 +00:00
|
|
|
|
virtual bool edit(TMask& m);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
TForm_string(TPrint_section* section) : TForm_item(section) {}
|
1995-01-02 09:33:00 +00:00
|
|
|
|
virtual ~TForm_string() {}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
1995-10-27 08:28:13 +00:00
|
|
|
|
bool TForm_string::edit(TMask& m)
|
|
|
|
|
{
|
|
|
|
|
const bool godmode = form().edit_level() > 1;
|
|
|
|
|
m.enable(F_PROMPT, godmode ? TRUE : (_field.items()==0));
|
|
|
|
|
return TForm_item::edit(m);
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_string::parse_item(TScanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
if (scanner.key() == "FI")
|
|
|
|
|
{
|
|
|
|
|
TFieldref* fr = new TFieldref(scanner.line(), 0);
|
1995-05-18 14:18:01 +00:00
|
|
|
|
_field.add(fr);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scanner.key() == "PI")
|
|
|
|
|
{
|
|
|
|
|
_picture = scanner.string();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TForm_item::parse_item(scanner);
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_string::print_body(ostream& out)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
TForm_item::print_body(out);
|
|
|
|
|
if (_picture.not_empty())
|
|
|
|
|
out << " PICTURE \"" << _picture << "\"" << endl;
|
|
|
|
|
for (int i = 0; i < _field.items(); i++)
|
1994-12-15 18:06:43 +00:00
|
|
|
|
out << " FIELD " << field(i) << endl;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm_string::read_from(const TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
bool changed = TForm_item::read_from(prof);
|
|
|
|
|
|
|
|
|
|
const TString& pict = prof.get("PICT");
|
|
|
|
|
if (_picture != pict)
|
|
|
|
|
{
|
|
|
|
|
_picture = pict;
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_string::print_on(TToken_string& row)
|
1995-06-22 14:48:00 +00:00
|
|
|
|
{
|
1995-07-19 09:57:25 +00:00
|
|
|
|
TForm_item::print_on(row);
|
|
|
|
|
if (_field.items() && form().edit_level() > 1)
|
1995-06-22 14:48:00 +00:00
|
|
|
|
row << '|' << field(0);
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
void TForm_string::print_on(TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
TForm_item::print_on(prof);
|
|
|
|
|
prof.put("PICT", _picture);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm_string::print_on(TMask& m)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1994-12-20 15:11:26 +00:00
|
|
|
|
TForm_item::print_on(m);
|
1995-05-18 14:18:01 +00:00
|
|
|
|
for (int i = 0; i < _field.items(); i++)
|
1995-05-29 10:25:10 +00:00
|
|
|
|
put_fieldref(field(i), m.field(i == 0 ? F_FIELDREF1 : F_FIELDREF2));
|
1994-12-15 18:06:43 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
m.set(F_PICTURE, _picture);
|
1995-05-30 16:01:38 +00:00
|
|
|
|
|
|
|
|
|
TSheet_field& s = (TSheet_field&)m.field(F_ITEMS);
|
|
|
|
|
s.reset();
|
|
|
|
|
if (_message.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = s.row(0);
|
|
|
|
|
row = " | ";
|
|
|
|
|
row.add(message(0));
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm_string::read_from(const TMask& m)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1994-12-20 15:11:26 +00:00
|
|
|
|
TForm_item::read_from(m);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
_picture = m.get(F_PICTURE);
|
1994-12-15 18:06:43 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
const TString& f = m.get(i == 0 ? F_FIELDREF1 : F_FIELDREF2);
|
1994-12-15 18:06:43 +00:00
|
|
|
|
if (f.not_empty())
|
1995-05-29 10:25:10 +00:00
|
|
|
|
{
|
|
|
|
|
TFieldref* fr = (TFieldref*)_field.objptr(i);
|
|
|
|
|
if (fr == NULL)
|
|
|
|
|
{
|
|
|
|
|
fr = new TFieldref(f, 0);
|
|
|
|
|
_field.add(fr, i);
|
|
|
|
|
}
|
|
|
|
|
*fr = f;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_field.destroy(i);
|
1994-12-15 18:06:43 +00:00
|
|
|
|
}
|
1995-05-30 16:01:38 +00:00
|
|
|
|
|
|
|
|
|
TSheet_field& f = (TSheet_field&)m.field(F_ITEMS);
|
|
|
|
|
TToken_string& msg = f.row(0);
|
|
|
|
|
if (msg.empty_items())
|
|
|
|
|
_message.destroy(0);
|
|
|
|
|
else
|
|
|
|
|
_message.add(msg.get(2), 0);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm_string::set(const char* s)
|
|
|
|
|
{
|
|
|
|
|
_str = s;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* TForm_string::get() const
|
|
|
|
|
{ return _str; }
|
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
|
|
// Se un campo e' abilitato ed ha almeno un riferimento su file leggilo
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_string::read()
|
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
const bool ok = enabled();
|
|
|
|
|
if (ok)
|
1995-01-09 16:51:21 +00:00
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (_field.items() != 0)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-01-09 16:51:21 +00:00
|
|
|
|
const char* s = "";
|
1995-11-27 08:39:18 +00:00
|
|
|
|
const TRelation* r = form().relation();
|
|
|
|
|
CHECK(r, "Can't read from null relation");
|
1995-03-22 09:07:04 +00:00
|
|
|
|
for (int i = 0; i < _field.items() && *s == '\0'; i++)
|
1995-01-09 16:51:21 +00:00
|
|
|
|
s = field(i).read(r);
|
|
|
|
|
set(s);
|
|
|
|
|
}
|
1995-05-29 10:25:10 +00:00
|
|
|
|
}
|
1995-01-09 16:51:21 +00:00
|
|
|
|
return ok;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_string::put_paragraph(const char* s)
|
|
|
|
|
{
|
|
|
|
|
if (hidden()) return;
|
|
|
|
|
|
1994-12-15 18:06:43 +00:00
|
|
|
|
if (height() > 1)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
TParagraph_string p(s, width());
|
|
|
|
|
int i = _prompt.not_empty() ? 1 : 0;
|
1994-12-15 18:06:43 +00:00
|
|
|
|
for (; (s = p.get()) != NULL && i < height(); i++)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
string_at(_x, _y+i, s);
|
|
|
|
|
}
|
1995-12-04 10:27:42 +00:00
|
|
|
|
else
|
1995-12-11 17:36:57 +00:00
|
|
|
|
string_at(-1, _y, s);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
|
|
|
|
|
void TForm_string::apply_format(TString& s, const TString& p) const
|
|
|
|
|
{
|
|
|
|
|
TString tmp(s);
|
|
|
|
|
if (!p.blank())
|
|
|
|
|
{
|
|
|
|
|
TToken_string delim(4, ','); // Stringa con i due delimitatori
|
|
|
|
|
const char* pic = p; // Picture senza delimitatori
|
|
|
|
|
|
|
|
|
|
if (pic[0] == '(') // Se ci sono i delimitatori ...
|
|
|
|
|
{
|
|
|
|
|
const int bra = p.find(')');
|
|
|
|
|
if (bra > 0) // ... cerca la parentesi chiusa
|
|
|
|
|
{
|
|
|
|
|
delim = p.sub(1, bra); // memorizza delimitatori
|
|
|
|
|
pic += bra+1; // toglili dalla picture
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (class_name() == "DATA" && s.empty())
|
|
|
|
|
tmp ="";
|
|
|
|
|
else
|
|
|
|
|
tmp.picture(pic, s); // riempi la stringa col valore pitturato
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
if (!delim.empty_items()) // Aggiungi delimitatori
|
|
|
|
|
{
|
|
|
|
|
TString16 d(delim.get(0));
|
|
|
|
|
const int ld = d.len();
|
|
|
|
|
|
|
|
|
|
if (ld > 0) // Se il primo delimitatore e' valido ...
|
|
|
|
|
{
|
|
|
|
|
for (int spc = 0;s[spc]==' ' ; spc++) ;
|
|
|
|
|
if (spc < ld)
|
|
|
|
|
{
|
|
|
|
|
TString16 spazi;
|
|
|
|
|
spazi.spaces(ld - spc);
|
|
|
|
|
tmp.insert(spazi,0);
|
|
|
|
|
spc = ld;
|
|
|
|
|
}
|
|
|
|
|
tmp.overwrite(d,spc - ld);
|
|
|
|
|
}
|
|
|
|
|
d = delim.get();
|
|
|
|
|
if (d.not_empty()) // Se il secondo delimitatore e' valido ...
|
|
|
|
|
tmp << d; // ... aggiungilo alla fine
|
|
|
|
|
}
|
|
|
|
|
s = tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_string::update()
|
|
|
|
|
{
|
|
|
|
|
if (read())
|
|
|
|
|
{
|
1995-11-03 08:23:59 +00:00
|
|
|
|
TString s;
|
1995-01-09 16:51:21 +00:00
|
|
|
|
TForm_item::update();
|
1995-07-19 09:57:25 +00:00
|
|
|
|
if (!picture().blank())
|
1995-12-14 10:45:17 +00:00
|
|
|
|
{
|
|
|
|
|
s = get();
|
|
|
|
|
apply_format(s, picture());
|
1995-11-03 08:23:59 +00:00
|
|
|
|
put_paragraph(s);
|
1994-12-15 18:06:43 +00:00
|
|
|
|
}
|
1995-10-18 11:31:01 +00:00
|
|
|
|
else
|
1995-11-03 08:23:59 +00:00
|
|
|
|
put_paragraph(s=get()); // Stampa immediata senza picture
|
|
|
|
|
const int n = (_message.objptr(1) != NULL && s.empty() ? 1 : 0);
|
|
|
|
|
do_message(n);
|
1995-01-03 14:19:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
const char* TForm_string::example() const
|
|
|
|
|
{
|
|
|
|
|
TString prova("Stringa esempio");
|
|
|
|
|
apply_format(prova, picture());
|
|
|
|
|
return strcpy(__tmp_string, prova);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_number
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TForm_number : public TForm_string
|
1995-12-14 10:45:17 +00:00
|
|
|
|
{
|
|
|
|
|
void apply_format(real& r, TString& s) const;
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
protected: // TForm_string
|
1994-12-15 18:06:43 +00:00
|
|
|
|
virtual const char* class_name() const { return "NUMERO"; }
|
1995-10-31 09:02:00 +00:00
|
|
|
|
virtual bool parse_head(TScanner& scanner);
|
1995-10-16 17:52:24 +00:00
|
|
|
|
virtual bool update();
|
1995-05-18 14:18:01 +00:00
|
|
|
|
virtual int height() const { return 0; }
|
|
|
|
|
|
|
|
|
|
protected:
|
1995-01-09 16:51:21 +00:00
|
|
|
|
int decimals() const { return _height; }
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
public:
|
1995-11-24 09:54:06 +00:00
|
|
|
|
|
|
|
|
|
void set_decimals(int d) { _height = d; }
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual const char* example() const;
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
TForm_number(TPrint_section* section) : TForm_string(section) {}
|
1995-01-02 09:33:00 +00:00
|
|
|
|
virtual ~TForm_number() {}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TForm_number::parse_head(TScanner& scanner)
|
1995-05-18 14:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
TForm_item::parse_head(scanner);
|
|
|
|
|
_height = _width; // Decimals
|
|
|
|
|
_width = 0;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TForm_number::update()
|
|
|
|
|
{
|
|
|
|
|
if (read())
|
1995-07-19 09:57:25 +00:00
|
|
|
|
{
|
1995-01-09 16:51:21 +00:00
|
|
|
|
TForm_item::update();
|
1995-07-19 09:57:25 +00:00
|
|
|
|
real n(get());
|
1994-12-15 18:06:43 +00:00
|
|
|
|
n.round(decimals());
|
1995-07-19 09:57:25 +00:00
|
|
|
|
|
1995-09-11 10:26:59 +00:00
|
|
|
|
if (!n.is_zero())
|
|
|
|
|
{
|
1995-12-14 10:45:17 +00:00
|
|
|
|
TString s;
|
|
|
|
|
apply_format(n,s);
|
|
|
|
|
put_paragraph(s);
|
|
|
|
|
do_message();
|
|
|
|
|
}
|
1995-11-03 08:23:59 +00:00
|
|
|
|
else
|
1995-12-14 10:45:17 +00:00
|
|
|
|
{
|
1995-11-03 08:23:59 +00:00
|
|
|
|
const int n = (_message.objptr(1) != NULL ? 1 : 0);
|
|
|
|
|
do_message(n);
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
1995-07-19 09:57:25 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_number::apply_format(real& n , TString& s) const
|
|
|
|
|
{
|
|
|
|
|
if (!picture().blank())
|
|
|
|
|
{
|
|
|
|
|
TToken_string delim(4, ','); // Stringa con i due delimitatori
|
|
|
|
|
TString pic(picture()); // Picture senza delimitatori
|
|
|
|
|
int maxlen = -1;
|
|
|
|
|
int at = pic.find('@');
|
|
|
|
|
if (at >= 0)
|
|
|
|
|
{
|
|
|
|
|
maxlen = atoi(&pic[at+1]);
|
|
|
|
|
pic.cut(at);
|
|
|
|
|
}
|
|
|
|
|
if (pic[0] == '(') // Se ci sono i delimitatori ...
|
|
|
|
|
{
|
|
|
|
|
const int bra = pic.find(')');
|
|
|
|
|
if (bra > 0) // ... cerca la parentesi chiusa
|
|
|
|
|
{
|
|
|
|
|
delim = pic.sub(1, bra); // memorizza delimitatori
|
|
|
|
|
pic.ltrim(bra + 1); // toglili dalla picture
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s=n.string(pic); // riempi la stringa col valore pitturato
|
|
|
|
|
|
|
|
|
|
if (maxlen >= 0)
|
|
|
|
|
s.cut(maxlen);
|
|
|
|
|
if (!delim.empty_items()) // Aggiungi delimitatori
|
|
|
|
|
{
|
|
|
|
|
TString16 d(delim.get(0));
|
|
|
|
|
const int ld = d.len();
|
|
|
|
|
|
|
|
|
|
if (ld > 0) // Se il primo delimitatore e' valido ...
|
|
|
|
|
{
|
|
|
|
|
for (int spc = 0;s[spc]==' ' ; spc++) ;
|
|
|
|
|
if (spc < ld)
|
|
|
|
|
{
|
|
|
|
|
TString16 spazi;
|
|
|
|
|
spazi.spaces(ld - spc);
|
|
|
|
|
s.insert(spazi,0);
|
|
|
|
|
spc = ld;
|
|
|
|
|
}
|
|
|
|
|
s.overwrite(d,spc - ld);
|
|
|
|
|
}
|
|
|
|
|
d = delim.get();
|
|
|
|
|
if (d.not_empty()) // Se il secondo delimitatore e' valido ...
|
|
|
|
|
s << d; // ... aggiungilo alla fine
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else s = n.string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* TForm_number::example() const
|
|
|
|
|
{
|
|
|
|
|
real n("123456789120.00"); n.round(2);
|
|
|
|
|
TString s;
|
|
|
|
|
apply_format(n,s);
|
|
|
|
|
return strcpy(__tmp_string, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_date
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TForm_date : public TForm_string
|
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
TString16 _format;
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
protected:
|
1994-12-15 18:06:43 +00:00
|
|
|
|
virtual const char* class_name() const { return "DATA"; }
|
1995-01-03 14:19:41 +00:00
|
|
|
|
virtual bool read();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
virtual bool set(const char*);
|
1995-01-03 14:19:41 +00:00
|
|
|
|
bool set(const TDate& d);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
virtual bool parse_item(TScanner& scanner);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual void print_body(ostream& out);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
1995-05-09 09:12:26 +00:00
|
|
|
|
virtual void print_on(TMask& m);
|
|
|
|
|
virtual void read_from(const TMask& m);
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
virtual bool read_from(const TRectype& rform);
|
|
|
|
|
virtual void print_on(TRectype& rform);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
public:
|
1995-11-24 09:54:06 +00:00
|
|
|
|
|
|
|
|
|
void set_format(const char* f) { _format = f; }
|
1995-05-09 09:12:26 +00:00
|
|
|
|
virtual bool edit(TMask& m);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual const char* example() const;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
TForm_date(TPrint_section* section);
|
1995-01-02 09:33:00 +00:00
|
|
|
|
virtual ~TForm_date() {}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
1994-12-15 18:06:43 +00:00
|
|
|
|
TForm_date::TForm_date(TPrint_section* section)
|
1995-05-09 09:12:26 +00:00
|
|
|
|
: TForm_string(section), _format("1444-")
|
1995-01-03 14:19:41 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
bool TForm_date::read()
|
|
|
|
|
{
|
|
|
|
|
bool ok = TForm_string::read();
|
1995-01-09 16:51:21 +00:00
|
|
|
|
if (ok && !get()[0] && automagic())
|
1995-04-20 14:35:14 +00:00
|
|
|
|
set(printer().getdate());
|
1995-01-03 14:19:41 +00:00
|
|
|
|
return ok;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_date::print_body(ostream& out)
|
1995-05-09 09:12:26 +00:00
|
|
|
|
{
|
|
|
|
|
TForm_string::print_body(out);
|
1995-05-18 14:18:01 +00:00
|
|
|
|
out << " FORMAT \"" << _format << "\"\n";
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm_date::parse_item(TScanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
if (scanner.key() == "FO")
|
|
|
|
|
{
|
|
|
|
|
_format = scanner.string();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return TForm_string::parse_item(scanner);
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
bool TForm_date::read_from(const TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
bool changed = TForm_string::read_from(prof);
|
|
|
|
|
|
|
|
|
|
const TString& df = prof.get("DATEFORM");
|
|
|
|
|
if (df.not_empty() && df != _format)
|
|
|
|
|
{
|
|
|
|
|
_format = df;
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_date::print_on(TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
TForm_string::read_from(prof);
|
|
|
|
|
prof.put("DATEFORM", _format);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm_date::set(const char* s)
|
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
const TDate da(s);
|
|
|
|
|
return set(da);
|
1995-01-03 14:19:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
bool TForm_date::set(const TDate& da)
|
1995-01-03 14:19:41 +00:00
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
TFormatted_date d(da); d.set_format(_format);
|
|
|
|
|
TForm_string::set(d.string());
|
1995-05-09 09:12:26 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_date::print_on(TMask& m)
|
1995-12-14 10:45:17 +00:00
|
|
|
|
{
|
|
|
|
|
const TDate dd(TODAY);
|
|
|
|
|
TFormatted_date d(dd); d.set_format(_format);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
m.set(F_DEXAMPLE, d.string());
|
|
|
|
|
|
|
|
|
|
m.set(F_DFORMAT, _format.mid(0,1));
|
|
|
|
|
m.set(F_DDAY, _format.mid(1,1));
|
|
|
|
|
m.set(F_DMONTH, _format.mid(2,1));
|
|
|
|
|
m.set(F_DYEAR, _format.mid(3,1));
|
|
|
|
|
m.set(F_DSEP, _format.mid(4,1));
|
|
|
|
|
|
|
|
|
|
TForm_string::print_on(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm_date::read_from(const TMask& m)
|
|
|
|
|
{
|
|
|
|
|
TForm_string::read_from(m);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
|
|
|
|
// adjust format string
|
|
|
|
|
_format[0] = m.get(F_DFORMAT)[0];
|
|
|
|
|
_format[1] = m.get(F_DDAY )[0];
|
|
|
|
|
_format[2] = m.get(F_DMONTH )[0];
|
|
|
|
|
_format[3] = m.get(F_DYEAR )[0];
|
|
|
|
|
_format[4] = m.get(F_DSEP )[0];
|
|
|
|
|
_format[5] = '\0';
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
|
|
|
|
|
1995-05-09 09:12:26 +00:00
|
|
|
|
bool TForm_date::edit(TMask& m)
|
|
|
|
|
{
|
|
|
|
|
return TForm_string::edit(m);
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
const char* TForm_date::example() const
|
|
|
|
|
{
|
|
|
|
|
const TDate dd(TODAY);
|
|
|
|
|
TFormatted_date d(dd); d.set_format(_format);
|
|
|
|
|
TString s(d.string());
|
|
|
|
|
return strcpy(__tmp_string, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_list
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TForm_list : public TForm_string
|
|
|
|
|
{
|
|
|
|
|
TToken_string _codes;
|
|
|
|
|
TToken_string _values;
|
|
|
|
|
|
|
|
|
|
protected:
|
1994-12-15 18:06:43 +00:00
|
|
|
|
virtual const char* class_name() const { return "LISTA"; }
|
1994-12-20 15:11:26 +00:00
|
|
|
|
virtual bool parse_item(TScanner& scanner);
|
|
|
|
|
virtual void print_on(TMask& m);
|
|
|
|
|
virtual void read_from(const TMask& m);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual void print_body(ostream& out);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
virtual bool update();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TForm_list(TPrint_section* section);
|
1995-01-02 09:33:00 +00:00
|
|
|
|
virtual ~TForm_list() {}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TForm_list::TForm_list(TPrint_section* section)
|
|
|
|
|
: TForm_string(section)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
bool TForm_list::parse_item(TScanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
if (scanner.key() == "IT")
|
|
|
|
|
{
|
|
|
|
|
TToken_string s(scanner.string());
|
|
|
|
|
_codes.add(s.get());
|
|
|
|
|
_values.add(s.get());
|
1994-12-15 18:06:43 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
while (scanner.popkey() == "ME")
|
|
|
|
|
{
|
1995-04-26 08:06:43 +00:00
|
|
|
|
TFixed_string m(scanner.line());
|
1994-11-10 14:17:03 +00:00
|
|
|
|
m.strip_spaces();
|
|
|
|
|
message(_values.items()-1).add(m);
|
|
|
|
|
}
|
|
|
|
|
scanner.push();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TForm_string::parse_item(scanner);
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm_list::print_on(TMask& m)
|
|
|
|
|
{
|
|
|
|
|
TForm_string::print_on(m);
|
|
|
|
|
TSheet_field& s = (TSheet_field&)m.field(F_ITEMS);
|
1995-05-30 16:01:38 +00:00
|
|
|
|
s.reset();
|
1994-12-20 15:11:26 +00:00
|
|
|
|
_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));
|
|
|
|
|
}
|
1995-05-30 16:01:38 +00:00
|
|
|
|
// s.force_update();
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TForm_list::print_body(ostream& out)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
TForm_string::print_body(out);
|
|
|
|
|
|
|
|
|
|
TToken_string& cod = (TToken_string&)_codes; // Trick to skip const
|
|
|
|
|
TToken_string& val = (TToken_string&)_values;
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
TString c(cod.get(0));
|
|
|
|
|
TString v(val.get(0));
|
|
|
|
|
|
|
|
|
|
for (; c[0]; c = cod.get(), v = val.get(), i++)
|
|
|
|
|
{
|
|
|
|
|
out << " ITEM \"" << c;
|
|
|
|
|
if (v.not_empty()) out << '|' << v;
|
|
|
|
|
out << '"';
|
|
|
|
|
|
|
|
|
|
const char* m = ((TForm_list*)this)->message(i);
|
|
|
|
|
if (*m) out << " MESSAGE " << m;
|
|
|
|
|
|
|
|
|
|
out << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TForm_list::update()
|
|
|
|
|
{
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
|
|
|
|
|
if (!read()) return ok;
|
|
|
|
|
|
1994-12-15 18:06:43 +00:00
|
|
|
|
const TString& val =get();
|
1994-12-28 11:01:33 +00:00
|
|
|
|
int pos = _codes.get_pos(val);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (pos < 0)
|
|
|
|
|
{
|
1995-10-09 15:42:33 +00:00
|
|
|
|
TString def= _codes.get(0);
|
|
|
|
|
def.trim();
|
|
|
|
|
if (val == def) pos = 0; // Test default (first & empty) value
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ok = yesno_box("Il campo '%s' non puo' valere '%s': continuare ugualmente",
|
|
|
|
|
(const char*)key(), (const char*)val);
|
|
|
|
|
set(_codes.get(pos = 0));
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
1994-12-28 11:01:33 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
do_message(pos);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-28 11:01:33 +00:00
|
|
|
|
if (!hidden())
|
|
|
|
|
{
|
|
|
|
|
const char* c = _values.get(pos);
|
|
|
|
|
if (c == NULL) c = val;
|
|
|
|
|
if (c) string_at(_x, _y, c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1995-01-02 09:33:00 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm_group
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TForm_group : public TForm_item
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual const char* class_name() const { return "GRUPPO"; }
|
|
|
|
|
virtual bool update() { return TRUE; }
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TForm_group(TPrint_section* section) : TForm_item(section) {};
|
|
|
|
|
virtual ~TForm_group() {}
|
|
|
|
|
};
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TGraphic_section
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TGraphic_section : public TPrint_section
|
|
|
|
|
{
|
|
|
|
|
TString _back;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
TForm_item* parse_item(const TString& s);
|
|
|
|
|
bool update();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void append(const char* s) { _back << s; }
|
|
|
|
|
|
|
|
|
|
TGraphic_section(TForm* f, pagetype pt) : TPrint_section(f, 'G', pt) {}
|
|
|
|
|
virtual ~TGraphic_section() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TForm_picture : public TForm_item
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual const char* class_name() const { return "FIGURA"; }
|
|
|
|
|
virtual bool update();
|
|
|
|
|
|
|
|
|
|
public:
|
1995-12-15 11:35:47 +00:00
|
|
|
|
TForm_picture(TGraphic_section* section) : TForm_item(section) {}
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual ~TForm_picture() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TForm_line : public TForm_item
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual const char* class_name() const { return "LINEA"; }
|
|
|
|
|
virtual bool update();
|
|
|
|
|
|
|
|
|
|
public:
|
1995-12-15 11:35:47 +00:00
|
|
|
|
TForm_line(TGraphic_section* section) : TForm_item(section) {}
|
1995-12-14 10:45:17 +00:00
|
|
|
|
virtual ~TForm_line() {}
|
|
|
|
|
};
|
|
|
|
|
|
1995-12-15 11:35:47 +00:00
|
|
|
|
class TForm_box : public TForm_item
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual const char* class_name() const { return "BOX"; }
|
|
|
|
|
virtual bool update();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TForm_box(TGraphic_section* section) : TForm_item(section) {}
|
|
|
|
|
virtual ~TForm_box() {}
|
|
|
|
|
};
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
bool TForm_picture::update()
|
|
|
|
|
{
|
|
|
|
|
const bool ok = _prompt.not_empty();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TString80 i;
|
|
|
|
|
i << "i{" << _prompt << ',' << _x << ',' << _y << ','
|
|
|
|
|
<< (_x+width()-1) << ',' << (_y+height()-1) << '}';
|
|
|
|
|
((TGraphic_section&)section()).append(i);
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm_line::update()
|
|
|
|
|
{
|
1995-12-15 17:11:18 +00:00
|
|
|
|
int spessore = 1;
|
|
|
|
|
char codice = 'l';
|
|
|
|
|
for (int j = _prompt.len()-1; j >= 0; j--)
|
|
|
|
|
{
|
|
|
|
|
switch (_prompt[j])
|
|
|
|
|
{
|
|
|
|
|
case 'B':
|
|
|
|
|
case 'b':
|
|
|
|
|
spessore = 3; break;
|
|
|
|
|
case 'R':
|
|
|
|
|
case 'r':
|
|
|
|
|
codice = 'r'; break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TString80 i;
|
|
|
|
|
i << 'W' << spessore << codice
|
|
|
|
|
<< '{' << _x << ',' << _y << ','
|
1995-12-14 10:45:17 +00:00
|
|
|
|
<< (_x+width()-1) << ',' << (_y+height()-1) << '}';
|
|
|
|
|
|
|
|
|
|
((TGraphic_section&)section()).append(i);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-15 11:35:47 +00:00
|
|
|
|
bool TForm_box::update()
|
|
|
|
|
{
|
|
|
|
|
TString80 i;
|
|
|
|
|
const int w = _prompt[0] == '@' ? 3 : 1;
|
|
|
|
|
i << 'W' << w << "b{" << _x << ',' << _y << ','
|
|
|
|
|
<< (_x+width()-1) << ',' << (_y+height()-1) << '}';
|
|
|
|
|
|
|
|
|
|
((TGraphic_section&)section()).append(i);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
TForm_item* TGraphic_section::parse_item(const TString& s)
|
|
|
|
|
{
|
|
|
|
|
if (s == "FI")
|
|
|
|
|
return new TForm_picture(this);
|
|
|
|
|
else if (s == "LI")
|
|
|
|
|
return new TForm_line(this);
|
1995-12-15 11:35:47 +00:00
|
|
|
|
else if (s == "BO")
|
|
|
|
|
return new TForm_box(this);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
|
|
|
|
|
error_box("Campo di stampa non ammesso per lo sfondo: %s", (const char*)s);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TGraphic_section::update()
|
|
|
|
|
{
|
|
|
|
|
_back.cut(0);
|
|
|
|
|
const bool ok = TPrint_section::update();
|
|
|
|
|
printer().setbackground(_back);
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TPrint_section
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
1995-08-31 15:16:13 +00:00
|
|
|
|
HIDDEN bool font_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
main_app().begin_wait();
|
|
|
|
|
|
|
|
|
|
const char* family = f.get();
|
|
|
|
|
const int MAXSIZES = 16;
|
|
|
|
|
long sizes[MAXSIZES];
|
|
|
|
|
BOOLEAN scalable;
|
|
|
|
|
const int num_sizes = (int)xvt_fmap_get_family_sizes(printer().get_printrcd(),
|
|
|
|
|
(char*)family, sizes, &scalable, MAXSIZES);
|
|
|
|
|
|
|
|
|
|
TToken_string pn1(80), pn2(80);
|
|
|
|
|
if (scalable)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 4; i <= 32; i++)
|
|
|
|
|
{
|
|
|
|
|
pn1.add(i);
|
|
|
|
|
pn2.add(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (num_sizes > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < num_sizes; i++)
|
|
|
|
|
pn1.add(sizes[i]);
|
|
|
|
|
}
|
|
|
|
|
else pn1.add(printer().get_char_size());
|
|
|
|
|
pn2 = pn1;
|
|
|
|
|
}
|
|
|
|
|
TList_field& lst = (TList_field&)f.mask().field(F_SIZE);
|
|
|
|
|
lst.replace_items(pn1, pn2);
|
|
|
|
|
lst.set(format("%d",printer().get_char_size()));
|
|
|
|
|
|
|
|
|
|
main_app().end_wait();
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
TMask* TPrint_section::_msk = NULL;
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
|
1995-07-19 09:57:25 +00:00
|
|
|
|
TPrint_section::TPrint_section(TForm* f, char st, pagetype pt, bool sub)
|
1995-08-31 15:16:13 +00:00
|
|
|
|
: _height(0), _form(f), _sec_type(st), _page_type(pt), _dirty(FALSE),
|
1995-12-15 11:35:47 +00:00
|
|
|
|
_subsection(sub), _repeat_count(0), _ofspc(0), _nfld(0)
|
1995-12-14 10:45:17 +00:00
|
|
|
|
{ _tab[0] = -1; }
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
TPrint_section::~TPrint_section()
|
|
|
|
|
{
|
|
|
|
|
if (_msk)
|
|
|
|
|
{
|
|
|
|
|
delete _msk;
|
|
|
|
|
_msk = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
void TPrint_section::change_field(int n, TForm_item* f)
|
|
|
|
|
{
|
|
|
|
|
_item.add(f,n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPrint_section::insert_field(int n, TForm_item* f)
|
|
|
|
|
{
|
|
|
|
|
_item.insert(f,n);
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-15 11:35:47 +00:00
|
|
|
|
void TPrint_section::add_field(TForm_item* f)
|
|
|
|
|
{
|
|
|
|
|
_item.add(f);
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
const TPrint_section& TPrint_section::copy(const TPrint_section& ps)
|
|
|
|
|
{
|
|
|
|
|
_item = ps._item;
|
|
|
|
|
_height = ps._height;
|
|
|
|
|
return ps;
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
TPrintrow& TPrint_section::row(int num)
|
|
|
|
|
{
|
|
|
|
|
TPrintrow* pr = (TPrintrow*)objptr(num);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (pr == NULL)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
pr = new TPrintrow;
|
|
|
|
|
add(pr, num);
|
|
|
|
|
}
|
|
|
|
|
return *pr;
|
|
|
|
|
}
|
1995-12-14 10:45:17 +00:00
|
|
|
|
|
|
|
|
|
int TPrint_section::tab(int col)
|
|
|
|
|
{
|
|
|
|
|
int ret = -1;
|
|
|
|
|
if (_columnwise)
|
|
|
|
|
{
|
|
|
|
|
if (_tab[0] == -1)
|
|
|
|
|
{
|
|
|
|
|
// compute column offset
|
1995-12-15 11:35:47 +00:00
|
|
|
|
_nfld = 0;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
_tab[0] = 1;
|
|
|
|
|
for (word i = 0; i < fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (field(i).shown() && field(i).enabled())
|
|
|
|
|
{
|
|
|
|
|
CHECKD (field(i)._x < MAXCOLUMNS, "Colonna ammessa e non concessa: ", field(i)._x);
|
|
|
|
|
_tab[field(i)._x] = field(i).width() + 1; // one is for separation
|
1995-12-15 11:35:47 +00:00
|
|
|
|
_nfld++;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// cumulate offsets
|
1995-12-15 11:35:47 +00:00
|
|
|
|
for (i = 1; i < _nfld; i++)
|
|
|
|
|
_tab[i] += _tab[i-1];
|
1995-12-14 10:45:17 +00:00
|
|
|
|
}
|
|
|
|
|
ret = _tab[col];
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPrint_section::offset(int& x, int& y)
|
|
|
|
|
{
|
|
|
|
|
if (x >= 0)
|
|
|
|
|
{
|
1995-12-15 11:35:47 +00:00
|
|
|
|
if (_columnwise) x = tab(x-1) + _ofspc;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
x += form().offset_x();
|
|
|
|
|
}
|
1995-08-31 15:16:13 +00:00
|
|
|
|
if (y >= 0) y += form().offset_y() + (_height * _repeat_count);
|
1995-01-09 16:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
TForm_item* TPrint_section::parse_item(const TString& s)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1994-12-20 15:11:26 +00:00
|
|
|
|
if (s == "ST")
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return new TForm_string(this);
|
1994-12-20 15:11:26 +00:00
|
|
|
|
if (s == "NU")
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return new TForm_number(this);
|
1994-12-20 15:11:26 +00:00
|
|
|
|
if (s == "DA")
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return new TForm_date(this);
|
1994-12-20 15:11:26 +00:00
|
|
|
|
if (s == "LI")
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return new TForm_list(this);
|
1995-01-02 09:33:00 +00:00
|
|
|
|
if (s == "GR")
|
|
|
|
|
return new TForm_group(this);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (s == "SE")
|
|
|
|
|
return new TForm_subsection(this);
|
1994-12-15 18:06:43 +00:00
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
yesnofatal_box("Campo di stampa non ammesso per la sezione di stampa: %s", (const char*)s);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
TForm_item* TPrint_section::parse_item(TScanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
return parse_item(scanner.key());
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TPrint_section::parse(TScanner& scanner)
|
|
|
|
|
{
|
1995-08-31 15:16:13 +00:00
|
|
|
|
_height = scanner.integer();
|
|
|
|
|
scanner.integer();scanner.integer(); // Eat offset X and Y of Print_section if present
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
if (scanner.popkey() == "CO") // COLUMNWISE attribute
|
|
|
|
|
_columnwise = TRUE;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_columnwise = FALSE;
|
|
|
|
|
scanner.push();
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
while (scanner.popkey() != "EN")
|
|
|
|
|
{
|
|
|
|
|
TForm_item *fi = parse_item(scanner);
|
1995-03-22 09:07:04 +00:00
|
|
|
|
if (fi == NULL) return FALSE;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
if (fi->parse(scanner))
|
|
|
|
|
_item.add(fi);
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-09 14:47:31 +00:00
|
|
|
|
// Azzera tutte le righe della sezione di stampa
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TPrint_section::reset()
|
|
|
|
|
{
|
|
|
|
|
for (word i = 0; i < height(); i++)
|
|
|
|
|
row(i).reset();
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-09 14:47:31 +00:00
|
|
|
|
// Aggiorna tutti i campi e li stampa
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TPrint_section::update()
|
|
|
|
|
{
|
|
|
|
|
bool ok = TRUE;
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
reset();
|
|
|
|
|
for (word i = 0; i < fields(); i++)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1994-12-20 15:11:26 +00:00
|
|
|
|
const bool esito = field(i).update();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (!esito) ok = FALSE;
|
|
|
|
|
}
|
1995-02-09 14:47:31 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return ok;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TPrint_section::read_from(const TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM");
|
|
|
|
|
|
|
|
|
|
bool changed = FALSE;
|
|
|
|
|
const word h = (word)prof.get_int("HGT");
|
|
|
|
|
if (_height != h)
|
|
|
|
|
{
|
|
|
|
|
_height = h;
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPrint_section::print_on(TRectype& prof)
|
|
|
|
|
{
|
|
|
|
|
CHECK(prof.num() == LF_RFORM, "Il record deve essere del file LF_RFORM");
|
|
|
|
|
prof.put("ID", 0);
|
1995-08-31 15:16:13 +00:00
|
|
|
|
prof.put("X", 0);
|
|
|
|
|
prof.put("Y", 0);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
prof.put("HGT", _height);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-08-31 15:16:13 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
char name_1[80]; // Fontname old
|
|
|
|
|
char name_2[80]; // Fontname new
|
|
|
|
|
int size_1; // size (height) of old font
|
|
|
|
|
int size_2; // size (height) of new font
|
|
|
|
|
double ratio; // ratio (width_old_font/width_new_font)
|
|
|
|
|
} s_data;
|
|
|
|
|
|
|
|
|
|
BOOLEAN XVT_CALLCONV1 wpr (long data)
|
|
|
|
|
{
|
|
|
|
|
s_data* st =(s_data*)data;
|
|
|
|
|
WINDOW prwin = xvt_print_create_win(printer().get_printrcd(),"");
|
|
|
|
|
long width_old,width_new;
|
|
|
|
|
TString spc(100);
|
|
|
|
|
spc.fill('m');
|
|
|
|
|
xvt_set_font(prwin,st->name_1, XVT_FS_NONE, st->size_1);
|
|
|
|
|
width_old = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 100);
|
|
|
|
|
xvt_set_font(prwin,st->name_2, XVT_FS_NONE, st->size_2);
|
|
|
|
|
width_new = xvt_dwin_get_text_width(prwin,(char*)(const char*)spc, 100);
|
|
|
|
|
st->ratio = (double)width_old / (double)width_new;
|
|
|
|
|
xvt_vobj_destroy(prwin);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1995-12-14 10:45:17 +00:00
|
|
|
|
|
|
|
|
|
bool TPrint_section::special_field_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE && _special_mask != NULL)
|
|
|
|
|
_special_mask->run();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handlers for section editing
|
|
|
|
|
bool TPrint_section::detail_field_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
// to avoid kasinations with recursion
|
|
|
|
|
TPrint_section& section = ::section();
|
|
|
|
|
TSheet_field& ms = *f.mask().get_sheet();
|
|
|
|
|
int field = ms.selected();
|
|
|
|
|
TToken_string& tt = ms.row(field);
|
|
|
|
|
|
|
|
|
|
TMask msk("ba2100f");
|
|
|
|
|
|
|
|
|
|
msk.set_handler(F_DFORMAT, dateformat_handler);
|
|
|
|
|
msk.set_handler(F_DYEAR, dateformat_handler);
|
|
|
|
|
msk.set_handler(F_DMONTH, dateformat_handler);
|
|
|
|
|
msk.set_handler(F_DDAY, dateformat_handler);
|
|
|
|
|
msk.set_handler(F_DSEP, dateformat_handler);
|
|
|
|
|
|
|
|
|
|
msk.set_handler(F_BUT_FILE1, but_file_handler);
|
|
|
|
|
msk.set_handler(F_BUT_FIELD1, but_field_handler);
|
|
|
|
|
msk.set_handler(F_FROM1, from_handler);
|
|
|
|
|
msk.set_handler(F_TO1, to_handler);
|
|
|
|
|
msk.set_handler(F_BUT_FILE2, but_file_handler);
|
|
|
|
|
msk.set_handler(F_BUT_FIELD2, but_field_handler);
|
|
|
|
|
msk.set_handler(F_FROM2, from_handler);
|
|
|
|
|
msk.set_handler(F_TO2, to_handler);
|
|
|
|
|
|
|
|
|
|
// TBI set_mode etc, vedi sotto
|
|
|
|
|
|
|
|
|
|
// gna'
|
|
|
|
|
TForm_item& fi = section.field(field);
|
|
|
|
|
|
|
|
|
|
msk.enable(F_OPTIONS, fi.special_items() > 0);
|
|
|
|
|
|
|
|
|
|
// build option mask
|
|
|
|
|
if (fi.special_items() > 0)
|
|
|
|
|
{
|
|
|
|
|
msk.set_handler(F_OPTIONS, special_field_handler);
|
|
|
|
|
|
|
|
|
|
CHECK(fi.special_items() < 18, "Ostia, quanti special! Non ho nessuna voglia di "
|
|
|
|
|
" farti una maschera a piu' pagine per sta cagata. Ripensaci e riprova");
|
|
|
|
|
|
|
|
|
|
_special_mask = new TMask("Variabili personalizzate", 1, 78, fi.special_items() + 3);
|
|
|
|
|
_special_mask->add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
|
|
|
|
_special_mask->add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
|
|
|
|
fi.specials().restart();
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < fi.special_items(); k++)
|
|
|
|
|
{
|
|
|
|
|
THash_object* ho = fi.specials().get_hashobj();
|
|
|
|
|
TToken_string& tt = (TToken_string&)(ho->obj());
|
|
|
|
|
TString type = tt.get(0);
|
|
|
|
|
TString val = tt.get(1);
|
|
|
|
|
TToken_string des(tt.get(2),'/');
|
|
|
|
|
TString prompt(des.get(0));
|
|
|
|
|
|
|
|
|
|
if (type == "STRINGA")
|
|
|
|
|
{
|
|
|
|
|
_special_mask->add_string(101+k, 0, prompt, 1, k+1, des.get_int(1),"");
|
|
|
|
|
_special_mask->set(101+k, val);
|
|
|
|
|
}
|
|
|
|
|
else if (type == "NUMERO")
|
|
|
|
|
{
|
|
|
|
|
_special_mask->add_number(101+k, 0, prompt, 1, k+1, des.get_int(1),"",des.get_int(2));
|
|
|
|
|
_special_mask->set(101+k, val);
|
|
|
|
|
}
|
|
|
|
|
else if (type == "LISTA")
|
|
|
|
|
{
|
|
|
|
|
TToken_string codes(128);
|
|
|
|
|
TToken_string value(128);
|
|
|
|
|
|
|
|
|
|
for (int jj = 2; jj < des.items(); jj++)
|
|
|
|
|
{
|
|
|
|
|
CHECK (jj < (des.items() - 1), "AAARGH! LISTA special fatta col CULO!");
|
|
|
|
|
TString t1(des.get(jj++));
|
|
|
|
|
TString t2(des.get(jj));
|
|
|
|
|
codes.add(t1);
|
|
|
|
|
value.add(t2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_special_mask->add_list(101+k, 0, prompt, 1, k+1, des.get_int(1), "", codes, value);
|
|
|
|
|
_special_mask->set(101+k, val);
|
|
|
|
|
}
|
|
|
|
|
else if (type == "BOOLEAN")
|
|
|
|
|
{
|
|
|
|
|
_special_mask->add_boolean(101+k, 0, prompt, 1, k+1);
|
|
|
|
|
_special_mask->set(101+k, val);
|
|
|
|
|
}
|
|
|
|
|
else if (type == "DATA")
|
|
|
|
|
{
|
|
|
|
|
_special_mask->add_date(101+k, 0, prompt, 1, k+1);
|
|
|
|
|
_special_mask->set(101+k, val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fi.edit(msk);
|
|
|
|
|
|
|
|
|
|
// check specials
|
|
|
|
|
if (_special_mask != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (_special_mask->last_key() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
fi.specials().restart();
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < fi.special_items(); k++)
|
|
|
|
|
{
|
|
|
|
|
THash_object* ho = fi.specials().get_hashobj();
|
|
|
|
|
TToken_string& tt = (TToken_string&)(ho->obj());
|
|
|
|
|
TString val = tt.get(1);
|
|
|
|
|
TString nvl = _special_mask->get(k + 101);
|
|
|
|
|
if (nvl != val)
|
|
|
|
|
{
|
|
|
|
|
tt.add(nvl, 1);
|
|
|
|
|
if (tt.items() == 3) tt.add("X");
|
|
|
|
|
fi.set_dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete _special_mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// reset stominchione
|
|
|
|
|
fi.print_on_sheet_row(tt);
|
|
|
|
|
|
|
|
|
|
ms.force_update();
|
|
|
|
|
|
|
|
|
|
_cur_sect = §ion;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
bool TPrint_section::detail_field_notify (TSheet_field& s, int r, KEY k)
|
|
|
|
|
{
|
|
|
|
|
TPrint_section& sec = ::section();
|
|
|
|
|
if (k == K_DEL || k == K_INS)
|
|
|
|
|
{
|
|
|
|
|
if (::form().edit_level() <= 1)
|
|
|
|
|
return FALSE;
|
|
|
|
|
if (k == K_DEL)
|
|
|
|
|
{
|
|
|
|
|
// elimina campo
|
|
|
|
|
sec.destroy_field(r);
|
|
|
|
|
sec.set_dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (k == (K_INS + K_CTRL))
|
|
|
|
|
{
|
|
|
|
|
// new field: set defaults and create field
|
|
|
|
|
TForm_string* f = new TForm_string(&sec);
|
|
|
|
|
sec.insert_field(r, f);
|
|
|
|
|
TToken_string& tt = s.row(r);
|
|
|
|
|
f->print_on_sheet_row(tt);
|
|
|
|
|
tt.add("Nuovo campo", sec.columnwise() ? int_id : dsc_id);
|
|
|
|
|
if (sec.columnwise()) tt.add(r+1, col_id - 101);
|
|
|
|
|
s.force_update();
|
|
|
|
|
sec.set_dirty();
|
|
|
|
|
}
|
|
|
|
|
else if (k == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
// modify field
|
|
|
|
|
TForm_item* fld = &sec.field(r);
|
|
|
|
|
TToken_string& tt = s.row(r);
|
|
|
|
|
|
|
|
|
|
if (sec.columnwise() && ((word)tt.get_int(col_id - 101) <= 0 ||
|
|
|
|
|
(word)tt.get_int(col_id - 101) > sec.fields()))
|
|
|
|
|
{
|
|
|
|
|
warning_box("Numero di colonna non accettabile (deve essere da 1 a %u)", sec.fields());
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ??? type changed ???
|
|
|
|
|
if (strcmp(tt.get(typ_id - 101), fld->class_name()) != 0)
|
|
|
|
|
{
|
|
|
|
|
// so'ccazzi: crea nuovo campo del tipo dato e
|
|
|
|
|
// copia gli special (e il resto)
|
|
|
|
|
TString typ(tt.get(typ_id - 101));
|
|
|
|
|
TForm_item* fff = NULL;
|
|
|
|
|
if (typ == "NUMERO")
|
|
|
|
|
fff = new TForm_number(&sec);
|
|
|
|
|
else if (typ == "STRINGA")
|
|
|
|
|
fff = new TForm_string(&sec);
|
|
|
|
|
else if (typ == "DATA")
|
|
|
|
|
fff = new TForm_date(&sec);
|
|
|
|
|
else if (typ == "LISTA")
|
|
|
|
|
fff = new TForm_list(&sec);
|
|
|
|
|
else if (typ == "GRUPPO")
|
|
|
|
|
fff = new TForm_group(&sec);
|
|
|
|
|
else if (typ == "LINEA")
|
|
|
|
|
fff = new TForm_line((TGraphic_section*)&sec);
|
1995-12-15 11:35:47 +00:00
|
|
|
|
else if (typ == "BOX")
|
|
|
|
|
fff = new TForm_box((TGraphic_section*)&sec);
|
1995-12-14 10:45:17 +00:00
|
|
|
|
else if (typ == "FIGURA")
|
|
|
|
|
fff = new TForm_picture((TGraphic_section*)&sec);
|
|
|
|
|
|
|
|
|
|
// copia SPECIALS
|
|
|
|
|
TAssoc_array& aa = fld->specials();
|
|
|
|
|
TAssoc_array& bb = fff->specials();
|
|
|
|
|
THash_object* oo = NULL;
|
|
|
|
|
aa.restart();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < aa.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
oo = aa.get_hashobj();
|
|
|
|
|
bb.add(oo->key(), oo->obj());
|
|
|
|
|
}
|
|
|
|
|
sec.change_field(r, fld = fff);
|
|
|
|
|
fld->set_dirty();
|
|
|
|
|
}
|
|
|
|
|
// modifica valori
|
|
|
|
|
fld->read_from(tt);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
bool TPrint_section::edit(const char* title)
|
1995-05-18 14:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
_cur_form = _form;
|
1995-12-14 10:45:17 +00:00
|
|
|
|
_cur_sect = this;
|
|
|
|
|
|
1995-06-07 10:47:05 +00:00
|
|
|
|
if (!_subsection)
|
1995-01-09 16:51:21 +00:00
|
|
|
|
{
|
1995-06-07 10:47:05 +00:00
|
|
|
|
TMask m("ba2100s");
|
|
|
|
|
m.set_caption(title);
|
|
|
|
|
m.set(F_HEIGHT, _height);
|
1995-08-31 15:16:13 +00:00
|
|
|
|
m.set(F_X, form().offset_x());
|
1995-10-27 08:28:13 +00:00
|
|
|
|
m.set(F_Y, form().offset_y());
|
|
|
|
|
m.set(F_CTP, format("%c",form().char_to_pos()));
|
|
|
|
|
m.set(F_IPX, form().ipx());
|
|
|
|
|
m.set(F_IPY, form().ipy());
|
|
|
|
|
m.set(F_FPX, form().fpx());
|
1995-10-16 17:52:24 +00:00
|
|
|
|
m.set(F_FLEN, printer().formlen());
|
1995-12-15 11:35:47 +00:00
|
|
|
|
m.set(F_OFSPC, _ofspc);
|
|
|
|
|
|
|
|
|
|
// still unused: will need to be shown if section is columnwise; no
|
|
|
|
|
// provision for saving yet (should be in form, with a field for each pos)
|
|
|
|
|
m.hide(F_OFSPC);
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
TSheet_field& ms = (TSheet_field&)m.field(F_FIELDS);
|
1995-06-07 10:47:05 +00:00
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
if (_columnwise)
|
1995-08-31 15:16:13 +00:00
|
|
|
|
{
|
1995-12-14 10:45:17 +00:00
|
|
|
|
ms.delete_column(dsc_id); ms.sheet_mask().hide(dsc_id);
|
|
|
|
|
ms.delete_column(xps_id); ms.sheet_mask().hide(xps_id);
|
|
|
|
|
ms.delete_column(yps_id); ms.sheet_mask().hide(yps_id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ms.delete_column(int_id); ms.sheet_mask().hide(int_id);
|
|
|
|
|
ms.delete_column(len_id); ms.sheet_mask().hide(len_id);
|
|
|
|
|
ms.delete_column(col_id); ms.sheet_mask().hide(col_id);
|
|
|
|
|
ms.delete_column(spc_id); ms.sheet_mask().hide(spc_id);
|
|
|
|
|
ms.delete_column(fnl_id); ms.sheet_mask().hide(fnl_id);
|
|
|
|
|
ms.delete_column(fnr_id); ms.sheet_mask().hide(fnr_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ms.enable_column(frm_id - 101, FALSE);
|
|
|
|
|
|
|
|
|
|
if (form().edit_level() <= 1)
|
|
|
|
|
{
|
|
|
|
|
ms.enable_column(idt_id - 101, FALSE);
|
|
|
|
|
ms.enable_column(typ_id - 101, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// handlers
|
|
|
|
|
ms.set_notify(detail_field_notify);
|
|
|
|
|
ms.sheet_mask().set_handler(100, detail_field_handler);
|
|
|
|
|
|
|
|
|
|
TToken_string tt(128);
|
|
|
|
|
|
|
|
|
|
// fill sheet
|
|
|
|
|
for (word i = 0; i < fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& f = field(i);
|
|
|
|
|
field(i).print_on_sheet_row(tt);
|
|
|
|
|
ms.row(-1) = tt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const int MAX_FAMILIES = 128;
|
|
|
|
|
char* family[MAX_FAMILIES];
|
|
|
|
|
const int num_families = (int)xvt_fmap_get_families(printer().get_printrcd(), family, MAX_FAMILIES);
|
|
|
|
|
bool font_found = FALSE;
|
|
|
|
|
TToken_string pn1(256), pn2(256);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < num_families; i++)
|
|
|
|
|
{
|
|
|
|
|
pn1.add(family[i]);
|
|
|
|
|
pn2.add(family[i]);
|
|
|
|
|
if (!font_found)
|
|
|
|
|
if (form().fontname() == family[i]) font_found = TRUE;
|
|
|
|
|
xvt_mem_free(family[i]);
|
|
|
|
|
}
|
|
|
|
|
TList_field& lst = (TList_field&)m.field(F_FONT);
|
|
|
|
|
lst.replace_items(pn1, pn2);
|
|
|
|
|
if (!font_found) warning_box("Il font %s non esiste per la stampante di default.",(const char*) form().fontname());
|
|
|
|
|
lst.set(form().fontname());
|
|
|
|
|
}
|
|
|
|
|
|
1995-08-31 15:16:13 +00:00
|
|
|
|
printer().set_char_size(form().fontsize());
|
|
|
|
|
m.set_handler(F_FONT,font_handler);
|
1995-06-07 10:47:05 +00:00
|
|
|
|
if (m.run() == K_ESC)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
bool dirty = m.dirty() != 0;
|
|
|
|
|
|
|
|
|
|
if (dirty)
|
|
|
|
|
{
|
1995-08-31 15:16:13 +00:00
|
|
|
|
if (_height != (word)m.get_int(F_HEIGHT) )
|
|
|
|
|
{
|
|
|
|
|
_height = m.get_int(F_HEIGHT);
|
|
|
|
|
_dirty=TRUE;
|
|
|
|
|
}
|
1995-12-15 11:35:47 +00:00
|
|
|
|
if (_ofspc != (word)m.get_int(F_OFSPC) )
|
|
|
|
|
{
|
|
|
|
|
_ofspc = m.get_int(F_OFSPC);
|
|
|
|
|
_dirty=TRUE;
|
|
|
|
|
}
|
1995-08-31 15:16:13 +00:00
|
|
|
|
if (m.get_int(F_X) != form().offset_x() || m.get_int(F_Y) != form().offset_y())
|
|
|
|
|
{
|
|
|
|
|
form().offset_x() = m.get_int(F_X);
|
|
|
|
|
form().offset_y() = m.get_int(F_Y);
|
|
|
|
|
form().set_dirty();
|
|
|
|
|
_dirty = TRUE;
|
1995-10-27 08:28:13 +00:00
|
|
|
|
}
|
1995-11-13 08:18:10 +00:00
|
|
|
|
if (m.get(F_CTP)[0] != form().char_to_pos() ||
|
|
|
|
|
m.get_int(F_IPX) != form().ipx() ||
|
|
|
|
|
m.get_int(F_IPY) != form().ipy() ||
|
1995-11-13 08:27:45 +00:00
|
|
|
|
m.get_int(F_IPX) != form().fpx())
|
1995-10-27 08:28:13 +00:00
|
|
|
|
{
|
|
|
|
|
form().char_to_pos() = m.get(F_CTP)[0];
|
|
|
|
|
form().ipx() = m.get_int(F_IPX);
|
|
|
|
|
form().ipy() = m.get_int(F_IPY);
|
|
|
|
|
form().fpx() = m.get_int(F_FPX);
|
|
|
|
|
_dirty = TRUE;
|
1995-08-31 15:16:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TString80 name(m.get(F_FONT));
|
|
|
|
|
int size = m.get_int(F_SIZE);
|
|
|
|
|
if (name != form().fontname() || size != form().fontsize())
|
|
|
|
|
{
|
|
|
|
|
if (!form().dirty()) form().set_dirty();
|
|
|
|
|
_dirty = TRUE;
|
|
|
|
|
s_data prm;
|
|
|
|
|
prm.size_1=form().fontsize();
|
|
|
|
|
strcpy(prm.name_1,form().fontname());
|
|
|
|
|
prm.size_2=size;
|
|
|
|
|
strcpy(prm.name_2,name);
|
|
|
|
|
prm.ratio = 1.0;
|
|
|
|
|
// Next 3 lines may be changed
|
|
|
|
|
xvt_print_open();
|
|
|
|
|
xvt_print_start_thread (wpr, (long)&prm);
|
|
|
|
|
xvt_print_close();
|
|
|
|
|
|
|
|
|
|
form().fontname() = name;
|
|
|
|
|
form().fontsize() = size;
|
|
|
|
|
const char sechar[4] = { 'B', 'F', 'G', 'H' };
|
|
|
|
|
for (int sn = 0; sn < 4 ; sn++)
|
|
|
|
|
{
|
|
|
|
|
const char sc = sechar[sn];
|
|
|
|
|
for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1))
|
|
|
|
|
{
|
|
|
|
|
TPrint_section* sec = form().exist(sc, pt);
|
|
|
|
|
if (sec != NULL)
|
|
|
|
|
{
|
|
|
|
|
sec->set_dirty();
|
|
|
|
|
for (word i = 0; i < sec->fields() ; i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& fi = sec->field(i);
|
|
|
|
|
if (fi.x() > 0 && (prm.ratio != 1.0))
|
|
|
|
|
{
|
|
|
|
|
real x_pos;
|
|
|
|
|
x_pos = fi.x() * prm.ratio;
|
|
|
|
|
x_pos.round();
|
|
|
|
|
fi.x() = (short)x_pos.integer();
|
|
|
|
|
fi.set_dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-06-07 10:47:05 +00:00
|
|
|
|
}
|
1995-01-09 16:51:21 +00:00
|
|
|
|
}
|
1995-11-13 08:18:10 +00:00
|
|
|
|
|
1995-11-13 14:49:46 +00:00
|
|
|
|
if ((_dirty || form()._isnew) && yesno_box("Dati generali modificati. Salvare?"))
|
1995-11-13 08:18:10 +00:00
|
|
|
|
{
|
|
|
|
|
TLocalisamfile frm(LF_FORM);
|
|
|
|
|
frm.zero();
|
|
|
|
|
frm.put("TIPOPROF",form().name());
|
|
|
|
|
frm.put("CODPROF",form().code());
|
|
|
|
|
if (frm.read(_isequal,_lock) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
frm.put("OFFY",form().offset_y());
|
|
|
|
|
frm.put("OFFX",form().offset_x());
|
|
|
|
|
frm.put("FONTNAME",form().fontname());
|
|
|
|
|
frm.put("FONTSIZE",form().fontsize());
|
|
|
|
|
frm.put("CTP",form().char_to_pos());
|
|
|
|
|
frm.put("IPX", form().ipx());
|
|
|
|
|
frm.put("IPY", form().ipy());
|
|
|
|
|
frm.put("FPX", form().fpx());
|
|
|
|
|
frm.rewrite();
|
|
|
|
|
_dirty = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-14 10:45:17 +00:00
|
|
|
|
if (!_dirty)
|
|
|
|
|
for (word j = 0; j < fields(); j++)
|
|
|
|
|
_dirty |= field(j).dirty();
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-06-07 10:47:05 +00:00
|
|
|
|
set_dirty(_dirty);
|
|
|
|
|
return _dirty;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPrint_section::print_on(ostream& out) const
|
1995-05-18 14:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
out << ' ';
|
|
|
|
|
switch (page_type())
|
|
|
|
|
{
|
|
|
|
|
case even_page:
|
|
|
|
|
out << "EVEN"; break;
|
|
|
|
|
case first_page:
|
|
|
|
|
out << "FIRST"; break;
|
|
|
|
|
case last_page:
|
|
|
|
|
out << "LAST"; break;
|
|
|
|
|
default:
|
|
|
|
|
out << "ODD"; break;
|
|
|
|
|
}
|
1995-12-14 10:45:17 +00:00
|
|
|
|
out << ' ' << _height;
|
|
|
|
|
if (_columnwise) out << " COLUMNWISE";
|
|
|
|
|
out << endl << endl;
|
1994-12-20 15:11:26 +00:00
|
|
|
|
for(word i = 0; i < fields(); i++)
|
|
|
|
|
out << field(i);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
TForm_item& TPrint_section::find_field(short id) const
|
|
|
|
|
{
|
|
|
|
|
for(word i = 0; i < fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& f = field(i);
|
|
|
|
|
if (f.id() == id) return f;
|
|
|
|
|
}
|
1995-12-15 11:54:24 +00:00
|
|
|
|
yesnofatal_box("Can't find item with id %d", id);
|
1995-05-18 14:18:01 +00:00
|
|
|
|
return field(0);
|
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TForm
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
1995-12-14 14:30:58 +00:00
|
|
|
|
TForm_editor& TForm::editor() const
|
|
|
|
|
{ return (TForm_editor&)main_app(); }
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
bool TForm::parse_use(TScanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
const int logicnum = scanner.integer();
|
|
|
|
|
const char* tab = NULL;
|
|
|
|
|
|
|
|
|
|
if (logicnum > 0)
|
|
|
|
|
_relation = new TRelation(logicnum);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tab = scanner.pop();
|
|
|
|
|
_relation = new TRelation(tab);
|
|
|
|
|
}
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
int key = 1;
|
|
|
|
|
if (scanner.popkey() == "KE")
|
|
|
|
|
key = scanner.integer();
|
1994-12-27 14:59:25 +00:00
|
|
|
|
else
|
|
|
|
|
scanner.push();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-05-09 09:12:26 +00:00
|
|
|
|
_cursor = new TCursor(_relation, "", key);
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TForm::parse_join(TScanner& scanner)
|
|
|
|
|
{
|
1994-12-27 14:59:25 +00:00
|
|
|
|
TString16 j(scanner.pop()); // File or table
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
int to = 0;
|
|
|
|
|
if (scanner.popkey() == "TO") // TO keyword
|
|
|
|
|
{
|
|
|
|
|
const char* n = scanner.pop();
|
|
|
|
|
to = name2log(n);
|
|
|
|
|
}
|
|
|
|
|
else scanner.push();
|
|
|
|
|
|
|
|
|
|
int key = 1;
|
|
|
|
|
if (scanner.popkey() == "KE")
|
|
|
|
|
key = scanner.integer();
|
|
|
|
|
else scanner.push();
|
|
|
|
|
|
|
|
|
|
int alias = 0;
|
|
|
|
|
if (scanner.popkey() == "AL")
|
|
|
|
|
alias = scanner.integer();
|
|
|
|
|
else scanner.push();
|
|
|
|
|
|
|
|
|
|
TToken_string exp(80);
|
|
|
|
|
if (scanner.pop() == "INTO")
|
|
|
|
|
{
|
|
|
|
|
const char* r = scanner.pop();
|
|
|
|
|
while (strchr(r, '=') != NULL)
|
|
|
|
|
{
|
|
|
|
|
exp.add(r);
|
|
|
|
|
r = scanner.pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
1994-12-15 18:06:43 +00:00
|
|
|
|
if (exp.empty())
|
|
|
|
|
yesnofatal_box("JOIN senza espressioni INTO");
|
1994-11-10 14:17:03 +00:00
|
|
|
|
scanner.push();
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (isdigit(j[0]))
|
|
|
|
|
_relation->add(atoi(j), exp, key, to, alias); // join file
|
|
|
|
|
else
|
|
|
|
|
_relation->add(j, exp, key, to, alias); // join table
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TRelation_description& TForm::rel_desc() const
|
|
|
|
|
{
|
|
|
|
|
CHECK(_rel_desc, "No relation description");
|
|
|
|
|
return *_rel_desc;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
bool TForm::parse_description(TScanner& scanner)
|
1995-05-09 09:12:26 +00:00
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (edit_level() > 0)
|
|
|
|
|
{
|
|
|
|
|
CHECK(_rel_desc == NULL, "Can't parse descriptions two times");
|
|
|
|
|
_rel_desc = new TRelation_description(*_relation);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
bool ok = scanner.popkey() == "DE";
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
if (edit_level() > 0)
|
|
|
|
|
{
|
|
|
|
|
scanner.popkey(); // eat BEGIN
|
|
|
|
|
TFieldref fld;
|
|
|
|
|
while (scanner.pop() != "END")
|
|
|
|
|
{
|
|
|
|
|
fld = scanner.token();
|
|
|
|
|
_rel_desc->set_cur_file(fld.file());
|
|
|
|
|
if (fld.name() == "*")
|
|
|
|
|
_rel_desc->file_desc(scanner.string());
|
|
|
|
|
else
|
|
|
|
|
_rel_desc->set_field_description(fld.name(), scanner.string());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (scanner.line() != "END");
|
|
|
|
|
ok = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else scanner.push();
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm::print_description(ostream& out) const
|
|
|
|
|
{
|
|
|
|
|
out << "DESCRIPTION\nBEGIN\n";
|
|
|
|
|
out << rel_desc();
|
|
|
|
|
out << "END\n" << endl;
|
1995-05-09 09:12:26 +00:00
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-08-31 15:16:13 +00:00
|
|
|
|
bool TForm::parse_general(TScanner &scanner)
|
|
|
|
|
{
|
|
|
|
|
bool ok = scanner.popkey() == "GE";
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
while (scanner.pop() != "END")
|
|
|
|
|
{
|
|
|
|
|
if (scanner.popkey() == "OF") // Offsets
|
|
|
|
|
{
|
|
|
|
|
_x = scanner.integer();
|
|
|
|
|
_y = scanner.integer();
|
|
|
|
|
}
|
|
|
|
|
else scanner.push();
|
|
|
|
|
if (scanner.popkey() == "FO") // Font name
|
|
|
|
|
_fontname = scanner.string();
|
|
|
|
|
else scanner.push();
|
|
|
|
|
if (scanner.popkey() == "SI") // Font size
|
|
|
|
|
_fontsize = scanner.integer();
|
1995-10-27 08:28:13 +00:00
|
|
|
|
else scanner.push();
|
|
|
|
|
if (scanner.popkey() == "CA") // Carattere di posizionamento
|
|
|
|
|
_char_to_pos = scanner.string()[0];
|
|
|
|
|
else scanner.push();
|
|
|
|
|
if (scanner.popkey() == "IN") // Riga e colonna del posizionamento iniziale
|
|
|
|
|
{
|
|
|
|
|
_ipx = scanner.integer();
|
|
|
|
|
_ipy = scanner.integer();
|
|
|
|
|
}
|
|
|
|
|
else scanner.push();
|
|
|
|
|
if (scanner.popkey() == "FI") // Riga e colonna del posizionamento finale
|
|
|
|
|
{
|
|
|
|
|
_fpx = scanner.integer();
|
|
|
|
|
}
|
|
|
|
|
else scanner.push();
|
1995-11-21 10:39:05 +00:00
|
|
|
|
|
|
|
|
|
if (scanner.popkey() == "GR") // Carattere di posizionamento
|
|
|
|
|
_fink = scanner.string();
|
|
|
|
|
else scanner.push();
|
1995-10-27 08:28:13 +00:00
|
|
|
|
|
1995-10-09 15:42:33 +00:00
|
|
|
|
extended_parse_general(scanner); // Parse non-standard parameters
|
1995-08-31 15:16:13 +00:00
|
|
|
|
}
|
|
|
|
|
} else scanner.push();
|
|
|
|
|
|
|
|
|
|
return (ok);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm::print_general(ostream& out) const
|
|
|
|
|
{
|
|
|
|
|
out << "GENERAL\nBEGIN\n";
|
|
|
|
|
out << " OFFSET " << _x << " " << _y << "\n";
|
|
|
|
|
out << " FONT " << "\"" << _fontname << "\"\n";
|
1995-10-27 08:28:13 +00:00
|
|
|
|
out << " SIZE " << _fontsize << "\n" ;
|
|
|
|
|
if (_char_to_pos != '\0')
|
|
|
|
|
{
|
1995-11-14 14:19:37 +00:00
|
|
|
|
out << " CARATTERE \"" << _char_to_pos << "\"\n" ;
|
1995-10-27 08:28:13 +00:00
|
|
|
|
out << " INIZIO_POS " << _ipx << " " << _ipy << "\n";
|
|
|
|
|
out << " FINE_POS " << _fpx << "\n";
|
1995-11-21 10:39:05 +00:00
|
|
|
|
}
|
|
|
|
|
out << " GRID \"" << (const char*)_fink << "\"\n";
|
1995-08-31 15:16:13 +00:00
|
|
|
|
out << "END\n" << endl;
|
|
|
|
|
}
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
1994-12-28 11:01:33 +00:00
|
|
|
|
TPrint_section* TForm::exist(char s, pagetype t, bool create)
|
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TArray* a;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
switch (toupper(s))
|
1994-12-28 11:01:33 +00:00
|
|
|
|
{
|
|
|
|
|
case 'F':
|
|
|
|
|
a = &_foot; break;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
case 'G':
|
|
|
|
|
a = &_back; break;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
case 'H':
|
|
|
|
|
a = &_head; break;
|
1994-12-28 11:01:33 +00:00
|
|
|
|
default:
|
|
|
|
|
a = &_body; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TPrint_section* sec = (TPrint_section*)a->objptr(t);
|
|
|
|
|
if (sec == NULL && create)
|
|
|
|
|
{
|
1995-07-19 09:57:25 +00:00
|
|
|
|
sec = (s == 'G') ? new TGraphic_section(this, t) : new TPrint_section(this, s, t);
|
1994-12-28 11:01:33 +00:00
|
|
|
|
a->add(sec, t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sec;
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
TForm_item& TForm::find_field(char s, pagetype t, short id) const
|
|
|
|
|
{
|
|
|
|
|
const TPrint_section* ps = ((TForm*)this)->exist(s, t);
|
|
|
|
|
CHECKD(ps, "Can't find section for field %d", id);
|
|
|
|
|
return ps->find_field(id);
|
|
|
|
|
}
|
1994-12-28 11:01:33 +00:00
|
|
|
|
|
1995-12-14 08:00:27 +00:00
|
|
|
|
TPrint_section& TForm::section(char s, pagetype pos)
|
1994-12-20 15:11:26 +00:00
|
|
|
|
{
|
1994-12-28 11:01:33 +00:00
|
|
|
|
TPrint_section* sec = exist(s, pos, TRUE);
|
1994-12-27 14:59:25 +00:00
|
|
|
|
return *sec;
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
1995-12-14 08:00:27 +00:00
|
|
|
|
|
|
|
|
|
TPrint_section& TForm::section(char s, word pagenum)
|
|
|
|
|
{
|
|
|
|
|
pagetype pt = odd_page;
|
|
|
|
|
if (pagenum == 0 && exist(s, last_page))
|
|
|
|
|
pt = last_page;
|
|
|
|
|
if (pagenum == 1 && exist(s, first_page))
|
|
|
|
|
pt = first_page;
|
|
|
|
|
if (pt == odd_page && (pagenum & 0x1) == 0 && exist(s, even_page))
|
|
|
|
|
pt = even_page;
|
|
|
|
|
|
|
|
|
|
return section(s, pt);
|
|
|
|
|
}
|
|
|
|
|
|
1995-11-24 09:54:06 +00:00
|
|
|
|
|
|
|
|
|
// ===========================================
|
|
|
|
|
// TForm
|
|
|
|
|
// ===========================================
|
|
|
|
|
|
|
|
|
|
bool TForm::ps_change_date_format(TPrint_section& s, const char* f)
|
|
|
|
|
{
|
|
|
|
|
for (word i = 0; i < s.fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& fi = s.field(i);
|
|
|
|
|
if (strcmp(fi.class_name(), "SEZIONE") == 0)
|
|
|
|
|
{
|
|
|
|
|
TPrint_section& ps = ((TForm_subsection&)fi).subsection();
|
|
|
|
|
ps_change_date_format(ps, f);
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(fi.class_name(), "DATA") == 0)
|
|
|
|
|
((TForm_date&)fi).set_format(f);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm::ps_change_number_format(TPrint_section& s, int w, int dec, const char* p)
|
|
|
|
|
{
|
|
|
|
|
for (word i = 0; i < s.fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& fi = s.field(i);
|
|
|
|
|
if (strcmp(fi.class_name(), "SEZIONE") == 0)
|
|
|
|
|
{
|
|
|
|
|
TPrint_section& ps = ((TForm_subsection&)fi).subsection();
|
|
|
|
|
ps_change_number_format(ps, w, dec, p);
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(fi.class_name(), "NUMERO") == 0)
|
|
|
|
|
{
|
|
|
|
|
TForm_number& fn = (TForm_number&)fi;
|
1995-12-15 11:35:47 +00:00
|
|
|
|
fn.width() = w;
|
1995-11-24 09:54:06 +00:00
|
|
|
|
fn.set_decimals(dec);
|
|
|
|
|
fn.set_picture(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TForm::change_date_format(const char* f)
|
|
|
|
|
{
|
|
|
|
|
char secs[] = { "FHGB" };
|
|
|
|
|
char ptyp[] = { "LOEF" };
|
|
|
|
|
TPrint_section* ps;
|
|
|
|
|
|
|
|
|
|
for (int sc = 0; sc < 4; sc++)
|
|
|
|
|
for (int pt = 0; pt < 4; pt++)
|
|
|
|
|
if ((ps = exist(secs[sc], char2page(ptyp[pt]), FALSE)) != NULL)
|
|
|
|
|
ps_change_date_format(*ps, f);
|
|
|
|
|
}
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-11-24 09:54:06 +00:00
|
|
|
|
void TForm::change_number_format(int w, int dec, const char* p)
|
|
|
|
|
{
|
|
|
|
|
char secs[] = { "FHGB" };
|
|
|
|
|
char ptyp[] = { "LOEF" };
|
|
|
|
|
TPrint_section* ps;
|
|
|
|
|
|
|
|
|
|
for (int sc = 0; sc < 4; sc++)
|
|
|
|
|
for (int pt = 0; pt < 4; pt++)
|
|
|
|
|
if ((ps = exist(secs[sc], char2page(ptyp[pt]), FALSE)) != NULL)
|
|
|
|
|
ps_change_number_format(*ps, w, dec, p);
|
|
|
|
|
}
|
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
word TForm::set_background(word p, bool u)
|
|
|
|
|
{
|
|
|
|
|
word len = 0;
|
|
|
|
|
|
|
|
|
|
if (u && _back.items())
|
|
|
|
|
{
|
|
|
|
|
TPrint_section& graph = section('G', p);
|
|
|
|
|
graph.update();
|
1995-04-20 14:35:14 +00:00
|
|
|
|
len = printer().formlen();
|
1995-03-22 09:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
}
|
1994-12-28 11:01:33 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
word TForm::set_header(word p, bool u)
|
1995-03-22 09:07:04 +00:00
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
|
TPrinter& pr = printer();
|
|
|
|
|
pr.resetheader();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
TPrint_section& head = section('H', p);
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
if (u) head.update();
|
1994-12-27 14:59:25 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
head.reset();
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.headerlen(head.height());
|
1994-12-27 14:59:25 +00:00
|
|
|
|
}
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
for (word j = 0; j < head.height(); j++)
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.setheaderline(j, head.row(j));
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
return head.height();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
word TForm::set_body(word p, bool u)
|
|
|
|
|
{
|
1994-12-27 14:59:25 +00:00
|
|
|
|
TPrint_section& body = section('B', p);
|
1994-12-28 11:01:33 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
if (u) body.update();
|
|
|
|
|
else body.reset();
|
|
|
|
|
|
|
|
|
|
if (u)
|
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
|
TPrinter& pr = printer();
|
1994-12-20 15:11:26 +00:00
|
|
|
|
for (word j = 0; j < body.height(); j++)
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.print(body.row(j));
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return body.height();
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
word TForm::set_footer(word p, bool u)
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
|
TPrinter& pr = printer();
|
|
|
|
|
pr.resetfooter();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
TPrint_section& foot = section('F', p);
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
if (u) foot.update();
|
1994-12-27 14:59:25 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foot.reset();
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.footerlen(foot.height());
|
1994-12-27 14:59:25 +00:00
|
|
|
|
}
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
for (word j = 0; j < foot.height(); j++)
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.setfooterline(j, foot.row(j));
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
return foot.height();
|
|
|
|
|
}
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
void TForm::header_handler(TPrinter& p)
|
|
|
|
|
{
|
|
|
|
|
const word page = form().page(p);
|
1995-03-22 09:07:04 +00:00
|
|
|
|
form().set_background(page, TRUE);
|
1994-12-20 15:11:26 +00:00
|
|
|
|
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();
|
1995-10-27 08:28:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm::arrange_form()
|
|
|
|
|
{
|
|
|
|
|
TString device;
|
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
|
char defPrinter[80];
|
|
|
|
|
char szDevice[50];
|
|
|
|
|
|
|
|
|
|
// get default printer driver
|
|
|
|
|
GetProfileString ("windows", "device", ",,,", defPrinter, sizeof(defPrinter));
|
|
|
|
|
TToken_string pdev (defPrinter, ',');
|
|
|
|
|
GetProfileString ("devices", pdev, "", szDevice, sizeof(szDevice));
|
|
|
|
|
pdev.add(szDevice);
|
|
|
|
|
device = pdev.get(2);
|
|
|
|
|
device = device.left(4); //Legge solo LPTx...
|
|
|
|
|
#endif
|
|
|
|
|
FILE* lpt = fopen(device,"w");
|
|
|
|
|
// Nota: siccome si scrive direttamente sulla porta, sarebbe necessario
|
|
|
|
|
// mandare una stringa di reset alla stampante, o per lo meno far si' che
|
|
|
|
|
// ogni volta che si fa il posizionamento il font col quale scrive sia sempre
|
|
|
|
|
// lo stesso. Tutto cio' non e' possibile con la generica solo testo, o meglio
|
|
|
|
|
// ad ogni stampa col posizionamento e' necessario che la stampante sia resettata.
|
|
|
|
|
// Riassumendo, come regola generale, i posizionamenti devono essere fatti con il
|
|
|
|
|
// font di default della stampante (tipicamente 10 cpi). Accade pero' (con la generica
|
|
|
|
|
// solo testo) che rimanga settato l'ultimo font, di conseguenza quando si effettua una
|
|
|
|
|
// seconda stampa con posizionamento, stampera' tali caratteri in 17"!!!! Per questo
|
1995-11-07 16:36:22 +00:00
|
|
|
|
// motivo e' necessario settare a 17 cpi, almeno la prima volta, la stampante!.
|
|
|
|
|
// Quindi, per ovviare a tutto cio, visto che TForm::arange_form() ha senso solo su
|
|
|
|
|
// stampanti ad aghi, che le stampanti ad aghi possono andare in emulazione EPSON o IBM,
|
|
|
|
|
// che il codice per settare il font draft 17cpi e' lo stesso sia per EPSON che IBM
|
|
|
|
|
// CHR(15), allora prima del posizionamento scrivo il chr(15) sulla stampante!
|
|
|
|
|
int i, x;
|
1995-10-27 08:28:13 +00:00
|
|
|
|
TString str_pos;
|
|
|
|
|
if (lpt == NULL) fatal_box("Non rieso ad aprire il device %s.",device);
|
|
|
|
|
TMask m("ba2100c");
|
|
|
|
|
|
|
|
|
|
// _ipy viene assunto uguale per entrambi i posizionamneti
|
|
|
|
|
str_pos << "\017"; // Questo e' 15 in ottale...
|
|
|
|
|
for (i=1; i < _ipy; i++) str_pos << "\n";
|
|
|
|
|
fprintf(lpt,"%s",(const char*) str_pos);
|
|
|
|
|
fflush(lpt); // Salta le righe...
|
1995-11-07 16:36:22 +00:00
|
|
|
|
fclose(lpt);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
str_pos.cut(0); //Azzera la stringa di posizionamento
|
|
|
|
|
for (i=1; i < _ipx; i++) str_pos << " "; //Aggiunge gli spazi necessari...
|
|
|
|
|
if (_ipx > 0 && _ipy > 0)
|
|
|
|
|
str_pos << _char_to_pos; // aggiunge il primo carattere di posizionamento...
|
|
|
|
|
x = _fpx - _ipx ; // calcola quanti spazi aggiungere...
|
|
|
|
|
for (i=1; i < x; i++) str_pos << " ";
|
|
|
|
|
if (_fpx > 0)
|
|
|
|
|
str_pos << _char_to_pos; // aggiunge il secondo carattere di posizionamento
|
1995-11-07 16:36:22 +00:00
|
|
|
|
TString bspc; bspc.fill('\b',str_pos.len()); // Questi servono per tornare indietro...
|
1995-10-27 08:28:13 +00:00
|
|
|
|
do
|
1995-11-07 16:36:22 +00:00
|
|
|
|
{
|
|
|
|
|
lpt = fopen(device,"w");
|
|
|
|
|
if (lpt == NULL) fatal_box("Non rieso ad aprire il device %s.",device);
|
1995-11-13 08:18:10 +00:00
|
|
|
|
// fprintf(lpt,"%s",(const char*) bspc);
|
|
|
|
|
fprintf(lpt,"%s\n",(const char*) str_pos);
|
1995-11-07 16:36:22 +00:00
|
|
|
|
fflush(lpt);
|
|
|
|
|
fclose(lpt);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
} while (m.run() == K_ESC); // cicla sulla stampa posizionamento...
|
|
|
|
|
const int h = height(odd_page);
|
|
|
|
|
str_pos.cut(0);
|
1995-11-13 08:18:10 +00:00
|
|
|
|
for (i=0; i < h; i++) str_pos << "\n";
|
1995-11-07 16:36:22 +00:00
|
|
|
|
lpt = fopen(device,"w");
|
|
|
|
|
if (lpt == NULL) fatal_box("Non rieso ad aprire il device %s.",device);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
fprintf(lpt, "%s", (const char*) str_pos); // Salta tante righe quanto e' lungo il form standard
|
|
|
|
|
fclose (lpt);
|
|
|
|
|
#if XVT_OS != XVT_OS_WIN
|
|
|
|
|
#pragma message ("Voglio proprio vedere come fai a gestire il posizionamento sotto Unix!")
|
|
|
|
|
#endif
|
|
|
|
|
}
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
long TForm::records() const
|
|
|
|
|
{
|
1995-11-27 08:39:18 +00:00
|
|
|
|
const long r = cursor() ? cursor()->items() : 0;
|
1994-12-28 11:01:33 +00:00
|
|
|
|
return r;
|
1995-12-15 11:35:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm::genera_fincatura(pagetype p, int y1, int y2, int* rows)
|
|
|
|
|
{
|
|
|
|
|
const TPrint_section* body = exist('B', p);
|
|
|
|
|
if (body == NULL) return FALSE;
|
|
|
|
|
|
|
|
|
|
TGraphic_section* grs = (TGraphic_section*)exist('G', p, TRUE);
|
|
|
|
|
word j = 0, start = 999, end = 0, wlast = 0;
|
|
|
|
|
word cols[MAXCOLUMNS];
|
|
|
|
|
|
|
|
|
|
for (word i = 0; i < body->fields(); i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& f = body->field(i);
|
|
|
|
|
if (!f.shown()) continue;
|
|
|
|
|
|
|
|
|
|
word x = f.x();
|
|
|
|
|
|
|
|
|
|
if (x < start) start = x;
|
|
|
|
|
if (x > end) { end = x; wlast = f.width(); }
|
1995-12-15 11:54:24 +00:00
|
|
|
|
if (!f.finkl())
|
|
|
|
|
cols[j++] = x;
|
1995-12-15 11:35:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// inner lines
|
|
|
|
|
for (i = 0; i < j; i++)
|
|
|
|
|
{
|
|
|
|
|
if (cols[i] != start)
|
|
|
|
|
{
|
|
|
|
|
TForm_line* l = new TForm_line(grs);
|
|
|
|
|
l->x() = cols[i]-1;
|
|
|
|
|
l->y() = (word)y1;
|
|
|
|
|
l->width() = 0;
|
|
|
|
|
l->height() = (int)(y2 - y1 + 1);
|
|
|
|
|
grs->add_field(l);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// box around
|
|
|
|
|
if (start != 999 && end != 0)
|
|
|
|
|
{
|
|
|
|
|
TForm_box* l = new TForm_box(grs);
|
|
|
|
|
l->x() = start;
|
|
|
|
|
l->y() = (word)y1;
|
|
|
|
|
l->width() = (int)(end + wlast - start + 1);
|
|
|
|
|
l->height() = (int)(y2 - y1 + 1);
|
|
|
|
|
grs->add_field(l);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// horizontal lines
|
|
|
|
|
if (start != 999 && end != 0)
|
|
|
|
|
for (i = 0; rows[i]; i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_line* l = new TForm_line(grs);
|
|
|
|
|
l->x() = start;
|
|
|
|
|
l->y() = (word)rows[i];
|
|
|
|
|
l->width() = (int)(end + wlast - start + 1);
|
|
|
|
|
l->height() = 0;
|
|
|
|
|
grs->add_field(l);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-12-15 11:35:47 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
// Stampa gli items dal from a to
|
|
|
|
|
// se to < 0 stampa fino alla fine del file
|
|
|
|
|
|
|
|
|
|
bool TForm::print(long from, long to)
|
1994-12-20 15:11:26 +00:00
|
|
|
|
{
|
1995-05-18 14:18:01 +00:00
|
|
|
|
_cur_form = this;
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-10-27 08:28:13 +00:00
|
|
|
|
if ((_char_to_pos != '\0' || ((_ipx +_ipy+_fpx) != 0)) && // Se i parametri di posizionamento sono settati e
|
|
|
|
|
(_x != 0 || _y != 0)) // cosi' pure gli offset genera un errore.
|
|
|
|
|
{
|
|
|
|
|
error_box("Non e' possibile settare contemporaneamente gli offset"
|
|
|
|
|
" e i parametri di posizionamento del modulo.");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
TPrinter& pr = printer();
|
|
|
|
|
if (_char_to_pos != '\0' || (_ipx +_ipy+_fpx) != 0) // Effettua il posizionamento del form...
|
|
|
|
|
{
|
|
|
|
|
if (pr.printtype() == screenvis)
|
|
|
|
|
error_box("Stampa a video selezionata. Non e' possibile effettuare il posizionamento.");
|
|
|
|
|
else
|
1995-11-09 13:40:20 +00:00
|
|
|
|
if (_arrange)
|
|
|
|
|
arrange_form();
|
1995-10-27 08:28:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr.setheaderhandler(header_handler); // Setta handlers
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.setfooterhandler(footer_handler);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
if (!pr.is_generic())
|
1995-10-16 17:52:24 +00:00
|
|
|
|
{
|
1995-10-27 08:28:13 +00:00
|
|
|
|
for (pagetype t = odd_page; t <= last_page; t = pagetype(t+1))
|
|
|
|
|
{
|
|
|
|
|
if (height(t)> (word)pr.formlen())
|
|
|
|
|
{
|
|
|
|
|
TString s("La lunghezza totale della sezione ");
|
|
|
|
|
switch ( t )
|
|
|
|
|
{
|
|
|
|
|
case odd_page:
|
|
|
|
|
s << "standard"; break;
|
|
|
|
|
case even_page:
|
|
|
|
|
s << "pagine pari"; break;
|
|
|
|
|
case first_page:
|
|
|
|
|
s << "prima pagina"; break;
|
|
|
|
|
case last_page:
|
|
|
|
|
s << "ultima pagina"; break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
s << " eccede la lunghezza reale del foglio.";
|
|
|
|
|
message_box(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pr.formlen(height(odd_page));
|
1995-10-16 17:52:24 +00:00
|
|
|
|
}
|
1995-08-31 15:16:13 +00:00
|
|
|
|
pr.set_char_size(_fontsize); // Set font name and size
|
|
|
|
|
pr.set_fontname(_fontname); // according to current form
|
1995-04-20 14:35:14 +00:00
|
|
|
|
const bool was_open = pr.isopen();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-12-12 13:35:59 +00:00
|
|
|
|
set_last_page(FALSE); // non e' l'ultima pagina
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
|
|
set_background(1, TRUE);
|
1995-01-05 17:50:40 +00:00
|
|
|
|
|
1995-04-20 14:35:14 +00:00
|
|
|
|
if (!was_open && !pr.open())
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return FALSE;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
do_events();
|
|
|
|
|
|
1995-10-09 15:42:33 +00:00
|
|
|
|
long lastrec= records()-1;
|
|
|
|
|
|
|
|
|
|
if (to < 0) to = lastrec;
|
|
|
|
|
if (to == lastrec) to--; // l'ultima pagina <20> gestita come caso particolare
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
for (long i = from; i <= to && ok; i++)
|
|
|
|
|
{
|
|
|
|
|
if (from < 0) to = from;
|
1995-11-27 08:39:18 +00:00
|
|
|
|
else if (cursor()) *cursor() = i;
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-04-20 14:35:14 +00:00
|
|
|
|
const word h = set_body(page(pr), FALSE);
|
|
|
|
|
if (h > pr.rows_left())
|
|
|
|
|
pr.formfeed();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-04-20 14:35:14 +00:00
|
|
|
|
set_body(page(pr), TRUE);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1995-10-09 15:42:33 +00:00
|
|
|
|
if (i == lastrec)
|
1994-12-20 15:11:26 +00:00
|
|
|
|
{
|
1995-11-27 08:39:18 +00:00
|
|
|
|
if (cursor()) *cursor() = i;
|
1995-12-12 13:35:59 +00:00
|
|
|
|
set_last_page(TRUE);
|
1995-10-09 15:42:33 +00:00
|
|
|
|
set_background(0, TRUE);
|
|
|
|
|
set_header(0, TRUE);
|
|
|
|
|
set_body(0, TRUE);
|
|
|
|
|
pr.formfeed();
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
if (!was_open)
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.close();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1995-04-20 14:35:14 +00:00
|
|
|
|
pr.setheaderhandler(NULL);
|
|
|
|
|
pr.setfooterhandler(NULL);
|
1995-05-18 14:18:01 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
void TForm::print_section(ostream& out, char s) const
|
1994-12-20 15:11:26 +00:00
|
|
|
|
{
|
1994-12-27 14:59:25 +00:00
|
|
|
|
for (pagetype t = odd_page; t <= last_page; t = pagetype(t+1))
|
1994-12-20 15:11:26 +00:00
|
|
|
|
{
|
1994-12-27 14:59:25 +00:00
|
|
|
|
const TPrint_section* sec = ((TForm*)this)->exist(s, t);
|
1994-12-28 11:01:33 +00:00
|
|
|
|
if (sec && sec->ok())
|
1994-12-27 14:59:25 +00:00
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
|
const char* name;
|
|
|
|
|
switch (s)
|
|
|
|
|
{
|
1995-04-20 14:35:14 +00:00
|
|
|
|
case 'F':
|
|
|
|
|
name = "FOOTER"; break;
|
|
|
|
|
case 'G':
|
|
|
|
|
name = "GRAPHICS"; break;
|
|
|
|
|
case 'H':
|
|
|
|
|
name = "HEADER"; break;
|
|
|
|
|
default :
|
|
|
|
|
name = "BODY"; break;
|
|
|
|
|
}
|
1995-05-18 14:18:01 +00:00
|
|
|
|
out << "SECTION " << name;
|
1994-12-27 14:59:25 +00:00
|
|
|
|
out << *sec;
|
|
|
|
|
out << "END\n" << endl;
|
|
|
|
|
}
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
1995-02-09 14:47:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-07-19 09:57:25 +00:00
|
|
|
|
bool TForm::validate(TForm_item& f, TToken_string&)
|
|
|
|
|
{ return FALSE; }
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
|
|
|
|
void TForm::print_on(ostream& out) const
|
1995-01-04 15:39:38 +00:00
|
|
|
|
{
|
|
|
|
|
main_app().begin_wait();
|
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
if (relation())
|
1995-05-29 10:25:10 +00:00
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
|
out << *relation() << "\nEND" << endl;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
print_description(out);
|
1995-08-31 15:16:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print_general(out);
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
|
print_section(out, 'G');
|
1994-12-27 14:59:25 +00:00
|
|
|
|
print_section(out, 'H');
|
|
|
|
|
print_section(out, 'B');
|
|
|
|
|
print_section(out, 'F');
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
|
|
|
|
out << "END" << endl;
|
1995-01-04 15:39:38 +00:00
|
|
|
|
|
|
|
|
|
main_app().end_wait();
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
|
1995-10-16 17:52:24 +00:00
|
|
|
|
word TForm::height(word page)
|
1994-12-27 14:59:25 +00:00
|
|
|
|
{
|
|
|
|
|
word h = 0;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
|
|
if (_back.items() == 0)
|
|
|
|
|
{
|
1995-10-16 17:52:24 +00:00
|
|
|
|
if (_head.items() && exist('H', pagetype(page)) != NULL)
|
|
|
|
|
h += section('H', page).height();
|
|
|
|
|
if (_body.items() && exist('B', pagetype(page)) != NULL)
|
|
|
|
|
h += section('B', page).height();
|
|
|
|
|
if (_foot.items() && exist('F', pagetype(page)) != NULL)
|
|
|
|
|
h += section('F', page).height();
|
1995-03-22 09:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1995-04-20 14:35:14 +00:00
|
|
|
|
h = printer().formlen();
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
return h;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
bool TForm::read_profile()
|
1995-08-31 15:16:13 +00:00
|
|
|
|
{
|
|
|
|
|
TLocalisamfile prof(LF_FORM);
|
|
|
|
|
TLocalisamfile rprof(LF_RFORM);
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
prof.zero();
|
1995-08-31 15:16:13 +00:00
|
|
|
|
prof.put("TIPOPROF",_name);
|
|
|
|
|
prof.put("CODPROF",_code);
|
|
|
|
|
if (prof.read(_isequal) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
rprof.zero();
|
|
|
|
|
rprof.put("TIPOPROF", _name);
|
|
|
|
|
rprof.put("CODPROF", _code);
|
|
|
|
|
const TRectype filter(rprof.curr());
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
1995-08-31 15:16:13 +00:00
|
|
|
|
for (int err = rprof.read(_isgteq); err == NOERR && rprof.curr() == filter; err = rprof.next())
|
|
|
|
|
{
|
|
|
|
|
const TString& s = rprof.get("SEZ");
|
|
|
|
|
const char sec = s[0];
|
|
|
|
|
const pagetype pt = char2page(s[1]);
|
|
|
|
|
const short id = rprof.get_int("ID");
|
|
|
|
|
|
|
|
|
|
if (id == 0)
|
|
|
|
|
{
|
|
|
|
|
TPrint_section& se = section(sec, pt);
|
|
|
|
|
se.read_from(rprof.curr());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TForm_item& item = find_field(sec, pt, id);
|
|
|
|
|
item.read_from(rprof.curr());
|
|
|
|
|
}
|
1995-11-13 08:18:10 +00:00
|
|
|
|
}
|
|
|
|
|
if (_code.not_empty()&& !_isnew)
|
|
|
|
|
{
|
1995-08-31 15:16:13 +00:00
|
|
|
|
_x = prof.get_int("OFFX");
|
|
|
|
|
_y = prof.get_int("OFFY");
|
|
|
|
|
_fontname = prof.get("FONTNAME");
|
|
|
|
|
_fontsize = prof.get_int("FONTSIZE");
|
1995-10-31 09:02:00 +00:00
|
|
|
|
_char_to_pos = prof.get("CTP")[0];
|
1995-10-27 08:28:13 +00:00
|
|
|
|
_ipx = prof.get_int("IPX");
|
|
|
|
|
_ipy = prof.get_int("IPY");
|
|
|
|
|
_fpx = prof.get_int("FPX");
|
1995-05-29 10:25:10 +00:00
|
|
|
|
}
|
1995-08-31 15:16:13 +00:00
|
|
|
|
}
|
1995-05-18 14:18:01 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TForm::write_profile()
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1995-05-29 10:25:10 +00:00
|
|
|
|
const char sechar[4] = { 'B', 'F', 'G', 'H' };
|
|
|
|
|
|
1995-08-31 15:16:13 +00:00
|
|
|
|
TLocalisamfile form(LF_FORM);
|
|
|
|
|
form.zero();
|
|
|
|
|
form.put("TIPOPROF",_name);
|
|
|
|
|
form.put("CODPROF",_code);
|
|
|
|
|
if (form.read(_isequal,_lock) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
if (_dirty)
|
|
|
|
|
{
|
|
|
|
|
form.put("OFFY",_y);
|
|
|
|
|
form.put("OFFX",_x);
|
|
|
|
|
form.put("FONTNAME",_fontname);
|
|
|
|
|
form.put("FONTSIZE",_fontsize);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
form.put("CTP",_char_to_pos);
|
|
|
|
|
form.put("IPX", _ipx);
|
|
|
|
|
form.put("IPY", _ipy);
|
|
|
|
|
form.put("FPX", _fpx);
|
1995-08-31 15:16:13 +00:00
|
|
|
|
form.rewrite();
|
|
|
|
|
_dirty=FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TLocalisamfile rform(LF_RFORM);
|
|
|
|
|
TRectype& cur = rform.curr();
|
|
|
|
|
|
|
|
|
|
int err = NOERR;
|
|
|
|
|
for (int sn = 0; sn < 4 && err == NOERR; sn++) // For each section
|
|
|
|
|
{
|
|
|
|
|
const char sc = sechar[sn];
|
|
|
|
|
for (pagetype pt = odd_page; pt <= last_page; pt = pagetype(pt+1)) // For each section type
|
|
|
|
|
{
|
|
|
|
|
TPrint_section* sec = exist(sc, pt);
|
|
|
|
|
if (sec != NULL && sec->dirty())
|
|
|
|
|
{
|
|
|
|
|
const char codsez[3] = { sc, pt+'0', '\0' };
|
|
|
|
|
cur.zero();
|
|
|
|
|
cur.put("TIPOPROF", name());
|
|
|
|
|
cur.put("CODPROF", code());
|
|
|
|
|
cur.put("SEZ", codsez);
|
|
|
|
|
sec->print_on(cur);
|
|
|
|
|
sec->set_dirty(FALSE);
|
|
|
|
|
|
|
|
|
|
err = _isnew ? rform.write() : rform.rewrite();
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
err = _isnew ? rform.rewrite() : rform.write();
|
|
|
|
|
|
|
|
|
|
for (word i = 0; i < sec->fields() && err == NOERR; i++)
|
|
|
|
|
{
|
|
|
|
|
TForm_item& fi = sec->field(i);
|
|
|
|
|
if (fi.dirty())
|
|
|
|
|
{
|
|
|
|
|
fi.print_on(cur);
|
|
|
|
|
err = _isnew ? rform.write() : rform.rewrite();
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
err = _isnew ? rform.rewrite() : rform.write();
|
|
|
|
|
fi.set_dirty(FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1995-08-31 15:16:13 +00:00
|
|
|
|
form.reread(_unlock);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (err != NOERR)
|
|
|
|
|
return error_box("Errore di salvataggio profilo: %d", err);
|
|
|
|
|
|
1995-05-18 14:18:01 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-04 10:27:42 +00:00
|
|
|
|
void TForm::init()
|
|
|
|
|
{
|
1995-12-11 17:36:57 +00:00
|
|
|
|
_relation= NULL;
|
|
|
|
|
_cursor= NULL;
|
|
|
|
|
_rel_desc= NULL;
|
|
|
|
|
_isnew= FALSE;
|
|
|
|
|
_fontname= "Roman 17cpi";
|
|
|
|
|
_fontsize= 12;
|
|
|
|
|
_x= 0;
|
|
|
|
|
_y= 0;
|
|
|
|
|
_char_to_pos= '\0';
|
|
|
|
|
_ipx= 0;
|
|
|
|
|
_ipy= 0;
|
|
|
|
|
_fpx= 0;
|
|
|
|
|
_arrange= TRUE;
|
|
|
|
|
_fink= "+,+,+,+,+,+,+,+,+,-,|";
|
|
|
|
|
_fink.separator(',');
|
1995-12-15 11:35:47 +00:00
|
|
|
|
_dirty= FALSE;
|
|
|
|
|
_background_mode = printer().isgraphics() ? graphics : text;
|
1995-12-04 10:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TForm::read(const char* name, const char* code, int lev, const char* desc)
|
|
|
|
|
{
|
1995-12-11 17:36:57 +00:00
|
|
|
|
_name= name;
|
|
|
|
|
_code= code;
|
|
|
|
|
_editlevel= lev;
|
|
|
|
|
_desc= desc;
|
1995-12-04 10:27:42 +00:00
|
|
|
|
|
1995-01-03 15:06:43 +00:00
|
|
|
|
main_app().begin_wait();
|
1995-05-18 14:18:01 +00:00
|
|
|
|
|
1995-11-27 08:39:18 +00:00
|
|
|
|
if (_code.not_empty())
|
1995-05-18 14:18:01 +00:00
|
|
|
|
{
|
|
|
|
|
// extract base form name
|
1995-05-29 10:25:10 +00:00
|
|
|
|
TLocalisamfile forms(LF_FORM);
|
|
|
|
|
forms.zero();
|
|
|
|
|
|
|
|
|
|
forms.put("TIPOPROF", _name);
|
|
|
|
|
forms.put("CODPROF", _code);
|
|
|
|
|
_isnew = forms.read() != NOERR;
|
1995-05-18 14:18:01 +00:00
|
|
|
|
if (_isnew)
|
|
|
|
|
{
|
|
|
|
|
// create new form
|
1995-05-29 10:25:10 +00:00
|
|
|
|
forms.put("TIPOPROF", _name);
|
|
|
|
|
forms.put("CODPROF", _code);
|
1995-06-07 10:47:05 +00:00
|
|
|
|
forms.put("DESC", _desc);
|
1995-08-31 15:16:13 +00:00
|
|
|
|
forms.put("OFFY",_y);
|
|
|
|
|
forms.put("OFFX",_x);
|
|
|
|
|
forms.put("FONTNAME",_fontname);
|
|
|
|
|
forms.put("FONTSIZE",_fontsize);
|
1995-10-27 08:28:13 +00:00
|
|
|
|
forms.put("CTP", _char_to_pos);
|
|
|
|
|
forms.put("IPX", _ipx);
|
|
|
|
|
forms.put("IPY", _ipy);
|
|
|
|
|
forms.put("FPX", _fpx);
|
1995-05-29 10:25:10 +00:00
|
|
|
|
forms.write();
|
1995-05-18 14:18:01 +00:00
|
|
|
|
}
|
1995-05-29 10:25:10 +00:00
|
|
|
|
else _desc = forms.get("DESC");
|
1995-05-18 14:18:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
// read base form
|
|
|
|
|
TFilename n(_name); n.ext("frm");
|
|
|
|
|
TScanner scanner(n);
|
1994-11-10 14:17:03 +00:00
|
|
|
|
|
1994-12-20 15:11:26 +00:00
|
|
|
|
bool ok = TRUE;
|
1995-03-22 09:07:04 +00:00
|
|
|
|
if (scanner.popkey() == "US") // Parse relation
|
1994-11-10 14:17:03 +00:00
|
|
|
|
{
|
1994-12-20 15:11:26 +00:00
|
|
|
|
ok = parse_use(scanner);
|
|
|
|
|
while (ok && scanner.popkey() == "JO")
|
1995-05-09 09:12:26 +00:00
|
|
|
|
ok = parse_join(scanner);
|
|
|
|
|
|
1995-05-29 10:25:10 +00:00
|
|
|
|
parse_description(scanner); // Parse description
|
1995-03-22 09:07:04 +00:00
|
|
|
|
}
|
1995-05-09 09:12:26 +00:00
|
|
|
|
else scanner.push();
|
1995-08-31 15:16:13 +00:00
|
|
|
|
|
|
|
|
|
if (ok) parse_general(scanner); // Parse general
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1994-12-27 14:59:25 +00:00
|
|
|
|
while (ok)
|
1995-03-22 09:07:04 +00:00
|
|
|
|
{
|
|
|
|
|
if (scanner.popkey() != "SE") // SECTION or END
|
1994-12-27 14:59:25 +00:00
|
|
|
|
break;
|
1995-05-18 14:18:01 +00:00
|
|
|
|
const char sec = scanner.popkey()[0]; // Section name (GRAPH, HEAD, BODY, FOOT)
|
|
|
|
|
const pagetype p = char2page(scanner.popkey()[0]); // Section type (odd, even, first, last)
|
1995-03-22 09:07:04 +00:00
|
|
|
|
TPrint_section* ps = exist(sec, p, TRUE); // Create section
|
|
|
|
|
ok = ps->parse(scanner); // Parse section
|
1994-12-20 15:11:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-11-27 08:39:18 +00:00
|
|
|
|
if (_code.not_empty())
|
1995-05-29 10:25:10 +00:00
|
|
|
|
read_profile(); // read from LF_RFORM file
|
1995-05-09 09:12:26 +00:00
|
|
|
|
|
1995-01-03 15:06:43 +00:00
|
|
|
|
main_app().end_wait();
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-12-04 10:27:42 +00:00
|
|
|
|
TForm::TForm()
|
|
|
|
|
{
|
1995-12-11 17:36:57 +00:00
|
|
|
|
init();
|
1995-12-04 10:27:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TForm::TForm(const char* name, const char* code, int lev, const char* desc)
|
|
|
|
|
{
|
1995-12-11 17:36:57 +00:00
|
|
|
|
init();
|
|
|
|
|
read(name, code, lev, desc);
|
1995-12-04 10:27:42 +00:00
|
|
|
|
}
|
1994-12-20 15:11:26 +00:00
|
|
|
|
|
1994-11-10 14:17:03 +00:00
|
|
|
|
TForm::~TForm()
|
|
|
|
|
{
|
|
|
|
|
if (_cursor)
|
|
|
|
|
{
|
|
|
|
|
delete _cursor;
|
1995-05-09 09:12:26 +00:00
|
|
|
|
delete _relation;
|
1995-05-29 10:25:10 +00:00
|
|
|
|
if (_rel_desc)
|
|
|
|
|
delete _rel_desc;
|
1994-11-10 14:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1995-05-29 10:25:10 +00:00
|
|
|
|
|
|
|
|
|
|